$INCLUDE: 'C:\FG\INTRFACE.FOR'

      PROGRAM MAIN

      INTEGER*2 NEW_MODE, OLD_MODE
      INTEGER*2 READ_STATUS, WRITE_STATUS
      INTEGER*2 FG_BESTMODE, FG_GETMODE, FG_MAKESPR, FG_SHOWSPR

      NEW_MODE = FG_BESTMODE(320,200,1)
      IF (NEW_MODE .LT. 0 .OR. NEW_MODE .EQ. 12) THEN
         STOP 'This program requires a 320 x 200 color graphics mode.'
      END IF
      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(NEW_MODE)
      CALL FG_MOVE(0,199)

      READ_STATUS = FG_SHOWSPR('CORAL.SPR'//CHAR(0),320)
      CALL FG_WAITKEY
      IF (READ_STATUS .EQ. 0) THEN
         WRITE_STATUS = FG_MAKESPR(0,319,80,99,'NEW.SPR'//CHAR(0))
      ELSE
         WRITE_STATUS = 1
      END IF

      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      IF (READ_STATUS .EQ. 1)  WRITE(6,*) 'CORAL.SPR not found.'
      IF (WRITE_STATUS .EQ. 1) WRITE(6,*) 'NEW.SPR not created.'

      STOP ' '
      END
