home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
PROGRAM
/
DIVERSEN
/
PCXK53
/
SHOW.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-16
|
2KB
|
70 lines
/* Sample implementation of PCX.CPP. Enter a filename (extension optional)
on the command line or, if running under the IDE, in the Parameters box.
You can optionally override the default video mode with a second argument,
entered as a decimal or C-style hexadecimal. */
#include "pcx.h"
#include <dir.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void cmd_error(char *msg);
void cmd_error(char *msg) {
puts(msg);
exit(1);
}
void main(int argc, char *argv[])
{
int pcx_mode = auto_set;
int start_mode = get_mode();
int err = 0;
int n = 0;
char file_name[80];
char drive[MAXDRIVE];
char dir[MAXDIR];
char file[MAXFILE];
char ext[MAXEXT];
int flags;
VESA_info_struct VESA_inf;
if (!detect_VGA) cmd_error("VGA card required.");
// Get filename and add ".PCX if necessary
if (argc > 1) {
strcpy(file_name, argv[1]);
flags = fnsplit(file_name, drive, dir, file, ext);
if (!(flags & EXTENSION)) {
strcpy(ext, ".PCX");
fnmerge(file_name, drive, dir, file, ext);
}
// Get mode from command line and check legality
if (argc > 2) {
sscanf(argv[2], "%i", &n) ; // recognizes decimal or hex
if (n) pcx_mode = n;
}
if ((!we_support(pcx_mode)) && (pcx_mode != auto_set))
cmd_error("The requested video mode is not supported by this program.");
if (pcx_mode >= 0x100) {
if (!detect_VESA(&VESA_inf))
cmd_error("VESA BIOS extensions not found. Your video card may require\n"
"a program (typically called VESA.COM) to be loaded so that\n"
"Super-VGA images can be displayed without a special driver.");
if (!hardware_supports(pcx_mode))
cmd_error("Your card or VESA BIOS does not support the requested"
" video mode.");
}
err = read_it(file_name, pcx_mode, hcenter | vcenter | blackout);
if(err) printf(report_error(err));
}
else // no argument
cmd_error("Usage:\nshow filename[.pcx] [mode]");
getch();
set_mode(start_mode, no_options);
return;
}