home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c011 / 4.ddi / EXAMPLES / PAS / FXTEST.MP < prev    next >
Encoding:
Text File  |  1989-06-01  |  4.2 KB  |  160 lines

  1. {* Effect.PAS                                                               *}
  2. {* Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved. *}
  3.  
  4. {****************************************************************************
  5.  
  6.   This program demonstrates the usage of an effect. It is an example
  7.   Pascal routine for the PCX Effects Toolkit.
  8.  
  9.   To Compile: MS Pascal 4.x  pl /c fxtest.pas        (Rename to fxTest.PAS)
  10.                              link fxtest,,,pcx_cl fx_cl;
  11.  
  12.   Microsoft Pascal 4.x                    Programmer: Chris Howard  5/07/89
  13.  
  14. *****************************************************************************}
  15.  
  16.  
  17. { Include the PCX Toolkit Unit, and the PCX Effects Unit }
  18. {$include:'pcxlib.pas'}
  19. {$include:'fxlib.pas'}
  20.  
  21. Program fxTest(input,output);
  22.  
  23. uses pcxlib,fxlib;
  24.  
  25. { Include DOS read key function }
  26. function DOSXQQ(command,parameter:word):byte;extern;
  27.  
  28. { Globals }
  29. const
  30.   pcximage       = 'fxTest.PCX'*chr(0);
  31.  
  32.   bufmax         = 20000;
  33.  
  34. var
  35.  
  36.   pcxtype        : integer;
  37.  
  38.   vi             : array[1..2] of PCXVINFO;
  39.   header         : PCXHEADER;
  40.  
  41.   vfree,vreq     : integer4;
  42.   vptr           : integer4;
  43.  
  44.   width,depth    : integer;
  45.   wx2,wy2        : integer;
  46.  
  47.   retcode        : integer;
  48.   key            : byte;
  49.  
  50.   buffer         : array[1..bufmax] of byte;
  51.  
  52. {**********}
  53.  
  54. begin
  55.  
  56.   { Display program header }
  57.   writeln;
  58.   writeln('╒══════════════════════════════════════════════════════════════════════════╕');
  59.   writeln('│ fxTest: Example Effect Pascal Program                   PCX Effects 1.0x │');
  60.   writeln('│ Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved. │');
  61.   writeln('╘══════════════════════════════════════════════════════════════════════════╛');
  62.   writeln;
  63.  
  64.   { Get a key, to begin }
  65.   writeln('Press a key to run . . .');
  66.   key := DOSXQQ(1,0);
  67.  
  68.   { Allocate a larger toolkit buffer, to speed up file and display speeds }
  69.   retcode := pcxSetBuffer(ADS buffer,bufmax);
  70.  
  71.   { Check if we have expanded memory, and display }
  72.   if (pcxEMInstalled = pcxSUCCESS) then begin
  73.     vfree := pcxVirtualFree(pcxEMM);
  74.     writeln('Free EMM: ',vfree);
  75.   end; {of if}
  76.  
  77.   { Display the amount of conventional free memory }
  78.   vfree := pcxVirtualFree(pcxCMM);
  79.   writeln('Free CMM: ',vfree);
  80.  
  81.   { Look at the current hardware, to find a B/W mode }
  82.   retcode := pcxVideoInfo(ADS vi);
  83.  
  84.   if (vi[1].adapter = viCGA) then
  85.     pcxtype := pcxCGA_6
  86.   else begin 
  87.     if (vi[1].adapter = viEGA) then begin
  88.       if (vi[1].display = viMDAdisp) then
  89.         pcxtype := pcxEGA_F
  90.       else
  91.         pcxtype := pcxEGA_10;
  92.     end
  93.     else begin
  94.       if (vi[1].adapter = viVGA) then
  95.         pcxtype := pcxVGA_11
  96.       else begin
  97.         if (vi[1].adapter = viHGC) then
  98.           pcxtype := pcxHERC
  99.         else
  100.           pcxtype := -1;
  101.       end;
  102.     end;
  103.   end;
  104.  
  105.   { If we found a mode, continue }
  106.   if (pcxtype <> -1) then begin
  107.  
  108.     { Set the display type }
  109.     retcode := pcxSetDisplay(pcxtype);
  110.  
  111.     { Load the image }
  112.     retcode := fxFileImage(pcxCMM,ADS vptr,ADS pcximage);
  113.     if (retcode = fxSUCCESS) then begin
  114.  
  115.       { Change to graphics mode }
  116.       retcode := pcxSetMode(pcxGRAPHICS);
  117.  
  118.       { Calibrate the delay timer, and play a looping song }
  119.       retcode := fxCalibrateDelay;
  120.       retcode := fxPlayLoop(25);
  121.       retcode := fxPlay(ADS 'T120 MB O3 L32 C D E F G A B A G F E D '*chr(0));
  122.  
  123.       { Select our effect }
  124.       retcode := fxSetEffect(fxRANDOM);
  125.       retcode := fxSetGrain(8);
  126.  
  127.       { and do it }
  128.       retcode := fxVirtualEffect(vptr,0,0,fxNONE);
  129.  
  130.       { Kill any remaining background music }
  131.       retcode := fxPlayKill;
  132.  
  133.       { Wait for a key }
  134.       key := DOSXQQ(1,0);
  135.  
  136.       { Get back to text mode }
  137.       retcode := pcxSetMode(pcxTEXT);
  138.  
  139.       { Were we successful? }
  140.       if (retcode <> fxSUCCESS) then
  141.         writeln('pcxVirtualEffect Error: ',retcode);
  142.  
  143.       { Destroy the image }
  144.       retcode := fxFreeImage(vptr);
  145.  
  146.     end
  147.     else begin
  148.       { Could not load image }
  149.       writeln('Could not load image: ',retcode);
  150.     end;
  151.  
  152.   end
  153.   else begin
  154.     { We could not find a good mode }
  155.     writeln('Could not find a good mode type . . .');
  156.   end; {of else}
  157.  
  158. end. { end of main }
  159.  
  160.