PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
breakpoints/src/breakpoints.c
/*---------------------------------------------------------------------------------
Simple example of using special Mesen breakpoints.
The 65816 CPU has an unused opcode called WDM which functions as a NOP.
Mesen can be told to break on it.
-- jeffythedragonslayer
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char tilfont, palfont;
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize SNES
// Initialize text console with our font
consoleInitText(0, 16 * 2, &tilfont, &palfont);
// 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(10, 10, "Breakpoints!");
consoleDrawText(6, 14, "Press Ctrl+D to open");
consoleDrawText(7, 15, "the Mesen debugger.");
consoleDrawText(5, 18, "Make sure \'Break on...\'");
consoleDrawText(8, 19, "WDM is checked");
// Wait for nothing :P
while (1)
{
}
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 consoleMesenBreakpoint()
Execute the special WDM opcode which Mesen can break on.
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 setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.