home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_04
/
1n04062a
< prev
next >
Wrap
Text File
|
1990-08-06
|
2KB
|
121 lines
/* wrld4.cpp */
#include <stdio.h>
#include <stdlib.h>
#include <typedefs.hpp>
extern "C"
{
#include <tiga.h>
#include <extend.h>
}
#define gspMain( n, p ) \
dm_psnd( USER_DM( gspWorld | 0 ), n * sizeof(POINT), p )
#define XSIZE (config.mode.disp_hres)
#define YSIZE (config.mode.disp_vres)
struct POINT
{
int x;
int y;
};
CONFIG config;
int gspWorld;
POINT points[5];
void buildPositionTable( )
{
points[0].x = XSIZE/4;
points[0].y = YSIZE/4;
points[1].x = 3*XSIZE/4;
points[1].y = YSIZE/4;
points[2].x = XSIZE/2;
points[2].y = YSIZE/2;
points[3].x = XSIZE/4;
points[3].y = 3*YSIZE/4;
points[4].x = 3*XSIZE/4;
points[4].y = 3*YSIZE/4;
}
int main( int argc, char argv[ ] )
{
if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
{
if( install_primitives( ) >= 0 )
{
gspWorld = install_rlm( "gspWrld4.rlm" );
if( gspWorld < 0 )
{
printf("ERROR: could not load gspWrld4.rlm\n");
printf("Error code = %d\n", gspWorld );
exit( 7 );
}
get_config( &config );
buildPositionTable( );
gspMain( 5, points );
}
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;
}
/* gspWrld4.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 count;
int x, y;
int tw;
char* hello;
count = *p++; /* get count (in bytes). */
count = count /4; /* number of points */
set_fcolor( WHITE );
set_bcolor( BLACK );
hello = " H e l l o W o r l d ";
tw = text_width( hello ); /* string width for
centering */
while( count-- > 0 )
{
x = *p++;
y = *p++;
text_out( x - tw/2, y, " H e l l o W o r l d " );
}
}