home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DIVERSEN / PCXK53 / SHOW.CPP < prev    next >
C/C++ Source or Header  |  1994-11-16  |  2KB  |  70 lines

  1. /* Sample implementation of PCX.CPP. Enter a filename (extension optional)
  2.   on the command line or, if running under the IDE, in the Parameters box.
  3.   You can optionally override the default video mode with a second argument,
  4.   entered as a decimal or C-style hexadecimal. */
  5.  
  6. #include "pcx.h"
  7. #include <dir.h>
  8. #include <conio.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12.  
  13. void cmd_error(char *msg);
  14.  
  15. void cmd_error(char *msg) {
  16.   puts(msg);
  17.   exit(1);
  18. }
  19.  
  20. void main(int argc, char *argv[])
  21. {
  22.   int pcx_mode = auto_set;
  23.   int start_mode = get_mode();
  24.   int err = 0;
  25.   int n = 0;
  26.   char file_name[80];
  27.   char drive[MAXDRIVE];
  28.   char dir[MAXDIR];
  29.   char file[MAXFILE];
  30.   char ext[MAXEXT];
  31.   int flags;
  32.   VESA_info_struct VESA_inf;
  33.  
  34.  
  35.   if (!detect_VGA) cmd_error("VGA card required.");
  36.  
  37. // Get filename and add ".PCX if necessary
  38.   if (argc > 1) {
  39.     strcpy(file_name, argv[1]);
  40.     flags = fnsplit(file_name, drive, dir, file, ext);
  41.     if (!(flags & EXTENSION)) {
  42.       strcpy(ext, ".PCX");
  43.       fnmerge(file_name, drive, dir, file, ext);
  44.     }
  45. // Get mode from command line and check legality
  46.     if (argc > 2) {
  47.       sscanf(argv[2], "%i", &n)  ;   // recognizes decimal or hex
  48.       if (n) pcx_mode = n;
  49.     }
  50.     if ((!we_support(pcx_mode)) && (pcx_mode != auto_set))
  51.       cmd_error("The requested video mode is not supported by this program.");
  52.     if (pcx_mode >= 0x100) {
  53.       if (!detect_VESA(&VESA_inf))
  54.     cmd_error("VESA BIOS extensions not found. Your video card may require\n"
  55.        "a program (typically called VESA.COM) to be loaded so that\n"
  56.        "Super-VGA images can be displayed without a special driver.");
  57.       if (!hardware_supports(pcx_mode))
  58.     cmd_error("Your card or VESA BIOS does not support the requested"
  59.                   " video mode.");
  60.     }
  61.     err = read_it(file_name, pcx_mode, hcenter | vcenter | blackout);
  62.     if(err) printf(report_error(err));
  63.   }
  64.   else  // no argument
  65.     cmd_error("Usage:\nshow filename[.pcx] [mode]");
  66.   getch();
  67.   set_mode(start_mode, no_options);
  68.   return;
  69. }
  70.