PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
audio/music/Music.c
/*---------------------------------------------------------------------------------
Simple music demo
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
#include "res/soundbank.h"
extern char snesfont, snespal;
extern char SOUNDBANK__;
unsigned short bgcolor = 0;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize sound engine (take some time)
// Initialize SNES
// Initialize text console with our font
consoleInitText(0, 16 * 2, &snesfont, &snespal);
// Set give soundbank
spcSetBank(&SOUNDBANK__);
// Load music
spcLoad(MOD_POLLEN8);
// 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, "Let's the music play !");
// Wait for nothing :P
// Play file from the beginning
spcPlay(0);
// Wait for nothing :D !
while (1)
{
// Update music / sfx stream and wait vbl
// change background color
bgcolor++;
setPaletteColor(0x00, bgcolor);
}
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 consoleInit(void)
Initialize console.
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)
void WaitForVBlank(void)
Wait for vblank interrupt
the master include file for snes applications.
void spcLoad(u16 musIndex)
load module into sm-spc. this function may take some time to execute
void spcSetBank(u8 *bank)
set soundbank origin. soundbank must have dedicated bank(s)
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
void spcPlay(u8 startPos)
play module. note: this simply queues a message, use spcFlush if you want to wait until the message i...
#define setPaletteColor(paletteEntry, paletteColor)
Change a color palette in CGRAM.
Definition: video.h:395
void setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.