gtalleg

Top  Previous  Next

c:\harbour\source\rtl\gtalleg
gtalleg.c
TypeFunctionSourceLine
STATIC VOIDhb_gt_alleg_Error( char * szMsg )
static void hb_gt_alleg_Error( char * szMsg )
{
   s_fGtError = TRUE;
   hb_errInternal( 9997, "%s: %s", szMsg, allegro_error );
}
gtalleg.c212
STATIC BOOLhb_gt_alleg_CursorRect( int iRow, int iCol, int iStyle, int * piTop, int * piLeft, int * piBottom, int * piRight )
static BOOL hb_gt_alleg_CursorRect( int iRow, int iCol, int iStyle,
                                    int * piTop, int * piLeft,
                                    int * piBottom, int * piRight )
{
   *piLeft = s_iHBorder + iCol * s_byFontWidth;
   *piRight = *piLeft + s_byFontWidth - 1;
   *piTop = s_iVBorder + iRow * s_byFontSize;
   *piBottom = *piTop;

   switch( iStyle )
   {
      case SC_NORMAL:
         *piBottom += s_byFontSize - 1;
         *piTop = *piBottom - 1;
         break;

      case SC_INSERT:
         *piBottom += s_byFontSize - 1;
         *piTop = *piBottom - ( s_byFontSize / 2 ) + 1;
         break;

      case SC_UNDEF:
      case SC_SPECIAL1:
         *piBottom += s_byFontSize - 1;
         break;

      case SC_SPECIAL2:
         *piBottom += ( s_byFontSize / 2 ) - 1;
         break;

      default:
         return FALSE;
   }

   return TRUE;
}
gtalleg.c218
STATIC VOIDhb_gt_alleg_DoCursor( int iRow, int iCol, int iStyle )
static void hb_gt_alleg_DoCursor( int iRow, int iCol, int iStyle )
{
   int iTop, iLeft, iBottom, iRight;

   /* Hide the previous cursor */
   if( s_iCursorStyle != SC_NONE &&
       hb_gt_alleg_CursorRect( s_iCurRow, s_iCurCol, s_iCursorStyle,
                               &iTop, &iLeft, &iBottom, &iRight ) )
   {
      al_scare_mouse_area( iLeft, iTop, iRight, iBottom );
      al_blit( s_bmp, al_screen, iLeft, iTop, iLeft, iTop, iRight - iLeft + 1, iBottom - iTop + 1 );
      al_unscare_mouse();
   }
   /* Show the new one */
   if( iStyle != SC_NONE &&
       hb_gt_alleg_CursorRect( iRow, iCol, iStyle,
                               &iTop, &iLeft, &iBottom, &iRight ) )
   {
      al_drawing_mode( DRAW_MODE_XOR, NULL, 0, 0 );
      al_scare_mouse_area( iLeft, iTop, iRight, iBottom );
      al_draw_rect_fill( al_screen, iLeft, iTop, iRight, iBottom, s_pClr[7] );
      al_unscare_mouse();
      al_drawing_mode( DRAW_MODE_SOLID, NULL, 0, 0 );
   }
   s_iCurRow = iRow;
   s_iCurCol = iCol;
   s_iCursorStyle = iStyle;
}
gtalleg.c255
STATIC VOIDhb_gt_alleg_ScreenUpdate( PHB_GT pGT )
static void hb_gt_alleg_ScreenUpdate( PHB_GT pGT )
{
   int iRow, iCol, iStyle;
   BOOL fPix, fCursor;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_ScreenUpdate(%p)", pGT));

   HB_GTSELF_GETSCRCURSOR( pGT, &iRow, &iCol, &iStyle );
   fPix = s_GFXUpd.iTop <= s_GFXUpd.iBottom &&
          s_GFXUpd.iLeft <= s_GFXUpd.iRight;
   fCursor = s_iCurRow != iRow || s_iCurCol != iCol || s_iCursorStyle != iStyle;

   if( fPix || fCursor )
   {
      al_acquire_screen();

      if( fPix )
      {
         al_scare_mouse_area( s_GFXUpd.iLeft, s_GFXUpd.iTop,
                              s_GFXUpd.iRight, s_GFXUpd.iBottom );
         al_blit( s_bmp, al_screen, s_GFXUpd.iLeft, s_GFXUpd.iTop,
                                    s_GFXUpd.iLeft, s_GFXUpd.iTop,
                                    s_GFXUpd.iRight - s_GFXUpd.iLeft + 1,
                                    s_GFXUpd.iBottom - s_GFXUpd.iTop + 1 );
         al_unscare_mouse();
      }
      if( fCursor )
      {
         hb_gt_alleg_DoCursor( iRow, iCol, iStyle );
      }
      al_release_screen();

      s_GFXUpd.iTop = s_iScrHeight * s_byFontSize;
      s_GFXUpd.iLeft = s_iScrWidth * s_byFontWidth;
      s_GFXUpd.iBottom = 0;
      s_GFXUpd.iRight = 0;
   }
}
gtalleg.c284
STATIC BOOLhb_gt_alleg_InitializeScreen( PHB_GT pGT, int iRows, int iCols, BOOL lClearInit )
static BOOL hb_gt_alleg_InitializeScreen( PHB_GT pGT, int iRows, int iCols, BOOL lClearInit )
{
   PHB_FNAME pFileName;
   int iRet = 1, iWidth, iHeight;  /* Don't remove iRet, ixFP and iyFP initializers! */
   short ixFP = 0, iyFP = 0;
   BOOL lMode = FALSE, lPrev = s_fInit;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_InitializeScreen(%p,%d,%d,%d)", pGT, iRows, iCols, (int) lClearInit ));

   if( s_fGtError )
   {
      return FALSE;
   }

   if( lPrev )
   {
      al_destroy_bitmap(s_bmp);
      s_bmp = NULL;
   }

   if( s_iGFXWidth != 0 && s_iGFXHeight != 0 )
   {
      iWidth = (int) s_iGFXWidth;
      iHeight = (int) s_iGFXHeight;
   }
   else
   {
      iWidth = s_byFontWidth * iCols;
      iHeight = s_byFontSize * iRows;
   }

   if( iRows > 11 && iCols > 23 && iRows < 129 && iCols < 257 )
   {
#if defined(AL_GFX_XWINDOWS)
      HB_TRACE(HB_TR_DEBUG, ("trying X DGA2 mode"));
      iRet = al_set_gfx_mode( AL_GFX_XDGA2, iWidth, iHeight, 0, 0 );
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying X DGA mode"));
         iRet = al_set_gfx_mode( AL_GFX_XDGA, iWidth, iHeight, 0, 0 );
      }
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying X Windows mode"));
         iRet = al_set_gfx_mode( AL_GFX_XWINDOWS, iWidth, iHeight, 0, 0 );
      }
