1989 · MicroStyle

Stunt Car Racer

This minisite was contributed by air. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/c64/stunt-car-racer with me to Gold.

Every computer driver has the same engine. Hot Rod sits in front of you and Road Hog swerves about the road because of a byte of habits each, read every pass, and the driver's number, which sets how often it swerves.

01 · How it moves

The other car rides the track on three springs, and cannot fall off it

Your car is thrown about by the game: it moves and turns every way, flies off the road and breaks. The computer's car is a few numbers: how far it is round the track, its place across the road, its speed, and three wheels on springs that move only up and down. The track carries it, wherever its springs put it.

Run-up

Recorded pass by pass from the Play tab's game: the first race of a season on Little Ramp, with Jumping Jack driving, the car where OPP_CORNERS ($E4DA) puts its corners. In the picture each spring is drawn shorter the further its wheel is pressed into the road, and orange while it pushes; the white dots are where the car's middle was each pass. The run-up to the jump insists on a speed of 70 (pieces 30 to 33, $0710, section 09); the other run-ups are the same race with that one limit changed. The springs are OPP_WHEELS ($21DE, section 04): each pushes its wheel up harder the further the wheel is pressed into the road and the faster it is going in, against a pull down of 40, or 124 on a bend, and each wheel takes three quarters of its own push and an eighth of each of the others'. OPP_SPREAD ($23A2) then keeps the back wheels within 296 of each other in height and the front within 368 of them. Heights are the game's: the road on the flat is at 1,280, the car 81 across.

Each back wheel reads the road under its own corner, its place across less or plus half the car's width, and the front wheel the road under the middle, half a segment ahead. So on a banked bend the car leans, and over a crest it leaves the road and flies on along the track at its speed. In the air its engine pushes nothing, so only the drag slows it. If it took the jump too slowly it would come down in the dip between the ramps, and the face of the landing ramp would hit its springs as hard as they can push, throwing it into the sky. That is why the run-ups insist on a speed.

Your carThe computer's car
Where it isA place on the map in three dimensions and a heading ($0100-$0108, $0122/$0125)A piece and a place along it ($C375, $C4/$23), and a place across the road ($B0)
Which way it pointsWherever it turnsAlong the road; a swerve turns it up to 16° (section 03)
SteeringLeft and right turn it while a spring is pressed (CONTROLS, $1C64)10 across a pass towards its aim while a wheel is on the road, never past $20 or $E0 (section 02)
Its wheelsThree points on springs, two at the front and one at the back in the middle (WHEEL_OFFSETS, $0897)Three wheels on springs, two at the back and one at the front in the middle ($238A)
SpeedIts engine, and the boost doubles the push (BOOST, $F60F)One push for every driver less a drag, plus the slope's pull, held to each piece's limit; no push in the air (sections 07 and 09)
Off the roadOff the track it is wrecked (DRAW_VIEW sets $6B)It cannot leave the road
Bumps and damagePushed across, up and along, and a spring pressed past the damage line adds damage (section 06)Loses speed along and its wheels are pushed up, never across; nothing counts damage for it

02 · Racing lines

Where you are decides whether the other car blocks you or gets out of your way

