Skip to content

Commit

Permalink
save latest version of BASIC program
Browse files Browse the repository at this point in the history
  • Loading branch information
TechCowboy committed Mar 31, 2023
1 parent 2c13ee4 commit 07dc94c
Showing 1 changed file with 162 additions and 112 deletions.
274 changes: 162 additions & 112 deletions apple2/examples/REVERSI.BAS.TXT
Original file line number Diff line number Diff line change
@@ -1,47 +1,58 @@

NEW

9 GOSUB 10000 : N0=0 : TEXT : HOME : &NSETEOL 155:OX=20:OY=1
REM UPPER LEFT 22,5, 27,5 32,5
REM 22,9
REM 22,13

REM UPPER RIGHT 57,5
REM LOWER LEFT 22,33
REM LOWER RIGHT 57,33,

REM ATARI CR
REM PLAYER1=BLACK PLAYER2=WHITE
3 DIM F(1),S(1,9),LO%(79,47), AX%(79,47)
5 GOSUB 10000 : N0=0 : &NSETEOL 155

REM BL=BACKGROUND LIGHT BD=BACKGROUND DARK
6 TEXT:HOME: OX=16:OY=0:SS=3:BL=12:BD=4:CU=6:ME=0:TH=15:GOSUB 650

10 GOTO 500
REM DRAW BOARD
11 FOR Y=0 TO 39:X2=0:FOR X=0 TO 39:COLOR = LO(X+OX,Y+OY):PLOT X,Y:NEXT X:NEXT Y:RETURN

REM GET COLOR AT X,Y-1, SET COLOR AT X,Y AND X+1,Y
15 IF Y >0 THEN C = LOC(X,Y-1):LO(X,Y)=C:LO(X+1,Y)=C:RETURN
16 RETURN
11 FOR Y=0 TO 39:FOR X=OX TO 79:IF AX%(X,Y) > -1 THEN COLOR=LO%(X,Y):PLOT AX%(X,Y),Y
12 NEXT X:NEXT Y:RETURN

REM GET COLOR AT X-1, Y-1
17 IF X >0 THEN C = LOC(X-1,Y-1)
18 GOTO 30
REM SET the color at x,y and x+1,y equal to what's at x,y-1
18 C = LO%(X,Y-1):LO%(X,Y)=C:LO%(X+1,Y)=C:I=X:J=Y:GOSUB 100:I=X+1:GOSUB 100:RETURN

REM GET THE COLOR AT X-1,Y-1
19 C=LO%(X-1,Y-1):GOTO 30

REM I THINK THIS IS THE FLASHING CURSOR
REM GET COLOR AT X-1, Y,
REM IF COLOR IS THE SAME AS C, MAKE THE C=0 OTHERWISE NO CHANGE
REM USING THAT COLOR SET X,Y AND X+1,Y TO C
20 CC = LOC( X-1,Y):IF C=CC THEN C=0
30 LO(X,Y)=C:LO(X+1,Y)=C:GOTO 60

20 CC = LO%( X-1,Y):IF C=CC THEN C=BL

30 LO%(X,Y)=C:LO%(X+1,Y)=C:I=X:J=Y:GOSUB 100:I=X+1:GOSUB 100:GOTO 60

REM SEE IF THE COLOR AT X-1,Y IS THE SAME AS C
REM IF NOT, MAKE IT THE SAME
40 Z = LOC(X-1,Y):IF Z=C THEN RETURN
40 Z = LO%(X-1,Y):IF Z=C THEN RETURN

45 COLOR = C
46 FOR I=X-1 TO X+2
47 FOR J=Y-1 TO Y+1
50 LOC(I,J)=C
51 NEXT J
52 NEXT I
45 COLOR = C:FOR I=X-1 TO X+2:FOR J=Y-1 TO Y+1
50 LO%(I,J)=C:GOSUB 100:NEXT J:NEXT I

REM SEE IF THERE IS INPUT FROM REMOTE SITE
60 FOR V=0 TO 10:NEXT V

61 & NSTATUS N0, BW, CN, ERR:IF BW=0 THEN RETURN
65 GOSUB 15: & NINPUT N0, A$
66 GOSUB 240:IF TRIG=0 THEN 1700
60 REM
61 & NSTATUS N0, BW, CN, ERR:IF BW>0 THEN GOSUB 18: & NINPUT N0, A$:GOSUB 240
70 RETURN

