libtonc: Operations

Tonclib

Operations
[Tonc Text Engine]

Basic operations. More...

Functions

void tte_set_context (TTC *tc)
 Set the master context pointer.
INLINE TTCtte_get_context (void)
 Get the master text-system.
INLINE uint tte_get_glyph_id (int ch)
 Get the glyph index of character ch.
INLINE int tte_get_glyph_width (uint gid)
 Get the width of glyph id.
INLINE int tte_get_glyph_height (uint gid)
 Get the height of glyph id.
INLINE const void * tte_get_glyph_data (uint gid)
 Get the glyph data of glyph id.
void tte_set_color (eint type, u16 clr)
 Set color attribute of type to cattr.
void tte_set_colors (const u16 colors[])
 Load important color data.
void tte_set_color_attr (eint type, u16 cattr)
 Set color attribute of type to cattr.
void tte_set_color_attrs (const u16 cattrs[])
 Load important color attribute data.
char * tte_cmd_default (const char *str)
 Text command handler.
int tte_putc (int ch)
 Plot a single character; does wrapping too.
int tte_write (const char *text)
 Render a string.
int tte_write_ex (int x, int y, const char *text, const u16 *clrlut)
 Extended string writer, with positional and color info.
void tte_erase_rect (int left, int top, int right, int bottom)
 Erase a porttion of the screen (ignores margins).
void tte_erase_screen (void)
 Erase the screen (within the margins).
void tte_erase_line (void)
 Erase the whole line (within the margins).
POINT16 tte_get_text_size (const char *str)
 Get the size taken up by a string.
void tte_init_base (const TFont *font, fnDrawg drawProc, fnErase eraseProc)
 Base initializer of a TTC.

Detailed Description

Basic operations.

This covers most of the things you can actually use TTE for, like writing the text, getting information about a glyph and setting color attributes.


Function Documentation

char* tte_cmd_default ( const char *  str  ) 

Text command handler.

Takes commands formatted as "#{[cmd]:[opt];[[cmd]:[opt];...]} and deals with them.

Command list:

  • P Set cursor to margin top-left.
  • Ps Save cursor position
  • Pr Restore cursor position.
  • P:#x,#y Set cursorX/Y to x, y.
  • X Set cursorX to margin left.
  • X:#x Set cursorX to x.
  • Y Set cursorY to margin top.
  • Y:#y Set cursorX to y.
  • c[ispx]:#val Set ink/shadow/paper/special color to val.
  • e[slbfr] Erase screen/line/backward/forward/rect
  • m:#l,#t,#r,#b Set all margins
  • m[ltrb]:#val Set margin to val.
  • p:#x,#y Move cursorX/Y by x, y.
  • w:#val Wait val frame.
  • x:#x Move cursorX by x.
  • y:#y Move cursorX by y.

Examples:

  • #{X:32} Move to x = 32;
  • #{ci:0x7FFF} Set ink color to white.
  • #{w:120;es;P} Wait 120 frames, clear screen, return to top of screen.
    Parameters:
    str Start of command. Assumes the initial "\{" is lobbed off already.
    Returns:
    pointer to after the parsed command.
    Note:
    Routine does text wrapping. Make sure margins are set.

    This function involves heavy (yet necessary) switching. Leave your sanity at the door before viewing.

    Todo:
    Scrolling and variables ?
    Todo:
    Restructure for safety checks.

void tte_erase_line ( void   ) 

Erase the whole line (within the margins).

Note:
Ponder: set paper color?

void tte_erase_screen ( void   ) 

Erase the screen (within the margins).

Note:
Ponder: set paper color?

POINT16 tte_get_text_size ( const char *  str  ) 

Get the size taken up by a string.

Parameters:
str String to check.
Returns:
width and height, packed into a POINT16.
Note:
This function ignores tte commands, so don't use on strings that use commands.

int tte_putc ( int  ch  ) 

Plot a single character; does wrapping too.

Parameters:
ch Character to plot (not glyph-id).
Returns:
Character width.
Note:
Overhead: ~70 cycles.

void tte_set_context ( TTC tc  ) 

Set the master context pointer.

int tte_write ( const char *  text  ) 

Render a string.

Parameters:
text String to parse and write.
Returns:
Number of parsed characters.


Generated on Mon Aug 25 17:03:57 2008 for libtonc by  doxygen 1.5.3