-
Notifications
You must be signed in to change notification settings - Fork 0
/
fujinet-3dTTT.txt
241 lines (241 loc) · 8.54 KB
/
fujinet-3dTTT.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
100 REM VERSION 11/08/81
105 REM ******* ATARI VERSION *******
110 REM 3D TIC-TAC-TOE BY SCOTT ADAMS.
115 REM ATARI CONVERSION BY TOM SCHAEPER, 07/25/81
116 REM FUJINET CONVERSION BY KAY SAVETZ, 12/31/20
120 DIM A$(514),N$(20),K$(10),DT(15),ZERO$(1)
121 ZERO$=CHR$(0):ZERO=0:WUN=1:TEN=10:S64=64:S65=65:FOUR=4:THREE=3
122 V=1
125 Y=1:N=0:T=0:W=0:X=0:DT(5)=5:DT(6)=-3:DT(7)=1:DT(9)=3:DT(10)=-5:DT(11)=-1:DT(13)=4:DT(14)=-4
126 GOSUB 8000:REM WELCME SCREEN
127 GOSUB 4200
128 GOSUB 8200:REM FUJINET CONNECT
186 FOR I=WUN TO S64:A$(I,I)=ZERO$:NEXT I
187 FOR I=371 TO 447:A$(I,I)=ZERO$:NEXT I
200 GOSUB 5000
210 IF TI+W1+X THEN GOSUB 6000:REM PRESS START FOR REPEAT GAME
212 FOR I=WUN TO S64:A$(I,I)=ZERO$:NEXT I
213 FOR I=371 TO 447:A$(I,I)=ZERO$:NEXT I
215 D=ZERO:Z=ZERO
220 Z=Z+WUN:IF Z=33 THEN 4070
222 IF P=0 THEN GOSUB 5400:GOSUB 3400:GOSUB 3000:GOSUB 3600:GOTO 220
225 IF P=1 THEN GOSUB 3400:GOSUB 3000:GOSUB 3600:GOSUB 5400:GOTO 220
3000 REM COMPUTER PICK SPOT. K IS THE SPOT IT CHOOSES
3001 H$="OPPONENT'S TURN ":GOSUB 9100
3010 H$=NAME$:H$(LEN(H$)+1)="'S TURN "
3015 GOSUB 9100:OLDLOC=0
3020 STATUS #1,A:IF PEEK(746)=0 THEN 3020
3030 INPUT #1,LOC,FINAL
3040 IF LOC<>OLDLOC AND OLDLOC>0 THEN D=OLDLOC:GOSUB 5300:COLOR 0:GOSUB 9000+ NOT P
3050 OLDLOC=LOC:D=LOC
3060 IF FINAL=1 THEN 3100
3070 GOSUB 5300:COLOR 3-P:GOSUB 9000+ NOT P
3080 SOUND 0,100,10,10:SOUND 0,0,0,0
3090 GOTO 3020
3100 REM OPPONENT CHOOSE FINAL POSITION
3110 K=LOC:GOSUB 3710:RETURN
3400 REM CHECK FOR PLAYER WIN
3402 Q=0:R=0
3415 IF Z<4 THEN 3490:REM THIS IS MOOT IN FIRST MOVES
3416 H$="CHECKING... ":GOSUB 9100
3417 KILL=0
3420 FOR I=1 TO 76
3422 E=(I-WUN)*FOUR+S65:F=370+I:C=ZERO
3425 FOR J=ZERO TO THREE
3430 T=J+E:T=ASC(A$(T,T)):IF T<WUN THEN 3440
3435 C=C+ASC(A$(T,T))
3440 NEXT J
3447 REM A$(F,F)=CHR$(C)
3450 IF C=4 THEN R=I:KILL=1:I=99
3480 NEXT I
3485 IF KILL=1 THEN POP :GOTO 4040:REM PLAYER WON IN THEIR PREV MOVE
3490 RETURN
3510 FOR H=ZERO TO THREE
3520 T=S65+H+(R-WUN)*FOUR:C=ASC(A$(T,T))
3530 IF A$(C,C)=ZERO$ THEN K=C:H=4
3540 NEXT H
3560 GOSUB 3710
3570 GOTO 4005
3600 REM CHECK FOR OPPONENT WIN
3615 IF Z<4 THEN 3699:REM THIS IS MOOT IF FIRST MOVES
3617 KILL=0
3620 FOR I=1 TO 76
3622 E=(I-1)*4+S65:F=370+I:C=0
3625 FOR J=0 TO 3
3630 T=J+E:T=ASC(A$(T,T)):IF T<1 THEN 3640
3635 C=C+ASC(A$(T,T))
3640 NEXT J
3647 REM A$(F,F)=CHR$(C)
3670 IF C=20 THEN R=I:KILL=2:I=99
3680 NEXT I
3687 IF KILL=2 THEN POP :GOTO 4005
3699 RETURN
3710 D=K:A$(D,D)=CHR$(5):GOSUB 5300:COLOR 3-P
3730 GOSUB 9000+ NOT P
3760 RETURN
4005 GOSUB 4083
4008 REM OPPONENT WON. X COUNTS NUMBER OF OPPONENT WINS
4009 H$="YOU LOSE! hit start":GOSUB 9100
4010 X=X+1:T=X*FOUR+TEN:COLOR 3-P:FOR I=T TO T+2:PLOT 120-(20*P),I:DRAWTO 126-(20*P),I:NEXT I
4012 FOR I=100 TO 200
4014 SOUND 0,I,TEN,8:NEXT I:SOUND ZERO,ZERO,ZERO,ZERO
4020 REM
4030 GOTO 210
4036 END
4040 GOSUB 4083
4041 REM PLAYER WON. W1 COUNTS NUMBER OF PLAYER WINS
4042 H$="YOU WIN!! hit start":GOSUB 9100
4043 W1=W1+1:T=W1*FOUR+TEN:COLOR P+2:FOR I=T TO T+2:PLOT 100+(20*P),I:DRAWTO 106+(20*P),I:NEXT I
4044 FOR I=200 TO 100 STEP -1:SOUND ZERO,I,TEN,8:NEXT I:SOUND ZERO,ZERO,ZERO,ZERO
4050 GOTO 4020
4069 REM TIE. TI IS NUMBER OF TIE GAMES
4070 H$="CATS GAME hit start":GOSUB 9100
4071 TI=TI+1:T=TI*FOUR+TEN:COLOR 1:FOR I=T TO T+2:PLOT 140,I:DRAWTO 146,I:NEXT I
4072 SOUND 0,100,12,8:FOR I=1 TO 100:NEXT I:SOUND ZERO,ZERO,ZERO,ZERO
4075 GOTO 4020
4083 COLOR WUN
4084 FOR H=ZERO TO THREE:T=S65+H+(R-1)*FOUR:D=ASC(A$(T,T))
4086 GOSUB 5300
4087 PLOT PX-3,PY-3:DRAWTO PX+2,PY+2
4088 SOUND 0,20+D,10,8:FOR W=1 TO 100:NEXT W
4089 NEXT H:RETURN
4200 RESTORE
4204 FOR I=WUN TO TEN:FOR C=ZERO TO THREE:READ N:T=S65+C+(I-1)*FOUR:A$(T,T)=CHR$(N):NEXT C:NEXT I
4210 FOR I=57 TO 76:FOR C=ZERO TO THREE
4220 READ N:T=S65+C+(I-WUN)*FOUR:A$(T,T)=CHR$(N)
4230 NEXT C:NEXT I
4231 FOR I=WUN TO THREE:FOR C=WUN TO TEN:FOR E=ZERO TO THREE
4232 T=E+S65+(C+I*TEN-WUN)*FOUR:T1=E+S65+(C-WUN)*FOUR
4233 A$(T,T)=CHR$(ASC(A$(T1,T1))+16*I)
4234 NEXT E:NEXT C:NEXT I
4236 FOR I=41 TO 56:FOR C=ZERO TO THREE
4238 T=S65+C+(I-WUN)*FOUR:A$(T,T)=CHR$(C*16+I-40):NEXT C:NEXT I
4239 RETURN
4250 DATA 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,1,5,9,13,2
4252 DATA 6,10,14
4254 DATA 3,7,11,15,4,8,12,16,1,6,11,16,4,7,10,13,1,22,43,64
4256 DATA 5,22,39,56,9,26,43,60,13,26,39,52,2,22,42,62,14,26
4258 DATA 38,50
4260 DATA 3,23,43,63,15,27,39,51,4,23,42,61,8,23,38,53,12,27
4262 DATA 42,57,16,27,38,49
4264 DATA 1,21,41,61,1,18,35,52,4,19,34,49,4,24,44,64
4266 DATA 13,25,37,49,13,30,47,64,16,31,46,61,16,28,40,52
5000 GRAPHICS 23:Z=0
5005 FOR I=1 TO S64:A$(I,I)=ZERO$:NEXT I
5010 POKE 752,1
5020 DL=PEEK(560)+PEEK(561)*256:POKE DL+6,6:POKE I+97,65:POKE I+98,PEEK(560):POKE I+99,PEEK(561)
5025 H$="3D TICTACTOE FUJINET":GOSUB 9100
5028 SETCOLOR 0,0,12:SETCOLOR 1,5,8:SETCOLOR 2,12,6
5029 COLOR WUN
5030 FOR I=ZERO TO THREE
5040 FOR J=ZERO TO FOUR
5050 X1=20-J*5:Y1=3+I*22+J*5:PLOT X1,Y1:DRAWTO X1+40,Y1
5060 NEXT J:NEXT I
5100 FOR I=ZERO TO THREE
5110 FOR J=ZERO TO 4
5120 X1=20+J*10:Y1=3+I*22:PLOT X1,Y1:DRAWTO X1-20,Y1+20
5140 NEXT J:NEXT I
5150 COLOR 2:PLOT 100,3:DRAWTO 106,9:PLOT 106,3:DRAWTO 100,9
5160 COLOR 3:PLOT 120,3:DRAWTO 126,3:DRAWTO 126,9:DRAWTO 120,9:DRAWTO 120,3
5170 COLOR 1:PLOT 146,3:DRAWTO 140,3:DRAWTO 140,9:DRAWTO 146,9
5200 RETURN
5300 D1=INT((D-WUN)/16):D2=D-D1*16:D3=INT((D2-WUN)/FOUR):D4=D2-FOUR*D3-WUN
5320 PX=23+D4*TEN-D3*5:PY=6+22*D1+5*D3
5350 RETURN
5400 REM
5401 H$="YOUR TURN ":GOSUB 9100
5402 POKE 77,0
5405 SW=0:IF D=0 THEN SW=1
5406 DX=D
5407 SOUND ZERO,20,TEN,8:FOR I=TEN TO 30:NEXT I
5408 SOUND ZERO,30,TEN,8:FOR I=WUN TO 50:NEXT I:SOUND ZERO,ZERO,ZERO,ZERO
5410 FOR I=WUN TO S64:IF A$(I,I)=ZERO$ THEN D=I:GOTO 5412
5411 NEXT I
5412 GOSUB 5300:COLOR P+2:GOSUB 9000+P
5413 DT=D
5414 PRINT #1;D;",",0:REM SHOW OPPONENT START POSITION
5415 STK=STICK(ZERO):STG=STRIG(ZERO):KEY=PEEK(764):POKE 764,255
5416 IF SW THEN 5420
5417 IF C1=3-P THEN C1=0:GOTO 5419
5418 C1=3-P
5419 D=DX:GOSUB 5300:COLOR C1:GOSUB 9000+ NOT P
5420 IF NOT (STG) OR KEY=12 THEN 5465
5421 IF KEY=14 THEN STK=14
5422 IF KEY=15 THEN STK=13
5423 IF KEY=6 THEN STK=11
5424 IF KEY=7 THEN STK=7
5425 IF STK=15 THEN 5415
5427 IF SW=0 THEN SW=1:D=DX:GOSUB 5300:COLOR 3-P:GOSUB 9000+ NOT P:D=DT
5430 TEST=D+DT(STK)
5432 IF TEST<WUN THEN TEST=TEST+S64
5434 IF TEST>S64 THEN TEST=TEST-S64
5435 IF TEST=D THEN 5415
5440 IF A$(TEST,TEST)<>ZERO$ THEN TEST=TEST+DT(STK):GOTO 5432
5445 GOSUB 5300:COLOR 0:GOSUB 9000+P
5450 D=TEST:GOSUB 5300:COLOR P+2:GOSUB 9000+P
5452 PRINT #1;D;",";0
5455 SOUND ZERO,20,2,8:SOUND ZERO,ZERO,ZERO,ZERO
5460 GOTO 5415
5465 IF SW=0 THEN SW=1:D=DX:GOSUB 5300:COLOR 3-P:GOSUB 9000+ NOT P:D=DT
5467 A$(D,D)=CHR$(WUN)
5468 PRINT #1;D;",";1:REM TELL OPPONENT WE'VE SELECTED THE SPOT
5470 SOUND ZERO,50,2,6:N=2^2:SOUND ZERO,ZERO,ZERO,ZERO
5480 RETURN
6000 POKE 53279,0
6005 T=PEEK(53279)
6010 IF T=6 THEN 6060
6020 GOTO 6005
6060 H$="RESETTING BOARD ":GOSUB 9100
6061 REM ERASE OLD TILES
6062 COLOR 0:FOR D=1 TO S64
6070 GOSUB 5300
6080 FOR J=PY-2 TO PY+1:PLOT PX-2,J:DRAWTO PX+2,J:NEXT J
6085 NEXT D
6090 RETURN
8000 GRAPHICS 2+16
8030 PRINT #6:PRINT #6
8040 PRINT #6;" 3D TIC-TAC-TOE"
8050 PRINT #6;"(C) SCOTT ADAMS '78"
8060 PRINT #6
8070 PRINT #6;" #FUJINET HACK"
8080 PRINT #6;" KAY SAVETZ 2020"
8090 PRINT #6:PRINT #6;" please wait"
8100 RETURN
8200 DIM H$(64),D$(128),NAME$(13)
8210 GRAPHICS 0
8220 ? " 3D TIC-TAC-TOE":?
8221 ? "WHAT IS YOUR NAME";
8222 INPUT NAME$
8223 IF NAME$="" THEN NAME$="OPPONENT"
8230 ? :? "ENTER HOSTNAME OR RETURN TO LISTEN"
8240 INPUT #16,H$
8250 IF H$="" THEN 8300
8260 D$="N:TCP://":D$(LEN(D$)+1)=H$:D$(LEN(D$)+1)=":6502/"
8261 TRAP 8290
8270 ? :? "CONNECTING TO: ";H$:OPEN #1,12,0,D$
8280 ? :? "CONNECTED!":P=1:REM AWAY PLAYER
8281 FOR I=255 TO 0 STEP -16:SOUND 0,I,12,12:FOR DE=0 TO 20:NEXT DE:NEXT I:SOUND 0,0,0,0:P=1:GOTO 8390
8290 ? :? "COULD NOT CONNECT."
8291 FOR I=0 TO 255 STEP 16:SOUND 0,I,12,12:FOR DE=0 TO 20:NEXT DE:NEXT I:SOUND 0,0,0,0:CLOSE #1:GOTO 8210
8300 REM LISTEN FOR CONNECTION
8301 P=0:REM HOME PLAYER
8310 ? :? "LISTENING..."
8320 D$="N:TCP://:6502/"
8330 OPEN #1,12,0,D$
8340 STATUS #1,A:IF PEEK(748)=0 THEN 8340
8350 ? :? "ACCEPTING..."
8360 XIO 65,#1,12,0,"N:"
8370 FOR I=255 TO 0 STEP -16:SOUND 0,I,12,12:FOR DE=0 TO 20:NEXT DE:NEXT I:SOUND 0,0,0,0
8380 P=0
8390 TRAP 40000
8395 ? #1;NAME$
8396 STATUS #1,A:IF PEEK(746)=0 THEN 8396
8397 INPUT #1,NAME$
8400 RETURN
9000 PLOT PX-2,PY-2:DRAWTO PX+1,PY+1:PLOT PX-2,PY+1:DRAWTO PX+1,PY-2:RETURN :REM DRAW X
9001 PLOT PX-2,PY:PLOT PX+1,PY:PLOT PX-1,PY+1:PLOT PX,PY+1:PLOT PX-2,PY-1:REM DRAW 0
9002 PLOT PX+1,PY-1:PLOT PX-1,PY-2:PLOT PX,PY-2:RETURN
9003 RETURN
9100 REM PRINT MESSAGE (H$) AT TOP OF SCREEN
9110 POKE 87,1:POSITION 0,2:PRINT #6;H$:POKE 87,7
9120 RETURN