PAlib
Macros | Functions
Text output system

Macros

#define PA_InitText   PA_LoadDefaultText
 Old name for PA_LoadDefaultText().
 
#define PA_SetTileLetter(screen, x, y, letter)   PA_SetMapTileAll(screen, PAbgtext[screen], x, y, (PA_textmap[screen][(u16)letter]&((1<<12)-1)) + (PAtext_pal[screen] << 12))
 Output a letter on the DS screen.
 
#define PA_InitCustomText(screen, bg_select, text)   PA_InitCustomTextEx(screen, bg_select, text##_Tiles, text##_Map, text##_Pal)
 [DEPRECATED] Init the text using one of your own fonts !
 
#define PA_ShowFont(screen)   PA_LoadBgMap(screen, PAbgtext[screen], (void*)PA_textmap[screen], BG_256X256)
 Show the current font used. This is just for debug, no real use ingame.
 
#define PA_8bitCustomFont(bit8_slot, bit8_font)
 [DEPRECATED] Add custom fonts to the 8bit Font system !! Font must be converted with PAGfx
 

Functions

void PA_LoadDefaultText (u8 screen, u8 bg_select)
 Load and initialize the default text. Works only in modes 0-2.
 
static void PA_SetTextTileCol (u8 screen, u8 color)
 Change the text writing color (does not change the current text's color)
 
void PA_OutputText (u8 screen, u16 x, u16 y, const char *text,...)
 Output text on the DS screen. Works only in modes 0-2.
 
u16 PA_OutputSimpleText (u8 screen, u16 x, u16 y, const char *text)
 Output simple text on the DS screen. Works only in modes 0-2. Much faster than PA_OutputText, but much more limited... Returns the number of letters.
 
u32 PA_BoxText (u8 screen, u16 basex, u16 basey, u16 maxx, u16 maxy, const char *text, u32 limit)
 Output text on the DS screen. This text is limited to a chosen box, and you can chose the number of letters to output (can be used to show 'typed' text, just put 10000 if you want to show all the text...). Returns the number of letters outputed.
 
u32 PA_BoxTextNoWrap (u8 screen, u16 basex, u16 basey, u16 maxx, u16 maxy, const char *text, u32 limit)
 Output text on the DS screen. This text is limited to a chosen box, and you can chose the number of letters to output (can be used to show 'typed' text, just put 10000 if you want to show all the text...). Returns the number of letters outputed. This function does not support word wrapping.
 
static void PA_SetTextCol (u8 screen, u16 r, u16 g, u16 b)
 Change the screen text's default color.
 
void PA_LoadText (u8 screen, u8 bg_number, const PA_BgStruct *font)
 Load and initialize a custom font.
 
s16 PA_8bitText (u8 screen, s16 basex, s16 basey, s16 maxx, s16 maxy, const char *text, u8 color, u8 size, u8 transp, s32 limit)
 This is a variable width and variable size function to draw text on the screen. It draws on an 8 bit background (see PA_Init8bitBg for more info), and has options such as size, transaprency, and box limits, as well as the color. Only problem : it does not take commands such as d, etc... The function returns the number of characters it outputed.
 
s16 PA_CenterSmartText (u8 screen, s16 basex, s16 basey, s16 maxx, s16 maxy, const char *text, u8 color, u8 size, u8 transp)
 Basicaly the same as the SmartText function, but this time centered...
 
void PA_AddBitmapFont (int slot, const PA_BgStruct *font)
 Add a custom font to the 8bit/16bit font system.
 
void PA_InitTextBorders (u8 screen, u8 x1, u8 y1, u8 x2, u8 y2)
 Initialise a text box with it's borders. This makes writing in a delimited area much easier...
 
void PA_EraseTextBox (u8 screen)
 Erases the text in a textbox. Requires that that box be initialized with PA_InitTextBorders.
 
static u32 PA_SimpleBoxText (u8 screen, const char *text, u32 limit)
 Write text in an initiliazed textbox. Similar to PA_BoxText, but without needing the text limits.
 
void PA_ClearTextBg (u8 screen)
 Erase all the text on a given screen.
 
void PA_Print (u8 screen, const char *text,...)
 Output text on the DS screen. Works like a printf function.
 
static void PA_PrintLetter (u8 screen, char letter)
 Like PA_Print, but for a letter.
 

Detailed Description

Allows you to output text...

Macro Definition Documentation

◆ PA_SetTileLetter

#define PA_SetTileLetter (   screen,
  x,
  y,
  letter 
)    PA_SetMapTileAll(screen, PAbgtext[screen], x, y, (PA_textmap[screen][(u16)letter]&((1<<12)-1)) + (PAtext_pal[screen] << 12))

Output a letter on the DS screen.

Parameters
screenChose de screen (0 or 1)
xX coordinate in TILES (0-31) where to write the letter
yY coordinate in TILES (0-19) where to write the letter
letterLetter... 'a', 'Z', etc...

