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/* --- Bank $00 SLOT 1 (C-accessible, < $2000) --- */
116
118extern u16 x_pos;
119
121extern u16 y_pos;
122
123/* --- Bank $7E SLOT 2 (NOT C-accessible, ASM-only) --- */
124/* The map engine's bulk data lives in Bank $7E:
125 * metatiles[4096] — metatile definitions (4 tile entries per metatile)
126 * metatilesprop[2048] — tile collision properties
127 * bg_L1[2048] — BG1 tilemap buffer
128 * mapadrrowlut[1024] — row address lookup table
129 * These are managed internally by mapLoad/mapUpdate/mapVblank.
130 * C code accesses map data through mapGetMetaTile/mapGetMetaTilesProp.
131 */
132
133/*============================================================================
134 * Functions
135 *============================================================================*/
136
161void mapLoad(const u8 *layer1map, const u8 *layertiles, const u8 *tilesprop);
162
169void mapUpdate(void);
170
179void mapVblank(void);
180
196
205
214
220void mapSetMapOptions(u8 optmap);
221
222#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.
u16 x_pos
Current camera X position in pixels.
void mapSetMapOptions(u8 optmap)
Set map engine options.
u16 y_pos
Current camera Y 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]
X positions for the four sprites displayed in a horizontal row.
Definition main.c:54
OpenSNES Standard Types.