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.
u16 snes_vblank_count
Number of VBL since consoleInit called (16 bits longs so reset each 18 minutes in NTSC)
void consoleInit(void)
Initialize console.
void dmaCopyOAram(u8 *source, u16 address, u16 size)
copies Sprites from source to destination using channel 0 of DMA available channels in half words
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
#define nmiSet(handler)
Add a handler for the given interrupt mask.
Definition: interrupt.h:150
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.
u8 oamMemory[128 *4+8 *4]
to address oam table low and high
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.