diff options
| author | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-10-11 14:22:26 -0700 |
|---|---|---|
| committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-10-11 14:27:23 -0700 |
| commit | 7c870e6eabd53f7a8cb0c9b5ecb477797b4de09a (patch) | |
| tree | 9c52c9ffb4f036ffcbeb785b8ed2b8bd0dfbf61a /src/video.c | |
| parent | c74bd1baa844eac1fcb17a266ef720ed0c1ae616 (diff) | |
| download | macaroni-main.tar.gz macaroni-main.zip | |
Diffstat (limited to 'src/video.c')
| -rw-r--r-- | src/video.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/video.c b/src/video.c new file mode 100644 index 0000000..be01f6d --- /dev/null +++ b/src/video.c @@ -0,0 +1,33 @@ +#include "video.h" +#include "utils.h" +#include "io.h" + +void init_video(multiboot_info_t* p_multiboot_info) { + #ifdef DEBUG + macaroni_assert(p_multiboot_info->framebuffer_width == MULTIBOOT_GODS_WIDTH, "not gods width"); + macaroni_assert(p_multiboot_info->framebuffer_height == MULTIBOOT_GODS_HEIGHT, "not gods height"); + macaroni_assert(p_multiboot_info->framebuffer_bpp == MULTIBOOT_VIDEO_BPP, "not gods bpp"); + macaroni_assert(p_multiboot_info->framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB, "not video fbtype"); + #endif + + #ifdef DEBUG + serial_puthex((uint32_t) p_multiboot_info->framebuffer_red_field_position); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_red_mask_size); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_green_field_position); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_green_mask_size); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_blue_field_position); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_blue_mask_size); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_bpp); + serial_puthex((uint32_t) p_multiboot_info->framebuffer_pitch); + #endif // DEBUG + + video_framebuffer = (uint8_t*) (uint32_t) p_multiboot_info->framebuffer_addr; + pixel_width = (p_multiboot_info->framebuffer_bpp / 8); + pitch = p_multiboot_info->framebuffer_pitch; +} + +void put_pixel(macaroni_color color, uint16_t x, uint16_t y) { + video_framebuffer[x * pixel_width + y * pitch] = color & 0xFF; + video_framebuffer[x * pixel_width + y * pitch + 1] = (color >> 8) & 0xFF; + video_framebuffer[x * pixel_width + y * pitch + 2] = (color >> 16) & 0xFF; +} |
