PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
graphics/Backgrounds/Mode7/Mode7.c
/*---------------------------------------------------------------------------------
Simple mode 7 rotating demo with more than 32k tiles
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char patterns, patterns_end;
extern char palette;
extern char map, map_end;
u16 pad0;
u8 angle;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize SNES
// Read tiles & map to VRAM (interlace for mode 7)
bgInitMapTileSet7(&patterns, &map, &palette, (&patterns_end - &patterns), 0x0000);
// Now Put mode7 without anything else
// Display screen
// Init angle
angle = 0;
// Wait for nothing :P
while (1)
{
// Get current #0 pad
pad0 = padsCurrent(0);
if (pad0)
{
// Update scrolling with current pad
switch (pad0)
{
case KEY_A:
angle++;
setMode7Rot(angle);
break;
case KEY_B:
angle--;
setMode7Rot(angle);
break;
}
}
}
return 0;
}
void bgInitMapTileSet7(u8 *tileSource, u8 *mapSource, u8 *tilePalette, u16 tileSize, u16 address)
Initializes a Tile & Map Set and Loads the Tile & Map GFX into VRAM for Mode 7.
void consoleInit(void)
Initialize console.
#define padsCurrent(value)
Return current value of selected pad.
Definition: input.h:161
@ KEY_B
pad B button.
Definition: input.h:49
@ KEY_A
pad A button.
Definition: input.h:48
void WaitForVBlank(void)
Wait for vblank interrupt
the master include file for snes applications.
void setMode7Rot(u8 angle)
Change angle view in mode 7 with matrix transformation.
void setScreenOn(void)
Put screen On.
void setMode7(u8 mode)
Put screen in mode 7 with generic init.