Track Star

Type
Game
Category
Cross-country running game
Author
John Weber
Published in
Antic, October 1983 (Vol. 2, No. 7), In the Public Domain
Year
1983
Language
Atari BASIC (with a short machine-language routine)
Requirements
16K RAM, Atari BASIC, joystick in port 1
A brown cross-country course in big blocky characters: grey rock walls, green trees, dark potholes, blue hurdles, a small runner at top left and a flag at bottom right

About the program

"Indoor athletes may think it easy to become a track star," John Weber wrote in Antic's October 1983 issue, "but I challenge them to complete three laps of this cross-country course." His runner zigzags from the upper left of the screen to the lower right and back, past rock walls, trees and potholes, with the clock ticking all the way. Each lap is harder: the runner moves faster and more potholes open up.

The game was one of the type-ins in the magazine's "In the Public Domain" section. Weber was also the author of Snowbird, published a few months later.

Typing it in

Only three lines have special characters: the inverse-video words in the title and score screens (lines 1010, 1024 and 1030). {inv}…{/inv} means press the Atari key before and after. The course itself is built from numbers. Each value in lines 3070–3080 is a screen offset where a rock goes, and line 3049 rightly warns you to type the DATA carefully. A wrong number there doesn't cause an error, just a rock in the wrong place.

How to play

Press START at the title screen, then push the joystick to begin (the timer starts when you move). The runner can move in all eight directions.

  • Touch the flag at the lower right, then the one that appears at the upper left. That's one lap. Three laps finish the race.
  • Trees and rocks block you. Falling into a pothole sends you back to the start of the lap, and a second fall disqualifies you.
  • To jump a hurdle (the six in the lower half of the course), hold the stick left or right and press the button. Each hurdle is worth 5 points once per lap, so 90 points is the maximum.
  • Cutting through the trees is cheating: two low tones mean you've lost all your points. The race also ends after five minutes.

At the end you get one of five ratings: TRACK STAR, CLOSE SECOND, STEADY PACE, LEAD FOOT or TWO LEFT FEET. For TRACK STAR you need under 110 seconds, at least 80 points and no falls.

How it works

  • The game runs in GRAPHICS 17 (big GRAPHICS 1 text, no text window). Instead of printing, it POKEs character codes straight into screen memory, which is fast and makes collision testing a simple PEEK of the square ahead.
  • A 32-byte machine-language routine in CH$ copies the ROM character set into RAM (line 2030). Lines 2040–2045 then redraw the first ten characters, among them three runner poses, a fallen runner, the hurdle, tree, rock, pothole and flag. Different character codes give the different colours.
  • Sounds are made by POKEing POKEY's first voice directly (S0=53760, S1=53761) in a short loop, rather than using SOUND.
  • Line 130 works out the new position from the joystick value with logical expressions: (LST=9 OR LST=5 OR LST=13) is 1 or 0, so each term adds or subtracts a row (20 bytes) or a column.

Changes from the published listing

One change, so the program also runs under Altirra BASIC, the free replacement BASIC built into many emulators. Altirra BASIC adds a command called DIR, so it rejected the published lines that use that word as the start of a variable name. The variable is renamed everywhere in the program. The new name is the same length, so the memory layout is unchanged and the program behaves exactly as published on genuine Atari BASIC. If you type it in from the magazine, the original names work fine on a real Atari.

Published Now Lines
DIR DRN 250, 340, 410, 420

Listing

