OpenSNES
Modern Open-Source SNES Development SDK
Loading...
Searching...
No Matches
background.h
Go to the documentation of this file.
1
16
17#ifndef OPENSNES_BACKGROUND_H
18#define OPENSNES_BACKGROUND_H
19
20#include <snes/types.h>
21
22/*============================================================================
23 * Constants
24 *============================================================================*/
25
30#define BG_MAP_32x32 0
31#define BG_MAP_64x32 1
32#define BG_MAP_32x64 2
33#define BG_MAP_64x64 3
34
35/* PVSnesLib compatibility aliases */
36#define SC_32x32 BG_MAP_32x32
37#define SC_64x32 BG_MAP_64x32
38#define SC_32x64 BG_MAP_32x64
39#define SC_64x64 BG_MAP_64x64
41
46#define BG_4COLORS 4
47#define BG_16COLORS 16
48#define BG_256COLORS 256
49
50/* Mode 0 has separate subpalettes */
51#define BG_4COLORS0 1
53
54/*============================================================================
55 * Scrolling
56 *============================================================================*/
57
80void bgSetScroll(u8 bg, u16 x, u16 y);
81
88void bgSetScrollX(u8 bg, u16 x);
89
96void bgSetScrollY(u8 bg, u16 y);
97
105
113
114/*============================================================================
115 * Memory Configuration
116 *============================================================================*/
117
138void bgSetMapPtr(u8 bg, u16 vramAddr, u8 mapSize)
139 OPENSNES_CHECK_ARGS((vramAddr & 0x03FF) != 0,
140 "bgSetMapPtr: the tilemap address must be a multiple of 0x400 words; BGnSC keeps vramAddr >> 10");
141
166
168 OPENSNES_CHECK_ARGS((vramAddr & 0x0FFF) != 0,
169 "bgSetGfxPtr: the tile address must be a multiple of 0x1000 words; BG12NBA/BG34NBA keep vramAddr >> 12");
170
178void bgInit(u8 bg);
179
180/*============================================================================
181 * Combined Initialization (PVSnesLib compatible)
182 *============================================================================*/
183
205void bgInitTileSet(u8 bgNumber, const u8 *tileSource, const u8 *tilePalette,
206 u8 paletteEntry, u16 tileSize, u16 paletteSize,
207 u16 colorMode, u16 vramAddr)
208 OPENSNES_CHECK_ARGS((vramAddr & 0x0FFF) != 0,
209 "bgInitTileSet: the tile address must be a multiple of 0x1000 words (see bgSetGfxPtr)");
210
219void bgInitTileSetData(u8 bgNumber, const u8 *tileSource, u16 tileSize, u16 vramAddr)
220 OPENSNES_CHECK_ARGS(bgNumber != 0xFF && (vramAddr & 0x0FFF) != 0,
221 "bgInitTileSetData: the tile address must be a multiple of 0x1000 words (see bgSetGfxPtr), or bgNumber 0xFF");
222
223/*============================================================================
224 * Tilemap Utilities
225 *============================================================================*/
226
245#define bgClearTilemap(vramAddr, fillTile, sizeBytes) \
246 dmaFillVRAM((u16)(fillTile), (u16)(vramAddr), (u16)(sizeBytes))
247
248#endif /* OPENSNES_BACKGROUND_H */
void bgInitTileSet
Definition background.h:209
void bgSetScrollY(u8 bg, u16 y)
Set vertical scroll only.
void or bgNumber
Definition background.h:221
void bgSetScrollX(u8 bg, u16 x)
Set horizontal scroll only.
u16 bgGetScrollY(u8 bg)
Get current vertical scroll position (from shadow).
void bgInitTileSetData
Definition background.h:221
void bgSetMapPtr
Definition background.h:140
void bgSetGfxPtr
Definition background.h:169
u16 bg_address_refused
Set background tile graphics address.
void bgSetScroll(u8 bg, u16 x, u16 y)
Set background scroll position.
BGnSC keeps vramAddr
Definition background.h:140
u16 bgGetScrollX(u8 bg)
Get current horizontal scroll position (from shadow).
void bgInit(u8 bg)
Initialize background layer to defaults.
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
OpenSNES Standard Types.
#define OPENSNES_CHECK_ARGS(cond, msg)
Refuse a call whose constant argument the hardware cannot take.
Definition types.h:334