REM PLOT AT I,J
100 C = LO%(I,J):COLOR=C:IF AX%(I,J) > -1 AND J<40 THEN PLOT AX%(I,J),J
110 RETURN

REM THIS ROUTINE REMOVES CONTENT BEFORE THE FIRST COMMA
REM FROM A STRING
200 FC=1
Expand All @@ -53,23 +64,28 @@ REM THIS TAKES 3 COMMA SEPARATED VALUES IN A$ AND RETURNS THEM AS
REM X,Y,TRIG

240 X = VAL(A$):GOSUB 200:Y=VAL(A$):GOSUB 200: TRIG=VAL(A$)
247 HTAB 1: VTAB 22: PRINT "CONVERT: ";X;",";Y;",";TRIG;
250 RETURN

REM CENTER TEXT ON A 40 COLUMN DISPLAY
300 M=LEN(A$)/2:HTAB 20-M: PRINT A$;: RETURN

REM ********************************************************
REM ********************************************************
REM START OF PROGRAM
REM ********************************************************
REM ********************************************************

REM LO IS THE ATARI REPRESENTATION OF THE SCREEN
500 DIM F(1),S(1,9),LO(79,47)
REM AX CONVERT ATARI X COORDINATE TO APPLE X COORDINATE

500

501 LS=0
500 LS=0

530 VTAB 10: A$= "#FUJINET REVERSI - APPLE EDITION": INVERSE:GOSUB 300:NORMAL

531 VTAB 15: HTAB 1: A$ = "BE SURE TO FORWARD TCP PORT 6502.":GOSUB 300: PRINT
540 VTAB 20: PRINT "TYPE HOSTNAME OR PRESS ";:INVERSE: PRINT "ENTER": NORMAL: PRINT " TO HOST"
540 VTAB 20: PRINT "TYPE HOSTNAME OR PRESS ";:INVERSE: PRINT "ENTER";: NORMAL: PRINT " TO HOST"
550 INPUT H$
560 IF H$="" THEN LS=1
565 HOME
Expand All @@ -91,61 +107,87 @@ REM LO IS THE ATARI REPRESENTATION OF THE SCREEN
601 IF NOT LS THEN 620

610 PRINT:PRINT "PLAYER 1";:INPUT A$:IF A$="" THEN 610
612 A$=A$+CR$
615 & NPRINT N0, A$
615 & NPRINT N0, A$: HTAB 30: VTAB 23: PRINT ">";A$;
616 & NSTATUS N0,BW,CN,ER:IF BW = 0 THEN 616
617 & NINPUT N0, B$
617 & NINPUT N0, B$: HTAB 15:VTAB 23:PRINT "<";B$;

618 GOTO 700

620 PRINT:PRINT "PLAYER 2";:INPUT B$:IF B$="" THEN 620
621 B$=B$+CR$
622 & NPRINT N0, B$
623 & NSTATUS N0,BW,CN,ER:IF BW = 0 THEN 623
624 & NINPUT N0, A$

624 GOTO 700

REM 625 F(0)=0:F(1)=0
REM 630 IF A$="COMPUTER" THEN F(0)=1
REM 640 IF B$="COMPUTER" THEN F(1)=1

REM CLEAR THE "SCREEN"
700 HOME:INVERSE:PRINT "PLEASE WAIT...";: NORMAL
REM 705 FOR X=0 TO 79:FOR Y=0 TO 47:LO(X,Y)=0:NEXT Y: NEXT X
710 PRINT "30%...";
750 C=3
760 FOR Y=1 TO 37
770 LO(17,Y)=C:LO(18,Y)=C:LO(19,Y)=C
780 FOR X=20 TO 60 STEP 5:LO(X,Y)=C:NEXT X
790 LO(61,Y)=C:LO( 62,Y)=C:LO(63,Y)=C
795 NEXT Y
799 PRINT "50%...";
800 FOR X=17 TO 60
810 LO(X,1)=C::LO(X,2)=C
820 FOR Y=3 TO 35 STEP 4:LO(X,Y)=C:NEXT Y
830 LO(X,36)=C:LO(X,37)=C
840 NEXT X
845 PRINT "90%...";
625 GOTO 700


