From 7c870e6eabd53f7a8cb0c9b5ecb477797b4de09a Mon Sep 17 00:00:00 2001 From: Elizabeth Alexander Hunt Date: Sun, 11 Oct 2026 14:22:26 -0700 Subject: Scroll some pixels on the fuckin screen --- src/video.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/video.c (limited to 'src/video.c') 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; +} -- cgit v1.3