aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/graphics/vesa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/graphics/vesa.c')
-rw-r--r--src/kernel/graphics/vesa.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index 3549d66..af2502b 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -1,11 +1,42 @@
#include "vesa.h"
-extern struct vbe_best vbe_find_mode();
+vbe_mode_info *vbe_set_mode(unsigned short mode) {
+ regs16_t regs;
+ regs.ax = 0x4F02;
+ regs.bx = mode | (1 << 14);
+ int32(0x10, &regs);
-extern void vbe_set_mode(struct vbe_best);
+ if (regs.ax == 0x004F) {
+ regs.ax = 0x4F01;
+ regs.cx = mode;
+ regs.di = 0x0000;
+ regs.es = 0xA000;
+ int32(0x10, &regs);
+ if (regs.ax != 0x004F) {
+ // Add VGA redirect
+ }
-struct vbe_best best;
+ vbe_mode_info *vbe_info = (vbe_mode_info *) 0xA0000;
-void init_graphics() {
- best = vbe_find_mode();
-} \ No newline at end of file
+ vbe_width = vbe_info->width;
+ vbe_height = vbe_info->height;
+ vbe_bpp = vbe_info->bpp / 8;
+ vbe_pitch = vbe_info->pitch;
+
+ char *fb = (char *) vbe_info->framebuffer;
+ for (int i = 0; i < 640 * 480 * 3; i++) {
+ fb[i] = 100;
+ }
+ regs.ax = 0x0000;
+ int32(0x16, &regs);
+ regs.ax = 0x0003;
+ int32(0x10, &regs);
+
+ return vbe_info;
+ } else {
+ // Add VGA redirect
+ }
+
+ vbe_mode_info vbe_info;
+ return &vbe_info;
+}