text: #include <gb/gb.h>
  #include <gb/drawing.h>
  #include <stdio.h>
  
  #define FONT_OFFSET 128
  
  
  const unsigned char font[] ={
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x38,0x08,0x38,0x08,0x38,0x08,0x38,0x08,0x38,0x38,0x38,0x08,0x38,0x08,0x38,0x38,
    0x00,0x00,0x36,0x12,0x36,0x12,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x3E,0x02,0x7F,0x3D,0xFF,0x66,0xFF,0x5A,0xF7,0x52,0xFF,0x61,0xFF,0xBF,0x7F,0x41,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x1E,0x02,0x1C,0x14,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
    0x18,0x08,0x3C,0x04,0xFF,0x01,0xFE,0x82,0x7E,0x02,0x7E,0x12,0x7E,0x3A,0x66,0x66,
    0x00,0x00,0x0C,0x04,0x18,0x08,0x18,0x08,0x18,0x08,0x18,0x08,0x1C,0x14,0x0C,0x0C,
    0x00,0x00,0x18,0x08,0x1C,0x14,0x0C,0x04,0x0C,0x04,0x0C,0x04,0x1C,0x0C,0x18,0x18,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x18,0x08,0x18,0x08,0x7E,0x02,0x7E,0x6E,0x18,0x08,0x18,0x18,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x04,0x1C,0x04,0x1C,0x14,0x18,0x08,
    0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x02,0x7E,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x04,0x1C,0x04,0x1C,0x1C,
    0x00,0x00,0x06,0x02,0x0E,0x02,0x1E,0x06,0x3C,0x0C,0x78,0x18,0x70,0x30,0x60,0x60,
    0x7E,0x02,0xFF,0x39,0xE7,0x21,0xE7,0x21,0xE7,0x21,0xE7,0x21,0xFF,0x83,0x7E,0x7E,
    0x1C,0x04,0x3C,0x04,0x3C,0x24,0x1C,0x04,0x1C,0x04,0x1C,0x04,0x3E,0x02,0x3E,0x3E,
    0x7E,0x02,0xFF,0x39,0xC7,0xC1,0x1E,0x02,0x7C,0x0C,0xF0,0x30,0xFF,0x01,0xFF,0xFF,
    0x7E,0x02,0xFF,0x39,0xC7,0xC1,0x3E,0x02,0x3F,0x39,0xC7,0x01,0xFF,0x83,0x7E,0x7E,
    0x0E,0x02,0x1E,0x02,0x3E,0x12,0x6E,0x22,0xFF,0x01,0xFF,0xF3,0x1F,0x01,0x1F,0x1F,
    0xFE,0x02,0xFE,0x3E,0xE0,0x20,0xFE,0x02,0xFF,0xF9,0xE7,0x21,0xFF,0x83,0x7E,0x7E,
    0x7E,0x02,0xFF,0x39,0xE7,0x27,0xFE,0x02,0xFF,0x39,0xE7,0x21,0xFF,0x83,0x7E,0x7E,
    0x7F,0x01,0xFF,0x79,0x8E,0x82,0x1C,0x04,0x1C,0x04,0x1C,0x04,0x1C,0x04,0x1C,0x1C,
    0x7E,0x02,0xFF,0x39,0xE7,0x21,0x7F,0x03,0xFF,0x39,0xE7,0x21,0xFF,0x83,0x7E,0x7E,
    0x7E,0x02,0xFF,0x39,0xE7,0x21,0x7F,0x01,0x0F,0x09,0xFF,0x39,0xFF,0x83,0x7E,0x7E,
    0x00,0x00,0x1C,0x04,0x1C,0x04,0x1C,0x1C,0x1C,0x04,0x1C,0x04,0x1C,0x1C,0x00,0x00,
    0x00,0x00,0x1C,0x04,0x1C,0x04,0x1C,0x1C,0x1C,0x04,0x1C,0x04,0x1C,0x14,0x18,0x08,
    0x00,0x00,0x0C,0x04,0x18,0x08,0x18,0x08,0x18,0x08,0x18,0x08,0x1C,0x14,0x0C,0x0C,
    0x00,0x00,0x00,0x00,0x7F,0x01,0x7F,0x7F,0x7F,0x01,0x7F,0x7F,0x00,0x00,0x00,0x00,
    0x00,0x00,0x18,0x08,0x1C,0x14,0x0C,0x04,0x0C,0x04,0x0C,0x04,0x1C,0x0C,0x18,0x18,
    0x3C,0x04,0x7E,0x3A,0x66,0x22,0x4E,0x46,0x1C,0x0C,0x18,0x18,0x18,0x08,0x18,0x18,
    0x7E,0x02,0xFF,0x7D,0xFF,0x41,0xFF,0x41,0xFF,0x41,0xFF,0x7D,0x7F,0x03,0x7E,0x7E,
    0x1C,0x04,0x1C,0x04,0x3E,0x02,0x3E,0x1A,0x7F,0x01,0x7F,0x3D,0xF7,0x10,0xFF,0xFF,
    0xFE,0x02,0xFF,0x99,0x77,0x11,0x7E,0x02,0x7F,0x19,0x77,0x11,0xFF,0x03,0xFE,0xFE,
    0x3E,0x02,0x7F,0x19,0x77,0x11,0x77,0x17,0x77,0x11,0x77,0x11,0x7F,0x43,0x3E,0x3E,
    0xFE,0x02,0xFF,0x99,0x77,0x11,0x77,0x11,0x77,0x11,0x77,0x11,0xFF,0x03,0xFE,0xFE,
    0xFE,0x02,0xFF,0x9D,0x73,0x13,0x7C,0x04,0x7C,0x1C,0x72,0x10,0xFF,0x03,0xFE,0xFE,
    0xFE,0x02,0xFF,0x9D,0x73,0x13,0x7C,0x04,0x7C,0x1C,0x70,0x10,0xF8,0x08,0xF8,0xF8,
    0x7E,0x02,0xFF,0x39,0xE7,0x21,0xE7,0x27,0xEF,0x21,0xEF,0x29,0xFF,0x81,0x7F,0x7F,
    0xFF,0x00,0x77,0x11,0x77,0x11,0x7F,0x01,0x77,0x11,0x77,0x11,0xFF,0x00,0x77,0x77,
    0x3E,0x02,0x3E,0x26,0x1C,0x04,0x1C,0x04,0x1C,0x04,0x1C,0x04,0x3E,0x02,0x3E,0x3E,
    0x1F,0x01,0x0F,0x03,0x0E,0x02,0x0E,0x02,0xEE,0x22,0xEE,0x22,0xFE,0x86,0x7C,0x7C,
    0xFF,0x09,0x7F,0x13,0x7C,0x04,0x78,0x08,0x7C,0x04,0x7E,0x12,0xFF,0x09,0xFF,0xFF,
    0xF0,0x00,0xF0,0x90,0x70,0x10,0x70,0x10,0x70,0x10,0x73,0x11,0xFF,0x03,0xFE,0xFE,
    0xE7,0x24,0xFF,0x99,0x7F,0x01,0x7F,0x01,0x7F,0x19,0x7F,0x19,0xFF,0x18,0xFF,0xFF,
    0xE7,0x20,0x77,0x11,0x7F,0x09,0x7F,0x01,0x7F,0x11,0x7F,0x19,0xF7,0x14,0x77,0x77,
    0x7E,0x02,0xFF,0x39,0xE7,0x21,0xE7,0x21,0xE7,0x21,0xE7,0x21,0xFF,0x83,0x7E,0x7E,
    0xFE,0x02,0x7F,0x19,0x77,0x11,0x77,0x11,0x7F,0x03,0x7E,0x1E,0xF8,0x08,0xF8,0xF8,
    0x7E,0x02,0xFF,0x39,0xE7,0x21,0xE7,0x21,0xFF,0x25,0xFF,0x3B,0xFF,0x85,0x7E,0x7E,
    0xFE,0x02,0xFF,0x99,0x77,0x11,0x7E,0x02,0x7F,0x19,0x77,0x11,0xFF,0x08,0xFF,0xFF,
    0x7E,0x02,0xFF,0x39,0xE7,0x27,0xFE,0x82,0x7F,0x79,0xE7,0x21,0xFF,0x83,0x7E,0x7E,
    0x7E,0x00,0xFF,0x66,0x1D,0x05,0x1C,0x04,0x1C,0x04,0x1C,0x04,0x3E,0x02,0x3E,0x3E,
    0xFF,0x10,0xFF,0x99,0x77,0x11,0x77,0x11,0x77,0x11,0x77,0x11,0x7F,0x43,0x3E,0x3E,
    0xE7,0x21,0xE7,0xA3,0x7E,0x12,0x7E,0x56,0x3C,0x04,0x3C,0x2C,0x18,0x08,0x18,0x18,
    0xFF,0x18,0xFF,0x99,0x7F,0x19,0x7F,0x01,0x7F,0x01,0x7F,0x19,0x77,0x35,0x63,0x63,
    0xF7,0x10,0xFF,0x99,0x7E,0x42,0x3C,0x24,0x3E,0x02,0x7F,0x19,0xF7,0x10,0xF7,0xF7,
    0xF7,0x10,0xF7,0x91,0x7E,0x42,0x3C,0x24,0x1C,0x04,0x1C,0x04,0x3E,0x02,0x3E,0x3E,
    0x7F,0x01,0xFF,0x73,0x1C,0x04,0x38,0x08,0x70,0x10,0xE2,0x20,0xFF,0x03,0xFE,0xFE,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xFF,0x00,0x7F,0x7F,0xE7,0x20,0x77,0x11,0x7F,0x09,0x7F,0x11,0xF7,0x14,0x77,0x77,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x02,0x7E,0x7E};
  
  /*
   * Image size: 0x10 x 0x70
   * Number of tiles (total - unique): 0x1C - 0x1C
   */
  
  /////////////////////////////////////////////////////
  //  void drawString(char str[], UBYTE x, UBYTE y){
  //  dibuja la cadena str en la posicion x, y
  //  en BKG si flag es 0 y en WIN si es 1
  //  si una palabra no entra en la linea, la dibuja
  //  en la siguiente
  //
  /////////////////////////////////////////////////////
  void drawString( char *str, UBYTE x, UBYTE y, UBYTE flag ){
  
      UBYTE posx, strx, nextlen;
      UBYTE posy, e;
      UBYTE c;
  
      strx = 0;
      posx = x;
      posy = y;
  
      // mientras la cadena no termine
      while(str[strx] != 0){
  
          // comprueba la longitud de la palabra actual de la cadena
          nextlen = 0;
          for( e = strx; (str[e] != ' ') && (str[e] != 0); e++)
              nextlen++;
  
          // si no cabe en pantalla bajamos de linea
          if ( posx + nextlen > 20){
              posx = 0;
              posy++;
          }
  
          // dibuja la palabra en la posicion que corresponda
          for(;(str[strx] != ' ') && (str[strx] != 0); strx++){
              c = str[strx] + FONT_OFFSET - 32;
              if( !flag )
                  set_bkg_tiles( posx, posy, 1, 1, (unsigned char *) &c);
              else
                  set_win_tiles( posx, posy, 1, 1, (unsigned char *) &c);
              posx++;
          }
  
          // dibuja un espacio en blanco entre las palabras de la cadena
          if ( posx != 0 ){
              c = ' ' + FONT_OFFSET - 32;
              if( !flag )
                  set_bkg_tiles( posx, posy, 1, 1, (unsigned char *) &c);
              else
                  set_win_tiles( posx, posy, 1, 1, (unsigned char *) &c);
              posx++;
          }
  
          // si no es el final de la cadena incrementamos la posicion
          if(str[strx] != 0 )
            strx++;
      }
  }
  
  void PaintDialogBox(UBYTE x, UBYTE y, UBYTE w, UBYTE h)
  {
  	UBYTE count = 3;	
  	unsigned char mystr[1];
  	
  	mystr[0] = 0x30+count;
  /*	
  	for( UBYTE i = x; i < x+w; i++ )
  	{
  		for( UBYTE j = y; j < y+h; j++ )
  		{
  			gotogxy(i,j);
  			gprintf("X");
  		}
  	}
  	*/
  	
  
  	drawString("HOLA BOLUDOO",x,y,1);
  	
  }
  
  void StartDialog()
  {
  	PaintDialogBox(5,5,5,5);
  }
  
  void main()
  {
  	set_bkg_data( FONT_OFFSET, 64,(unsigned char *)font);
  	SHOW_BKG;
  	SHOW_WIN;
  	SHOW_SPRITES;
  	DISPLAY_ON;
  	enable_interrupts();
  	
  	StartDialog();
  
  	while(1)
  	{
  					wait_vbl_done();
  
  	}
  }
  
  