Initialization

Font initialization functions

Print_Initialize
bool Print_Initialize()

Initialize print module.  Must be called after VDP_SetMode().

Print_SetMode
void Print_SetMode(
u8 mode
)

Change current print mode.

Parameters
mode
u8

Print mode to select. Can be:

PRINT_MODE_BITMAP          Draw characters from RAM (R-T unpack font data and draw it). Need PRINT_USE_BITMAP or PRINT_USE_VRAM compile option.
PRINT_MODE_BITMAP_TRANS Draw characters from RAM with transparency (R-T unpack font data and draw it). Need PRINT_USE_BITMAP or PRINT_USE_VRAM compile option.
PRINT_MODE_BITMAP_VRAM Draw characters from VRAM (font data is upack once in VRAM thne drawing is done by VRAM copy). Need PRINT_USE_VRAM compile option.
PRINT_MODE_SPRITE Draw characters from sprites (load font data as sprite pattern in VRAM then display characters using sprite system). Need PRINT_USE_SPRITE compile option.
PRINT_MODE_TEXT Draw characters as pattern names (text mode). Need PRINT_USE_TEXT compile option.
Print_SetFont
void Print_SetFont(
const u8* font
)

Set the current font (and set mode to RAM).

Parameters
font
const u8*

Pointer to font structure. Character patterns plus a 4 bytes headers (character width/height, spacing width/height, 1st character code, last character code).

Print_SetFontEx
inline void Print_SetFontEx(
u8 patternX,
u8 patternY,
u8 sizeX,
u8 sizeY,
u8 firstChr,
u8 lastChr,
const u8* patterns
)

Set the current font

Parameters
patternX
u8

Width of the character data (should be always 8)

patternY
u8

Height of the character data

sizeX
u8

Width of the chatacter to display (can be different than the one of the data)

sizeY
u8

Height of the chatacter to display (can be different than the one of the data)

firstChr
u8

ASCII code of the first character included in the font data

lastChr
u8

ASCII code of the last character included in the font data

patterns
const u8*

Address of the character data table

Print_GetFontInfo
inline const struct Print_Data* Print_GetFontInfo()

Get first character code

Return

Current font information structure

Print_SetPosition
inline void Print_SetPosition(
UX x,
UY y
)

Set cursor position.

Parameters
X
UX

Print cursor position X coordinate

Y
UY

Print cursor position Y coordinate

Print_SetCharSize
inline void Print_SetCharSize(
u8 x,
u8 y
)

Set character size.

Parameters
X
u8

Character width

Y
u8

Character height

Print_SetTabSize
inline void Print_SetTabSize(
u8 size
)

Set tabulation size in pixel.

Parameters
size
u8

Size of the tabulation in pixel (must be a power of 2 like 16, 32, 64, ...)

Print_SetBitmapFont
bool Print_SetBitmapFont(
const u8* font
)

Initialize print module and set a font in RAM.  This function requires PRINT_USE_BITMAP compile option to be set to TRUE.

Parameters
font
const u8*

Pointer to font structure. Character patterns plus a 4 bytes headers (character width/height, spacing width/height, 1st character code, last character code).

Print_SetVRAMFont
void Print_SetVRAMFont(
const u8* font,
UY y,
u8 color
)

Set the current font and upload data to VRAM .  This function requires PRINT_USE_VRAM compile option to be set to TRUE.

Parameters
font
const u8*

Pointer to font structure. Character patterns plus a 4 bytes headers (character width/height, spacing width/height, 1st character code, last character code).

y
UY

Y position to store the font in VRAM

color
u8

Color of the font

Print_SetTextFont
void Print_SetTextFont(
const u8* font,
u8 offset
)

Initialize print module and set a font in RAM.  This function requires PRINT_USE_TEXT compile option to be set to TRUE.

Parameters
font
const u8*

Pointer to font structure. Character patterns plus a 4 bytes headers (character width/height, spacing width/height, 1st character code, last character code).

offset
u8

Pattern index where to start to store the font

Print_SelectTextFont
inline void Print_SelectTextFont(
const u8* font,
u8 offset
)

Set print mode to text mode.  This function requires PRINT_USE_TEXT compile option to be set to TRUE.

Parameters
font
const u8*

Pointer to font structure. Character patterns plus a 4 bytes headers (character width/height, spacing width/height, 1st character code, last character code).

offset
u8

Pattern index where to start to store the font

Print_SetSpriteFont
void Print_SetSpriteFont(
const u8* font,
u8 patIdx,
u8 sprtIdx
)

Set the current font and upload to Sprite Pattern Table.  This function requires PRINT_USE_SPRITE compile option to be set to TRUE.

Parameters
font
const u8*

Pointer to font structure. Character patterns plus a 4 bytes headers (character width/height, spacing width/height, 1st character code, last character code).

