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.

Play the whole game in your browser: the league's four divisions and the Super League above them, the eight tracks, practice on any of them, the eleven drivers, and a league or a Hall of Fame saved to a disc the page keeps and loaded again.

Loading the game's data…
  • Tap a key in this list to press it in the game.
  • P pauses a race and O goes on; F1 held in the pause sets the five driving keys again
  • C= (Left Ctrl) gives up a race once the car is off the track or the race is lost, and leaves a file's name unsaved
  • F1 held at the panel before a league race skips the race
  • Your name, or a file's:
  • Return or fire picks a menu's choice
  • ↑ accelerates, ↓ brakes, ← → steer, Alt (Option on a Mac) with ↑ or ↓ is the boost, and Z accelerates with it; in the menus the stick moves the choice
  • The game's own driving keys: Return accelerates with the boost, = brakes, Space brakes with the boost, S D steer

01 · Mod

Chase cam: the race from behind your car

The Chase cam button under the picture puts the camera behind your car and above it, while the game draws a race. It and Heli cam (section 02) take turns: pressing one switches the other off, and pressing it again goes back to the driver's seat. The track and both cars are drawn again each time the game draws a picture, from the game's own memory, in its colours and its fat pixels, over everything above the dashboard. The dashboard is the game's own.

The track

The track is the one the game builds for the race (BUILD_TRACK, its pieces at $0400-$0773). Each piece's points are worked out by the game's own routines (PIECE_LOAD, PIECE_POINTS, PIECE_POINT_IN_VIEW), run on a copy of the machine with the eye put at the map's corner, so that they come out in the map's units: a square is $800 each way and the road $180 wide, the flat road is at height $500 and the ground at $200. The points come in pairs, the road's two edges, and between two pairs the road is a solid block down to the ground. Its lines are the ones the game draws (POINTS_TO_LINES): the edges white and black by turns for the road just ahead and black further on, a line across at each piece's end and a white one at the start, and a line down to the ground wherever a side of the road shows.

The cars

Both cars are the shape the game draws the opponent's car (DRAW_OPPONENT, $E1B1): a box on four wheels, worked out from four corners. The game builds it on the screen from the corners' places there; Chase cam builds the same shape in the track's units. The car is 81 across and half as long again ($C34D is $1B of the road's 256 to each side). The wheels are boxes a quarter of the width across and as tall. The body is a wedge, half the width across: at the back from half a wheel's height up to twice it, and at the front from half a wheel's height to its top.

The camera

The camera is 280 units behind the car and 95 above it, looking 400 ahead. It turns after the car, closing 6 % of the gap each video frame (a third of it over a pass of seven), and moves to the car at once when the game puts it somewhere new.

The game's lens is a cylinder. A point's place across the screen is its bearing, 256 fat pixels to a quarter turn (PROJECT_X), and its place up the screen is its height over its distance along the ground, about 83 lines for a unit of height at a distance of one (PROJECT_Y). So on this page's square pixels the game draws a unit of height about a quarter as tall as a unit across is wide, and Chase cam draws heights the same. Its lens is flat and wider than the game's: it sees 76 degrees across, where the game sees 56.

What it leaves out

The crane itself, which the game never draws, and the crack across the windscreen, which is a part of the cockpit. The game itself is unchanged: its memory is only read, and with Chase cam or Heli cam on or off it runs byte for byte the same race. The drawing costs the game no time.

02 · Mod

Heli cam: the race filmed from a helicopter

The Heli cam button films the race as you drive it, from a helicopter flying with your car: behind it and to one side, high up, looking ahead along the road, so that you can steer by it.

The helicopter

The camera hangs 560 units from your car, 126 degrees round from its nose, and 210 above it. It looks at a point 250 ahead of the car, so the car sits low and to one side of the picture and the road it is driving into fills the rest. While the opponent's car is ahead of you and less than 1,600 units away, the camera films the point midway between the two cars and stands further off, by 0.8 of the gap, so that both are in the picture. The game keeps which car is ahead in bit 7 of $C36A (CAR_GAP, $F585). An opponent behind you is not followed, so the road ahead stays in sight.

When the track has hidden your car from the helicopter for six video frames, and the car would be in sight from the other side, it flies round to that side. It goes over the back of the car, higher as it passes behind, and stays on its new side for at least a second and a half. It never comes lower than 270 units above the road under it.

It follows the car with a lag, as a helicopter would. Across the ground it closes 12 % of the gap each video frame and turns with the car at the same rate; up and down it closes 30 %, so that a car falling off the track stays in the picture. Its lens is flat and sees 57 degrees across, about the game's own 56.

The track, the cars, the dust, the boost's sparks and the colours are Chase cam's, drawn by the same code, and the opponent's car is drawn behind and beside yours here too. The sound is the game's own.

03 · Fast CPU

A C64 with a much faster processor

The Fast CPU switch beside the screen races as a C64 with a much faster processor would. The race's main loop goes round once every video frame, 50 times a second, and each pass draws a new view into the game's own bitmaps, which its interrupt puts on show. On a C64 the same loop manages about seven a second.

A faster processor alone would make a faster game, since each pass moves the cars a fixed step. Fast CPU keeps the game's speed instead, and the game says what that is: its clocks add 0.14 seconds for each pass (TICK_CLOCK, $109C), seven frames' worth. So seven of Fast CPU's passes stand for one of the C64's, and each takes a seventh of every step: of the car's move and its turn, of the springs' and the engine's push, of the crane's swing, of the other car's move along the track and across it, and of each speck of dust thrown up at the road's edge. The sevenths go through the game's own code and add up to the C64's step.

