163 lines
3.7 KiB
Plaintext
163 lines
3.7 KiB
Plaintext
_runtimePath_ "../runtime"
|
|
_codeRomType_ ROMv1
|
|
|
|
const fgBgColour = &h0008
|
|
set FGBG_COLOUR, fgBgColour
|
|
cls
|
|
'load font, ../../images/gbas/Fonts/sc3000/sc3000.tga, 0, fgBgColour
|
|
|
|
data 1, "one", 2, "two", 3, "three", 4, "four", 5, "five", 6, "test", 7, "yes", 8, "no"
|
|
|
|
for i=1 to 4
|
|
read a, a$
|
|
print i;" ";hex$(a, 4);" : ";a$
|
|
next i
|
|
|
|
print
|
|
restore 2
|
|
|
|
for i=1 to 7
|
|
read a, a$
|
|
print i;" ";hex$(a, 4);" : ";a$
|
|
next i
|
|
|
|
dim strings$(3) = "test", "dog", "cat", "fish"
|
|
a = 2
|
|
oops$ = strings$(a)
|
|
print oops$;" ";strings$(a);" ";strings$(0);" ";strings$(a + 1);" ";hex$(@strings$, 4)
|
|
print #oops$;" ";#strings$;" ";hex$(@strings$(0), 4);" ";hex$(@strings$(1, 3), 4);" ";chr$(peek(addr(strings$(a + 1)) + 1));" ";peek(@strings$(0, 1))
|
|
|
|
input fff$
|
|
print
|
|
|
|
'elements 4 to 5 are initialised to -1
|
|
dim test1d%(5) = 1, 2, 3, 0xAA55, 23
|
|
|
|
def fn func(x, y, z) = x + y + z + j
|
|
|
|
j = 10
|
|
print func(8, 8, 8) + func(1, 1, 1) + func(3, 3, 3);" ";
|
|
|
|
gosub asmTest
|
|
|
|
for i=10 &downto 0
|
|
next i
|
|
|
|
for i=-10 &to 0
|
|
next i
|
|
|
|
for i=10 &downto 1
|
|
next i
|
|
|
|
a = 2
|
|
a = test1d(a)
|
|
print a;" ";hex$(test1d(3), 4);" ";hex$(test1d(3).lo, 4);" ";hex$(test1d(3).hi, 4);" ";
|
|
|
|
dim test2d%(1, 1) = 0, 1
|
|
print test2d(0, 0);" ";test2d(0, 1)
|
|
test2d(0, 1) = &hBEEF
|
|
print test2d(0, 0);" ";hex$(test2d(0, 1), 4)
|
|
|
|
dim test3d%(2, 2, 4) = 1, 2, 3, 4, 0
|
|
print test3d(1, 2, 3);" ";
|
|
test3d(1, 2, 3) = &hAA55
|
|
print hex$(test3d(1, 2, 3), 4)
|
|
|
|
dim arr3d%(2, 2, 2) = 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
|
|
|
|
for i=0 to 2
|
|
for j=0 to 2
|
|
for k=0 to 2
|
|
arr3d(i, j, k) = i*9 + j*3 + k
|
|
next k
|
|
next j
|
|
next i
|
|
for i=0 to 2
|
|
for j=0 to 2
|
|
for k=0 to 2
|
|
print arr3d(i, j, k).lo;" ";
|
|
next k
|
|
next j
|
|
next i
|
|
print
|
|
|
|
strTest$ = "dogcat"
|
|
print len(test1d);" ";len(test2d);" ";len(test3d);" ";len(arr3d);" ";len(strTest$)
|
|
print hex$(@test1d, 4);" ";hex$(@test2d, 4);" ";hex$(@test3d, 4);" ";hex$(@arr3d, 4)
|
|
print peek(@test1d(0));" ";peek(@test2d(0, 0));" ";hex$(peek(@test3d(0, 0, 2)), 4);" ";peek(@arr3d(1, 1, 1));" ";
|
|
index0=0 : print peek(addr(test1d(index0)));" ";
|
|
index0=0 : index1=0 : print peek(addr(test2d(index0, index1)));" ";
|
|
index0=0 : index1=0 : index2=2 : print peek(addr(test3d(index0, index1, index2)));" ";
|
|
index0=1 : index1=1 : index2=1 : print peek(addr(arr3d(index0, index1, index2)))
|
|
|
|
aaa = @arr3d
|
|
aaa = deek(aaa + 2) ' arrays k pointers are always 2 bytes, so multiply your k index by 2
|
|
aaa = deek(aaa + 2) ' arrays j pointers are always 2 bytes, so multiply your j index by 2
|
|
print deek(aaa + 2);' arrays i values are always 2 bytes, so multiply your i index by 2
|
|
|
|
x = 0 : y = x : z = y
|
|
|
|
x = 20
|
|
blah = (53 - 12 - 9) + x*20
|
|
print " ";blah;" ";
|
|
|
|
x = 10
|
|
blah = x*2*(50*exp(-1.232455)*sin(45)*cos(57.324786234) - 1000.342876324) 'transcendentals use degrees by default
|
|
print blah
|
|
|
|
print pow(144, 0.5);" ";sqrt(256.0);" ";exp2(13);" ";exp(5);" ";log(148);" ";log2(2048);" ";log10(10000);" ";atan2(10.0, -10.0)
|
|
|
|
print hex$(lup(&h0920, 0), 2);" ";hex$(lup(&h0920, 1), 2)
|
|
|
|
'loop:
|
|
' a = rnd(2) + 1
|
|
' gosub a
|
|
'
|
|
' b = rnd(2) + 3
|
|
' goto b
|
|
'goto &loop
|
|
'
|
|
'' Numeric GOSUB identifies line numbers with ':'
|
|
'1: print "1" : return
|
|
'2: print "2" : return
|
|
'
|
|
'' Numeric GOTO identifies line numbers with '!'
|
|
'3! print "3" : goto loop
|
|
'4! print "4" : goto loop
|
|
|
|
|
|
kk = 255
|
|
|
|
call doStuff, a + 1 * sgn(a), x, y, fgBgColour
|
|
|
|
loop:
|
|
k = get("SERIAL_RAW")
|
|
if kk &= 255
|
|
if k &<>255 then gosub k
|
|
endif
|
|
kk = k
|
|
goto loop
|
|
|
|
49: print "1" : return
|
|
50: print "2" : return
|
|
51: print "3" : return
|
|
|
|
asmTest:
|
|
asm
|
|
LDW _i
|
|
STW _i
|
|
endasm
|
|
return
|
|
|
|
proc doStuff, a, b, c, d
|
|
local e, f, g, h
|
|
|
|
e = 3
|
|
f = a + e
|
|
g = a + b + c + d
|
|
h = e*f
|
|
|
|
print a;" ";b;" ";c;" ";d;" ";e;" ";f;" ";g;" ";h;" ";hex$(@a, 2);" ";#b
|
|
|
|
print min(1, 2);" ";max(3, -1);" ";clamp(8, c, f);" ";
|
|
endproc |