home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Game Killer
/
Game_Killer.bin
/
060.REVERSI.BAS
< prev
next >
Wrap
BASIC Source File
|
1979-12-31
|
6KB
|
152 lines
1000 REM Reversi Game
1010 REM Copyright (c) 1990
1020 REM by Randy Hawkins and ONE THOUSAND Magazine
1030 REM All Rights Reserved
1040 REM
1045 COMMON RH: IF RH = 0 THEN SYSTEM
1050 SCREEN 0: WIDTH 80: KEY OFF: COLOR 2,0: CLS
1052 KEY (17) ON: KEY 17, CHR$(0) + CHR$(1)
1054 ON KEY (17) GOSUB 2500
1060 DIM X(3), T(1), F(79)
1070 DEF FNR(X) = INT(X/10) * 3 + 2
1080 DEF FNC(X) = (X MOD 10) * 6 + 2
1090 X(0) = 1: X(1) = 11: X(2) = 10: X(3) = 9
1100 RANDOMIZE TIMER: STRIG ON
1110 REM
1120 REM Present Welcome Screen
1130 REM
1140 LOCATE 10,1,1: PRINT "Welcome to REVERSI"
1150 LOCATE 12,1: INPUT "What is your name"; N$
1160 LOCATE 14,1: PRINT "Are you using a joystick (Y/N)?"; CHR$(32);
1170 A$ = INKEY$: IF A$ = "Y" OR A$ = "y" THEN JS = 0: GOTO 1220
1180 IF A$ = "N" OR A$ = "n" THEN JS = 1 ELSE 1170
1190 REM
1200 REM Display Game Board and Instructions
1210 REM
1220 CLS: FOR A = 1 TO 25 STEP 3: LOCATE A, 6, 0
1230 PRINT STRING$(49, 219);: NEXT A: FOR A = 1 TO 25
1240 FOR B = 6 TO 54 STEP 6: LOCATE A, B: PRINT CHR$(219);
1250 NEXT B,A: LOCATE 8,59: PRINT "Surround any of"
1260 LOCATE 9,60: PRINT "my pieces ...": P = 1: X = 34
1270 GOSUB 2270: X = 45: GOSUB 2270: GOSUB 1910: LOCATE 11,61
1280 PRINT "with two of": LOCATE 12,59: PRINT "your pieces ..."
1290 P = 0: X = 23: GOSUB 2270: X = 56: GOSUB 2270: GOSUB 1910
1300 LOCATE 14,59: PRINT "and you capture": LOCATE 15,62
1310 PRINT "them all!": S = 56: F(S) = -1: GOSUB 2370
1320 GOSUB 1910: FOR A = 23 TO 56 STEP 11: FOR B = 0 TO 1
1330 LOCATE FNR(A)+B, FNC(A)-1: PRINT STRING$(5,32): NEXT B, A
1340 REM
1350 REM Start the Game
1360 REM
1370 GOSUB 1950: LOCATE 16,65: PRINT "SCORES": LOCATE 17,65
1380 PRINT STRING$(6, 205): COLOR 14,1: LOCATE 19,58
1390 PRINT CHR$(254);: COLOR 2,0: PRINT CHR$(32);
1400 PRINT N$; CHR$(32);: WHILE POS(0) < 74: PRINT CHR$(46);
1410 WEND: PRINT CHR$(32); "02": COLOR 4,7: LOCATE 21,58
1420 PRINT CHR$(254);: COLOR 2,0: PRINT CHR$(32); "Computer";
1430 PRINT CHR$(32); STRING$(5, 46); CHR$(32); "02"
1440 FOR A = 0 TO 79: F(A) = -1: NEXT A
1450 P = 0: X = 34: GOSUB 2270: X = 45: GOSUB 2270
1460 P = 1: X = 35: GOSUB 2270: X = 44: GOSUB 2270
1470 S = 1: P = INT(RND * 2)
1480 REM
1490 REM Take a Turn then Check for End
1500 REM
1510 P = 1 - P: ON P + 1 GOSUB 1630, 1780
1520 IF T(0) + T(1) < 64 THEN 1510
1530 GOSUB 1950: LOCATE 8,60: PRINT "This Game Is Over"
1540 ON SGN(T(0)-T(1)) + 2 GOTO 1550, 1560, 1570
1550 LOCATE 9, 64: PRINT "And I Win!": GOTO 1580
1560 LOCATE 9, 61: PRINT "And It's a Tie!": GOTO 1580
1570 LOCATE 9, 64 - LEN(N$) / 2: PRINT "And "; N$; "Wins!"
1580 LOCATE 11,60: PRINT "Play Again (Y/N)?";
1590 GOSUB 1970: IF A$ = "Y" THEN 1090 ELSE 2500
1600 REM
1610 REM Your Turn
1620 REM
1630 GOSUB 1950: LOCATE 8, 60: PRINT "It's your turn,"
1640 LOCATE 9, 67 - LEN(N$) / 2: PRINT N$
1650 GOSUB 2020: IF PT = 0 THEN 1680
1660 LOCATE 11, 58: PRINT "Want to Pass (Y/N)?"
1670 GOSUB 1970: IF A$ = "N" THEN 1650 ELSE 1690
1680 GOSUB 2370: IF TF = 0 THEN 1650
1690 T(0) = 0: T(1) = 0: FOR A = 1 TO 78
1700 IF F(A) < 0 THEN 1740 ELSE B = F(A)
1710 T(B) = T(B) + 1: SOUND 100, .1
1720 LOCATE 19,75: PRINT USING "##"; T(0);
1730 LOCATE 21,75: PRINT USING "##"; T(1);
1740 NEXT A: RETURN
1750 REM
1760 REM Computer's Turn
1770 REM
1780 GOSUB 1950: LOCATE 8, 62: PRINT "It's My Turn"
1790 LOCATE 9,60: PRINT "One Moment Please": RESTORE
1800 READ S: SOUND 100 + S * 10, .1: IF S < 0 THEN 1890
1810 GOSUB 2370: IF TF THEN 1690 ELSE IF RND < .98 THEN 1800
1820 S = INT(RND*8) * 10 + RND*8 + 1: S = INT(S): GOTO 1810
1830 DATA 1, 8, 71, 78, 3, 6, 21, 28, 51, 58, 73, 76
1840 DATA 23, 26, 53, 56, 4, 5, 31, 38, 41, 48, 74, 75
1850 DATA 24, 25, 33, 36, 43, 46, 54, 55, 14, 15, 32
1860 DATA 37, 42, 47, 64, 65, 13, 16, 22, 27, 52, 57
1870 DATA 63, 66, 2, 7, 11, 18, 61, 68, 72, 77, 12
1880 DATA 17, 62, 67, -1
1890 IF PT THEN 1530 ELSE FOR A = 1 TO 3: BEEP: SOUND 100,5
1900 NEXT A: S = 1: LOCATE 9,60: PRINT "I'm Going to Pass": PT = 1
1910 A = TIMER: WHILE A + 3 > TIMER: WEND: RETURN
1920 REM
1930 REM Clear Message Area; Accept Y or N Answer
1940 REM
1950 FOR A = 8 TO 15: LOCATE A, 58
1960 PRINT STRING$(22, 32): NEXT A: RETURN
1970 A$ = INKEY$: IF A$ = "Y" OR A$ = "y" THEN A$ = "Y": RETURN
1980 IF A$ = "N" OR A$ = "n" THEN A$ = "N": RETURN ELSE 1970
1990 REM
2000 REM Allow User to Select a Square
2010 REM
2020 PT = 0: Z = 176: GOSUB 2200
2030 A$ = INKEY$: IF A$ = "P" OR A$ = "p" THEN 2160
2040 A$ = RIGHT$(A$, 1): IF JS THEN 2100
2050 IF STICK(0) < 10 THEN A$ = "K"
2060 IF STICK(0) > 90 THEN A$ = "M"
2070 IF STICK(1) < 10 THEN A$ = "H"
2080 IF STICK(1) > 90 THEN A$ = "P"
2090 IF STRIG(0) OR STRIG(4) THEN A$ = CHR$(13)
2100 IF A$ = "" THEN 2030 ELSE Z = 219: GOSUB 2200
2110 IF A$ = CHR$(27) THEN 1530 ELSE IF A$ = CHR$(13) THEN RETURN
2120 IF A$ = "K" AND (S MOD 10) <> 1 THEN S = S - 1: GOTO 2020
2130 IF A$ = "M" AND (S MOD 10) <> 8 THEN S = S + 1: GOTO 2020
2140 IF A$ = "H" AND S > 10 THEN S = S - 10: GOTO 2020
2150 IF A$ = "P" AND S < 70 THEN S = S + 10: GOTO 2020 ELSE 2020
2160 Z = 219: GOSUB 2200: PT = 1: RETURN
2170 REM
2180 REM Highlight One Square
2190 REM
2200 A = FNR(S): B = FNC(S): LOCATE A - 1, B - 2
2210 PRINT STRING$(7, Z);: FOR C = 0 TO 1: LOCATE A + C, B - 2
2220 PRINT CHR$(Z);: LOCATE A + C, B + 4: PRINT CHR$(Z);
2230 NEXT C: LOCATE A + 2, B - 2: PRINT STRING$(7, Z);: RETURN
2240 REM
2250 REM Color Square for Player #P
2260 REM
2270 COLOR 14 - P * 7, 1 + P * 3: N1 = 32 + P * 187
2280 N2 = 220 + P * 3: N3 = 223 - P * 3: F(X) = P
2290 LOCATE FNR(X), FNC(X) - 1
2300 PRINT CHR$(N1); STRING$(3, N2); CHR$(N1);
2310 LOCATE FNR(X) + 1, FNC(X) - 1
2320 PRINT CHR$(N1); STRING$(3, N3); CHR$(N1);
2330 COLOR 2,0: RETURN
2340 REM
2350 REM Flip Pieces by Marker at S
2360 REM
2370 TF = 0: IF F(S) > -1 THEN RETURN
2380 FOR A = 0 TO 3: FOR B = -1 TO 1 STEP 2: Q = S
2390 Q = Q + X(A) * B: IF Q < 1 OR Q > 78 THEN 2460
2400 IF F(Q) <> 1 - P THEN 2460
2410 Q = Q + X(A) * B: IF Q < 1 OR Q > 78 THEN 2460
2420 IF F(Q) = -1 THEN 2460
2430 IF F(Q) <> P THEN 2410
2440 FOR X = Q - X(A) * B TO S STEP -X(A) * B
2450 GOSUB 2270: NEXT X: TF = 1
2460 NEXT B, A: RETURN
2500 CLS: LOCATE 12,30: PRINT "One Moment Please": RUN "menu"