home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_04
/
1n04064a
< prev
next >
Wrap
Text File
|
1990-08-06
|
2KB
|
104 lines
/* wrld5.cpp */
#include <stdio.h>
#include <stdlib.h>
#include <typedefs.hpp>
extern "C"
{
#include <tiga.h>
#include <extend.h>
}
#define gspMain( n, p ) \
dm_pget( USER_DM( gspWorld | 0 ), n * sizeof(POINT), p )
struct POINT
{
int x;
int y;
};
int gspWorld;
POINT points[5];
void reportPositionTable( )
{
printf( "Text displayed at:\n" );
for( int i = 0; i < 5; i++ )
printf( " %4d, %4d \n", points[i].x, points[i].y );
}
int main( int argc, char argv[ ] )
{
if( set_videomode( TIGA, INIT | CLR_SCREEN ) )
{
if( install_primitives( ) >= 0 )
{
gspWorld = install_rlm( "gspWrld5.rlm" );
if( gspWorld < 0 )
{
printf("ERROR: could not load gspWrld5.rlm\n");
printf("Error code = %d\n", gspWorld );
exit( 7 );
}
gspMain( 5, points );
reportPositionTable( );
}
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;
}
/* gspWrld5.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
int xPosition[5] = { 25, 75, 50, 25, 75 };
int yPosition[5] = { 25, 25, 50, 75, 75 };
void gspMain( p )
short* p;
{
int count;
int x, y, i;
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 */
for( i = 0; i < count; i++ )
{
*p++ = x = xPosition[i] * XSIZE / 100;
*p++ = y = yPosition[i] * YSIZE / 100;
text_out( x - tw/2, y, " H e l l o W o r l d " );
}
}