10 REM ****************************
20 REM *       TRACK STAR         *
30 REM *            6/23          *
40 REM *      BY JOHN WEBER       *
45 REM *      ANTIC MAGAZINE      *
50 REM ****************************
60 GOSUB 2000:GOSUB 1000
70 POKE POS,WW
80 IF STICK(0)=15 THEN 80
90 POKE 20,0:POKE 19,0
100 REM ** MAIN LOOP **
105 LST=STICK(0):WW=1
110 IF LST>8 AND LST<12 THEN WW=2
115 IF LST=13 OR LST=14 THEN WW=3
120 POKE POS,WW
125 TIME=PEEK(20)+256*PEEK(19):POSITION 12,23:? #6;INT(TIME/60)
126 IF INT(TIME/60)>300 THEN POP :GOTO 1000
130 NPOS=POS+20*(LST=9 OR LST=5 OR LST=13)-20*(LST=6 OR LST=10 OR LST=14)-(LST>8 AND LST<12)+(LST>4 AND LST<8)
135 IF NPOS<SC OR NPOS>SC+459 THEN 105
138 IF PEEK(NPOS+20)=137 AND PEEK(NPOS-20)=137 THEN SOUND 0,255,10,10:SCORE=0
140 IF STRIG(0)=0 AND STICK(0)<13 THEN GOSUB 200:GOTO 120
145 IF PEEK(NPOS)=135 THEN GOSUB 700:GOTO 105
150 IF PEEK(NPOS)=10 THEN GOSUB 800:GOTO 105
155 IF PEEK(NPOS)<>0 THEN GOSUB 500:GOTO 105
160 POKE POS,0:POS=NPOS:POKE POS,WW:FOR X=1 TO FAST:NEXT X
165 POKE S1,138:FOR A=125 TO 121 STEP -2:POKE S0,A:NEXT A:POKE S1,0:POKE S0,0
175 IF STICK(0)=15 OR STICK(0)=LST THEN 125
180 GOTO 105
200 REM *** RIGHT HURDLE JUMP   ***
205 IF STICK(0)>8 AND STICK(0)<12 THEN 300:REM GO TO LEFT HURDLE
210 RJMP=19:FOR I=0 TO 2
215 IF PEEK(POS-RJMP)<>0 THEN 260
220 IF PEEK(POS-RJMP+20)=196 THEN JUMP=1:POKE (POS-RJMP+20),4+128
225 POKE POS,0:POKE POS-RJMP,WW
230 DV=170:HI=94:LO=78:TONE=-2:GOSUB 450
240 POKE POS-RJMP,0:RJMP=RJMP-1:NEXT I:POS=POS+3
245 IF PEEK(POS)<>0 THEN POS=POS-1:JUMP=0:GOTO 245
250 IF JUMP=1 THEN DRN=-3:GOSUB 400:JUMP=0
255 RETURN
260 FOR X=1 TO I:POKE POS,0:POS=POS-1
262 IF PEEK(POS)<>0 THEN POS=POS+1
265 POKE POS,5
270 DV=138:HI=125:LO=75:TONE=-2:GOSUB 450:NEXT X
275 FOR X=1 TO 300:NEXT X:RETURN
300 REM *** LEFT JUMP ***
305 LJMP=21:FOR I=0 TO 2
310 IF PEEK(POS-LJMP)<>0 THEN 360
315 IF PEEK(POS-LJMP+20)=196 THEN JUMP=1:POKE POS-LJMP+20,4+128
320 POKE POS,0:POKE POS-LJMP,WW
325 DV=170:HI=94:LO=78:TONE=-2:GOSUB 450
330 POKE POS-LJMP,0:LJMP=LJMP+1:NEXT I:POS=POS-3
335 IF PEEK(POS)<>0 THEN POS=POS+1:JUMP=0:GOTO 335
340 IF JUMP=1 THEN DRN=3:GOSUB 400:JUMP=0
345 RETURN
360 IF POS+1>SC+455 THEN POP :GOTO 385
365 FOR X=1 TO I
370 POKE POS,0:POS=POS+1:IF PEEK(POS)<>0 THEN POS=POS+1:GOTO 380
375 POKE POS,5
380 DV=138:HI=125:LO=75:TONE=-2:GOSUB 450
385 POKE POS,5:FOR X=1 TO 300:NEXT X:RETURN
400 REM **** JUMPING TOTALS ****
410 POKE POS+DRN,21
420 FOR X=1 TO 75:NEXT X:POKE POS+DRN,0:SCORE=SCORE+5
430 RETURN
450 REM *** COMMON SOUND ROUTINE **
460 POKE S1,DV:FOR A=HI TO LO STEP TONE:POKE S0,A:NEXT A
470 POKE S1,0:POKE S0,0:RETURN
500 REM *** CRASH   ***
510 POKE POS,5
515 FOR X=1 TO 2
520 DV=138:HI=125:LO=75:TONE=-2:GOSUB 450
530 IF POS+20>SC+459 THEN POP :GOTO 550
540 IF PEEK(POS+20)=0 THEN POKE POS,0:POS=POS+20:POKE POS,5
545 NEXT X
550 IF STICK(0)=15 THEN 550
560 RETURN
600 REM *** INCREASE POTHOLES ***
610 X=0:FOR I=1 TO 3
620 READ A:IF A=-1 THEN X=255:GOTO 620
625 IF A=-2 THEN RETURN
630 POKE SC+X+A,135:NEXT I:RETURN
650 DATA 54,247,66,92,144,197,82,170,-1,7,-1,94,82,126,-2,-2,-2
700 REM *** FALL IN A POTHOLE ***
710 POKE POS,0:FALL=FALL+1
720 DV=170:HI=25:LO=250:TONE=4:GOSUB 450
730 IF FALL=2 THEN POP :GOTO 1000
740 WW=1:POKE SC+40,0:POKE SC+437,10
750 POS=SC+61:POKE POS,WW
760 IF STICK(0)=15 THEN 760
770 RETURN
800 REM *** TOUCH FLAGS ***
805 IF NPOS=SC+40 THEN 850
810 POKE POS,0:POS=NPOS:POKE POS,WW
820 DV=168:HI=20:LOW=120:TONE=20:GOSUB 450
830 IF LAP=2 THEN GOSUB 600:GOSUB 600
840 BOT=1:POKE SC+40,10:RETURN
850 IF BOT=0 THEN RETURN
860 LAP=LAP+1:IF LAP=3 THEN POP :GOTO 1000
870 POKE POS,0:POS=NPOS:POKE POS,WW
875 DV=168:HI=20:LOW=120:TONE=20:GOSUB 450
880 GOSUB 600:FAST=FAST-11:POKE 77,0
885 BOT=0:POKE SC+437,10
890 FOR I=SC+303 TO SC+311 STEP 4:POKE I,196:NEXT I:FOR I=SC+425 TO SC+433 STEP 4:POKE I,196:NEXT I
895 RETURN
900 REM *** GET RATING ***
905 TIM=INT(TIME)/60:RATE=3
915 IF FALL=2 OR TIM>140 THEN RATE=5:GOTO 950
920 IF FALL=1 OR TIM>125 THEN RATE=4:GOTO 950
925 IF SCORE>54 AND TIM<130 THEN RATE=2
930 IF SCORE>79 AND FALL=0 AND TIM<110 THEN RATE=1
950 RESTORE 980:FOR I=1 TO RATE:READ R$:NEXT I:RETURN
980 DATA TRACK STAR,CLOSE SECOND,STEADY PACE,LEAD FOOT,TWO LEFT FEET
1000 REM *** TITLE PAGE ***
1005 GRAPHICS 17:POKE 756,BEGIN/256
1010 POSITION 4,3:? #6;"{inv}TRACK STAR{/inv}":IF TIME=0 THEN 1030
1015 POSITION 3,7:? #6;"TOTAL LAPS = ";LAP:POSITION 9,9:? #6;"TIME = ";INT(TIME/60)
1020 POSITION 8,11:? #6;"SCORE = ";SCORE
1022 GOSUB 900
1024 POSITION 3,13:? #6;"{inv}RATING:{/inv}":POSITION 5,16:? #6;R$
1030 POSITION 2,23:? #6;"HIT {inv}START{/inv} TO RUN"
1035 FOR X=0 TO 19:POSITION X,19:? #6;CHR$(1)
1040 FOR I=1 TO 15:IF PEEK(53279)=6 THEN POP :GOTO 1090
1043 NEXT I:SOUND 0,100,8,8:SOUND 0,0,0,0
1045 POSITION X,19:? #6;" ":NEXT X
1050 FOR X=19 TO 0 STEP -1:POSITION X,19:? #6;CHR$(2)
1055 FOR I=1 TO 15:IF PEEK(53279)=6 THEN POP :GOTO 1090
1060 NEXT I:SOUND 0,100,8,8:SOUND 0,0,0,0
1065 POSITION X,19:? #6;" ":NEXT X
1070 GOTO 1035
1090 IF POS=SC+61 THEN 1099
1095 GOSUB 2070:GOTO 70
1099 GOSUB 2070:RETURN
2000 REM *** REDEFINE CHARS AND SETUP
2005 DIM CH$(32),R$(13):RESTORE 2015
2010 FOR I=1 TO 32:READ A:CH$(I)=CHR$(A):NEXT I
2015 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,162,4,160,0
2020 DATA 177,203,145,205,136,208,249,230,204,230,206,202,208,240,96
2025 POKE 106,PEEK(106)-5:GRAPHICS 0:BEGIN=(PEEK(106)+1)*256:POKE 756,BEGIN/256
2030 A=USR(ADR(CH$),57344,BEGIN)
2040 RESTORE 2045:FOR I=BEGIN+8 TO BEGIN+87:READ A:POKE I,A:NEXT I:RETURN
2045 DATA 3,3,6,6,7,6,14,17
2047 DATA 192,192,96,96,224,96,112,136
2049 DATA 32,36,36,24,24,36,36,4
2051 DATA 1,3,5,9,16,16,16,16
2053 DATA 8,136,126,29,28,20,35,64
2055 DATA 66,255,66,255,66,255,66,255
2057 DATA 62,63,255,248,126,154,240,63
2059 DATA 60,120,254,248,254,62,31,255
2061 DATA 16,56,56,124,124,254,16,16
2063 DATA 8,24,56,120,8,8,8,8
2070 GRAPHICS 17:POKE 756,BEGIN/256:RESTORE 2075:FOR X=0 TO 4:READ A:POKE 708+X,A:NEXT X
2075 DATA 252,8,194,156,22
2080 POKE 559,0:SC=PEEK(88)+256*PEEK(89)
2085 SCORE=0:LAP=0:FAST=28:JUMP=0:WW=1:FALL=0:BOT=0:POS=SC+61:S0=53760:S1=53761
3000 REM *** DRAW SCREEN ***
3010 RESTORE 3050:X=0
3020 READ A:IF A=-1 THEN X=255
3030 IF A=-2 THEN 4000
3040 POKE SC+X+A,72:GOTO 3020
3049 REM TYPE DATA NUMBERS CAREFULLY
3050 DATA 0,1,2,3,4,5,6,17,18,19,27,28,38,39,48,49,50,59,80,81,95,96,102,103,104,105,106,114,126
3060 DATA 127,128,129,130,131,132,133,134,182,183,184,185,186,188,189,202,203,209,210,211
3070 DATA 222,231,232,233,251,254,255,-1,1,2,17,19,23,40,41,90,109,110,111,116,117,132,134,135,138,139
3080 DATA 165,184,185,186,203,204,205,206,207,222,223,224,-2
4000 FOR I=SC+9 TO SC+16:POKE I,137:NEXT I:FOR I=SC+120 TO SC+400 STEP 40:POKE I,137:NEXT I
4010 FOR I=SC+79 TO SC+439 STEP 40:POKE I,137:NEXT I:RESTORE 4040:X=0
4020 READ A:IF A=-1 THEN X=255:GOTO 4020
4025 IF A=-2 THEN 4050
4030 POKE SC+X+A,137:GOTO 4020
4040 DATA 186,188,207,214,225,-1,88,113,209,220,-2
4050 POKE SC+437,10
4060 FOR I=SC+303 TO SC+311 STEP 4:POKE I,196:NEXT I:FOR I=SC+425 TO SC+433 STEP 4:POKE I,196:NEXT I
4070 POKE SC+92,135:POKE SC+355,135:POKE SC+156,135
4080 POSITION 6,23:? #6;"TIME: "
4099 RESTORE 650:POKE 559,46:RETURN

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: TRAKSTAR.BAS.

Credits