Skip to content

Commit badb4bd

Browse files
author
EgonOlsen
committed
Added corona game test case
1 parent fda0b79 commit badb4bd

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed

src/test/java/com/sixtyfour/test/TransformerTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,17 @@ public static void main(String[] args) throws Exception {
123123
testChrOptimizer();
124124
testCcTestOptimizer();
125125
testDefFnArray();
126+
testCorona();
126127

127128
}
128129

130+
private static void testCorona() throws Exception {
131+
System.out.println("\n\ntestCorona");
132+
String[] vary = Loader.loadProgram("src/test/resources/transform/corona.bas");
133+
Assembler assy = initTestEnvironment(vary, false, -1, true);
134+
FileWriter.writeAsPrg(assy.getProgram(), path + "++corona.prg", true);
135+
}
136+
129137
private static void testDefFnArray() throws Exception {
130138
System.out.println("\n\ntestDefFnArray");
131139
String[] vary = Loader.loadProgram("src/test/resources/transform/deffnarray.bas");
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
10 poke 53280,0:poke 53281,0
2+
20 gosub 10000:mv=12:dim vp%(mv),vs%(mv):sc=0::dd=0:iv=3:rc=200
3+
25 dim ya%(rc),xa%(rc):gosub 12000:gosub 26130
4+
30 x=20:y=10:df=0:xd=-1:yd=-1:gosub 9000
5+
40 v=160:gosub 11000:gosub 11100:gosub 10500
6+
50 gosub 25000:gosub 20000
7+
60 if df=1 then gosub 22000
8+
70 gosub 29000:goto 50
9+
10+
9000 xv=rnd(0):for i=0 to mv
11+
9010 xv=int(rnd(1)*30+3):yv=int(rnd(1)*20)
12+
9020 vp%(i)=xv+yv*40+1024:vs%(i)=5
13+
9030 next
14+
9040 for i=0 to iv-1:vs%(i)=10:next:return
15+
16+
10000 poke646,1:print chr$(147);
17+
10005 poke 211,4:poke 214,5:poke 646,1:sys 58640
18+
10006 print "detecting virus - please wait..."
19+
10010 for i=1025 to 1865 step 40:poke i,93:next
20+
10020 for i=1062 to 1902 step 40:poke i,93:next
21+
10030 for i=1906 to 1941:poke i,64:next
22+
10040 poke 1905,109:poke 1942,125
23+
10050 for i=55296 to 55296+24*40 step 40:poke i,2:next
24+
10060 for i=55335 to 55335+24*40 step 40:poke i,2:next
25+
10070 for i=56216 to 56216+37:poke i,2:next
26+
10080 return
27+
28+
10500 poke 211,4:poke 214,5:poke 646,1:sys 58640
29+
10510 print " ":return
30+
31+
11000 ps=y*40:poke 1024+ps,v:return
32+
11100 poke 1944+x,v:return
33+
34+
12000 xa=rnd(0):rp=0:for i=0 to rc
35+
12010 xa=rnd(1):ya=rnd(1)
36+
12020 if xa<0.2 then xa=0:goto 12050
37+
12030 if ya<0.2 then ya=0:goto 12050
38+
12040 xa=xa-0.7:ya=ya-0.7
39+
12050 xa=sgn(xa):ya=sgn(ya)*40
40+
12060 ya%(i)=ya:xa%(i)=xa:next:return
41+
42+
20000 j=peek(56320)
43+
20010 if (j and 1)=1 then 20100
44+
20020 y2=y-1:if y2<0 then 20100
45+
20030 v=32:gosub 11000:y=y2:v=160:gosub 11000
46+
20100 if (j and 2)=2 then 20200
47+
20110 y2=y+1:if y2>21 then 20200
48+
20120 v=32:gosub 11000:y=y2:v=160:gosub 11000
49+
20200 if (j and 4)=4 then 20300
50+
20210 x2=x-1:if x2<2 then 20300
51+
20220 v=32:gosub 11100:x=x2:v=160:gosub 11100
52+
20300 if (j and 8)=8 then 20400
53+
20310 x2=x+1:if x2>37 then 20400
54+
20320 v=32:gosub 11100:x=x2:v=160:gosub 11100
55+
20400 if (j and 16)=16 then 20500
56+
20410 df=1:xd=x:yd=y:xc=2:yc=21
57+
20420 px=yc*40+1024+xd:p=peek(px):if p=91 or p=93 then xd=-1
58+
20430 py=xc+1024+yd*40:p=peek(py):if p=91 or p=64 then yd=-1
59+
20500 return
60+
61+
22000 if xd=-1 then 23000
62+
22010 px=yc*40+1024+xd
63+
22015 p=peek(px):if p=90 then p=32:gosub 26000
64+
22018 if p=32 then p=93:goto 22200
65+
22020 if p=64 then p=91
66+
22200 poke 54272+px,7:poke px,p:px=px-40:yc=yc-1
67+
22210 if yc>-1 then 22015
68+
23000 if yd=-1 then 24000
69+
23010 py=xc+1024+yd*40
70+
23015 p=peek(py):if p=90 then p=32:gosub 26050
71+
23018 if p=32 then p=64:goto 23200
72+
23020 if p=93 then p=91
73+
23200 poke 54272+py,7:poke py,p:py=py+1:xc=xc+1
74+
23210 if xc<38 then 23015
75+
24000 xd=-1:yd=-1:return
76+
77+
25000 for i=0 to mv:si=vs%(i)
78+
25005 gosub 28000:if si=11 then 25100
79+
25010 xa=xa%(rp):ya=ya%(rp):rp=rp+1:if rp>rc then rp=0
80+
25020 po=vp%(i):if po<1064 and ya=-1 then ya=0
81+
25030 pn=po+xa+ya:p=peek(pn)
82+
25040 if p=90 and si=10 then gosub 27000:goto 25100
83+
25050 if p<>32 then 25100
84+
25060 poke 54272+pn,si:poke po,32:poke pn,90:vp%(i)=pn
85+
25100 next:return
86+
87+
26000 sv=peek(54272+px) and 15:pp=px:goto 26100
88+
26050 sv=peek(54272+py) and 15:pp=py:goto 26100
89+
26100 gosub 26500
90+
26110 if sv=10 then iv=iv-1
91+
26120 if sv<>11 then sc=sc-100:dd=dd+1
92+
26130 poke 211,2:poke 214,24:poke 646,12:sys 58640:print"score: ";sc;
93+
26140 return
94+
95+
26500 for o=0 to mv:if vp%(o)=pp then vs%(o)=11:return
96+
26510 next:return
97+
98+
27000 px=pn
99+
27010 for o=0 to mv:if vp%(o)=px and o<>i then 27050
100+
27020 next:return
101+
27050 vo=vs%(o):ns=10:if vo=6 then ns=6:gosub 26130
102+
27055 if vo<>10 and vo<>11 and ns=10 then sc=sc-20:iv=iv+1:gosub 26130
103+
27060 pn=po:vs%(o)=ns:xa=0:ya=0
104+
27070 poke 54272+vp%(o),ns:return
105+
106+
28000 if si<>10 then return
107+
28010 r=rnd(1):if r<0.003 then si=11:dd=dd+1:iv=iv-1:sc=sc-30
108+
28020 if r>0.992 then si=6:iv=iv-1:sc=sc+40
109+
28030 gosub 28100:return
110+
111+
28100 vs%(i)=si:poke 54272+vp%(i),si:return
112+
113+
29000 if iv>0 then return
114+
29010 sc=sc+25*(mv-dd)
115+
29020 gosub 26130
116+
29030 poke 211,3:poke 214,5:poke 646,1:sys 58640
117+
29040 print "virus exterminated - fire to start"
118+
29050 if (peek(56320) and 16)=0 then 29050
119+
29060 if (peek(56320) and 16)=0 then run
120+
29070 goto 29060

0 commit comments

Comments
 (0)