    ! Pascal interface to EDWIN.
    external string (63) fn spec ERROR alias "EDWIN_ERROR" (integer X)

    external routine spec TERMINATE alias "EDWIN_TERM"
    external routine TERMINATE EDWIN
       TERMINATE
    end

    external routine spec INITIALISE alias "EDWIN_INIT" (integer DEVICE TYPE)
    external routine INITIALISE FOR (integer DEVICE TYPE)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       INITIALISE (DEVICE TYPE)
    end

    external routine spec MOVE A alias "EDWIN_MOVE_ABS" (integer X, Y)
    external routine MOVE ABS (integer X, Y)
       MOVE A (X, Y)
    end

    external routine spec MOVE R alias "EDWIN_MOVE_REL" (integer DX, DY)
    external routine MOVE REL (integer DX, DY)
       MOVE R (DX, DY)
    end

    external routine spec LINE A alias "EDWIN_LINE_ABS" (integer X, Y)
    external routine LINE ABS (integer X, Y)
       LINE A (X, Y)
    end

    external routine spec LINE R alias "EDWIN_LINE_REL" (integer DX, DY)
    external routine LINE REL (integer DX, DY)
       LINE R (DX, DY)
    end

    external routine spec MARKER A alias "EDWIN_MARK_ABS" (integer N, X, Y)
    external routine MARKER ABS (integer N, X, Y)
       MARKER A (N, X, Y)
    end

    external routine spec MARKER R alias "EDWIN_MARK_REL" (integer N, DX, DY)
    external routine MARKER REL (integer N, DX, DY)
       MARKER R (N, DX, DY)
    end

    external routine spec CHAR alias "EDWIN_CHAR" (integer SYM)
    external routine CHARACTER (integer SYM)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       CHAR (SYM&255)
    end

    external routine spec WIPE alias "EDWIN_NEW_FRAME"
    external routine NEW FRAME
       WIPE
    end

    external routine spec UPD alias "EDWIN_UPDATE"
    external routine UPDATE
       UPD
    end

    external routine spec C ON alias "EDWIN_CLIP_ON"
    external routine CLIP ON
       C ON
    end

    external routine spec C OFF alias "EDWIN_CLIP_OFF"
    external routine CLIP OFF
       C OFF
    end

    external routine spec S ON alias "EDWIN_STORE_ON" (integer STREAM)
    external routine STORE ON (integer STREAM)
       S ON (STREAM)
    end

    external routine spec S OFF alias "EDWIN_STORE_OFF"
    external routine STORE OFF
       S OFF
    end

    external routine spec V ON alias "EDWIN_VIEW_ON" (integer STREAM)
    external routine VIEW ON (integer STREAM)
       V ON (STREAM)
    end

    external routine spec V OFF alias "EDWIN_VIEW_OFF"
    external routine VIEW OFF
       V OFF
    end

    external routine spec ASR alias "EDWIN_ASPECT_RATIO" (integer MODE)
    external routine ASPECT RATIOING (integer MODE)
       ASR (MODE)
    end

    external routine spec WIN alias "EDWIN_WINDOW" (integer XL, XR, YB, YT)
    external routine WINDOW (integer XL, XR, YB, YT)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       WIN (XL, XR, YB, YT)
    end

    external routine spec VIEWP alias "EDWIN_VIEWPORT" (integer XL, XR, YB, YT)
    external routine VIEWPORT (integer XL, XR, YB, YT)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       VIEWP (XL, XR, YB, YT)
    end

    external routine spec S COLOUR alias "EDWIN_SET_COLOUR" (integer COLOUR)
    external routine SET COLOUR (integer COLOUR)
       S COLOUR (COLOUR)
    end

    external routine spec S COLOUR MODE alias "EDWIN_SET_COL_MODE" (integer MODE)
    external routine SET COLOUR MODE (integer MODE)
       S COLOUR MODE (MODE)
    end

    external routine spec S LINE STYLE alias "EDWIN_SET_STYLE" (integer STYLE)
    external routine SET LINE STYLE (integer STYLE)
       S LINE STYLE (STYLE)
    end

    external routine spec S CHAR SIZE alias "EDWIN_SET_CHAR_SIZE" (integer SIZE)
    external routine SET CHAR SIZE (integer SIZE)
       S CHAR SIZE (SIZE)
    end

    external routine spec S MARKER SIZE alias "EDWIN_SET_MARK_SIZE" (integer S)
    external routine SET MARKER SIZE (integer S)
       S MARKER SIZE (S)
    end

    external routine spec S CHAR ROT alias "EDWIN_SET_CHAR_ROT" (integer ROT)
    external routine SET CHAR ROT (integer ROT)
       S CHAR ROT (ROT)
    end

    external routine spec S CHAR QUALITY alias "EDWIN_SET_CHAR_QUAL" (integer WHICH)
    external routine SET CHAR QUALITY (integer WHICH)
       S CHAR QUALITY (WHICH)
    end

    external routine spec S CHAR FONT alias "EDWIN_SET_CHAR_FONT" (integer WHICH)
    external routine SET CHAR FONT (integer WHICH)
       S CHAR FONT (WHICH)
    end

    external routine spec S CHAR SLANT alias "EDWIN_SET_CHAR_SLANT"(integer ANGLE)
    external routine SET CHAR SLANT (integer ANGLE)
       S CHAR SLANT (ANGLE)
    end

    external routine spec S CHORD STEP alias "EDWIN_SET_CHORD_STEP" (integer TO)
    external routine SET CHORD STEP (integer TO)
       S CHORD STEP (TO)
    end

    external routine spec S SHADE MODE alias "EDWIN_SET_SHADE_MODE" (integer TO)
    external routine SET SHADE MODE (integer TO)
       S SHADE MODE (TO)
    end

    external routine spec REV alias "EDWIN_REVIEW"
    external routine REVIEW
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       REV
    end

    external routine spec GET POSITION alias "EDWIN_INQ_POSITION" (integer name X, Y)
    external routine INQUIRE POSITION (integer name X, Y)
       GET POSITION (X, Y)
    end

    external routine spec GET WINDOW alias "EDWIN_INQ_WINDOW" (integer name XL, XR, YB, YT)
    external routine INQUIRE WINDOW (integer name XL, XR, YB, YT)
       GET WINDOW (XL, XR, YB, YT)
    end

    external routine spec GET VIEWPORT alias "EDWIN_INQ_VIEWPORT" (integer name XL, XR, YB, YT)
    external routine INQUIRE VIEWPORT (integer name XL, XR, YB, YT)
       GET VIEWPORT (XL, XR, YB, YT)
    end

    external routine spec MAP TO DEVICE C alias "EDWIN_MAP_TO_DCS" (integer name X, Y)
    external routine MAP TO DEVICE COORDS (integer name X, Y)
       MAP TO DEVICE C (X, Y)
    end

    external routine spec MAP TO VIRTUAL C alias "EDWIN_MAP_TO_VCS" (integer name X, Y)
    external routine MAP TO VIRTUAL COORDS (integer name X, Y)
       MAP TO VIRTUAL C (X, Y)
    end

    external routine spec REQUEST CUR alias "EDWIN_REQUEST" (integer name STATE, X, Y)
    external routine REQUEST INPUT (integer name S, X, Y)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       REQUEST CUR (S, X, Y)
    end

    external routine spec SAMPLE CUR alias "EDWIN_SAMPLE" (integer name STATE, X, Y)
    external routine SAMPLE INPUT (integer name S, X, Y)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       SAMPLE CUR (S, X, Y)
    end

    external routine spec AREA CUR alias "EDWIN_AREA" (integer name XL, YB, XR, YT)
    external routine AREA INPUT (integer name XL, YB, XR, YT)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       AREA CUR (XL, YB, XR, YT)
    end

    external routine spec REQUEST DEV alias "EDWIN_REQUEST_DEV" (integer name STATE, X, Y)
    external routine REQUEST DEVICE (integer name S, X, Y)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       REQUEST DEV (S, X, Y)
    end

    external routine spec SAMPLE DEV alias "EDWIN_SAMPLE_DEV" (integer name STATE, X, Y)
    external routine SAMPLE DEVICE (integer name S, X, Y)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       SAMPLE DEV (S, X, Y)
    end

    external routine spec AREA DEV alias "EDWIN_AREA_DEV" (integer name XL, YB, XR, YT)
    external routine AREA DEVICE (integer name XL, YB, XR, YT)
       on 14 start
           Terminate
           Print string ("EDWIN error - ".error(event_sub))
           newline
           stop
       finish
       AREA DEV (XL, YB, XR, YT)
    end

    external routine spec DRIVE DEV alias "EDWIN_DRIVE_DEV" (integer COM, X, Y)
    external routine DRIVE DEVICE (integer COM, X, Y)
       DRIVE DEV (COM, X, Y)
    end

    external integer fn spec DEFAULT DEV alias "EDWIN_DEFAULT_DEV"
    external integer fn DEFAULT DEVICE
       result = DEFAULT DEV
    end

    ! PASCAL integerface to the EDWIN shape utility routines.

    record format POINTFM (integer X, Y)
    external routine spec Z SET WIRE MODE  alias "EDWIN_SET_WIRE_MODE"  (integer MODE)
    external routine spec Z SET COLOUR MAP alias "EDWIN_SET_COLOUR_MAP" (integer ADR, RED, BLUE, GREEN)
    external routine spec Z ARC            alias "EDWIN_ARC"        (integer OX, OY, RAD, START ANG, END AND)
    external routine spec Z SECTOR         alias "EDWIN_SECTOR"     (integer OX, OY, RAD, START ANG, END AND)
    external routine spec Z CIRCLE         alias "EDWIN_CIRCLE"     (integer RAD)
    external routine spec Z RECTANGLE      alias "EDWIN_RECTANGLE"  (integer XL, YL, XU, YU)
    external routine spec Z BOX            alias "EDWIN_BOX"        (integer L, W, record (POINTFM) name C, D)
    external routine spec Z WIRE           alias "EDWIN_WIRE"       (integer W, NP, record (POINTFM) array name P)
    external routine spec Z POLYGON        alias "EDWIN_POLYGON"    (integer NP, record (POINTFM) array name P)

    external routine SET WIRE MODE (integer MODE)
       Z SET WIRE MODE (MODE)
    end

    external routine ARC (integer OX, OY, RAD, SA, EA)
       Z ARC (OX, OY, RAD, SA, EA)
    end

    external routine SECTOR (integer OX, OY, RAD, SA, EA)
       Z SECTOR (OX, OY, RAD, SA, EA)
    end

    external routine CIRCLE (integer RAD)
       Z CIRCLE (RAD)
    end

    external routine RECTANGLE (integer LX, HX, LY, HY)
       Z RECTANGLE (LX, HX, LY, HY)
    end

    external routine BOX (integer L, W, record (POINTFM) name C, D)
       Z BOX (L, W, C, D)
    end

    external routine WIRE (integer W, NE, record (POINTFM) name PN)
       record (POINTFM) array P (1:NE)
       integer I, PP
       PP = ADDR (PN)
       for I = 1, 1, NE cycle
          P(I) = RECORD (PP)
          PP = PP + 8
       repeat
       Z WIRE (W, NE, P)
    end

    external routine POLYGON (integer NE, record (POINTFM) name PN)
       record (POINTFM) array P (1:NE)
       integer I, PP
       PP = ADDR (PN)
       for I = 1, 1, NE cycle
          P(I) = RECORD (PP)
          PP = PP + 8
       repeat
       Z POLYGON (NE, P)
    end

    external routine SET COLOUR MAP (integer A, C1, C2, C3)
       Z SET COLOUR MAP (A, C1, C2, C3)
    end

    external routine spec TEXT alias "EDWIN_TEXT" (string (255) S)

    external routine Edwin Write (integer I, P)
       Text (ItoS(I,P))
    end

    external routine Edwin Print (long real R, integer BP, AP)
       Text (RtoS(R, BP, AP))
    end

    end of file