extern char snesfont, snespal;
extern char sprite8, sprite8_end, palsprite8, palsprite8_end;
extern char sprite16, sprite16_end, palsprite16, palsprite16_end;
extern char sprite32, sprite32_end, palsprite32, palsprite32_end;
extern char sprite64, sprite64_end, palsprite64, palsprite64_end;
u16 selectedItem;
bool keyPressed;
#define ADRBG1 0x2000
#define ADRSPRITE 0x2100
#define ADRSPRITLARDGE 0x2500
#define PALETTESPRSIZE (16 * 2)
void draw()
{
consoleDrawText(3, 3,
"%s %s", selectedItem == 0 ?
">" :
" ",
"Small: 8 - Large: 16");
consoleDrawText(3, 4,
"%s %s", selectedItem == 1 ?
">" :
" ",
"Small: 8 - Large: 32");
consoleDrawText(3, 5,
"%s %s", selectedItem == 2 ?
">" :
" ",
"Small: 8 - Large: 64");
consoleDrawText(3, 6,
"%s %s", selectedItem == 3 ?
">" :
" ",
"Small: 16 - Large: 32");
consoleDrawText(3, 7,
"%s %s", selectedItem == 4 ?
">" :
" ",
"Small: 16 - Large: 64");
consoleDrawText(3, 8,
"%s %s", selectedItem == 5 ?
">" :
" ",
"Small: 32 - Large: 64");
}
void changeObjSize()
{
if (selectedItem == 0)
{
dmaCopyVram(&sprite16, ADRSPRITLARDGE, (&sprite16_end - &sprite16));
}
else if (selectedItem == 1)
{
dmaCopyVram(&sprite32, ADRSPRITLARDGE, (&sprite32_end - &sprite32));
}
else if (selectedItem == 2)
{
dmaCopyVram(&sprite64, ADRSPRITLARDGE, (&sprite64_end - &sprite64));
}
else if (selectedItem == 3)
{
dmaCopyVram(&sprite32, ADRSPRITLARDGE, (&sprite32_end - &sprite32));
}
else if (selectedItem == 4)
{
dmaCopyVram(&sprite64, ADRSPRITLARDGE, (&sprite64_end - &sprite64));
}
else if (selectedItem == 5)
{
dmaCopyVram(&sprite64, ADRSPRITLARDGE, (&sprite64_end - &sprite64));
}
oamSet(0, 70, 120, 3, 0, 0, 0x0010, 0);
oamSet(4, 170, 120, 3, 0, 0, 0x0050, 1);
}
int main(void)
{
unsigned short pad0;
selectedItem = 0;
keyPressed = false;
draw();
changeObjSize();
while (1)
{
if (pad0)
{
{
if (selectedItem > 0 && !keyPressed)
{
selectedItem--;
draw();
changeObjSize();
keyPressed = true;
}
}
{
if (selectedItem < 5 && !keyPressed)
{
selectedItem++;
draw();
changeObjSize();
keyPressed = true;
}
}
}
else
keyPressed = false;
}
return 0;
}
void bgSetGfxPtr(u8 bgNumber, u16 address)
Definition of each background address.
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void bgSetMapPtr(u8 bgNumber, u16 address, u8 mapSize)
Change Background Map address.
void consoleSetTextVramAdr(u16 vramfont)
Change text graphics address (4K aligned)
void consoleInitText(u8 palnum, u8 palsize, u8 *tilfont, u8 *palfont)
Initialize the Text System.
void consoleInit(void)
Initialize console.
void consoleDrawText(u16 x, u16 y, char *fmt,...)
Output formatted string on a screen (tiles mode)
void consoleSetTextOffset(u16 offsetfont)
Change text Background map address for display (must be BG address)
void consoleSetTextVramBGAdr(u16 offsetfont)
Change text Background map address for display (must be BG address)
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 dmaCopyCGram(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.
#define OBJ_SIZE16_L32
default OAM size 16x16 (SM) and 32x32 (LG) pix for OBJSEL register
Definition: sprite.h:42
#define OBJ_SIZE8_L64
default OAM size 8x8 (SM) and 64x64 (LG) pix for OBJSEL register
Definition: sprite.h:41
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.
#define OBJ_SIZE8_L32
default OAM size 8x8 (SM) and 32x32 (LG) pix for OBJSEL register
Definition: sprite.h:40
#define OBJ_SIZE8_L16
default OAM size 8x8 (SM) and 16x16 (LG) pix for OBJSEL register
Definition: sprite.h:39
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
#define OBJ_SIZE16_L64
default OAM size 16x16 (SM) and 64x64 (LG) pix for OBJSEL register
Definition: sprite.h:43
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.