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

  1. /* wrld5.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, p )        \
  15.     dm_pget( USER_DM( gspWorld | 0 ), n * sizeof(POINT), p )
  16.  
  17. struct    POINT
  18. {
  19.   int    x;
  20.   int    y;
  21. };
  22.  
  23. int    gspWorld;
  24. POINT    points[5];
  25.  
  26.  
  27. void        reportPositionTable( )
  28. {
  29.   printf( "Text displayed at:\n" );
  30.   for( int i = 0; i < 5; i++ )
  31.     printf( "  %4d, %4d \n", points[i].x, points[i].y );
  32. }
  33.  
  34. int        main( int argc, char argv[ ] )
  35. {
  36.   
  37.   if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
  38.   { 
  39.     if( install_primitives( ) >= 0 )
  40.     {
  41.       gspWorld = install_rlm( "gspWrld5.rlm" );
  42.       if( gspWorld < 0 )
  43.       {
  44.         printf("ERROR: could not load gspWrld5.rlm\n");
  45.         printf("Error code = %d\n", gspWorld );
  46.         exit( 7 );
  47.       }
  48.       gspMain( 5, points );
  49.       reportPositionTable( );
  50.     }
  51.     else
  52.     {
  53.       printf( "ERROR: Can not load TIGA primitives.\n" );
  54.       return 1;
  55.     }
  56.     set_videomode( PREVIOUS, NO_INIT );
  57.   }
  58.   else
  59.   {
  60.     printf( "ERROR: Please install TIGA and try again.\n" );
  61.     return 2;
  62.   }
  63.   return 0;
  64. }
  65.  
  66. /* gspWrld5.c */
  67.  
  68. #include <gsptypes.h>
  69. #include <gspglobs.h>
  70. #include <gsptiga.h>
  71.  
  72. #define XSIZE    (config.mode.disp_hres)
  73. #define YSIZE    (config.mode.disp_vres)
  74. #define    XOR    10
  75.  
  76. int    xPosition[5] = { 25, 75, 50, 25, 75 };
  77. int    yPosition[5] = { 25, 25, 50, 75, 75 };
  78.  
  79. void        gspMain( p )
  80. short*    p;
  81. {
  82.   int count;
  83.   int x, y, i;
  84.   int tw;
  85.   char* hello;
  86.   
  87.   count = *p++;            /* get count (in bytes).    */
  88.   count = count /4;        /* number of points        */
  89.  
  90.   set_fcolor( WHITE );
  91.   set_bcolor( BLACK );
  92.  
  93.   hello = "   H e l l o   W o r l d   ";
  94.   tw = text_width( hello );    /* string width for
  95.                                    centering    */
  96.   
  97.   for( i = 0; i < count; i++ )
  98.   {
  99.     *p++ = x = xPosition[i] * XSIZE / 100;
  100.     *p++ = y = yPosition[i] * YSIZE / 100;
  101.     text_out( x - tw/2, y, "   H e l l o   W o r l d   " );
  102.   }
  103. }
  104.