home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nibble Magazine
/
nib34b.dsk
/
ZAPZ.bas
< prev
next >
Wrap
BASIC Source File
|
2023-02-26
|
12KB
|
363 lines
10 REM **********************
20 REM * ZAPZ *
30 REM * BY JEFFRY G. BROWN *
40 REM * COPYRIGHT(C) 1988 *
50 REM * MICROSPARC, INC. *
60 REM * CONCORD, MA 01742 *
70 REM **********************
80 REM
90 PRINT CHR$(21)
100 PM = 1: GOSUB 3260
110 IF PEEK(104) < >64 GOTO 130
120 GOTO 150
130 POKE 16384,0: POKE 103,1: POKE 104,64
140 PRINT : PRINT CHR$(4);"RUN ZAPZ"
150 GOTO 3500
160 DX = (ZD = 1) -(ZD = 3):DY = (ZD = 2) -(ZD = 4):ZS = 0: ROT= 0
170 IF DX AND NOT ((ZX +DX) <0 OR (ZX +DX) >SZ) GOTO 190
180 GOTO 250
190 MY = FN SY(ZY)
200 FOR MX = FN SX(ZX) TO FN SX(TX) STEP 3 *DX
210 XDRAW 7 +ZS AT MX,MY: CALL SND,SF *2
220 XDRAW 7 +ZS AT MX,MY: CALL SND,SF *9:ZS = NOT ZS
230 NEXT MX
240 GOTO 320
250 IF DY AND NOT ((ZY +DY) <0 OR (ZY +DY) >SZ) GOTO 270
260 GOTO 320
270 MX = FN SX(ZX)
280 FOR MY = FN SY(ZY) TO FN SY(TY) STEP 3 *DY
290 XDRAW 7 +ZS AT MX,MY: CALL SND,SF *2
300 XDRAW 7 +ZS AT MX,MY: CALL SND,SF *9:ZS = NOT ZS
310 NEXT MY
320 RETURN
330 K0 = PEEK(36):K1 = PEEK(37):YES = 0
340 HTAB K0 +1: VTAB K1 +1: PRINT T$;" (Y/N) ?";: GET A$
350 IF A$ = "Y" OR A$ = "y" OR A$ = "N" OR A$ = "n" GOTO 370
360 GOTO 340
370 YES = ((A$ = "Y") OR (A$ = "y"))
380 RETURN
390 D$ = CHR$(4):RN$ = CHR$(13):FALSE = 0:TRUE = NOT FALSE
400 DIM PL$(1),B(9,9),AR(9,9),PC(1,1),RF(4,2),CP$(10),DF$(10),WN(1)
410 DEF FN SX(X) = QX +X *18
420 DEF FN SY(Y) = QY +Y *18
430 GMODE = 49232:P1 = 49236:FULL = 49234:KCLR = 49168:RDKY = 49152:SND = 768
440 RESTORE
450 FOR J = 1 TO 2: FOR I = 1 TO 4: READ RF(I,J): NEXT I: NEXT J
460 DATA 4,3,2,1,2,1,4,3
470 IF PEEK(64899) + PEEK(64898) = 264 GOTO 490
480 GOTO 510
490 UP$ = "I":RT$ = "K":DN$ = "M":LF$ = "J"
500 GOTO 520
510 UP$ = CHR$(11):RT$ = CHR$(21):DN$ = CHR$(10):LF$ = CHR$(8)
520 CP = 6: FOR I = 1 TO CP: READ CP$(I),DF$(I): NEXT I
530 DATA "PLAYER 1","ALPHA"
540 DATA "PLAYER 2","BETA"
550 DATA "BOARD SIZE (6-10)","8"
560 DATA "OBSTACLE DENSITY (0-20)","10"
570 DATA "CHANCE OF REFLECTOR (0-100)","50"
580 DATA "ROTATING REFLECTORS? (Y/N)","NO"
590 MT$ = " *** GAME SETUP *** ":MT = 5
600 PL$(0) = DF$(1):PL$(1) = DF$(2):SZ = VAL(DF$(3)) -1:D = VAL(DF$(4)):PF = 50:RR = FALSE:SF = TRUE
610 PRINT D$"BLOAD ZAPZ.SHP,A$800": POKE 232,0
620 PRINT D$"BLOAD ZFONT.SHP,A$900"
630 PRINT D$"BLOAD ZAPZ.SND"
640 RETURN
650 TEXT : HOME : HTAB 17: INVERSE : PRINT " Z A P Z "
660 NORMAL : VTAB 3: HTAB 10: PRINT "(C)1988 MICROSPARC, INC."
670 FOR CL = 1 TO CP
680 GOSUB 1000
690 NEXT CL
700 VTAB MT:T$ = " ARE THESE OPTIONS CORRECT"
710 GOSUB 330
720 VTAB MT: HTAB 1: CALL -868
730 IF YES GOTO 990
740 VTAB MT: HTAB 1: CALL -868: HTAB INT(21 - LEN(MT$)/2): INVERSE : PRINT MT$
750 FOR CL = 1 TO CP
760 VTAB CL +MT +1: HTAB 1: INVERSE : PRINT CP$(CL);: NORMAL
770 VTAB CL +MT +1: HTAB 30
780 GOSUB 1030
790 IF LEN(IN$) >0 GOTO 810
800 GOTO 930
810 ON CL GOSUB 1120,1120,1230,1290,1350,1410
820 IF ER = TRUE GOTO 840
830 GOTO 900
840 VTAB MT +1: HTAB 8: INVERSE : PRINT " INPUT ERROR - TRY AGAIN";
850 NORMAL : CALL SND,SF *6
860 VTAB 23: HTAB 1: PRINT "PRESS RETURN TO CONTINUE ";: POKE -16368,0: GET A$: HTAB 1: PRINT SPC( 39)
870 VTAB MT +1: HTAB 8: PRINT SPC( 25);
880 GOSUB 1000
890 GOTO 920
900 DF$(CL) = IN$
910 GOSUB 1000
920 GOTO 950
930 ER = FALSE
940 GOSUB 1000
950 IF NOT ER GOTO 970
960 GOTO 760
970 NEXT CL
980 GOTO 700
990 RETURN
1000 VTAB CL +MT +1: HTAB 1: NORMAL : PRINT SPC( 40);: VTAB CL +MT +1: HTAB 1: PRINT CP$(CL);
1010 HTAB 40 - LEN(DF$(CL)): PRINT DF$(CL)
1020 RETURN
1030 CALL -868
1040 IN$ = "":L = 0:CV = PEEK(37):CH = PEEK(36): VTAB 15: HTAB 1: PRINT "PRESS RETURN TO RESTORE FORMER ENTRY";: VTAB CV +1: HTAB CH +1
1050 GET A$: IF A$ < > CHR$(13) THEN GOSUB 1110: IF NG THEN CALL 768,9: GOTO 1050
1060 IF A$ = CHR$(13) THEN GOSUB 1100: RETURN
1070 IF L <10 THEN PRINT A$;:IN$ = IN$ +A$:L = L +1: GOSUB 1100
1080 IF L = 10 THEN CALL 768,9
1090 GOTO 1050
1100 CV = PEEK(37):CH = PEEK(36): VTAB 15: HTAB 1: PRINT SPC( 39);: VTAB CV +1: HTAB CH +1: RETURN
1110 NG = (A$ <"!" OR A$ > CHR$(122)) OR ((CL = 1 OR CL = 2) AND ((A$ <"A") OR A$ >"Z" AND A$ < CHR$(97))): RETURN
1120 ER = TRUE:A$ = ""
1130 FOR NC = 1 TO LEN(IN$)
1140 A = ASC( MID$ (IN$,NC,1)): IF A >95 THEN A = A -32
1150 IF (A > = 65) AND (A < = 90) GOTO 1170
1160 GOTO 1180
1170 A$ = A$ + CHR$(A)
1180 NEXT NC
1190 IF LEN(A$) >0 GOTO 1210
1200 GOTO 1220
1210 PL$(CL -1) = A$:ER = FALSE
1220 RETURN
1230 K = INT( VAL(IN$))
1240 ER = (K <6 OR K >10)
1250 IF NOT ER THEN 1270
1260 GOTO 1280
1270 SZ = K -1:IN$ = STR$(K)
1280 RETURN
1290 K = INT( VAL(IN$))
1300 ER = (K <0 OR K >20)
1310 IF ER = FALSE GOTO 1330
1320 GOTO 1340
1330 D = K:IN$ = STR$(D)
1340 RETURN
1350 K = INT( VAL(IN$))
1360 ER = (K <0 OR K >100)
1370 IF ER = FALSE GOTO 1390
1380 GOTO 1400
1390 PF = K:IN$ = STR$(PF)
1400 RETURN
1410 A$ = LEFT$(IN$,1):ER = TRUE
1420 IF A$ = "Y" OR A$ = CHR$(121) GOTO 1440
1430 GOTO 1460
1440 RR = TRUE:ER = FALSE:IN$ = "YES"
1450 GOTO 1490
1460 IF A$ = "N" OR A$ = CHR$(110) GOTO 1480
1470 GOTO 1490
1480 RR = FALSE:ER = FALSE:IN$ = "NO"
1490 RETURN
1500 HGR : POKE FULL,0: HCOLOR= 3: SCALE= 1: POKE 233,8
1510 QX = 139 -9 *SZ:QY = 90 -9 *SZ:PB = 0.10 +D/100
1520 A = PEEK(78):A = A +1: FOR I = 0 TO A:X = RND(1): NEXT I: POKE 202,A:X = RND(1)
1530 FOR BX = 0 TO SZ
1540 FOR BY = 0 TO SZ
1550 X = FN SX(BX):Y = FN SY(BY)
1560 ROT= 0: DRAW 1 AT X,Y: CALL SND,SF *8
1570 AR = INT( RND(1) *4): ROT= AR *16: DRAW 2 AT X,Y:AR(BX,BY) = AR +1
1580 B(BX,BY) = 0
1590 IF (BX +BY) >1 AND (BX +BY) <2 *SZ -1 GOTO 1610
1600 GOTO 1650
1610 IF RND(1) <PB GOTO 1630
1620 GOTO 1650
1630 R = INT( RND(1) *2):T = INT(( RND(1) >PF/100) +3): ROT= R *16: DRAW T AT X,Y
1640 B = T +R +(T = 4):B = B -(B = 6):B(BX,BY) = B -2
1650 IF (BX +BY) = 0 OR (BX +BY) = 2 *SZ GOTO 1670
1660 GOTO 1680
1670 ROT= 0: DRAW 5 +((BX +BY) >0) AT X,Y
1680 NEXT BY
1690 NEXT BX
1700 PC(0,0) = 0:PC(0,1) = 0:PC(1,0) = SZ:PC(1,1) = SZ
1710 B(0,0) = 4:B(SZ,SZ) = 5
1720 RETURN
1730 PL = INT( RND(1) *2)
1740 KILL = 0
1750 GOSUB 1830
1760 GOSUB 1950
1770 GOSUB 2410
1780 GOSUB 2550
1790 IF KILL GOTO 1820
1800 PL = NOT (PL)
1810 GOTO 1750
1820 RETURN
1830 ROT= 0: POKE 233,9: HCOLOR= 0: FOR LN = 181 TO 191: HPLOT 0,LN TO 279,LN: NEXT LN
1840 NM$ = PL$(PL) +"@S TURN":NR = 140 -(9 * INT( LEN(NM$)/2)): HPLOT NR,191
1850 FOR NC = 1 TO LEN(NM$)
1860 A = ASC( MID$ (NM$,NC,1))
1870 IF A <64 OR A >90 GOTO 1890
1880 GOTO 1910
1890 A = 28
1900 GOTO 1920
1910 A = A -63
1920 XDRAW A: XDRAW 29
1930 NEXT NC
1940 RETURN
1950 CX = PC(PL,0):CY = PC(PL,1): POKE 233,8
1960 XDRAW 1 AT FN SX(CX), FN SY(CY): XDRAW 1 AT FN SX(CX), FN SY(CY)
1970 A = PEEK(RDKY)
1980 IF A > = 128 GOTO 2000
1990 GOTO 1960
2000 POKE KCLR,0:A$ = CHR$(A -128):A$ = CHR$( ASC(A$) -32 *(A$ > CHR$(95)))
2010 IF A$ = UP$ OR A$ = DN$ OR A$ = RT$ OR A$ = LF$ OR A$ = RN$ GOTO 2220
2020 IF A$ = CHR$(27) GOTO 2040
2030 GOTO 2160
2040 TEXT : HOME : VTAB 12
2050 HTAB 8: PRINT " DO YOU REALLY WANT"
2060 HTAB 8:T$ = "TO END THIS GAME"
2070 GOSUB 330
2080 HOME
2090 IF YES GOTO 2110
2100 GOTO 2140
2110 CALL 54915
2120 GOTO 3510
2130 GOTO 2150
2140 POKE GMODE,0: POKE FULL,0: POKE P1,0
2150 GOTO 2210
2160 IF A$ = CHR$(83) OR A$ = CHR$(115) GOTO 2180
2170 GOTO 2200
2180 SF = NOT SF
2190 GOTO 2210
2200 CALL SND,SF *6
2210 GOTO 1960
2220 IF A$ = RN$ GOTO 2240
2230 GOTO 2270
2240 IF NOT ((CX = PC(PL,0)) AND (CY = PC(PL,1))) GOTO 2400
2250 CALL SND,SF *6
2260 GOTO 2390
2270 NX = CX +((A$ = RT$) -(A$ = LF$)):NY = CY +((A$ = DN$) -(A$ = UP$))
2280 ER = (NX <0 OR NX >SZ OR NY <0 OR NY >SZ)
2290 IF NOT ER GOTO 2310
2300 GOTO 2340
2310 ER = ER +((B(NX,NY) >0) AND (B(NX,NY) < >(4 +PL)))
2320 DX = (PC(PL,0) -NX):DY = (PC(PL,1) -NY):ER = ER +(DX < >0 AND DY < >0)
2330 ER = ER +( ABS(DX) >3 OR ABS(DY) >3)
2340 IF NOT ER GOTO 2360
2350 GOTO 2380
2360 CX = NX:CY = NY
2370 GOTO 2390
2380 CALL SND,SF *6
2390 GOTO 1960
2400 RETURN
2410 ROT= 0
2420 IF CX = PC(PL,0) GOTO 2440
2430 GOTO 2490
2440 DY = SGN(CY -PC(PL,1))
2450 FOR ROW = PC(PL,1) TO CY -DY STEP DY
2460 XDRAW 5 +PL AT FN SX(CX), FN SY(ROW): XDRAW 5 +PL AT FN SX(CX), FN SY(ROW +DY): CALL SND,SF *1
2470 NEXT ROW
2480 GOTO 2530
2490 DX = SGN(CX -PC(PL,0))
2500 FOR COL = PC(PL,0) TO CX -DX STEP DX
2510 XDRAW 5 +PL AT FN SX(COL), FN SY(CY): XDRAW 5 +PL AT FN SX(COL +DX), FN SY(CY): CALL SND,SF *1
2520 NEXT COL
2530 B(PC(PL,0),PC(PL,1)) = 0:B(CX,CY) = 4 +PL:PC(PL,0) = CX:PC(PL,1) = CY
2540 RETURN
2550 ZX = PC(PL,0):ZY = PC(PL,1)
2560 ZD = AR(PC( NOT (PL),0),PC( NOT (PL),1))
2570 TX = PC(PL,0):TY = PC(PL,1)
2580 ZQUIT = 0
2590 GOSUB 2780
2600 GOSUB 160
2610 IF TT >2 AND ( NOT (TX = ZX AND TY = ZY)) GOTO 2630
2620 GOTO 2700
2630 B(TX,TY) = 0
2640 XDRAW TT +1 AT FN SX(TX), FN SY(TY)
2650 FOR EX = 8 TO 9
2660 XDRAW EX AT FN SX(TX), FN SY(TY): XDRAW EX AT FN SX(TX), FN SY(TY)
2670 NEXT EX: CALL SND,SF *4
2680 ZQUIT = 1
2690 KILL = (TT = 4 OR TT = 5)
2700 IF ZQUIT GOTO 2760
2710 ZX = TX:ZY = TY:ZD = RF(ZD,B(TX,TY)): CALL SND,SF *5
2720 IF RR = TRUE GOTO 2740
2730 GOTO 2750
2740 GOSUB 2960
2750 GOTO 2580
2760 CALL SND,7 *SF *((TT = 0) OR (TX = ZX AND TY = ZY))
2770 RETURN
2780 TT = 0
2790 IF ZD = 1 OR ZD = 3 GOTO 2810
2800 GOTO 2880
2810 DX = (ZD = 1) -(ZD = 3)
2820 AX = TX +DX:ZQUIT = (AX <0 OR AX >SZ)
2830 IF ZQUIT GOTO 2870
2840 TX = AX
2850 IF B(AX,TY) >0 GOTO 2870
2860 GOTO 2820
2870 GOTO 2940
2880 DY = (ZD = 2) -(ZD = 4)
2890 AY = TY +DY:ZQUIT = (AY <0 OR AY >SZ)
2900 IF ZQUIT GOTO 2940
2910 TY = AY
2920 IF B(TX,AY) >0 GOTO 2940
2930 GOTO 2890
2940 TT = B(TX,TY)
2950 RETURN
2960 ROT= 16 *(B(TX,TY) = 2): XDRAW 3 AT FN SX(TX), FN SY(TY)
2970 ROT= 16 *(B(TX,TY) = 1): XDRAW 3 AT FN SX(TX), FN SY(TY)
2980 B(TX,TY) = (B(TX,TY) = 1) +1
2990 RETURN
3000 FOR I = 1 TO 600: NEXT I
3010 WN$ = PL$(TT = 4):WD = LEN(WN$) +8:B$ = "++++++++++++++++++++++++++++++++++++++++": REM "40 PLUS SIGNS"
3020 TEXT : HOME : FOR LN = 7 TO 13: VTAB LN: HTAB INT(21 -(WD/2)): PRINT LEFT$(B$,WD): NEXT LN
3030 FOR LN = 8 TO 12: VTAB LN: HTAB INT(21 -(WD/2)) +1: PRINT SPC( WD -2);: NEXT LN
3040 VTAB 9: HTAB INT(21 - LEN(WN$)/2): FLASH : PRINT WN$: NORMAL
3050 VTAB 11: HTAB 18: PRINT "WINS!!": CALL SND,SF *3
3060 WINNER = (TT = 4):WN(WINNER) = WN(WINNER) +1: VTAB 15
3070 GOSUB 3100
3080 VTAB 23: HTAB 1: PRINT "PRESS RETURN TO CONTINUE ";: POKE -16368,0: GET A$
3090 RETURN
3100 DOTS$ = "...........................": REM "27 PERIODS"
3110 HTAB 12: PRINT "*** GAMES WON ***": PRINT
3120 FOR K = 0 TO 1
3130 HTAB 5: PRINT PL$(K);: PRINT LEFT$(DOTS$,27 - LEN(PL$(K)));
3140 PRINT RIGHT$(" " + STR$(WN(K)),3)
3150 NEXT K
3160 RETURN
3170 TEXT : HOME : VTAB 12: PRINT "WOULD YOU LIKE TO PLAY ";
3180 IF AGAIN GOTO 3200
3190 GOTO 3220
3200 T$ = "AGAIN"
3210 GOTO 3230
3220 T$ = "ZAPZ":AGAIN = 1
3230 GOSUB 330
3240 X = FRE(0)
3250 RETURN
3260 ONERR GOTO 3280
3270 RETURN
3280 K = PEEK(222)
3290 TEXT : HOME : NORMAL
3300 IF K = 255 GOTO 3320
3310 GOTO 3380
3320 VTAB 11: HTAB 7: PRINT "YOU HAVE ABORTED THIS GAME
3330 HTAB 7: PRINT " BY PRESSING CONTROL-C."
3340 VTAB 23: PRINT "PRESS RETURN TO CONTINUE ";: POKE -16368,0: GET A$
3350 CALL 54915
3360 GOTO 3510
3370 GOTO 3500
3380 IF K = 6 OR K = 8 GOTO 3400
3390 GOTO 3480
3400 PRINT "THERE HAS BEEN A DISK ERROR."
3410 PRINT "ZAPZ CANNOT FIND THE FILES IT NEEDS."
3420 PRINT "PLEASE INSERT THE ZAPZ DISK AND"
3430 PRINT "PRESS ANY KEY."
3440 GET A$
3450 PRINT
3460 RUN
3470 GOTO 3500
3480 PRINT "ERROR #";K;" IN LINE "; PEEK(218) +256 * PEEK(219);"."
3490 PRINT : PRINT "ZAPZ HAS TERMINATED ABNORMALLY.": END
3500 GOSUB 390
3510 IF NOT PM THEN GOSUB 3170
3520 IF PM THEN PM = 0:YES = 1
3530 IF NOT YES GOTO 3590
3540 GOSUB 650
3550 GOSUB 1500
3560 GOSUB 1730
3570 GOSUB 3000
3580 GOTO 3510
3590 TEXT : HOME : VTAB 7
3600 GOSUB 3100
3610 PRINT : PRINT : HTAB 10: PRINT "THANK YOU FOR PLAYING"
3620 PRINT : INVERSE : HTAB 17: PRINT " ZAPZ ": NORMAL : VTAB 22: PRINT
3630 END