h35402
s 00264/00000/00000
d D 1.1 83/03/15 21:08:29 tes 1 0
c date and time created 83/03/15 21:08:29 by tes
e
u
4
U
t
T
I 1
#-h-  dd4012.rat          local   03/24/82  11:21
subroutine dd4012 (contrl, intin, rlin, intout, rlout)
########################################################################
#                                                                      #
#          THIS MATERIAL IS CONFIDENTIAL AND IS FURNISHED UNDER        #
#          A WRITTEN LICENSE AGREEMENT.  IT MAY NOT BE USED,           #
#          COPIED OR DISCLOSED TO OTHERS EXCEPT IN ACCORDANCE          #
#          WITH THE TERMS OF THAT AGREEMENT.                           #
#                                                                      #
#          COPYRIGHT (C) 1982 GRAPHIC SOFTWARE SYSTEMS INC.            #
#          ALL RIGHTS RESERVED.                                        #
#                                                                      #
#     Function: GSS-CORE device driver for Tektronix 4012              #
#                                                                      #
#     Input Parameters:                                                #
#            contrl(1-3) - An integer array with following information #
#                          contrl(1) - opcode for driver function      #
#                          contrl(2) - length of integer array intin   #
#                          contrl(3) - length of real input array rlin #
#                                                                      #
#            intin   -     Array of integer input parameters           #
#                                                                      #
#            rlin    -     Array of real input parameters              #
#                                                                      #
#     Output Parameters:                                               #
#            contrl(4-7) - contrl(4) - length of integer array intout  #
#                          contrl(5) - length of integer array rlout   #
#                          contrl(6) - count of any other control parms#
#                                                                      #
#             intout -     Array of integer output parameters          #
#                                                                      #
#             rlout  -     Array of integer output parameters          #
#                                                                      #
#     Routines Called:                                                 #
#            dm40xx - 40xx marker emulation routine                    #
#            dr40xx - 40xx move/draw routine                           #
#            gdevot - put a character to device                        #
#            gdstin - get a string from the current device             #
#            gdstot - output a string to the current device            #
#            gimnmx - bound an integer variable                        #
#                                                                      #
########################################################################
include mgsdef
 
# local defines
define(X_LIMITS_4012,1023.)            #4012 screen width
define(Y_LIMITS_4012,779.)             #4012 screen height
define (CHAR_SIZE,SHARP)
 
integer contrl(1),intin(1),intout(1)
real rlin(1),rlout(1)
 
integer opcode, x, y, i, j, gimnmx,
        tries, ginok, bytes(4),
        line(7), xhi, xlo, yhi, ylo,
        booboo(2), enable(4), setup(4),
        txtcap, lstcap, tszcap, gincap, mrkcap, bflcap
real chrwid, chrhgt,
     xcoord, ycoord
 
include mgscom
 
# The following equivalence statements are used to decrease the amount of code
#    necessary to access specific array elements. The arrays and the
#    variables equivalenced are listed below:
#
#       devcap(TEXT_CAP)         :: txtcap
#       devcap(LINESTYLE_CAP)    :: lstcap
#       devcap(TEXT_SIZE_CAP)    :: tszcap
#       devcap(GIN_CAP)          :: gincap
#       devcap(MARKER_CAP)       :: mrkcap
#       devcap(BAR_FILL_CAP)     :: bflcap
#
#       line(2) :: xhi
#       line(3) :: xlo
#       line(4) :: yhi
#       line(5) :: ylo
#
 
equivalence (devcap(TEXT_CAP), txtcap), (devcap(LINESTYLE_CAP), lstcap),
            (devcap(TEXT_SIZE_CAP), tszcap), (devcap(GIN_CAP), gincap),
            (devcap(MARKER_CAP), mrkcap), (devcap(BAR_FILL_CAP), bflcap),
            (line(2), xhi), (line(3), xlo), (line(4), yhi), (line(5), ylo)
 
 
#    chrwid /11.0/
data chrwid /.01074219/
 
#    chrhgt /14.0/
data chrhgt /.01367188/
 
#    booboo
data booboo /BELL, NEWLINE/
 
#    enable GIN
data enable /BELL, ESC, SUB, NEWLINE/
 
#    setup - initialize device
data setup /US, ESC, CHAR_SIZE, NEWLINE/
 
 
opcode=contrl(OPCODE)
 
