Time Trial

Type
Game
Category
Overhead road-racing game against the clock
Author
Stan Ockers
Published in
ACE Newsletter (Atari Computer Enthusiasts, Eugene, Oregon), 1981; later on the BELLCOM public domain disks
Year
1981
Language
Atari BASIC (with machine-language DATA)
Requirements
Any 8-bit Atari with 16K+ and Atari BASIC; joystick in port 1
A winding black road between green chequered verges, with a small red car near the bottom and squashed status text at the top

About the program

Time Trial is one of Stan Ockers' early games for the ACE newsletter of Eugene, Oregon. The REM header dates it November 1981. You look down on a winding road that streams towards you from the top of the screen, and you steer a little car left and right to stay on the tarmac for five laps. Speed, lap time, average speed and a record are shown on the text lines at the top. The program later circulated on the BELLCOM public domain disks and in the Page 6 PD library.

What you need

Any Atari with Atari BASIC and 16K or more, plus a joystick in port 1. Allow a minute after RUN: "INITIALIZING" stays up while 513 road-shape values are POKEd into memory.

Typing it in

  • Lines 265–290 hold exactly 513 numbers and lines 315–343 exactly 196. Both are read by a fixed-length loop, so a missing value shifts everything after it. Count them if the road looks wrong.
  • Line 180 says GRAPHICS O and line 650 says POSITION O,2, with the letter O. That's how the listing reads, and it works because the unused variable O is 0. Type it as shown or use a zero.
  • The surviving copy seems to have lost runs of spaces inside some PRINT strings (line 358 prints a single blank where it presumably cleared the line, and the headings in line 502 are squashed together). The game still works. Pad those strings out if the status lines look cramped.
  • The listing is plain ASCII. SAVE before the first RUN, because a mistyped number in the machine code can lock the computer.

How to play

When asked for ROAD WIDTH, press 1 (narrow), 2 or 3 (wide). Press the fire button to start. Holding fire shifts up through eight speeds (shown as 20–160), and letting go shifts down again, one step every 30 passes through the main loop. Push the stick left or right to steer. Running onto the verge flashes the screen and drops you back to the lowest speed. After five laps the program shows your average speed and the record. Press and release the trigger to race again.

How it works

  • One line of road. Line 240 rebuilds the GRAPHICS 2 display list so that every row is a mode-7 line with its own LMS (load memory scan) address, all pointing into a short strip in page 6 at 1682 ($692). Line 370 draws that strip: road surface in the middle and verge characters at each side, with the width set by your 1–3 choice.
  • Curves for free. The road data (lines 265–290) is a list of small offsets. The vertical-blank routine at 1553 shifts the LMS addresses down the display list and gives the new top row an address of strip + offset. A larger offset starts the row further along the strip, so that row's road appears shifted sideways. The result is a smoothly bending road without any characters being redrawn.
  • Smooth speed. The same VBI uses the VSCROL register (54277) for fine vertical scrolling. The speed byte at 1548 is a bit pattern (S$): the more 1 bits it has, the more often the road advances.
  • Steering and laps. The VBI also reads the joystick directly from PORTA (54016) and moves player 0. BASIC checks the player-to-playfield collision register (53252) for crashes. A 255 at the end of the road data makes the VBI wrap round and add one to the lap counter at 1549.
  • Lap speeds are computed from the jiffy clock in locations 18–20.

Variations to try

  • Make your own circuit: change the offsets in lines 265–290 (keep them in the same small range as the originals), but keep the count at 513 and the final value 114. It becomes 255, the end-of-track marker.
  • Change the number of laps in line 572.

Listing

