libnds
|
NDS stdio support. More...
Data Structures | |
struct | ConsoleFont |
A font struct for the console. More... | |
struct | PrintConsole |
Console structure used to store the state of a console render context. More... | |
Typedefs | |
typedef struct ConsoleFont | ConsoleFont |
A font struct for the console. More... | |
typedef ssize_t(* | ConsoleOutFn) (const char *ptr, size_t len) |
Function type used by libnds to redirect characters sent to stdout and stderr (skipping the call to the ConsolePrint handler). | |
typedef bool(* | ConsolePrint) (void *con, char c) |
Function type used by the PrintConsole struct to send characters to the console. | |
typedef struct PrintConsole | PrintConsole |
Console structure used to store the state of a console render context. More... | |
Enumerations | |
enum | DebugDevice { DebugDevice_NULL = 0x0 , DebugDevice_NOCASH = 0x1 , DebugDevice_CONSOLE = 0x02 } |
Console debug devices supported by libnds. More... | |
Functions | |
void | consoleClear (void) |
Clears the screan by using printf("\x1b[2J");. | |
void | consoleDebugInit (DebugDevice device) |
Initializes the debug console output on stderr to the specified device. More... | |
PrintConsole * | consoleDemoInit (void) |
Initialize the console to a default state for prototyping. More... | |
PrintConsole * | consoleGetDefault (void) |
Gets a pointer to the console with the default values. More... | |
PrintConsole * | consoleInit (PrintConsole *console, int layer, BgType type, BgSize size, int mapBase, int tileBase, bool mainDisplay, bool loadGraphics) |
Initialise the console. More... | |
PrintConsole * | consoleSelect (PrintConsole *console) |
Make the specified console the render target. More... | |
void | consoleSetCustomStderr (ConsoleOutFn fn) |
Sets the function where stderr is sent, bypassing the PrintConsole handler. More... | |
void | consoleSetCustomStdout (ConsoleOutFn fn) |
Sets the function where stdout is sent, bypassing the PrintConsole handler. More... | |
void | consoleSetFont (PrintConsole *console, ConsoleFont *font) |
Loads the font into the console. More... | |
void | consoleSetWindow (PrintConsole *console, int x, int y, int width, int height) |
Sets the print window. More... | |
NDS stdio support.
Provides stdio integration for printing to the DS screen as well as debug print functionality provided by stderr.
General usage is to initialize the console by calling consoleDemoInit() or to customize the console usage by calling consoleInit()
The default instance utilizes the sub display, approximatly 4 KiB of VRAM C starting at tile base 3 and 2 KiB of map at map base 22.
Debug printing is performed by initializing the debug console via consoleDebugInit() as follows:
OR
The print console must be initialized to use DB_CONSOLE.
typedef struct ConsoleFont ConsoleFont |
A font struct for the console.
If convertSingleColor is true, the font is treated as a single color font where all non zero pixels are set to a value of 15 or 255 (4bpp / 8bpp respectivly). This ensures only one palette entry is utilized for font rendering.
typedef struct PrintConsole PrintConsole |
Console structure used to store the state of a console render context.
Default values from consoleGetDefault();
enum DebugDevice |
void consoleDebugInit | ( | DebugDevice | device | ) |
Initializes the debug console output on stderr to the specified device.
device | The debug device (or devices) to output debug print to. |
PrintConsole * consoleDemoInit | ( | void | ) |
Initialize the console to a default state for prototyping.
This function sets the console to use sub display, VRAM_C, and BG0 and enables MODE_0_2D on the sub display. It is intended for use in prototyping applications which need print ability and not actual game use. Print functionality can be utilized with just this call.
PrintConsole * consoleGetDefault | ( | void | ) |
Gets a pointer to the console with the default values.
This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit().
PrintConsole * consoleInit | ( | PrintConsole * | console, |
int | layer, | ||
BgType | type, | ||
BgSize | size, | ||
int | mapBase, | ||
int | tileBase, | ||
bool | mainDisplay, | ||
bool | loadGraphics | ||
) |
Initialise the console.
console | A pointer to the console data to initialze (if it's NULL, the default console will be used). |
layer | Background layer to use. |
type | Type of the background. |
size | Size of the background. |
mapBase | Map base. |
tileBase | Tile graphics base. |
mainDisplay | If true main engine is used, otherwise false. |
loadGraphics | If true the default font graphics will be loaded into the layer. |
PrintConsole * consoleSelect | ( | PrintConsole * | console | ) |
Make the specified console the render target.
console | A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console) |
void consoleSetCustomStderr | ( | ConsoleOutFn | fn | ) |
Sets the function where stderr is sent, bypassing the PrintConsole handler.
To reset it to the libnds console handler, call this function with NULL as an argument, or call consoleDebugInit().
fn | Callback where stderr is sent. |
void consoleSetCustomStdout | ( | ConsoleOutFn | fn | ) |
Sets the function where stdout is sent, bypassing the PrintConsole handler.
To reset it to the libnds console handler, call this function with NULL as an argument.
fn | Callback where stdout is sent. |
void consoleSetFont | ( | PrintConsole * | console, |
ConsoleFont * | font | ||
) |
Loads the font into the console.
console | Pointer to the console to update. If NULL, it will update the current console. |
font | The font to load. |
void consoleSetWindow | ( | PrintConsole * | console, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height | ||
) |
Sets the print window.
console | Console to set. If NULL it will set the current console window |
x | X location of the window. |
y | Y location of the window. |
width | Width of the window. |
height | Height of the window. |