OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
asset.h
Go to the documentation of this file.
1
75
76#ifndef SNES_ASSET_H
77#define SNES_ASSET_H
78
79#include <snes/types.h>
80#include <snes/background.h>
81#include <snes/dma.h>
82
101typedef struct {
103 const u8 *tiles;
106 const u8 *tiles_end;
108 const u8 *palette;
118} GfxAsset;
119
126typedef struct {
130 const u8 *tilemap;
138} BgAsset;
139
152void gfxLoad(u8 bg, const GfxAsset *asset, u8 palette_slot, u16 tiles_vram);
153
169void bgLoad(u8 bg, const BgAsset *asset, u8 palette_slot,
170 u16 tiles_vram, u16 map_vram);
171
184#define DECLARE_GFX_ASSET(name, color_mode_) \
185 extern const u8 name##_tiles[], name##_tiles_end[]; \
186 extern const u8 name##_pal[], name##_pal_end[]; \
187 static const GfxAsset name = { \
188 .tiles = name##_tiles, \
189 .tiles_end = name##_tiles_end, \
190 .palette = name##_pal, \
191 .palette_end = name##_pal_end, \
192 .color_mode = (color_mode_), \
193 }
194
206#define DECLARE_BG_ASSET(name, color_mode_, map_size_) \
207 extern const u8 name##_tiles[], name##_tiles_end[]; \
208 extern const u8 name##_pal[], name##_pal_end[]; \
209 extern const u8 name##_map[], name##_map_end[]; \
210 static const BgAsset name = { \
211 .gfx = { \
212 .tiles = name##_tiles, \
213 .tiles_end = name##_tiles_end, \
214 .palette = name##_pal, \
215 .palette_end = name##_pal_end, \
216 .color_mode = (color_mode_), \
217 }, \
218 .tilemap = name##_map, \
219 .tilemap_end = name##_map_end, \
220 .map_size = (map_size_), \
221 }
222
223#endif /* SNES_ASSET_H */
void gfxLoad(u8 bg, const GfxAsset *asset, u8 palette_slot, u16 tiles_vram)
Load a tileset (tiles + palette) and configure a BG's tile graphics pointer. (It used to be described...
void bgLoad(u8 bg, const BgAsset *asset, u8 palette_slot, u16 tiles_vram, u16 map_vram)
Load a full background bundle: tiles, palette and tilemap in one call. (The BG_LOAD macro this used t...
SNES Background Layer Management.
SNES DMA (Direct Memory Access).
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
A full background bundle: tileset + tilemap + map size.
Definition asset.h:126
const u8 * tilemap
Pointer to tilemap data (gfx4snes .map).
Definition asset.h:130
u8 map_size
Tilemap layout. Use one of SC_32x32, SC_64x32, SC_32x64, SC_64x64.
Definition asset.h:137
const u8 * tilemap_end
One past the end of the tilemap data.
Definition asset.h:132
GfxAsset gfx
Tileset (tiles + palette + color mode).
Definition asset.h:128
A tileset bundle: graphics + palette + color depth.
Definition asset.h:101
const u8 * tiles_end
One past the end of tile graphics. Size is computed at load time as tiles_end - tiles.
Definition asset.h:106
u16 color_mode
Color depth selector. Use one of: BG_4COLORS, BG_4COLORS0 (Mode 0), BG_16COLORS, BG_256COLORS....
Definition asset.h:117
const u8 * tiles
Pointer to tile graphics data.
Definition asset.h:103
const u8 * palette
Pointer to BGR555 palette data.
Definition asset.h:108
const u8 * palette_end
One past the end of the palette data.
Definition asset.h:110
OpenSNES Standard Types.