h13382
s 00478/00000/00000
d D 1.1 83/03/15 21:04:20 tes 1 0
c date and time created 83/03/15 21:04:20 by tes
e
u
4
U
t
T
I 1
#-h-  hp.c                local   03/24/82  10:30
#-h-  dd2647.rat          local   03/24/82  10:30
subroutine dd2647 (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.                                        #
#                                                                      #
#     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-6) - contrl(4) - length of integer array intout  #
#                          contrl(5) - length of integer array rlout   #
#                          contrl(6) - count of any other control parms#
#                                                                      #
#             rlout  -     Array of integer output parameters          #
#                                                                      #
#     Routines Called:                                                 #
#             chtoi   - convert a character string to a binary integer #
#             dm2647 - marker output emulation for HP2647              #
#             dr2647 - move/draw for HP2647                            #
#             gdevot  - put a character to device                      #
#             gdstot - put a character string to the device            #
#             gdstin - get a string of characters from the device      #
#             gimnmx - bound an integer variable                       #
#             itoch  - convert integer to character string             #
#                                                                      #
########################################################################
include mgsdef
 
# local defines
define(X_LIMITS_2647,719.)             # screen surface width
define(Y_LIMITS_2647,359.)             # screen surface height
 
integer contrl(1),intin(1),intout(1)
real rlin(1),rlout(1)
 
integer opcode, i, line(20), len, j, kstop, xin, yin, nchar, gimnmx,
	txtout(4), setsiz(5), lstyle(6), newfrm(4), solid(5),
        enagin(6), setup(13), txtoff(4), itoch, rotate(5), filbar(3)
real chrwid, chrhgt, lastpt(2), areain, pwr2, darea
 
include mgscom
 
#   The character cell for the HP2647 is 7x10 including intercharacter gap.
#   We add 1 to the character height for an interline gap.
 
#            chrwid = 7./X_LIMITS_2647
data chrwid /0.009735/
 
#            chrhgt = (10+1)/X_LIMITS_2647
data chrhgt /0.015299/
 
#            Set line/fill style to solid - <ESC>*m1B
data  solid/  ESC, STAR, LETM, DIG1, BIGB/
 
#            Enable gin - <ESC>*s4^
data enagin/ ESC, STAR, LETS, DIG4, CARET, NEWLINE/
 
#            Line style - <ESC>*m<style>B
data lstyle/ ESC, STAR, LETM, DIG1, BIGB, NEWLINE/
 
#            New frame - <ESC>*dA
data newfrm/ ESC, STAR, LETD, BIGA/
 
#            Set up for graphics
#		Reset environmentals       <ESC>*mR
#		Turn off alpha cursor      <ESC>*dR
#		Home alpha cursor          <ESC>H
#		Clear alpha display        <ESC>J
data setup / ESC, STAR, LETM, BIGR, ESC, STAR, LETD, BIGR,
             ESC, BIGH, ESC, BIGJ, NEWLINE/
 
#            Set up for text output - <ESC>*dS
data txtout/ ESC, STAR, LETD, BIGS/
 
#            Turn off graphic text mode - <ESC>*dT
data txtoff/ ESC, STAR, LETD, BIGT/
 
#            Set text size  - <ESC>*m<size>M
data setsiz/ ESC, STAR, LETM, DIG1, BIGM/
 
#            Set text rotation - <ESC>*m<rotation>N
data rotate/ ESC, STAR, LETM, DIG1, BIGN/
 
#            Fill bar - <ESC>*m
data filbar/ ESC, STAR, LETM/
 
opcode=contrl(OPCODE)
 
#
#  opcode move and draw
#
if  ((opcode == DRAW) | (opcode == MOVE)) {
   call dr2647 (opcode, rlin)
   }
 
#
#  opcode text
#
else if (opcode == TEXT) {
   call gdstot (4, txtout)       # Enter graphic text mode
   i = contrl(INTEGER_IN_LENGTH)
   call gdstot (i, intin)        # Output the text string
   call gdstot (4, txtoff)       # Exit graphic text mode
   }
 
#
#  opcode marker
#
else if (opcode == MARKER) {
   call gdstot (5, solid)        # set line style to solid
   call dm2647 (intin, rlin)
 
   # Restore line style
   len = itoch (ndlntp, lstyle(4), 2, j)
   len = len + 4                    # Update length of line style string
   lstyle(len) = LETB
   call gdstot (len, lstyle)        # Output string
   }
 
#
#  opcode filled bar
#
else if (opcode == BAR_FILL) {
 
   call gdstot (5, solid)         # set line style to solid
   call gdstot (3, filbar)
   for (i=1; i<=4; i=i+1) {       # send lower left and upper right corners
      len = itoch (int (rlin(i)*zdlgax), line, 3, j)
      call gdstot (len, line)
      call gdevot (BLANK)
      }
   call gdevot (BIGE)
 
   # Restore line style
   len = itoch (ndlntp, lstyle(4), 2, j)
   len = len + 4                    # Update length of line style string
   lstyle(len) = LETB
   call gdstot (len, lstyle)        # Output string
   }
 
#
#  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 text size
#
else if (opcode == TEXT_SIZE) {
   areain = rlin(1) * rlin(2)
   i = 1
   pwr2 = 1.0
   repeat {
      darea = (pwr2*chrwid)*(pwr2*chrhgt)
      if (darea > areain) break
      i = i + 1
      pwr2 = pwr2 * 2.0
      }
   i = gimnmx ((i-1), 1, 8)   # device has 8 text sizes
   setsiz(4) = i +DIG0
   call gdstot (5, setsiz)        # set graphic text size
   pwr2 = 2.0 ** (i-1)
   rlout(1) = pwr2*chrwid         # return size selected
   rlout(2) = pwr2*chrhgt
   }
 
#
#  opcode line style
#
else if (opcode == LINESTYLE) {
   ndlntp = gimnmx (intin(1), 1, 8)   # The 2647 has 8 line styles (1-8)
   intout(1) = ndlntp               # Return the actual linestyle selected
   if (ndlntp > 1) ndlntp = ndlntp + 2   # Map to 2647 line style numbers
   len = itoch (ndlntp, lstyle(4), 2, j)
   len = len + 4                    # Update length of line style string
   lstyle(len) = BIGB
   call gdstot (len, lstyle)        # Output string
   }
 
#
#    opcode text rotation
#
else if (opcode == CHAR_ROTATION) {
   # the device can rotate in 90 degree increments
   i = mod (int ((rlin(1)+45.0)/90.0), 4) + 1
   rotate (4) = i + DIG0
   call gdstot (5, rotate)   # Set text rotation
   rlout(1) = (i-1) * 90.0   # Inform upper level of actual angle selected
   }
 
#
#    opcode new_frame
#
else if (opcode == NEW_FRAME) {
   call gdstot (4, newfrm)
   }
 
#
#    opcode get_point
#
else if (opcode == GET_POINT) {
   contrl (4) = 0
   for (i=1; i<=3; i=i+1) {  # try 3 times for a good input point
      call gdstot (6, enagin)      # Enable gin
      call gdstin (18, line, len)  # Read the device's response
      if (len == 17) {
         call chtoi (line, 1, xin, kstop)          # Get x coordinate
         j = kstop
         if (line(j) == COMMA) {
            call chtoi (line, j, yin, kstop)       # Get y coordinate
            j = kstop
            if (line(j) == COMMA) {
               call chtoi (line, j, nchar, kstop)  # Get key pressed
               if (line(kstop) == NEWLINE) {
                  contrl(4) = 1                    # Input point OK
                  break
                  }
               }
            }
         }
      }
   if (contrl(4) == 1) {          # Input point was received OK
      intout(1) = nchar
      rlout(1) = float(xin)/zdlgax
      rlout(2) = float(yin)/zdlgax
      }
   }
 
#
# opcode set_device_parameters
#
else if (opcode == SET_DEVICE_PARAMETERS) {
 
   # set up device capability array
 
   devcap(TEXT_CAP) = YES        # Text capability
   devcap(LINESTYLE_CAP) = 8     # Capable of 8 different linestyles
   devcap(TEXT_SIZE_CAP) = 8     # Capable of 8 text sizes
   devcap(GIN_CAP) = YES         # Gin capability
   devcap(MARKER_CAP) = 5        # Capable of 5 different markers
   devcap(TEXT_ROT_CAP) = 4      # Capable of 4 different text rotations
   devcap(BAR_FILL_CAP) = YES    # Capable of filling a rectangular bar
 
   zdlgax = X_LIMITS_2647      # Set the length of the longest axis.
   zdxlng = 1.0                # Set the length of each axis in NDCs
   zdylng = 0.5                # Y_LIMITS_2647 / X_LIMITS_2647
   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
 
   # initialize device
 
   call gdstot (13, setup)
   }
 
#
#     stop graphics
#
else if (opcode == STOP_GRAPHICS) {
   call gdstot (4, setup)  # Reset graphic environmentals
   call gdevot (NEWLINE)   # Insure that buffer has been output
   }
 
#
#     inquire screen size
#
else if (opcode == INQUIRE_SCREEN_SIZE) {
   rlout(1) = zdxlng
   rlout(2) = zdylng
   rlout(3) = X_LIMITS_2647
   }
 
#
#  opcode escape
#
else if (opcode == ESCAPE) {
   i = contrl(INTEGER_IN_LENGTH)
   call gdstot (i, intin)
   }
 
return
end
#-t-  dd2647.rat          local   03/24/82  10:30
#-h-  dm2647.rat          local   03/24/82  11:21
subroutine dm2647 (marker,rlin)
########################################################################
#                                                                      #
#          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: Place a marker at the current location on HP2647       #
#                                                                      #
#     Input Parameters:                                                #
#            marker - marker symbol index (1-5)                        #
#            rlin   - x/y location for marker                          #
#     Output Parameters:                                               #
#            none                                                      #
#                                                                      #
#     Routines Called:                                                 #
#            dr2647 - HP2647 move/draw routine                         #
#                                                                      #
########################################################################
 
include mgsdef
 
define (MARK_PERIOD,1)
define (MARK_PLUS,2)
define (MARK_STAR,3)
define (MARK_O,4)
define (MARK_X,5)
define (FULLSZ,.0125)
define (HALFSZ,.00625)
define (FPERSZ,.005)
define (HPERSZ,.0025)
 
integer marker
real rlin(1)
 
real fsize, hsize, x1, x2, y1, y2
real rxy(2), rxy1, rxy2
 
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:
#
#       rxy(1) :: rxy1
#       rxy(2) :: rxy2
 
equivalence (rxy(1), rxy1), (rxy(2), rxy2)
 
 
   if (marker == MARK_PERIOD) {
      fsize = FPERSZ
      hsize = HPERSZ
      }
   else {
      fsize = FULLSZ
      hsize = HALFSZ
      }
 
   x1 = rlin(1) - hsize        #clip marker to device limits
   x2 = x1 + fsize
   y1 = rlin(2) - hsize
   y2 = y1 + fsize
   if ((amin1(x1,y1) < 0.0) | (x2 > zdxlng) | (y2 > zdylng)) return
 
   # output appropriate marker centered on location
 
   rxy1 = x1
   rxy2 = y1
   call dr2647 (MOVE, rxy)   # move to lower left corner of character cell
 
   if (marker == MARK_PERIOD | marker == MARK_O) {
      rxy1 = x2
      call dr2647 (DRAW, rxy)
      rxy2 = y2
      call dr2647 (DRAW, rxy)
      rxy1 = x1
      call dr2647 (DRAW, rxy)
      rxy2 = y1
      call dr2647 (DRAW, rxy)
      }
   else {
      if (marker == MARK_X | marker == MARK_STAR) {
         rxy1 = x2
         rxy2 = y2
         call dr2647 (DRAW, rxy)
         rxy2 = y1
         call dr2647 (MOVE, rxy)
         rxy1 = x1
         rxy2 = y2
         call dr2647 (DRAW, rxy)
         }
      if (marker == MARK_PLUS | marker == MARK_STAR) {
         rxy2 = y1 + hsize
         call dr2647 (MOVE, rxy)
         rxy1 = x2
         call dr2647 (DRAW, rxy)
         rxy1 = x1 + hsize
         rxy2 = y1
         call dr2647 (MOVE, rxy)
         rxy2 = y2
         call dr2647 (DRAW, rxy)
         }
      }
   call dr2647 (MOVE, rlin)     # Return the cursor position to the original
                                #    value
   return
end
#-t-  dm2647.rat          local   03/24/82  11:21
#-h-  dr2647.rat          local   03/24/82  11:21
subroutine dr2647 (opcode, rlin)
########################################################################
#                                                                      #
#          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 move/draw for HP2647            #
#                                                                      #
#     Input Parameters:                                                #
#           opcode - driver function, either move/draw                 #
#                                                                      #
#            rlin    -     Array of real input parameters              #
#                                                                      #
#     Output Parameters: none                                          #
#                                                                      #
#     Routines Called:                                                 #
#            gdevot - put a character to device                        #
#            itoch - convert integer to character string               #
#                                                                      #
########################################################################
 
include mgsdef
 
integer opcode
real rlin(1)
integer movdrw(5), coord, string(4), len, ierror, itoch
 
include mgscom
 
#        Move / draw absolute - <ESC>*paf for move  <ESC>*pbf for draw
data movdrw/ ESC, STAR, LETP, LETA, LETF/
 
   movdrw(4) = LETA
   if (opcode == DRAW) movdrw(4) = LETB
   call gdstot (5, movdrw)       # Output move or draw command
   coord = int (rlin(1) * zdlgax)
   len = itoch (coord, string, 4, ierror)
   call gdstot (len, string)     # Output x coordinate
   call gdevot (COMMA)
   coord = int (rlin(2) * zdlgax)
   len = itoch (coord, string, 4, ierror)
   call gdstot (len, string)     # Output y coordinate
   call gdevot (BIGZ)            # Terminate command
 
   return
end
#-t-  dr2647.rat          local   03/24/82  11:21
#-t-  hp.c                local   03/24/82  10:30
#-h-  ddv125.c            local   06/27/82  14:05:42
E 1