#endif
#if defined (ALLEGRO_UNIX) || defined(ALLEGRO_LINUX) || defined(ALLEGRO_DOS)
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying VBE/AF mode"));
         iRet = al_set_gfx_mode( AL_GFX_VBEAF, iWidth, iHeight, 0, 0 );
      }
#endif
#if (defined(ALLEGRO_UNIX) || defined(ALLEGRO_LINUX)) && defined(AL_GFX_FBCON)
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying fb console mode"));
         iRet = al_set_gfx_mode( AL_GFX_FBCON, iWidth, iHeight, 0, 0 );
      }
#endif
      /* Trying safe (slower) modes */
      /* Try a windowed mode first */
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying autodetect windowed mode"));
         iRet = al_set_gfx_mode( AL_GFX_AUTODETECT_WINDOWED, iWidth, iHeight, 0, 0 );
      }
#ifdef ALLEGRO_WINDOWS
      /* GDI is slower, but it is more likely to bring a windowed mode than DirectX */
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying GDI windowed mode"));
         iRet = al_set_gfx_mode( AL_GFX_GDI, iWidth, iHeight, 0, 0 );
      }
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying DirectX windowed mode"));
         iRet = al_set_gfx_mode( AL_GFX_DIRECTX_WIN, iWidth, iHeight, 0, 0 );
      }
