## Barca in BASIC

So you’re feeling nostalgic and want to have fun with an old school BASIC program. Or maybe you want to experience the old days of computing where you had to type in the game you played! Then break out that Apple II, Commodore 64 or emulator and you can enter Barca in BASIC.

A good amount of work that I did making video games was programming them. It’s something I enjoy doing. Stumbling across an old BASIC programming book, “What To Do After You Hit Return or P.C.C.’s First Book of Computer Games” gave me the idea to write a Barca program in that fashion. The program was tested on my old Apple IIe computer. Although it was written in vanilla BASIC you may still may have to make changes to accommodate your computer’s flavor.

Barca in BASIC is a two human player game that displays the game in progress and enforces the rules.

The full listing…

1000 PRINT “WELCOME TO BARCA, THE WATERING HOLE GAME”

2000 DIM A$(6),C$(1),F$(2),P$(2),W$(1)

2010 DIM B(9,9),F(9,9),G(7),H(7),L(6),R(6),S(6)

2020 LET A$(0) = “”

2030 LET B$ = CHR$(8)

2040 LET C$(0) = ” ”

2050 LET C$(1) = “.”

2060 LET F$(0) = “”

2070 LET F$(1) = B$ + “!”

2080 LET F$(2) = B$ + “*”

2090 LET P$(1) = “ELM”

2100 LET P$(2) = “PCR”

2110 LET W$(0) = “”

2120 LET W$(1) = B$ + “_”

2130 FOR Y = 0 TO 9

2140 FOR X = 0 TO 9

2150 LET B(X,Y) = 0

2160 NEXT X

2170 NEXT Y

2180 FOR I = 1 TO 6

2190 READ I$,X,Y,R(I),L(I),S(I)

2200 LET B(X,Y) = I

2210 LET B(9 – X,Y) = I

2220 LET A$(I) = B$ + I$

2230 NEXT I

2240 FOR I = 0 TO 7

2250 READ G(I),H(I)

2260 NEXT I

3000 PRINT “WHICH PLAYER WON ROSHAMBO (1 OR 2) “;

3010 INPUT P

3020 LET P = ABS(P – 2) + 1

3030 IF P > 2 THEN GOTO 3000

4000 LET M = 0

4010 FOR Y = 0 TO 9

4020 FOR X = 0 TO 9

4030 LET S = 0

4040 LET A = B(X,Y)

4050 IF A = 0 THEN GOTO 4240

4060 LET U = X

4070 LET V = Y

4080 GOSUB 8000

4090 IF S = 0 THEN GOTO 4240

4100 FOR I = L(A) TO 7 STEP S(A)

4110 LET U = X

4120 LET V = Y

4130 LET V = V + H(I)

4140 IF V < 0 OR V > 9 THEN GOTO 4230

4150 LET U = U + G(I)

4160 IF U < 0 OR U > 9 THEN GOTO 4230

4170 IF B(U,V) > 0 THEN GOTO 4230

4180 GOSUB 8000

4190 IF S = 1 THEN GOTO 4130

4200 LET S = 2

4210 IF P = INT((9 – A) / 3) THEN LET M = 2

4220 LET I = 7

4230 NEXT I

4240 LET F(X,Y) = S

4250 NEXT X

4260 NEXT Y

5000 PRINT

5010 PRINT ” “;

5020 FOR X = 0 TO 9

5030 PRINT ” “;X;

5040 NEXT X

5050 PRINT

5060 LET G = 0

5070 FOR Y = 0 TO 9

5080 PRINT ” “;Y;” “;

5090 FOR X = 0 TO 9

5100 LET I = 0

5110 IF (Y = 3 OR Y = 6) AND (X = 3 OR X = 6) THEN I = 1

5120 PRINT C$(G);C$(G);W$(I);A$(B(X,Y));C$(G);F$(F(X,Y));

5130 LET G = ABS(G – 1)

5140 NEXT X

5150 PRINT

5160 LET G = ABS(G – 1)

5170 NEXT Y

5180 PRINT

6000 LET I = 0

6010 FOR Y = 3 TO 6 STEP 3

6020 FOR X = 3 TO 6 STEP 3

6030 IF INT((B(X,Y) + 2) / 3) = P THEN LET I = I + 1

6040 NEXT X

6050 NEXT Y

6060 IF I < 3 THEN GOTO 7000

6070 PRINT “PLAYER “;P;” WINS!”

6080 PRINT “BARCA SAYS GOODBYE”

6090 END

7000 LET P = ABS(P – 2) + 1

7010 PRINT “PLAYER “;P;” (“;P$(P);”) MOVE FROM X,Y “;

7020 INPUT X,Y

7030 IF X < 0 OR X > 9 OR Y < 0 OR Y > 9 THEN GOTO 7010

7040 IF P <> INT((B(X,Y) + 2) / 3) THEN GOTO 7010

7050 IF M = 2 AND F(X,Y) < 2 THEN GOTO 7010

7060 PRINT ” TO X,Y “;

7070 INPUT C,D

7080 IF C < 0 OR C > 9 OR D < 0 OR D > 9 THEN GOTO 7060

7090 LET U = ABS(X – C)

7100 LET V = ABS(Y – D)

7110 IF U * V > 0 AND U <> V THEN GOTO 7060

7120 LET A = B(X,Y)

7130 IF (A = 1 OR A = 4) AND U * V > 0 THEN GOTO 7060

7140 IF (A = 2 OR A = 5) AND U * V = 0 THEN GOTO 7060

7150 LET U = X

7160 LET V = Y

7170 LET U = U + SGN(C – X)

7180 LET V = V + SGN(D – Y)

7190 IF B(U,V) <> 0 THEN GOTO 7060

7200 IF C <> U OR D <> V THEN GOTO 7170

7210 GOSUB 8000

7220 IF S = 1 AND F(X,Y) <> 1 THEN GOTO 7060

7230 LET B(C,D) = B(X,Y)

7240 LET B(X,Y) = 0

7250 GOTO 4000

8000 LET S = 0

8010 FOR Z = V – 1 TO V + 1

8020 IF Z < 0 OR Z > 9 THEN GOTO 8100

8030 FOR W = U – 1 TO U + 1

8040 IF W < 0 OR W > 9 THEN GOTO 8090

8050 IF R(A) <> B(W,Z) THEN GOTO 8090

8060 LET S = 1

8070 LET Z = V + 1

8080 LET W = U + 1

8090 NEXT W

8100 NEXT Z

8110 RETURN

9000 DATA “M”,4,1,5,0,2,”L”,3,1,6,1,2,”E”,4,0,4,0,1

9010 DATA “R”,4,8,2,0,2,”C”,3,8,3,1,2,”P”,4,9,1,0,1

9020 DATA 0,-1,1,-1,1,0,1,1,0,1,-1,1,-1,0,-1,-1

9999 REM COPYRIGHT 2012 ANDREW CALDWELL

Don’t forget to save it to the tape or floppy drive!

Enjoy Typing

-Drew