summaryrefslogtreecommitdiff
path: root/src/kernel.c
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-10-11 14:22:26 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-10-11 14:27:23 -0700
commit7c870e6eabd53f7a8cb0c9b5ecb477797b4de09a (patch)
tree9c52c9ffb4f036ffcbeb785b8ed2b8bd0dfbf61a /src/kernel.c
parentc74bd1baa844eac1fcb17a266ef720ed0c1ae616 (diff)
downloadmacaroni-7c870e6eabd53f7a8cb0c9b5ecb477797b4de09a.tar.gz
macaroni-7c870e6eabd53f7a8cb0c9b5ecb477797b4de09a.zip
Scroll some pixels on the fuckin screenHEADmain
Diffstat (limited to 'src/kernel.c')
-rw-r--r--src/kernel.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/kernel.c b/src/kernel.c
index 2c2afcc..dacc47e 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -1,28 +1,33 @@
-#include "utils.h"
-#include "multiboot.h"
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
+#include "utils.h"
+#include "multiboot.h"
+#include "io.h"
+#include "video.h"
-void validate_multiboot
+void validate_multiboot(multiboot_info_t* p_multiboot_info, uint32_t magic_response) {
+ macaroni_assert(magic_response == 0x2BADB002, "im not a bad boo twooo");
+ macaroni_assert(p_multiboot_info->flags != 0, "version flag being zero is not a good sign");
+}
-void cmain(void) {
- uint32_t magic_response;
- multiboot_info_t* p_multiboot_info;
- asm("\t movl %%eax,%0" : "=r"(magic_response));
- asm("\t movl %%ebx,%0" : "=r"(p_multiboot_info));
+// Stack: [...Bottom] (%ebx, %eax) [...Top]
+void cmain(uint32_t magic_response, multiboot_info_t* p_multiboot_info) {
+ validate_multiboot(p_multiboot_info, magic_response);
- macaroni_assert(magic_response == 0x2BADB002, "im not a bad boo twooo");
- macaroni_assert(p_multiboot_info->framebuffer_width == 640, "not gods width");
- macaroni_assert(p_multiboot_info->framebuffer_height == 480, "not gods height");
- macaroni_assert(p_multiboot_info->framebuffer_bpp == 16, "not gods bpp");
- macaroni_assert(p_multiboot_info->framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_RGB, "not gods fbtype");
- macaroni_assert(p_multiboot_info->framebuffer_red_field_position == 1, "bpp not formatted correctly");
+ init_serial();
+ init_video(p_multiboot_info);
- void *fb = (void *) (unsigned long) p_multiboot_info->framebuffer_addr;
- uint8_t* pixel = fb;
- for (int i = 0; i < 10000; i++) {
- *(pixel + i) = i * 2;
+ macaroni_color colors[] = { RED, GREEN, BLUE };
+ uint32_t i = 0;
+ while(true) {
+ for (uint32_t y = 0; y < MULTIBOOT_GODS_HEIGHT; y++) {
+ for (uint32_t x = 0; x < MULTIBOOT_GODS_WIDTH; x++) {
+ put_pixel(colors[(i + y / 10) % 3], x, y);
+ }
+ }
+ // "sleep"
+ for (int _k = 0; _k < 10000000; _k++) {}
+ i++;
}
-
}