PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
graphics/Sprites/SimpleSprite/SimpleSprite.c
/*---------------------------------------------------------------------------------
Simple sprite demo in mode 1
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char gfxpsrite, gfxpsrite_end;
extern char palsprite, palsprite_end;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize SNES
// Init Sprites gfx and palette with default size of 32x32
oamInitGfxSet(&gfxpsrite, (&gfxpsrite_end - &gfxpsrite), &palsprite, (&palsprite_end - &palsprite), 0, 0x0000, OBJ_SIZE32_L64);
// Define sprites parameters
oamSet(0, 100, 100, 3, 0, 0, 0, 0); // Put sprite in 100,100, with maximum priority 3 from tile entry 0, palette 0
oamSetEx(0, OBJ_SMALL, OBJ_SHOW);
// Now Put in 16 color mode and disable all backgrounds
setMode(BG_MODE1, 0);
// Wait for nothing :P
while (1)
{
// Wait VBL 'and update sprites too ;-) )
}
return 0;
}
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void consoleInit(void)
Initialize console.
void WaitForVBlank(void)
Wait for vblank interrupt
the master include file for snes applications.
void oamSetEx(u16 id, u8 size, u8 hide)
Put the correct size and hide or show a sprite.
#define OBJ_SIZE32_L64
default OAM size 32x32 (SM) and 64x64 (LG) pix for OBJSEL register
Definition: sprite.h:44
void oamInitGfxSet(u8 *tileSource, u16 tileSize, u8 *tilePalette, u16 paletteSize, u8 tilePaletteNumber, u16 address, u8 oamsize)
Initializes a sprites Gfx and Loads the GFX into VRAM.
void oamSet(u16 id, u16 xspr, u16 yspr, u8 priority, u8 hflip, u8 vflip, u16 gfxoffset, u8 paletteoffset)
sets an oam entry to the supplied values
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.