# Artillery 1.4.2

a guest
Nov 5th, 2019
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.    10 GO TO 2630
2.    20 REM Artillery, based on the 1987 Macintosh game by Kirk Crawford
3.    30 REM Started in about 1994 and mostly developed in Feb 2019 by patters
4.    40 REM
5.    50 REM sub - trajectories loop
6.    60 REM
7.    70 FOR t=0 TO 30 STEP 0.5
8.    80 POKE 23677,r: POKE 23678,s: LET p1=j: LET p3=f
9.    90 LET v1=v1+z/8
10.   100 LET x=o1+v1*t
11.   110 LET y=o3+v3*t-4.905*t*t
12.   120 LET j=x>=0
13.   130 IF y<0 THEN LET f=0
14.   140 IF x>255 THEN LET j=0: IF y<c2 THEN LET f=0
15.   150 IF h=1 THEN LET h=0: PRINT c\$
16.   160 IF h=2 THEN LET h=0: PRINT e\$
17.   170 IF NOT f THEN GO TO 240
18.   180 IF y>175 THEN LET j=0: IF x>=0 AND x<=255 THEN LET c\$(3)=CHR\$ (INT (x/8)): PRINT c\$: LET h=1
19.   190 IF x>255 THEN IF y>=c2 AND y<=175 THEN LET e\$(2)=CHR\$ (21-INT (y/8)): PRINT e\$: LET h=2
20.   200 IF NOT j THEN GO TO 240
21.   210 IF p1 THEN DRAW INK 3;x-r,y-s
22.   220 IF NOT p1 THEN PLOT INK 3;x,y
23.   230 IF ATTR (21-INT (y/8),INT (x/8))=gd THEN LET f=0
24.   240 IF NOT h2 THEN IF PEEK a+PEEK b+PEEK c+PEEK d<>cs THEN LET h2=1: PRINT h\$: BEEP .4,-20: LET s\$=s\$+"2": IF x>127 THEN LET f=0: LET p3=0
25.   250 IF NOT f THEN IF p3 THEN BEEP .01,-20
26.   260 LET r=PEEK 23677: LET s=PEEK 23678
27.   270 POKE 23677,p: POKE 23678,q: LET p2=i: LET p4=e
28.   280 LET v2=v2+z/8
29.   290 LET v=o2+v2*t
30.   300 LET w=o4+v4*t-4.905*t*t
31.   310 LET i=v<=255
32.   320 IF w<0 THEN LET e=0
33.   330 IF v<0 THEN LET i=0: IF w<c1 THEN LET e=0
34.   340 IF g=1 THEN LET g=0: PRINT d\$
35.   350 IF g=2 THEN LET g=0: PRINT f\$
36.   360 IF NOT e THEN GO TO 430
37.   370 IF w>175 THEN LET i=0: IF v>=0 AND v<=255 THEN LET d\$(3)=CHR\$ (INT (v/8)): PRINT d\$: LET g=1
38.   380 IF v<0 THEN IF w>=c1 AND w<=175 THEN LET f\$(2)=CHR\$ (21-INT (w/8)): PRINT f\$: LET g=2
39.   390 IF NOT i THEN GO TO 430
40.   400 IF p2 THEN DRAW INK 3;v-p,w-q
41.   410 IF NOT p2 THEN PLOT INK 3;v,w
42.   420 IF ATTR (21-INT (w/8),INT (v/8))=gd THEN LET e=0
43.   430 IF NOT h1 THEN IF PEEK l+PEEK m+PEEK n+PEEK o<>cs THEN LET h1=1: PRINT g\$: BEEP .4,-20: LET s\$=s\$+"1": IF v<128 THEN LET e=0: LET p4=0
44.   440 IF NOT e THEN IF p4 THEN BEEP .01,-20
45.   450 LET p=PEEK 23677: LET q=PEEK 23678
46.   460 IF f OR e THEN NEXT t
47.   470 RETURN
48.   480 REM
49.   490 REM sub - redraw terrain
50.   500 REM
51.   510 LET t=0: IF te<>tp OR bt<>bp THEN LET t=1
52.   520 IF bt=bs THEN IF sk=sp THEN IF te=tp THEN LET t=2
53.   530 FOR y=s TO e STEP dd
54.   540 IF dd=-1 THEN IF y=18 THEN IF rv THEN GO SUB 1420
55.   550 IF t=2 THEN PRINT AT y,0; PAPER 8; INK 8; BRIGHT bs; OVER 1;TAB 31;" ": GO TO 590
56.   560 IF c(y+1,1) THEN PRINT AT y,0; PAPER sk; BRIGHT bs; OVER ov; INK 8;TAB c(y+1,1)-1;" "
57.   570 IF t THEN PRINT AT y,c(y+1,1); PAPER te; BRIGHT bt; OVER 1; INK 8;TAB c(y+1,2);" "
58.   580 IF c(y+1,2)<31 THEN PRINT AT y,c(y+1,2)+1; PAPER sk; BRIGHT bs; OVER ov; INK 8;TAB 31;" "
59.   590 IF y=k THEN PRINT a\$(30 TO )
60.   600 IF y=k-1 THEN PRINT a\$(17 TO 29)
61.   610 IF y=k-2 THEN PRINT a\$( TO 16)
62.   620 IF y=u THEN PRINT b\$(30 TO )
63.   630 IF y=u-1 THEN PRINT b\$(17 TO 29)
64.   640 IF y=u-2 THEN PRINT b\$( TO 16)
65.   650 NEXT y
66.   660 IF dd=1 AND rv THEN GO SUB 1420: REM draw water
67.   670 RETURN
68.   680 REM
69.   690 REM sub - generate and draw terrain
70.   700 REM
71.   710 DIM c(22,2): REM terrain matrix, last 2 rows for water extents
72.   720 REM generate terrain left to right with sine function
73.   730 LET yp=k+2: REM previous y value
74.   740 LET t=0: REM x is river
75.   750 LET p=0: REM prev x is river
76.   760 LET ym=19: REM peak
77.   770 FOR x=x1+3 TO x2-2
78.   780 LET n=ABS (31*q-x): REM x-flip
79.   790 LET y=21-INT (v*SIN (PI/w*n-s)+r+0.5)
80.   800 REM river extents
81.   810 IF y>19 THEN LET y=19: IF rv THEN LET t=1
82.   820 IF t THEN IF NOT p THEN LET c(21+(c(21,1)<>0),1)=x: REM start
83.   830 IF NOT t THEN IF p THEN LET c(21+(c(21,2)<>0),2)=x-1: REM end
84.   840 IF t THEN IF x=x2-2 THEN LET c(21+(c(21,2)<>0),2)=x: REM catch last extent
85.   850 LET p=t: LET t=0
86.   860 IF y<0 THEN LET y=0
87.   870 PRINT AT y,x;"-"
88.   880 REM find horizontal extents
89.   890 IF y<>yp THEN LET c(y+1,2-(y<yp))=x
90.   900 IF y>yp THEN LET c(yp+1,2)=x-1: REM fix descending extents after gaps
91.   910 LET yp=y
92.   920 IF y<ym THEN LET ym=y: REM peak
93.   930 NEXT x
94.   940 IF u+1>y THEN LET c(y+1,2)=x-1: REM fix last descending extent
95.   950 FOR y=k+1 TO 19: LET c(y+1,1)=0: NEXT y: REM castle 1 footing
96.   960 FOR y=u+1 TO 19: LET c(y+1,2)=31: NEXT y: REM castle 2 footing
97.   970 REM edge detection pass
98.   980 LET v=0: LET w=0
99.   990 FOR y=ym TO 19
100.  1000 IF NOT c(y+1,1) AND y<=k THEN LET c(y+1,1)=v
101.  1010 IF NOT c(y+1,2) THEN LET c(y+1,2)=w
102.  1020 LET v=c(y+1,1): LET w=c(y+1,2)
103.  1030 NEXT y
104.  1040 REM
105.  1050 REM draw terrain
106.  1060 REM
107.  1070 LET ov=0
108.  1080 FOR y=19 TO ym STEP -1
109.  1090 IF y=18 THEN IF rv THEN GO SUB 1420: REM draw water
110.  1100 IF y=k THEN PRINT a\$
111.  1110 IF y=u THEN PRINT b\$
112.  1120 PRINT AT y,c(y+1,1); PAPER te; INK 3; BRIGHT bt;TAB c(y+1,2);" "
113.  1130 NEXT y
114.  1140 IF k<=ym THEN PRINT a\$
115.  1150 IF u<=ym THEN PRINT b\$
116.  1160 RETURN
117.  1170 REM
118.  1180 REM sub - redraw sky
119.  1190 REM
120.  1200 FOR y=s TO e STEP dd
121.  1210 PRINT AT y,0; OVER ov; INK 8;TAB 31;" "
122.  1220 IF y=k THEN PRINT a\$(30 TO )
123.  1230 IF y=k-1 THEN PRINT a\$(17 TO 29)
124.  1240 IF y=k-2 THEN PRINT a\$( TO 16)
125.  1250 IF y=u THEN PRINT b\$(30 TO )
126.  1260 IF y=u-1 THEN PRINT b\$(17 TO 29)
127.  1270 IF y=u-2 THEN PRINT b\$( TO 16)
128.  1280 NEXT y
129.  1290 RETURN
130.  1300 REM
131.  1310 REM sub - redraw terrain and sky
132.  1320 REM
133.  1330 LET ov=1: LET dd=-1: IF td=1 OR td=4 THEN LET dd=1: REM draw dir, sunrise or sunset
134.  1340 IF td=3 AND tn>4 THEN LET ov=0: LET tn=0: REM nightfall scrubs trails in sky after 4 turns
135.  1350 IF dd=-1 THEN LET s=19: LET e=ym: GO SUB 510: LET s=ym-1: LET e=0: GO SUB 1200
136.  1360 IF dd=1 THEN LET s=0: LET e=ym-1: GO SUB 1200: LET s=ym: LET e=19: GO SUB 510
137.  1370 PRINT a\$+b\$: REM redraw castles to catch edge cases
138.  1380 RETURN
139.  1390 REM
140.  1400 REM sub - draw water
141.  1410 REM
142.  1420 PRINT AT 19,c(21,1); PAPER 1; BRIGHT (bs=0); INK 3; OVER ov;TAB c(21,2)+(c(21,1)>0);AT 19,c(22,1);TAB c(22,2)+(c(22,1)>0)
143.  1430 RETURN
144.  1440 REM
145.  1450 REM sub - check input
146.  1460 REM
147.  1470 PRINT #0;AT 1,ix;"Entry error": PAUSE 50
148.  1480 INPUT AT 1,ix;(v\$;" [";d;"]: "); LINE i\$
149.  1490 IF i\$="" THEN LET i=d: RETURN
150.  1500 FOR n=1 TO LEN i\$: IF CODE i\$(n)<45 OR CODE i\$(n)>57 THEN GO TO 1470: NEXT n
151.  1510 LET i=INT VAL i\$
152.  1520 IF i<mn THEN LET i=mn: PRINT #0;"Constrained to min": PAUSE 50
153.  1530 IF i>mx THEN LET i=mx: PRINT #0;"Constrained to max": PAUSE 50
154.  1540 RETURN
155.  1550 PAPER 7: INK 0: BRIGHT 0: FLASH 0: BORDER 7: CLS
156.  1560 LET s1=0: LET s2=0: REM score
157.  1570 LET sk=0: LET te=0: LET bt=0: REM sky colour, terrain colour, terrain bright
158.  1580 LET td=1: REM time of day
159.  1590 LET ix=0: REM input x pos
160.  1600 LET wn=5: LET v\$="Score to win match (1-9)": LET d=wn: LET mn=1: LET mx=9: GO SUB 1480: LET wn=i
161.  1610 RANDOMIZE
162.  1620 REM
163.  1630 REM start round
164.  1640 REM
165.  1650 LET z=(INT (RND*11))-5: REM wind
166.  1660 IF td=5 THEN LET td=1: REM loop time of day counter
167.  1670 REM default params
168.  1680 LET a1=60: LET a2=60: REM angle (deg)
169.  1690 LET q1=45: LET q2=45: REM initial velocity
170.  1700 LET h1=0: LET h2=0: REM reset castle hit states
171.  1710 LET s\$="": REM records order castles are hit in
172.  1720 LET tn=0: REM turns
173.  1730 REM
174.  1740 REM terrain and castle setup
175.  1750 REM
176.  1760 LET v=(RND*8)+3: REM amplitude
177.  1770 LET w=(RND*4)+13: REM frequency
178.  1780 LET r=(RND*(17-((v<6)*v)+((v>9)*(12-v))))-2: REM y-offset
179.  1790 LET s=((RND*25)+2)/10: REM x-offset
180.  1800 LET q=INT (RND*2): REM terrain function may x-flip, to remove bias
181.  1810 REM castle 1 location
182.  1820 LET x1=2+(INT (RND*4))
183.  1830 LET n=ABS (31*q-(x1+2)): REM x-flip
184.  1840 LET k=21-INT (v*SIN (PI/w*n-s)+r+0.5)-1: REM castle is 1 row higher than terrain at x
185.  1850 IF k<4 THEN GO TO 1760: REM problem, reset terrain params
186.  1860 IF k>18 THEN LET k=18
187.  1870 REM castle 2 location
188.  1880 LET x2=28-(INT (RND*4))
189.  1890 LET n=ABS (31*q-(x2-1)): REM x-flip
190.  1900 LET u=21-INT (v*SIN (PI/w*n-s)+r+0.5)-1: REM castle is 1 row higher than terrain at x
191.  1910 IF u<4 THEN GO TO 1760: REM problem, reset terrain params
192.  1920 IF u>18 THEN LET u=18
193.  1930 REM castle coords valid, continue setup
194.  1940 LET lv=INT (RND*8)+2: REM level type, grass desert soil snow
195.  1950 IF lv>7 THEN LET lv=3: REM grass is more likely
196.  1960 LET rv=INT (RND*3): IF rv=2 THEN LET rv=0: REM water
197.  1970 IF lv=7 THEN LET rv=1
198.  1980 REM trajectory origin coords
199.  1990 LET o1=(x1+2)*8: LET o3=(21-k+2)*8
200.  2000 LET o2=(x2*8)-1: LET o4=(21-u+2)*8
201.  2010 GO SUB 3320: REM set up time of day
202.  2020 INK 0: CLS
203.  2030 GO SUB 3090: REM wind arrow
204.  2040 FOR n=20 TO 21: PRINT AT n,0; BRIGHT 0; PAPER 7; OVER 1;TAB 31;" ": NEXT n
205.  2050 REM
206.  2060 REM update castle sprites
207.  2070 REM
208.  2080 LET a\$(2 TO 3)=CHR\$ (k-2)+CHR\$ (x1+po): LET a\$(10 TO 13)=w\$(po+1)+CHR\$ 22+CHR\$ (k-2)+CHR\$ (x1+fl): LET a\$(16 TO 19)=w\$(fl+1)+CHR\$ 22+CHR\$ (k-1)+CHR\$ x1: LET a\$(31 TO 32)=CHR\$ k+CHR\$ x1
209.  2090 LET b\$(2 TO 3)=CHR\$ (u-2)+CHR\$ (x2+po): LET b\$(10 TO 19)=w\$(po+1)+CHR\$ 22+CHR\$ (u-2)+CHR\$ (x2+fl)+CHR\$ 16+CHR\$ 2+w\$(fl+1)+CHR\$ 22+CHR\$ (u-1)+CHR\$ x2: LET b\$(31 TO 32)=CHR\$ u+CHR\$ x2
210.  2100 LET g\$( TO 32)=a\$( TO 32): LET g\$(9)=CHR\$ 6: LET g\$(28)=CHR\$ 2
211.  2110 LET h\$( TO 32)=b\$( TO 32): LET h\$(9)=CHR\$ 6: LET h\$(28)=CHR\$ 2
212.  2120 GO SUB 3490: REM update sprite colours
213.  2130 GO SUB 710: REM generate and draw terrain
214.  2140 REM
215.  2150 REM start turn
216.  2160 REM
217.  2170 LET tn=tn+1
218.  2180 PRINT AT 21,1; BRIGHT 0; INVERSE 1; PAPER 7;"SCORE  ";AT 21,8-(s1>9);s1;AT 21,23;"SCORE  ";AT 21,30-(s2>9);s2
219.  2190 GO SUB 2900: REM player 1 input
220.  2200 PRINT a\$(11 TO 16)
221.  2210 GO SUB 2990: REM player 2 input
222.  2220 PRINT b\$(11 TO 16)
223.  2230 LET j=1: LET i=1: REM on-screen trajectory flag
224.  2240 LET f=1: LET e=1: REM projectile in flight flag
225.  2250 LET r=o1: LET s=o3: LET p=o2: LET q=o4: REM draw coords set to origins
226.  2260 REM velocity components
227.  2270 LET n=a1*PI/180: REM deg to rad
228.  2280 LET v1=q1*COS n
229.  2290 LET v3=q1*SIN n
230.  2300 LET n=(180-a2+180)*PI/180: REM deg to rad, x flip
231.  2310 LET v2=-q2*COS n
232.  2320 LET v4=-q2*SIN n
233.  2330 LET h=0: LET g=0: REM off screen arrows
234.  2340 LET c1=(21-k)*8: LET c2=(21-u)*8: REM castle footings y
235.  2350 REM castle ATTR mem addr
236.  2360 LET l=22528+k*32+x1: LET m=l+1: LET n=l-32: LET o=n+1
237.  2370 LET a=22528+u*32+x2: LET b=a+1: LET c=a-32: LET d=c+1
238.  2380 BEEP .1,-35
239.  2390 GO SUB 70: REM trajectories loop
240.  2400 REM
241.  2410 REM end of turn, check outcomes
242.  2420 REM
243.  2430 PRINT a\$(11 TO 16)+b\$(11 TO 16): REM fix flags colour clash
244.  2440 FOR n=0 TO 1: PRINT AT 20+n,0; BRIGHT 0; PAPER 7; OVER 1;TAB 31;" ": NEXT n: REM fix HUD colour clash
245.  2450 IF s\$="1" THEN LET pl=1: LET x=x1: LET y=k: GO SUB 3220: REM castle 1 collapse
246.  2460 IF s\$="2" THEN LET pl=2: LET x=x2: LET y=u: GO SUB 3220: REM castle 2 collapse
247.  2470 IF s\$="21" THEN LET pl=2: LET x=x2: LET y=u: GO SUB 3220: LET pl=1: LET y=k: LET x=x1: GO SUB 3220: REM castle 2 then 1 collapse
248.  2480 IF s\$="12" THEN LET pl=1: LET x=x1: LET y=k: GO SUB 3220: LET pl=2: LET y=u: LET x=x2: GO SUB 3220: REM castle 1 then 2 collapse
249.  2490 IF s\$<>"" THEN LET td=INT td+1: GO TO 3550: REM round over, increment time of day
250.  2500 IF td=2 OR td=4 THEN LET td=td+0.5: REM dawn and dusk last one turn only
251.  2510 LET td=td+0.5: IF td=5 THEN LET td=1: REM night and day last two turns
252.  2520 IF td-(INT td)=0 THEN GO SUB 3320: GO SUB 3490: GO SUB 1330: REM change time of day, update sprites, redraw screen
253.  2530 GO TO 2150: REM no score, round continues
254.  2540 REM
255.  2550 REM user defined graphics
256.  2560 REM
257.  2570 RESTORE 2590
258.  2580 FOR x=0 TO 71: READ y: POKE USR CHR\$ (144)+x,y: NEXT x
259.  2590 DATA 1,1,1,1,1,1,1,1,153,153,255,96,40,37,34,34,153,153,255,38,132,68,164,164,34,34,35,32,44,38,32,32,164,36,236,28,20,4,100,4,128,128,128,128,128,128,128,128,0,16,40,16,0,0,0,0,0,0,16,32,126,32,16,0,0,0,8,4,126,4,8,0
260.  2600 REM
261.  2610 REM variables setup, perf critical first
262.  2620 REM
263.  2630 LET x=0: LET y=0: LET v=0: LET w=0: LET r=0: LET s=0: LET p=0: LET q=0: LET t=0: LET v1=0: LET v3=0: LET v2=0: LET v4=0: LET o1=0: LET o3=0: LET o2=0: LET o4=0: LET f=0: LET e=0: LET j=0: LET i=0: LET h=0: LET g=0: LET p1=0: LET p2=0: LET p3=0: LET p4=0: LET h1=0: LET h2=0: LET gd=0: LET cs=0
264.  2640 LET c\$=CHR\$ 22+CHR\$ 0+CHR\$ 0+CHR\$ 21+CHR\$ 1+CHR\$ 19+CHR\$ 8+CHR\$ 17+CHR\$ 8+CHR\$ 16+CHR\$ 3+"^": LET d\$=c\$: LET e\$=c\$: LET f\$=c\$: LET e\$(12)="\i": LET e\$(3)=CHR\$ 31: LET f\$(12)="\h": REM offscreen arrows
265.  2650 DIM a\$(42): DIM b\$(42): REM castle sprites
266.  2660 DIM g\$(46): DIM h\$(46): REM hit castle sprites
267.  2670 LET a\$( TO 16)=CHR\$ 22+CHR\$ 17+CHR\$ 0+CHR\$ 17+CHR\$ 8+CHR\$ 19+CHR\$ 8+CHR\$ 16+CHR\$ 7+"\a"+CHR\$ 22+CHR\$ 17+CHR\$ 1+CHR\$ 16+CHR\$ 1+"\' ": REM castle flag,16 chars
268.  2680 LET a\$(17 TO 29)=CHR\$ 22+CHR\$ 18+CHR\$ 0+CHR\$ 19+CHR\$ 1+CHR\$ 16+CHR\$ 0+"\b"+CHR\$ 19+CHR\$ 0+CHR\$ 16+CHR\$ 1+"\c": REM castle top, 13 chars
269.  2690 LET a\$(30 TO 42)=CHR\$ 22+CHR\$ 19+CHR\$ 0+CHR\$ 19+CHR\$ 1+CHR\$ 16+CHR\$ 0+"\d"+CHR\$ 19+CHR\$ 0+CHR\$ 16+CHR\$ 1+"\e": REM castle base, 13 chars
270.  2700 LET b\$()=a\$
271.  2710 LET g\$()=a\$: LET g\$(36 TO 46)=CHR\$ 6+CHR\$ 17+CHR\$ 2+CHR\$ 18+CHR\$ 1+CHR\$ 21+CHR\$ 1+"\.'"+CHR\$ 19+CHR\$ 0+"\.'": REM hit castle
272.  2720 LET h\$()=g\$
273.  2730 DIM c(22,2): DIM d(32)
274.  2740 REM time of day colour lookup table
275.  2750 REM day,dusk,night,dawn - 1st row sky types, +10 for bright
276.  2760 RESTORE 2770
277.  2770 DATA 15,5,1,6
278.  2780 DATA 2,2,0,2
279.  2790 DATA 4,4,0,4
280.  2800 DATA 14,4,0,5
281.  2810 DATA 6,6,0,6
282.  2820 DATA 16,6,0,16
283.  2830 DATA 17,17,5,17
284.  2840 DIM e(7,4)
285.  2850 FOR n=1 TO 7: FOR t=1 TO 4: READ a: LET e(n,t)=a: NEXT t: NEXT n
286.  2860 GO TO 1550
287.  2870 REM
288.  2880 REM sub - user input player 1
289.  2890 REM
290.  2900 PRINT AT k-2,x1+fl; INK 1-(sk=1); FLASH 1; BRIGHT bs;"\..": REM highlight flag
291.  2910 LET ix=0: LET v\$="Angle": LET d=a1: LET mn=-45: LET mx=135: GO SUB 1480: LET a1=i
292.  2920 PRINT AT 20,1; PAPER 7; INK 0; BRIGHT 0;"    ";AT 20,1;a1;"\g"
293.  2930 LET ix=0: LET v\$="Velocity": LET d=q1: LET mn=20: LET mx=99: GO SUB 1480: LET q1=i
294.  2940 PRINT AT 20,6; PAPER 7; INK 0; BRIGHT 0;"    ";AT 20,6;"V";q1
295.  2950 RETURN
296.  2960 REM
297.  2970 REM sub - user input player 2
298.  2980 REM
299.  2990 PRINT AT u-2,x2+fl; INK 2; FLASH 1; BRIGHT bs;"\..": REM highlight flag
300.  3000 LET ix=15: LET v\$="Angle": LET d=a2: LET mn=-45: LET mx=135: GO SUB 1480: LET a2=i
301.  3010 PRINT AT 20,23; PAPER 7; INK 0; BRIGHT 0;"    ";AT 20,23;a2;"\g"
302.  3020 LET ix=12: LET v\$="Velocity": LET d=q2: LET mn=20: LET mx=99: GO SUB 1480: LET q2=i
303.  3030 PRINT AT 20,28; PAPER 7; INK 0; BRIGHT 0;"    ";AT 20,28;"V";q2
304.  3040 INPUT #1: REM clear bottom of screen
305.  3050 RETURN
306.  3060 REM
307.  3070 REM sub - wind arrow & flag
308.  3080 REM
309.  3090 LET r\$="No Wind": IF z>0 THEN LET m\$="-----": LET r\$=m\$(1 TO z-1)+">"
310.  3100 IF z THEN PRINT AT 21,14;"Wind"
311.  3110 IF z<0 THEN LET m\$="<-----": LET r\$=m\$(1 TO INT (ABS (z)+0.5))
312.  3120 LET n=INT ((32-(LEN r\$))/2)
313.  3130 PRINT AT 20,n; r\$
314.  3140 IF z<0 THEN PLOT (8*n)+3,11: DRAW (((LEN r\$)-1)*8)+3,0
315.  3150 IF z>0 THEN PLOT (8*n)+2,11: DRAW (((LEN r\$)-1)*8)+3,0
316.  3160 LET w\$="\a\' \. ": LET po=0: LET fl=1
317.  3170 IF z<0 THEN LET w\$="\ '\f\ .": LET po=1: LET fl=0
318.  3180 RETURN
319.  3190 REM
320.  3200 REM sub - castle collapse
321.  3210 REM
322.  3220 PRINT AT y-2,x+fl; INK pl-(pl=1 AND sk=1);w\$(3): PAUSE 10: PRINT AT y-2,x+fl;" ": PAUSE 10: PRINT AT y-2,x+fl; INK 7; BRIGHT bs;w\$(3): PAUSE 10: PRINT AT y-2,x+fl; INK 7; BRIGHT bs;w\$(fl+1)
323.  3230 PAUSE 60: PRINT AT y-2,x;"  ";AT y-1,x; INK 0; BRIGHT 1; OVER 1;"#"; BRIGHT 0; INK 1-(sk=1);"#";AT y,x; BRIGHT 1; INK 0;"\b"; BRIGHT 0; INK 1-(sk=1);"\c"
324.  3240 FOR n=20 TO -10 STEP -5: BEEP 0.005,n: NEXT n
325.  3250 PRINT AT y-1,x; INK 0; BRIGHT bs;"  ";AT y,x; BRIGHT bs; INVERSE 1; OVER 1;"00"
326.  3260 PRINT AT y,x-1; INK 0; BRIGHT bs;".";AT y,x+2; INK 1-(sk=1);"'"
327.  3270 PAUSE 20: PRINT AT y-2,x; INK 0; BRIGHT bs;"  ";AT y-1,x;"  ";AT y,x; BRIGHT 1;"\b"; BRIGHT 0; INK 1-(sk=1);"\c"; BRIGHT bs;",";AT y,x; OVER 1; BRIGHT 1; INK 0;"_"; INK 1-(sk=1); BRIGHT 0;"_"
328.  3280 PAUSE 20: RETURN
329.  3290 REM
330.  3300 REM sub - set time of day
331.  3310 REM
332.  3320 LET sp=sk: LET tp=te: LET bp=bt: REM store previous values
333.  3330 LET sk=e(1,td)
334.  3340 LET bs=0: REM sky bright
335.  3350 IF sk>10 THEN LET bs=1: LET sk=sk-10
336.  3360 LET te=e(lv,td)
337.  3370 LET bt=0: REM terrain bright
338.  3380 IF te>10 THEN LET bt=1: LET te=te-10
339.  3390 REM colour constraints
340.  3400 IF te=6 AND sk=6 THEN LET sk=5
341.  3410 IF te=5 AND sk=5 THEN LET sk=6: LET bs=0
342.  3420 PAPER sk: BRIGHT bs
343.  3430 LET gd=64*bt+8*te+3: REM ground ATTR
344.  3440 LET cs=32*sk+130-(sk=1)*2: REM castle aggregate ATTR
345.  3450 RETURN
346.  3460 REM
347.  3470 REM sub - update sprite colours
348.  3480 REM
349.  3490 IF sk=1 OR sp=1 THEN LET a\$(9)=CHR\$ (7-(sk=1)*2): LET b\$(9)=a\$(9): LET a\$(15)=CHR\$ (1-(sk=1)): LET a\$(28)=a\$(15): LET b\$(28)=a\$(15): LET a\$(41)=a\$(15): LET b\$(41)=a\$(15): LET g\$(15)=a\$(15): LET g\$(21 TO 23)=a\$(15)+CHR\$ 16+CHR\$ (0+(sk=1)*6): LET h\$(21 TO 23)=g\$(21 TO 23)
350.  3500 IF sk=6 OR sp=6 THEN LET g\$(9)=CHR\$ (6+(sk=6)): LET h\$(9)=g\$(9)
351.  3510 RETURN
352.  3520 REM
353.  3530 REM check scores
354.  3540 REM
355.  3550 PAPER 7: BRIGHT 0: INK 0: PAUSE 60
356.  3560 PRINT AT 21,1; BRIGHT 0; INVERSE 1; PAPER 7;"SCORE  ";AT 21,8-(s1>9);s1;AT 21,14; INVERSE 0;"    ";AT 21,23; INVERSE 1;"SCORE  ";AT 21,30-(s2>9);s2;AT 20,0; INVERSE 0;TAB 31;" "
357.  3570 FOR n=0 TO 10: PRINT AT n,0; OVER 1; BRIGHT 0;TAB 31;" ";AT 20-n,0;TAB 31;" ": NEXT n: PAUSE 20
358.  3580 IF h2=1 THEN LET s1=s1+1: BEEP 0.01,20: PRINT AT 21,8-(s1>9); INVERSE 1; PAPER 7; BRIGHT 1;s1: BEEP 0.01,30: PAUSE 30
359.  3590 IF h1=1 THEN LET s2=s2+1: BEEP 0.01,20: PRINT AT 21,30-(s2>9); INVERSE 1; BRIGHT 1; PAPER 7;s2: BEEP 0.01,30: PAUSE 30
360.  3600 PAUSE 60: FOR n=0 TO 10: PRINT AT n,0;TAB 31;" ";AT 20-n,0;TAB 31;" ": NEXT n
361.  3610 IF s1<wn AND s2<wn THEN GO TO 1650
362.  3620 IF s1=s2 THEN LET wn=wn+1: GO TO 1650: REM tied, play another round
363.  3630 REM
364.  3640 REM game over yeah
365.  3650 REM
366.  3660 IF s1=wn THEN LET pl=1
367.  3670 IF s2=wn THEN LET pl=2
368.  3680 CLS : BRIGHT bs: PAPER sk
369.  3690 FOR n=6 TO 12
370.  3700 IF n>10 THEN PAPER te: BRIGHT bt
371.  3710 PRINT AT n,12;TAB 19;" "
372.  3720 NEXT n
373.  3730 LET n=10: LET y=10: LET x=15: PAPER sk: BRIGHT bs: PRINT AT y-2,x; INK 7-(sk=1)*2;"\a"; INK pl-(pl=1 AND sk=1);"\' ";AT y-1,x;a\$(20 TO 29);AT y,x;a\$(33 TO ): PAUSE 5: PRINT AT y-2,x+1; INK pl-(pl=1 AND sk=1);"\''": PAUSE n
374.  3740 INK pl: PRINT AT 15,12; BRIGHT 0; INVERSE 1; PAPER 7;"VICTORY!"
375.  3750 LET x=x+2: LET y=y-2: PAUSE n: INK pl-(pl=1 AND sk=1): BRIGHT bs: PRINT AT y,x;"\' ": PAUSE n: PRINT AT y,x;"\. ": PAUSE n: FLASH 1: PRINT AT y,x;"\'.": PAUSE n*2: PRINT AT y,x;"\''": PRINT AT y,x+1; FLASH 0;"\' ": PAUSE n: PRINT AT y,x+1; FLASH 0;"\. ": PAUSE n: PRINT AT y,x+1;"\.."
376.  3760 BEEP 0.5,0: BEEP 0.25,0: BEEP 0.5,7
377.  3770 FLASH 0: PAPER 7: INK 0: BRIGHT 0: PAUSE 0: LET sp=1: LET sk=6: GO SUB 3490: GO TO 1550