#endif
      if( iRet != 0 )
      {
         HB_TRACE(HB_TR_DEBUG, ("trying autodetect console mode"));
         iRet = al_set_gfx_mode( AL_GFX_AUTODETECT, iWidth, iHeight, 0, 0 );
      }
      if( iRet != 0 )
      {
      /* If that fails (ie, plain DOS or Linux VESA Framebuffer)
         ensure to get any available gfx mode */
         HB_TRACE(HB_TR_DEBUG, ("trying safe mode"));
         iRet = al_set_gfx_mode(AL_GFX_SAFE, iWidth, iHeight, 0, 0 );
      }
      if( iRet != 0 )  /* Doh! */
      {
         if( lPrev )
         {
            iCols = s_iScrWidth;
            iRows = s_iScrHeight;
         }
         else
         {
            hb_gt_alleg_Error( "Could not switch to graphic mode" );
         }
      }
      else
      {
         lMode = TRUE;
      }

      pFileName = hb_fsFNameSplit(hb_cmdargARGV()[0]);
      al_set_window_title(pFileName->szName);
      hb_xfree( pFileName );

      if( !lPrev )
      {
         al_install_timer();
         al_install_keyboard();
         s_iMsButtons = al_install_mouse();
      }

      s_fInit = TRUE;
      s_mouseBound.iLeft = 0;
      s_mouseBound.iTop = 0;
      s_mouseBound.iRight = AL_SCREEN_W - 1;
      s_mouseBound.iBottom = AL_SCREEN_H - 1;
      s_mouseButtonsState = al_mouse_b;
      al_show_mouse(al_screen);
      s_iScrWidth = iCols;
      s_iScrHeight = iRows;

      /* WAS: Center console in screen if we got a larger resolution than requested
       * NOW: Calculate proper font size
       * eg: Linux vesafb (doesn't support mode switching)
       *     or for DOS, we'll mostly request unavailable resolutions
       */
      if( AL_SCREEN_W != s_byFontWidth * s_iScrWidth )
      {
         ixFP = (BYTE) (AL_SCREEN_W / s_iScrWidth) * 2;
      }

      if( AL_SCREEN_H != s_byFontSize * s_iScrHeight )
      {
         iyFP = (BYTE) (AL_SCREEN_H / s_iScrHeight);
         if( iyFP & 1 )
         {
            iyFP--;
         }
      }

      if( ixFP || iyFP )
      {
         if( !ixFP )
         {
            ixFP = iyFP;
         }
         if( !iyFP )
         {
            iyFP = ixFP;
         }
         s_byFontSize = ( ixFP < iyFP ? ixFP : iyFP );
         s_byFontWidth = s_byFontSize / 2;
      }

      s_mousePos.iCol = al_mouse_x / s_byFontWidth;
      s_mousePos.iRow = al_mouse_y / s_byFontSize;
      s_GFXUpd.iTop = s_iScrHeight;
      s_GFXUpd.iLeft = s_iScrWidth;
      s_GFXUpd.iBottom = 0;
      s_GFXUpd.iRight = 0;
      s_CLIP.iTop = 0;
      s_CLIP.iLeft = 0;
      s_CLIP.iBottom = AL_SCREEN_H - 1;
      s_CLIP.iRight = AL_SCREEN_W - 1;
      s_iCurCol = 0;
      s_iCurRow = 0;
      s_iCursorStyle = SC_NONE;
      ssfSetFontSize(&s_ssfDefaultFont, s_byFontSize);
      s_pClr[ 0] = al_make_color(0x00, 0x00, 0x00);  /* black */
      s_pClr[ 1] = al_make_color(0x00, 0x00, 0xAA);  /* blue */
      s_pClr[ 2] = al_make_color(0x00, 0xAA, 0x00);  /* green */
      s_pClr[ 3] = al_make_color(0x00, 0xAA, 0xAA);  /* cyan */
      s_pClr[ 4] = al_make_color(0xAA, 0x00, 0x00);  /* red */
      s_pClr[ 5] = al_make_color(0xAA, 0x00, 0xAA);  /* magenta */
      s_pClr[ 6] = al_make_color(0xAA, 0x55, 0x00);  /* brown */
      s_pClr[ 7] = al_make_color(0xAA, 0xAA, 0xAA);  /* white */
      s_pClr[ 8] = al_make_color(0x55, 0x55, 0x55);  /* gray */
      s_pClr[ 9] = al_make_color(0x55, 0x55, 0xFF);  /* bright blue */
      s_pClr[10] = al_make_color(0x55, 0xFF, 0x55);  /* bright green */
      s_pClr[11] = al_make_color(0x55, 0xFF, 0xFF);  /* bright cyan */
      s_pClr[12] = al_make_color(0xFF, 0x55, 0x55);  /* bright red */
      s_pClr[13] = al_make_color(0xFF, 0x55, 0xFF);  /* bright magenta */
      s_pClr[14] = al_make_color(0xFF, 0xFF, 0x55);  /* yellow */
      s_pClr[15] = al_make_color(0xFF, 0xFF, 0xFF);  /* bright white */

      s_bmp = al_create_system_bitmap(AL_SCREEN_W, AL_SCREEN_H);
      if( s_bmp == NULL )
      {
         s_bmp = al_create_bitmap(AL_SCREEN_W, AL_SCREEN_H);
         if( s_bmp == NULL )
         {
            hb_gt_alleg_Error( "Could not allocate double buffer bitmap" );
         }
      }

      if( !lClearInit )
      {
         BYTE bColor = s_pClr[ ( HB_GTSELF_GETCLEARCOLOR( pGT ) >> 4 ) & 0x0f ];
         al_clear_to_color( s_bmp, bColor );
         al_clear_to_color( al_screen, bColor );
      }

      HB_GTSELF_RESIZE( pGT, s_iScrHeight, s_iScrWidth );
      HB_GTSELF_EXPOSEAREA( pGT, 0, 0, s_iScrHeight, s_iScrWidth );
      HB_GTSELF_REFRESH( pGT );
   }

   s_iGFXWidth = 0;
   s_iGFXHeight = 0;

   return lMode;
}
gtalleg.c323
STATIC VOIDhb_gt_alleg_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE hFilenoStderr )
static void hb_gt_alleg_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE hFilenoStderr )
{
   int iRet;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_Init(%p,%p,%p,%p)", pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr));

   ssfCreateThinFont( &s_ssfDefaultFont );

   s_iCursorStyle = SC_NONE;
   s_fMakeInit = s_fGtError = FALSE;

   if( allegro_init() != 0 )
   {
      hb_gt_alleg_Error( "Screen driver initialization failure" );
   }

   iRet = al_desktop_color_depth();

   if( iRet > 0 )
   {
      al_set_color_depth( iRet );
   }

   HB_GTSUPER_INIT( pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr );
   HB_GTSELF_RESIZE( pGT, s_iScrHeight, s_iScrWidth );
}
gtalleg.c546
STATIC VOIDhb_gt_alleg_Exit( PHB_GT pGT )
static void hb_gt_alleg_Exit( PHB_GT pGT )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_Exit(%p)", pGT));

   HB_GTSUPER_EXIT( pGT );

   if( s_bmp )
   {
      al_destroy_bitmap( s_bmp );
      s_bmp = NULL;
   }
}
gtalleg.c573
STATIC CHAR *hb_gt_alleg_Version( PHB_GT pGT, int iType )
static char * hb_gt_alleg_Version( PHB_GT pGT, int iType )
{
   HB_SYMBOL_UNUSED( pGT );

   if( iType == 0 )
      return HB_GT_DRVNAME( HB_GT_NAME );

   return "Harbour Terminal: Portable Allegro GUI console";
}
gtalleg.c586
STATIC BOOLhb_gt_alleg_SetMode( PHB_GT pGT, int iRows, int iCols )
static BOOL hb_gt_alleg_SetMode( PHB_GT pGT, int iRows, int iCols )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_SetMode(%p,%d,%d)", pGT, iRows, iCols));

   HB_SYMBOL_UNUSED( pGT );

   return hb_gt_alleg_InitializeScreen( pGT, iRows, iCols, TRUE );
}
gtalleg.c596
STATIC INThb_gt_alleg_ReadKey( PHB_GT pGT, int iEventMask )
static int hb_gt_alleg_ReadKey( PHB_GT pGT, int iEventMask )
{
   int nKey = 0;
   int i, iMseCol, iMseRow;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_ReadKey(%p,%d)", pGT, iEventMask));

   HB_SYMBOL_UNUSED( iEventMask );

   GT_SCREENINIT();

   if( al_mouse_needs_poll() )
   {
      al_poll_mouse();
   }

   iMseCol = al_mouse_x / s_byFontWidth;
   iMseRow = al_mouse_y / s_byFontSize;
   if( iMseCol != s_mousePos.iCol || iMseRow != s_mousePos.iRow )
   {
      s_mousePos.iCol = iMseCol;
      s_mousePos.iRow = iMseRow;
      nKey = K_MOUSEMOVE;
   }

   if( nKey == 0 && al_mouse_b != s_mouseButtonsState )
   {
      if( ( al_mouse_b & 1 ) != ( s_mouseButtonsState & 1 ) )
      {
         if( al_mouse_b & 1 )
            nKey = K_LBUTTONDOWN;
         else
            nKey = K_LBUTTONUP;
      }
      else if( ( al_mouse_b & 2 ) != ( s_mouseButtonsState & 2 ) )
      {
         if( al_mouse_b & 2 )
            nKey = K_RBUTTONDOWN;
         else
            nKey = K_RBUTTONUP;
      }
      else if( ( al_mouse_b & 4 ) != ( s_mouseButtonsState & 4 ) )
      {
         if( al_mouse_b & 4 )
            nKey = K_MBUTTONDOWN;
         else
            nKey = K_MBUTTONUP;
      }
      /* We need to define INKEY_M* & K_MBUTTON* in inkey.ch ! */
      s_mouseButtonsState = al_mouse_b;
   }

   if( nKey == 0 )
   {
      if( al_keyboard_needs_poll() )
      {
         al_poll_keyboard();
      }

      if( al_key_pressed() )
      {
         nKey = al_read_key();
      }

#ifdef DEBUG
      if( nKey != 0 )
      {
         /* Good standard debuging... */
         printf("gtAlleg: Scancode: %d (0x%0x) ascii: %d (0x%0x) raw: %d (0x%0x)\n", nKey>>8, nKey>>8, nKey&0xff, nKey&0xff, nKey, nKey);
      }
#endif

      if( ( ( nKey & 255 ) == 2 || ( nKey & 255 ) == 3 )  && ( nKey >> 8 ) > 31 )  /* K_CTRL_ + navigation key */
      {
         for( i = 0; i < GT_CTRL_TABLE_SIZE; i++ )
         {
            if( ( nKey >> 8 ) == s_CtrlTable[i].al_key )
            {
               nKey = s_CtrlTable[i].xhb_key;
               break;
            }
         }
      }
      else if( ( nKey != 0 ) && ( ( nKey & 255 ) < 32 ) && ( ( nKey & 255 ) == ( nKey >> 8 ) ) )  /* K_CTRL_A .. Z */
      {
#ifdef HB_NEW_KCTRL
        nKey = 512 + ( nKey & 255 );
#else
        nKey = nKey & 255;
#endif
      }
      else if( ( ( ( nKey & 255 ) == 1 ) || ( ( nKey & 255 ) == 4 ) ) && ( ( ( nKey >> 8 ) >= AL_KEY_F1 ) && ( ( nKey >> 8 ) <= AL_KEY_F12 ) ) )  /* K_SH_F1 .. F12, K_ALT_F1..F12 */
      {
         if( ( nKey & 255 ) == 1 )
         {
            int iFKeys[12] = {K_SH_F1, K_SH_F2, K_SH_F2, K_SH_F4, K_SH_F5, K_SH_F6,
                              K_SH_F7, K_SH_F8, K_SH_F9, K_SH_F10, K_SH_F11, K_SH_F12};
            nKey   = iFKeys[( nKey >> 8 ) - AL_KEY_F1];
         }
         else
         {
            int iFKeys[12] = {K_ALT_F1, K_ALT_F2, K_ALT_F2, K_ALT_F4, K_ALT_F5, K_ALT_F6,
                              K_ALT_F7, K_ALT_F8, K_ALT_F9, K_ALT_F10, K_ALT_F11, K_ALT_F12};
            nKey   = iFKeys[( nKey >> 8 ) - AL_KEY_F1];
         }
      }
      else if( nKey & 255 )
      {
         nKey = nKey & 255;
      }
      else if( nKey != 0 )
      {
         for( i = 0; i < GT_KEY_TABLE_SIZE; i++ )
         {
            if( ( nKey >> 8 ) == s_KeyTable[i].al_key )
            {
               nKey = s_KeyTable[i].xhb_key;
               break;
            }
         }
      }
   }

   return nKey;
}
gtalleg.c605
STATIC BOOLhb_gt_alleg_mouse_IsPresent( PHB_GT pGT )
static BOOL hb_gt_alleg_mouse_IsPresent( PHB_GT pGT )
{
   HB_SYMBOL_UNUSED( pGT );

   return TRUE;
}
gtalleg.c731
STATIC VOIDhb_gt_alleg_mouse_GetPos( PHB_GT pGT, int * piRow, int * piCol )
static void hb_gt_alleg_mouse_GetPos( PHB_GT pGT, int * piRow, int * piCol )
{
   GT_SCREENINIT();

   if( al_mouse_needs_poll() )
   {
      al_poll_mouse();
   }

   *piRow = al_mouse_y / s_byFontSize;
   *piCol = al_mouse_x / s_byFontWidth;
}
gtalleg.c738
STATIC VOIDhb_gt_alleg_mouse_SetPos( PHB_GT pGT, int iRow, int iCol )
static void hb_gt_alleg_mouse_SetPos( PHB_GT pGT, int iRow, int iCol )
{
   GT_SCREENINIT();

   al_position_mouse(iCol * s_byFontWidth, iRow * s_byFontSize);
}
gtalleg.c751
STATIC BOOLhb_gt_alleg_mouse_ButtonState( PHB_GT pGT, int iButton )
static BOOL hb_gt_alleg_mouse_ButtonState( PHB_GT pGT, int iButton )
{
   GT_SCREENINIT();

   if( al_mouse_needs_poll() )
   {
      al_poll_mouse();
   }

   return ( al_mouse_b & ( 1 << ( iButton - 1 ) ) ) != 0;
}
gtalleg.c758
STATIC INThb_gt_alleg_mouse_CountButton( PHB_GT pGT )
static int hb_gt_alleg_mouse_CountButton( PHB_GT pGT )
{
   GT_SCREENINIT();

   return s_iMsButtons;
}
gtalleg.c770
STATIC VOIDhb_gt_alleg_mouse_SetBounds( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static void hb_gt_alleg_mouse_SetBounds( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
   GT_SCREENINIT();

   if( iTop > -1 && iTop * s_byFontSize < AL_SCREEN_H )
   {
      s_mouseBound.iTop = iTop * s_byFontSize;
   }

   if( iLeft > -1 && iLeft * s_byFontWidth < AL_SCREEN_W )
   {
      s_mouseBound.iLeft = iLeft * s_byFontWidth;
   }

   if( iBottom >= iTop && iBottom * s_byFontSize < AL_SCREEN_H )
   {
      s_mouseBound.iBottom = iBottom * s_byFontSize;
   }

   if( iRight >= iLeft && iRight * s_byFontWidth < AL_SCREEN_W )
   {
      s_mouseBound.iRight = iRight * s_byFontWidth;
   }

   al_set_mouse_range( s_mouseBound.iLeft, s_mouseBound.iTop,
                       s_mouseBound.iRight, s_mouseBound.iBottom );
}
gtalleg.c777
STATIC VOIDhb_gt_alleg_mouse_GetBounds( PHB_GT pGT, int *piTop, int *piLeft, int *piBottom, int *piRight )
static void hb_gt_alleg_mouse_GetBounds( PHB_GT pGT, int *piTop, int *piLeft, int *piBottom, int *piRight )
{
   GT_SCREENINIT();

   *piTop = s_mouseBound.iTop;
   *piLeft = s_mouseBound.iLeft;
   *piBottom = s_mouseBound.iBottom;
   *piRight = s_mouseBound.iRight;
}
gtalleg.c805
STATIC BOOLhb_gt_alleg_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
static BOOL hb_gt_alleg_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
{
   int iWidth, iHeight, iValue;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_Info(%p,%d,%p)", pGT, iType, pInfo));

   switch( iType )
   {
      case HB_GTI_FULLSCREEN:
      case HB_GTI_KBDSUPPORT:
      case HB_GTI_ISGRAPHIC:
         pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE );
         break;

      case HB_GTI_INPUTFD:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, -1 );
         break;

      case HB_GTI_SCREENWIDTH:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_fInit ?
                                 AL_SCREEN_W : s_byFontWidth * s_iScrWidth );
         iWidth = hb_itemGetNI( pInfo->pNewVal );
         if( iWidth > 0 )
         {
            s_iGFXWidth = iWidth;
            /* hb_gt_alleg_InitializeScreen( pGT, s_iScrHeight, s_iScrWidth, s_fInit ); */
         }
         break;

      case HB_GTI_SCREENHEIGHT:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_fInit ?
                                 AL_SCREEN_H : s_byFontSize * s_iScrHeight );
         iHeight = hb_itemGetNI( pInfo->pNewVal );
         if( iHeight > 0 )
         {
            s_iGFXHeight = iHeight;
            hb_gt_alleg_InitializeScreen( pGT, s_iScrHeight, s_iScrWidth, s_fInit );
         }
         break;

      case HB_GTI_SCREENDEPTH:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_fInit ?
               al_bitmap_color_depth( al_screen ) : al_desktop_color_depth() );
         iValue = hb_itemGetNI( pInfo->pNewVal );
         if( iValue == 8 || iValue == 15 || iValue == 16 ||
             iValue == 24 || iValue == 32 )
         {
            al_set_color_depth( iValue );
            hb_gt_alleg_InitializeScreen( pGT, s_iScrHeight, s_iScrWidth, s_fInit );
         }
         break;

      case HB_GTI_FONTSIZE:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_byFontSize );
         iValue = hb_itemGetNI( pInfo->pNewVal );
         if( iValue > 0 && iValue < 256 )
         {
            s_byFontSize = ( BYTE ) iValue;
            s_byFontWidth = s_byFontSize / 2;
            hb_gt_alleg_InitializeScreen( pGT, s_iScrHeight, s_iScrWidth, s_fInit );
         }
         break;

      case HB_GTI_FONTWIDTH:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_byFontWidth );
         break;

      case HB_GTI_DESKTOPWIDTH:
         al_get_desktop_resolution( &iWidth, &iHeight );
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, iWidth );
         break;

      case HB_GTI_DESKTOPHEIGHT:
         al_get_desktop_resolution( &iWidth, &iHeight );
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, iHeight );
         break;

      case HB_GTI_DESKTOPDEPTH:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, al_desktop_color_depth() );
         break;

      case HB_GTI_KBDSHIFTS:
         if( al_keyboard_needs_poll() )
         {
            al_poll_keyboard();
         }
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, al_key_shifts );
         if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC )
         {
            al_set_keyboard_leds( hb_itemGetNI( pInfo->pNewVal ) );
         }
         break;

      case HB_GTI_WINTITLE:
         if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
         {
            al_set_window_title( hb_itemGetCPtr( pInfo->pNewVal ) );
         }
         break;

      case HB_GTI_VIEWMAXWIDTH:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_iScrWidth );
         break;

      case HB_GTI_VIEWMAXHEIGHT:
         pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_iScrHeight );
         break;

      default:
         return HB_GTSUPER_INFO( pGT, iType, pInfo );
   }

   return TRUE;
}