The computer's car steers towards a point across the road, its aim, by 10 a pass. Far from you the aim is the driver's own line. Close to you, the driver's habits choose it from where you are. Pick a driver, then drag either car.

      The road as the game draws it, seen from high behind your car, with the race going up the page; the numbers beside it are car lengths ahead of you and behind. Each colour is what the computer's car does with its middle there, worked out by the game's own OPPONENT_LINE ($1D25) ported to JavaScript, on the game's memory from the listing. The computer's car never steers past $20 or $E0 across, so it is never in the grey strips at the edges. The pale car is where it heads, its aim; the hatched patch round your car is where the cars touch (section 06). Drag either car, or click the road to put the computer's car there; arrow keys move it once the map has the focus.

      The gap between the cars is counted along the track, a car length to about 15 of its units. Within a gap of 255 either way, the driver's habits decide:

      The computer's carGapWhat it does
      behind you$18 or more, 1.6 car lengthspulls out to pass (LINE_PASS, $1E3C): it heads for the edge on its own side of you, or for the far edge when you are near that one (under $60 or from $A0 across)
      behind you, closeunder $18goes round you (LINE_ROUND, $1E30): it heads for the edge on its own side of you
      right in front of you$0E to $17, 0.9 to 1.5 car lengthsgoes round you, or keeps its own line with bit 3 of its habits
      in front, closer stillunder $0Egoes round
      ahead of you$18 to $31, 1.6 to 3.2 car lengthsblocks you with bit 1 (LINE_HOLD, $1E5A): it heads for your line; without it, it moves out of your way as when passing
      further ahead$32 to $C7, 3.3 to 13 car lengthsmoves out of your way with bit 5; without it, drives its own line
      far ahead$C8 or moredrives its own line

      Passing and going round only change the aim while the cars are less than $38 apart across. Further apart, you are not in its way and it holds its course. A bend on the piece it is on or the next sends it to the middle of the road, $80, except while it is passing you from behind or going round you, which go on through the bend.

      03 · Swerves

      Secret: coming out of a bend ahead of you, the other car may swerve

      On the first pass after a bend, if it is in front of you, the computer's car rolls a number from 0 to 31. If the number is no higher than the driver's own, it swerves for 16 passes, weaving across the road with its nose turned. Hot Rod swerves 1 time in 32, Road Hog 11 times in 32.

       

      • the wave's value turning the car this pass
      • the value five places on, which steers it

      The car drives a straight at a speed of 60, one picture a pass, drawn with the Play tab's Chase cam renderer, its corners placed as OPP_CORNERS places them. Each pass the game's SWERVE ($158E, ported) reads the 16 values of the wave at $1601 one place on. The value moves one end of the line the car's corners are set out on along the track, the left end ($C30D) for a value over 0 and the right ($C30E) for one under, which turns the car by up to 16 degrees; the value five places on steers it 10 across a pass, left or right by its sign ($C357). While it swerves its engine pushes 25 less, $D3 for $EC. Roll is the game's dice, Swerve now starts one without them. After the swerve it steers back to its own line.

      A swerve can start only when several things line up: the computer's car is ahead of you, one of its wheels is on the road, it has just left a bend (bit 7 of the piece's flags at $B2 on the pass before, and not on this one), and the piece it is on does not insist on a speed of its own (section 09). Which half of the wave comes first is set by the bend it has left: bit 6 of the same flags, turned round when the piece is driven backwards, picks the half it starts on ($C358).

      So the drivers further down the list swerve more often, and a swerve only ever happens in front of you, where the game draws the other car.

      04 · Springs

      The other car is dropped onto the track from a random height

      The computer's car has three wheels, two at the back and one at the front, each on a spring over the road. At the start of a race it is dropped: each wheel starts at the road's height plus 104 to 231, the same for all three, at random.

      One picture a pass, at a third of the game's speed. Fast CPU draws seven a pass at the game's own speed, a picture every video frame, as the Play tab's Fast CPU does (its section 03): each pass is shared among seven of its own, each taking a seventh of every wheel's change of speed and of its move, and reading a spring's depth from a whole pass before, so the springs answer a little sooner. OPP_DROP ($1EE2) sets the heights. Each pass OPP_WHEELS ($21DE) works out how deep each wheel is, from 40 over the road down, and pushes it up by twice that depth less the depth a pass before, at most $3FF, less 40, which is what pulls a wheel down while it is off the road. Each wheel takes an eighth of the three pushes' sum and five eighths of its own, and OPP_SPREAD then keeps the three together, so the car lands as one. Heights are in the game's units, a quarter of a unit across: the car is 81 across.

      05 · Bounces

      Secret: three drivers make the front of their car hop

      Big Ed, Max Boost and High Flyer have bit 2 in their habits. Whenever the front wheel of their car stops moving up and down, its speed up and the change in it both 0 to 3, one pass in 16 at random the game kicks it upwards. That happens in the race too, at speed, wherever the road under the wheel stays level long enough for the wheel to settle.

      The kick is an upward speed of 160 for the front wheel ($07DE, OPP_WHEELS), which lifts it about 260 in the game's units of height before the spring brings it down. The front wheel is wheel 2: the game draws its two front corners from it (the table at $238A). Here the car stands on a flat road, so its front wheel is still nearly every pass and it hops often. Racing, the road moves the wheel more: in the first race of a season on Little Ramp, run on the Play tab's machine with Big Ed driving, the front wheel was still enough on 41 of the race's 377 passes and it hopped 5 times, at speeds of 43 to 72 (port/scripts/bounce-race.js). For the other eight drivers the car settles and stays still.

      06 · Bumps

      When the cars touch, only your car is damaged

      Once the cars are less than $10 apart along the road and $32 across, with your car over the road and not off its side, OPP_BUMP ($209C) pushes your car and adds the pushes to its damage. The computer's car loses nothing but some speed.

      Your car is the near one. The arrows are the pushes on it: across ($017F/$0182), along ($0181/$0184) and up ($0180/$0183), drawn 6 units long for each 256 of push. Each pass the cars touch, the page runs the game's OPPONENT_LINE, OPP_BUMP and OPP_PUSH ($2176), ported, with these settings. Your height is that of your car over the computer's back wheel ($46/$64 against $07CC/$07D0), and counts only while one of the cars is in the air.

      The push across is 8 away from the other car, once the cars are less than $2D apart across and 8 along. The push along is half the difference of the speeds, with 3 more the same way: a faster computer car shoves you forward, a slower one holds you back. It comes once a meeting, and OPP_PUSH takes it off the computer's speed, so the slower car speeds up as the faster one slows. Each pass the cars touch, the three pushes' sizes in 256s, plus 2, are added to the damage of each of your car's three points, which widens the crack in the windscreen (How it works).

      In the air the heights count. More than 151 over the other car's wheels, or 231 under, your car is out of its reach and passes over or under with no push at all. Come back into reach after that, landing on it, and for three passes it pushes you up as well: hardest when you meet it 40 under its back wheel, and less the higher you come in. Lower than that the push is down instead, weaker the further under you are. The computer's wheels take a sixteenth of the push the other way.

      07 · The engine

      Every driver has the same engine

      The computer's car's speed is the engine's push, less a drag that grows with the square of the speed, plus the pull of the slope while a wheel is on the road. The push is the race's, the same for every driver: $EC in the league and $13A in the Super League.

      Each line is the speed after each pass from a standstill on a straight, the game's OPP_ENGINE, OPP_GRIP ($2037) and OPP_SPEED ($1F48) run as OPPONENT_MOVE ($1E85) runs them. The dashed line is the league's engine on the flat with no limit. The speed is the high byte of $D6/$D7, and a car moves about four units along the track a pass for each one of it. Slope is the height of the road under the back wheels less that under the front wheel; on the tracks it is mostly 0, and 25 to 75 either way on a ramp.

      Over a piece's limit the engine brakes: its push is turned round, and doubled when the car is 14 or more over. Under the limit it pushes twice as hard, until the car is within 2 of a limit it has reached, where the push goes back to normal. So the car holds a limit just under it.

      08 · The tow

      Secret: the computer's car gets a tow from anywhere behind you

      Within a gap of $40 behind you, wherever it is across the road, the computer's car works out its drag from its speed less 20, so it goes faster. You get the same cut in your own drag only from behind it and lined up with it, less than $32 apart across.

      • the computer's car gets a tow
      • you get a tow
      • neither

      The map is the one in section 02, coloured by the flag OPPONENT_LINE sets each pass, $C308. With the computer's car behind you ($C36A bit 7) OPP_SPEED takes 20 off the speed it works the drag out from; with it ahead, your car's DRAG ($0DE8) takes 20 off the figure it works yours out from. The chart is the computer's speed from a standstill on the flat, with the tow all the way and without.

      09 · Speed limits

      The computer's car speeds up for the jumps, past its own top speed

      Every piece of track has a speed limit for the computer's car, and before each race the car draws a top speed of its own from the track's range. The top speed holds the limits down, except where the piece insists on its own: the run-ups to the jumps, which set the speed the car takes each jump at, whatever its top speed.

      • the limit the car is held to, under its top speed
      • a piece that insists on its own limit, whatever the top speed
      • the piece's own limit, where the top speed is lower

      Each bar is a piece, as wide as it is long, from the start line round. OPP_PICK ($1F06) draws the race's top speed ($2099) and the bends' speed ($209A): a base for the track plus a random number masked, from the second half of each table in the Super League ($BFB2 and $BFAA, $BFC2 and $BFBA). PIECE_TABLE ($8F11) then builds each piece's limit at $0710: a bend's is the bends' speed, a piece before one 10 more for each piece back, and the track's description gives some pieces a limit of their own, with bit 7 set for one that insists, which spreads 3 pieces back. A race draws the speed of the computer's car pass by pass over the first race of a season on Little Ramp, recorded from the Play tab's game, with the limits of its draw.

      In the league the bends' speed is fixed at the top of the top speed's range, so a bend never slows the computer's car. It brakes only where the track's description gives a piece a lower limit of its own, a few pieces on most tracks and none on Hump Back or High Jump. In the Super League the bends' speed is drawn too, mostly below the top speed, and it brakes for the bends.

      TrackTop speed, the leagueTop speed, the Super League
      Little Ramp65 to 72102 to 109
      Hump Back62 to 6987 to 90
      Stepping Stones58 to 6587 to 90
      Big Ramp65 to 7289 to 92
      High Jump72 to 7998 to 105
      Roller Coaster79 to 86100 to 103
      Ski Jump72 to 7989 to 92
      Draw Bridge81 to 88105 to 108

      10 · The drivers

      The drivers differ only in a byte of habits and how often they swerve

      There are eleven computer drivers, numbered from 0 for Hot Rod to 10 for Road Hog. Each one's habits are a byte at $AEE0 plus its number, and the number itself sets how often it swerves. Pick a row to see that driver's car take its own line on a straight.

      DriverHabitsIts own lineClose aheadFurther aheadRight in frontSwervesBounces
      Hot Rod$22$40blocks youmoves asidegoes round1 in 32-
      Whizz Kid$20$BFmoves asidemoves asidegoes round2 in 32-
      Bad Guy$62$40blocks youmoves asidegoes round3 in 32-
      The Dodger$20$BFmoves asidemoves asidegoes round4 in 32-
      Big Ed$3E$6Eblocks youmoves asidekeeps its line5 in 32yes
      Max Boost$04$BFmoves aside-goes round6 in 32yes
      Dare Devil$30$40moves asidemoves asidegoes round7 in 32-
      High Flyer$14$BFmoves aside-goes round8 in 32yes
      Bully Boy$4A$6Eblocks you-keeps its line9 in 32-
      Jumping Jack$10$BFmoves aside-goes round10 in 32-
      Road Hog$08$6Emoves aside-keeps its line11 in 32-

      Its own line is the line it drives far from you, $40 across, or $6E with bit 3 of its habits, mirrored across the road for the odd numbers; the grey strip is $20 to $E0, where it keeps its car. Close ahead is a gap of $18 to $31 with the computer's car in front, where it blocks you with bit 1 or moves aside, out of your way; further ahead is $32 to $C7, where it moves aside with bit 5; and right in front is $0E to $17, where it keeps its line with bit 3 or goes round you. Swerves is the chance of a swerve each time one may start (section 03), and bounces bit 2 (section 05).

      The car is steered by the game's own OPPONENT_LINE ($1D25) ported to JavaScript, on the game's memory from the listing, as it is when you are more than 255 behind it or ahead: towards its own line, 10 across a pass. The lines of all eleven drivers are drawn faint; there are three, since no odd-numbered driver has bit 3. The darker strips at the edges are beyond $20 and $E0, where the computer's car never goes. Click the picture to stop the road moving.