From 634681ce2bb36cd686943102a0f071cd6a09049f Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Wed, 27 Aug 2025 21:22:55 +1000 Subject: fixed bugs and revolutionized the universe --- ROMs/hello_c.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'ROMs/hello_c.c') diff --git a/ROMs/hello_c.c b/ROMs/hello_c.c index f670952..9cf7a96 100644 --- a/ROMs/hello_c.c +++ b/ROMs/hello_c.c @@ -1,7 +1,55 @@ +#include "ROMs/font.bin" + +int drawChar(int ch, int x, int y, int color) +{ + // adjust for jmp instruction + char* fontStart = 0x1FFF + 2; + int charStart = ch * 8; + + for (int yOff = 0; yOff < 8; yOff++) + { + int row = fontStart[charStart + yOff]; + + for (int xOff = 0; xOff < 8; xOff++) + { + int bit = (row >> (7 - xOff)) & 1; + int pix = bit ? 0 : color; + setPixel(x + xOff, y + yOff, pix); + } + } +} + +int setPixel(int x, int y, int c) +{ + char* screenStart = 0x402F; + int i = (y * 128) + x; + screenStart[i] = c; +} + +int clear(int c) +{ + char* screenStart = 0x402F; + char screenSize = 64 * 128; + for (int i = 0; i < screenSize; i++) + { + screenStart[i] = c; + } +} + int main() { - int x = 1; - for (int i = 0; i < 10; i++) { - x *= 2; + int color = 1; + int* text = "HELLO WORLD!"; + int len = 12; + + clear(0); + while (1) + { + for (int i = 0; i < len; i++) + { + int ch = text[i]; + drawChar(ch, i * 8, 0, color); + } + color++; } } \ No newline at end of file -- cgit v1.3.1