gtalleg.c815
STATIC INThb_gt_alleg_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
static int hb_gt_alleg_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
{
   int iRet = 1;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_gfx_Primitive(%p,%d,%d,%d,%d,%d,%d)", pGT, iType, iTop, iLeft, iBottom, iRight, iColor));

   GT_SCREENINIT();
   HB_GTSELF_REFRESH( pGT );

   switch( iType )
   {
      case GFX_ACQUIRESCREEN:
         al_acquire_bitmap(s_bmp);
         break;

      case GFX_RELEASESCREEN:
         al_release_bitmap(s_bmp);
         break;

      case GFX_MAKECOLOR:
         iRet = al_make_color(iTop, iLeft, iBottom);
         break;

      case GFX_CLIPTOP:
         iRet = s_CLIP.iTop;
         break;

      case GFX_CLIPLEFT:
         iRet = s_CLIP.iLeft;
         break;

      case GFX_CLIPBOTTOM:
         iRet = s_CLIP.iBottom;
         break;

      case GFX_CLIPRIGHT:
         iRet = s_CLIP.iRight;
         break;

      case GFX_SETCLIP:
         al_set_clip(s_bmp, iLeft, iTop, iRight, iBottom);
         s_CLIP.iTop = iTop;
         s_CLIP.iLeft = iLeft;
         s_CLIP.iBottom = iBottom;
         s_CLIP.iRight = iRight;
         break;

      case GFX_DRAWINGMODE:
         iRet = GFX_MODE_SOLID;
         break;

      case GFX_GETPIXEL:
         iRet = al_get_pixel(s_bmp, iLeft, iTop);
         break;

      case GFX_PUTPIXEL:
         al_acquire_bitmap(s_bmp);
         al_put_pixel(s_bmp, iLeft, iTop, iBottom);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop,iLeft,iTop,iLeft);
         break;

      case GFX_LINE:
         al_acquire_bitmap(s_bmp);
         if( iLeft == iRight )
            al_draw_vline(s_bmp, iLeft, iTop, iBottom, iColor);
         else if( iTop == iBottom )
            al_draw_hline(s_bmp, iLeft, iTop, iRight, iColor);
         else
            al_draw_line(s_bmp, iLeft, iTop, iRight, iBottom, iColor);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop,iLeft,iBottom,iRight);
         break;

      case GFX_RECT:
         al_acquire_bitmap(s_bmp);
         al_draw_rect(s_bmp, iLeft, iTop, iRight, iBottom, iColor);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop,iLeft,iBottom,iRight);
         break;

      case GFX_FILLEDRECT:
         al_acquire_bitmap(s_bmp);
         al_draw_rect_fill(s_bmp, iLeft, iTop, iRight, iBottom, iColor);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop,iLeft,iBottom,iRight);
         break;

      case GFX_CIRCLE:
         al_acquire_bitmap(s_bmp);
         al_draw_circle(s_bmp, iLeft, iTop, iBottom, iRight);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop-iBottom,iLeft-iBottom,iTop+iBottom,iLeft+iBottom);
         break;

      case GFX_FILLEDCIRCLE:
         al_acquire_bitmap(s_bmp);
         al_draw_circle_fill(s_bmp, iLeft, iTop, iBottom, iRight);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop-iBottom,iLeft-iBottom,iTop+iBottom,iLeft+iBottom);
         break;

      case GFX_ELLIPSE:
         al_acquire_bitmap(s_bmp);
         al_draw_ellipse(s_bmp, iLeft, iTop, iRight, iBottom, iColor);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop-iBottom,iLeft-iRight,iTop+iBottom,iLeft+iRight);
         break;

      case GFX_FILLEDELLIPSE:
         al_acquire_bitmap(s_bmp);
         al_draw_ellipse_fill(s_bmp, iLeft, iTop, iRight, iBottom, iColor);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(iTop-iBottom,iLeft-iRight,iTop+iBottom,iLeft+iRight);
         break;

      case GFX_FLOODFILL:
         al_acquire_bitmap(s_bmp);
         al_floodfill(s_bmp, iLeft, iTop, iBottom);
         al_release_bitmap(s_bmp);
         GT_UPD_GFXRECT(0,0,s_iScrHeight*s_byFontSize,s_iScrWidth*s_byFontWidth);
         break;

      default:
         return HB_GTSUPER_GFXPRIMITIVE( pGT, iType, iTop, iLeft, iBottom, iRight, iColor );
   }

   if( HB_GTSELF_DISPCOUNT( pGT ) == 0 )
   {
      hb_gt_alleg_ScreenUpdate( pGT );
   }

   return iRet;
}
gtalleg.c932
STATIC VOIDhb_gt_alleg_gfx_Text( PHB_GT pGT, int iTop, int iLeft, char * cBuf, int iColor, int iSize, int iWidth )
static void hb_gt_alleg_gfx_Text( PHB_GT pGT, int iTop, int iLeft, char * cBuf, int iColor, int iSize, int iWidth )
{
   int iBottom, iRight;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_alleg_gfx_Text(%p,%d,%d,%s,%d,%d,%d)", pGT, iTop, iLeft, cBuf, iColor, iSize, iWidth));

   HB_SYMBOL_UNUSED( iWidth );

   GT_SCREENINIT();
   HB_GTSELF_REFRESH( pGT );

   if( iSize )
   {
      ssfSetFontSize( &s_ssfDefaultFont, (unsigned short) iSize );
   }

   iRight = iLeft + strlen(cBuf) * ( s_ssfDefaultFont.fsize / 2 ) - 1;
   iBottom = iTop + s_ssfDefaultFont.fsize - 1;

   al_acquire_bitmap(s_bmp);
   ssfDrawText( s_bmp, &s_ssfDefaultFont, cBuf, iLeft, iTop, iColor );
   al_release_bitmap(s_bmp);
   GT_UPD_GFXRECT( iTop, iLeft, iBottom, iRight );

   if( iSize )
   {
      ssfSetFontSize( &s_ssfDefaultFont, s_byFontSize );
   }

   if( HB_GTSELF_DISPCOUNT( pGT ) == 0 )
   {
      hb_gt_alleg_ScreenUpdate( pGT );
   }
}

