diff options
| author | EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-05-10 01:44:59 -0400 |
|---|---|---|
| committer | EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-05-10 01:44:59 -0400 |
| commit | 975a9ec96e282e437ccc1bdf1e660dcbf4542791 (patch) | |
| tree | 29bdbd7769d59df82c6bace1d653c8be310c2d08 /kernel/framebuffer.cpp | |
| parent | abaab98bd757cd0818cfcddc983eee25ab7672ed (diff) | |
Added GDT and basic IDT as well as a bitmap drawing function
Diffstat (limited to 'kernel/framebuffer.cpp')
| -rw-r--r-- | kernel/framebuffer.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
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 <stdint.h>
#include <stddef.h>
-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 |
