$INCLUDE: 'C:\FG\FASTGRAF.FI'

      PROGRAM MAIN

      INTEGER*1 KEY, AUX
      INTEGER HANDLE, OLD_MODE, STATUS, X, Y
      INTEGER FG_GETMODE, FG_LOADPCX, FG_VBALLOC, FG_VBOPEN

      CALL FG_INITPM
      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(19)

      CALL FG_VBINIT
      HANDLE = FG_VBALLOC(320,200)
      IF (HANDLE .LT. 0) THEN
         CALL FG_SETMODE(OLD_MODE)
         CALL FG_RESET
         STOP 'Could not create the virtual buffer.'
      END IF
      STATUS = FG_VBOPEN(HANDLE)
      STATUS = FG_LOADPCX('CORAL.PCX'//CHAR(0),0)
      CALL FG_VBCLOSE

      CALL FG_SETCOLOR(2)
      CALL FG_FILLPAGE
      CALL FG_SETCOLOR(15)
      CALL FG_BOX(111,208,69,130)
      CALL FG_LOCATE(3,8)
      CALL FG_TEXT('Press arrow keys to pan.',24)

      X = 112
      Y = 129
      CALL FG_VBPASTE(X,X+95,Y-59,Y,112,129)

10    CALL FG_GETKEY(KEY,AUX)
      IF (AUX .EQ. 72 .AND. Y .LT. 199) THEN
         Y = Y + 1
      ELSE IF (AUX .EQ. 75 .AND. X .LT. 223) THEN
         X = X + 1
      ELSE IF (AUX .EQ. 77 .AND. X .GT. 0) THEN
         X = X - 1
      ELSE IF (AUX .EQ. 80 .AND. Y .GT. 59) THEN
         Y = Y - 1
      ENDIF
      CALL FG_VBPASTE(X,X+95,Y-59,Y,112,129)
      IF (KEY .NE. 27) GO TO 10

      CALL FG_VBFREE(HANDLE)
      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
      END