gtalleg.c1067
STATIC VOIDhb_gt_alleg_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
static void hb_gt_alleg_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize )
{
   BYTE bColor, bAttr;
   USHORT usChar;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_alleg_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) );

   if( s_fInit )
   {
      int iPosX = iCol * s_byFontWidth, iPosY = iRow * s_byFontSize;

      if( s_iCursorStyle != SC_NONE && s_iCurRow == iRow &&
          s_iCurCol >= iCol && s_iCurCol <= iCol + iSize - 1 )
      {
         s_iCursorStyle = SC_NONE;
      }
      GT_UPD_GFXRECT( iPosY, iPosX, iPosY + s_byFontSize - 1, iPosX + iSize * s_byFontWidth - 1 );

      while( iSize-- )
      {
         if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &bColor, &bAttr, &usChar ) )
            break;
         al_draw_rect_fill( s_bmp,  iPosX, iPosY, iPosX + s_byFontWidth - 1, iPosY + s_byFontSize - 1, s_pClr[bColor >> 4] );
         ssfDrawChar( s_bmp, &s_ssfDefaultFont, ( BYTE ) usChar, iPosX, iPosY, s_pClr[bColor & 0x0F] );
         iPosX += s_byFontWidth;
      }
   }
   else if( !s_fMakeInit )
   {
      BYTE bDefColor = HB_GTSELF_GETCOLOR( pGT );

      while( iSize-- )
      {
         if( !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol++, &bColor, &bAttr, &usChar ) )
            break;

         if( bColor != bDefColor || usChar != ' ' )
         {
            s_fMakeInit = TRUE;
            break;
         }
      }
   }
}
gtalleg.c1104
STATIC VOIDhb_gt_alleg_Refresh( PHB_GT pGT )
static void hb_gt_alleg_Refresh( PHB_GT pGT )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_alleg_Refresh(%p)", pGT ) );

   if( !s_fGtError )
   {
      if( s_fInit )
      {
         al_acquire_bitmap(s_bmp);
         HB_GTSUPER_REFRESH( pGT );
         al_release_bitmap(s_bmp);
         if( HB_GTSELF_DISPCOUNT( pGT ) == 0 )
         {
            hb_gt_alleg_ScreenUpdate( pGT );
         }
      }
      else
      {
         HB_GTSUPER_REFRESH( pGT );
         if( s_fMakeInit )
         {
            s_fMakeInit = FALSE;
            GT_SCREENINIT();
         }
      }
   }
}


