C        COPYRIGHT 1985 UNIVERSITY OF GLASGOW                           0001.000
C        GX SYSTEM LIBRARY OF GRAPHICS DRIVER ROUTINES FOR TEKTRONIX    0002.000
C        4010 COMPATIBLE DEVICES (GOULD S.E.L. MACHINE-SPECIFIC).       0003.000
C        PAUL R. MALLINSON APRIL 1985                                   0004.000
         SUBROUTINE XYVECT(IPEN,IX,IY)                                  0005.000
         INTEGER*1 CBUF(12),GS,ESC,ENQ,NUL                              0006.000
         LOGICAL VMODE                                                  0007.000
         DIMENSION BUF(3)                                               0008.000
         COMMON /XY/ CBUF,IVCOUNT,VMODE,IXOLD,IYOLD                     0009.000
         COMMON/PLOTDEV/IOG                                             0010.000
         EQUIVALENCE (BUF(1),CBUF(1))                                   0011.000
          DATA GS/2Z1D/,ESC/2Z1B/,ENQ/2Z05/,NUL/2Z00/                   0012.000
         CALL M:WAIT(IOG)                                               0013.000
         BUF(2)=0.                                                      0014.000
         IF (IPEN.GE.0) GO TO 1                                         0015.000
         CALL ITOA(IX,IY,2)                                             0016.000
         CBUF(1)=GS                                                     0017.000
         CALL BUFFEROUT(IOG,1,BUF,2)                                    0018.000
         VMODE =.TRUE.                                                  0019.000
         GO TO 4                                                        0020.000
 1       IF (VMODE) GO TO 2                                             0021.000
         BUF(3)=0.                                                      0022.000
         CBUF(1)=GS                                                     0023.000
         CALL ITOA(IXOLD,IYOLD,2)                                       0024.000
         IF (IOG.NE.8) GO TO 5                                          0025.000
         CALL ITOA(IX,IY,7)                                             0026.000
         GO TO 6                                                        0027.000
 5       CALL ITOA(IX,IY,6)                                             0028.000
 6       CALL BUFFEROUT(IOG,1,BUF,3)                                    0029.000
         VMODE=.TRUE.                                                   0030.000
         GO TO 3                                                        0031.000
 2       CALL ITOA(IX,IY,1)                                             0032.000
         IF (IOG.NE.8) GO TO 7                                          0033.000
         CALL BUFFEROUT(IOG,1,BUF,2)                                    0034.000
         GO TO 3                                                        0035.000
 7       CALL BUFFEROUT(IOG,1,BUF,1)                                    0036.000
 3       IVCOUNT=IVCOUNT+1                                              0037.000
         IF (IVCOUNT.LT.20) GO TO 4                                     0038.000
