summaryrefslogtreecommitdiff
path: root/src/kernel.c
blob: dacc47e946837114f50cb89185fc2c0f4f6d7d97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "utils.h"
#include "multiboot.h"
#include "io.h"
#include "video.h"

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");
}

// Stack: [...Bottom] (%ebx, %eax) [...Top]
void cmain(uint32_t magic_response, multiboot_info_t* p_multiboot_info) {
    validate_multiboot(p_multiboot_info, magic_response);

    init_serial();
    init_video(p_multiboot_info);

    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++;
    }
}