◆ PA_InitCustomText

#define PA_InitCustomText (   screen,
  bg_select,
  text 
)    PA_InitCustomTextEx(screen, bg_select, text##_Tiles, text##_Map, text##_Pal)

[DEPRECATED] Init the text using one of your own fonts !

Deprecated:
Parameters
screenChose de screen (0 or 1)
bg_selectBackground number...
textFont image file name converted with PAGfx

◆ PA_ShowFont

#define PA_ShowFont (   screen)    PA_LoadBgMap(screen, PAbgtext[screen], (void*)PA_textmap[screen], BG_256X256)

Show the current font used. This is just for debug, no real use ingame.

Parameters
screenChose de screen (0 or 1)

◆ PA_8bitCustomFont

#define PA_8bitCustomFont (   bit8_slot,
  bit8_font 
)
Value:
do{\
PA_DEPRECATED_MACRO;\
bittext_maps[bit8_slot] = (u16*)(void*)bit8_font##_Map; \
bit8_tiles[bit8_slot] = (u8*)bit8_font##_Tiles; \
pa_bittextdefaultsize[bit8_slot] = (u8*)bit8_font##_Sizes; \
pa_bittextpoliceheight[bit8_slot] = bit8_font##_Height;\
}while(0)

[DEPRECATED] Add custom fonts to the 8bit Font system !! Font must be converted with PAGfx

Deprecated:
Parameters
bit8_slotFont slot... 0-4 are used by the defaut PAlib fonts, 5-9 are free to use. You can freely overwrite the PAlib fonts if you want
bit8_fontFont name;..

Function Documentation

◆ PA_LoadDefaultText()

void PA_LoadDefaultText ( u8  screen,
u8  bg_select 
)

Load and initialize the default text. Works only in modes 0-2.

Parameters
screenChoose the screen (0 or 1)
bg_selectBackground number (0-3)
Examples
Backgrounds/Effects/Mode7/source/main.c, and Text/Normal/HelloWorld/source/main.c.

◆ PA_SetTextTileCol()

static inline void PA_SetTextTileCol ( u8  screen,
u8  color 
)
inlinestatic

