PVSnesLib  3.4.0
Functions | Variables
console.h File Reference

snes generic console support. More...

#include <snes/snestypes.h>
#include <snes/background.h>
#include <snes/dma.h>
#include <snes/interrupt.h>
#include <snes/pad.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 consoleDrawText (u16 x, u16 y, char *fmt,...)
 Output formatted string on a screen (tiles mode) More...
 
 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 bgNumber, u8 paletteNumber, u8 *gfxText)
 Initialize the Text System. More...
 
void consoleLoadSram (u8 *dest, u16 size)
 Load data from SRAM. More...
 
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 consoleSetTextCol (u16 colorChar, u16 colorBG)
 Change Character and Background color of text. More...
 
void consoleUpdate (void)
 Update current text buffer on screen.
 
u16 rand (void)
 return a randomized number More...
 

Variables

u8 pvsneslibdirty
 flag to redraw text during vblank
 
u8 pvsneslibfont_map [0x800]
 tilemap used for text display
 
u8 snes_50hz
 1 if on a PAL/50Hz SNES
 
u16 snes_vblank_count
 Number of VBL since consoleInit called.
 

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/sram.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/music/Music.c, audio/tada/Tada.c, games/likemario/LikeMario.c, graphics/Backgrounds/Mode1Scroll/Mode1Scroll.c, graphics/Palette/GetColors/GetColors.c, hello_world/src/hello_world.c, input/input.c, random/random.c, scoring/scoring.c, sram/sram.c, and timer/timer.c.

◆ consoleDrawTextMap()

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  )

◆ consoleInitText()

void consoleInitText ( u8  bgNumber,
u8  paletteNumber,
u8 *  gfxText 
)

Initialize the Text System.

Parameters
bgNumberThe BG number to show Text on.
paletteNumberPalette number (0..16).
gfxTextPointer to tiles gfx for printing

Reserve a BG and load the font characters into VRAM. It will only work in tiled display modes. Also, please note that this function will overwrite BG palette number 0 and 1 to black and white, and set the Font to use these two colors. You can change colors by calling consoleSetTextCol().

Examples:
audio/music/Music.c, audio/tada/Tada.c, games/likemario/LikeMario.c, graphics/Backgrounds/Mode1Scroll/Mode1Scroll.c, graphics/Palette/GetColors/GetColors.c, hello_world/src/hello_world.c, input/input.c, random/random.c, scoring/scoring.c, sram/sram.c, and timer/timer.c.

◆ 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/sram.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

◆ consoleSetTextCol()

consoleSetTextCol ( u16  colorChar,
u16  colorBG 
)

Change Character and Background color of text.

Parameters
colorCharThe BG color palette with RGB5 values of text itself
colorBGThe BG color palette with RGB5 values of text background
Examples:
games/likemario/LikeMario.c.

◆ rand()

rand ( void  )

return a randomized number

Returns
unsigned short of a randozied number
Examples:
objects/moveobjects/moveobjects.c, and random/random.c.