C         CALL M:WAIT(IOG)                                              0039.000
C          CBUF(1)=ESC                                                  0040.000
C          CBUF(2)=NUL                                                  0041.000
C         CBUF(3)=NUL                                                   0042.000
C         CBUF(4)=ENQ                                                   0043.000
C          CALL BUFFERIN(IOG,1,BUF(2),1)                                0044.000
C           CALL BUFFEROUT(IOG,1,BUF,1)                                 0045.000
         CALL WAIT(100,1,M)                                             0046.000
         IVCOUNT=0                                                      0047.000
 4       IXOLD=IX                                                       0048.000
         IYOLD=IY                                                       0049.000
        RETURN                                                          0050.000
         END                                                            0051.000
         SUBROUTINE ITOA(IX,IY,I)                                       0052.000
         INTEGER*1 COORDS(12)                                           0053.000
         LOGICAL VMODE                                                  0054.000
         COMMON /XY/ COORDS,IVCOUNT,VMODE,IXOLD,IYOLD                   0055.000
         COMMON/PLOTDEV/IOG                                             0056.000
         DATA IHYTAG/2Z20/,LOYTAG/2Z60/,LOXTAG/2Z40/                    0057.000
         IF (IOG.NE.8) GO TO 1                                          0058.000
         IXH=IX/4                                                       0059.000
         IYH=IY/4                                                       0060.000
         COORDS(I)=IYH/32+IHYTAG                                        0061.000
         COORDS(I+1)=4*MOD(IY,4)+MOD(IX,4)+LOYTAG                       0062.000
         COORDS(I+2) =MOD(IYH,32)+LOYTAG                                0063.000
         COORDS(I+3)=IXH/32+IHYTAG                                      0064.000
         COORDS(I+4) =MOD(IXH,32)+LOXTAG                                0065.000
         RETURN                                                         0066.000
 1       COORDS(I)=IY/32+IHYTAG                                         0067.000
         COORDS(I+1) =MOD(IY,32)+LOYTAG                                 0068.000
         COORDS(I+2)=IX/32+IHYTAG                                       0069.000
         COORDS(I+3) =MOD(IX,32)+LOXTAG                                 0070.000
         RETURN                                                         0071.000
         END                                                            0072.000
         SUBROUTINE XYCHAR(STRING)                                      0073.000
         INTEGER*1 STRING(1),NUL,CBUF(12)                               0074.000
         LOGICAL VMODE                                                  0075.000
         COMMON /XY/ CBUF,IVCOUNT,VMODE,IXOLD,IYOLD                     0076.000
         COMMON /PLOTDEV/ IOG                                           0077.000
         DATA US/8Z1F000000/,NUL/2Z00/                                  0078.000
         CALL M:WAIT(IOG)                                               0079.000
         CALL BUFFEROUT(IOG,1,US,1)                                     0080.000
         VMODE=.FALSE.                                                  0081.000
         DO 1 I=1,73                                                    0082.000
         IF (STRING(I).EQ.NUL) GO TO 2                                  0083.000
 1       CONTINUE                                                       0084.000
         I=74                                                           0085.000
 2       ICOUNT=(I-1)/4                                                 0086.000
         NNUL=4-MOD(I-1,4)                                              0087.000
         IF (NNUL.EQ.4) GO TO 4                                         0088.000
         ICOUNT=ICOUNT+1                                                0089.000
         DO 3 J=1,NNUL                                                  0090.000
 3       STRING(I-1+J)=NUL                                              0091.000
 4       CALL M:WAIT(IOG)                                               0092.000
         CALL BUFFEROUT(IOG,1,STRING,ICOUNT)                            0093.000
         CALL M:WAIT(IOG)                                               0094.000
         RETURN                                                         0095.000
         END                                                            0096.000
         SUBROUTINE XYSCAL(X,Y)                                         0097.000
         INTEGER*1 CBUF(12)                                             0098.000
         DIMENSION BUF(3)                                               0099.000
         COMMON /PLOTDEV/IOG                                            0100.000
         EQUIVALENCE(BUF(1),CBUF(1))                                    0101.000
         DATA CBUF/2Z1B,2Z41,2Z49,2Z00,2Z00,2Z00,2Z2C,2Z00,2Z00,2Z00,   0102.000
     1   2Z0D,2Z00/                                                     0103.000
         IX=X*56                                                        0104.000
         IY=Y*88                                                        0105.000
         ENCODE(3,10,CBUF(4)) IX                                        0106.000
         ENCODE(3,10,CBUF(8)) IY                                        0107.000
 10      FORMAT(I3)                                                     0108.000
         CALL M:WAIT(IOG)                                               0109.000
         CALL BUFFEROUT(IOG,1,BUF,3)                                    0110.000
         CALL M:WAIT(IOG)                                               0111.000
         RETURN                                                         0112.000
         END                                                            0113.000
         SUBROUTINE XYRSET                                              0114.000
         CHARACTER   CBUF(4)                                            0115.000
         COMMON /PLOTDEV/IOG                                            0116.000
         EQUIVALENCE(BUF,CBUF(1))                                       0117.000
         DATA CBUF/2Z1B,2Z41,2Z56,2Z00/                                 0118.000
         CALL M:WAIT(IOG)                                               0119.000
         CALL BUFFEROUT(IOG,1,BUF,1)                                    0120.000
         CALL M:WAIT(IOG)                                               0121.000
         RETURN                                                         0122.000
         END                                                            0123.000
         SUBROUTINE XYINIT                                              0124.000
         LOGICAL VMODE                                                  0125.000
         COMMON /XY/ BUF(3),IVCOUNT,VMODE,IXOLD,IYOLD                   0126.000
         COMMON /PLOTDEV/ IOG                                           0127.000
         DATA SUB/8Z1A000000/                                           0128.000
         IVCOUNT=0                                                      0129.000
         IOG=7                                                          0130.000
         CALL M:WAIT(7)                                                 0131.000
         CALL BUFFEROUT(7,1,SUB,1)                                      0132.000
         RETURN                                                         0133.000
         END                                                            0134.000
         SUBROUTINE XYHOME                                              0135.000
         INTEGER*1 CBUF(4)                                              0136.000
         COMMON /PLOTDEV/IOG                                            0137.000
         EQUIVALENCE(BUF,CBUF(1))                                       0138.000
         DATA CBUF/2Z1B,2Z0C,2Z18,2Z00/                                 0139.000
         KIOG=IOG                                                       0140.000
         IOG=7                                                          0141.000
         CALL XYVECT(-1,0,50)                                           0142.000
         IOG=KIOG                                                       0143.000
         WRITE ('UT',2)                                                 0144.000
 2       FORMAT (' PRESS <CR> TO CONTINUE')                             0145.000
         READ ('UT',1)                                                  0146.000
 1       FORMAT(A4)                                                     0147.000
         CALL BUFFEROUT(7,1,BUF,1)                                      0148.000
         CALL M:WAIT(7)                                                 0149.000
         CALL WAIT(1000,1,M)                                            0150.000
         RETURN                                                         0151.000
         END                                                            0152.000
         SUBROUTINE XYVDU                                               0153.000
         LOGICAL VMODE                                                  0154.000
         COMMON /XY/ BUF(3),IVCOUNT,VMODE,IXOLD,IYOLD                   0155.000
         COMMON /PLOTDEV/IOG                                            0156.000
         DATA USCAN/8Z1F180000/                                         0157.000
         CALL M:WAIT(7)                                                 0158.000
         CALL BUFFEROUT(7,1,USCAN,1)                                    0159.000
         IF (IOG.EQ.7) VMODE=.FALSE.                                    0160.000
         RETURN                                                         0161.000
         END                                                            0162.000
         SUBROUTINE XYROT(ANG)                                          0163.000
         INTEGER*1 CBUF(12)                                             0164.000
         DIMENSION BUF(3)                                               0165.000
         COMMON /PLOTDEV/IOG                                            0166.000
         EQUIVALENCE(BUF(1),CBUF(1))                                    0167.000
         DATA CBUF/2Z1B,2Z41,2Z4A,2Z00,2Z00,2Z00,2Z00,2Z00,2Z00,2Z00,   0168.000
     1   2Z0D,2Z00/                                                     0169.000
         ENCODE(7,10,CBUF(4)) ANG                                       0170.000
 10      FORMAT(F7.1)                                                   0171.000
         CALL M:WAIT(IOG)                                               0172.000
         CALL BUFFEROUT(IOG,1,BUF,3)                                    0173.000
         CALL M:WAIT(IOG)                                               0174.000
         RETURN                                                         0175.000
         END                                                            0176.000
         SUBROUTINE XYCLER                                              0177.000
         DATA SUB/8Z1A000000/                                           0178.000
         CALL M:WAIT(7)                                                 0179.000
         CALL BUFFEROUT(7,1,SUB,1)                                      0180.000
         CALL M:WAIT(7)                                                 0181.000
         RETURN                                                         0182.000
         END                                                            0183.000
         SUBROUTINE XYPEN(I)                                            0184.000
         INTEGER*1 CBUF(8)                                              0185.000
         DIMENSION BUF(2)                                               0186.000
         COMMON /PLOTDEV/IOG                                            0187.000
         EQUIVALENCE(BUF(1),CBUF(1))                                    0188.000
         DATA CBUF/2Z1B,2Z41,2Z42,2Z50,2Z00,2Z1B,2Z41,2Z45/             0189.000
         ENCODE(1,10,CBUF(5)) I                                         0190.000
 10      FORMAT(I1)                                                     0191.000
         CALL M:WAIT(IOG)                                               0192.000
         CALL BUFFEROUT(IOG,1,BUF,2)                                    0193.000
         RETURN                                                         0194.000
         END                                                            0195.000
                                                                        0196.000
                                                                        0197.000
                                                                        0198.000
                                                                        0199.000
                                                                        0200.000
                                                                        0201.000
                                                                        0202.000
                                                                        0203.000
                                                                        0204.000
                                                                        0205.000
                                                                        0206.000
                                                                        0207.000
                                                                        0208.000
                                                                        0209.000
                                                                        0210.000
                                                                        0211.000
                                                                        0212.000
                                                                        0213.000
                                                                        0214.000
                                                                        0215.000
                                                                        0216.000
                                                                        0217.000
                                                                        0218.000
                                                                        0219.000
                                                                        0220.000




















