PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
graphics/Effects/Transparency/Transparency.c
/*---------------------------------------------------------------------------------
Transparency between 2 BGs demo
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char LandTiles, LandTiles_end;
extern char CloudTiles, CloudTiles_end;
extern char LandPalette, LandPalette_end, CloudPalette, CloudPalette_end;
extern char Maps, Maps_end;
extern char Mapsc, Mapsc_end;
//---------------------------------------------------------------------------------
int main(void)
{
short scrX = 0, scrY = 0;
unsigned short pad0, move;
// Initialize SNES
// Copy tiles to VRAM
bgInitTileSet(0, &LandTiles, &LandPalette, 1, (&LandTiles_end - &LandTiles), (&LandPalette_end - &LandPalette), BG_16COLORS, 0x0000);
bgInitTileSet(2, &CloudTiles, &CloudPalette, 0, (&CloudTiles_end - &CloudTiles), (&CloudPalette_end - &CloudPalette), BG_4COLORS, 0x1000);
// Copy Map to VRAM
bgInitMapSet(0, &Maps, (&Maps_end - &Maps), SC_32x32, 0x2000);
bgInitMapSet(2, &Mapsc, (&Mapsc_end - &Mapsc), SC_32x32, 0x2400);
// Now Put in 16 color mode and put cloud on top of screen
setMode(BG_MODE1, BG3_MODE1_PRIORITY_HIGH);
// Set BG3 SubScreen and
// enable Subscreen Color ADD/SUB and Color addition on BG1 and Backdrop color
setColorEffect(CM_SUBBGOBJ_ENABLE, CM_MSCR_BACK | CM_MSCR_BG1);
// Wait for nothing :P
while (1)
{
// change scrolling
scrX++;
bgSetScroll(2, scrX, 0);
}
return 0;
}
void bgSetEnableSub(u8 bgNumber)
Enable a BG from sub screen (translucent) in the actual SNES mode.
void bgSetDisable(u8 bgNumber)
Disable a BG in the actual SNES mode.
void bgSetScroll(u8 bgNumber, u16 x, u16 y)
Sets the scroll hardware to the specified location.
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 WaitForVBlank(void)
Wait for vblank interrupt
the master include file for snes applications.
void setColorEffect(u8 colorMathA, u8 colorMathB)
Do addition or other color effects.
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.