diff options
Diffstat (limited to 'ROMs')
| -rw-r--r-- | ROMs/hello_c.asm | 220 | ||||
| -rw-r--r-- | ROMs/hello_c.c | 54 | ||||
| -rw-r--r-- | ROMs/hello_c.q1 | bin | 55 -> 2842 bytes | |||
| -rw-r--r-- | ROMs/hid.asm | 117 | ||||
| -rw-r--r-- | ROMs/hid.c | 34 | ||||
| -rw-r--r-- | ROMs/hid.q1 | bin | 0 -> 417 bytes |
6 files changed, 409 insertions, 16 deletions
diff --git a/ROMs/hello_c.asm b/ROMs/hello_c.asm index bdb32ff..da648b6 100644 --- a/ROMs/hello_c.asm +++ b/ROMs/hello_c.asm @@ -1,21 +1,215 @@ jmp _main -_main: ; int main() - mov 1, [$51FF] ; int x = 1 - mov 0, [$5201] ; int i = 0 + .include "ROMs/font.bin" +_drawChar_int_ch__int_x__int_y__int_color: + pop V0 + pop [$71FF] + pop [$7201] + pop [$7203] + pop [$7205] + push V0 + ; adjust for jmp instruction + push $1FFF + mov 2, V1 + pop V0 + add V0, V1 + mov AX, [$7207] + push [$71FF] + mov 8, V1 + pop V0 + mul V0, V1 + mov AX, [$7209] + mov 0, [$720B] _body_1: - push [$5201] ; left operand - mov 10, V1 ; right operand - pop V0 ; get left operand back - lt V0, V1 ; compute less than check + push [$720B] + mov 8, V1 + pop V0 + lt V0, V1 + not LX + bz + jmp _end_2 + push [$7207] + push [$7209] + mov [$720B], V1 + pop V0 + add V0, V1 + mov AX, V1 + pop V0 + mul V1, 1 + add AX, V0 + mov AX, V0 + mov [V0], [$720D] + mov 0, [$720F] +_body_3: + push [$720F] + mov 8, V1 + pop V0 + lt V0, V1 not LX bz - jmp _end_2 ; if for condition fails, jump to end - mult [$51FF], 2 ; compute multiplication - mov AX, [$51FF] ; store back into left param - push [$5201] ; i++ - inc [$5201] + jmp _end_4 + push [$720D] + push 7 + mov [$720F], V1 + pop V0 + sub V0, V1 + mov AX, V1 pop V0 + shr V0, V1 + push DX + mov 1, V1 + pop V0 + and V0, V1 + mov DX, [$7211] + bz [$7211] + jmp _then_5 + mov [$7205], V0 + jmp _end_6 +_then_5: + mov 0, V0 +_end_6: + mov V0, [$7213] + push [$7213] + push [$7203] + mov [$720B], V1 + pop V0 + add V0, V1 + push AX + push [$7201] + mov [$720F], V1 + pop V0 + add V0, V1 + push AX + call _setPixel_int_x__int_y__int_c + push [$720F] + inc [$720F] + pop V0 + jmp _body_3 +_end_4: + push [$720B] + inc [$720B] + pop V0 + jmp _body_1 _end_2: - mov 0, V0 ; fallback return 0 + mov 0, V0 + ret + +_setPixel_int_x__int_y__int_c: + pop V0 + pop [$7215] + pop [$7217] + pop [$7219] + push V0 + mov $402F, [$721B] + push [$7217] + mov 128, V1 + pop V0 + mul V0, V1 + push AX + mov [$7215], V1 + pop V0 + add V0, V1 + mov AX, [$721D] + push [$721B] + mov [$721D], V1 + pop V0 + mul V1, 1 + add AX, V0 + mov AX, V0 + movb [$7219], [V0] + mov 0, V0 + ret + +_clear_int_c: + pop V0 + pop [$721F] + push V0 + mov $402F, [$7221] + push 64 + mov 128, V1 + pop V0 + mul V0, V1 + mov AX, [$7223] + mov 0, [$7225] +_body_7: + push [$7225] + mov [$7223], V1 + pop V0 + lt V0, V1 + not LX + bz + jmp _end_8 + push [$7221] + mov [$7225], V1 + pop V0 + mul V1, 1 + add AX, V0 + mov AX, V0 + movb [$721F], [V0] + push [$7225] + inc [$7225] + pop V0 + jmp _body_7 +_end_8: + mov 0, V0 + ret + +_main: + mov 1, [$7227] + mov 72, [$722B] + mov 69, [$722D] + mov 76, [$722F] + mov 76, [$7231] + mov 79, [$7233] + mov 32, [$7235] + mov 87, [$7237] + mov 79, [$7239] + mov 82, [$723B] + mov 76, [$723D] + mov 68, [$723F] + mov 33, [$7241] + mov $722B, [$7229] + mov 12, [$7243] + push 0 + call _clear_int_c +_body_9: + not 1 + bz + jmp _end_10 + mov 0, [$7245] +_body_11: + push [$7245] + mov [$7243], V1 + pop V0 + lt V0, V1 + not LX + bz + jmp _end_12 + push [$7229] + mov [$7245], V1 + pop V0 + mul V1, 2 + add AX, V0 + mov AX, V0 + mov [V0], [$7247] + push [$7227] + push 0 + push [$7245] + mov 8, V1 + pop V0 + mul V0, V1 + push AX + push [$7247] + call _drawChar_int_ch__int_x__int_y__int_color + push [$7245] + inc [$7245] + pop V0 + jmp _body_11 +_end_12: + push [$7227] + inc [$7227] + pop V0 + jmp _body_9 +_end_10: + mov 0, V0 ret 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 diff --git a/ROMs/hello_c.q1 b/ROMs/hello_c.q1 Binary files differindex 1af8388..5e3248c 100644 --- a/ROMs/hello_c.q1 +++ b/ROMs/hello_c.q1 diff --git a/ROMs/hid.asm b/ROMs/hid.asm new file mode 100644 index 0000000..0e3600f --- /dev/null +++ b/ROMs/hid.asm @@ -0,0 +1,117 @@ + jmp _main +_setPixel_int_x__int_y__int_c: + pop V0 + pop [$71FF] + pop [$7201] + pop [$7203] + push V0 + mov $402F, [$7205] + push [$7201] + mov 128, V1 + pop V0 + mul V0, V1 + push AX + mov [$71FF], V1 + pop V0 + add V0, V1 + mov AX, [$7207] + push [$7205] + mov [$7207], V1 + pop V0 + mul V1, 1 + add AX, V0 + mov AX, V0 + movb [$7203], [V0] + mov 0, V0 + ret + +_setPixelIndex_int_i__int_c: + pop V0 + pop [$7209] + pop [$720B] + push V0 + mov $402F, [$720D] + push [$720D] + mov [$7209], V1 + pop V0 + mul V1, 1 + add AX, V0 + mov AX, V0 + movb [$720B], [V0] + mov 0, V0 + ret + +_clear_int_c: + pop V0 + pop [$720F] + push V0 + mov $402F, [$7211] + push 64 + mov 128, V1 + pop V0 + mul V0, V1 + mov AX, [$7213] + mov 0, [$7215] +_body_1: + push [$7215] + mov [$7213], V1 + pop V0 + lt V0, V1 + not LX + bz + jmp _end_2 + push [$7211] + mov [$7215], V1 + pop V0 + mul V1, 1 + add AX, V0 + mov AX, V0 + movb [$720F], [V0] + push [$7215] + inc [$7215] + pop V0 + jmp _body_1 +_end_2: + mov 0, V0 + ret + +_main: +_body_3: + not 1 + bz + jmp _end_4 + mov $602F, [$7217] + push [$7217] + mov 0, V1 + pop V0 + mul V1, 2 + add AX, V0 + mov AX, V0 + mov [V0], [$7219] + push [$7217] + mov 1, V1 + pop V0 + mul V1, 2 + add AX, V0 + mov AX, V0 + mov [V0], [$721B] + push [$721B] + push 1 + mov 1, V1 + pop V0 + cmp V0, V1 + mov LX, V1 + pop V0 + and V0, V1 + not DX + bz + jmp _end_5 + push 1 + push [$7219] + call _setPixelIndex_int_i__int_c +_end_5: + jmp _body_3 +_end_4: + mov 0, V0 + ret + diff --git a/ROMs/hid.c b/ROMs/hid.c new file mode 100644 index 0000000..615808a --- /dev/null +++ b/ROMs/hid.c @@ -0,0 +1,34 @@ +int setPixel(int x, int y, int c) +{ + char* screenStart = 0x402F; + int i = (y * 128) + x; + screenStart[i] = c; +} + +int setPixelIndex(int i, int c) +{ + char* screenStart = 0x402F; + 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() +{ + while (1) + { + int* hid = 0x602F; + int mouseIndex = hid[0]; + int mouseState = hid[1]; + if (mouseState & 1 == 1) + setPixelIndex(mouseIndex, 1); + } +}
\ No newline at end of file diff --git a/ROMs/hid.q1 b/ROMs/hid.q1 Binary files differnew file mode 100644 index 0000000..e188e33 --- /dev/null +++ b/ROMs/hid.q1 |
