Rafferty Run

Type
Game
Category
Two-player coin race
Author
Chuck Rosko
Published in
ANALOG Computing, issue 36 (1985); later on the BELLCOM public domain disks
Year
1985
Language
Atari BASIC (with a short machine-language DLI)
Requirements
Any 8-bit Atari with 16K+ and Atari BASIC; two joysticks
Title screen with RAFFERTY RUN between two shamrocks, BY CHUCK ROSKO, and PRESS START FOR COLOR TV, SELECT FOR BW TV

About the program

Rafferty Run is a head-to-head game for two players, with an Irish flavour: the title is framed by shamrocks, and the winner's name, Paddy O'Brian or Lanny McErly, goes up in lights at the end. The playfield is a network of paths in a GRAPHICS 1 screen built from redefined characters. Coins appear one at a time at random spots. Each player must reach a coin first, pick it up, and carry it back to his own pot at the bottom of the screen. The first to bank ten coins wins. The REM header says it was written "for ANALOG". It appeared in ANALOG Computing issue 36 in 1985 and was later collected on the BELLCOM public domain disks.

What you need

Any Atari with Atari BASIC and 16K or more, and two joysticks. Paddy uses port 1 and Lanny port 2. There's no computer opponent.

Typing it in

  • Every number is written as a constant variable (K0, K1 … K32, set in line 8). That's an ANALOG-era trick: each numeric constant in Atari BASIC costs seven bytes of memory, but a variable reference costs only one. Type the K's exactly as shown.
  • Lines 25000–25060 draw the maze from ordinary characters (#, $, (, &, +, - and others). After the character set is redefined they become path corners, straights and junctions, so the strings must be copied character for character, spaces included. The same applies to the shamrock patterns made of Q in lines 1020–1050.
  • A few words are in inverse video ({inv}start{/inv}, {inv}coins{/inv} and so on). Press the Atari key before and after them.

How to play

On the title screen, press START for a colour TV or SELECT for black and white. Then race:

  • Run to the coin and step onto it to pick it up. While you're carrying it, a coin symbol shows in the middle of the screen. Then go back along the paths and drop down into your pot to bank it.
  • Walking into your own pot without a coin costs you one, so don't wander in by mistake.
  • The shamrocks at the crossroads are switches. Pushing up into one reshuffles the junction pieces around it, opening some routes and closing others, and sometimes makes the paths go dark for a while.
  • If the two runners collide, both drop whatever they were carrying.

A throbbing tone plays throughout and climbs in pitch as coins are banked.

How it works

  • Characters as a map. The screen is GRAPHICS 1 with a redefined character set (lines 32000–32231 copy the ROM font and patch several dozen characters). Each path piece is a character whose code says which directions are open, and lines 300–630 use LOCATE to read the piece a runner is standing on before allowing a move. Moving onto a coin, a pot, a shamrock or the other player is detected the same way.
  • A heartbeat in a DLI. Lines 29000–29030 put a 21-byte display-list interrupt in page 6. It's called once per frame and steps the pitch of sound channel 1 down a 20-step sweep, over and over. Banking a coin POKEs new values into the routine's own code (line 654), so the sweep climbs higher as the race goes on.
  • Two players, one loop. Line 265 alternates G between 0 and 1 on each pass, so one set of movement code serves both players.

Listing

2 REM ******* RAFFERTY RUN ******
3 REM ****** BY CHUCK ROSKO *****
4 REM ******** FOR ANALOG *******
8 K1=1:K2=2:K3=3:K4=4:K5=5:K6=6:K7=7:K8=8:K10=10:K11=11:K12=12:K13=13:K14=14:K15=15:K16=16:K32=32
10 DIM ZZ$(K32),XD(K15),XC(K8),YC(K8),COIN(K2),ZT(K2),X(K2),Y(K2),CTEMP(K2),MAN(K2),POT(K2)
20 POKE 559,K0:GOSUB 32000:POKE 559,34:GOTO 28000
250 REM {inv} READ JOYSTICKS {/inv}
260 L=L+K1:IF INT(L/K2)=L/K2 THEN M=K1-M:L=K0
263 MAN(G)=M+254*(G=K0)+126*(G=K1):M=K1-M
265 G=K1-G:J=STICK(G):ON XD(J) GOTO 300,400,500,600,700
300 LOCATE X(G)+K1,Y(G),Z:K=(ZT(G)=36)+(ZT(G)=38)+(ZT(G)=39)+(ZT(G)=45):IF K=K1 THEN 260
310 K=260*(Z=K32 OR Z=43)+320*(Z=216)+995*(Z=254 OR Z=255 OR Z=126 OR Z=127):IF K=K0 THEN 330
315 GOTO K
320 IF CTEMP(G)=K1 THEN 260
325 COLOR K32:PLOT X(G)+K1,Y(G):COLOR 251-G*128:PLOT K12-G*K5,K13:GOSUB 985:GOSUB 910:CTEMP(G)=K1:GOTO 260
330 COLOR ZT(G):PLOT X(G),Y(G):X(G)=X(G)+K1:COLOR MAN(G):PLOT X(G),Y(G):ZT(G)=Z:GOTO 260
400 LOCATE X(G)-K1,Y(G),Z:K=(ZT(G)=35)+(ZT(G)=36)+(ZT(G)=37)+(ZT(G)=43):IF K=K1 THEN 260
410 K=260*(Z=K32 OR Z=45)+420*(Z=216)+995*(Z=254 OR Z=255 OR Z=126 OR Z=127):IF K=K0 THEN 430
415 GOTO K
420 IF CTEMP(G)=K1 THEN 260
425 COLOR K32:PLOT X(G)-K1,Y(G):COLOR 251-G*128:PLOT K12-G*K5,K13:GOSUB 985:GOSUB 910:CTEMP(G)=K1:GOTO 260
430 COLOR ZT(G):PLOT X(G),Y(G):X(G)=X(G)-K1:COLOR MAN(G):PLOT X(G),Y(G):ZT(G)=Z:GOTO 260
500 LOCATE X(G),Y(G)-K1,Z:K=(ZT(G)=35)+(ZT(G)=38)+(ZT(G)=40)+(ZT(G)=44):IF K=K1 THEN 260
510 K=260*(Z=K32 OR Z=42)+520*(Z=81)+995*(Z=254 OR Z=255 OR Z=126 OR Z=127):IF K=K0 THEN 530
515 GOTO K
520 IF PEEK(540)=K0 THEN ZZ=(X(G)*K2)+800:GOTO ZZ
525 GOTO 260
530 COLOR ZT(G):PLOT X(G),Y(G):Y(G)=Y(G)-K1:COLOR MAN(G):PLOT X(G),Y(G):ZT(G)=Z:GOTO 260
600 LOCATE X(G),Y(G)+K1,Z:K=(ZT(G)=37)+(ZT(G)=39)+(ZT(G)=40)+(ZT(G)=42):IF K=K1 THEN 260
610 K=260*(Z=K32 OR Z=44 OR Z=POT(K1-G))+995*(Z=254 OR Z=255 OR Z=126 OR Z=127)+635*(Z=POT(G)):IF K=K0 THEN 630
620 GOTO K
630 COLOR ZT(G):PLOT X(G),Y(G):Y(G)=Y(G)+K1:COLOR MAN(G):PLOT X(G),Y(G):ZT(G)=Z:GOTO 260
635 IF CTEMP(G)=K0 THEN 640
637 GOTO 650
640 COIN(G)=COIN(G)-K1:IF COIN(G)<K0 THEN COIN(G)=K0
645 POSITION K11-G*K10,23:? #K6;COIN(G):GOSUB 990:GOTO 660
650 FOR C=K15 TO K0 STEP -0.25:SOUND K2,C+C,K10,C:SOUND K2,K0,K0,K0:POKE 711-G-G,(127-G*K32)-C:NEXT C
651 POKE 711-G-G,127-G*K32
652 IF BW=K1 THEN POKE 711,134:POKE 709,127
653 COIN(G)=COIN(G)+K1:GOSUB 985:POSITION K11-G*K10,23:? #K6;COIN(G):GOSUB 910
654 S=S+K2:POKE 1547,70-S:POKE 1551,90-S:POKE 1600,90-S
660 COLOR K32:PLOT K12-G*K5,K13:CTEMP(G)=K0:GOTO 670+G*K10
670 COLOR 36:PLOT K12,K11:X(K0)=K3:Y(K0)=21:ZT(K0)=37:COLOR MAN(K0):PLOT X(K0),Y(K0):GOTO 690
680 COLOR 36:PLOT K7,K11:X(K1)=K16:Y(K1)=21:ZT(K1)=39:COLOR MAN(K1):PLOT X(K1),Y(K1):GOTO 690
690 IF COIN(G)=MAX THEN 1000
695 GOTO 260
700 IF PEEK(540)=K0 THEN POKE 708,200
710 COLOR MAN(G):PLOT X(G),Y(G):GOTO 260
800 REM {inv} CHANGE CROSSROADS {/inv}
804 GOSUB 975:PLOT K6,K7:GOSUB 980:GOSUB 975:PLOT K8,K7:GOSUB 980
805 GOSUB 975:PLOT K6,K8:GOSUB 980:GOSUB 975:PLOT K8,K8:GOSUB 980:GOTO 850
818 GOSUB 975:PLOT K6,K15:GOSUB 980:GOSUB 975:PLOT K8,K15:GOSUB 980
819 GOSUB 975:PLOT K6,K16:GOSUB 980:GOSUB 975:PLOT K8,K16:GOSUB 980:GOTO 850
820 GOSUB 975:PLOT K11,K7:GOSUB 980:GOSUB 975:PLOT K13,K7:GOSUB 980
821 GOSUB 975:PLOT K11,K8:GOSUB 980:GOSUB 975:PLOT K13,K8:GOSUB 980:GOTO 850
834 GOSUB 975:PLOT K11,K15:GOSUB 980:GOSUB 975:PLOT K13,K15:GOSUB 980
835 GOSUB 975:PLOT K11,K16:GOSUB 980:GOSUB 975:PLOT K13,K16:GOSUB 980:GOTO 850
845 REM {inv} PATHS DISAPPEAR {/inv}
850 DARK=INT(RND(K0)*K7)+K1:IF DARK=K1 THEN POKE 708,K0
860 POKE 540,120:GOTO 260
900 REM {inv} PLOT COINS {/inv}
910 CN=INT(RND(K0)*K7)+K1:COLOR 216:PLOT XC(CN),YC(CN):GOTO 985
970 REM {inv} CHANGE CROSSROADS {/inv}
975 COLOR 209:PLOT X(G),Y(G)-K1:PATH=INT(RND(K0)*K5)+41:COLOR PATH:RETURN 
977 REM {inv} SOUND SUBROUTINES {/inv}
980 FOR C=K14 TO K0 STEP -K2:SOUND K2,K10*C,K10,C:NEXT C:COLOR 81:PLOT X(G),Y(G)-K1:RETURN 
985 SOUND K2,K6,K10,K14:SOUND K3,K8,K10,K14:SOUND K2,K0,K0,K0:SOUND K3,K0,K0,K0:RETURN 
990 FOR C=K15 TO K0 STEP -0.4:SOUND K2,80,K0,C:NEXT C:RETURN 
995 FOR C=K10 TO K0 STEP -K1:SOUND K2,150,K0,C:POKE 708,200-C:NEXT C:POKE 708,200:CTEMP(K0)=K0:CTEMP(K1)=K0
997 COLOR K32:PLOT K7,K13:PLOT K12,K13:GOTO 260
1000 POKE 54286,64:FOR C=50 TO K0 STEP -K1:FOR J=K0 TO K3:SOUND J,C+J,K10,K8:NEXT J:NEXT C:FOR C=K1 TO K3
1005 SOUND C,K0,K0,K0:NEXT C:FOR C=K1 TO 22:COLOR K32:PLOT K0,C:DRAWTO 19,C:NEXT C
1010 POSITION K3,K3:? #K6;"THE  WINNER IS":IF COIN(K0)=MAX THEN POSITION K3,K5:? #K6;"{inv}paddy{/inv} {inv} o brian{/inv}":GOTO 1020
1015 POSITION K3,K5:? #K6;"lanny  mc erly"
1020 POSITION K0,K7:? #K6;"        QQQQ               Q    Q             Q      Q"
1030 POSITION K0,K10:? #K6;"    Q  Q    Q  Q       Q Q  Q  Q  Q Q     Q   QQ    QQ   Q"
1040 POSITION K0,K13:? #K6;"  Q              Q    Q     Q  Q     Q    Q   QQ QQ  Q   Q"
1050 POSITION K0,K16:? #K6;"   Q Q   QQ   Q Q       Q    QQ    Q             QQ":C=K5:FOR CC=K1 TO 100
1060 C=C+K15:IF C>245 THEN C=K5
1070 POKE 708,C:SOUND K3,C,K10,K6:NEXT CC:POKE 708,200:SOUND K3,K0,K0,K0
1200 FOR C=K1 TO 1000:NEXT C:POSITION K0,K0:? #K6;CHR$(125):GOTO 28000
24995 REM {inv} DRAW SCREEN {/inv}
25000 POKE 559,K0:POSITION K0,K2:? #K6;"   #((& #((& #((&      $  $ $  $ $  $      +{inv}X{/inv} $ $ Q$ +{inv}X{/inv} $   "
25010 POSITION K0,K5:? #K6;"   $  - $ $$ $  -      $  $ $ $$ $  $      +((' %(*' %((-   "
25020 POSITION K0,K8:? #K6;" #(-  #,&  #,&  +(&  $ $  $$$  $$$  $ $  $ $  $$$  $$$  $ $ "
25030 POSITION K0,K11:? #K6;" $ $  $$$  $$$  $ $  $Q$  $z$  ${inv}z{/inv}$  $Q$  $$$  $ $  $ $  $$$ "
25040 POSITION K0,K14:? #K6;" $$$  $ $  $ $  $$$  %*-  %('  %('  +*' "
25050 POSITION K0,K16:? #K6;"   +((& #((& #((-      $  $ $  $ $  $      +  $ $Q $ +  $   "
25060 POSITION K0,19:? #K6;"   $  - $$ $ $  -      $  $ $$ $ $  $      %((' %*(' %(('   "
25070 POSITION K2,K0:? #K6;"Q {inv}RAFFERTY RUN{/inv} Q":POKE 559,34:RETURN 
27995 REM {inv} TITLE & INIT {/inv}
28000 POKE 708,200:POKE 709,95:POKE 710,46:POKE 711,143:C=K5
28010 POSITION K0,K3:? #K6;"  Q RAFFERTY RUN Q  ":POSITION K3,K5:? #K6;"by chuck rosko":POSITION K2,K12
28015 ? #K6;"PRESS":POSITION K2,K14:? #K6;"{inv}start{/inv} for color tv":POSITION K2,K16:? #K6;"{inv}select{/inv} for bw tv"
28020 IF PEEK(53279)=K6 THEN POKE 711,143:POKE 709,95:BW=K0:GOTO 28050
28025 IF PEEK(53279)=K5 THEN POKE 711,134:POKE 709,127:BW=K1:GOTO 28050
28030 C=C+K15:IF C>245 THEN C=K5
28035 POKE 711,C:GOTO 28020
28050 POSITION K0,K0:? #K6;CHR$(125):FOR X=K5 TO K15:XD(X)=K5:NEXT X:XD(K7)=K1:XD(K11)=K2:XD(K14)=K3:XD(K13)=K4
28060 RESTORE 28070:FOR C=K1 TO K8:READ X,Y:XC(C)=X:YC(C)=Y:NEXT C:GOTO 28080
28070 DATA 4,4,14,4,5,5,15,5,4,18,14,18,5,19,15,19
28080 COIN(K0)=K0:COIN(K1)=K0:ZT(K0)=37:ZT(K1)=39:CTEMP(K0)=K0:CTEMP(K1)=K0:X(K0)=K3:Y(K0)=21
28090 X(K1)=K16:Y(K1)=21:MAN(K0)=254:MAN(K1)=126:Z=K0:MAX=K10:POT(K0)=250:POT(K1)=122
28100 GOSUB 25000:POSITION K0,23:? #K6;" 0 coins   0 {inv}coins{/inv}"
28120 COLOR MAN(K0):PLOT X(K0),Y(K0):COLOR MAN(K1):PLOT X(K1),Y(K1):GOSUB 29000:GOTO 260
28995 REM {inv} SOUND DLI {/inv}
29000 DL=PEEK(560)+256*PEEK(561):POKE 53768,K0:POKE 53775,K3:POKE 53761,162:POKE 1600,90:RESTORE 29030
29010 POKE DL+K6,134:FOR I=K0 TO 20:READ A:POKE 1536+I,A:NEXT I:POKE 512,K0:POKE 513,K6:POKE 54286,192
29020 RETURN 
29030 DATA 72,206,64,6,173,64,6,141,0,210,201,70,208,5,169,90,141,64,6,104,64
31995 REM {inv} REDEFINE CHAR SET {/inv}
32000 RESTORE 32010:FOR I=K1 TO K32:READ A:ZZ$(I)=CHR$(A):NEXT I
32010 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,162,4,160,0
32020 DATA 177,203,145,205,136,208,249,230,204,230,206,202,208,240,96
32030 POKE 106,PEEK(106)-K5:GRAPHICS 18:START=(PEEK(106)+K1)*256:POKE 752,K1
32031 POSITION K5,K3:? #K6;"{inv}COMING{/inv}  {inv}UP{/inv}":POSITION 4,K6:? #K6;"rafferty run"
32040 A=USR(ADR(ZZ$),57344,START):RESTORE 32200
32050 READ X:IF X=-K1 THEN RESTORE:GRAPHICS 17:POKE 756,PEEK(106)+K1:RETURN 
32060 FOR Y=K0 TO K7:READ Z:POKE X+Y+START,Z:NEXT Y:GOTO 32050
32200 DATA 24,0,127,64,64,64,64,67,66
32201 DATA 32,66,66,66,66,66,66,66,66
32202 DATA 40,66,67,64,64,64,64,127,0
32203 DATA 48,0,254,2,2,2,2,194,66
32204 DATA 56,66,194,2,2,2,2,254,0
32205 DATA 64,0,255,0,0,0,0,255,0
32206 DATA 72,66,195,0,0,0,0,195,66
32207 DATA 80,66,195,0,0,0,0,255,0
32208 DATA 88,66,67,64,64,64,64,67,66
32209 DATA 96,0,255,0,0,0,0,195,66
32210 DATA 104,66,194,2,2,2,2,194,66
32211 DATA 392,108,231,255,60,60,255,231,108
32212 DATA 448,60,126,231,231,231,231,126,60
32213 DATA 464,0,255,60,126,251,253,251,126
32214 DATA 472,0,0,255,255,255,255,0,0
32215 DATA 496,0,0,110,110,126,255,102,231
32216 DATA 504,110,110,126,255,102,102,102,231
32220 DATA 128,127,99,99,99,99,99,127,0,136,56,24,24,24,62,62,62,0,144,127,3,3,127,96,96,127,0
32221 DATA 152,126,6,6,127,7,7,127,0,160,112,112,112,112,119,127,7,0,168,127,96,96,127,3,3,127,0
32222 DATA 176,124,108,96,127,99,99,127,0,184,127,3,3,31,24,24,24,0,192,62,54,54,127,119,119,127,0
32223 DATA 200,127,99,99,127,7,7,7,0
32224 DATA 264,63,51,51,127,115,115,115,0,272,126,102,102,127,103,103,127,0,280,127,103,103,96,99,99,127,0
32225 DATA 288,126,102,102,119,119,119,127,0,296,127,96,96,127,112,112,127,0,304,127,96,96,127,112,112,112,0
32226 DATA 312,127,99,96,111,103,103,127,0,320,115,115,115,127,115,115,115,0,328,127,28,28,28,28,28,127,0
32227 DATA 336,12,12,12,14,14,110,126,0,344,102,102,108,127,103,103,103,0,352,48,48,48,112,112,112,126,0
32228 DATA 360,103,127,127,119,103,103,103,0,368,103,119,127,111,103,103,103,0,376,127,99,99,103,103,103,127,0
32229 DATA 384,127,99,99,127,112,112,112,0,400,126,102,102,127,119,119,119,0
32230 DATA 408,127,96,127,3,115,115,127,0,416,127,28,28,28,28,28,28,0,424,103,103,103,103,103,103,127,0
32231 DATA 432,103,103,103,103,111,62,28,0,440,103,103,103,111,127,127,103,0,456,103,103,103,127,28,28,28,0,-1

Credits