Scrolling platformer with object engine and enemy AI. More...
#include <snes.h>#include <snes/map.h>#include <snes/object.h>#include "mario.h"#include "goomba.h"#include "koopatroopa.h"Functions | |
| int | main (void) |
| Main entry point – scrolling platformer with map and object engines. | |
| void | objRegisterTypes (void) |
| Register all object type callbacks (Mario, Goomba, Koopa) with correct bank bytes. | |
Variables | |
| u8 | mapmario |
| Map data (tile indices for the scrolling level layout) | |
| u16 | nbobjects |
| Running count of active objects in the level. | |
| u8 | objmario |
| Object layer data (spawn positions and type IDs for entities) | |
| u8 | palsprite |
| Shared sprite palette for all entity types (BGR555) | |
| u8 | tileset |
| BG1 tileset tile data (4bpp) – start label. | |
| u8 | tilesetatt |
| Tile attribute table (collision flags per tile index) | |
| u8 | tilesetdef |
| Tile definition table (visual properties per tile index) | |
| u8 | tilesetend |
| BG1 tileset tile data – end label (for size calculation) | |
| u8 | tilesetpal |
| BG1 tileset palette (BGR555, 16 colors) | |
Scrolling platformer with object engine and enemy AI.
Demonstrates the OpenSNES map engine and object engine working together to create a scrolling platformer with multiple entity types. The map engine handles tile-based scrolling and VRAM streaming, while the object engine manages entity lifecycle, physics, collision callbacks, and per-frame update dispatch.
Three object types are registered via assembly callbacks (for correct bank byte resolution): Mario (player-controlled), Goomba (walks and reverses at walls), and Koopa Troopa (patrols with shell behavior). Object spawn positions are loaded from the map's object layer.
The dynamic sprite engine handles animated 16x16 sprites with automatic VRAM tile management, freeing the game logic from manual tile uploads.
Port of the PVSnesLib mapandobjects example by Alekmaul.
| int main | ( | void | ) |
Main entry point – scrolling platformer with map and object engines.
Initializes the map engine (BG1 tileset + tilemap), object engine (entity registration and spawning), and dynamic sprite engine (animated 16x16 sprites). The main loop follows the standard OpenSNES game pipeline:
Active display: mapUpdate() + objUpdateAll() + sprite end-frame VBlank: mapVblank() + oamVramQueueUpdate()
Object callbacks (Mario, Goomba, Koopa Troopa) handle their own physics, collision, animation, and sprite drawing within objUpdateAll().
|
extern |
Register all object type callbacks (Mario, Goomba, Koopa) with correct bank bytes.
Each object type has an update callback function pointer stored with its ROM bank byte. Since C cannot express the :label bank-byte operator, this assembly function handles registration for all three entity types.
|
extern |
Map data (tile indices for the scrolling level layout)
| u16 nbobjects |
Running count of active objects in the level.
Initialized to 1 (Mario is always object 0) and incremented as enemies are loaded from the map's object layer by objLoadObjects().
|
extern |
Object layer data (spawn positions and type IDs for entities)
|
extern |
Shared sprite palette for all entity types (BGR555)
|
extern |
BG1 tileset tile data (4bpp) – start label.
|
extern |
Tile attribute table (collision flags per tile index)
|
extern |
Tile definition table (visual properties per tile index)
|
extern |
BG1 tileset tile data – end label (for size calculation)
|
extern |
BG1 tileset palette (BGR555, 16 colors)