extern char gfxpsrite, gfxpsrite_end;
extern char palsprite, palsprite_end;
unsigned short pad0, padkeya;
unsigned char spr_queue, spr_mutex;
#define ADRGFXSPR 0x0000
typedef struct
{
u8 *gfxoffset;
u16 adrgfxvram;
} spritequeue;
spritequeue sprqueue[16];
void myconsoleVblank(void)
{
u8 *pgfx;
u16 padrgfx;
if (spr_queue != 0xff)
{
if (spr_mutex == 0)
{
while (spr_queue != 0xff)
{
pgfx = sprqueue[spr_queue].gfxoffset;
padrgfx = sprqueue[spr_queue].adrgfxvram;
dmaCopyVram(pgfx + 8 * 4 * 16, padrgfx + 8 * 4 * 8, 8 * 4 * 2);
spr_queue--;
}
}
}
}
}
void addSprite(u8 *pgfx, u16 adrspr)
{
spr_mutex = 1;
spr_queue++;
sprqueue[spr_queue].gfxoffset = pgfx;
sprqueue[spr_queue].adrgfxvram = adrspr;
spr_mutex = 0;
}
int main(void)
{
spr_queue = 0xff;
spr_mutex = 0;
oamSet(0, 100, 100, 3, 0, 0, 0, 0);
addSprite(&gfxpsrite, ADRGFXSPR);
padkeya = 0;
while (1)
{
if (pad0)
{
{
if (padkeya == 0)
{
padkeya = 1;
addSprite((&gfxpsrite) + 8 * 4 * 2, ADRGFXSPR);
}
}
else
padkeya = 0;
}
}
return 0;
}
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
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 nmiSet(void(*vblankRoutine)(void))
Sets the nmi_handler (VBlank routine).
u8 vblank_flag
VBlank ISR flag.
void WaitForVBlank(void)
Waits for a VBlank interrupt.
the master include file for snes applications.
#define OBJ_SIZE16_L32
default OAM size 16x16 (SM) and 32x32 (LG) pix for OBJSEL register
Definition sprite.h:42
void oamSetEx(u16 id, u8 size, u8 hide)
Put the correct size and hide or show a sprite.
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.