OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1
43
44#ifndef OPENSNES_MAP_H
45#define OPENSNES_MAP_H
46
47#include <snes/types.h>
48
49/*============================================================================
50 * Tile Property Constants
51 *============================================================================*/
52
54#define T_EMPTY 0x0000
55
57#define T_SOLID 0xFF00
58
60#define T_LADDER 0x0001
61
63#define T_FIRES 0x0002
64
66#define T_SPIKE 0x0004
67
69#define T_PLATE 0x0008
70
72#define T_SLOPEU1 0x0020
73
75#define T_SLOPED1 0x0021
76
78#define T_SLOPELU2 0x0022
79
81#define T_SLOPELD2 0x0023
82
84#define T_SLOPEUU2 0x0024
85
87#define T_SLOPEUD2 0x0025
88
89/*============================================================================
90 * Action Constants (used by both map and object engines)
91 *============================================================================*/
92
93#define ACT_STAND 0x0000
94#define ACT_WALK 0x0001
95#define ACT_JUMP 0x0002
96#define ACT_FALL 0x0004
97#define ACT_CLIMB 0x2000
98#define ACT_DIE 0x4000
99#define ACT_BURN 0x8000
100
101/*============================================================================
102 * Map Options
103 *============================================================================*/
104
106#define MAP_OPT_1WAY 0x01
107
109#define MAP_OPT_BG2 0x02
110
111/*============================================================================
112 * Exported Variables
113 *============================================================================*/
114
115/* The camera position is read with mapGetCameraX() / mapGetCameraY() (below).
116 * Until 2026-10-03 it was two exported globals, `x_pos` and `y_pos`: names a
117 * game is likely to want for itself, and that no alias could have moved
118 * later. Replace `x_pos` by `mapGetCameraX()` and `y_pos` by
119 * `mapGetCameraY()`; assembly code reads `map_cam_x` / `map_cam_y`. */
120
121/* --- Bank $7E SLOT 2 (NOT C-accessible, ASM-only) --- */
122/* The map engine's bulk data lives in Bank $7E:
123 * metatiles[4096] — metatile definitions (4 tile entries per metatile)
124 * metatilesprop[2048] — tile collision properties
125 * bg_L1[2048] — BG1 tilemap buffer
126 * mapadrrowlut[1024] — row address lookup table
127 * These are managed internally by mapLoad/mapUpdate/mapVblank.
128 * C code accesses map data through mapGetMetaTile/mapGetMetaTilesProp.
129 */
130
131/*============================================================================
132 * Functions
133 *============================================================================*/
134
164void mapLoad(const u8 *layer1map, const u8 *layertiles, const u8 *tilesprop);
165
172void mapUpdate(void);
173
182void mapVblank(void);
183
199
213
220
229
238
248void mapSetMapOptions(u8 optmap);
249
250#endif /* OPENSNES_MAP_H */
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:53
unsigned char u8
8-bit unsigned integer (0 to 255)
Definition types.h:47
void mapUpdateCamera(u16 xpos, u16 ypos)
Update camera position to follow an object.
void mapLoad(const u8 *layer1map, const u8 *layertiles, const u8 *tilesprop)
Load map data into the engine and flush to VRAM.
u16 mapGetMetaTilesProp(u16 xpos, u16 ypos)
Get tile collision property at map coordinates.
void mapSetMapOptions(u8 optmap)
Set map engine options.
u16 mapGetCameraY(void)
Camera Y position in pixels.
u16 mapGetCameraX(void)
Camera X position in pixels.
void mapVblank(void)
Transfer map updates to VRAM.
void mapUpdate(void)
Update map scroll buffers based on camera position.
u16 mapGetMetaTile(u16 xpos, u16 ypos)
Get metatile index at map coordinates.
static const s16 xpos[4]
ROM source for the 16x16 sprite sheet tile data.
Definition main.c:53
OpenSNES Standard Types.