c1ad0fc5/1/2026, 8:41:11 PM
~kernel/vga.c
.c
C
(text/x-csrc)
#include <stdint.h>
#include "module.h"

static volatile uint16_t* VGA = (volatile uint16_t*)0xB8000;
static int row = 0;
static int col = 0;

void vga_putc(char c) {
    if (c == '\n') { row++; col = 0; return; }
    uint16_t attr = (0x0f << 8);
    VGA[row * 80 + col] = (uint16_t)c | attr;
    col++;
    if (col >= 80) { col = 0; row++; }
    if (row >= 25) { for (int i=0;i<80*25;i++) VGA[i]=0; row=0; }
}

void vga_write(const char* s) {
    for (const char* p = s; *p; p++) vga_putc(*p);
}