PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
console.h File Reference

snes generic console support. More...

#include <snes/snestypes.h>
#include <snes/background.h>
#include <snes/dma.h>
#include <snes/input.h>
#include <snes/interrupt.h>
#include <snes/sprite.h>
#include <snes/sound.h>
#include <snes/video.h>

Go to the source code of this file.

Functions

void consoleCopySram (u8 *source, u16 size)
 Send data to SRAM. More...
 
void consoleCopySramWithOffset (u8 *source, u16 size, u16 offset)
 Send data to SRAM with offset. More...
 
void consoleDrawText (u16 x, u16 y, char *fmt,...)
 Output formatted string on a screen (tiles mode) More...
 
void consoleDrawTextMap (u16 x, u16 y, u8 *map, u8 attributes, char *fmt,...)
 Output formatted string on a screen (2 colors tiles mode) More...
 
void consoleDrawTextMapCenter (u16 y, u16 *map, u8 attributes, char *fmt,...)
 Output formatted string on a screen, centered it (2 colors tiles mode) More...
 
void consoleInit (void)
 Initialize console. More...
 
void consoleInitText (u8 palnum, u8 palsize, u8 *tilfont, u8 *palfont)
 Initialize the Text System. More...
 
void consoleLoadSram (u8 *dest, u16 size)
 Load data from SRAM. More...
 
void consoleLoadSramWithOffset (u8 *dest, u16 size, u16 offset)
 Load data from SRAM with offset. More...
 
void consoleMesenBreakpoint ()
 Execute the special WDM opcode which Mesen can break on.
 
void consoleNocashMessage (char *fmt,...)
 Send a message to the no$sns debug window. More...
 
u16 consoleRegionIsOK (void)
 Check compatibility between console (NTSC/PAL) and cartridge (country) More...
 
void consoleSetTextOffset (u16 offsetfont)
 Change text Background map address for display (must be BG address) More...
 
void consoleSetTextPal (u8 palnum, u8 *palfont, u8 palsize)
 Change text font palette. More...
 
void consoleSetTextVramAdr (u16 vramfont)
 Change text graphics address (4K aligned) More...
 
void consoleSetTextVramBGAdr (u16 offsetfont)
 Change text Background map address for display (must be BG address) More...
 
void consoleUpdate (void)
 Update current text buffer on screen.
 
u16 rand (void)
 return a randomized number More...
 

Variables

u8 scr_txt_dirty
 flag to redraw text during vblank
 
u8 scr_txt_font_map [0x800]
 tilemap used for text display
 
u8 snes_50hz
 1 if on a PAL/50Hz SNES
 
u8 snes_fps
 50 if PAL console (50 Hz) or 60 if NTSC console (60Hz)
 
u16 snes_vblank_count
 Number of VBL since consoleInit called (16 bits longs so reset each 18 minutes in NTSC)
 

Detailed Description

snes generic console support.

Function Documentation

◆ consoleCopySram()

void consoleCopySram ( u8 *  source,
u16  size 
)

Send data to SRAM.

Parameters
sourcethe source to copy from
sizethe size in bytes of the data to copy.
Examples
sram/sramsimple/sram.c.

◆ consoleCopySramWithOffset()

void consoleCopySramWithOffset ( u8 *  source,
u16  size,
u16  offset 
)

Send data to SRAM with offset.

Parameters
sourcethe source to copy from
sizethe size in bytes of the data to copy.
offsetthe offset in bytes where the data should be copied
Examples
sram/sramoffset/sramoffset.c.

◆ consoleDrawText()

void consoleDrawText ( u16  x,
u16  y,
char *  fmt,
  ... 
)

Output formatted string on a screen (tiles mode)

Parameters
xThe X character number the string should start on
yThe Y character number the string should start on
fmtThe Format string (see printf() documentation in your local C tutorial)

Output a text string to the screen. Before using this, you need to call consoleInitText(). You can also print the value of variables this way, by putting a format string and additional parameters.

Examples
audio/effects/effects.c, audio/effectsandmusic/effectsandmusic.c, audio/music/Music.c, audio/musicGreaterThan32k/musicGreaterThan32k.c, audio/tada/Tada.c, breakpoints/src/breakpoints.c, games/likemario/LikeMario.c, graphics/Backgrounds/Mode1Scroll/Mode1Scroll.c, graphics/Palette/GetColors/GetColors.c, graphics/Sprites/ObjectSize/ObjectSize.c, hello_world/src/hello_world.c, input/controller/controller.c, input/mouse/mouse.c, input/multiplay5/multiplay5.c, input/superscope/superscope.c, memory_mapping/src/memory_mapping.c, random/random.c, scoring/scoring.c, sram/sramoffset/sramoffset.c, sram/sramsimple/sram.c, testregion/testregion.c, timer/timer.c, and typeconsole/src/pal_ntsc.c.

◆ consoleDrawTextMap()

void consoleDrawTextMap ( u16  x,
u16  y,
u8 *  map,
u8  attributes,
char *  fmt,
  ... 
)

Output formatted string on a screen (2 colors tiles mode)

Parameters
xThe X character number the string should start on
yThe Y character number the string should start on
mapThe 0x800 char map entry to put string
attributesattributes for tiles
fmtThe Format string (see printf() documentation in your local C tutorial)

Output a text string to the screen. Before using this, you need to call consoleInitText(). You can also print the value of variables this way, by putting a format string and additional parameters.

◆ consoleDrawTextMapCenter()

