Skip to content

Commit 88c29ea

Browse files
authored
Merge pull request #24 from GamingMadster/main
Merge Prettified Corax+ Code
2 parents de1ca9c + 861dc90 commit 88c29ea

File tree

1 file changed

+94
-42
lines changed

1 file changed

+94
-42
lines changed

src/tests/3-corax+.8o

Lines changed: 94 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# MIT License
66
#
7-
# Copyright (c) 2019 corax89, 2023 Timendus
7+
# Copyright (c) 2019 corax89, 2023,2024 Timendus
88
#
99
# Permission is hereby granted, free of charge, to any person obtaining a copy
1010
# of this software and associated documentation files (the "Software"), to deal
@@ -32,18 +32,22 @@
3232
:macro drawop A B {
3333
i := A
3434
sprite x0 y 4
35+
3536
i := B
3637
sprite x1 y 4
3738
}
3839

3940
: test-2X-0E
4041
v0 := 1
4142
return
43+
# These opcodes will run if the interpreter doesn't have return (00EE) implemented:
4244
v0 := 2
4345
jump test-2X-0E-hard-return
4446

4547
: main
4648
clear
49+
50+
# Display current version
4751
x0 := 50
4852
y := 26
4953
i := version-0-0
@@ -52,80 +56,99 @@
5256
i := version-1-0
5357
sprite x0 y 4
5458

59+
# Show output in the first column
5560
x0 := 2
5661
x1 := 6
5762
x2 := 11
5863
y := 1
64+
65+
#################
66+
# Test 3xNN
67+
5968
v5 := 42
6069
v6 := 43
61-
62-
#test 3x
6370
drawop im3 imX
6471
i := image-ok
6572
if v6 != 43 then i := image-no
6673
sprite x2 y 4
6774

68-
#test 4x
75+
#################
76+
# Test 4xNN
77+
6978
y := 6
7079
drawop im4 imX
7180
i := image-no
7281
if v5 == 42 then i := image-ok
7382
sprite x2 y 4
7483

75-
#test 5x
84+
#################
85+
# Test 5xy0
86+
7687
y := 11
7788
drawop im5 imX
7889
i := image-no
7990
if v5 != v6 then i := image-ok
8091
sprite x2 y 4
8192

82-
#test 7x
93+
#################
94+
# Test 7xNN
95+
8396
y := 16
8497
drawop im7 imX
8598
i := image-no
8699
v6 += 255
87100
if v6 == 42 then i := image-ok
88101
sprite x2 y 4
89102

90-
#test 9x
103+
#################
104+
# Test 9xy0
105+
91106
y += 5
92107
drawop im9 imX
93108
i := image-no
94109
if v5 == v6 then i := image-ok
95110
sprite x2 y 4
96111

97-
#test 1x
112+
#################
113+
# Test 1NNN (displayed as 1X)
114+
98115
y += 5
99116
drawop im1 imX
100117
i := image-ok
101-
jump test1x
118+
jump test-1X-pass
102119
i := image-no
103-
: test1x
120+
: test-1X-pass
104121
sprite x2 y 4
105122

106-
# Test calling and returning from subroutines (2NNN and 00EE)
123+
# Show output in the second column
107124
x0 := 18
108125
x1 := 22
109126
x2 := 27
110127
y := 1
128+
129+
#################
130+
# Test calling subroutines (2NNN, displayed as 2X)
131+
111132
drawop im2 imX
112-
113-
# Attempt to run a subroutine
114133
v0 := 0
115-
test-2X-0E
116-
134+
test-2X-0E # Attempt to run a subroutine
117135
: test-2X-0E-hard-return
118136
i := image-ok
119137
if v0 == 0 then i := image-no # Subroutine was never called
120138
sprite x2 y 4
121-
139+
140+
#################
141+
# Test returning from subroutines (00EE, displayed as 0E)
142+
122143
y += 5
123144
drawop im0 imE
124145
i := image-ok
125146
if v0 == 2 then i := image-no # Return didn't work
126147
if v0 != 0 then sprite x2 y 4 # If subroutine wasn't called, return wasn't tested
127148

128-
#test 8xy0
149+
#################
150+
# Test 8xy0
151+
129152
y += 5
130153
drawop im8 im0
131154
i := image-no
@@ -135,7 +158,9 @@
135158
if v7 == 42 then i := image-ok
136159
sprite x2 y 4
137160

138-
#test 8xy1
161+
#################
162+
# Test 8xy1
163+
139164
y += 5
140165
drawop im8 im1
141166
i := image-no
@@ -145,7 +170,9 @@
145170
if v7 == 43 then i := image-ok
146171
sprite x2 y 4
147172

148-
#test 8xy2
173+
#################
174+
# Test 8xy2
175+
149176
y += 5
150177
drawop im8 im2
151178
i := image-no
@@ -155,7 +182,9 @@
155182
if v7 == 24 then i := image-ok
156183
sprite x2 y 4
157184

158-
#test 8xy3
185+
#################
186+
# Test 8xy3
187+
159188
y += 5
160189
drawop im8 im3
161190
i := image-no
@@ -165,11 +194,15 @@
165194
if v7 == 103 then i := image-ok
166195
sprite x2 y 4
167196