Change the text writing color (does not change the current text's color)

Parameters
screenChose de screen (0 or 1)
colorColor, from 0 to 6, just test to see the result...

◆ PA_OutputText()

void PA_OutputText ( u8  screen,
u16  x,
u16  y,
const char *  text,
  ... 
)

Output text on the DS screen. Works only in modes 0-2.

Parameters
screenChose de screen (0 or 1)
xX coordinate in TILES (0-31) where to begin writing the text
yY coordinate in TILES (0-19) where to begin writing the text
textString to output. The following commands are avaiblable : %s to output another string, %d to output a value, %fX to output a float with X digits, \n to go to the line. Here's an example : PA_OutputText(0, 0, 1, "My name is %s and I have only %d teeth", "Mollusk", 20);
Examples
Backgrounds/Effects/Mode7/source/main.c.

◆ PA_OutputSimpleText()

u16 PA_OutputSimpleText ( u8  screen,
u16  x,
u16  y,
const char *  text 
)

Output simple text on the DS screen. Works only in modes 0-2. Much faster than PA_OutputText, but much more limited... Returns the number of letters.

Parameters
screenChose de screen (0 or 1)
xX coordinate in TILES (0-31) where to begin writing the text
yY coordinate in TILES (0-19) where to begin writing the text
textString to output.
Examples
Text/Normal/HelloWorld/source/main.c.

◆ PA_BoxText()

u32 PA_BoxText ( u8  screen,
u16  basex,
u16  basey,
u16  maxx,
u16  maxy,
const char *  text,
u32  limit 
)

Output text on the DS screen. This text is limited to a chosen box, and you can chose the number of letters to output (can be used to show 'typed' text, just put 10000 if you want to show all the text...). Returns the number of letters outputed.

Parameters
screenChose de screen (0 or 1)
basexX coordinate in TILES (0-31) where to begin writing the text
baseyY coordinate in TILES (0-19) where to begin writing the text
maxxX coordinate in TILES (0-31) where to stop writing the text
maxyY coordinate in TILES (0-19) where to stop writing the text
textString to output.
limitMaximum number of letters to show this time

◆ PA_BoxTextNoWrap()

u32 PA_BoxTextNoWrap ( u8  screen,
u16  basex,
u16  basey,
u16  maxx,
u16  maxy,
const char *  text,
u32  limit 
)

Output text on the DS screen. This text is limited to a chosen box, and you can chose the number of letters to output (can be used to show 'typed' text, just put 10000 if you want to show all the text...). Returns the number of letters outputed. This function does not support word wrapping.

Parameters
screenChose de screen (0 or 1)
basexX coordinate in TILES (0-31) where to begin writing the text
baseyY coordinate in TILES (0-19) where to begin writing the text
maxxX coordinate in TILES (0-31) where to stop writing the text
maxyY coordinate in TILES (0-19) where to stop writing the text
textString to output.
limitMaximum number of letters to show this time

◆ PA_SetTextCol()

static inline void PA_SetTextCol ( u8  screen,
u16  r,
u16  g,
u16  b 
)
inlinestatic

Change the screen text's default color.

Parameters
screenChose de screen (0 or 1)
rRed amount (0-31)
gGreen amount (0-31)
bBlue amount (0-31)

◆ PA_LoadText()

void PA_LoadText ( u8  screen,
u8  bg_select,
const PA_BgStruct font 
)

Load and initialize a custom font.

Parameters
screenChose the screen (0 or 1)
bg_selectBackground number...
fontPointer to the font

◆ PA_8bitText()

s16 PA_8bitText ( u8  screen,
s16  basex,
s16  basey,
s16  maxx,
s16  maxy,
const char *  text,
u8  color,
u8  size,
u8  transp,
s32  limit 
)

This is a variable width and variable size function to draw text on the screen. It draws on an 8 bit background (see PA_Init8bitBg for more info), and has options such as size, transaprency, and box limits, as well as the color. Only problem : it does not take commands such as d, etc... The function returns the number of characters it outputed.

Parameters
screenChose de screen (0 or 1)
basexX coordinate of the top left corner
baseyY coordinate of the top left corner
maxxX coordinate of the down right corner
maxyY coordinate of the down right corner
textText, such as "Hello World"
colorPalette color to use (0-255)
sizeSize of the text, from 0 (really small) to 4 (pretty big)
transpTransparency. Setting this to 0 will overwrite all drawing in the text zone. 1 will write the text without erasing the drawing. 2 won't output anything (just to count the letters), 3 is rotated one way, 4 rotated the other way
limitYou can give a maximum number of characters to output. This can be usefull to have a slowing drawing text (allow to draw 1 more character each frame...)

◆ PA_CenterSmartText()

s16 PA_CenterSmartText ( u8  screen,
s16  basex,
s16  basey,
s16  maxx,
s16  maxy,
const char *  text,
u8  color,
u8  size,
u8  transp 
)

Basicaly the same as the SmartText function, but this time centered...

Parameters
screenChose de screen (0 or 1)
basexX coordinate of the top left corner
baseyY coordinate of the top left corner
maxxX coordinate of the down right corner
maxyY coordinate of the down right corner
textText, such as "Hello World"
colorPalette color to use (0-255)
sizeSize of the text, from 0 (really small) to 4 (pretty big)
transpTransparency. Setting this to 0 will overwrite all drawing in the text zone. 1 will write the text without erasing the drawing. 2 won't output anything (just to count the letters), 3 is rotated one way, 4 rotated the other way

◆ PA_AddBitmapFont()

void PA_AddBitmapFont ( int  slot,
const PA_BgStruct font 
)

Add a custom font to the 8bit/16bit font system.

Parameters
slotFont slot. 0-4 are used by the default PAlib fonts, 5-9 are free to use. You can freely overwrite the PAlib fonts if you want.
fontPointer to the font.

◆ PA_InitTextBorders()

void PA_InitTextBorders ( u8  screen,
u8  x1,
u8  y1,
u8  x2,
u8  y2 
)

Initialise a text box with it's borders. This makes writing in a delimited area much easier...

Parameters
screenChose de screen (0 or 1)
x1Left limit in tiles
y1Top
x2Right
y2Bottom

◆ PA_EraseTextBox()

void PA_EraseTextBox ( u8  screen)

Erases the text in a textbox. Requires that that box be initialized with PA_InitTextBorders.

Parameters
screenChose de screen (0 or 1)

◆ PA_SimpleBoxText()

static inline u32 PA_SimpleBoxText ( u8  screen,
const char *  text,
u32  limit 
)
inlinestatic

Write text in an initiliazed textbox. Similar to PA_BoxText, but without needing the text limits.

Parameters
screenChose de screen (0 or 1)
textString to output.
limitMaximum number of letters to show this time

◆ PA_ClearTextBg()

void PA_ClearTextBg ( u8  screen)

Erase all the text on a given screen.

Parameters
screenChose de screen (0 or 1)

◆ PA_Print()

void PA_Print ( u8  screen,
const char *  text,
  ... 
)

Output text on the DS screen. Works like a printf function.

Parameters
screenChose de screen (0 or 1)
textString to output. The following commands are avaiblable : %s to output another string, %d to output a value, %fX to output a float with X digits, \n to go to the line. Here's an example : PA_OutputText(0, 0, 1, "My name is %s and I have only %d teeth", "Mollusk", 20);

◆ PA_PrintLetter()

static inline void PA_PrintLetter ( u8  screen,
char  letter 
)
inlinestatic

Like PA_Print, but for a letter.

Parameters
screenChose de screen (0 or 1)
letterAny letter...