CC  PAGE.FOR - Illustrates animation effects by changing the video page.
CC             The video page functions demonstrated include:
CC             getactivepage  getvisualpage  setactivepage  setvisualpage

      INCLUDE  'FGRAPH.FI'
      INCLUDE  'FGRAPH.FD'

      INTEGER*2        dummy, oldapage, oldvpage
      INTEGER*2        page, row, col, line, count
      CHARACTER*3      jumper(4,3)
      RECORD /rccoord/ curpos
      RECORD / videoconfig / vc

      DATA jumper / '\o/', '_o_', ' o ', ' o ',
     +              ' O ', ' O ', '/O\', ' O ',
     +              '/ \', '( )', '/ \', '( )' /

      CALL getvideoconfig( vc )
      IF( vc.numvideopages .LE. 4 )
     +    STOP 'Error:  not enough pages'
      oldapage  = getactivepage()
      oldvpage  = getvisualpage()
      IF( setvideomode( $TEXTBW40 ) .EQ. 0 )
     +    STOP 'Error:  cannot set 40-column mode'
      dummy     = displaycursor( $GCURSOROFF )

C
C     Draw 24 images on each page.
C
      DO page = 1, 4
         dummy = setactivepage( page - 1 )
         DO row = 1, 22, 7
            DO col = 1, 36, 7
               DO line = 0, 2
                  CALL settextposition( row + line, col, curpos )
                  CALL outtext( jumper(page, line + 1) )
               END DO
            END DO
         END DO
      END DO

C
C     Cycle 10 times through pages 0-3.
C
      DO count = 1, 10
         DO page = 0, 3
            dummy = setvisualpage( page )
            CALL delay( INT2( 10 ) )
         END DO
      END DO

C
C     Restore original page.
C
      dummy = setvideomode( $DEFAULTMODE )
      dummy = setactivepage( oldapage )
      dummy = setvisualpage( oldvpage )
      END



CC  DELAY - Pauses for a specified number of 1/100 seconds.
CC
CC  Params:  wait - pause time in 0.01 seconds

      SUBROUTINE delay( wait )
      INTEGER*2 wait, tick0, tick1, tick, kount, dummy

      kount = 0
      CALL GETTIM( dummy, dummy, dummy, tick0 )
      DO WHILE( kount .LT. wait )
         CALL GETTIM( dummy, dummy, dummy, tick1 )
         tick = tick1 - tick0
         IF( tick .LT. 0 ) tick = tick + 100 
         tick0 = tick1
         kount = kount + tick
      END DO
      RETURN
      END
