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

  1. /* world.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( )    cp_cmd( USER_CP( gspWorld | 0 ), 0 )
  15.  
  16. int    gspWorld;
  17.  
  18. int        main( int argc, char argv[ ] )
  19. {
  20.   
  21.   if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
  22.   { 
  23.     if( install_primitives( ) >= 0 )
  24.     {
  25.       gspWorld = install_rlm( "gspWorld.rlm" );
  26.       if( gspWorld < 0 )
  27.       {
  28.         printf("ERROR: could not load gspWorld.rlm\n");
  29.         printf("Error code = %d\n", gspWorld );
  30.         exit( 7 );
  31.       }
  32.       gspMain( );
  33.     }
  34.     else
  35.     {
  36.       printf( "ERROR: Can not load TIGA primitives.\n" );
  37.       return 1;
  38.     }
  39.     set_videomode( PREVIOUS, NO_INIT );
  40.   }
  41.   else
  42.   {
  43.     printf( "ERROR: Please install TIGA and try again.\n" );
  44.     return 2;
  45.   }
  46.   return 0;
  47. }
  48.  
  49. /* gspWorld.c */
  50.  
  51. #include <gsptypes.h>
  52. #include <gspglobs.h>
  53. #include <gsptiga.h>
  54.  
  55. #define XSIZE    (config.mode.disp_hres)
  56. #define YSIZE    (config.mode.disp_vres)
  57. #define    XOR    10
  58.  
  59. void        gspMain( )
  60. {
  61.   char* hello;
  62.   int tw;
  63.   int w, h, i;
  64.     /*    Get display size        */
  65.     /* get_config( &config ); */
  66.   set_fcolor( WHITE );
  67.   set_bcolor( BLACK );
  68.  
  69.     /*    Center message on screen    */
  70.   hello = "   H e l l o   W o r l d   ";
  71.   tw = text_width( hello );
  72.   text_out( (XSIZE-tw)/2, YSIZE/2, hello );
  73.  
  74.     /*    Draw 10 surrounding boxes    */
  75.   set_ppop( XOR );
  76.   for( i = 1; i <= 10; i++ )
  77.   {
  78.     w = tw + (XSIZE-tw) * i / 10;
  79.     h = YSIZE * i / 10;
  80.     fill_rect( w, h, (XSIZE-w)/2, (YSIZE-h)/2 );
  81.   }
  82. }
  83.  
  84. /* extWorld.asm */
  85.  
  86.     .width    132
  87.     .length  58
  88.     .option B, D, L, M, T
  89.  
  90. ;------- Publics --------------------------------
  91.   .global    _gspMain
  92. ;------------------------------------------------
  93.  
  94. ;-------- Tiga Extension List -------------------
  95.       .sect   ".TIGAISR"
  96.  
  97.       .sect ".TIGAEXT"
  98.   .long        _gspMain
  99. ;------------------------------------------------
  100.  
  101.   .text
  102.   .end
  103.  
  104. /* gspWorld.cmd */
  105.  
  106. -cr            /*  C conventions    */
  107. -r            /*  Relocatable output    */
  108. -o gspWorld.rlm        /*  Output file     */
  109. -m gspWorld.map        /*  Map file        */
  110.  
  111.     /*    Input files    */
  112. gspWorld.obj
  113. extWorld.obj
  114.