void consoleDrawTextMapCenter ( u16  y,
u16 *  map,
u8  attributes,
char *  fmt,
  ... 
)

Output formatted string on a screen, centered it (2 colors tiles mode)

Parameters
yThe Y character number the string should start on
mapThe 0x800 char map entry to put string
attributesattributes for tiles
fmtThe Format string (see printf() documentation in your local C tutorial)

Output a text string to the screen. Before using this, you need to call consoleInitText(). You can also print the value of variables this way, by putting a format string and additional parameters. The text will be centered on x axis.

◆ consoleInit()

consoleInit ( void  )

Initialize console.

Generic init for SNES console.

Examples
audio/effects/effects.c, audio/effectsandmusic/effectsandmusic.c, audio/music/Music.c, audio/musicGreaterThan32k/musicGreaterThan32k.c, audio/tada/Tada.c, breakpoints/src/breakpoints.c, debug/debug.c, games/breakout/breakout.c, games/likemario/LikeMario.c, graphics/Backgrounds/Mode0/Mode0.c, graphics/Backgrounds/Mode1/Mode1.c, graphics/Backgrounds/Mode1BG3HighPriority/Mode1BG3HighPriority.c, graphics/Backgrounds/Mode1ContinuosScroll/Mode1ContinuosScroll.c, graphics/Backgrounds/Mode1LZ77/Mode1LZ77.c, graphics/Backgrounds/Mode1MixedScroll/Mode1MixedScroll.c, graphics/Backgrounds/Mode1Png/Mode1.c, graphics/Backgrounds/Mode1Scroll/Mode1Scroll.c, graphics/Backgrounds/Mode3/Mode3.c, graphics/Backgrounds/Mode5/Mode5.c, graphics/Backgrounds/Mode7/Mode7.c, graphics/Backgrounds/Mode7Perspective/Mode7Perspective.c, graphics/Effects/Fading/Fading.c, graphics/Effects/GradientColors/GradientColors.c, graphics/Effects/HDMAGradient/HDMAGradient.c, graphics/Effects/MosaicShading/MosaicShading.c, graphics/Effects/ParallaxScrolling/ParallaxScrolling.c, graphics/Effects/Transparency/Transparency.c, graphics/Effects/TransparentWindow/src/main.c, graphics/Effects/Waves/Waves.c, graphics/Effects/Window/Window.c, graphics/Palette/GetColors/GetColors.c, graphics/Sprites/AnimatedSprite/AnimatedSprite.c, graphics/Sprites/DynamicEngineMetaSprite/DynamicEngineMetaSprite.c, graphics/Sprites/DynamicEngineSprite/DynamicEngineSprite.c, graphics/Sprites/DynamicSprite/DynamicSprite.c, graphics/Sprites/ObjectSize/ObjectSize.c, graphics/Sprites/SimpleSprite/SimpleSprite.c, hello_world/src/hello_world.c, input/controller/controller.c, input/mouse/mouse.c, input/multiplay5/multiplay5.c, input/superscope/superscope.c, maps/mapscroll/mapscroll.c, maps/tiled/tiled.c, memory_mapping/src/memory_mapping.c, objects/mapandobjects/mapandobjects.c, objects/moveobjects/moveobjects.c, objects/nogravityobject/nogravityobjects.c, random/random.c, scoring/scoring.c, sram/sramoffset/sramoffset.c, sram/sramsimple/sram.c, testregion/testregion.c, timer/timer.c, and typeconsole/src/pal_ntsc.c.

◆ consoleInitText()

void consoleInitText ( u8  palnum,
u8  palsize,
u8 *  tilfont,
u8 *  palfont 
)

◆ consoleLoadSram()

void consoleLoadSram ( u8 *  dest,
u16  size 
)

Load data from SRAM.

Parameters
destthe destination to load into
sizethe size in bytes of the data to copy.
Examples
sram/sramsimple/sram.c.

◆ consoleLoadSramWithOffset()

void consoleLoadSramWithOffset ( u8 *  dest,
u16  size,
u16  offset 
)

Load data from SRAM with offset.

Parameters
destthe destination to load into
sizethe size in bytes of the data to copy.
offsetthe offset from which the data should be loaded
Examples
sram/sramoffset/sramoffset.c.

◆ consoleNocashMessage()

void consoleNocashMessage ( char *  fmt,
  ... 
)

Send a message to the no$sns debug window.

Parameters
fmtThe Format string (see printf() documentation in your local C tutorial)
Examples
debug/debug.c, games/likemario/LikeMario.c, and objects/moveobjects/moveobjects.c.

◆ consoleRegionIsOK()

consoleRegionIsOK ( void  )

Check compatibility between console (NTSC/PAL) and cartridge (country)

Returns
1 if cartridge and console are from the same region, 2 if not

Check if console (PAL / NSTC) is the same as cartrdige region code

Examples
testregion/testregion.c.

◆ consoleSetTextOffset()

◆ consoleSetTextPal()

consoleSetTextPal ( u8  palnum,
u8 *  palfont,
u8  palsize 
)

Change text font palette.

Parameters
palnumpalette entry (0..7)
palfontpointer to the new palette
palsizesize of palette of text (4,16,etc ...)

◆ consoleSetTextVramAdr()

◆ consoleSetTextVramBGAdr()

◆ rand()

rand ( void  )

return a randomized number

Returns
unsigned short of a randozied number
Examples
graphics/Sprites/DynamicEngineSprite/DynamicEngineSprite.c, input/superscope/superscope.c, objects/moveobjects/moveobjects.c, and random/random.c.