PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
graphics/Backgrounds/Mode3/Mode3.c
/*---------------------------------------------------------------------------------
Simple tile mode 3 demo with more than 32k tiles
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char patterns, patterns1, patterns1_end;
extern char palette;
extern char map, map_end;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize SNES
// Read tiles to VRAM in 2 phases because we are more than 32k
bgInitTileSet(0, &patterns, &palette, 0, 0x8000, 256 * 2, BG_256COLORS, 0x0000);
dmaCopyVram(&patterns1, 0x4000, (&patterns1_end - &patterns1));
// Copy Map to VRAM
bgInitMapSet(0, &map, (&map_end - &map), SC_32x32, 0x6000);
// Now Put in 256 color mode and disable other BGs except 1st one
setMode(BG_MODE3, 0);
;
// Wait for nothing :P
while (1)
{
}
return 0;
}
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void bgInitMapSet(u8 bgNumber, u8 *mapSource, u16 mapSize, u8 sizeMode, u16 address)
Initializes a Map Set and loads it into SNES VRAM.
void bgInitTileSet(u8 bgNumber, u8 *tileSource, u8 *tilePalette, u8 paletteEntry, u16 tileSize, u16 paletteSize, u16 colorMode, u16 address)
Initializes a Tile Set and Loads the Tile GFX into VRAM.
void consoleInit(void)
Initialize console.
void dmaCopyVram(u8 *source, u16 address, u16 size)
copy data from source to destination using channel 0 of DMA available channels in half words
void WaitForVBlank(void)
Wait for vblank interrupt
the master include file for snes applications.
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.