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

  1. /* wrld4.cpp */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7. #include <typedefs.hpp>
  8.  
  9. extern "C"
  10. {
  11.     #include <tiga.h>
  12.     #include <extend.h>
  13. }
  14.  
  15. #define gspMain( n, p )        \
  16.     dm_psnd( USER_DM( gspWorld | 0 ), n * sizeof(POINT), p )
  17.  
  18. #define XSIZE    (config.mode.disp_hres)
  19. #define YSIZE    (config.mode.disp_vres)
  20.  
  21. struct    POINT
  22. {
  23.   int    x;
  24.   int    y;
  25. };
  26.  
  27. CONFIG    config;
  28. int    gspWorld;
  29. POINT    points[5];
  30.  
  31. void        buildPositionTable( )
  32. {
  33.   points[0].x = XSIZE/4;
  34.   points[0].y = YSIZE/4;
  35.   points[1].x = 3*XSIZE/4;
  36.   points[1].y = YSIZE/4;
  37.   points[2].x = XSIZE/2;
  38.   points[2].y = YSIZE/2;
  39.   points[3].x = XSIZE/4;
  40.   points[3].y = 3*YSIZE/4;
  41.   points[4].x = 3*XSIZE/4;
  42.   points[4].y = 3*YSIZE/4;
  43. }
  44.  
  45. int        main( int argc, char argv[ ] )
  46. {
  47.   
  48.   if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
  49.   { 
  50.     if( install_primitives( ) >= 0 )
  51.     {
  52.       gspWorld = install_rlm( "gspWrld4.rlm" );
  53.       if( gspWorld < 0 )
  54.       {
  55.         printf("ERROR: could not load gspWrld4.rlm\n");
  56.         printf("Error code = %d\n", gspWorld );
  57.         exit( 7 );
  58.       }
  59.       get_config( &config );
  60.       buildPositionTable( );
  61.       gspMain( 5, points );
  62.     }
  63.     else
  64.     {
  65.       printf( "ERROR: Can not load TIGA primitives.\n" );
  66.       return 1;
  67.     }
  68.     set_videomode( PREVIOUS, NO_INIT );
  69.   }
  70.   else
  71.   {
  72.     printf( "ERROR: Please install TIGA and try again.\n" );
  73.     return 2;
  74.   }
  75.   return 0;
  76. }
  77.  
  78. /* gspWrld4.c */
  79.  
  80. #include <gsptypes.h>
  81. #include <gspglobs.h>
  82. #include <gsptiga.h>
  83.  
  84. #define XSIZE    (config.mode.disp_hres)
  85. #define YSIZE    (config.mode.disp_vres)
  86. #define    XOR    10
  87.  
  88. void        gspMain( p )
  89. short*    p;
  90. {
  91.   int count;
  92.   int x, y;
  93.   int tw;
  94.   char* hello;
  95.   
  96.   count = *p++;            /* get count (in bytes).    */
  97.   count = count /4;        /* number of points        */
  98.  
  99.   set_fcolor( WHITE );
  100.   set_bcolor( BLACK );
  101.  
  102.   hello = "   H e l l o   W o r l d   ";
  103.   tw = text_width( hello );    /* string width for
  104.                                    centering    */
  105.   
  106.   while( count-- > 0 )
  107.   {
  108.     x = *p++;
  109.     y = *p++;
  110.     text_out( x - tw/2, y, "   H e l l o   W o r l d   " );
  111.   }
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.