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

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