! EDWIN driver for the DEC GIGI Colour Graphics terminal

from Edwin include Device
from Edwin include Icodes

! Screen information
own integer SX = 0       { Current device position
own integer SY = 0
own integer XL = 0
own integer XR = 511     { Right hand side of device window
own integer YB = 0
own integer YT = 511

external routine SET COLOUR MAP alias "EDWIN___G_MAP" (integer ADR, RED, BLUE, GREEN)
   ! red, blue, green combination for this address in color map
end

external routine GIGI alias "EDWIN___G" (integer COM, X, Y)
   own integer WX, WY
   switch SW(0:MAX COM)

   routine SWAP (integer name  A, B)
      integer C
      C = A;   A = B;   B = C
   end

   routine CHANGE ATTRIBUTE (integer WHAT, TO)
      switch AS (0:ATT MAXIMUM)
      -> AS (WHAT)

AS(att colour):
       return

AS(att char size):
       return

AS(att colour mode):
       return
    
AS(*): ! All other attributes ignored
   end

   -> SW(COM)

SW(0): ! Initialise
       DEV DATA_NAME = "a DEC GIGI terminal"
       DEV DATA_DVX = 767
       DEV DATA_DVY = 479
       DEV DATA_MVX = 767
       DEV DATA_MVY = 479
       TTMODE (1)
       return

SW(1): !Terminate
       TTMODE (0)
       return

SW(2): ! Update
       return

SW(3): ! New frame
       return

SW(4): ! Move Abs
       return

SW(5): ! Line Abs
       return

SW(6): ! Character
       return

SW(7): ! Attribute  Change
       CHANGE ATTRIBUTE (X, Y)
       return

SW(8): ! Set lower window settings
       XL = X;   YB = Y
       return

SW(9): ! Set upper window bounds
       XR = X;   YT = Y
       return

SW(10): ! Mode change
        return

SW(11): ! Set Colour replacement mode (old entry point)
        change attribute (att colour mode, X)
        return

SW(12): ! Lower box bounds
        WX = X;   WY = Y
        return

SW(13): ! Upper box bounds, and do box
        SWAP (WX, X) if WX > X
        SWAP (WY, Y) if WY > Y
        return if WX > XR or X < XL or WY > YT or Y < YB
        WX = XL if WX < XL
        WY = YB if WY < YB
        X = XR if X > XR
        Y = YT if Y > YT
        ! Box now clipped into the screen.
        return

SW(*):
end

external routine G SAM alias "EDWIN___G_SAM" (integer name BUT, X, Y)
   signal 14, 8
end

external routine G REQ alias "EDWIN___G_REQ" (integer name BUT, X, Y)
   signal 14, 8
end

end of file