Use the original handling, walls and projection from the executable

Decoded from SKIDMARKS_CD32's machine code:

- Car physics: the per-frame engine/grip/steering update, gravity and
  jumps, the hill effect on the throttle, and body tilt. Replaces the
  reconstructed handling model.
- The meaning of every .set value (separate drag, grip and power for
  human and computer drivers; steering, gravity, tow hitch), and the
  six handling presets, offered by a new Handling menu option.
- Walls: the road edges are quadratic B-splines through the gates'
  ends. They match the painted road edges.
- The real projection, which lifts points by their height; the height
  map is indexed by world cells, not screen pixels.
- Tracks have one more gate than the stored count: the last gate was
  being dropped on every track.

Computer drivers now follow the road between the walls and steer like
the original's. Vehicle assets store the values as `handling`; older
files still load. Docs describe the decoded logic.
This commit is contained in:
2026-10-20 07:32:46 +00:00
parent ee895e0455
commit 6226c88d4e
44 changed files with 1283 additions and 791 deletions
+50 -21
View File
@@ -18,8 +18,9 @@ The track picture: 1024 × 512, a 16-colour indexed (palette) image.
- **Palette:** the PNG's palette is the track's palette. Change a palette
entry to recolour every pixel that uses it.
- **Road vs scenery:** colours 8–15 are road (full grip, full speed).
Colours 0–7 are scenery (less grip, slower).
- **Road vs scenery:** colours 8–15 are road; colours 0–7 are scenery,
where cars throw up dust. The picture doesn't affect handling. The
walls come from the gates (below).
- **Painting a new route:** paint it with the upper eight colours and
update the gates to match.
- **Saving:** keep the image indexed if your editor allows it. If it saves
@@ -32,16 +33,26 @@ Plain text; lines starting with `#` are comments.
- **`gate x1 y1 x2 y2`:** lap gates in race order.
- Gate 0 is the start/finish line, and the grid forms up behind it.
- Cars must cross every gate, in order, to complete a lap. Computer
drivers steer from one gate to the next.
- Cars must cross every gate, in order, to complete a lap.
- **Walls:** the gates' ends also shape the road. One edge is a smooth
curve through every gate's first end (`x1 y1`), the other through
every second end (`x2 y2`). Those curves are the walls, and computer
drivers follow the road between them. The curves pass halfway
between neighbouring gates' ends and round off the corners, as in
the original.
- Coordinates are on the isometric ground plane. To find where a point
sits in the picture:
`picture x = wx - wy + 512`, `picture y = (wx + wy) × 31/64 − 252`.
- `skids trace --data assets --track N --out t.png` draws the gates
(gate 0 in yellow) and the computer cars' paths over the picture.
- **`height`:** 64 rows of 64 numbers giving ground height × 256. Each
number covers a 16 × 8 pixel cell of the picture. Slopes push cars
downhill and tilt the car sprites.
on the ground sits in the picture, with `z` its height in pixels
(from `height`):
`picture x = wx - wy + 512`, `picture y = (wx + wy) / 2 − 156 − z`.
- `skids trace --data assets --track N --out t.png` draws the walls
(grey), the gates (gate 0 in yellow) and the computer cars' paths over
the picture.
- **`height`:** 64 rows of 64 numbers giving ground height in pixels × 64.
- **Layout:** the rows run along world y and the numbers within a row
along world x. Each covers 16 × 16 world units.
- **Effect:** climbing slows cars and descending speeds them up. Cars
leave the ground over crests that drop away faster than gravity, and
the car sprites tilt with the slope.
- **`set`:** the name of the set of tracks this one belongs to, shown under
the menu thumbnail.
- **`start`, `flags`:** values from the original data that the game
@@ -91,17 +102,35 @@ The display name, driver and handling:
| `name` | name shown in the menu |
| `driver` | driver's name, shown next to it |
| `trailer` | `yes` for something towed behind cars (the caravan) rather than driven |
| `original`| the 16 values from the original `.set` file, kept for reference; the game doesn't use them yet |
| `top` | top speed on tarmac |
| `accel` | acceleration |
| `brake` | braking |
| `grip` | sideways grip; higher means less sliding |
| `turn` | steering rate |
| `mass` | weight in collisions |
| `offroad` | speed and grip multiplier on scenery |
| `handling`| the 16 values from the original `.set` file, used as the original game uses them (below) |
| `mass` | weight when cars collide; not from the original data |
The handling values are a reconstruction, so tune them freely. To add a
car, add a new `<id>.png` / `<id>.txt` pair.
The `handling` values, counting from 1:
| Value | Meaning |
|-------|---------|
| 1, 2, 6 | computer drivers: drag, grip, power |
| 9, 10, 11 | human drivers: drag, grip, power |
| 3 | steering: 16 = 1/64 of a turn per frame at full lock |
| 5 | gravity: 8 = 1 pixel per frame² |
| 7 | tow hitch distance behind the car: 2 = 1 world unit |
| 4, 8, 12–16 | unused |
What the driving values do:
- **Drag** (below 64): how much of the engine's speed survives each frame.
Low drag gives fast pick-up and fast slowing.
- **Power:** what the throttle adds.
- **Top speed:** `power × drag / (64 − drag) / 32` world units per frame,
at 50 frames a second.
- **Grip:** how quickly the car's movement turns to follow where it's
pointing. Low grip means long slides.
The menu's **Handling** option can replace every car's values with one of
the original's presets.
Older files with `original`, `top`, `accel`, `brake`, `grip`, `turn` and
`offroad` lines still load: `original` is read as `handling`, and the
others are ignored. To add a car, add a new `<id>.png` / `<id>.txt` pair.
## Sounds: `sounds/*.wav`