scroll down works on CHIP-8 and High-Res modes

scroll left and right work in stdef and hidef
adds octo test roms
adds schip fonts to memory
This commit is contained in:
2024-10-25 08:19:03 -04:00
parent a978ddc41e
commit e29ac45c84
65 changed files with 13342 additions and 230 deletions
+23
View File
@@ -0,0 +1,23 @@
###########################################
#
# Big Font
#
# High resolution font test program.
# Draw the complete SuperChip high res
# hex character set.
#
###########################################
: main
hires
loop
i := bighex v0
sprite v1 v2 10
v1 += 9
v0 += 1
if v0 == 8 then v1 := 0
if v0 == 8 then v2 += 11
if v0 != 16 then
again
loop again
+72
View File
@@ -0,0 +1,72 @@
###########################################
#
# Branch Test
#
# Tests the if...begin...else...then
# control structure.
# Should print "51368"
#
###########################################
: main
# simple taken branch
v0 := 1
v1 := 3
if v1 == 3 begin
v0 := 2
v0 += 3
end
print0
# simple not taken branch
v0 := 1
v1 := 3
if v1 != 3 begin
v0 := 2
v0 += 3
end
print0
# else taken
v0 := 2
v1 := 3
if v1 != v0 begin
v0 := 1
v0 += 2
else
v0 := 2
v0 += 4
end
print0
# else not taken
v0 := 2
v1 := 3
if v1 < v0 begin
v0 := 1
v0 += 2
else
v0 := 2
v0 += 4
end
print0
# nesting
v0 := 1
if v0 != 0 begin
if v0 != 2 begin
v0 := 7
else
v0 := 3
end
v0 += 1
end
print0
loop again
: print0
i := hex v0
sprite va vb 5
va += 5
;
+32
View File
@@ -0,0 +1,32 @@
###########################################
#
# Collision Detection Test
#
# Draws two overlapping sprites and
# displays the contents of the vF register.
# Should print "1".
#
###########################################
: square
0b11110000
0b11110000
0b11110000
0b11110000
: main
v0 := 20
v1 := 10
i := square
sprite v0 v1 4
v0 += 2
v1 += 2
sprite v0 v1 4
v2 := vf
v0 += 10
i := hex v2
sprite v0 v1 5
loop again
+70
View File
@@ -0,0 +1,70 @@
###########################################
#
# Numeric Comparison Tests
#
# Exercises all combinations of
# register-to-register and register-to-constant
# comparisons with the synthetic pseudo-ops
# < > <= and >=
#
###########################################
: print
i := hex v0
sprite va vb 5
va += 5
v0 := 0
;
: newline
va := 0
vb += 6
;
: greater? if v1 > v2 then v0 := 1 print ;
: greater5? if v1 > 5 then v0 := 1 print ;
: less? if v1 < v2 then v0 := 1 print ;
: less5? if v1 < 5 then v0 := 1 print ;
: greatere? if v1 >= v2 then v0 := 1 print ;
: greatere5? if v1 >= 5 then v0 := 1 print ;
: lesse? if v1 <= v2 then v0 := 1 print ;
: lesse5? if v1 <= 5 then v0 := 1 print ;
: main
# 001001
v1 := 3 v2 := 5 greater?
v1 := 3 v2 := 3 greater?
v1 := 5 v2 := 3 greater?
v1 := 3 greater5?
v1 := 5 greater5?
v1 := 7 greater5?
newline
# 100100
v1 := 3 v2 := 5 less?
v1 := 3 v2 := 3 less?
v1 := 5 v2 := 3 less?
v1 := 3 less5?
v1 := 5 less5?
v1 := 7 less5?
newline
# 011011
v1 := 3 v2 := 5 greatere?
v1 := 3 v2 := 3 greatere?
v1 := 5 v2 := 3 greatere?
v1 := 3 greatere5?
v1 := 5 greatere5?
v1 := 7 greatere5?
newline
# 110110
v1 := 3 v2 := 5 lesse?
v1 := 3 v2 := 3 lesse?
v1 := 5 v2 := 3 lesse?
v1 := 3 lesse5?
v1 := 5 lesse5?
v1 := 7 lesse5?
loop again
+66
View File
@@ -0,0 +1,66 @@
###########################################
#
# Loop Construct Tests
#
# Tests boundary conditions using `if`
# and `while` with simple and synthetic
# comparison operators.
# Should draw 5 vertical strips of 6 boxes.
#
###########################################
: main
# while with pseudo-op
v0 := 0
v1 := 0
loop
while v1 < 30
sprite v0 v1 5
v1 += 5
again
# while with simple comparison
v0 := 5
v1 := 0
loop
while v1 != 30
sprite v0 v1 5
v1 += 5
again
# if with pseudo-op
v0 := 10
v1 := 0
loop
if v1 >= 30 then jump done1
sprite v0 v1 5
v1 += 5
again
: done1
# if with simple comparison
v0 := 15
v1 := 0
loop
if v1 == 30 then jump done2
sprite v0 v1 5
v1 += 5
again
: done2
# nested loops with while
v0 := 20
v1 := 0
loop
while v1 != 25
sprite v0 v1 5
v1 += 5
v2 := 5
loop
v2 += -1
if v2 != 0 then
again
again
sprite v0 v1 5
loop again
+34
View File
@@ -0,0 +1,34 @@
###########################################
#
# Next Test
#
# Demonstrates the use of the :next
# operative to refer to the second byte
# of an instruction. Mainly used for
# writing self-modifying code.
#
###########################################
: lt v0 := -1 i := vx save v0 ;
: rt v0 := 1 i := vx save v0 ;
: up v0 := -1 i := vy save v0 ;
: dn v0 := 1 i := vy save v0 ;
: main
va := 2
vb := 8
loop
clear
i := hex vc
sprite va vb 5
:next vx va += 1
:next vy vb += 1
if va == 0 then rt
if va == 59 then lt
if vb == 0 then dn
if vb == 26 then up
again
+66
View File
@@ -0,0 +1,66 @@
###########################################
#
# Quirks Mode Tests
#
# Examines the behavior of operations
# which have multiple interpretations
# in the wild and demonstrates the
# distinction between Octo's defaults
# and quirks modes for each instruction.
#
###########################################
: buffer 0 3
: main
# Perform a shift where source and dest
# differ. The correct behavior will draw a 1
# while in-place vx modification will draw 2.
v0 := 4
v1 := 2
v0 >>= v1
i := hex v0
va := 5
sprite va va 5
# perform a repeated store and load.
# the correct behavior should print 3 due to i autoincrements.
# quirks mode will print 4.
i := buffer
v0 := 4
save v0
v0 := 9 # just clobber v0 in case
load v0
i := hex v0
vb := 12
sprite va vb 5
# perform an arithmetic operation which stores to vf.
# the correct behavior should write the carry flag last, resulting in 0.
# quirks mode will print 6.
vf := 3
vf <<= vf
i := hex vf
vb := 19
sprite va vb 5
# try a jump0 instruction.
# the correct behavior should respect the value of v0 as an offset, resulting in 7
# quirks mode will respect v2 instead (in this case), resulting in 8.
v0 := 8
v2 := 4
jump0 jump-table
: jump-table
0x00 0x00 0x00 0x00
vf := 8 jump show-jump0-result
vf := 7 jump show-jump0-result
0x00 0x00 0x00 0x00
: show-jump0-result
i := hex vf
va := 10
vb := 5
sprite va vb 5
loop again
+69
View File
@@ -0,0 +1,69 @@
###########################################
#
# Unpacking Tests
#
# Uses the :unpack operative to perform
# self-modification and rewrite an
# i := NNN instruction.
#
###########################################
: font
0x20 0x20 0x20 0x00 0x20 0xF0 0x10 0x70 0x00 0x40 0xE0 0x90 0xE0 0x90 0x90 0x90
0xE0 0x90 0xE0 0x90 0xE0 0x80 0x80 0xD0 0xB0 0xB0 0x90 0x90 0x90 0x90 0x60 0x60
0x90 0x90 0x90 0x60 0x90 0xD0 0xB0 0x90 0x90 0x90 0x50 0x20 0x40 0x00 0x00 0x00
0x00 0x00 0x60 0x90 0xF0 0x90 0x90 0xF0 0x90 0x90 0xF0 0x80 0xE0 0x80 0x80 0x80
0x80 0xF0 0x80 0xE0 0x80 0xF0 0x40 0x40 0x40 0xF0 0x20 0x40 0x80 0xF0 0x20 0x20
0x20 0xC0 0x60 0x90 0x80 0x90 0x60 0x90 0x90 0xB0 0x70 0x80 0xB0 0x90 0x70 0x80
0x60 0x10 0xE0 0x90 0xA0 0xC0 0xA0 0x90 0x90 0xB0 0xB0 0xD0 0xF0 0x40 0x40 0x40
0x40 0x90 0x90 0x70 0x10 0xE0
# draw and linewrap a string at an address given
# in the v0-v1 registers. The string will consist
# of a sequence of offsets into the font data:
: display-string
i := string-addr
save v1
v1 := 2 # character x
v2 := 1 # character y
v3 := 0 # byte index
# v4 contains string length
loop
: string-addr 0 0
i += v3
load v0
i := font
i += v0
sprite v1 v2 5
v1 += 5
if v1 == 62 then v2 += 6
if v1 == 62 then v1 := 2
v3 += 1
if v3 != v4 then
again
;
: demo-string
0x71 0x1F 0x1A 0x2D 0x35 0x41 0x32 0x0A 0x2D 0x2D 0x2D 0x2D 0x32 0x2D 0x0A 0x1A
0x17 0x10 0x3D 0x41 0x2D 0x45 0x24 0x2D 0x6C 0x35 0x41 0x2D 0x0C 0x45 0x5E 0x6C
0x32 0x24 0x52 0x41
:const demo-string-length 36
# these constants demonstrate all the valid opcodes
# which can be built with the high nybble in :unpack
:const JUMP 0x1 # jump <label>
:const CALL 0x2 # <label>
:const INDEX 0xA # i := <label>
:const JUMP0 0xB # jump0 <label>
# these aliases are defaults but can be overridden
# to unpack into alternate registers
:alias unpack-hi v0
:alias unpack-lo v1
: main
:unpack INDEX demo-string
v4 := demo-string-length
display-string
loop again
+18
View File
@@ -0,0 +1,18 @@
###########################################
#
# Key Input Test
#
# Prompt for a keypress,
# then display its hex digit onscreen.
#
###########################################
: main
v0 := 20
v1 := 10
loop
v2 := key
clear
i := hex v2
sprite v0 v1 5
again
+103
View File
@@ -0,0 +1,103 @@
###########################################
#
# XO-Chip Tests
#
# Perform basic exercises demonstrating
# the XO-Chip extended instructions
# to verify the behavior of the compiler,
# emulator and disassembler.
#
###########################################
: main
# demonstrate playing an audio sample:
i := long gurgle
audio
v0 := 3
loop
vf := 10
buzzer := vf
vf := 15
wait
v0 += -1
if v0 != 0 then
again
# demonstrate drawing a color sprite:
plane 3
i := long rocket
v2 := 24
sprite v2 v1 0
# demonstrate the ranged load instructions
# drawing hex characters to plane 2.
# should display F B A.
print-init
i := long data1
load vf - vf
print
i := long data2
load v1 - v0
vf := v0 print
vf := v1 print
# demonstrate vertical scrolling
# in both directions with one plane:
plane 1
loop
v0 := 0
loop
vf := 5 wait
scroll-down 1
v0 += 1
if v0 != 16 then
again
loop
vf := 5 wait
scroll-up 1
v0 += -1
if v0 != 0 then
again
vf := 20 wait
again
: wait
delay := vf
loop
vf := delay
if vf != 0 then
again
;
: print-init
plane 2
ve := 4
vd := 1
;
: print
i := hex vf
sprite ve vd 5
vd += 6
;
# place static data beyond normal addressing space:
:org 0x1000
: gurgle
0x55 0xAA 0x55 0xAA 0x55 0xAA 0x55 0xAA
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
: rocket
0x03 0xC0 0x05 0xE0 0x08 0x70 0x09 0xF0
0x13 0xF8 0x12 0xF8 0x11 0xB8 0x08 0x30
0x08 0xB0 0x04 0x60 0x04 0xE0 0x1E 0x78
0x2E 0x5C 0x26 0x4C 0x23 0xC4 0x3C 0x3C
0x03 0xC0 0x06 0x20 0x0F 0x90 0x0F 0x90
0x1E 0x48 0x1F 0x48 0x1F 0xC8 0x0F 0xD0
0x0F 0xD0 0x07 0xA0 0x07 0xA0 0x1B 0xD8
0x33 0xE4 0x3B 0xF4 0x3F 0xFC 0x3C 0x3C
: data1 0x0F
: data2 0x0A 0x0B