PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
graphics/Effects/Waves/Waves.c
/*---------------------------------------------------------------------------------
Simple gradient color effect in mode 1
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char patterns, patterns_end;
extern char palette, palette_end;
extern char map, map_end;
u8 pada,padb;
u16 pad0;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize SNES
// Copy tiles to VRAM
bgInitTileSet(0, &patterns, &palette, 0, (&patterns_end - &patterns), (&palette_end - &palette), BG_16COLORS, 0x4000);
// Copy Map to VRAM
bgInitMapSet(0, &map, (&map_end - &map), SC_32x32, 0x0000);
// Now Put in 16 color mode and disable other BGs except 1st one
setMode(BG_MODE1, 0);
// Initialize the wave effect
pada=0; padb=0;
// Wait for nothing :P
while (1)
{
// Get current #0 pad
pad0 = padsCurrent(0);
// remove it with key a
if (pad0 & KEY_A) {
if (!pada) {
pada=1;
}
}
else pada=0;
// put it again with key b
if (pad0 & KEY_B) {
padb=1;
}
else padb=0;
// even if wa call it each frame, it will do the effect every 4th frame
// Wait vblank sync
}
return 0;
}
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void bgInitMapSet(u8 bgNumber, u8 *mapSource, u16 mapSize, u8 sizeMode, u16 address)
Initializes a Map Set and loads it into SNES VRAM.
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 setModeHdmaReset(u8 channels)
Reset or Set HDMA channels.
void setModeHdmaWaves(u8 bgrnd)
Do a waves effect on screen (init function). Use HDMA Channels 6.
void setModeHdmaWavesMove(void)
Animate the waves effect. Must be called during each frame. setModeHdmaWaves must have been done to ...
#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 setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.