aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/framebuffer.cpp
diff options
context:
space:
mode:
authorEmu <89668582+EmulatedSeasons@users.noreply.github.com>2024-05-31 23:38:46 -0400
committerGitHub <noreply@github.com>2024-05-31 23:38:46 -0400
commit27a44e0d79d1c6e01cd832feb8ad958d5999b5e3 (patch)
tree3759eb02fcad7a609a064080d81b7c6f9dbec4c8 /kernel/framebuffer.cpp
parent639240bbf498195912d8ceb6cb396b89391a5b1b (diff)
parentfd5a1699592ce0afafc42ebf22401596abcdfc28 (diff)
Merge pull request #1 from EmulatedSeasons/limineswitch
Limineswitch
Diffstat (limited to 'kernel/framebuffer.cpp')
-rw-r--r--kernel/framebuffer.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/kernel/framebuffer.cpp b/kernel/framebuffer.cpp
new file mode 100644
index 0000000..62ffee7
--- /dev/null
+++ b/kernel/framebuffer.cpp
@@ -0,0 +1,37 @@
+#include <framebuffer.h>
+#include <stdint.h>
+#include <stddef.h>
+
+uint32_t* fb_addr;
+uint32_t fb_width;
+uint32_t fb_height;
+
+void fb_init(uint32_t* addr, uint32_t width, uint32_t height) {
+ fb_addr = addr;
+ fb_width = width;
+ fb_height = height;
+ fb_clear();
+}
+
+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 draw_pixel(const uint32_t x, const uint32_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 uint32_t x_pos, const uint32_t y_pos, const uint32_t width, const uint32_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