h53837
s 00739/00000/00000
d D 1.1 83/03/15 21:04:06 tes 1 0
c date and time created 83/03/15 21:04:06 by tes
e
u
4
U
t
T
I 1
#-h-  dd100v.c            local   06/27/82  14:54:34
#-h-  dd100V.rat          local   01/20/82  09:30
subroutine dd100V (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 ID 100V terminal            #
#                                                                      #
#     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:                                                 #
#             dr100v - move/draw for ID 100V terminal                  #
#             gdevot - put out a character to the device               #
#             gdstot - put out a character string to the device        #
#             dc100v - color changing on ID 100V terminal              #
#             dm100v - emulate markers for ID 100V terminal            #
#             itoch  - convert integer to character string             #
#             gimnmx - bounds checking function for integers           #
#             inside - find point inside polygon                       #
#                                                                      #
########################################################################
 
include mgsdef
 
# local defines
define(X_LIMITS_ID100V,607.)             # Terminal width
define(Y_LIMITS_ID100V,479.)             # Terminal heigth
define(OUTLINE,1)                       # Outline polygons
 
integer contrl(1),intin(1),intout(1)
real rlin(1),rlout(1)
 
integer opcode, icnvt(4), gimnmx, endcmd(2),
        blink(6), flood(2), box(2), endbox(5), lstyle(5), newfrm(2),
        setclr(2), setup(20), solid(5), txtatt(7), txtwid(6),
        tries, enable(4), curoff(2), line(7), booboo(2)
 
real xcoord, ycoord, xy(2)
 
integer cl100V(8,3)
 
include mgscom
 
common /cm100V/ cl100V
 
equivalence (xy(1) , xcoord), (xy(2) , ycoord)
 
#  Display a filled box / <esc> B /
data box /ESC, BIGB/
 
#  End the box
data endbox / COMMA, DIG0, COMMA, DIG0, CR/
 
#  Need to make a blinking black line to outline a panel
data blink / ESC, BIGP, DIG0, COMMA, DIG1, CR/
 
#   Flood an area   / <esc> F /
data flood / ESC, BIGF /
 
#  Change line patterns  /<esc> TV 0 <cr> /
data lstyle /ESC, BIGT, BIGV, DIG0, CR/
 
#  Set text attributes: size and rotation
data txtatt /ESC, BIGT, BIGC, DIG0, COMMA, DIG0, CR/
 
#  Table to determine which is the correct text size to use
data txtwid/ 7, 14, 28, 56, 112, 224/
 
#  Need to be able to set a solid line pattern  / <esc> TV1 <cr> /
data solid /ESC, BIGT, BIGV, DIG1, CR/
 
#  Erase the screen  / <esc> U /
data newfrm / ESC, BIGU /
 
#  Set up the terminal for operation:
#                    Move the cursor to home:<esc> [0;0H
#                    Erase the alpha plane   <esc> [2J
#                    Turn on graphics mode:  <esc> 1
#                    Graphics reset:         <esc> G
#                    Enable lower case:      <esc> Z
#                    Set scale factor:       <esc> S 0 <cr>
data setup / ESC, LBRACK, DIG0, SEMICOL, DIG0, BIGH, ESC, LBRACK,
             DIG2, BIGJ, ESC, DIG1, ESC, BIGG, ESC, BIGZ, ESC,
             BIGS, DIG0, CR/
 
#  Enable 4010 gin
data enable / BELL, ESC, SUB, NEWLINE/
 
# Turn the cursor off
data curoff / CR, NEWLINE/
 
#  Report a gin mistake
data booboo / BELL, NEWLINE/
 
#  Command to turn off the graphics plane
data endcmd/ ESC, DIG2/
 
 
opcode=contrl(OPCODE)
 
#
#  opcode move and draw
#
if  ((opcode == DRAW) | (opcode == MOVE)) {
   if ((opcode == DRAW) & (ndclrp ~= ndclrl))   { # Change the color
      i = ndclrl
      call dc100V (i)
      }
   call dr100V (opcode, rlin)
   }
#
#  opcode text
#
else if (opcode == TEXT) {
 
   if (ndclrp ~= ndclrt)  {  # Change the color
      i = ndclrt
      call dc100V (i)
      }
 
   i = contrl (INTEGER_IN_LENGTH)
   call gdstot (i, intin)
   }
 
#
#  opcode marker
#
else if (opcode == MARKER) {
 
   call gdstot (5, solid)   #set a solid dash pattern
 
   if (ndclrp ~= ndclrm)  {  # Need a different color to do a marker
      i = ndclrm
      call dc100V (i)
      }
   call dm100V (intin, rlin)
 
   # Now need to restore the user's dash pattern
   lstyle(4) = ndlntp
   call gdstot (5, lstyle)
   }
 
#
#  opcode polygon edge style
#
else if (opcode == SET_POLYGON_EDGE_STYLE) {
   ndedgs = intin(1)
   }
 
#
#  opcode polygon
#
else if (opcode == POLYGON) {
 
   # To make sure the polygon is filled properly, the border
   # is first filled in blinking black
   call gdstot (6, blink)
 
   ndclrp = -1  # Always need to reset device color
 
   # Set the line type to solid for the edge being drawn
   call gdstot (5, solid)
 
   j = intin(1)                # Get start of x-coordinates
   k = intin(2)                # Get start of y-coordinates
   xcoord = rlin(j)
   ycoord = rlin(k)
   call dr100V (MOVE, xy)       # Move to first point
   for (i=2; i <= contrl(3); i=i+1) {
      j = j + 1
      k = k + 1
      xcoord = rlin(j)
      ycoord = rlin(k)
      call dr100V (DRAW, xy)    # Draw polygon edges
      }
 
   # Now redraw the first edge again to fix a bug with the terminals
   # dash pattern
   j = intin(1) + 1
   k = intin(2) + 1
   xcoord = rlin(j)
   ycoord = rlin(k)
   call dr100v (DRAW, xy)
 
   i = intin(1)
   j = intin(2)
   call inside (contrl(3), rlin(i), rlin(j), xcoord, ycoord)
   call dr100V (MOVE, xy)       # Move inside polygon
 
   i = ndclrf                  # Set fill color
   call dc100V (i)
 
   call gdstot ( 2, flood)     # Flood interior
 
   # Now draw the border
   if (ndedgs == OUTLINE) i = ndclrl
   else                   i = ndclrf
 
   call dc100V (i)              # Set polygon edge color
 
   j = intin(1)                # Get start of x-coordinates
   k = intin(2)                # Get start of y-coordinates
   xcoord = rlin(j)
   ycoord = rlin(k)
   call dr100V (MOVE, xy)       # Move to first point
   for (i=2; i <= contrl(3); i=i+1) {
      j = j + 1
      k = k + 1
      xcoord = rlin(j)
      ycoord = rlin(k)
      call dr100V (DRAW, xy)    # Draw polygon edges
      }
 
   lstyle(4) = ndlntp
   call gdstot (5, lstyle)
   }
 
#
#  opcode filled bar
#
else if (opcode == BAR_FILL) {
 
   if ( ndclrf ~= ndclrp )  {  # Need another color for the bar
      i = ndclrf
      call dc100V (i)
      }
   # Move to the lower left corner
   call dr100V (MOVE, rlin)
 
   call gdstot (2, box) # Begin the box command
 
   i = (rlin(3)-rlin(1)) * X_LIMITS_ID100V
   len = itoch (i, icnvt, 4, ierror)
   call gdstot (len, icnvt)
   call gdevot (COMMA) # End the x point
 
   i = (rlin(4)-rlin(2)) * X_LIMITS_ID100V
   len = itoch ( i, icnvt, 4, ierror)
   call gdstot (len, icnvt)
   call gdstot (5, endbox)
   }
 
#
#  opcode set fill color
#
else if (opcode == SET_FILL_COLOR) {
   ndclrf = gimnmx( intin(1), 0, 7)
   intout(1) = ndclrf      # Communicate which pattern was selected
   }
 
#
#  opcode text rotation
#
else if (opcode == CHAR_ROTATION) {
   i = amod((rlin(1)+45.)/90.,4.)
   ndtxrt = (2*i+1) + DIG0    # 90 degree rotations are 1, 3, 5, and 7
 
   txtatt(6) = ndtxrt
   txtatt(4) = ndtxsz  # Command also needs the last size sent
   call gdstot ( 7, txtatt)
 
   rlout(1) = float(i) * 90.
   }
 
#
#  opcode text size
#
else if (opcode == TEXT_SIZE) {
 
   # Determine text size to use
   i = rlin(1) * X_LIMITS_ID100V # Size in device units
   for (j=6; j >= 1; j=j-1) {  # Find the right size
      if (txtwid(j) <= i)  break
      }
 
   if (j==0)  j = 1   # If the user wanted the smallest, give it to him
 
   ndtxsz = j + SLASH
 
   txtatt(4) = ndtxsz
   txtatt(6) = ndtxrt
   call gdstot (7, txtatt)
 
   rlout(1) = float(txtwid(j)) / X_LIMITS_ID100V
                               # 10. / 7. / X_LIMITS_ID110V
   rlout(2) = float(txtwid(j)) * .0023534
   }
 
#
#  opcode line style
#
else if (opcode == LINESTYLE) {
   i = gimnmx( intin(1), 1, 4)
   ndlntp = i + DIG0    # Save the current pattern for future use
   intout(1) = i        # Inform upper level of style selected
   lstyle(4) = ndlntp
   call gdstot (5, lstyle)   # Send out the pattern
   }
 
#
#    opcode new_frame
#
else if (opcode == NEW_FRAME) {
   if (ndclrp ~= ndclrb)  {  # Set a new background color
      i = ndclrb
      call dc100v (i)
      }
   call gdstot (2, newfrm)  # Clear the screen
   }
 
#
#   Set background color
#
else if (opcode == SET_BACKGROUND_COLOR) {
   # Save this action until a new page
   ndclrb = gimnmx (intin(1), 0, 7)
   intout(1) = ndclrb
   }
 
#
#  Set line color
#
else if (opcode == SET_LINE_COLOR)  {
   ndclrl = gimnmx (intin(1), 0, 7)
   intout(1) = ndclrl
   }
 
#
#  Set text color
#
else if (opcode == SET_TEXT_COLOR)  {
   ndclrt = gimnmx( intin(1), 0, 7)
   intout(1) = ndclrt
   }
 
#
#  Set marker color
#
else if (opcode == SET_MARKER_COLOR)  {
   ndclrm = gimnmx( intin(1), 0, 7)
   intout(1) = ndclrm
   }
 
#
# Set device color
#
else if (opcode == COLOR)  {
 
   }
 
#
#  opcode inquire color index
#
else if (opcode == INQUIRE_COLOR_INDEX) {
   i = gimnmx( intin(1), 0, 7) + 1
   do j = 1, 3  {
      rlout(j) = float( cl100V(i,j))
      }
   }
 
#
# opcode set_device_parameters
#
else if (opcode == SET_DEVICE_PARAMETERS) {
 
   # set up device capability array
 
   devcap(TEXT_CAP) = YES      # Text capability
   devcap(LINESTYLE_CAP) = 4   # Capable of 4 different linestyle
   devcap(COLOR_CAP) = 8       # Capable of 8 different colors
   devcap(TEXT_SIZE_CAP) = 6   # Capable of 6 different text sizes
   devcap(TEXT_ROT_CAP) = 4    # Device rotates in 90 degree increments
   devcap(GIN_CAP) = YES       # Capable of graphic input
   devcap(MARKER_CAP) = 5      # Capable of 5 different markers
   devcap(POLYGON_FILL_CAP) = YES # Capable of filling polygons
   devcap(BAR_FILL_CAP) = 8    # Capable of filling a rectangle
 
   # Initialize Device Driver globals
 
   zdlgax = X_LIMITS_ID100V  # Set the length of the longest axis
                                # in device units
   zdxlng = 1.0              # Set x and y axis lengths in NDC units
   zdylng = .7894            # Y_LIMITS_ID100V/X_LIMITS_ID100V
 
   ndlntp = 49               # Default line type is solid
   ndclrl = 1                # Default line color is red
   ndclrm = 1                # Default marker color is red
   ndclrt = 1                # Default text color is red
   ndclrf = 1                # Default panel fill is red
   ndclrb = 0                # Default background color is black
   ndclrp = -1               # And no color is set at the device
   ndtxsz = DIG0             # Default size is the smallest
   ndtxrt = DIG1             # No text rotation is in effect
   ndedgs = OUTLINE          # Set default polygon mode to outline
 
   zdxpos = 0.0              # Default position is at home
   zdypos = 0.0
 
   # Initialize all colors to black and then set non-zero values
   do i = 1, 8 {
      do j = 1, 3 {
         cl100v(i,j) = 0
         }
      }
 
   cl100v(2,1) = 1 # Red
   cl100v(3,2) = 1 # Green
   cl100v(4,3) = 1 # Blue
   cl100v(5,2) = 1 # Cyan
   cl100v(5,3) = 1
   cl100v(6,1) = 1 # Yellow
   cl100v(6,2) = 1
   cl100v(7,1) = 1 # Magenta
   cl100v(7,3) = 1
   cl100v(8,1) = 1 # White
   cl100v(8,2) = 1
   cl100v(8,3) = 1
 
   # initialize the terminal
   call gdstot (20, setup)
   }
 
#
#    get point
#
else if (opcode == GET_POINT) {
   contrl(4) = 0  # Initialize the output count
   ginok = YES
   tries = 0
   repeat {
      # Enable gin
      call gdstot (4, enable)
      call gdstin (7, line, i)
 
      if ( i <= 5 )  { # Check the characters that were returned
         for (j=2; j<=i; j=j+1)  { # Verify characters valid
             if (line(j) < SPACE)  {
#            if (line(j) < SPACE | line(j) > QMARK) {
               ginok = NO
               call gdstot (2, booboo)
               }
            }
         }
      else  {  # Too many characters returned
         ginok = NO
         call gdstot (2, booboo)
         }
      tries = tries + 1
      }  until (ginok == YES | tries > 3)
 
   call gdstot (2, curoff)
 
   #  Decode the data
   if (ginok == YES) {
      xcoord = float (mod(line(2),SPACE) * SPACE + mod(line(3),SPACE))
      ycoord = float (mod(line(4),SPACE) * SPACE + mod(line(5),SPACE))
      rlout(1) = xcoord / 608.  # Put the point into NDC space
      rlout(2) = ycoord / 608.
      intout(1) = line(1)
      contrl(4) = 1
      }
   }
 
#
#     inquire screen size
#
else if (opcode == INQUIRE_SCREEN_SIZE) {
      rlout(1) = zdxlng
      rlout(2) = zdylng
      rlout(3) = X_LIMITS_ID100V
      }
 
#
#  opcode escape
#
else if (opcode == ESCAPE) {
      j = contrl(INTEGER_IN_LENGTH)
      call gdstot (j, intin)
      }
 
#
#     stop graphics
#
else if (opcode == STOP_GRAPHICS) {
      call gdstot (2, endcmd) # Terminate graphics by exiting command mode
      }
 
return
end
#-t-  dd100v.rat          local   01/20/82  09:30
#-h-  dm100v.rat          local   03/24/82  11:21
subroutine dm100v (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 100v type    #
#               devices                                                #
#                                                                      #
#     Input Parameters:                                                #
#            marker - marker symbol index (1-5)                        #
#            rlin   - x/y location for marker                          #
#     Output Parameters:                                               #
#            none                                                      #
#                                                                      #
#     Routines Called:                                                 #
#            dr100v - ID 100v 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 dr100v (MOVE, rxy)   # move to lower left corner of character cell
 
   if (marker == MARK_PERIOD | marker == MARK_O) {
      rxy1 = x2
      call dr100v (DRAW, rxy)
      rxy2 = y2
      call dr100v (DRAW, rxy)
      rxy1 = x1
      call dr100v (DRAW, rxy)
      rxy2 = y1
      call dr100v (DRAW, rxy)
      }
   else {
      if (marker == MARK_X | marker == MARK_STAR) {
         rxy1 = x2
         rxy2 = y2
         call dr100v (DRAW, rxy)
         rxy2 = y1
         call dr100v (MOVE, rxy)
         rxy1 = x1
         rxy2 = y2
         call dr100v (DRAW, rxy)
         }
      if (marker == MARK_PLUS | marker == MARK_STAR) {
         rxy2 = y1 + hsize
         call dr100v (MOVE, rxy)
         rxy1 = x2
         call dr100v (DRAW, rxy)
         rxy1 = x1 + hsize
         rxy2 = y1
         call dr100v (MOVE, rxy)
         rxy2 = y2
         call dr100v (DRAW, rxy)
         }
      }
   call dr100v (MOVE, rlin)     # Return the cursor position to the original
                                #    value
   return
end
#-t-  dm100v.rat          local   03/24/82  11:21
#-h-  dr100v.rat          local   01/20/82  09:30
subroutine dr100v (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 ID 100v           #
#                                                                      #
#     Input Parameters:                                                #
#           opcode - driver function, either move/draw                 #
#                                                                      #
#            rlin    -     Array of real input parameters              #
#                                                                      #
#     Output Parameters: none                                          #
#                                                                      #
#     Routines Called:                                                 #
#            gdstot - put a character string to a device               #
#            gdevot - put a character to a device                      #
#            itoch  - convert an integer into a string of characters   #
#                                                                      #
########################################################################
 
include mgsdef
 
integer opcode
real rlin(1)
 
integer len, xcoord, ycoord, drawit(3), iconvt(4), moveit(2)
 
include mgscom
data moveit /ESC, ATSIGN/     # <esc> @
data drawit /ESC, BIGV, BIGM/ # <esc> VM
 
   if (opcode == MOVE) {  # Save the move until later
      call gdstot (2, moveit)
      }
   else {
      call gdstot (3, drawit)
      }
 
   zdxpos = rlin(1)
   zdypos = rlin(2)
 
   xcoord = int (zdxpos*zdlgax)  # convert coords to device space
   ycoord = int (zdypos*zdlgax)
 
   len = itoch (xcoord,iconvt,4,ierr)
   call gdstot (len,iconvt)
   call gdevot (COMMA)
 
   len = itoch (ycoord,iconvt,4,ierr)
   call gdstot (len,iconvt)
   call gdevot (CR)
return
end
#-t-  dr100v.rat          local   01/20/82  09:30
#-h-  dc100v.rat          local   03/24/82  11:21
subroutine dc100v (color)
########################################################################
#                                                                      #
#          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: Change the color on the ID 100v terminal               #
#                                                                      #
#     Input Parameters:                                                #
#            color - color to change to                                #
#     Output Parameters:                                               #
#            none                                                      #
#                                                                      #
#     Routines Called:                                                 #
#            gdstot - output a string to the current device            #
#            gdevot - output a character to the current device         #
#            itoch  - convert an integer into a string of characters   #
#                                                                      #
########################################################################
 
include mgsdef
 
integer color
 
integer clr(6), clrtbl(8)
 
include mgscom
 
#    Set the color   / <esc> P 0,0 <CR> /
data clr / ESC, BIGP, DIG0, COMMA, DIG0, CR/
 
#    The terminal has a non standard color table that can not be changed
#    so a table look up must be done to get the correct color
data clrtbl/ 0, 1, 2, 4, 6, 3, 5, 7/
 
   ndclrp = color    # Set the current color
 
   clr(3) = clrtbl(color+1) + DIG0
   call gdstot (6, clr)
   return
end
#-t-  dc100v.rat          local   03/24/82  11:21
#-t-  dd100v.c            local   06/27/82  14:54:34
#-h-  dd512.c             local   06/27/82  14:55:47
E 1