10 REM **********************
11 REM ** TIME TRIAL **
20 REM ** S. OCKERS 11/81 **
30 REM **********************
100 DIM M$(32),S$(8),P$(8),T(5):OPEN #1,4,0,"K:"
160 FOR I=1 TO 32:READ A:M$(I)=CHR$(A):NEXT I
170 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,162,4,160,0,177,203,145,205,136,208,249,230,204
175 DATA 230,206,202,208,240,96
180 POKE 106,PEEK(106)-5:GRAPHICS O:CS=(PEEK(106)+1)*256:A=USR(ADR(M$),57344,CS)
190 FOR I=CS+32 TO CS+47:READ A:POKE I,A:NEXT I
195 DATA 36,109,73,146,146,73,109,36,36,182,146,73,73,146,182,36
210 GRAPHICS 18:DL=PEEK(560)+256*PEEK(561):A=PEEK(DL+4)+256*PEEK(DL+5):A=A+22:B=INT(A/256):C=A-B*256
220 POKE DL+4,C:POKE 88,C:POKE DL+5,B:POKE 89,B:POKE DL+6,6:POKE DL+7,6
230 FOR I=17 TO 19:POKE DL+I+21,PEEK(DL+I):NEXT I
240 FOR I=DL+8 TO DL+35 STEP 3:POKE I,103:POKE I+1,146:POKE I+2,6:NEXT I:POKE DL+35,71
245 POKE 756,CS/256:POKE 708,200:POSITION 4,0:? #6;"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,4,4,3,3,2,2,1,1,2,2,3,3,3,4,4,4,5,5,5,6,6,7,7,8,8,9,9,8,8,8,8,7,7,7,6,6,6,5,5,5,5,5,5
290 DATA 5,5,5,4,3,2,1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,114
310 RESTORE 315:FOR I=1536 TO 1731:READ A:POKE I,A:NEXT I
315 DATA 104,160,17,162,6,169,7,76,92,228
317 DATA 1,1,0,0,0,0,0
319 DATA 206,11,6,208,94,173,10,6,141,11,6
320 DATA 173,12,6,206,16,6,74,176,250,173,16,6,141,5,212,16,71
322 DATA 169,16,141,16,6,173,48,2,133,203
325 DATA 56,233,3,133,205,173,49,2,133,204,133,206,160,37,177,205,145,203,136,177,205,145,203,136,136
330 DATA 192,10,208,241
332 DATA 230,207,208,2,230,208,162,0,161,207,201,255,208,15,173,14,6,133,207
333 DATA 173,15,6,133,208,161,207,238,13,6,136,145,203
335 DATA 173,0,211,72,41,8,208,2,230,209,104,41,4,208,2,198,209,165,209,141,0,208,76,98,228
340 DATA 4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4,5,4
343 DATA 104,160,98,162,228,169,7,76,92,228
345 POKE 1550,0:POKE 1551,RW/256:POKE 207,0:POKE 208,RW/256
358 POSITION 0,0:? #6;" "
360 POSITION 0,1:? #6;"ROAD WIDTH (1)NARROW TO (3) WIDE ":GET #1,A:W=A-48:IF W<1 OR W>3 THEN 360
370 FOR I=1690-W TO 1693+W:POKE I,0:NEXT I:FOR I=1710-W TO 1713+W:POKE I,222:NEXT I
410 A=PEEK(106)-7:POKE 54279,A:PM=256*A:POKE 559,46:POKE 53277,3:X=120:POKE 53248,X:POKE 209,X:POKE 53256,1
415 RESTORE 430
420 FOR I=PM+512 TO PM+640:POKE I,0:NEXT I:POKE 704,56:Y=90:FOR I=PM+512+Y TO PM+528+Y:READ A:POKE I,A:NEXT I
430 DATA 153,153,255,153,153,24,24,60,36,36,36,36,165,165,231,189,153
440 FOR I=1 TO 8:READ A:P$(I,I)=CHR$(A):NEXT I
450 DATA 106,96,85,76,63,51,40,22
490 POSITION 0,1:? #6;"PRESS FIRE BUTTON WHEN READY TO START"
492 IF STRIG(0)=1 THEN 492
495 A=USR(1536)
502 POSITION 0,1:? #6;"TOTAL LAP ":POSITION 0,2:? #6;" AVG. SPEED AVG. LAP"
505 Z=0:POKE 18,Z:POKE 19,Z:POKE 20,Z:LAP=0:T(0)=0:DIST=220000:DIS=12
510 RESTORE 520:FOR I=1 TO 8:READ A:S$(I)=CHR$(A):NEXT I:N=1:TT=30
520 DATA 0,1,3,7,15,31,63,127
525 T=STRIG(0):POKE 53278,0
531 TT=TT-1:IF TT>0 THEN 560
532 TT=30
533 IF T=1 AND N=1 THEN 560
536 IF T=0 AND N=8 THEN 560
540 IF T=1 THEN N=N-1:IF N=0 THEN N=8
550 IF T=0 THEN N=N+1:IF N=9 THEN N=1
560 POKE 1548,ASC(S$(N,N))
570 L=PEEK(1549):IF L>LAP THEN GOSUB 2010
572 IF L=5 THEN 610
575 IF PEEK(53252)=1 THEN GOSUB 1010
580 POSITION 7,0:? #6;20*N;" "
582 IF DIS=12 THEN DIS=2:GOTO 584
583 IF DIS=2 THEN DIS=12
584 SOUND 0,ASC(P$(N,N)),DIS,7+N
590 GOTO 525
610 SOUND 0,0,0,0:A=USR(1722)
620 POSITION 0,0:? #6;"AVG. = ";INT(TS);" "
630 IF TS>RA THEN RA=TS
640 POSITION 0,1:? #6;"RECORD = ";INT(RA);" "
650 POSITION O,2:? #6;"Again? Press Trigger"
655 IF STRIG(0)=0 THEN 655
660 IF STRIG(0)=1 THEN 660
670 GOTO 310
1000 REM ** COLLISION SUBROUTINE **
1010 FOR I=0 TO 3:SOUND I,50+20*I,2*I+2,12:NEXT I
1020 FOR I=N TO 1 STEP -1
1030 N=I:POKE 1548,ASC(S$(N,N)):POKE 712,N*16+8:POKE 704,N*16+10:FOR J=1 TO 10:NEXT J:NEXT I
1090 POKE 704,56:POKE 712,0:FOR I=0 TO 3:SOUND I,0,0,0:NEXT I:RETURN
2010 LAP=L:T(LAP)=PEEK(20)+256*PEEK(19)+256*256*PEEK(18):SP=DIST/(T(LAP)-T(LAP-1))
2020 POSITION 12,0:? #6;INT(SP);" ":TS=DIST*LAP/(T(LAP)-T(0)):POSITION 1,0:? #6;INT(TS);" "
2025 POSITION 18,0:? #6;LAP
2030 RETURN

Credits