patIdx
u8

Pattern index to put font character

sprtIdx
u8

Sprite index of the first sprite the module can use to display text

Print_GetSpritePattern
inline u8 Print_GetSpritePattern()

Get pattern index of the 1st sprite character.  This function requires PRINT_USE_SPRITE compile option to be set to TRUE.

Return

Pattern index where the font is stored

Print_GetSpriteID
inline u8 Print_GetSpriteID()

Get the next sprite index.  This function requires PRINT_USE_SPRITE compile option to be set to TRUE.

Return

Sprite index of the first sprite the module can use to display text

Print_SetSpriteID
inline void Print_SetSpriteID(
u8 id
)

Set the next sprite index.  This function requires PRINT_USE_SPRITE compile option to be set to TRUE.

Parameters
id
u8

Sprite index of the first sprite the module can use to display text

Draw

Text draw functions

Print_DrawChar
void Print_DrawChar(
u8 chr
)

Print a single character

Parameters
chr
u8

ASCII code of the character to draw

Print_DrawCharX
void Print_DrawCharX(
c8 chr,
u8 num
)

Print the same character many times

Parameters
chr
c8

ASCII code of the character to draw

num
u8

Number of the same character to display in a row

Print_DrawText
void Print_DrawText(
const c8* string
)

Print a character string

Parameters
string
const c8*

Null-terminated string to draw

Print_DrawHex8
void Print_DrawHex8(
u8 value
)

Print a 8-bits binary value

Parameters
value
u8

8 bits integer to draw in hexadecimal form

Print_DrawHex16
void Print_DrawHex16(
u16 value
)

Print a 16-bits hexadecimal value

Parameters
value
u16

16 bits integer to draw in hexadecimal form

Print_DrawBin8
void Print_DrawBin8(
u8 value
)

Print a 8-bits binary value

Parameters
value
u8

8 bits integer to draw in binary form (0 or 1)

Print_DrawHex32
void Print_DrawHex32(
u32 value
)

Print a 32-bits hexadecimal value This function requires PRINT_USE_32B compile option to be set to TRUE.

Parameters
value
u32

32 bits integer to draw in hexadecimal form

Print_DrawInt
void Print_DrawInt(
i32 value
)

Print a 32-bits signed decimal value.  This function requires PRINT_USE_32B compile option to be set to TRUE.

Parameters
value
i32

32 bits signed integer to draw

Print_DrawInt
void Print_DrawInt(
i16 value
)

Print a 16-bits signed decimal value.  This function requires PRINT_USE_32B compile option to be set to FALSE.

Parameters
value
i16

16 bits signed integer to draw

Print_Space
inline void Print_Space()

Print space.

Print_Tab
inline void Print_Tab()

Print tabulation.

Print_Return
inline void Print_Return()

Print return.

Print_DrawFormat
void Print_DrawFormat(
const c8* format,
...
)

Print a formated string with a variable number of parameters.  This function requires PRINT_USE_FORMAT compile option to be set to TRUE.

Parameters
format
const c8*

Printf style format

%i or %d                  16 bits signed integer
%u 16 bits unsigned integer
%[N]x 16 bits hexadecimal with N digits (default: 4)
%c ASCII coded character
%s Null-terminated string
%I or %D 32 bits signed integer
%U 32 bits unsigned integer
%[N]X 32 bits hexadecimal with N digits (default: 4)
\t Tabulation
\n Return to new line

... - Variadic parameters

Helper
Print_Clear
void Print_Clear()

Clear screen

Print_Backspace
void Print_Backspace(
u8 num
)

Clear X character back from current cursor position.

Parameters
num
u8

Number of character to clear

Print_DrawTextAt
inline void Print_DrawTextAt(
u8 x,
u8 y,
const c8* str
)

Draw text at a given position on screen.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

str
const c8*

Null-terminated string to draw

Print_DrawTextAtV
inline void Print_DrawTextAtV(
u8 x,
u8 y,
const c8* str
)

Draw a vertical text at a given position on screen.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

str
const c8*

Null-terminated string to draw

Print_DrawCharAt
inline void Print_DrawCharAt(
u8 x,
u8 y,
c8 chr
)

Print a single character at a given position.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

chr
c8

Character to draw

Print_DrawCharXAt
inline void Print_DrawCharXAt(
u8 x,
u8 y,
c8 chr,
u8 len
)

Print the same character many times at a given position.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

chr
c8

Character to draw

len
u8

Number of character to draw

Print_DrawCharYAt
inline void Print_DrawCharYAt(
u8 x,
u8 y,
c8 chr,
u8 len
)

Print vertically the same character many times at a given position.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

chr
c8

Character to draw

len
u8

Number of character to draw

