Kit's Rooftop Run — a side-scrolling platformer, title to game over. More...
#include <snes.h>#include <snes/vramqueue.h>#include <snes/anim.h>#include <snes/text.h>#include <snes/snesmod.h>#include "soundbank.h"#include "res/tiles.inc"#include "res/skyline.inc"#include "res/kit.inc"#include "res/enemies.inc"#include "res/shard.inc"#include "res/level_objects.h"Macros | |
| #define | DOWN_FRAMES 60 |
| Frames the world waits after a life lost. | |
| #define | EN_ALIVE 0 |
| A machine patrols; stomped, it lies flat for a while; then it is gone. | |
| #define | EN_FLAT 1 |
| See EN_ALIVE. | |
| #define | EN_GONE 2 |
| See EN_ALIVE. | |
| #define | ENEMY_DRONE 1 |
| A drone flies over the roofs. | |
| #define | ENEMY_INSECT 0 |
| Machine types of enemy_def[][0]. | |
| #define | FRAME_DRONE 4 |
| First frame of the drone's hover. | |
| #define | FRAME_FALL 25 |
| Jump pose while coming down. | |
| #define | FRAME_IDLE 0 |
| Kit's sheet (res/kit.png, four 32x32 frames a row): idle 0-3, walk 4-11, run 12-19, jump 20-27 (crouch, rise, top, fall, land). | |
| #define | FRAME_INSECT 0 |
| The machines' sheet (res/enemies.png): the insect's walk 0-3, the drone's hover 4-7, the insect stomped 8, the drone stomped 9. | |
| #define | FRAME_RISE 23 |
| Jump pose while going up. | |
| #define | FRAME_SQUASH 8 |
| The stomped insect, then the stomped drone. | |
| #define | FRAME_WALK 4 |
| First frame of the walk cycle. | |
| #define | GRAVITY 48 |
| Gravity acceleration in 8.8 fixed-point units per frame. | |
| #define | GS_CLEAR 4 |
| The beacon reached. | |
| #define | GS_DOWN 2 |
| A life lost: Kit blinks, the world waits. | |
| #define | GS_OVER 3 |
| No life left. | |
| #define | GS_PLAY 1 |
| Running. | |
| #define | GS_TITLE 0 |
| The game's states. | |
| #define | HIDE_Y_32 224 |
| Where a 32x32 dynamic sprite is drawn to be unseen: below the 224 visible lines. OBJ_HIDE_Y (240) is for 8 and 16-px sprites: a 32-px one there wraps past line 255 and shows its bottom 16 rows at the top. | |
| #define | KIT_ACCEL 0x0038 |
| Horizontal acceleration per frame in 8.8 fixed-point (0.22 pixels/frame). | |
| #define | KIT_ACT_FALL 3 |
| Kit is falling (downward velocity or walked off an edge). | |
| #define | KIT_ACT_JUMP 2 |
| Kit is jumping (upward velocity, ascending phase). | |
| #define | KIT_ACT_STAND 0 |
| Kit is standing on solid ground, idle. | |
| #define | KIT_ACT_WALK 1 |
| Kit is walking (horizontal velocity nonzero, on ground). | |
| #define | KIT_BOUNCE 0x0300 |
| The bounce off a stomped machine. | |
| #define | KIT_DRAW_DX (-8) |
| Where the 32x32 sprite is drawn relative to the 16x16 collision box: Kit's feet are on row 30 of his frame, the box's bottom is row 16. | |
| #define | KIT_DRAW_DY (-14) |
| Vertical offset of the frame from the box (see KIT_DRAW_DX). | |
| #define | KIT_HIJUMPING 0x0594 |
| High jump initial upward velocity (when holding UP during jump). | |
| #define | KIT_JUMPING 0x0394 |
| Normal jump initial upward velocity in 8.8 fixed-point. | |
| #define | KIT_MAXACCEL 0x0140 |
| Maximum horizontal velocity in 8.8 fixed-point (1.25 pixels/frame). | |
| #define | OAM_SHARD 32 |
| The first OAM entry of the shards: the dynamic sprites take 0-6. | |
| #define | SAFE_FRAMES 90 |
| Frames Kit cannot be hurt after coming back. | |
| #define | SHARD_TILE 0xC0 |
| OBJ tile number of the shard's first frame. | |
| #define | START_LIVES 3 |
| Lives at the start. | |
| #define | T_EMPTY 0x0000 |
| Tile property: passable (air, background decoration). | |
| #define | T_SOLID 0xFF00 |
| Tile property: solid (ground, walls, platforms). | |
| #define | VRAM_BG2_MAP 0x7000 |
| VRAM word address for BG2 tilemap (SC_64x32). | |
| #define | VRAM_BG2_TILES 0x1000 |
| VRAM word address for BG2 (the skyline) tiles, at most 256. | |
| #define | VRAM_BG3_MAP 0x7800 |
| VRAM word address for the BG3 tilemap, the HUD (SC_32x32). | |
| #define | VRAM_BG3_TILES 0x6000 |
| VRAM word address for the BG3 font (2bpp, 96 glyphs). | |
| #define | VRAM_BG_MAP 0x6800 |
| VRAM word address for BG1 tilemap (SC_64x32). | |
| #define | VRAM_BG_TILES 0x2000 |
| VRAM word address for BG1 tile character data (831 tiles, to $53F0). | |
| #define | VRAM_SHARD 0x0C00 |
| The shard's frames: tile $C0 of the first OBJ table, where the engine's slots 12-15 would go (it never uses more than seven). | |
| #define | VRAM_SPR_LARGE 0x0000 |
| VRAM word address for large (32x32) sprite tiles. | |
| #define | VRAM_SPR_SMALL 0x1000 |
| VRAM word address for small sprite tiles: the engine's fixed second pool; this game draws no small dynamic sprite, so BG2 uses the room. | |
Functions | |
| static s16 | asr8 (s16 val) |
| Arithmetic right shift by 8 bits (extract integer part of 8.8 fixed-point). | |
| static void | banner (const char *line1, u8 x1, const char *line2, u8 x2) |
| Two centred lines over the level (title, game over, cleared), the HUD kept. | |
| static u8 | boxes_touch (s16 ax, s16 ay, s16 bx, s16 by, s16 inset) |
| Do two 16x16 boxes, shrunk by inset on each side, overlap? | |
| static void | come_back (void) |
| After a life lost: Kit at the last checkpoint he passed, safe for a while. | |
| static void | enemies_reset (void) |
| Put the machines back where the level places them, alive. | |
| static void | enemies_update (u8 move, u8 meet) |
| Move the machines (when move), meet Kit (when meet), and draw them. | |
| static void | hud_draw (void) |
| The top line: score, shards, lives. The score is kept in tens. | |
| static void | kit_animate (void) |
| Update Kit's sprite animation frame based on current action. | |
| static void | kit_apply_physics (void) |
| Apply gravity and integrate velocity into position. | |
| static u8 | kit_clamp_and_transition (void) |
| Clamp Kit to the world and handle action state transitions. | |
| static void | kit_collide_horizontal (void) |
| Check horizontal tile collisions (wall sliding). | |
| static void | kit_collide_vertical (void) |
| Check vertical tile collisions (ground landing and ceiling bonk). | |
| static void | kit_handle_input (void) |
| Process D-pad and button input for Kit's movement. | |
| static void | kit_place (s16 x, s16 y) |
| Put Kit at a point, at rest, and the camera on him. | |
| static void | kit_update_camera (void) |
| Update camera to follow Kit and position the sprite on screen. | |
| static void | lose_life (void) |
| Kit loses a life: the world waits, then he comes back or the game is over. | |
| int | main (void) |
| Main entry point – initialization and the game loop. | |
| static u16 | map_get_tile_prop (s16 px, s16 py) |
| Look up the collision property of the tile at pixel coordinates. | |
| static void | map_load (void) |
| Load the map from ROM and populate the initial VRAM tilemap. | |
| static void | map_prepare_column (u16 map_col, u16 vram_col) |
| Buffer a map column for deferred VRAM write (prepare phase). | |
| static void | map_redraw (void) |
| Write the columns the camera shows, in forced blank, after a jump of the camera. | |
| static void | map_update (void) |
| Check if the camera has scrolled to a new tile column and prepare it. | |
| static void | play_frame (void) |
| One frame of the run: Kit, the checkpoints, the goal. | |
| static void | put_num (u8 x, u8 y, u16 value, u8 digits) |
| Print value with digits digits, zeros in front, at (x, y). | |
| static void | run_reset (void) |
| A new run: score, lives, shards, machines, Kit on the first roof. | |
| static void | shards_update (u8 take) |
| Draw the shards on screen, and take the ones Kit touches. | |
| static void | to_title (void) |
| Back to the title screen: a new run under the title's two lines. | |
| static void | write_vram_column (u16 map_col, u16 vram_col) |
| Write a full tile column to VRAM via direct register writes. | |
Variables | |
| static const s8 | bob [16] = { 0, 1, 2, 3, 4, 3, 2, 1, 0, -1, -2, -3, -4, -3, -2, -1 } |
| The drone's bob, 16 steps of a slow wave, in pixels. | |
| static s16 | cam_max_x |
| static s16 | camera_x |
| static AnimClip | clip_fall = { clip_fall_frames, 0, 1, 1, 0 , 0 } |
| static u16 | clip_fall_frames [] = { 25 } |
| static AnimClip | clip_jump = { clip_jump_frames, 0, 1, 1, 0 , 0 } |
| static u16 | clip_jump_frames [] = { 23 } |
| static AnimClip | clip_stand = { clip_stand_frames, 0, 4, 12, 0 , 0 } |
| static u16 | clip_stand_frames [] = { 0 , 0 + 1, 0 + 2, 0 + 3 } |
| static AnimClip | clip_walk = { clip_walk_frames, 0, 8, 5, 0 , 0 } |
| static u16 | clip_walk_frames [] |
| static u16 | col_buffer [32] |
| Column tile buffer for deferred VRAM streaming. | |
| static u8 | cp_index |
| The last checkpoint Kit stood beyond (index into checkpoint_pos). | |
| static s8 | en_dir [ENEMY_COUNT] |
| static u8 | en_frame [ENEMY_COUNT] |
| static u8 | en_state [ENEMY_COUNT] |
| static u8 | en_timer [ENEMY_COUNT] |
| static s16 | en_x [ENEMY_COUNT] |
| Each machine: position (its 16x16 box), direction, state, timer, frame. | |
| static s16 | en_y [ENEMY_COUNT] |
| u8 | game_state |
| Probe oracles: the state (GS_*), the score in tens, the lives, the shards taken. | |
| static u8 | kit_action |
| static AnimPlayer | kit_anim = {0, 0, 0, 0, 0} |
| static u8 | kit_safe |
| static s16 | kit_x |
| static u8 | kit_xfrac |
| static s16 | kit_xvel |
| static s16 | kit_y |
| static u8 | kit_yfrac |
| static s16 | kit_yvel |
| static s16 | last_tile_x |
| u8 | lives |
| static const u16 * | map_data |
| static u16 | map_height |
| static s16 | map_max_x |
| static const u16 * | map_row_ptrs [32] |
| Precomputed row pointers into map_data for fast tile lookup. | |
| static u16 | map_width |
| const u8 | maplevel [] |
| The level's tiles, the skyline of BG2 and Kit's frames (32x32, 4bpp, for the dynamic sprite engine). | |
| u16 | score |
| static u8 | screen_off |
| Set when the screen was turned off for a camera jump: the loop turns it on after the next VBlank, once the NMI has sent the sprites' tiles. | |
| static u8 | sfx_clear |
| static u8 | sfx_hurt |
| static u8 | sfx_jump |
| SPC700 sound effect slots. | |
| static u8 | sfx_shard |
| static u8 | sfx_stomp |
| static u8 | shard_taken [SHARD_COUNT] |
| 1 for each shard picked up this run | |
| u8 | shards_got |
| static u16 | state_timer |
| Frames since the state began (blink, waits). | |
| static const u16 * | tile_props |
| const u8 | tilesetatt [] |
| Tile attribute table (T_SOLID/T_EMPTY per tile index, b16 format). | |
Kit's Rooftop Run — a side-scrolling platformer, title to game over.
A complete platformer on the rooftops of the city at night: Kit, the fox-kit courier, runs from roof to roof to the radio beacon at the end of the level, picking up data shards and stomping the security machines on the way. Three lives; a fall between two roofs or a machine touched from the side costs one, and Kit comes back at the start of the last roof he reached. The game goes title → play → roof cleared or game over → title.
It shows the core techniques of a scrolling SNES game: tile-based map streaming, subpixel physics, tile collision, camera tracking, animated sprites, a parallax layer, a text HUD in front of everything, and SPC700 music and sound effects through SNESMOD.
The map engine streams one tile column per frame using a prepare/flush pattern: during active display, the next column is read from ROM into a RAM buffer (map_prepare_column) and noted in the VRAM queue; during VBlank, vramQueueFlush() sends it with one 64-byte DMA. This keeps VRAM writes within the VBlank budget. The column at +32 tiles ahead is streamed to cover the 33rd partial tile at the screen edge.
Kit and the machines are dynamic sprites: the engine gives each one drawn a 32x32 slot of VRAM in the order they are drawn, so all of them are drawn every frame, in the same order (a machine off screen or stomped is drawn hidden), and each one keeps its slot. The shards are plain 16x16 sprites whose eight frames sit once in VRAM, in the tiles the engine's last slots would use (it uses seven).
This began as the PVSnesLib likemario example; the level, the roofs, the skyline, Kit, the machines and the shards are ours (devtools/art_assets/build.py writes the level and its objects from the pictures in assets/neo-lumen/).
| #define DOWN_FRAMES 60 |
Frames the world waits after a life lost.
| #define EN_ALIVE 0 |
A machine patrols; stomped, it lies flat for a while; then it is gone.
| #define EN_FLAT 1 |
See EN_ALIVE.
| #define EN_GONE 2 |
See EN_ALIVE.
| #define ENEMY_DRONE 1 |
A drone flies over the roofs.
| #define ENEMY_INSECT 0 |
Machine types of enemy_def[][0].
| #define FRAME_DRONE 4 |
First frame of the drone's hover.
| #define FRAME_FALL 25 |
Jump pose while coming down.
| #define FRAME_IDLE 0 |
Kit's sheet (res/kit.png, four 32x32 frames a row): idle 0-3, walk 4-11, run 12-19, jump 20-27 (crouch, rise, top, fall, land).
| #define FRAME_INSECT 0 |
The machines' sheet (res/enemies.png): the insect's walk 0-3, the drone's hover 4-7, the insect stomped 8, the drone stomped 9.
| #define FRAME_RISE 23 |
Jump pose while going up.
| #define FRAME_SQUASH 8 |
The stomped insect, then the stomped drone.
| #define FRAME_WALK 4 |
First frame of the walk cycle.
| #define GRAVITY 48 |
Gravity acceleration in 8.8 fixed-point units per frame.
Applied to kit_yvel every frame when airborne (jumping or falling). 48/256 = 0.1875 pixels/frame^2 – gives a natural parabolic arc.
| #define GS_CLEAR 4 |
The beacon reached.
| #define GS_DOWN 2 |
A life lost: Kit blinks, the world waits.
| #define GS_OVER 3 |
No life left.
| #define GS_PLAY 1 |
Running.
| #define GS_TITLE 0 |
The game's states.
| #define HIDE_Y_32 224 |
Where a 32x32 dynamic sprite is drawn to be unseen: below the 224 visible lines. OBJ_HIDE_Y (240) is for 8 and 16-px sprites: a 32-px one there wraps past line 255 and shows its bottom 16 rows at the top.
| #define KIT_ACCEL 0x0038 |
Horizontal acceleration per frame in 8.8 fixed-point (0.22 pixels/frame).
| #define KIT_ACT_FALL 3 |
Kit is falling (downward velocity or walked off an edge).
| #define KIT_ACT_JUMP 2 |
Kit is jumping (upward velocity, ascending phase).
| #define KIT_ACT_STAND 0 |
Kit is standing on solid ground, idle.
| #define KIT_ACT_WALK 1 |
Kit is walking (horizontal velocity nonzero, on ground).
| #define KIT_BOUNCE 0x0300 |
The bounce off a stomped machine.
| #define KIT_DRAW_DX (-8) |
Where the 32x32 sprite is drawn relative to the 16x16 collision box: Kit's feet are on row 30 of his frame, the box's bottom is row 16.
| #define KIT_DRAW_DY (-14) |
Vertical offset of the frame from the box (see KIT_DRAW_DX).
| #define KIT_HIJUMPING 0x0594 |
High jump initial upward velocity (when holding UP during jump).
| #define KIT_JUMPING 0x0394 |
Normal jump initial upward velocity in 8.8 fixed-point.
| #define KIT_MAXACCEL 0x0140 |
Maximum horizontal velocity in 8.8 fixed-point (1.25 pixels/frame).
| #define OAM_SHARD 32 |
The first OAM entry of the shards: the dynamic sprites take 0-6.
| #define SAFE_FRAMES 90 |
Frames Kit cannot be hurt after coming back.
| #define SHARD_TILE 0xC0 |
OBJ tile number of the shard's first frame.
| #define START_LIVES 3 |
Lives at the start.
| #define T_EMPTY 0x0000 |
Tile property: passable (air, background decoration).
| #define T_SOLID 0xFF00 |
Tile property: solid (ground, walls, platforms).
| #define VRAM_BG2_MAP 0x7000 |
VRAM word address for BG2 tilemap (SC_64x32).
| #define VRAM_BG2_TILES 0x1000 |
VRAM word address for BG2 (the skyline) tiles, at most 256.
| #define VRAM_BG3_MAP 0x7800 |
VRAM word address for the BG3 tilemap, the HUD (SC_32x32).
| #define VRAM_BG3_TILES 0x6000 |
VRAM word address for the BG3 font (2bpp, 96 glyphs).
| #define VRAM_BG_MAP 0x6800 |
VRAM word address for BG1 tilemap (SC_64x32).
| #define VRAM_BG_TILES 0x2000 |
VRAM word address for BG1 tile character data (831 tiles, to $53F0).
| #define VRAM_SHARD 0x0C00 |
The shard's frames: tile $C0 of the first OBJ table, where the engine's slots 12-15 would go (it never uses more than seven).
| #define VRAM_SPR_LARGE 0x0000 |
VRAM word address for large (32x32) sprite tiles.
| #define VRAM_SPR_SMALL 0x1000 |
VRAM word address for small sprite tiles: the engine's fixed second pool; this game draws no small dynamic sprite, so BG2 uses the room.
Arithmetic right shift by 8 bits (extract integer part of 8.8 fixed-point).
cc65816's >> on a signed value IS arithmetic (compiler check test_signed_ops.c), so val >> 8 would do; this helper spells the sign handling out:
| val | 8.8 fixed-point signed value |
Two centred lines over the level (title, game over, cleared), the HUD kept.
Do two 16x16 boxes, shrunk by inset on each side, overlap?
|
static |
After a life lost: Kit at the last checkpoint he passed, safe for a while.
|
static |
Put the machines back where the level places them, alive.
Move the machines (when move), meet Kit (when meet), and draw them.
A machine patrols between its two bounds at half a pixel a frame; a drone also bobs. Kit falling onto one from above flattens it and bounces; any other touch hurts him. Every machine is drawn every frame, hidden when gone or off screen, so each keeps its slot of the dynamic engine; its frame is changed (and uploaded) only while it is seen.
|
static |
The top line: score, shards, lives. The score is kept in tens.
|
static |
Update Kit's sprite animation frame based on current action.
Pure state->clip mapping: select the clip for the current action and tick. The anim module handles cadence, continue-if-same (walking keeps its phase), and the oamrefresh flag (tile re-upload only when the frame actually changes).
|
static |
Apply gravity and integrate velocity into position.
Adds GRAVITY to Y velocity when airborne (capped at terminal velocity). Then integrates both axes: adds velocity to the fractional accumulator, extracts the integer pixel displacement via asr8(), and stores the remaining fraction for sub-pixel precision next frame.
|
static |
Clamp Kit to the world and handle action state transitions.
Prevents Kit from leaving the map horizontally or going above the top, and moves WALK->STAND when velocity reaches zero, JUMP->FALL at the apex.
|
static |
Check horizontal tile collisions (wall sliding).
Probes one point at Kit's vertical midpoint in the direction of movement. If a solid tile is hit, snaps X to the tile boundary and zeroes horizontal velocity. Only checks the direction Kit is actually moving to avoid false positives.
|
static |
Check vertical tile collisions (ground landing and ceiling bonk).
Ground check: probes two points at Kit's feet (left+2, right+13). If either hits a solid tile, snaps Y to the tile boundary and resets vertical velocity. Ceiling check: probes one point above Kit's head. Collision detection uses the tile property table, not per-pixel checks.
|
static |
Process D-pad and button input for Kit's movement.
LEFT/RIGHT apply acceleration (with max velocity clamping and deceleration when released). A triggers a jump if grounded; holding UP during jump gives a higher arc. The sprite's H-flip attribute is set to match the facing direction.
Put Kit at a point, at rest, and the camera on him.
The sprite is the dynamic engine's slot 0; its tile data may sit in any ROM bank, OAM_SET_GFX() records the bank byte of the pointer it is given.
|
static |
Update camera to follow Kit and position the sprite on screen.
Centers the camera on Kit (offset by half-screen width = 128 pixels), clamped to the map boundaries, and draws Kit through the dynamic sprite engine. While he cannot be hurt, or the world waits after a life lost, he blinks: drawn hidden one frame in four.
|
static |
Kit loses a life: the world waits, then he comes back or the game is over.
| int main | ( | void | ) |
Main entry point – initialization and the game loop.
Initializes all subsystems during force blank: Mode 1 video with BG3 in front, tiles and palettes by DMA, the dynamic sprite engine, the shard frames, the map, the text HUD and SNESMOD (music + five effects). Then the loop, a strict pipeline:
Active display (CPU-only, no VRAM):
VBlank (VRAM writes allowed):
Look up the collision property of the tile at pixel coordinates.
Converts pixel coordinates to tile coordinates, reads the tile index from the map via precomputed row pointers, then looks up the tile's property (T_SOLID or T_EMPTY) in the attribute table. Out-of-bounds coordinates above or left return T_SOLID (wall); below or right return T_EMPTY (open air, allowing fall-off-screen respawn).
|
static |
Load the map from ROM and populate the initial VRAM tilemap.
Parses the map header (width, height in pixels), builds the row pointer table for O(1) tile lookups, and writes all 64 columns to VRAM. Must be called during force blank since it performs direct VRAM writes.
Buffer a map column for deferred VRAM write (prepare phase).
Called during active display (not VBlank). Reads tile indices from ROM map data into the col_buffer[] RAM array and notes the transfer in the VRAM queue (a column: the address steps by 32 words). No VRAM write occurs here – vramQueueFlush() sends it during the next VBlank.
| map_col | Source column index in the map data |
| vram_col | Target column in the SC_64x32 tilemap (0-63) |
|
static |
Write the columns the camera shows, in forced blank, after a jump of the camera.
The streaming of map_update() follows a camera that moves a few pixels a frame; a camera that jumps (Kit back at a checkpoint, the run started again) needs the 33 columns it now shows written at once. The caller turns the screen off around it.
|
static |
Check if the camera has scrolled to a new tile column and prepare it.
Compares the current camera tile position to last_tile_x. If the camera moved right, prepares the column at +32 (one tile ahead of the visible right edge, covering the 33rd partial tile). If moved left, prepares the newly revealed left column. At most one column is prepared per frame.
|
static |
One frame of the run: Kit, the checkpoints, the goal.
Print value with digits digits, zeros in front, at (x, y).
|
static |
A new run: score, lives, shards, machines, Kit on the first roof.
Called in forced blank: the camera jumps back to the start of the map.
|
static |
Draw the shards on screen, and take the ones Kit touches.
Each shard is its own OAM entry (OAM_SHARD + i), a plain 16x16 sprite on the frame tiles loaded once; one off screen or taken is hidden.
|
static |
Back to the title screen: a new run under the title's two lines.
Write a full tile column to VRAM via direct register writes.
Used during force blank (initial map load) when DMA is not needed because there is no time constraint. Sets VMAIN to vertical increment mode (bit 0 set = increment address by 32 after each write), which writes one tile per row down a column.
| map_col | Source column index in the map data |
| vram_col | Destination column in the SC_64x32 tilemap (0-63) |
|
static |
The drone's bob, 16 steps of a slow wave, in pixels.
|
static |
Maximum camera X offset (map_width*8 - 256)
|
static |
Current camera X scroll offset in pixels
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Column tile buffer for deferred VRAM streaming.
During active display, map_prepare_column() fills this 32-entry buffer from ROM map data (RAM-only writes) and notes it in the VRAM queue; vramQueueFlush() sends the 64 bytes in VBlank.
|
static |
The last checkpoint Kit stood beyond (index into checkpoint_pos).
|
static |
|
static |
|
static |
|
static |
|
static |
Each machine: position (its 16x16 box), direction, state, timer, frame.
|
static |
| u8 game_state |
Probe oracles: the state (GS_*), the score in tens, the lives, the shards taken.
|
static |
Current action state (KIT_ACT_STAND/WALK/JUMP/FALL)
|
static |
Kit's animation state
|
static |
Frames left during which Kit cannot be hurt
|
static |
Kit world X position in pixels
|
static |
Kit X sub-pixel fraction (8.8 fixed-point low byte)
|
static |
Kit X velocity in 8.8 fixed-point
|
static |
Kit world Y position in pixels
|
static |
Kit Y sub-pixel fraction (8.8 fixed-point low byte)
|
static |
Kit Y velocity in 8.8 fixed-point (negative = upward)
|
static |
Last tile column for which streaming was performed
| u8 lives |
|
static |
Pointer to the tile index array within maplevel
|
static |
Map height in tiles (parsed from map header)
|
static |
Rightmost valid Kit X position (map_width*8 - 16)
|
static |
Precomputed row pointers into map_data for fast tile lookup.
Avoids an expensive multiply (row * map_width) on every tile access. map_row_ptrs[row] points directly to the start of that row's tile data. Maximum 32 rows for SC_64x32 tilemap height.
|
static |
Map width in tiles (parsed from map header)
|
extern |
The level's tiles, the skyline of BG2 and Kit's frames (32x32, 4bpp, for the dynamic sprite engine).
The machines' frames (32x32) and the shard's eight frames (16x16)
Where the shards, the machines and the checkpoints are, and the goal
Map data (tile indices + header with width/height)
| u16 score |
|
static |
Set when the screen was turned off for a camera jump: the loop turns it on after the next VBlank, once the NMI has sent the sprites' tiles.
|
static |
|
static |
|
static |
SPC700 sound effect slots.
|
static |
|
static |
|
static |
1 for each shard picked up this run
| u8 shards_got |
|
static |
Frames since the state began (blink, waits).
|
static |
Pointer to the tile property table (T_SOLID/T_EMPTY)
|
extern |
Tile attribute table (T_SOLID/T_EMPTY per tile index, b16 format).