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

  1. /* wrld6.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_palt( 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.  
  25. POINT    points[5] =
  26. {
  27.   25, 25, 75, 25, 50, 50, 25, 75, 75, 75
  28. };
  29.  
  30. void        reportPositionTable( )
  31. {
  32.   printf( "Text displayed at:\n" );
  33.   for( int i = 0; i < 5; i++ )
  34.     printf( "  %4d, %4d \n", points[i].x, points[i].y );
  35. }
  36.  
  37. int        main( int argc, char argv[ ] )
  38. {
  39.   
  40.   if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
  41.   { 
  42.     if( install_primitives( ) >= 0 )
  43.     {
  44.       gspWorld = install_rlm( "gspWrld6.rlm" );
  45.       if( gspWorld < 0 )
  46.       {
  47.         printf("ERROR: could not load gspWrld6.rlm\n");
  48.         printf("Error code = %d\n", gspWorld );
  49.         exit( 7 );
  50.       }
  51.       gspMain( 5, points );
  52.       reportPositionTable( );
  53.     }
  54.     else
  55.     {
  56.       printf( "ERROR: Can not load TIGA primitives.\n" );
  57.       return 1;
  58.     }
  59.     set_videomode( PREVIOUS, NO_INIT );
  60.   }
  61.   else
  62.   {
  63.     printf( "ERROR: Please install TIGA and try again.\n" );
  64.     return 2;
  65.   }
  66.   return 0;
  67. }
  68.  
  69. /* gspWrld6.c */
  70.  
  71. #include <gsptypes.h>
  72. #include <gspglobs.h>
  73. #include <gsptiga.h>
  74.  
  75. #define XSIZE    (config.mode.disp_hres)
  76. #define YSIZE    (config.mode.disp_vres)
  77. #define    XOR    10
  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 = *p * XSIZE / 100;
  100.     *p++ = y = *p * YSIZE / 100;
  101.     text_out( x - tw/2, y, "   H e l l o   W o r l d   " );
  102.   }
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.