home *** CD-ROM | disk | FTP | other *** search
- /* wrld3.cpp */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <typedefs.hpp>
-
- extern "C"
- {
- #include <tiga.h>
- #include <extend.h>
- }
-
- #define gspMain( n, fg, bg ) \
- dm_cmd( USER_DM( gspWorld | 0 ), 3, n, fg, bg )
-
- int gspWorld;
-
- int main( int argc, char argv[ ] )
- {
-
- if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
- {
- if( install_primitives( ) >= 0 )
- {
- gspWorld = install_rlm( "gspWrld3.rlm" );
- if( gspWorld < 0 )
- {
- printf("ERROR: could not load gspWrld3.rlm\n");
- printf("Error code = %d\n", gspWorld );
- exit( 7 );
- }
- gspMain( 10, BLACK, WHITE );
- }
- else
- {
- printf( "ERROR: Can not load TIGA primitives.\n" );
- return 1;
- }
- set_videomode( PREVIOUS, NO_INIT );
- }
- else
- {
- printf( "ERROR: Please install TIGA and try again.\n" );
- return 2;
- }
- return 0;
- }
-
- /* gspWrld3.c */
-
- #include <gsptypes.h>
- #include <gspglobs.h>
- #include <gsptiga.h>
-
- #define XSIZE (config.mode.disp_hres)
- #define YSIZE (config.mode.disp_vres)
- #define XOR 10
-
- void gspMain( p )
- short* p;
- {
- int n, fg, bg;
- char* hello;
- int tw;
- int w, h, i;
-
- n = *p++;
- fg = *p++;
- bg = *p++;
-
- /* Get display size */
- set_fcolor( fg );
- set_bcolor( bg );
-
- /* Center message on screen */
- hello = " H e l l o W o r l d ";
- tw = text_width( hello );
- text_out( (XSIZE-tw)/2, YSIZE/2, hello );
-
- /* Draw n surrounding boxes */
- set_ppop( XOR );
- set_fcolor( -1 );
- for( i = 1; i <= n; i++ )
- {
- w = tw + (XSIZE-tw) * i / n;
- h = YSIZE * i / n;
- fill_rect( w, h, (XSIZE-w)/2, (YSIZE-h)/2 );
- }
- }
-