gtalleg.c1149
STATIC BOOLhb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
{
   HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable));

   pFuncTable->Init                       = hb_gt_alleg_Init;
   pFuncTable->Exit                       = hb_gt_alleg_Exit;
   pFuncTable->SetMode                    = hb_gt_alleg_SetMode;
   pFuncTable->Redraw                     = hb_gt_alleg_Redraw;
   pFuncTable->Refresh                    = hb_gt_alleg_Refresh;
   pFuncTable->Version                    = hb_gt_alleg_Version;
   pFuncTable->Info                       = hb_gt_alleg_Info;

   pFuncTable->ReadKey                    = hb_gt_alleg_ReadKey;

   pFuncTable->MouseIsPresent             = hb_gt_alleg_mouse_IsPresent;
   pFuncTable->MouseGetPos                = hb_gt_alleg_mouse_GetPos;
   pFuncTable->MouseSetPos                = hb_gt_alleg_mouse_SetPos;
   pFuncTable->MouseSetBounds             = hb_gt_alleg_mouse_SetBounds;
   pFuncTable->MouseGetBounds             = hb_gt_alleg_mouse_GetBounds;
   pFuncTable->MouseCountButton           = hb_gt_alleg_mouse_CountButton;
   pFuncTable->MouseButtonState           = hb_gt_alleg_mouse_ButtonState;
   pFuncTable->GfxPrimitive               = hb_gt_alleg_gfx_Primitive;
   pFuncTable->GfxText                    = hb_gt_alleg_gfx_Text;

   return TRUE;
}

