|
| u8 | car_heading |
| u16 | car_speed |
| u8 | car_surface |
| u16 | car_x |
| | Probe oracles / game state (12.4 fixed-point pixels).
|
| u16 | car_y |
| const u8 | lanes_heading [] |
| | The heading at each point of the two lanes (64 = east).
|
| const u16 | lanes_xy [] |
| | The rivals' lanes (data.asm): 2 lanes x 256 points of (x, y).
|
| u8 | race_on |
| | Set once Kit moves: the rivals wait for him on the line.
|
| u16 | rival_pos [2] |
| | Where each rival is on its lane: point number in 8.8 (256 points a lap).
|
| static const u16 | rival_speed [2] = { 0x0050, 0x0056 } |
| | Each rival's speed along its lane, points per frame in 8.8.
|
| const u8 | track_class [] |
| | Class of each track tile, 128x128 (data.asm, res/track_class.bin): 0 road, 1 gravel, 2 water or a prop, 3 boost pad.
|
Mode 7 racing — hover-bikes on a rooftop circuit, F-Zero style.
A drivable race circuit on the Mode 7 plane. Kit's hover-bike stays fixed near the bottom of the screen and the WORLD rotates and scrolls under it — the classic SNES racing camera: per frame, mode7SetAngle(heading) + mode7SetScroll/SetCenter follow the bike's fixed-point position, through the mode7 module.
- D-pad left/right: steer — A: accelerate — B: brake
- The gravel slows the bike down; the lagoon, the quay and the rooftop props stop it; the chevron pads throw it forward.
- Two rivals leave the line when Kit does, and ride their lanes.
The circuit, its 128x128 class map (one byte per tile), the rivals' lanes and the bike sheet are written by devtools/art_assets/build.py (racing.py) from the PixelLab art of assets/neo-lumen/; the build converts the circuit with opensnes-tileset (mode = 7) and the bikes with opensnes-sprite.
ROM mode: LoROM (project default).
- SNES Concepts
- The F-Zero camera: SetCenter(bike) makes the bike the rotation pivot, SetScroll places it low on screen, SetAngle spins the world opposite to the bike's heading
- Sprites standing on a turning Mode 7 plane: a rival's world position goes through the inverse of the plane's matrix to reach the screen, and its picture turns with the camera (five frames and the flips)
- Fixed-point driving physics from the math module: velocity = fixMul(speed, fixSin/fixCos(heading)) — same 0-255 angle unit as mode7SetAngle, so heading feeds both directly
- Mode 7 VRAM interleave loaded with dmaCopyVramMode7(); OBJ tiles coexist at name base 3 (word $6000)
- What to Observe
- Boot on the start line, a rival on each side. Hold A: the checker line recedes, the rivals pull away and the track streams under the bike; steer through the chicane. A rival seen side-on turns its bike with the camera. Cutting the gravel slows you; a chevron pad gives a burst of speed; the quay is solid.
- Modules Used
- console, dma, background, sprite, math, input, mode7
- See also
- devtools/art_assets/racing.py — how the circuit and the bikes are made
-
lib/source/mode7.c — the C Mode 7 module this game exercises
Draw rival r and its shadow where its lane puts it.
Its picture turns with the camera: the direction it faces on screen is its heading minus Kit's, in 16 steps of 22.5 degrees. Five frames turn the bike from up (0) to right (4); the flips give the rest — V turns a direction d into 8 - d, H into 16 - d, both into d + 8.
Put a world point (pixels) on the screen, through the camera.
The plane shows world = car + M * (screen - pivot), M = the matrix mode7SetAngle() writes at scale 0x0080 (cos, -sin / sin, cos, halved); this is the inverse, M^-1 = 2 * (cos, sin / -sin, cos).
- Returns
- 0 if the point is too far from the bike to be on screen