From 975a9ec96e282e437ccc1bdf1e660dcbf4542791 Mon Sep 17 00:00:00 2001 From: EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> Date: Fri, 10 May 2024 01:44:59 -0400 Subject: Added GDT and basic IDT as well as a bitmap drawing function --- kernel/framebuffer.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'kernel/framebuffer.cpp') diff --git a/kernel/framebuffer.cpp b/kernel/framebuffer.cpp index a07d61a..ca6ddb6 100644 --- a/kernel/framebuffer.cpp +++ b/kernel/framebuffer.cpp @@ -2,21 +2,36 @@ #include #include -Framebuffer::Framebuffer(uint32_t* addr, const uint64_t width, const uint64_t height) - : addr {addr}, width {width}, height {height} { - clear(); +uint32_t* fb_addr; +uint64_t fb_width; +uint64_t fb_height; + +void fb_init(uint32_t* addr, uint64_t width, uint64_t height) { + fb_addr = addr; + fb_width = width; + fb_height = height; + fb_clear(); } -void Framebuffer::clear() { - for (size_t y = 0; y < height; y++) { - for (size_t x = 0; x < width; x++) { - const size_t i = y * width + x; - addr[i] = 0x000000; +void fb_clear() { + for (size_t y = 0; y < fb_height; y++) { + for (size_t x = 0; x < fb_width; x++) { + const size_t i = y * fb_width + x; + fb_addr[i] = 0x000000; } } } -void Framebuffer::drawpixel(const uint64_t x, const uint64_t y, const uint32_t color) { - const size_t pos = y * width + x; - addr[pos] = color; +void draw_pixel(const uint64_t x, const uint64_t y, const uint32_t color) { + const size_t pos = y * fb_width + x; + fb_addr[pos] = color; +} + +void draw_bitmap(const uint32_t* bitmap, const uint64_t x_pos, const uint64_t y_pos, const uint64_t width, const uint64_t height) { + for (size_t y = 0; y < height; y++) { + for (size_t x = 0; x < width; x++) { + const size_t i = y * width + x; + draw_pixel(x_pos + x, y_pos + y, bitmap[i]); + } + } } \ No newline at end of file -- cgit v1.2.3-70-g09d2