home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ Games Programming
/
CPPGAMES.ISO
/
thx
/
source
/
utils
/
region.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-12
|
1KB
|
51 lines
#include <fastgraf.h>
#include <iostream.h>
#include <stdlib.h>
#include <io.h>
const int INPUTFILE = 1;
const int OUTPUTFILE = 2;
const int XONE = 3;
const int YONE = 4;
const int XTWO = 5;
const int YTWO = 6;
const int VMODE = 22;
int main(int argc,char** argv)
{
int x1,y1,x2,y2;
if (argc<7)
{
cout << "\nUSAGE : REGION <in_pcx> <out_pcx> <x1> <y1> <x2> <y2>\n\n";
return -1;
}
if (access(argv[INPUTFILE],0)!=0)
{
cout << "can't find file '" << argv[INPUTFILE] << "'\n";
return -1;
}
x1=atoi(argv[XONE]);
y1=atoi(argv[YONE]);
x2=atoi(argv[XTWO]);
y2=atoi(argv[YTWO]);
if (!(x1>=0 && y1>=0 && x2-x1<320 && y2-y1<240 && x2-x1>0 && y2-y1>0))
{
cout << "input error involving region coordinates\n";
return -1;
}
int oldmode=fg_getmode();
fg_setmode(VMODE);
fg_move(0,0);
fg_showpcx(argv[INPUTFILE],2);
fg_makepcx(x1,x2,y1,y2,argv[OUTPUTFILE]);
fg_setmode(oldmode);
return 0;
}