PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
Loading...
Searching...
No Matches
audio/tada/Tada.c
/*---------------------------------------------------------------------------------
Simple brr sound demo
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char soundbrr, soundbrrend;
brrsamples tadasound;
extern char snesfont, snespal;
unsigned short bgcolor = 128;
u8 keyapressed = 0;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize sound engine (take some time)
// Initialize text console with our font
consoleInitText(0, 16 * 2, &snesfont, &snespal);
// allocate around 10K of sound ram (39 256-byte blocks)
// Init background
bgSetGfxPtr(0, 0x2000);
bgSetMapPtr(0, 0x6800, SC_32x32);
// Now Put in 16 color mode and disable Bgs except current
setMode(BG_MODE1, 0);
// Draw a wonderful text :P
consoleDrawText(5, 10, "Press A to play effect !");
// Wait for nothing :P
// Load effect
spcSetSoundEntry(15, 15, 4, &soundbrrend - &soundbrr, &soundbrr, &tadasound);
// Wait for nothing :D !
while (1)
{
// Test key a (without repeating sound if still pressed)
if (padsCurrent(0) & KEY_A)
{
if (keyapressed == 0)
{
keyapressed = 1;
// Play effect
// change background color
bgcolor += 16;
setPaletteColor(0x00, bgcolor);
}
}
else
keyapressed = 0;
// Update music / sfx stream and wait vbl
}
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 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)
#define padsCurrent(value)
Return current value of selected pad.
Definition input.h:198
@ KEY_A
pad A button.
Definition input.h:51
void WaitForVBlank(void)
Waits for a VBlank interrupt.
the master include file for snes applications.
void spcAllocateSoundRegion(u8 size)
Set the size of the sound region.
void spcSetSoundEntry(u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr)
set the values and address of the SOUND TABLE for a sound entry
void spcPlaySound(u8 sndIndex)
Play sound from memory (using default arguments)
void spcProcess(void)
Process messages This function will try to give messages to the spc until a few scanlines pass.
void spcBoot(void)
boots the spc700 with sm-spc. call once at startup
brr sample sound header(8 bytes)
Definition sound.h:51
#define setPaletteColor(paletteEntry, paletteColor)
Change a color palette in CGRAM.
Definition video.h:397
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.