      SUBROUTINE TERM1(X,Y,N)
C
C SUBROUTINE TO PLOT ON TERM1 GRAPHICAL TERMINAL
C
      LOGICAL PART(4)
      LOGICAL m,d
      INTEGER X,Y,IX,IY
      EQUIVALENCE (IX,PART(1)),(IY,PART(3))
      DATA m,d/109,100/
      IX=X
      IY=Y
      IF(N.EQ.3) CALL UIT(m)
      IF(N.EQ.2) CALL UIT(d)
      CALL UIT(PART(2))
      CALL UIT(PART(1))
      CALL UIT(PART(4))
      CALL UIT(PART(3))
      RETURN
      END
      SUBROUTINE UIT(L1)
      LOGICAL L1
      CALL DELAY
      CALL OUT(208,L1)
      RETURN
      END
      SUBROUTINE DELAY
C
C THIS IS A SUBROUTINE TO MONITOR THE STATUS OF AN 8250 ACE
C LOCATED AT PORT 208-215. IF THE STATUSBIT IS ZERO, THE ACE
C MAY RECEIVE FURTHER CHARACTERS. WAITING SHOULD BE FOR A SHORT
C TIME, THEREFORE AN INDICATOR IS BUILT IN
C THE TRANSMITTER STATUS BIT IS LOCATED AT PORT (BASE+5) BIT 5
C THIS ROUTINE IS SPECIFIC FOR AN HEATH H89 CP/M SYSTEM WHERE
C TTY: AT 320-327(OCTAL) IS INITIALIZED AT 9600 BAUD
C This is an example of a device driver routine in fortran.
C Such routines are fast enough, as the serial line is the
C slower part of the system. Compared with assembly routines,
C device drivers in a high-level language are easier to
C modify.
C
      LOGICAL STATUS,BUSY,CTS
      DATA BUSY,CTS/32,16/
      K=0
      L=0
C
C THE FIRST CHECK IS PRINTER READY, INDICATED AS CONTROL S IF NOT
C
   10 CONTINUE
   40 L=L+1
      IF(L.EQ.32000) WRITE(5,2)
      STATUS=CTS.AND.INP(214)
      IF(STATUS.XOR.CTS) GOTO 40
      IF(BUSY.AND.INP(213)) RETURN
      K=K+1
      IF(K.GE.30) GOTO 20
      GOTO 10
   20 WRITE(5,1)
    1 FORMAT(' **ERROR** STATUS ACE REMAINS OCCUPIED')
    2 FORMAT(' GRAPHICS OCCUPIED')
      RETURN
      END
      SUBROUTINE RESGRA(N)
C
C reset term1 and set in graphical mode
C
      LOGICAL A,esc,Z,G,C,S,SP,CR,PAG,VIJF,EEN,NUL
      DATA A,esc,Z,G,C,S,SP,CR,VIJF,EEN,NUL/65,27,90,71,67,83,32,13,
     A53,49,48/
C
C page 1 will be cleared, page 2 is permanent
C
      CALL UIT(A)
      call uit(esc)
      call uit(esc)
      call uit(G)
      IF(N.EQ.2) GOTO 1
C
C N=3 means that all is cleared
C
      IF(N.EQ.3) CALL UIT(Z)
C
C selct page 2
C
      CALL UIT(S)
      CALL UIT(SP)
      CALL UIT(EEN)
      CALL UIT(NUL)
      CALL UIT(SP)
      CALL UIT(CR)
      call uit(C)
C
C show page 2 and page 3 alternating
C
      CALL UIT(Z-1)
      CALL UIT(SP)
      CALL UIT(EEN)
      CALL UIT(SP)
      CALL UIT(CR)
      RETURN
C
C select page 3
C
    1 CALL UIT(S)
      CALL UIT(SP)
      CALL UIT(EEN)
      CALL UIT(VIJF)
      CALL UIT(SP)
      CALL UIT(CR)
C
C USE PAGE 3 TO DISPLAY CUMULATIVE RESULTS
C
      RETURN
      END







MY+1-KH)
      IEIND=I*NX
      ISTART=IEIND-NX+1
C
C SET THE MX-80 I