extern char tileset, tilesetend, tilesetpal;
extern char gfxsprite, gfxsprite_end, palsprite;
extern char mapmario, tilesetdef, tilesetatt;
const char sprTiles[4] =
{
0,
2,
4,
6,
};
unsigned short pad0;
unsigned short xloc, yloc, flipx, frame, frameidx, flip;
int main(void)
{
bgInitTileSet(0, &tileset, &tilesetpal, 0, (&tilesetend - &tileset), 16 * 2, BG_16COLORS, 0x2000);
xloc = 0;
yloc = 224 - 32;
flipx = 0;
frame = 0;
frameidx = 0;
flip = 0;
oamSet(0, xloc, yloc, 0, 0, 0, 0, 0);
mapLoad((u8 *)&mapmario, (u8 *)&tilesetdef, (u8 *)&tilesetatt);
while (1)
{
if (pad0)
{
{
if (xloc)
xloc--;
flipx = 1;
flip++;
if (flip & 1)
{
frameidx++;
frameidx = frameidx & 3;
frame = sprTiles[frameidx];
}
}
{
xloc++;
flipx = 0;
flip++;
if (flip & 1)
{
frameidx++;
frameidx = frameidx & 3;
frame = sprTiles[frameidx];
}
}
}
oamSet(0, xloc - x_pos, yloc -
y_pos, 3, flipx, 0, frame, 0);
}
return 0;
}
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 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 WaitForVBlank(void)
Wait for vblank interrupt
void mapVblank(void)
Display map regarding current buffer (must be done once per frame, near Vblank)
void mapUpdate(void)
Update map regarding current camera position (must be done once per frame)
u16 y_pos
Current value of camera in x & y coordinates.
Definition: map.h:57
void mapLoad(u8 *layer1map, u8 *layertiles, u8 *tilesprop)
Load map definition into memory.
void mapUpdateCamera(u16 xpos, u16 ypos)
Update map camera (must be done once per frame)
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 oamSetVisible(u16 id, u8 hide)
Hide or show a sprite.
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.