REM ******************************************************************
REM AX - ATARI TO APPLE TRANSLATION
REM ******************************************************************

650 PRINT "CONVERTING ATARI TO APPLE COORDINATES..."
REM DON'T START SKIP UNTIL COLUMN 22
655 FOR Y=0 TO 39:X1=0:X2=0:FOR X=OX TO 79:AX%(X,Y)=-1:IF X < 20 THEN 675
660 IF X2 > 39 THEN 680

REM SKIP EVERY 3RD COLUMN
665 X1=X1+1:IF X1=SS THEN AX%(X,Y)=-1:GOTO 680

REM START COUNTING AGAIN AFTER #5
670 IF X1 = 5 THEN X1=0
675 AX%(X,Y) = X2 : X2=X2+1

680 NEXT X:NEXT Y:RETURN

REM ***********************************************************************
REM ***********************************************************************
REM BUILD UP THE BOARD
REM ***********************************************************************
REM ***********************************************************************
700 HOME:INVERSE:PRINT "PLEASE WAIT...":NORMAL:GR:C=BL

REM FORCE VISIBLE AREA TO BE LIGHT GREEN
710 FOR Y=0 TO 39:FOR X=OX TO 79:LO%(X,Y)=BL:NEXT X:NEXT Y

750 C=BD

REM ***********************************************************************
REM LINES DOWN
REM ***********************************************************************
760 FOR Y=1 TO 37:LO%(17,Y)=C:LO%(18,Y)=C:LO%(19,Y)=C:FOR X=20 TO 60 STEP 5:LO%(X,Y)=C:NEXT X:LO%(61,Y)=C:LO%( 62,Y)=C:LO%(63,Y)=C:NEXT Y

REM ***********************************************************************
REM LINES ACROSS
REM ***********************************************************************
800 FOR X=17 TO 60:LO%(X,1)=C:LO%(X,2)=C:FOR Y=3 TO 35 STEP 4:LO%(X,Y)=C:NEXT Y:LO%(X,36)=C:LO%(X,37)=C: NEXT X

REM STARTING BLOCKS
850 FOR L=1 TO 6:READ X,Y,C:GOSUB 40:NEXT L:RESTORE
855 DATA 10,36,1,37,17,1,42,21,1,72,36,2,42,17,2,37,21,2
REM ME ME ME TH TH TH
855 DATA 10,36,0,37,17,0,42,21,0,72,36,15,42,17,15,37,21,15

REM DRAW THE SCREEN - ALBEIT SLOWLY
860 GOSUB 11

860 GR
REM DRAW
900 GOSUB 11
REM ***********************************************************************
REM ***********************************************************************
REM ***********************************************************************

REM ***********************************************************************
REM CALCULATE SCORE
REM ***********************************************************************

990 P=2
1000 P=3-P
1010 A=0:B=0:
1011 FOR M=22 TO 57 STEP 5
1012 FOR N=5 TO 33 STEP 4
1020 C = LOC( M,N ):IF C=1 THEN A=A+1
1030 IF C=2 THEN B=B+1
1040 IF C=0 THEN X=M:Y=N
1020 C = LO%( M,N ):IF C=ME THEN A=A+1
1030 IF C=TH THEN B=B+1
1040 IF C=BL THEN X=M:Y=N
1050 NEXT N
1051 NEXT M
1055 HTAB 1:VTAB 21: PRINT A$;:HTAB 40-LEN(B$):PRINT B$: HTAB LEN(B$)/2: PRINT " ";A;" ";:HTAB 40-LEN(B$)/2:PRINT B;" "
1055 HTAB 1:VTAB 21: PRINT A$;:INVERSE:HTAB 40-LEN(B$):PRINT B$: NORMAL: HTAB LEN(B$)/2: PRINT " ";A;" ";:HTAB 40-LEN(B$)/2:PRINT " ";B;" ";

1070 IF A+B=64 THEN 2000
1110 IF F(P-1)=0 THEN GOTO 1500
Expand All @@ -156,59 +198,53 @@ REM DRAW
1145 NEXT L:GOTO 1000


1500 C=P:GOSUB 20:GOSUB 20:GOSUB 17

