diff --git a/bin/chip8-test-suite.8o b/bin/chip8-test-suite.8o
index 8515cf8..963fadd 100644
--- a/bin/chip8-test-suite.8o
+++ b/bin/chip8-test-suite.8o
@@ -1,3 +1,6 @@
+# CHIP-8 Test Suite -- Timendus, 2022
+# https://github.com/Timendus/chip8-test-suite
+
# The program begins from 0x200 with the CHIP-8 logo image,
# which contains the `main` label:
@@ -49,136 +52,188 @@
# After that, if the user auto-started a test, run it:
: select-test
- i := 0x1FF
- load v0
- if v0 == 1 then jump ibm-logo
- if v0 == 2 then jump corax89
- if v0 == 3 then jump flags-test
- if v0 == 4 then jump quirks-test
- if v0 == 5 then jump keypad-test
- if v0 == 9 then jump menu
- jump menu-after-keypress
+ i := 0x1FF
+ load v0
+ if v0 == 1 then jump ibm-logo
+ if v0 == 2 then jump corax89
+ if v0 == 3 then jump flags-test
+ if v0 == 4 then jump quirks-test
+ if v0 == 5 then jump keypad-test
+ if v0 == 9 then jump menu
+ jump menu-after-keypress
# Include all support code:
:stringmode str "$0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ -." {
- :byte { 4 * VALUE }
+ :byte { 4 * VALUE }
}
:macro text X Y STR {
- vD := X
- vE := Y
- i := STR
- drawText
+ vD := X
+ vE := Y
+ i := STR
+ drawText
}
:alias x vA
:alias y vB
: waitKeyRelease
- v0 := 0
+ v0 := 0
: -
- if v0 key then jump -
- v0 += 1
- if v0 == 16 then return
- jump -
+ if v0 key then jump -
+ v0 += 1
+ if v0 == 16 then return
+ jump -
# A cute little menu to select a test
: menu-after-keypress
- v0 := key
- waitKeyRelease
+ v0 := key
+ waitKeyRelease
: menu
- clear
- text 10 1 menu-header
- text 14 7 menu-ibm
- text 14 12 menu-corax
- text 14 17 menu-flags
- text 14 22 menu-quirks
- text 14 27 menu-keypad
-
- v1 := 10
- v2 := 8
- v3 := 0
- i := menu-cursor
- delay := v3
- loop
- # Blink cursor
- v0 := delay
- if v0 == 0 begin
- sprite v1 v2 2
- v0 := 10
- delay := v0
- v0 := 1
- v3 ^= v0
- end
-
- # Use numbers to start test
- v0 := 1 if v0 key then jump ibm-logo-after-keyrelease
- v0 := 2 if v0 key then jump corax89-after-keyrelease
- v0 := 3 if v0 key then jump flags-test-after-keyrelease
- v0 := 4 if v0 key then jump quirks-test-after-keyrelease
- v0 := 0xC if v0 key then jump quirks-test-after-keyrelease
-
- # Select test under cursor
- v0 := 6
- if v0 key begin
- waitKeyRelease
- if v2 == 8 then jump ibm-logo
- if v2 == 13 then jump corax89
- if v2 == 18 then jump flags-test
- if v2 == 23 then jump quirks-test
- if v2 == 28 then jump keypad-test
- end
-
- # Move cursor
- # Up
- v0 := 5
- if v0 key begin
- if v3 == 1 then sprite v1 v2 2
- if v2 > 8 then v2 -= 5
- if v3 == 1 then sprite v1 v2 2
- waitKeyRelease
- end
- # Down
- v0 := 8
- if v0 key begin
- if v3 == 1 then sprite v1 v2 2
- if v2 < 28 then v2 += 5
- if v3 == 1 then sprite v1 v2 2
- waitKeyRelease
- end
- again
+ clear
+ text 10 1 menu-header
+ text 14 7 menu-ibm
+ text 14 12 menu-corax
+ text 14 17 menu-flags
+ text 14 22 menu-quirks
+ text 14 27 menu-keypad
+
+ :unpack 0xA menu-main
+ v2 := 4
+ #jump menu-start
+
+# Input:
+# * v0 v1 point to 0xA + menu struct
+# * v2 holds the length (zero-indexed)
+: menu-start
+ :alias cursorX v0
+ :alias cursorY v1
+ :alias numItems v2
+ :alias showing v3
+ :alias temp v4
+ :alias currentItem v5
+ :alias selectedItem v6
+
+ currentItem := 0
+ i := menu-draw-cursor
+ save v1
+ i := menu-choose-load
+ save v1
+ jump menu-draw-cursor
+: menu-move-cursor
+ if showing == 1 then sprite cursorX cursorY 2 # i should still be correct
+ waitKeyRelease
+: menu-draw-cursor
+ 0 0 # i :=