diff options
author | Marvin Borner | 2020-07-22 16:32:32 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-22 16:32:32 +0200 |
commit | 5121d4bc820b39901461c759a8fbd57d3a8462e3 (patch) | |
tree | 467775459de88994df48bcaeaed9b39d7703a6e4 /src | |
parent | 881a837adb930a0a3316ab57da95d46c1943f3f1 (diff) |
Switched to Makefile.
Kinda for the sake of minimalism
Diffstat (limited to 'src')
-rw-r--r-- | src/drivers/vesa.c | 25 | ||||
-rw-r--r-- | src/inc/vesa.h | 53 | ||||
-rw-r--r-- | src/main.c | 11 |
3 files changed, 85 insertions, 4 deletions
diff --git a/src/drivers/vesa.c b/src/drivers/vesa.c new file mode 100644 index 0000000..ca130db --- /dev/null +++ b/src/drivers/vesa.c @@ -0,0 +1,25 @@ +#include <def.h> +#include <vesa.h> + +void vesa_draw_rectangle(int x1, int y1, int x2, int y2, const u32 color[3]) +{ + int vbe_bpl = vbe->bpp >> 3; + int vbe_pitch = vbe->pitch; + u8 *fb = (u8 *)vbe->framebuffer; + + int pos1 = x1 * vbe_bpl + y1 * vbe_pitch; + char *draw = (char *)&fb[pos1]; + for (int i = 0; i <= y2 - y1; i++) { + for (int j = 0; j <= x2 - x1; j++) { + draw[vbe_bpl * j] = (char)color[2]; + draw[vbe_bpl * j + 1] = (char)color[1]; + draw[vbe_bpl * j + 2] = (char)color[0]; + } + draw += vbe_pitch; + } +} + +void vesa_clear(const u32 color[3]) +{ + vesa_draw_rectangle(0, 0, vbe->width - 1, vbe->height - 1, color); +} diff --git a/src/inc/vesa.h b/src/inc/vesa.h new file mode 100644 index 0000000..e2ac4e5 --- /dev/null +++ b/src/inc/vesa.h @@ -0,0 +1,53 @@ +#ifndef VBE_H +#define VBE_H + +#include <def.h> + +struct vbe { + u16 attributes; + u8 window_a; + u8 window_b; + u16 granularity; + u16 window_size; + u16 segment_a; + u16 segment_b; + u32 win_func_ptr; + u16 pitch; + u16 width; + u16 height; + u8 w_char; + u8 y_char; + u8 planes; + u8 bpp; + u8 banks; + u8 memory_model; + u8 bank_size; + u8 image_pages; + u8 reserved0; + + u8 red_mask; + u8 red_position; + u8 green_mask; + u8 green_position; + u8 blue_mask; + u8 blue_position; + u8 reserved_mask; + u8 reserved_position; + u8 direct_color_attributes; + + u32 framebuffer; + u32 off_screen_mem_off; + u16 off_screen_mem_size; + u8 reserved1[206]; +}; + +struct vid_info { + u32 mode; + struct vbe *info; +}; + +struct vbe *vbe; + +void vesa_clear(const u32 color[3]); + +#endif @@ -1,11 +1,14 @@ #include <def.h> +#include <vesa.h> -// This must kinda be at the top -int main(u32 *mem_info, u32 *vid_info) +void main(u32 *mem_info, struct vid_info *vid_info) { mem_info++; // TODO: Use the mmap! - vid_info++; // TODO: Use the VBE struct! + vbe = vid_info->info; + + u32 terminal_background[3] = { 0x1d, 0x1f, 0x24 }; + vesa_clear(terminal_background); + while (1) { }; - return 0; } |