summaryrefslogtreecommitdiff
path: root/ROMs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-28 12:35:24 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2025-08-28 12:35:24 +1000
commit7f96fc5e7f412a66d460dcaa82bbdbcaea08f360 (patch)
tree67ebd30bce45f8e5ffed73212f287b4152a5b71d /ROMs
parent634681ce2bb36cd686943102a0f071cd6a09049f (diff)
everything is finally at peace
Diffstat (limited to 'ROMs')
-rw-r--r--ROMs/_old/hello_world.asm (renamed from ROMs/hello_world.asm)0
-rw-r--r--ROMs/_old/hello_world.q1 (renamed from ROMs/hello_world.q1)bin2151 -> 2151 bytes
-rw-r--r--ROMs/_old/manual.q1 (renamed from ROMs/manual.q1)bin10 -> 10 bytes
-rw-r--r--ROMs/_old/write_display_direct.asm (renamed from ROMs/write_display_direct.asm)0
-rw-r--r--ROMs/_old/write_display_direct.q1 (renamed from ROMs/write_display_direct.q1)bin51 -> 51 bytes
-rw-r--r--ROMs/hid.asm117
-rw-r--r--ROMs/hid.q1bin417 -> 0 bytes
-rw-r--r--ROMs/paint.asm191
-rw-r--r--ROMs/paint.c (renamed from ROMs/hid.c)27
-rw-r--r--ROMs/paint.q1bin0 -> 676 bytes
10 files changed, 215 insertions, 120 deletions
diff --git a/ROMs/hello_world.asm b/ROMs/_old/hello_world.asm
index 1d812fb..1d812fb 100644
--- a/ROMs/hello_world.asm
+++ b/ROMs/_old/hello_world.asm
diff --git a/ROMs/hello_world.q1 b/ROMs/_old/hello_world.q1
index fd66ffe..fd66ffe 100644
--- a/ROMs/hello_world.q1
+++ b/ROMs/_old/hello_world.q1
Binary files differ
diff --git a/ROMs/manual.q1 b/ROMs/_old/manual.q1
index b166c7a..b166c7a 100644
--- a/ROMs/manual.q1
+++ b/ROMs/_old/manual.q1
Binary files differ
diff --git a/ROMs/write_display_direct.asm b/ROMs/_old/write_display_direct.asm
index 9fde417..9fde417 100644
--- a/ROMs/write_display_direct.asm
+++ b/ROMs/_old/write_display_direct.asm
diff --git a/ROMs/write_display_direct.q1 b/ROMs/_old/write_display_direct.q1
index 4041649..4041649 100644
--- a/ROMs/write_display_direct.q1
+++ b/ROMs/_old/write_display_direct.q1
Binary files differ
diff --git a/ROMs/hid.asm b/ROMs/hid.asm
deleted file mode 100644
index 0e3600f..0000000
--- a/ROMs/hid.asm
+++ /dev/null
@@ -1,117 +0,0 @@
- 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.q1 b/ROMs/hid.q1
deleted file mode 100644
index e188e33..0000000
--- a/ROMs/hid.q1
+++ /dev/null
Binary files differ
diff --git a/ROMs/paint.asm b/ROMs/paint.asm
new file mode 100644
index 0000000..2f023b7
--- /dev/null
+++ b/ROMs/paint.asm
@@ -0,0 +1,191 @@
+ jmp _main
+_setPixel_int_x__int_y__int_c:; int setPixel(int x, int y, int c)
+ pop V0 ; preserve function return address
+ pop [$71FF] ; param int x
+ pop [$7201] ; param int y
+ pop [$7203] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7205] ; int screenStart = $402F
+ push [$7201] ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ push AX ; left operand
+ mov [$71FF], V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ mov AX, [$7207] ; int i = AX
+ push [$7205] ; store index obj
+ mov [$7207], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$7203], [V0] ; [V0] = [$7203]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_setPixelIndex_int_i__int_c: ; int setPixelIndex(int i, int c)
+ pop V0 ; preserve function return address
+ pop [$7209] ; param int i
+ pop [$720B] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$720D] ; int screenStart = $402F
+ push [$720D] ; store index obj
+ mov [$7209], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$720B], [V0] ; [V0] = [$720B]
+ mov 0, V0 ; fallback return 0
+ ret
+
+_clear_int_c: ; int clear(int c)
+ pop V0 ; preserve function return address
+ pop [$720F] ; param int c
+ push V0 ; restore function return address
+ mov $402F, [$7211] ; int screenStart = $402F
+ push 64 ; left operand
+ mov 128, V1 ; right operand
+ pop V0 ; get left operand back
+ mul V0, V1 ; compute multiplication
+ mov AX, [$7213] ; int screenSize = AX
+ mov 0, [$7215] ; int i = 0
+_body_1:
+ push [$7215] ; left operand
+ mov [$7213], V1 ; right operand
+ pop V0 ; get left operand back
+ lt V0, V1 ; compute less than check
+ not LX
+ bz
+ jmp _end_2 ; if for condition fails, jump to end
+ push [$7211] ; store index obj
+ mov [$7215], V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ movb [$720F], [V0] ; [V0] = [$720F]
+ push [$7215] ; i++
+ inc [$7215]
+ pop V0
+ jmp _body_1
+_end_2:
+ mov 0, V0 ; fallback return 0
+ ret
+
+_getKeyState_int_scanCode: ; int getKeyState(int scanCode)
+ pop V0 ; preserve function return address
+ pop [$7217] ; param int scanCode
+ push V0 ; restore function return address
+ mov $6033, [$7219] ; int hid = $6033
+ push [$7217] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ div V0, V1 ; compute division
+ mov AX, [$721B] ; int index = AX
+ push [$7217] ; left operand
+ mov 8, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ mov AX, [$721D] ; int bit = AX
+ push [$7219] ; store index obj
+ push [$721B] ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ sub V0, V1 ; compute subtraction
+ mov AX, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 1 ; multiply indexer by 1
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$721F] ; int val = [V0]
+ push [$721F] ; left operand
+ push 1 ; left operand
+ mov [$721D], V1 ; right operand
+ pop V0 ; get left operand back
+ shl V0, V1 ; compute left shift
+ mov DX, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ push DX ; left operand
+ mov 0, V1 ; right operand
+ pop V0 ; get left operand back
+ cmp V0, V1 ; compute inequality check
+ not
+ mov LX, V0 ; return value
+ ret
+ mov 0, V0 ; fallback return 0
+ ret
+
+_main: ; int main()
+ mov 0, [$7221] ; int color = 0
+_body_3:
+ not 1
+ bz
+ jmp _end_4 ; if while condition fails, jump to end
+ mov $602F, [$7223] ; int hid = $602F
+ push [$7223] ; store index obj
+ mov 0, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 2 ; multiply indexer by 2
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7225] ; int mouseIndex = [V0]
+ push [$7223] ; store index obj
+ mov 1, V1 ; store indexer
+ pop V0 ; restore index obj
+ mul V1, 2 ; multiply indexer by 2
+ add AX, V0 ; add indexer and index obj
+ mov AX, V0 ; move to general purpose register
+ mov [V0], [$7227] ; int mouseState = [V0]
+ push [$7227] ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ and V0, V1 ; compute and
+ not DX
+ bz ; check if condition
+ jmp _end_5 ; if succeeds, continue, else jump to end
+ push [$7221] ; left operand
+ mov 3, V1 ; right operand
+ pop V0 ; get left operand back
+ mod V0, V1 ; compute modulus
+ push AX ; left operand
+ mov 1, V1 ; right operand
+ pop V0 ; get left operand back
+ add V0, V1 ; compute addition
+ push AX ; arg int i
+ push [$7225] ; arg int c
+ call _setPixelIndex_int_i__int_c; int setPixelIndex(int i, int c)
+_end_5:
+ push 67 ; arg int scanCode
+ call _getKeyState_int_scanCode; int getKeyState(int scanCode)
+ not V0
+ bz ; check if condition
+ jmp _end_6 ; if succeeds, continue, else jump to end
+ push 8 ; arg int c
+ call _clear_int_c ; int clear(int c)
+_end_6:
+ push 65 ; arg int scanCode
+ call _getKeyState_int_scanCode; int getKeyState(int scanCode)
+ not V0
+ bz ; check if condition
+ jmp _end_7 ; if succeeds, continue, else jump to end
+ push [$7221] ; i++
+ inc [$7221]
+ pop V0
+_body_8:
+ push 65 ; arg int scanCode
+ call _getKeyState_int_scanCode; int getKeyState(int scanCode)
+ not V0
+ bz
+ jmp _end_9 ; if while condition fails, jump to end
+ jmp _body_8
+_end_9:
+_end_7:
+ jmp _body_3
+_end_4:
+ mov 0, V0 ; fallback return 0
+ ret
+
diff --git a/ROMs/hid.c b/ROMs/paint.c
index 615808a..443719a 100644
--- a/ROMs/hid.c
+++ b/ROMs/paint.c
@@ -21,14 +21,35 @@ int clear(int c)
}
}
-int main()
+int getKeyState(int scanCode)
{
+ char* hid = 0x6033;
+ int index = scanCode / 8;
+ int bit = scanCode % 8;
+
+ int val = hid[index - 1];
+ return (val & (1 << bit)) != 0;
+}
+
+int main()
+{
+ int color = 0;
while (1)
{
int* hid = 0x602F;
int mouseIndex = hid[0];
int mouseState = hid[1];
- if (mouseState & 1 == 1)
- setPixelIndex(mouseIndex, 1);
+
+ if (mouseState & 1)
+ setPixelIndex(mouseIndex, (color % 3) + 1);
+
+ if (getKeyState(67))
+ clear(8);
+
+ if (getKeyState(65))
+ {
+ color++;
+ while (getKeyState(65)) { }
+ }
}
} \ No newline at end of file
diff --git a/ROMs/paint.q1 b/ROMs/paint.q1
new file mode 100644
index 0000000..98929bb
--- /dev/null
+++ b/ROMs/paint.q1
Binary files differ