PrintConsole defaultConsole =
{
//Font:
{
(u16*)default_font_bin, //font gfx
0, //font palette
0, //font color count
4, //bpp
0, //first ascii character in the set
128, //number of characters in the font set
true, //convert to single color
},
0, //font background map
0, //font background gfx
31, //map base
0, //char base
0, //bg layer in use
-1, //bg id
0,0, //cursorX cursorY
0,0, //prevcursorX prevcursorY
32, //console width
24, //console height
0, //window x
0, //window y
32, //window width
24, //window height
3, //tab size
0, //font character offset
0, //selected palette
0, //print callback
false, //console initialized
true, //load graphics
};
*/
typedef struct PrintConsole
{
ConsoleFont font;
u16* fontBgMap; /*!< Pointer to the bg layer map if used. Is set by bgInit if bgId is valid>*/
u16* fontBgGfx; /*!< Pointer to the bg layer graphics if used. Is set by bgInit if bgId is valid>*/
u8 mapBase; /*!< Map base set by console init based on background setup >*/
u8 gfxBase; /*!< Tile graphics base set by console init based on background setup >*/
u8 bgLayer; /*!< Bg layer used by the background >*/
int bgId; /*!< bgId, should be set with a call to bgInit() or bgInitSub()>*/
int cursorX;/*!< Current X location of the cursor (as a tile offset by default) >*/
int cursorY;/*!< Current Y location of the cursor (as a tile offset by default) >*/
int prevCursorX; /*!< Internal state >*/
int prevCursorY; /*!< Internal state >*/
int consoleWidth;/*!< Width of the console hardware layer in tiles >*/
int consoleHeight;/*!< Height of the console hardware layer in tiles >*/
int windowX;/*!< Window X location in tiles (not implemented) >*/
int windowY;/*!< Window Y location in tiles (not implemented) >*/
int windowWidth;/*!< Window width in tiles (not implemented) >*/
int windowHeight;/*!< Window height in tiles (not implemented) >*/
int tabSize;/*!< Size of a tab >*/
u16 fontCharOffset;/*!< Offset to the first graphics tile in background memory (in case your font is not loaded at a graphics base boundary)>*/
u16 fontCurPal; /*!< The current palette used by the engine (only applies to 4bpp text backgrounds) >*/
ConsolePrint PrintChar; /*!< callback for printing a character. Should return true if it has handled rendering the graphics (else the print engine will attempt to render via tiles) >*/
bool consoleInitialised; /*!< True if the console is initialized >*/
bool loadGraphics; /*!< True if consoleInit should attempt to load font graphics into background memory >*/
}PrintConsole;
/**
* \enum DebugDevice
* \brief Console debug devices supported by libnds
*/
typedef enum
{
DebugDevice_NOCASH = 0x1, /*!< Prints debug statements to no$gba debug window >*/
DebugDevice_CONSOLE = 0x02 /*!< Prints debug statements to DS console window >*/
}DebugDevice;
/*! \fn void consoleSetFont(PrintConsole* console, ConsoleFont* font)
\brief Loads the font into the current console
\param console pointer to the print console to update
\param font the font to load
*/
void consoleSetFont(PrintConsole* console, ConsoleFont* font);
/*! \fn void consoleSetWindow(PrintConsole* console, int x, int y, int width, int height)
\brief Sets the print window
\param console console to set, if NULL will set current console window
\param x x location of the window
\param y y location of the window
\param width width of the window
\param height height of the window
*/
void consoleSetWindow(PrintConsole* console, int x, int y, int width, int height);
/*! \fn PrintConsole* consoleGetDefault(void)
\brief Gets a pointer to the default console (this should only be used when using a single console, other wise use consoleNew(PrintsConsole* console)
\return A pointer to the default console
*/
PrintConsole* consoleGetDefault(void);
/*! \fn void consoleSelect(PrintConsole* console)
\brief Make the specified console the render target
\param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)
*/
void consoleSelect(PrintConsole* console);
/*! \fn PrintConsole* consoleInit(PrintConsole* console, int layer, BgType type, BgSize size, int mapBase, int tileBase, bool mainDisplay, bool loadGraphics);
\brief Initialise the console.
\param console A pointer to the console initialze data (if null default console will be used)
\param layer background layer to use
\param type the type of the background
\param size the size of the background
\param mapBase the map base
\param tileBase the tile graphics base
\param mainDisplay if true main engine is used, otherwise false
\param loadGraphics if true the default font graphics will be loaded into the layer
*/
PrintConsole* consoleInit(PrintConsole* console, int layer, BgType type, BgSize size, int mapBase, int tileBase, bool mainDisplay, bool loadGraphics);
/*! \fn PrintConsole* consoleDemoInit(void)
\brief 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* consoleDemoInit(void);
/*! \fn void consoleClear(void)
\brief Clears the screan by iprintf("\x1b[2J");
*/
void consoleClear(void);
/*! \fn void consoleDebugInit(DebugDevice device)
\brief Initializes debug console output on stderr to the specified device
\param device The debug device (or devices) to output debug print statements to
*/
void consoleDebugInit(DebugDevice device);
#ifdef __cplusplus
}
#endif
#endif