/* ********************************************************************** */

static const HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ),
                                   hb_gt_FuncInit,
                                   HB_GTSUPER,
                                   HB_GTID_PTR };

HB_GT_ANNOUNCE( HB_GT_NAME )

HB_CALL_ON_STARTUP_BEGIN( _hb_startup_gt_Init_ )
   hb_gtRegister( >Init );
HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ )

#if defined( HB_PRAGMA_STARTUP )
   #pragma startup _hb_startup_gt_Init_
#elif defined(HB_MSC_STARTUP)
   #pragma data_seg( HB_MSC_START_SEGMENT )
   static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_;
   #pragma data_seg()
#endif

gtalleg.c1180
INT_mangled_main( int argc, char * argv[] )
int _mangled_main( int argc, char * argv[] )
{
   HB_TRACE(HB_TR_DEBUG, ("_mangled_main(%d, %p)", argc, argv));

   hb_cmdargInit( argc, argv );
   hb_vmInit( TRUE );
   return hb_vmQuit();
}
void * _mangled_main_address = ( void * ) _mangled_main;
gtalleg.c1230
ssf.c
TypeFunctionSourceLine
VOIDssfCreateThinFont(ssfFont *sfont)
void ssfCreateThinFont(ssfFont *sfont)
{
   sfont->fsize = 16;                     /* default pitch */
   sfont->chars = s_ssfFixedThinChars;    /* chars */
}
ssf.c76
VOIDssfSetFontSize(ssfFont *sfont, USHORT fsize)
void ssfSetFontSize(ssfFont *sfont, USHORT fsize)
{
   fSize = fsize;
}
ssf.c82
USHORTssfDrawChar(AL_BITMAP *dst, ssfFont *sfont, char c, int x, int y, int color)
USHORT ssfDrawChar(AL_BITMAP *dst, ssfFont *sfont, char c, int x, int y, int color)
{
   BYTE p;
   int i, j, thick;
   ssfGlyph charGlyph;
   ssfFrame charFrame;
   int points[8];
   float fScale;

   p = (BYTE) c;
   charGlyph = *sfont->chars[p];
   fScale = (float) ((float) sfont->fsize / (float) 65535);

   for( i = 0; i < charGlyph.num; i++ )
   {
      charFrame = charGlyph.frames[i];
      if( charFrame.ftype == SSF_SPLINE2 )
      {
         fLeft2 = x + (int) (fScale * charFrame.left);
         fTop2 = y + (int) (fScale * charFrame.top);
         fRight2 = x + (int) (fScale * charFrame.right);
         fBottom2 = y + (int) (fScale * charFrame.bottom);
      }
      else
      {
         fLeft = x + (int) (fScale * charFrame.left);
         fTop = y + (int) (fScale * charFrame.top);
         fRight = x + (int) (fScale * charFrame.right);
         fBottom = y + (int) (fScale * charFrame.bottom);
      }

      switch( charFrame.ftype )
      {
      case SSF_SPLINE2:
         thick = (int) (fScale * charFrame.thick);

         if( thick == 0 )
            thick++;

         for( j = 0; j < thick; j++ )
         {
            al_draw_spline(dst, points, color);
            switch( charFrame.thickdir )
            {
               case THICK_LEFT:
                  fLeft--;
                  fRight--;
                  fLeft2--;
                  fRight2--;
                  break;
               case THICK_UP:
                  fTop--;
                  fBottom--;
                  fTop2--;
                  fBottom2--;
                  break;
               case THICK_RIGHT:
                  fLeft++;
                  fRight++;
                  fLeft2++;
                  fRight2++;
                  break;
               case THICK_DOWN:
                  fTop++;
                  fBottom++;
                  fTop2++;
                  fBottom2++;
                  break;
            }
         }
         break;

      case SSF_LINE:
         thick = (int) (fScale * charFrame.thick);

         if( thick == 0 )
            thick++;

         for( j = 0; j < thick; j++ )
         {
            al_draw_line(dst, fLeft, fTop, fRight, fBottom, color);
            switch( charFrame.thickdir )
            {
               case THICK_LEFT:
                  fLeft--;
                  fRight--;
                  break;
               case THICK_UP:
                  fTop--;
                  fBottom--;
                  break;
               case THICK_RIGHT:
                  fLeft++;
                  fRight++;
                  break;
               case THICK_DOWN:
                  fTop++;
                  fBottom++;
                  break;
            }
         }
         break;

      case SSF_BOX:
         al_draw_rect_fill(dst, fLeft, fTop, fRight, fBottom, color);
         break;

      case SSF_TRIANGLE:
         thick = x + (int) (fScale * charFrame.thick);
         al_draw_triangle(dst, fLeft, fTop, fRight, fBottom, thick, y + (int) (fScale * charFrame.thickdir), color);
         break;
      }
   }

   return (sfont->fsize / 2);
}
ssf.c87
INTssfDrawText(AL_BITMAP *dst, ssfFont *sfont, char *s, int x, int y, int color)
int ssfDrawText(AL_BITMAP *dst, ssfFont *sfont, char *s, int x, int y, int color)
{
   int i = 0;

   while( s[i] )
   {
      x += ssfDrawChar(dst, sfont, s[i], x, y, color);
      i++;
   }

   return x;
}
ssf.c204