forked from Timendus/chip8-test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6-keypad.8o
185 lines (167 loc) · 2.97 KB
/
6-keypad.8o
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Keypad test
# A fresh new implementation for this test suite
:include "../utils/helpers.8o"
:include "../utils/menu.8o"
:include "../utils/text-rendering.8o"
: main
clear
i := 0x1FF
load v0
if v0 == 1 then jump keypad-down
if v0 == 2 then jump keypad-up
if v0 == 3 then jump keypad-getkey
text 10 2 keypad-choose
text 8 10 keypad-str-key-down
text 8 15 keypad-str-key-up
text 8 20 keypad-str-getkey
# Show version number in bottom right corner
x := 50
y := 27
i := version-0-0
sprite x y 4
x := 58
i := version-1-0
sprite x y 4
:unpack 0xA keypad-menu
v2 := 2
jump menu-start
: keypad-down
v1 := 0x9E
jump keypad-skip-if-key-test
: keypad-up
v1 := 0xA1
: keypad-skip-if-key-test
v0 := 0xEE
i := keypad-opcode
save v1
clear
i := keypad-initial-values
load vF
i := scratchpad
save vF
text 18 3 keypad-row1
text 18 10 keypad-row2
text 18 17 keypad-row3
text 18 24 keypad-row4
vE := 0
loop
keypad-pressed
vE += 1
if vE == 16 then vE := 0
again
: keypad-pressed
i := scratchpad
i += vE
load v0
v2 := 1
: keypad-opcode
if vE key then v2 := 0
if v0 != v2 begin
v0 := vE
v0 <<= v0
i := keypad-coordinates
i += v0
load v1
i := keypad-cursor
sprite v0 v1 6
i := scratchpad
i += vE
v0 := v2
save v0
end
return
: keypad-getkey
clear
text 6 13 keypad-str-press-key
v0 := 3
delay := v0
v0 := key
v1 := delay
if v1 != 0 then jump keypad-getkey-no-halt
if v0 key then jump keypad-getkey-no-release-wait
clear
i := flag-ok
v0 := 30
v1 := 9
sprite v0 v1 3
text 16 17 keypad-str-good
waitKeyRelease
v0 := key
waitKeyRelease
jump main
: keypad-getkey-no-halt
vD := 10
i := keypad-str-no-halt
jump keypad-getkey-error
: keypad-getkey-no-release-wait
vD := 8
i := keypad-str-no-release-wait
: keypad-getkey-error
clear
vE := 17
drawText
i := flag-err
v0 := 30
v1 := 9
sprite v0 v1 3
waitKeyRelease
v0 := key
waitKeyRelease
jump main
:segment data
: keypad-menu
4 11 :pointer keypad-down
4 16 :pointer keypad-up
4 21 :pointer keypad-getkey
: keypad-choose
str "PICK OPCODE" 0
: keypad-str-key-down
str "1 EX9E DOWN" 0
: keypad-str-key-up
str "2 EXA1 UP" 0
: keypad-str-getkey
str "3 FX0A GETKEY" 0
: keypad-str-press-key
str "PRESS ANY KEY" 0
: keypad-str-good
str "ALL GOOD" 0
: keypad-str-no-halt
str "NOT HALTING" 0
: keypad-str-no-release-wait
str "NOT RELEASED" 0
: keypad-initial-values
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
: keypad-row1
str "1 2 3 C" 0
: keypad-row2
str "4 5 6 D" 0
: keypad-row3
str "7 8 9 E" 0
: keypad-row4
str "A 0 B F" 0
: keypad-coordinates
24 23 # 0
16 2 # 1
24 2 # 2
32 2 # 3
16 9 # 4
24 9 # 5
32 9 # 6
16 16 # 7
24 16 # 8
32 16 # 9
16 23 # A
32 23 # B
40 2 # C
40 9 # D
40 16 # E
40 23 # F
: keypad-cursor
0b11111110
0b11111110
0b11111110
0b11111110
0b11111110
0b11111110
:include "../../pictures/version.png"