PVSnesLib  4.4.0
Documentation to code in C or ASM for the Nintendo SNES
Loading...
Searching...
No Matches
sram/sramsimple/sram.c
/*---------------------------------------------------------------------------------
snes sram demo
-- alekmaul
---------------------------------------------------------------------------------*/
#include <snes.h>
extern char snesfont, snespal;
unsigned short valToSave = 0xCAFE, valToLoad;
unsigned short pad0;
char sz[16];
//---------------------------------------------------------------------------------
int main(void)
{
// Initialize text console with our font
consoleInitText(0, 16 * 2, &snesfont, &snespal);
// Draw a wonderful text :P
consoleDrawText(12, 1, "SRAM TEST");
consoleDrawText(3, 5, "USE A TO WRITE");
consoleDrawText(3, 7, "USE B TO READ");
// Init background
bgSetGfxPtr(0, 0x2000);
bgSetMapPtr(0, 0x6800, SC_32x32);
// Now Put in 16 color mode
setMode(BG_MODE1, 0);
// Wait for nothing :P
while (1)
{
// Get current #0 pad
pad0 = padsCurrent(0);
// Update display with current pad
switch (pad0)
{
case KEY_A:
consoleCopySram((u8 *)&valToSave, 2);
consoleDrawText(9, 10, "SRAM SAVE");
break;
case KEY_B:
valToLoad = 0;
consoleLoadSram((u8 *)&valToLoad, 2);
sprintf(sz, "%04X READ", valToLoad);
consoleDrawText(9, 10, sz);
break;
}
}
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 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 consoleSetTextGfxPtr(u16 vramfont)
Change text graphics address (4K aligned)
void consoleLoadSram(u8 *dest, u16 size)
Load data from SRAM.
void consoleCopySram(u8 *source, u16 size)
Send data to SRAM.
void consoleSetTextMapPtr(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_B
pad B button.
Definition input.h:52
@ 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 setScreenOn(void)
Put screen On.
void setMode(u8 mode, u8 size)
Set the SNES hardware to operate in new display mode.