Print_DrawIntAt
inline void Print_DrawIntAt(
u8 x,
u8 y,
i16 val
)

Print a 16-bits signed decimal value at a given position.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

val
i16

16 bits integer to display

FX
Print_SetColor
void Print_SetColor(
u8 text,
u8 bg
)

Set the draw color.

Parameters
text
u8

Text color (16 color index or 8 bits RGB)

bg
u8

Background color (16 color index or 8 bits RGB)

Print_SetColorShade
void Print_SetColorShade(
const u8* shade
)

Set colors shade.  This function requires PRINT_COLOR_NUM compile option to be set to greater than 1 value.

Parameters
shade
const u8*

Pointer to font color (1 color for each line)

Print_SetShadow
void Print_SetShadow(
bool enable,
i8 offsetX,
i8 offsetY,
u8 color
)

Set shadow effect.  This function requires PRINT_USE_FX_SHADOW compile option to be set to TRUE.

Parameters
offsetX
i8

Offset on X coordinate (can be negative).

offsetY
i8

Offset on Y coordinate (can be negative).

color
u8

Shadow's color.

Print_EnableShadow
void Print_EnableShadow(
bool enable
)

Activate/desactivate shadow effect.  This function requires PRINT_USE_FX_SHADOW compile option to be set to TRUE.

Parameters
enable
bool

TRUE to enable shadow effect, FALSE to disable.

Print_DrawTextShadow
void Print_DrawTextShadow(
const c8* string,
i8 offsetX,
i8 offsetY,
u8 color
)

Print a character string with shadow FX using 2 pass rendering (to have clean shadow over all characters).  This function requires PRINT_USE_2_PASS_FX and PRINT_USE_FX_SHADOW compile options to be set to TRUE.

Parameters
string
const c8*

Pointer to the null-terminated string to display.

offsetX
i8

Shadow position offset (X coordinate).

offsetY
i8

Shadow position offset (X coordinate).

color
u8

Shadow color.

Print_SetOutline
void Print_SetOutline(
bool enable,
u8 color
)

Set shadow effect.  This function requires PRINT_USE_FX_OUTLINE compile option to be set to TRUE.

Parameters
enable
bool

TRUE to enable outline effect, FALSE to disable.

color
u8

Color of the outline effect

Print_EnableOutline
void Print_EnableOutline(
bool enable
)

Activate/desactivate shadow effect This function requires PRINT_USE_FX_OUTLINE compile option to be set to TRUE.

Parameters
enable
bool

TRUE to enable outline effect, FALSE to disable.

Print_DrawTextOutline
void Print_DrawTextOutline(
const c8* string,
u8 color
)

Print a character string using outline FX.  This function requires PRINT_USE_2_PASS_FX and PRINT_USE_FX_OUTLINE compile options to be set to TRUE.

Parameters
string
const c8*

Pointer to the null-terminated string to display

color
u8

Outline color

Graph

Boxes draw functions

Print_DrawLineH
void Print_DrawLineH(
u8 x,
u8 y,
u8 len
)

Draw an horizontal line using characters This function requires PRINT_USE_GRAPH compile option to be set to TRUE.

Parameters
x
u8

Start position X coordinate

y
u8

Start position Y coordinate

len
u8

Lenght of the horizontal line (in print mode unit)

Print_DrawLineV
void Print_DrawLineV(
u8 x,
u8 y,
u8 len
)

Draw a vertical line using characters This function requires PRINT_USE_GRAPH compile option to be set to TRUE.

Parameters
x
u8

Start position X coordinate

y
u8

Start position Y coordinate

len
u8

Lenght of the vertical line (in print mode unit)

Print_DrawBox
void Print_DrawBox(
u8 x,
u8 y,
u8 width,
u8 height
)

Draw a box using characters This function requires PRINT_USE_GRAPH compile option to be set to TRUE.

Parameters
x
u8

Start position X coordinate

y
u8

Start position Y coordinate

width
u8

Box width (in print mode unit)

height
u8

Box height (in print mode unit)

Print_DrawTextAlign
inline void Print_DrawTextAlign(
const c8* str,
u8 align
)

Print a character string

Parameters
str
const c8*

Null-terminated string to draw

align
u8

Alignement flag: PRINT_ALIGN_LEFT, PRINT_ALIGN_CENTER, PRINT_ALIGN_RIGHT

Print_DrawTextAlignAt
inline void Print_DrawTextAlignAt(
u8 x,
u8 y,
const c8* str,
u8 align
)

Draw text at a given position on screen.

Parameters
x
u8

Position X coordinate

y
u8

Position Y coordinate

str
const c8*

Null-terminated string to draw

align
u8

Alignement flag: PRINT_ALIGN_LEFT, PRINT_ALIGN_CENTER, PRINT_ALIGN_RIGHT