home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / cpmug / cpmug091.ark / HI.FOR < prev    next >
Encoding:
Text File  |  1984-04-29  |  5.2 KB  |  202 lines

  1. C *******************************************************
  2. C
  3. C            PLOT ROUTINES FOR DMP2 PLOTTER
  4. C
  5. C  Written by Victor DePinto,  1980, 1981, 1982
  6. C  Last revised Jan. 26, 1982
  7. C
  8. C ******************************************************
  9. C
  10. C The following routine returns the plotter pen to
  11. C the lower left of the display space.
  12. C
  13.       SUBROUTINE HOME
  14.       CALL DRAW ( 0.0, 0.0, .FALSE. )
  15.       RETURN
  16.       END
  17. C
  18. C *********************************************
  19. C
  20. C Draws a border
  21. C
  22.       SUBROUTINE BORDER
  23.       Y = 0.0
  24.       X = 1.0
  25.       CALL DRAW (X, Y, .TRUE.)
  26.       Y = 1.0
  27.       CALL DRAW (X, Y, .TRUE.)
  28.       X = 0.0
  29.       CALL DRAW (X, Y, .TRUE.)
  30.       Y = 0.0
  31.       CALL DRAW (X, Y, .TRUE.)
  32.       CALL HOME
  33.       RETURN
  34.       END
  35. C
  36. C **********************************************
  37. C
  38. C Draws gridlines
  39. C
  40.       SUBROUTINE GRID
  41.       WRITE (1,1)
  42. 1     FORMAT (' How many horizontal zones?'/)
  43.       READ (1,3) HZONS
  44. 3     FORMAT (F10.0)
  45.       WRITE (1,5)
  46. 5     FORMAT ('+How many vertical zones?'/)
  47.       READ (1,3) VZONS
  48.       IHLINS = HZONS - 1
  49.       IVLINS = VZONS - 1
  50.       X = 0.0
  51.       DO 7 J = 1,IVLINS
  52.       Y = J / VZONS
  53.       CALL DRAW (X, Y, .FALSE.)
  54.       IF (X .EQ. 0) GO TO 30
  55.       X = 0.0
  56.       GO TO 7
  57. 30    X = 1.0
  58. 7     CALL DRAW (X, Y, .TRUE.)
  59.       Y = 1.0
  60.       DO 10 J = 1,IHLINS
  61.       X = J / HZONS
  62.       CALL DRAW (X, Y, .FALSE.)
  63.       IF (Y .EQ. 0.0 ) GO TO 40
  64.       Y = 0.0
  65.       GO TO 10
  66. 40    Y = 1.0
  67. 10    CALL DRAW (X, Y, .TRUE.)
  68.       CALL HOME
  69.       END
  70. C
  71. C ***********************************************************
  72. C
  73. C The following routine sets the pen speed of the plotter.
  74. C
  75.       SUBROUTINE SPEED
  76.       INTEGER D
  77.       DATA R, C / 200.0, 0.000477 /
  78.       WRITE (1,10)
  79. 10    FORMAT (' Enter pen speed in inches per second
  80.      X (2.4 is max): ')
  81.       READ (1,20) S
  82. 20    FORMAT (F10.0)
  83. C The following code computes the integer delay constant, D, a
  84. C parameter indicating delay in tenth milliseconds.
  85. C Where:    D = Delay of delay routine in tenths of milliseconds.
  86. C           S = Desired pen speed in inches per second.
  87. C           R = Steps per inch of plotter.
  88. C           C = The time required to compute the step.
  89. C Note: The DMP2 can be strapped for either 100 or 200 steps per inch.
  90.       D = 10000.0 * (1.0/(R*S) - C)
  91.       CALL SETTIM ( D )
  92.       RETURN
  93.       END
  94. C
  95. C **********************************************************
  96. C
  97. C This routine moves to problem space position X, Y.
  98. C X and Y are unity full scale. 0,0 is lower left.
  99. C If DRWFLG is true on entry, a line is drawn; otherwise,
  100. C it is just a move.
  101. C
  102.       SUBROUTINE DRAW ( X, Y, DRWFLG )
  103.       LOGICAL DRWFLG, STATUS
  104.       INTEGER XD, YD, XPEN, YPEN, XWNDOW, YWNDOW
  105.       INTEGER XMOV, YMOV, ESTAT
  106.       COMMON /FISH/XMOV,YMOV
  107.       DATA XPEN, YPEN, XWNDOW, YWNDOW / 0, 0, 2000, 1400 /
  108.      X          ,STATUS / 0 /
  109. C EXPLAINATION OF STATUS BYTE:
  110. C BIT    MEANING
  111. C  0     Pen down
  112. C  1     Draw (move with pen down)
  113. C  2     Previous destination offscale
  114. C  3     Entry destination offscale
  115. C
  116. C Set the "Destination Offscale" and "Draw" bits in the status word
  117. C so that it correctly reflects status on entry to this routine.
  118.       STATUS = STATUS .AND. X'F5'
  119.       STATUS = STATUS .OR. ( 8 .AND. ( X .LT. 0.0 .OR. X .GT. 1.0
  120.      X         .OR. Y .LT. 0.0 .OR. Y .GT. 1.0 ) )
  121.      X         .OR. ( 2 .AND. DRWFLG )
  122. C This indicates status on entry to this routine.
  123.       ESTAT = STATUS + 1
  124. C Take action as required by plot algorithm.
  125.       GO TO (30,25,26,30,28,60,28,60,30,25,30,25,60,60,60), ESTAT
  126.       RETURN
  127. 25    CALL PENUP
  128.       STATUS = STATUS .AND. X'FE'
  129.       GO TO 30
  130. 26    CALL PENDN
  131.       STATUS = STATUS .OR. 1
  132.       GO TO 30
  133. 28    STATUS = STATUS .AND. X'FB'
  134. 30    GO TO (50,50,50,50,50,60,50,60,40,40,40,40,60,60,60), ESTAT
  135.       RETURN
  136. 40    STATUS = STATUS .OR. 4
  137.       GO TO 60
  138. C
  139. C Do the move.
  140. C
  141. C Convert to display space.
  142. 50    XD = X * XWNDOW
  143.       YD = Y * YWNDOW
  144. C Compute the move.
  145.       XMOV = XD - XPEN
  146.       YMOV = YD - YPEN
  147.       CALL VECTOR
  148. C Update the pen position.
  149.       XPEN = XD
  150.       YPEN = YD
  151. 60    RETURN
  152.       END
  153. C
  154. C ***********************************************************
  155. C
  156. C The following routine draws a vector on the the DMP2.
  157. C Entry parameters are X and Y.
  158. C This routine is taken from the Houston Instruments manual.
  159. C
  160.       SUBROUTINE VECTOR
  161.       LOGICAL ASTR(16), CHAR
  162.       INTEGER D,E,F,I,T,X,Y,Z
  163.       COMMON /FISH/X,Y
  164.       DATA ASTR/'p','q','r','q','r','s','t','s','t',
  165.      + 'u','v','u','v','w','p','w'/
  166. 130   F = IABS(X) + IABS(Y)
  167. 140   IF (F.EQ.0) GO TO 470
  168. 150   D = IABS(Y) - IABS(X)
  169. 180   I = 0
  170. 190   IF (Y.LT.0) GO TO 210
  171. 200   I=2
  172. 210   T=X+Y
  173. 220   IF (T.LT.0) GO TO 240
  174. 230   I=I+2
  175. 240   T=Y-X
  176. 250   IF (T.LT.0) GO TO 270
  177. 260   I=I+2
  178. 270   IF (X.LT.0) GO TO 300
  179. 280   I=8-I
  180. 290   GO TO 310
  181. 300   I=I+10
  182. 310   IF (D.LT.0) GO TO 350
  183. 320   T=IABS(X)
  184. 330   D = -D
  185. 340   GO TO 360
  186. 350   T=IABS(Y)
  187. 360   E=0
  188. 370   Z=T+D+E+E
  189. 380   IF (Z.LT.0) GO TO 430
  190. 390   E=E+D
  191. 400   F=F-2
  192. 410   CHAR = ASTR(I)
  193.       CALL PRINT (CHAR)
  194. 420   GO TO 460
  195. 430   E=E+T
  196. 440   F=F-1
  197. 450   CHAR = ASTR(I-1)
  198.       CALL PRINT (CHAR)
  199. 460   IF (F.GT.0) GO TO 370
  200. 470   RETURN
  201.                   E  N  D
  202.