home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_04 / 1n04060b < prev    next >
Text File  |  1990-08-06  |  2KB  |  91 lines

  1. /* wrld3.cpp */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. #include <typedefs.hpp>
  7.  
  8. extern "C"
  9. {
  10.     #include <tiga.h>
  11.     #include <extend.h>
  12. }
  13.  
  14. #define gspMain( n, fg, bg )        \
  15.     dm_cmd( USER_DM( gspWorld | 0 ), 3, n, fg, bg )
  16.  
  17. int    gspWorld;
  18.  
  19. int        main( int argc, char argv[ ] )
  20. {
  21.   
  22.   if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
  23.   { 
  24.     if( install_primitives( ) >= 0 )
  25.     {
  26.       gspWorld = install_rlm( "gspWrld3.rlm" );
  27.       if( gspWorld < 0 )
  28.       {
  29.         printf("ERROR: could not load gspWrld3.rlm\n");
  30.         printf("Error code = %d\n", gspWorld );
  31.         exit( 7 );
  32.       }
  33.       gspMain( 10, BLACK, WHITE );
  34.     }
  35.     else
  36.     {
  37.       printf( "ERROR: Can not load TIGA primitives.\n" );
  38.       return 1;
  39.     }
  40.     set_videomode( PREVIOUS, NO_INIT );
  41.   }
  42.   else
  43.   {
  44.     printf( "ERROR: Please install TIGA and try again.\n" );
  45.     return 2;
  46.   }
  47.   return 0;
  48. }
  49.  
  50. /* gspWrld3.c */
  51.  
  52. #include <gsptypes.h>
  53. #include <gspglobs.h>
  54. #include <gsptiga.h>
  55.  
  56. #define XSIZE    (config.mode.disp_hres)
  57. #define YSIZE    (config.mode.disp_vres)
  58. #define    XOR    10
  59.  
  60. void        gspMain( p )
  61. short*    p;
  62. {
  63.   int n, fg, bg;
  64.   char* hello;
  65.   int tw;
  66.   int w, h, i;
  67.   
  68.   n = *p++;
  69.   fg = *p++;
  70.   bg = *p++;
  71.   
  72.     /*    Get display size        */
  73.   set_fcolor( fg );
  74.   set_bcolor( bg );
  75.  
  76.     /*    Center message on screen    */
  77.   hello = "   H e l l o   W o r l d   ";
  78.   tw = text_width( hello );
  79.   text_out( (XSIZE-tw)/2, YSIZE/2, hello );
  80.  
  81.     /*    Draw n surrounding boxes    */
  82.   set_ppop( XOR );
  83.   set_fcolor( -1 );
  84.   for( i = 1; i <= n; i++ )
  85.   {
  86.     w = tw + (XSIZE-tw) * i / n;
  87.     h = YSIZE * i / n;
  88.     fill_rect( w, h, (XSIZE-w)/2, (YSIZE-h)/2 );
  89.   }
  90. }
  91.