#
#  opcode move and draw
#
if ((opcode == DRAW) | (opcode == MOVE)) {
   if (ndlntp == 1 | opcode == MOVE) {
      call dr40xx (opcode, rlin)
      }
   else {
      call da40xx (rlin)    # Emulate dashed lines
      }
   }
 
#
#  opcode text
#
else if (opcode == TEXT) {
      j = contrl(INTEGER_IN_LENGTH)
      call gdstot (j, intin)
      }
 
#
#  opcode marker
#
else if (opcode == MARKER) {
      call dm40xx (intin, rlin)
      }
 
#
#  opcode fill pattern
#
else if (opcode == SET_FILL_COLOR) {
      ndclrf = gimnmx (intin(1), 0, 7)   # Emulation supports 8 patterns
      intout(1) = ndclrf
      }
 
#
#  opcode polygon edge style
#
else if (opcode == SET_POLYGON_EDGE_STYLE) {
      ndedgs = intin(1)
      }
 
#
#  opcode line style
#
else if (opcode == LINESTYLE) {
      ndlntp = gimnmx (intin(1), 1, 5)   # Emulation supports 5 styles
      intout(1) = ndlntp   # Return the line style set
      }
 
#
#  opcode get point
#
else if (opcode == GET_POINT) {
        contrl(4) = 0    # Initialize the output count
        ginok = YES
        tries = 0
        repeat {
                # enable thumbwheel gin
                call gdstot (4, enable)
                call gdstin (7, line, i)
                if (i <= 5) {  # make sure there are right number of chars
                        for (j=2; j<=i; j=j+1) {
                                # verify chars valid
                                if (line(j) < SPACE | line(j) > QMARK) {
                                        ginok = NO
                                        call gdstot (2, booboo)
                                        }
                                }
                        }
                else {  # too many chars -- ooooops
                        ginok = NO
                        call gdstot (2, booboo)
                        }
                tries = tries + 1
 
                } until (ginok == YES | tries > 3)
 
        # decode the data returned
 
        if (ginok == YES) {
                # rlout(1) = x
                # rlout(2) = y
 
#                xcoord = float ((line(2)-SPACE)*SPACE + line(3)-SPACE)
                xcoord = float ((xhi-SPACE)*SPACE + xlo-SPACE)
 
#                ycoord = float ((line(4)-SPACE)*SPACE + line(5)-SPACE)
                ycoord = float ((hiy-SPACE)*SPACE + loy-SPACE)
 
                rlout(1) = xcoord / X_LIMITS_4012
                rlout(2) = ycoord / X_LIMITS_4012
                intout (1) = line(1)
                contrl(4) = 1
                }
        }
 
#
#   opcode text_size
#
else if (opcode == TEXT_SIZE) {
      rlout(1) = chrwid   # We only support the standard character size on
      rlout(2) = chrhgt   #    4012.
      }
 
#
#    opcode new_frame
#
else if (opcode == NEW_FRAME) {
      call gdevot (ESC)
      call gdevot (FF)
      for (i=1; i <=1200; i = i + 1) call gdevot (SYN)
      }
 
#
# opcode set_device_parameters
#
else if (opcode == SET_DEVICE_PARAMETERS) {
 
      # set up device capability array
 
      txtcap = YES   # Text capability
      lstcap = 5     # Capable of 5 different linestyles
      tszcap = 2     # Capable of 2 different text sizes
      gincap = YES   # Gin capability
      mrkcap = 5     # Capable of 5 different Markers
 
      zdlgax = X_LIMITS_4012      # Set the length of the longest axis.
      zdxlng = 1.0                # Set the length of each axis in NDCs
      zdylng = 0.76148583         # Y_LIMITS_4012 / X_LIMITS_4012
      zdxpos = 0.0                # Initialize the device position registers
      zdypos = 0.0
      ndlntp = 1                  # Set current device line style
      ndtxsz = 1                  # Set current device text size
 
      # put device in graphics mode, set character size to small, and
 
      call gdstot (4, setup)
      }
 
#
#     stop graphics
#
else if (opcode == STOP_GRAPHICS) {
      call gdevot (US)
      call gdevot (NEWLINE)
      }
 
#
#     inquire screen size
#
else if (opcode == INQUIRE_SCREEN_SIZE) {
      rlout(1) = zdxlng
      rlout(2) = zdylng
      rlout(3) = X_LIMITS_4012
      }
 
return
end
#-t-  dd4012.rat          local   03/24/82  11:21
#-h-  dd4025.rat          local   03/24/82  11:21
E 1