REM ATARI LINE
REM N = KEYPRESS
REM 1510 N=PEEK(764):POKE 764,255:TRIG=STRIG(0):JS=STICK(0)
REM STRIG RETURN ZERO WHEN BUTTON PRESSED

1510 IF PEEK(-16384) > 128 THEN GET A$: K=ASC(A$):GOTO 1512
1511 N=255:K=0
1512 IF K=32 THEN N=33 : REM SPACE
1513 IF K=13 THEN N=12 : REM ENTER
1514 IF K=49 THEN N=31 : REM '1'
1515 IF K=50 THEN N=30 : REM '2'
REM 1516 IF K=76 OR K=108 THEN N=10 : REM 'L' ??
1517 IF K=76 OR K=21 THEN N=7 : REM 'K' RIGHT
1518 IF K=74 OR K=8 THEN N=11 : REM 'J' LEFT
1519 IF K=75 OR K=10 THEN N=15 : REM 'L' DOWN
1520 IF K=73 OR K=11 THEN N=14 : REM 'I' UP

REM JOYSTICK CENTERED 15, LEFT=11, RIGHT=7, UP=14, DOWN=11
REM TRIG=0 THEN BUTTON PRESSED
1521 JS = 15
1500 C=P
1500 C=TH:IF P=1 THEN C=ME
1505 GOSUB 20:GOSUB 20:GOSUB 19
1510 TRIG=1:N=255:K=0:IF PEEK(-16384) > 128 THEN GET A$: K=ASC(A$):GOTO 1512
1511 IF LS=0 AND P=1 THEN 1500
1512 IF LS=1 AND P=2 THEN 1500

1522 IF LS=0 AND P=1 THEN 1500
1523 IF LS=1 AND P=2 THEN 1500
1520 IF N=255 AND TRIG=1 AND JS=15 THEN 1500

1524 IF N=255 AND TRIG=1 AND JS=15 THEN 1500
REM CONVERT FROM APPLE KEYS TO ATARI

REM SPACE OR ENTER OR NO JOYSTICK TRIGGER
1530 IF N=33 OR N=12 OR TRIG=0 THEN 1690
1521 IF K=32 THEN N=33 : REM SPACE
1512 IF K=13 THEN N=12 : REM ENTER
1513 IF K=49 THEN N=31 : REM '1'
1514 IF K=50 THEN N=30 : REM '2'
REM RETURN TAB
REM 1516 IF K=76 OR K=108 THEN N=10 : REM INVALID MOVE ????
1515 IF K=76 OR K=21 THEN N=7 : REM 'K' RIGHT
1516 IF K=74 OR K=8 THEN N=11 : REM 'J' LEFT
1517 IF K=75 OR K=10 THEN N=15 : REM 'L' DOWN
1518 IF K=73 OR K=11 THEN N=14 : REM 'I' UP

1520 IF N=255 AND TRIG=1 AND JS=15 THEN 1500
1530 IF N=33 OR N=12 OR TRIG=0 THEN 1698
1540 IF N=30 THEN C=2:GOSUB 40:GOTO 1500
1550 IF N=31 THEN C=1:GOSUB 40:GOTO 1500
1560 IF N=10 THEN 1630
1570 X=X+5*((N=7 OR JS=7) AND X<57)-5*((N=6 OR JS=11) AND X>22)
1580 Y=Y+4*((N=15 OR JS=13) AND Y<33)-XY*((N=14 OR JS=14) AND Y>5)
1581 IF N=33 OR N=12 THEN TRIG=0
1582 O$ = STR$(X)+","+STR$(Y)+","+STR$(TRIG):& NPRINT N0, O$
1582 O$ = STR$(X)+","+STR$(Y)+","+STR$(TRIG):& NPRINT N0, O$: HTAB 30: VTAB 23: PRINT ">";O$;
1590 GOTO 1500

