home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DIVERSEN / PCXK53 / SHOWP.PAS < prev    next >
Pascal/Delphi Source File  |  1994-11-07  |  2KB  |  98 lines

  1. program ShowPCX;
  2.  
  3. (* Sample implementation of PCX.TPU. Enter a filename (extension optional)
  4.   on the command line or, if running under the IDE, in the Parameters box.
  5.   You can optionally override the default video mode with a second argument,
  6.   entered as a decimal or Pascal hex number. *)
  7.  
  8. {$X+}
  9.  
  10. uses DOS, CRT, PCX;
  11.  
  12. CONST
  13.          PCXMode: word = AutoSet;
  14.  
  15. VAR
  16.          PCXFileName: pathstr;
  17.          Dir: DirStr;
  18.          Name: NameStr;
  19.          Ext: ExtStr;
  20.          StartMode: word;
  21.          Msg: string;
  22.          Temp, ValErr, ErrNo: integer;
  23.          VESARec: VESAInfoRec;
  24.  
  25. procedure WriteError(ErrMsg: string);
  26.  
  27. VAR  Msg: string;
  28.  
  29. begin
  30. writeln;
  31. writeln(ErrMsg);
  32. writeln;
  33. writeln('Press any key.');
  34. ReadKey;
  35. end;
  36.  
  37. BEGIN
  38. StartMode:= GetMode;
  39. PCXFileName:= paramstr(1);
  40. { --- No command-line argument }
  41. if PCXFileName = '' then
  42. begin
  43.   writeln('Usage:');
  44.   writeln('showp filename[.pcx] [mode]');
  45.   writeln;
  46.   halt;
  47. end;
  48. { --- Add '.PCX' if necessary }
  49. FSplit(PCXFileName, Dir, Name, Ext);
  50. if Ext = '' then PCXFileName:= PCXFileName + '.PCX';
  51. { --- Get mode from command line }
  52. if paramcount > 1 then
  53. begin
  54.   val(paramstr(2), Temp, ValErr);
  55.   if ValErr = 0 then PCXMode:= Temp;
  56. end;
  57. if not DetectVGA then
  58. begin
  59.   writeln('VGA card required.');
  60.   halt;
  61. end;
  62. if (not WeSupport(PCXMode)) and (PCXMode <> AutoSet) then
  63. begin
  64.   WriteError('The requested video mode is not supported by this program.');
  65.   halt;
  66. end;
  67. if (PCXMode >= $100) then
  68. begin
  69.   if not DetectVESA(VESARec) then
  70.   begin
  71.     writeln;
  72.     write('VESA BIOS extensions not found. Your video card may require');
  73.     write('a program (typically called VESA.COM) to be loaded so that');
  74.     write('Super-VGA images can be displayed without a special driver.');
  75.     writeln;
  76.     halt;
  77.   end;
  78.   if not HardwareSupports(PCXMode) then
  79.   begin
  80.     WriteError('Your card or VESA BIOS does not support the requested video mode.');
  81.     halt;
  82.   end;
  83. end;
  84.  
  85. { --- Do it }
  86. ErrNo:= (ReadIt(PCXFileName, PCXMode, Blackout or HCenter or VCenter));
  87.  
  88. if ErrNo <> 0 then
  89. begin
  90.   SetMode(3, NoOptions);
  91.   ReportError(ErrNo, Msg);
  92.   WriteError(Msg);
  93.   halt;
  94. end
  95. else ReadKey;
  96. SetMode(StartMode, NoOptions);         { Restore text mode }
  97. END.
  98.