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

      PROGRAM MAIN

      INTEGER COLORS, WIDTH
      PARAMETER (COLORS=16)
      PARAMETER (WIDTH=40)

      INTEGER BASE
      INTEGER COLOR
      INTEGER MINX, MAXX
      INTEGER MODE
      INTEGER FG_GETMODE

      CALL FG_INITPM
      MODE = FG_GETMODE()
      CALL FG_SETMODE(16)

      BASE = 0
      MINX = 0
      MAXX = WIDTH - 1

      DO 10 COLOR = 0,COLORS-1
         CALL FG_PALETTE(COLOR,0)
         CALL FG_SETCOLOR(COLOR)
         CALL FG_RECT(MINX,MAXX,0,349)
         MINX = MAXX + 1
         MAXX = MAXX + WIDTH
10    CONTINUE

20    IF (BASE .LT. COLORS*4) THEN
         DO 30 COLOR = 0,COLORS-1
            CALL FG_PALETTE(COLOR,BASE+COLOR)
30       CONTINUE
         BASE = BASE + COLORS
         CALL FG_WAITKEY
         GO TO 20
      END IF

      CALL FG_SETMODE(MODE)
      CALL FG_RESET

      STOP ' '
      END