1630 GOSUB 17:GOSUB 5000:IF Q=0 THEN 1000
1655 FOR I=0 TO 20
1657 NORMAL:IF I/2 = INT(I/2) THEN INVERSE
1660 VTAB 21:A$="INVALID MOVE":GOSUB 300:GOSUB 60
1670 NEXT I:VTAB 21:NORMAL:A$= " ":GOSUB 300:GOTO 1010
1630 GOSUB 19:GOSUB 5000:IF Q=0 THEN 1000
1655 FOR I=0 TO 20:NORMAL:IF I/2 = INT(I/2) THEN INVERSE
1656 VTAB 21:A$="INVALID MOVE":GOSUB 300:GOSUB 60
1657 NEXT I:VTAB 21:NORMAL:A$= " ":GOSUB 300:GOTO 1010

1690 IF N=33 OR N=12 THEN TRIG=0
1695 O$ = STR$(X)+","+STR$(Y)+","+STR$(TRIG):& NPRINT N0, O$
1697 HTAB 1: VTAB 22: PRINT "SENT: ";O$
1700 G=0:GOSUB 4000:IF R=0 THEN GOSUB 17:GOTO 1655
1698 IF N=33 OR N=12 THEN TRIG=0
1699 O$ = STR$(X)+","+STR$(Y)+","+STR$(TRIG):& NPRINT N0, O$:

1700 G=0:GOSUB 4000:IF R=0 THEN GOSUB 19:GOTO 1655
1730 G=1:GOSUB 4000
1780 GOTO 1000

REM END OF GAME

2000 PRINT "TO SEE SCOREBOARD, PRESS ANY KEY":GET A$
2040 S(0,GC)=A:S(1,GC)=B
2050 TEXT:HOME:HTAB 1:VTAB 10:PRINT "GAME":HTAB 1: VTAB 12:PRINT A$:HTAB 1:VTAB 14:PRINT B$
Expand All @@ -222,14 +258,15 @@ REM SPACE OR ENTER OR NO JOYSTICK TRIGGER
2140 GOTO 600
3000 TEXT:HOME:PRINT "DISCONNECTED.":& NCLOSE 0:END

REM I THINK THIS IS FOR DETERMINING WHERE OUR CURSOR IS

4000 R=0:SX=X:SY=Y
4005 C = LOC( X-1,Y ):IF C<>0 THEN RETURN
4005 C = LO%( X-1,Y ):IF C<>0 THEN RETURN
4010 FOR DX=-1 TO 1
4011 FOR DY=-1 TO 1
4020 IF DX=0 AND DY=0 THEN 4130
4030 RT=0:X=SX:Y=SY
4050 X=X+DX*5:Y=Y+DY*4:C = LOC( X,Y )
4050 X=X+DX*5:Y=Y+DY*4:C = LO%( X,Y )
4060 IF C=3-P THEN RT=RT+1:GOTO 4050
4070 IF C=P THEN R=R+RT:IF G=1 THEN 4100
4080 GOTO 4130
Expand All @@ -239,21 +276,13 @@ REM SPACE OR ENTER OR NO JOYSTICK TRIGGER
4131 NEXT DX:X=SX:Y=SY:RETURN

5000 Q=0:QX=0:QY=0
5010 FOR M=0 TO 7
5011 FOR N=0 TO 7
5020 X=M*5+22:Y=N*4+5
5030 C = LOC( X,Y ):IF C<>0 THEN 5090
5035 C=P:GOSUB 20:GOSUB 17
5040 G=0:GOSUB 4000
5080 IF R>Q THEN Q=R:QX=X:QY=Y
5090 NEXT N
5091 NEXT M:X=QX:Y=QY:RETURN
5010 FOR M=0 TO 7:FOR N=0 TO 7:X=M*5+22:Y=N*4+5:C = LO%( X,Y ):IF C<>0 THEN 5090
5035 C=P:GOSUB 20:GOSUB 19:G=0:GOSUB 4000:IF R>Q THEN Q=R:QX=X:QY=Y
5090 NEXT N:NEXT M:X=QX:Y=QY:RETURN

7005 FOR X=0 TO 8:S(0,X)=0:S(1,X)=0:NEXT X
8000 GOTO 8000

REM DRAW SCREEN



REM *******************************************
Expand All @@ -277,3 +306,24 @@ REM *******************************************

SAVE /FUJI.APPLE/REVERSI.BAS

5 HOME
61
517
550
571
580
585
590
610 A$="NORMAN"
615
616
617 B$="COMPUTER"
622
623
624 A$="COMPUTER"
1582





0 comments on commit 07dc94c

Please sign in to comment.