diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2025-08-27 21:22:55 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2025-08-27 21:22:55 +1000 |
| commit | 634681ce2bb36cd686943102a0f071cd6a09049f (patch) | |
| tree | 6710047aa231d50f57114bdd54a27c559fb20a73 /ROMs/hello_c.c | |
| parent | 94ddc02e03ab942d0c881e29053e8df3d2940c30 (diff) | |
fixed bugs and revolutionized the universe
Diffstat (limited to 'ROMs/hello_c.c')
| -rw-r--r-- | ROMs/hello_c.c | 54 |
1 files changed, 51 insertions, 3 deletions
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 |
