-
Notifications
You must be signed in to change notification settings - Fork 4
/
AmstradCPC.txt
256 lines (256 loc) · 9.53 KB
/
AmstradCPC.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
10 REM *****************************************************
20 REM * *
30 REM * SPACE WAR *
40 REM * For one or two Players on a Graphics Terminal *
50 REM * Jobst Brandt *
60 REM * Hewlett-Packard *
61 REM * (01 Apr 82) *
65 REM * *
66 REM * Modified for the Apple ][ *
67 REM * by Chris Osborn *
68 REM * (06 Jun 90) *
70 REM * *
71 REM * Modified for the Amstrad CPC *
72 REM * by George Schizas *
73 REM * (22 Mar 2015) *
80 REM * *
90 REM *****************************************************
100 DIM c(46),oa(21,3),s(16,2),e(8,2)
110 MODE 2
120 REM Star locs and size: Xmax=720, Ymax=360, Smax=0, Smin=0
130 DATA 0,0,0,0,10,0,-2,0,0,2,-1,0,3,2,-8,0,-2,-2,-4,0,-4
140 DATA -2,4,-2,4,0,2,-2,8,0,-3,2,1,0,0,2
145 DATA -2,6,-2,-6,-6,-2,6,-2,2,-6,2,6,6,2,-6,2
150 FOR i = 1 TO 4: READ q(i): NEXT: FOR i = 1 TO 16: FOR j = 1 TO 2: READ s(i,j): NEXT j,i: FOR i = 1 TO 8: FOR j = 1 TO 2: READ e(i,j): NEXT j,i
160 GOSUB 2740:g = r1
170 REM -q CONTAINS Xlim,Ylim(screen),Distance,Maxsize(stars)
220 m = INT(2 * RND + 1):o = 0
230 n1$ = "9":p$ = "2"
250 GOSUB 2370
270 MODE 2
280 f1 = 0:f2 = 0:f3 = 0:v1$(1) = "20":v1$(2) = "20"
290 LOCATE 1, 23: PRINT CHR$(18)"(";p$;") One or two players? ";
300 INPUT "";a$:p1$ = a$
310 GOSUB 2000: ON r1 GOTO 290,290,290,270,290,2980
320 IF a$ = "" THEN a$ = p$
330 q = VAL(a$)
340 IF q <> 1 AND q <> 2 THEN 290
350 NP = q
360 p$ = STR$(NP)
370 IF NP = 2 THEN 400
380 n$(1) = "Player":n$(2) = "Enemy"
390 GOTO 470
400 n$(1) = "Spock":n$(2) = "Darth": FOR j = 1 TO 2
410 LOCATE 1, 23: PRINT CHR$(18)"("n$(j)") Name of captain #";j;" ";
420 INPUT "";a$
430 p1$ = a$: GOSUB 2000: ON r1 GOTO 280,440,280,270,280,2980
440 IF a$ = "" THEN 460
450 p1$ = a$: GOSUB 2610:n$(j) = r1$
460 NEXT j
470 LOCATE 1, 23: PRINT CHR$(18)"(";n1$;") How many stars?(0 to 18): ";
480 INPUT "";a$
490 p1$ = a$: GOSUB 2000: ON r1 GOTO 280,470,470,470,280,2980
500 IF a$ = "" THEN a$ = n1$
510 n = VAL(a$)
530 IF ABS(n) < 0 OR ABS(n) > 18 THEN 470
540 n1$ = STR$(n)
550 REM o=Black hole
560 o = (n < 0)
570 n = ABS(n)
580 q(4) = INT(10 - n / 6)
590 q(3) = INT(q(2) / 3) - n
600 CLS
610 REM -------------------- MAKE STARS ---------------------
620 n = n + o
630 ResetI = 0: FOR i = 1 TO n
640 r = 0
650 r = r + 1: ResetJ = 0
660 IF r > 20 THEN ResetI = 1: i = n + 1: GOTO 760
670 oa(i,3) = q(4)
680 REM -- j: 1 = Xpos, 2 = Ypos, 3 = Mass/Size --
690 FOR j = 3 TO 1 STEP - 1
700 oa(i,j) = INT((q(j) - 2 * oa(i,3)) * RND + oa(i,3))
710 NEXT j
720 FOR j = 1 TO i-1:IF j > i-1 THEN 750
730 t =(oa(i,3) + oa(j,3) + 10) ^ 2
740 IF (oa(i,1)-oa(j,1))^2 + (oa(i,2)-oa(j,2))^2 < t THEN j = i-2: ResetJ = 1
750 NEXT j: IF ResetJ THEN 650
760 NEXT i: IF ResetI THEN 630
770 REM ----------------- PLACE SPACE SHIPS -----------------
780 REM -- Space ship size = 5 --
790 oa(n + 1,3) = 5:oa(n + 2,3) = 5
800 FOR j = 1 TO 2
810 t = 4 * LEN(n$(j)): IF t < 10 THEN t = 10
820 IF j = 1 THEN i = 0.28 * q(1):q = 0: GOTO 840
830 t = - t:i = - 0.28 * q(1):q = q(1)
840 r = 0
850 r = r + 1: ResetK = 0
860 IF r > 20 THEN j = 3: ResetJ = 1: GOTO 940
870 x = INT(i * RND) + q + t
880 y = INT((q(2) - 30) * RND + 20)
890 FOR k = 1 TO n
900 IF (x - oa(k,1)) ^ 2 +(y - oa(k,2)) ^ 2 <(oa(k,3) * 2) ^ 2 THEN k = n+1: ResetK = 1
910 NEXT k: IF ResetK THEN 850
920 oa(n + j,1) = x
930 oa(n + j,2) = y
940 NEXT j: IF ResetJ THEN 630
950 a1$(1) = "0":a1$(2) = "180"
960 IF NP > 1 THEN a$ = n$(1):n$(1) = n$(2):n$(2) = a$
970 REM -------------------- PLOT STARS ---------------------
980 GRAPHICS PEN 1
990 z1 = 3.14159 *(1 / 180)
1000 FOR i = 0 TO 45
1010 c(i + 1) = COS(i * 10 * z1)
1020 NEXT i
1030 FOR i = 1 TO n - o
1040 FOR j = 1 TO 37
1050 x = INT(oa(i,1) + oa(i,3) * c(j) + 0.5)
1060 y = INT(oa(i,2) - oa(i,3) * c(j + 9) + 0.5)
1070 IF j = 1 THEN move x, q(2) - y
1080 DRAW x, q(2) - y
1090 NEXT j
1110 NEXT i
1130 REM ------------------ PLOT SPACE SHIPS -----------------
1140 FOR i = 1 TO 2
1150 p1 = oa(n + i,1):p2 = oa(n + i,2):p3$ = n$(i):p4 = i: GOSUB 2120
1160 NEXT i
1170 IF a$(1,1) = "i" THEN 1450
1180 GOTO 1210
1190 REM --------------------- PLAY GAME ---------------------
1200 m = m - INT(m / 2) * 2 + 1
1210 IF NP = 1 THEN m = 1
1240 LOCATE 1, 23: PRINT CHR$(18)"(" + a1$(m) + ") ";n$(m);"'s, launch angle: ";
1250 b = 20:f1 = 1
1260 INPUT "";a$
1270 IF a$ = "" THEN a$ = a1$(m)
1280 p1$ = a$: GOSUB 2000: ON r1 GOTO 1240,980,1240,270,1240,2980
1290 a = VAL(a$)
1300 a = - SGN(a) * (ABS(a) - INT(ABS(a) / 360) * 360)
1310 a1$(m) = STR$(-a)
1320 IF n = 0 THEN 1450
1330 LOCATE 1, 23: PRINT CHR$(18);
1340 PRINT "(";v1$(m);") ";n$(m);"'s initial velocity: ";
1350 INPUT "";a$
1360 IF a$ = "" THEN a$ = v1$(m)
1370 p1$ = a$: GOSUB 2000: ON r1 GOTO 1240,980,1330,270,1240,2980
1380 b = VAL(a$)
1390 IF b >= 0 AND b <= 20 THEN 1420
1400 LOCATE 1, 24: PRINT "Velocity must be from 0 to 20"
1410 GOTO 1330
1420 v1$(m) = STR$(b)
1450 u1 = 0:u2 = 0:v1 = 0:v2 = 0:f3 = 0
1460 x = 0.35 * b * COS(a * z1)
1470 y = 0.35 * b * SIN(a * z1)
1480 u = x + oa(n + m,1) + 8 * COS(a * z1)
1490 v = y + oa(n + m,2) + 8 * SIN(a * z1)
1500 p1 = u:p2 = v: GOSUB 2230
1510 IF f2 THEN 1570
1520 REM ----------------- DRAW ROCKET PATH ------------------
1530 u1 = INT(u + 0.5):v1 = INT(v + 0.5)
1540 IF u1 <> u2 OR v1 <> v2 THEN p1 = u1:p2 = v1: GOSUB 2290
1550 u2 = u1:v2 = v1
1560 REM -- e = Xforce, f = Yforce --
1570 e = 0:f = 0
1580 FOR j = 1 TO n
1590 r5 = oa(j,1) - u
1600 r6 = oa(j,2) - v
1610 r4 = r5 ^ 2 + r6 ^ 2
1620 r3 = SQR(r4)
1630 r2 = r5 / r3
1640 r1 = r6 / r3
1650 g = 0.017 *(oa(j,3) ^ 3) / r4
1660 e = e + g * r2
1670 f = f + g * r1
1680 NEXT j
1690 x = x + e
1700 y = y + f
1710 u = u + x
1720 v = v + y
1730 REM ------------------ FIND COLLISIONS ------------------
1740 IF f2 THEN 1790
1750 SkipJ = 0: FOR j = 1 TO n + 2
1755 IF j = n + 1 THEN 1780
1760 IF o AND j = n THEN 1780
1770 IF (u - oa(j,1)) ^ 2 +(v - oa(j,2)) ^ 2 < oa(j,3) ^ 2 THEN f1 = j:j = n+3: SkipJ = 1
1780 NEXT j: IF SkipJ THEN J = F1: GOTO 1880
1790 IF u < -q(1) OR u > q(1) * 2 OR v < -q(2) OR v > q(2) * 2 THEN 1200
1800 f2 = (u < 0 OR u > q(1) OR v < 0 OR v > q(2))
1810 REM -- f2=f3(no change............) --
1820 REM -- f2=1 (just went off screen.) --
1830 REM -- f3=1 (just came onto screen) --
1840 IF f2 = f3 THEN 1510
1850 IF f3 THEN p1 = u:p2 = v: GOSUB 2230
1860 f3 = f2
1870 GOTO 1510
1880 REM ------------------ MAKE EXPLOSIONS ------------------
1890 p1 = u + 2:p2 = v + 2: GOSUB 2230
1900 FOR i = 1 TO 8:p1 = e(i,1):p2 = e(i,2): GOSUB 2250: NEXT
1910 IF j <= n THEN 1200
1920 LOCATE 1, 23: PRINT CHR$(18);
1930 PRINT n$(m);" destroyed ";n$(j - n);"'s ship!";
1940 PRINT " (Y) Again? : ";
1950 INPUT "";a$: a$ = LOWER$(a$)
1970 IF MID$(a$,1,2) = "//" THEN 2980
1980 a$ = LEFT$(a$,1): IF a$ = "d" OR a$ = "i" THEN 980
1985 IF a$ = "n" OR a$ = "e" THEN 2980
1990 GOTO 270
2000 REM ******************* INPUT ******************* FNC ***
2010 p1$ = LEFT$(p1$,1)
2060 IF p1$ = "" THEN r1 = 0: RETURN
2061 p = 7
2062 p = p - 1: IF p = 0 THEN 2100
2063 IF MID$("BDHS/e",p,1) = p1$ THEN 2080
2064 GOTO 2062
2080 IF MID$(a$,1,2) = "//" THEN p = 6
2090 IF p = 3 THEN GOSUB 2370
2100 r1 = p: RETURN
2120 REM **************** MAKE SHIPS ***************** FNS ***
2140 s = (p4 - 1)*2 - 1
2150 GOSUB 2230
2160 FOR k = 1 TO 16:p1 = s(k,1) * s:p2 = s(k,2): GOSUB 2250: NEXT
2210 RETURN
2230 REM ***************** g CURSOR ****************** FNG$ **
2240 cx = p1:cy = p2: RETURN
2250 REM ***************** DRAW LINE *************************
2260 IF cx >= 0 AND cx <= q(1) AND cy >= 0 AND cy <= q(2) AND cx + p1 >= 0 AND cx + p1 <= q(1) AND cy + p2 >= 0 AND cy + p2 <= q(2) THEN move cx, q(2)-cy:DRAW cx+p1, q(2) - (cy+p2)
2270 cx = cx + p1:cy = cy + p2
2280 RETURN
2290 IF cx >= 0 AND cx <= q(1) AND cy >= 0 AND cy <= q(2) AND p1 >= 0 AND p1 <= q(1) AND p2 >= 0 AND p2 <= q(2) THEN MOVE cx, q(2) - cy:DRAW p1, q(2) - p2
2300 cx = p1:cy = p2: RETURN
2370 REM ******************* HELP ******************** FNH ***
2410 CLS
2420 PRINT "SPACE WAR ";d$: LOCATE 1, 7
2430 PRINT TAB(26);" Commands:": PRINT
2440 PRINT TAB(26);" h = Help"
2450 PRINT TAB(26);" s = Start"
2460 PRINT TAB(26);" d = Display"
2470 PRINT TAB(26);" i = Instant replay after hit"
2480 PRINT TAB(26);" / or b = Back"
2490 PRINT TAB(26);"// or e = Exit": LOCATE 17, 17
2500 PRINT "Negative number of stars gives a BLACK HOLE"
2510 LOCATE 22, 19: PRINT "(y) Are you ready to play?(y/n): ";
2520 INPUT "";a$:a$ = LOWER$(a$)
2530 a$ = LEFT$(a$,2): IF a$ > "" THEN a = ASC(a$):a$ = CHR$(a - 32 *(a > 96 AND a < 123)) + MID$(a$,2)
2540 IF a$ = "n" OR a$ = "e" OR a$ = "//" THEN 2580
2550 IF a$ = "h" THEN 2410
2560 RETURN
2570 RETURN
2580 CLS
2590 END
2610 REM ************** FUNCTION DOWNSHIFT *********** FNS$ **
2640 m = 0: IF p1$ = "" THEN RETURN
2650 FOR i = 1 TO LEN(p1$)
2660 k = ASC(MID$(p1$,i,1))
2670 IF k = 32 THEN m = 0
2680 IF k < 65 OR k > 91 THEN 2710
2690 IF m THEN p1$ = MID$(p1$,1,i - 1) + CHR$(k + 32) + MID$(p1$,i + 1)
2700 m = 1
2710 NEXT i
2720 r1$ = p1$: RETURN
2740 REM *********** POLL TERMINAL CAPABILITY ******** FNi ***
2750 r1 = 1:q(1) = 639:q(2) = 395
2760 RETURN
2970 REM ******************** EXIT ***************************
2980 IF g THEN CLS
2990 CLS
3000 END