PrintMiniFix

From WikiPrizm
Revision as of 15:43, 2 May 2012 by KermMartian (talk | contribs) (Created page with '== Synopsis == This is a routine that displays a text in small (glyph) font on the screen. === Definition === <nowiki>int PrintMiniFix( int x, int y, const char*Msg, const int …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Synopsis

This is a routine that displays a text in small (glyph) font on the screen.

Definition

int PrintMiniFix( int x, int y, const char*Msg, const int flags, const short color, const short bcolor ){
int i = 0, dx;
unsigned short width;
void*p;

   while ( Msg[ i ] ){
      p = GetMiniGlyphPtr( Msg[ i ], &width );
      dx = ( 12 - width ) / 2;
      if ( dx > 0 ) {
         PrintMiniGlyph( x, y, (void*)empty, flags, dx, 0, 0, 0, 0, color, bcolor, 0 );
      }else dx = 0;
      PrintMiniGlyph( x+dx, y, p, flags, width, 0, 0, 0, 0, color, bcolor, 0 );
      if ( width+dx < 12 ){
         PrintMiniGlyph( x+width+dx, y, (void*)empty, flags, 12-width-dx, 0, 0, 0, 0, color, bcolor, 0 );
      }
      x += 12;
      i++;
   }
   return x;
}
const short empty[18] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

Inputs

  • int x: X-coordinate of top-left of text
  • int y: Y-coordinate of top-left of text
  • const char* Msg: string to display
  • const int flags: (unknown)
  • const short color: Text foreground color
  • const short bcolor: Text background color

Outputs

Small font string on-screen.

Comments

Cheers to Shaun "Merthsoft" Mcfall for this routine.

Usage Example

PrintMiniFix(0, 175,
         "Oh look a string at the bottom of the screen.",
         0, COLOR_WHITE, COLOR_BLACK);