The C64 falls behind its seven frames. It takes about 7.25 over most passes on Little Ramp, and 10.5 while the crane lowers the car, so everything slows with it and its clocks lose time: from the start line to the jump, they count 14.7 seconds in 15.9 seconds of real time. A faster processor would not fall behind, so Fast CPU keeps to the seven frames there. Where the C64 is quicker than seven, as the car falls off the track and there is little to draw, Fast CPU follows it: the page knows what each part of a pass costs on a C64, so before each of the C64's passes it works out the frames the C64 would take over the work of the last one, and shares that pass among as many of its own.

Little Ramp, from the line to the jump, the stick held forwardC64Fast CPU
Passes of the race a second6.650.1
Passes a second while the crane lowers the car4.850.1, seven for each of the C64's
Seconds on the race's clock for 15 seconds of real time13.815.0
The car's speed against the race's clockthe C64's ownwithin 1.5 % of the C64's

What the game does once a pass is done once for every seven: its clocks and the laps, the count of passes, the engine's note's aim (the interrupt still moves the note on each video frame, as on a C64), the countdowns, the damage's hold on a broken part, the other car's dice for a swerve or a bounce, and each sound it starts. A spring's press is measured against where its wheel was a C64's pass ago, as the game measures it.

Landings differ. On a C64 the car falls a whole pass's step into the road before a spring pushes back, so how hard a landing presses the springs depends on where in a pass the wheels reach the road. With Fast CPU they meet it within a video frame. In 16 practice races on Little Ramp from the same start, each with a short turn at a different moment, a spring's hardest press was 7 to 15 on a C64 and 9 to 12 with Fast CPU. The damage at the car's three points came to 6.8 on average with Fast CPU against 7.8 on a C64: more in 10 of the races, less in 5. So with Fast CPU the hardest landings do less damage and the softest a little more.

Some things change with the finer steps. The stick is read on every pass, so a short tap steers for as long as it is held, where a C64 holds it for the whole of a pass. The frames come at the C64's 50.12 a second: a display at 50 or 100 Hz shows each for the same time, and at 60 Hz one frame in five stays up for two refreshes. The menus, the panels before and after a race, and the restart after a wreck run at the C64's own speed. Switched off, the game is the C64's again from where it stands.

04 · Far view

The draw distance cheat

The Far view switch draws more of the track ahead, as the draw distance cheat on the C64-Wiki does: eight pieces of track a pass in place of four.

Each pass, the game draws the piece the car is on and the one after it, then as many more as the 2 in LDA #$02 at $173D says (DRAW_VIEW, $167A). The cheat pokes 6 into $173E, and the switch puts 6 in the same place; the game's own code does the rest. While the crane lowers the car the game draws five more pieces whatever the count says, so the cheat changes nothing until the car is let go.

On a C64 each extra piece costs time. A pass on Little Ramp takes about 8.8 frames in place of 7.1, so the picture changes about 5.7 times a second in place of 7, and the race's clocks, which add 0.14 seconds a pass, fall further behind real time. This page's machine pays the same cost. With Fast CPU on as well, a pass still takes one video frame and the clocks keep real time.

05 · Differences

What differs from a C64

The game plays as it does on a C64, at the C64's speed, unless Fast CPU is on (section 03). These are the places where the page cannot be the machine, and what it does instead.

On a C64On this page
The game loads from disk behind a loading picture, and its own loader jumps to the start-up at $3FFB.There is no loading. The page starts at $3FFB with the memory as the loader leaves it, and the main menu comes up after the start-up's work.
The start-up adds up the game's code and data, and on a sum that is not $9DFA it turns the border yellow and stops.The page carries the game's data and none of its code, so it cannot add up the code. It leaves the sum where the game's leaves it, takes as long as the game does, and goes on.
Each instruction takes its cycles, and the video chip takes some of the processor's on the lines where it fetches characters and sprites.The port executes no instructions. Each routine costs the cycles it costs the game, and the view costs what its lines cost: each pixel tested and drawn, each step of a line off the view. A pass of a race comes within a few per cent of the game's, so the view moves and the clocks count as they do on a C64. The video chip takes its cycles as the beam passes those lines.
The raster interrupt splits the screen into bands: the view's bitmap above and the dashboard below, the sprites placed again in each.Each band runs whole when its interrupt comes, and its writes to the video chip land where the game's land in that band on average, within a few cycles.
The SID plays the engine and the effects, written by the game as it runs.The site's model of the SID, with the filter of the C64's original 6581, plays what the port writes as each frame is shown.
A league, a Hall of Fame or a game for several is saved to a disc or a tape, and loaded from it.Both go to a disc the page keeps in this browser: what is saved there is there the next time the page is opened. The KERNAL's routines for it are written in JavaScript, as the page has no ROM.
The game reads a joystick in control port 2, and the keyboard.The arrows and Alt (Option on a Mac) are the joystick, or the pad on a touch screen, and the letters, figures, Return, Space, = and F1 are the C64's keys of the same names; Backspace is DEL and Left Ctrl is C=. In a race, Z, and the pad's fire without the stick back, are fire with the stick forward: the boost forward. A tap shorter than a pass of the game is held until the game has read it.