168-
#test 8xy4
197+
# Show output in the third column
169198
x0 := 34
170199
x1 := 38
171200
x2 := 43
172201
y := 1
202+
203+
#################
204+
# Test 8xy4
205+
173206
drawop im8 im4
174207
i := image-no
175208
v6 := 140
@@ -178,7 +211,9 @@
178211
if v7 == 24 then i := image-ok
179212
sprite x2 y 4
180213

181-
#test 8xy5
214+
#################
215+
# Test 8xy5
216+
182217
y += 5
183218
drawop im8 im5
184219
i := image-no
@@ -188,7 +223,9 @@
188223
if v7 == 236 then i := image-ok
189224
sprite x2 y 4
190225

191-
#test 8xy7
226+
#################
227+
# Test 8xy7
228+
192229
y += 5
193230
drawop im8 im7
194231
i := image-no
@@ -198,9 +235,9 @@
198235
if v7 == 236 then i := image-ok
199236
sprite x2 y 4
200237

201-
#test "8xyE"
202-
# Note by Timendus: This should be 8XY6, changed the label here too.
203-
# See PR: https://github.com/corax89/chip8-test-rom/pull/7
238+
#################
239+
# Test 8xy6
240+
204241
y += 5
205242
drawop im8 im6
206243
i := image-no
@@ -209,9 +246,9 @@
209246
if v6 == 7 then i := image-ok
210247
sprite x2 y 4
211248

212-
#test "8xy6"
213-
# Note by Timendus: This should be 8XYE, changed the label here too.
214-
# See PR: https://github.com/corax89/chip8-test-rom/pull/7
249+
#################
250+
# Test 8xyE
251+
215252
y += 5
216253
drawop im8 imE
217254
i := image-no
@@ -220,7 +257,9 @@
220257
if v6 == 192 then i := image-ok
221258
sprite x2 y 4
222259

223-
#test Fx65
260+
#################
261+
# Test Fx65
262+
224263
y += 5
225264
drawop imF im6
226265
i := scratchpad
@@ -230,7 +269,9 @@
230269
if v1 != 0x55 then i := image-no
231270
sprite x2 y 4
232271

233-
#test Fx55
272+
#################
273+
# Test Fx55
274+
234275
x0 := 50
235276
x1 := 54
236277
x2 := 59
@@ -250,58 +291,63 @@
250291
if v1 != 0 then i := image-no
251292
sprite x2 y 4
252293

253-
#test Fx33
294+
#################
295+
# Test Fx33
296+
254297
y += 5
255298
drawop imF im3
256-
257-
# >= 100
299+
300+
# N >= 100
258301
i := scratchpad
259302
v6 := 137
260303
bcd v6
261304
load v2
262-
263305
i := image-no
264-
265306
if v0 != 1 then jump fx33-fail
266307
if v1 != 3 then jump fx33-fail
267308
if v2 != 7 then jump fx33-fail
268309

269-
# < 100
310+
# N < 100
270311
i := scratchpad
271312
v6 := 65
272313
bcd v6
273314
load v2
315+
i := image-no
274316
if v0 != 0 then jump fx33-fail
275317
if v1 != 6 then jump fx33-fail
276318
if v2 != 5 then jump fx33-fail
277319

278-
# < 10
320+
# N < 10
279321
i := scratchpad
280322
v6 := 4
281323
bcd v6
282324
load v2
283-
325+
i := image-no
284326
if v0 != 0 then jump fx33-fail
285327
if v1 != 0 then jump fx33-fail
286328
if v2 != 4 then jump fx33-fail
287329

288330
i := image-ok
289-
290331
: fx33-fail
291332
sprite x2 y 4
292333

293-
#test Fx1E
334+
#################
335+
# Test Fx1E
336+
294337
y += 5
295338
drawop imF imE
296339
i := image-no
297340
v6 := 4
298341
i += v6
299342
sprite x2 y 4
300343

301-
# Test to see if registers are 8 bit, as much as we can
344+
#################
345+
# Test to see if registers are 8 bit, as thoroughly as possible.
346+
302347
y += 5
303348
drawop imV imX
304349
i := image-ok
350+
305351
# Addition opcodes should not allow us to overflow
306352
v6 := 255
307353
v6 += 10
@@ -314,6 +360,7 @@
314360
if v6 != 9 then i := image-no
315361
v6 >>= v6
316362
if v6 != 4 then i := image-no
363+
317364
# Shift opcodes should not retain bits
318365
v6 := 255
319366
v6 <<= v6
@@ -322,6 +369,7 @@
322369
v6 >>= v6
323370
v6 <<= v6
324371
if v6 != 126 then i := image-no
372+
325373
# Subtraction should wrap back to positive
326374
v6 := 5
327375
v6 -= 10
@@ -332,8 +380,12 @@
332380
v6 := 5
333381
v0 =- v6
334382
if v0 != 251 then i := image-no
383+
335384
sprite x2 y 4
336385

386+
#################
387+
# Test is done!
388+
337389
loop again
338390

339391
:segment data

0 commit comments

Comments
 (0)