* fxSimple.FOR                                                              *
* Copyright (c) Genus Microprogramming, Inc. 1988-89  All Rights Reserved.  *

*****************************************************************************
*                                                                           *
* This program is the simplest example of effect usage. It is an example    * 
* Fortran routine for PCX Effects.                                          * 
*                                                                           *
* NOTE: REQUIRES A CGA (or compatible) ADAPTER AND DISPLAY!                 *
*                                                                           *
* Microsoft Fortran 4.1                   Programmer: Chris Howard  5/25/89 *
*                                                                           *
*****************************************************************************

* Include the PCX Toolkit and PCX Effects interfaces
$INCLUDE: 'pcxint.for'
$INCLUDE: 'fxint.for'

PROGRAM fxSimple

* Include the PCX Toolkit and PCX Effects constants
$INCLUDE: 'pcxlib.for'
$INCLUDE: 'fxlib.for'

* Globals
      CHARACTER*20  pcximage [C]
      INTEGER*2     pcxtype,retcode,tempret
      INTEGER*4     vptr

      CHARACTER*1   key

      DATA pcxtype  /pcxCGA_4/
      DATA pcximage /'fxSimple.PCX' C/
      DATA retcode  /-999/
      DATA tempret  /-999/

***********

* Display program header
      PRINT '(A)',' '
      PRINT '(A)','  Simple Example Fortran PCX Effects Program '
      PRINT '(A)',' '

*     Get a key, to begin
      PRINT '(A)',' Press [ENTER] to run . . .'
      READ(*,'(A1)') key

*     Set the display type 
      retcode = pcxSetDisplay(pcxtype)

*     Select our effect
      retcode = fxSetEffect(fxSAND)

*     Calibrate the delay timer
      retcode = fxCalibrateDelay

*     Load the image
      retcode = fxFileImage(pcxCMM,vptr,pcximage)
      IF (retcode .EQ. fxSUCCESS) THEN

*       Set the mode we will be using
        retcode = pcxSetMode(pcxGRAPHICS)
        IF (retcode .EQ. pcxSUCCESS) THEN

*         and do it
          retcode = fxVirtualEffect(vptr,0,0,fxNONE)

*         Wait for a key
          READ(*,'(A1)') key

*         Return to text mode
          tempret = pcxSetMode(pcxTEXT)

        ENDIF

*       Free the image from memory
        tempret = fxFreeImage(vptr)

      ENDIF

*     Check if everything went OK
      IF (retcode .NE. pcxSUCCESS) THEN
        PRINT '(A)',' '
        PRINT '(A,I3,A)',' An error occurred: [',retcode,' ]'
        PRINT '(A)',' '
        PRINT '(A)',' You may not have a CGA, or the image FXSIMPLE.PCX'
        PRINT '(A)',' may not be in the current directory.'
        PRINT '(A)',' '
      ENDIF

      END
