home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / PASCAL / PAVT199 / PAVTDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1993-06-13  |  4KB  |  130 lines

  1. program PAvtDemo; { Demo of Avatar level 1 console using Crt routines }
  2.                   { Public Domain.  Author: Gregory P. Smith          }
  3.                   { Modification History:                             }
  4.                   {        12/23/91   Added coordinate checks on all  }
  5.                   {                   Screen Manipluations            }
  6.                   {        08/21/92   Added VT-52 & AdLib support     }
  7.                   {        10/17/92   Changed AVT/0+ to the default   }
  8.                   {                   Terminal.                       }
  9.                   {        01/30/93   Allowed music to finish playing }
  10.                   {                   before exiting.                 }
  11.                   {        04/07/93   Cleaned up and added comments.  }
  12.                   {        06/11/93   Added support for VT-102        }
  13. {$R-,F-,M 5120,4096,4096}
  14.  
  15. Uses Dos, Crt,
  16.      PAvtIO, PAvtSnd, PAvt150;
  17.  
  18. {$IFNDEF ST}
  19. {$I DHOOKS.INC -- link in the screen I/O and user hooks. }
  20. {$ENDIF}
  21.  
  22. function UpStr(s:string): string;
  23. var
  24.   ns : string;
  25.   i : integer;
  26. begin
  27.   for i := 1 to length(s) do
  28.     ns[i] := upcase(s[i]);
  29.   ns[0] := s[0];  { copy the length byte }
  30.   UpStr := ns;
  31. end;
  32.  
  33. procedure Help(long:boolean);
  34. begin
  35.   Writeln('PAvatar 1.55 Demo -- Copr. 1993 Gregory P. Smith'^M^J);
  36.   Writeln('Usage:  pavtdemo [params] input_file [params]');
  37.   if long then
  38.    begin
  39.      Writeln;
  40.      Writeln(' parameters (may be abbreviated):');
  41.      Writeln('   /AVT1         Emulate a full Avatar level 1 terminal. (*)');
  42.      Writeln('   /ANSI         Emulate an ANSI-BBS terminal. (*)');
  43.      Writeln('   /VT52         Emulate a VT-52 terminal. (*)');
  44.      Writeln('   /VT102        Emulate a VT-102 terminal. (*)');
  45.      Writeln('   /SLOW         Slow down emulation for easier viewing.');
  46.      Writeln('   /NOFM         Do NOT use AdLib / SoundBlaster FM music for sounds.');
  47.      Writeln;
  48.      Writeln(' (*) Avatar level 0+ with ANSI-BBS fallback is the default terminal.');
  49.    end
  50.   else Writeln(' type pavtdemo /? for more help');
  51.   halt;
  52. end;
  53.  
  54. var
  55.   fname : pathstr;  { name of file to display }
  56.   slowdown : byte;  { ms to delay between characters }
  57.  
  58. procedure ProcessParams;
  59. const
  60.   Prms = '/AVT1/ANSI/SLOW/?/HELP/VT52/NOFM/VT102';
  61. var
  62.   t : TerminalType;
  63.   i,p : byte;
  64. begin
  65.   p := paramcount;
  66.   if p = 0 then Help(False);
  67.   t := TermAVT0;   { AVT/0+ with fallback is default }
  68.   slowdown := 0;   { default to full speed }
  69.   while p > 0 do
  70.    begin
  71.      i := pos(UpStr(ParamStr(p)),Prms);
  72.      case i of
  73.        1  : t := TermAVT1;
  74.        6  : t := TermANSI;
  75.        11 : Slowdown := 4; { set to ms between chars. }
  76.        16..18 : Help(True);
  77.        23 : t := TermVT52;
  78.        28 : Use_AdLib := False;
  79.        33 : t := TermVT102;
  80.      else
  81.       fname := ParamStr(p);
  82.      end; { case }
  83.      dec(p);
  84.    end; { while }
  85.   SetTerminal(t);
  86. end;  { processed in reverse so that first non-parameter is the filename }
  87.  
  88. const
  89.   bufsize = 2048;
  90.  
  91. var
  92.   f : file;
  93.   buf : Array[0..bufsize-1] of char;
  94.   i,z : word;
  95.  
  96. BEGIN
  97.   InitUnit;  { Initialize the PAvatar unit }
  98. {$IFNDEF ST}
  99.   Assign(Output,''); Rewrite(Output);
  100.   Assign(Input,''); Reset(Input);
  101. {$ENDIF}
  102.   fname := '';
  103. {$IFNDEF ST}
  104.   SetScrPtr;  { Initialize the video routines (dhooks.inc) }
  105.   SetHooks;   { Initialize the I/O hooks in PAvatar (dhooks.inc) }
  106. {$ENDIF}
  107.   SetScreenSize(80, 24);
  108.   ProcessParams;  { Parse command line parameters }
  109. {$IFNDEF ST}
  110.   FillArea(1,1,80,25,7,' ');  { Clear the screen }
  111. {$ENDIF}
  112.   Set_Sound_Backg(True);  { We want background music }
  113.   Assign(f,fname);
  114.   Reset(f,1);
  115.   repeat  { read and display the file }
  116.     BlockRead(f,buf,bufsize,z);
  117.     dec(z); { 0 based buffer }
  118.     for i := 0 to z do begin delay(slowdown);
  119.       Parse_AVT1(buf[i]); end;
  120.   until EOF(f); { end else }
  121.   if Sounds_Left > 0 then begin
  122.     Writeln(' * Allowing music to finish * ');
  123.     Sound_Finish;  { Wait until all music has completed }
  124.   end;
  125. END.
  126.  
  127. (*{$IFNDEF ST}
  128.       Delay(slowdown);
  129. {$ENDIF}*)
  130.