

PSIONICS FILE - WSERVER
=======================
Window server calls
Last modified 1997-04-10
========================

SPECIAL NOTICE:

This file wouldn't have appeared for much longer if it weren't for Dan Ramage,
who sent me enough material to convince me to restart after many months of
neglect.

This file is dedicated to the memory of Felicia Hatunen (see
<http://www.stdc.demon.co.uk/felicia/>). Most of it was written travelling
to and from a memorial service for her (in California).

There is a lot of missing and incomplete material in this file. While Psion
have provided me with an SDK and other data, there are a number of gaps in
what I have, particularly the mapping of registers to C function arguments.
Therefore this file contains more than the usual number of @ signs indicating
missing material. Assistance in filling these gaps would be greatly appreciated
(though I don't promise credit).



Processes on the Psion do not have direct access to the screen and
keyboard. Instead, they send messages to a special process called the
Window Server. This process then handles the screen and keyboard,
arbitrating between the various requests - for example, it ensures that
only the current foreground process gets keystrokes, and handles the
case of different application windows overlapping.

Many calls to the Window Server are buffered; the individual commands
are stored in a buffer, and then sent to the server in a batch. This is
done whenever the buffer is full, by any command requiring a response
from the server, whenever waiting for an event, and by the wFlush call.
The calls that return a value but do not flush the command buffer are:
gTextCount, gFontInfo, and wCheckBitmapid.

If an error occurs when a buffered command is executed, all further
commands are ignored until one that requires a response. This command is
also ignored, and the error is returned instead.

Clients of the window server can be in the foreground or background. On
machines with a small screen, only one client can be in the foreground, and
it occupies the whole screen. On machines with a large screen, more than one
client can be in the foreground or be visible at a time.


See the file SYSCALLS.1 for the notation used in this file. In the case of
function $8D, bit 7 of the sub-function number is set to indicate that the
function obtains a response from the server; this bit is ignored in ordering
the functions in the following list of descriptions. Furthermore, in the
case of Fn $8D Sub $7E and Sub $FF, there are several different functions
depending on the value of AL.

If a call is marked "fails" then:
- if it fails, the resulting behaviour depends on the error handling flag set
  by wDisableLeaves;
- if no new value is shown for AX, it is set to 0 on success.


A common data structure is the "standard rectangle structure". This is defined
here:
  Offset 0 (word): x coordinate of left edge of the rectangle
  Offset 2 (word): y coordinate of top edge of the rectangle
  Offset 4 (word): x coordinate of left edge plus width
  Offset 6 (word): y coordinate of top edge plus height


Graphics Contexts
-----------------

Many window server calls are described as using a "graphics context". This is
a data structure associated with a specific window or bitmap and stored in the
window server itself. It determines various features about the call, such as
the font used in text operations. At any time there is a "current GC"; calls
labelled "cgc" use that to determine appropriate properties.

A graphics context is specified using a GC description block. This is a block
of memory in the client laid out as follows:
  Offset 0 (byte): graphics mode (0=set, 1=clear, 2=invert)
  Offset 1 (byte): text mode (0=set, 1=clear, 2=invert, 4=copy with background)
  Offset 2 (byte): text style
    Bit 0: bold
    Bit 1: underline
    Bit 2: inverse
    Bit 3: double height
    Bit 4: monospaced
    Bit 5: italic
    Bit 6: subscript   (v4 only, and only with appropriate font groups)
    Bit 7: superscript (v4 only, and only with appropriate font groups)
  Offset 3 (byte): additional graphics options (v4 only)
    Bits 0 and 1: 0 = black plane, 1 = grey plane, 2 = both planes
    Bit 2:        set = double pixel mode, clear = normal
  Offset 4 (word): font or font group
Wherever a font is required, one of the ROM-based fonts beginning at $4000
can be used. The value $4099 always means the system font.

GC description blocks are normally provided in association with a GC selector
mask. This is a word which is used to determine which values are taken from
the description block, as follows:
  Bit 1: graphics mode
  Bit 2: text mode
  Bit 3: text style
  Bit 4: font
  Bit 5: bits 0 and 1 of additional graphics options (v4 only)
  Bit 6: bit 2 of additional graphics options (v4 only)
When creating a new GC, values not taken from the description block are set
to zero, except the font which is set to the system font.


Events
------

An event is a message sent from the window server to a client to inform it that
something has happened that is not directly related to a function call; for
example, that a key has been pressed when the client is the foreground client.
The event is between 2 and @@ bytes long depending on its type. Offset 0 is
always a word giving the event type.


In many types of event the words at offsets 2 and 4 have a standard meaning.
* "window handle" (offset 2) - this is the value passed to wCreateWindow. It
  is not the same as the window identifier, and is commonly set to the address
  of a structure including the latter.
* "connection handle" (offset 2) - @@@ the value specified to wConnect
* "tick count" (offset 4) - the window server maintains this value, which it
  increments every tick (1/32 second).


Type 1 - WM_KEY
  Offset  0 (word): type, set to 1
  Offset  2 (word): connection handle
  Offset  4 (word): tick count
  Offset  6 (word): keycode
  Offset  8 (byte): keyboard modifiers and mouse state
  Offset  9 (byte): unused
  Offset 10 (word): repeat count
Sent when a key is pressed and the client is the one connected to the keyboard
(usually because it owns the frontmost foreground window). The keycode is
defined by the key and modifiers. For example, the 'A' key will generate:
    $0061  alone
    $0041  if shift is pressed or caps lock is on
    $0001  if control is pressed
    $0261  if Psion or alt is pressed
The window server will handle control-plus-number combinations and generate a
single event. @@@@ special cases
The modifiers are:
  Bit 1: shift key pressed
  Bit 2: control key pressed
  Bit 3: Psion or alt key pressed
  Bit 4: caps lock is on
  Bit 5: num lock is on
  Bit 7: mouse button down
The repeat count is 1 for a single key press. If a key is held down and is
autorepeating faster than the client accepts new events, the repeat count will
be set to the number of repeats since the last key event.


Type 2 - WM_MOUSE
  Offset  0 (word): type, set to 2
  Offset  2 (word): window handle
  Offset  4 (word): tick count
  Offset  6 (byte): 1=release, 2=press, 3=motion
  Offset  7 (byte): keyboard modifiers and mouse state
  Offset  8 (word): mouse position x coordinate
  Offset 10 (word): mouse position y coordinate
Sent when the mouse button is pressed or released, or the mouse moves and
the appropriate window has requested motion events. The modifiers are as for
WM_KEY, plus:
  Bit 6: mouse position is outside the visible portion of the window
This can happen through grabs and mouse capture.


Type 3 - WM_REDRAW
  Offset  0 (word): type, set to 3
  Offset  2 (word): window handle
  Offset  4 (word): tick count
  Offset  6 (word): left edge
  Offset  8 (word): top edge
  Offset 10 (word): @@@ right edge or width or what ?
  Offset 12 (word): @@@ bottom edge or height or what ?
Sent when no other events (except WM_USER_MSG) are pending and a window has
an area that needs redrawing (an "update region"). The rectangle describes 
some portion (possibly all) of the update region.


Type 5 - WM_BACKGROUND
  Offset 0 (word): type, set to 5
Sent to a client in the foreground when it moves to the background.


Type 6 - WM_FOREGROUND
  Offset 0 (word): type, set to 6
Sent to a client in the background when it moves to the foreground.


Type 7 - WM_RUBBER
  Offset 0 (word): type, set to 7
  Offset 2 (word): window handle
  Offset 4 (word): tick count
  Offset 6 (word): final status
  Offset 8 to  15: standard rectangle structure giving the final size
The final status can be:
  0 = the final rectangle is the same as the initial one
  1 = the rubber band moved but was not resized
  2 = the rubber band was resized
  3 = the rubber band was cancelled; the rectangle is undefined
  4 = the rubber band was not displayed because the parameters were wrong


Type 8 - WM_USER_MSG
  Offset 0 (word): type, set to 8
Sent to a client following a call to wUserMsg if no other events are pending
(and so can be used to check that condition).


Type 9 - WM_ACTIVE
  Offset 0 (word): type, set to 9
@@@@


Type 11 - WM_CANCELLED
  Offset 0 (word): type, set to 11
Sent to a client following a call to wCancelGetEvent.


Type 12 - WM_KEYBOARD_STATE_CHANGE
Sent to the system shell only.


Type 13 - WM_RUBBER_BAND_INIT
  Offset  0 (word): type, set to 13
  Offset  2 (word): window handle
  Offset  4 (word): tick count
  Offset  6 (byte): set to 2
  Offset  7 (byte): keyboard modifiers and mouse state
  Offset  8 (word): mouse position x coordinate
  Offset 10 (word): mouse position y coordinate
Sent to a client on a button press when the window is configured so that
pressing a mouse button starts rubber banding. The window server will suspend
all mouse and keyboard processing for all clients until this client calls
wRubberBand. If rubber banding is not desired, the cancel flag can be used in
the call.


Type 14 - WM_DEICONISE
  Offset 0 (word): type, set to 14
Sent to an iconised client when it moves to the foreground.


Type 15 - WM_ATTACHED
  Offset 0 (word): type, set to 15
  Offset 2 (word): @@@@
  Offset 4 (word): tick count
  Offset 6 (word): attached client
Sent to a client when another client has attached itself on top. Note that
the notifer process attaches itself to a client when that client uses the
p_notify@@@ system call.


Type 16 - WM_DETACHED
  Offset 0 (word): type, set to 16
  @@@@
Sent to a client when a previously attached client detaches itself.


Type 17 - WM_COMMAND v3.5
  Offset 0 (word): type, set to 17
Sent to a client that is the target of a wSendCommand call, and indicates that
wGetCommand should be called.


Type 18 - WM_TASK_KEY Series 3 only
  Offset  0 (word): type, set to 18
  Offset  2 (word): connection handle
  Offset  4 (word): tick count
  Offset  6 (word): application key code @@@
  Offset  8 (word): modifiers ? @@@
  Offset 10 (word): repeat count ? @@@
@@@@


Type 19 - WM_TASK_UPDATE v3.5
  Offset 0 (word): type, set to 19
Sent to the shell process if any process terminates, whether or not a client
of the window server.


Type 20 - WM_ON v3.5
  Offset 0 (word): type, set to 20
Sent to a client when the machine is switched on and the client has either
called wInformOnAll, or has called wInformOn and is in the foreground.


Type 21 - WM_ESCAPE
  Offset 0 (word): type, set to 21
  @@@@
Sent on if key events are not selected using wGetEventSpecial. The event is
sent when the ESC key is pressed; all pending keystrokes are thrown away.


Type 22 - WM_DATE_CHANGED v4
  Offset 0 (word): type, set to 22
Sent to any client which is not in Series 3t compatibility mode and is in the
foreground, whenever either the date changes, or the machine is switched on
on a different date to when it was switched off.


System calls
------------

Fn $8D Sub $00
wEndRedraw
Ends redrawing, as started by wBeginRedrawWin or related calls.


Fn $8D Sub $01
wEraseTextCursor
Makes the text cursor invisible.


Fn $8D Sub $02
wReleaseMouse
Cancels any call to wCaptureMouse.


Fn $8D Sub $03
gFreeTempGC
Destroys the temporary graphics context, and makes the remembered current
graphics context be current again.


Fn $8D Sub $04
wCancel
@@@


Fn $8D Sub $85
wDisconnect
@@@


Fn $8D Sub $06
wDetachClient
Detaches the client from any process it is attached to (see wAttachToClient)
and moves it to the back.


Fn $8D Sub $07
wCleanUp
Returns the window server to a standard state. This frees any temporary
graphics context, ends any redraws taking place, and invalidates any
window that has an attached graphics context.


Fn $8D Sub $08
wAttachToForegroundClient
Attaches the client to the current foreground client, if different. See
wAttachToClient for details.


Fn $8D Sub $09
wUserMsg
Instructs the window server to send the client a WM_USER_MSG event when there
are no other events to deliver. Only one such event can be pending for a
client.


Fn $8D Sub $8A
wStartCompute
Inform the window server that the client is about to start intensive
computation, and its priority should be set to 112 (background) even if
it is in the foreground. Ignored if the client has not selected server-
controlled priority handling (see wSetPriorityControl).


Fn $8D Sub $8B
wEndCompute
Cancel the effect of wStartCompute; if the client is in the foreground, 
sets its priority back to 128 (foreground). Ignored if the client has
not selected server-controlled priority handling.


Fn $8D Sub $8C
wClientInfo fails
    AX: -> information about the process
    BX: process to be checked
Returns information about a process:
  Bit 0: set if the process is connected the window server
  Bit 1: returns the setting specified at connection time
  Bit 2: the client is system modal
  Bit 7: server-controlled priority handing is active
If the process is not a client of the window server, the call may return zero
or may fail.


Fn $8D Sub $0D
wCloseWindowTree
    BX: window
Destroys the window and all its descendants.


Fn $8D Sub $8E
wInquireWindow
    BX: window
    SI: address of 14 byte information block (see wCreateWindow)
The first 10 bytes of the block are set to the flags, position, and size of
the specified window. The last 4 bytes of the block are set to unspecified
values.


Fn $8D Sub $0F
wCaptureMouse
    BX: window
Captures the mouse within the window and its descendants. It will cancel any
active capture in another window.


Fn $8D Sub $10
wBeginRedrawWin
    BX: window
Validate the window for redrawing. Validation causes all pixels to be set or
cleared if the background mode is 1 or 2 (this applies to black and grey
separately), and all future drawing is clipped to the update region (which
is set to the entire window in this case). Normal drawing resumes when
wEndRedraw is called.


Fn $8D Sub $11
wFree
    BX: identifier
Destroy an object and free all the related resources. The identifier can be
any of:
  * bitmap file handle
  * bitmap identifier (will also destroy any associated graphics context)
  * bitmap sequence identifier
  * clock identifier
  * font identifier
  * graphics context
  * mouse icon identifier
  * sprite identifier


Fn $8D Sub $12
wMakeInvisible
    BX: window
The window is marked as invisible; a window will not appear on the screen if
it or any of its ancestors is invisible.


Fn $8D Sub $93
wAttachtoClient fails
    BX: process to attach to
Attaches the current process to the specified one. This will cause its
windows to stay just in front of those of the client it is attached to.
Applies only on large screen servers.


Fn $8D Sub $14
wInitialiseWindowTree
    BX: window
The specified window and its descendants are initialized. This may only be
done once for any given window, and must be done before it is first drawn on.


Fn $8D Sub $15
wInvalidateWin
    BX: window
Add the entire window to its own update region. This will cause a redraw
event, which can be used to trigger redrawing of the window.


Fn $8D Sub $16
wValidateWin
    BX: window
Validate the window (causing all pixels to be set or cleared if the background
mode is 1 or 2 - this applies to black and grey separately), and the update
region is deleted.


Fn $8D Sub $17
wMakeVisible
    BX: window
Cancels wMakeInvisible on the window.


Fn $8D Sub $18
wClientIconised
    BX: action (0 = deiconise, 1 = iconise)
Iconises or deiconises the current process. Iconisation only works on large
screen systems.


Fn $8D Sub $19
wClientPosition
    BX: position
    CX: process ID
Move the specified process (zero means the current process) to the given
position in the window server task list. Position 0 is the front of the
list; any position greater than or equal to the number of processes attached
to the window server puts the process at the very back of the list.


Fn $8D Sub $9A
wInquireWindowOffset fails
    BX: window A (0 = screen)
    CX: window B
    SI: address of a 4 byte buffer
The buffer is filled in with the position of window B relative to window A:
  Offset 0 (word): x offset
  Offset 2 (word): y offset


Fn $8D Sub $1B
wWindowPosition
    BX: window
    CX: position (0 = front)
Moves the window to the specified position within the sibling list (the list
of windows with the same parent).


Fn $8D Sub $1C
wScrollRect
    BX: window
    CX: address of a standard rectangle structure
    DX: address of offset structure
The pixels defined by the rectangle are copied to a new rectangle offset by
the indicated distance. The offset structure is:
  Offset 0 (word): x offset of new rectangle
  Offset 2 (word): y offset of new rectangle
Copying does not go outside the window, and does not appear in areas obscured
by other windows or in "invalid" areas waiting for update.


Fn $8D Sub $1D
wRubberBand
    BX: window to be sent the WM_RUBBER event
    CX: window limiting the rubber band (0 = whole screen)
    DX: address of an information block
Starts rubber banding, with the rubber band limited to the specified window
or allowed to roam over the screen. When the user completes the rubber banding,
a WM_RUBBER event is sent to the window given. The information block is:
  Offset  0 to   7: standard rectangle structure giving the initial rectangle
  Offset  8 to  15: standard rectangle structure giving the inner bounds
  Offset 16 to  23: standard rectangle structure giving the outer bounds
  Offset 24 (word): flags
  Offset 26 (word): minimum width
  Offset 28 (word): minimum height
  Offset 30 (word): maximum width
  Offset 32 (word): maximum height
  Offset 34 (word): x grid snap value
  Offset 36 (word): y grid snap value
@@@@@@@@
A window can be set so that pressing a mouse button starts rubber banding. In
this case, the press event is sent as a WM_RUBBER_BAND_INIT event instead. The
client must call wRubberBand (use the @@@@@@ flag to cancel rubber banding if
necessary).


Fn $8D Sub $1E
gCopyRect cgc
    BX: standard rectangle structure
    CX: address of point definition block
    DX: mode (see gFillPattern)
Copies a rectangular block from one part of a bitmap to another (the current
graphics context should refer to a bitmap). The top left corner of the
rectangle is copied to the point given by the definition block:
  Offset 0 (word): x
  Offset 2 (word): y


Fn $8D Sub $9F
gPeekBit
    BX: bitmap identifier, window identifier, or zero (see gSaveBit)
    CX: address of point definition block
    DX: number of pixels
    SI: address of buffer
Copies a horizontal row of pixels into the buffer. The point definition block
gives the first pixel to be copied:
  Offset 0 (word): x
  Offset 2 (word): y
The pixels are packed 8 per byte of the buffer, in LSB-first order ?@@@@@@
In version 4, the grey plane can be used by setting bit 15 of BX.


Fn $8D Sub $20
gDrawPolyLine cgc
    BX: x coordinate of start point
    CX: y coordinate of start point
    DX: address of poly-line control block
Draws a sequence of lines according to the control block, which has the
format:
  Offset     0 (word): number of line segments (N)
  Offsets    2 to   5: line segment 1 control block
  Offsets    6 to   9: line segment 2 control block
  ...
where the block is 4N+2 bytes long. The control block for segment M has the
format:
  Offset 4M-2 (word): 2 times x offset, plus 0 for draw or 1 for don't draw
  Offset 4M   (word): y offset
Each control block causes a line to be drawn, or not drawn, from the previous
end point (or the start point, for the first control block) to a new point
specified as a relative offset. In version 2 of the window server there is a
limit of 61 control blocks.


Fn $8D Sub $21
gFillPattern cgc
    BX: standard rectangle structure
    CX: bitmap ($4000 = chequered 1 and 0 pixels)
    DX: mode
Fills the specified rectangle with copies of the bitmap. The mode can be:
    0 = set each pixel where the bitmap has a 1 pixel
    1 = clear each pixel where the bitmap has a 1 pixel
    2 = invert each pixel where the bitmap has a 1 pixel
    4 = copy the bitmap to the rectangle
In version 3 and above, CX can also be a window with black plane redraw
method 3, indicating that the backup bitmap of that window is to be used. In
version 4, if both planes have redraw method 3, the appropriate plane is used
for each selected plane in the target window or bitmap.


Fn $8D Sub $22
gCreateTempGC
    BX: window or bitmap
    CX: GC selector mask
    DX: GC description block
Creates a new temporary graphics context associated with the window or bitmap,
and makes it the current GC. The previous current GC is remembered. While a
temporary graphics context exists, the following calls are forbidden:
    gCreateGC
    gCreateTempGC
    gSetGC (unless modifying the temporary graphics context)
    wBeginRedrawGC
    wBeginRedrawWinGC
    wFree for any graphics context


Fn $8D Sub $A3
gCreateGC fails
    AX: -> graphics context identifier
    BX: window or bitmap
    CX: GC selector mask
    DX: GC description block
Creates a new graphics context associated with the window or bitmap, and makes
it the current GC.


Fn $8D Sub $24
gSetGC
    BX: graphics context (for v3 and above, 0=current GC)
    CX: GC selector mask
    DX: GC description block
Makes the specified graphics context current, and modifies those properties
specified in the selector mask.


Fn $8D Sub $25
wSetWindow
    BX: window to change
    CX: flags
    DX: address of a block of information about the window
Changes various properties of a window. The flags are as follows:
  Bits 2 to 6, 8, and 10: set the indicated property to the corresponding bit
    of the flags within the information block
  Bit 12: if set, move and resize the window
  Bit 13: if set, change the pointer symbol
  Bit 14: if set, change the background method
New values are taken from the information block, which is as for wCreateWindow.


Fn $8D Sub $26
wBeginRedrawWinGC
    BX: window
    CX: @@@@
    DX: GC selector mask
    DI: address of a GC description block
Validate the window for redrawing (see wBeginRedrawWin) but using a temporary
graphics context which will be destroyed by wEndRedraw.


Fn $8D Sub $27
gDrawLine cgc
    BX: x coordinate of first end
    CX: y coordinate of first end
    DX: x coordinate of second end
    DI: y coordinate of second end
Draws a line between the two locations. If horizontal or vertical, the line
includes the end with the lower coordinates. If diagonal, the line includes
all pixels intersected by the diagonal of a rectangle including the top and
left edges but not the bottom and right edges. Note that, in all cases, the
order of the two ends does not affect the line drawn.


Fn $8D Sub $28
gPrintText cgc
    BX: x coordinate of starting point
    CX: y coordinate of baseline
    DX: (text) string
    DI: length of string (maximum 246)
Prints the string at the indicated location. Characters not found in the font
will be treated as if they were the highest character code.


Fn $8D Sub $29
gCopyBit cgc
    BX: address of point definition block
    CX: bitmap identifier or window identifier
    DX: standard rectangle structure
    DI: mode (see gFillPattern)
Copies a rectangular block from a bitmap or a backed-up window (see gSaveBit).
The top left corner of the rectangle is copied to the point given by the
definition block:
  Offset 0 (word): x
  Offset 2 (word): y
The function cannot copy from a bitmap to itself. If the destination is in
grey plane mode, the grey plane of the source is used if there is one. If the
destination is in both planes mode, a single plane source is copied to both
planes, and a double plane source has each plane copied to the corresponding
plane.


Fn $8D Sub $AA
wCreateWindow fails
    AX: -> new window identifier
    BX: parent window (0 = parent is the entire screen)
    CX: flags
    DX: address of a block of information about the window
    DI: handle for the new window (must not be zero)
Creates a new window which is a child of the specified window, and gives it
the indicated id and handle (note that the two are not the same, and the former
is used in other calls except where explicitly stated otherwise). The window
cannot be drawn to until wInitialiseWindowTree has initialised it. The flags
are:
  Bits 0 to 11: if set, use the corresponding bit from the flags word of the
                information block; if clear, bits 1, 2, 7, 8, and 9 are
                cleared, the remainder are inherited from the parent window.
  Bit 12: set = use coordinates and size, clear = covers entire parent
  Bit 13: set = use pointer symbol in information block, clear = use parent's
  Bit 14: set = new background method, clear = same method as parent
The information block contains the following:
  Offset  0 (word): flags
    Bit  0: this window is input-only (and therefore invisible)
    Bit  1: pressing a mouse button starts rubber-banding (see wRubberBand)
    Bit  2: ignore the mouse when it is within this window
    Bit  3: send mouse events when the mouse button is up
    Bit  4: send mouse events when the mouse button is down
    Bit  5: grab the mouse when its button is pressed
    Bit  6: draw in double pixel mode (v4 only)
    Bit  7: visible only when client is in foreground (large screen only)
    Bit  8: send redraw events to windows with this bit set bfore those with
            it clear
    Bit  9: do not send redraw events
    Bit 10: activate the window if it receives a mouse click
    Bit 11: rubber banding will terminate when the mouse button is released
  Offset  2 (word): x coordinate within parent
  Offset  4 (word): y coordinate within parent
  Offset  6 (word): width
  Offset  8 (word): height
  Offset 10 (word): identifier of the pointer symbol, where relevant
  Offset 12 (byte): background redraw method
    Bits 0 and 1: black plane method (0 = do nothing, 1 = set pixels,
                  2 = clear pixels, 3 = keep an off-screen bitmap)
    Bit 3: if set, attempts to draw on the black plane are ignored (v4 only)
    Bits 4 and 5: grey plane method (0 = do nothing, 1 = set pixels,
                  2 = clear pixels, 3 = keep an off-screen bitmap)
    Bit 7: if clear, attempts to draw on the grey plane are ignored
The choice of keeping an off-screen bitmap cannot be changed after the window
has been created, while the other options can be changed using wSetWindow.


Fn $8D Sub $2B
wBeginRedrawGC
    BX: window
    CX: address of a standard rectangle structure
    DX: graphics context fields to be set
    DI: address of a graphics context information block
Validate the window for redrawing (see wBeginRedrawWin) with the update region
set to the indicated rectangle and using a temporary graphics context which
will be destroyed by wEndRedraw (see wBeginRedrawWinGC).


Fn $8D Sub $AC
gPrintClipText cgc
    AX: -> number of characters printed
    BX: x coordinate of starting point
    CX: y coordinate of baseline
    DX: (text) string
    DI: length of string (maximum 244)
    SI: maximum number of pixels
Prints the string at the indicated location as gPrintText, but only enough
characters are printed to fit within the specified number of pixels.


Fn $8D Sub $2D
gPrintBoxText cgc
    BX: address of a standard rectangle structure
    SI: distance from top of rectangle to baseline
    AX: alignment (1=right, 2=left, 4=centre)
    CX: margin
    DX: (text) string
    DI: length of string (maximum 236)
Clears the specified rectangle, then prints the string within it using text
mode 0 (set pixels). The text is clipped to fit within the rectangle. The
string is printed in the part of the rectangle excluding a margin area, whose
position depends on the alignment:
  left or right: CX must be >= 0, margin is on the same side, width is CX
  centre and CX >= 0: margin is on the left, width is CX
  centre and CX <  0: margin is on the right, width is -CX


Fn $8D Sub $AE
gOpenBit fails
    AX: -> bitmap identifier
    BX: (cstr) filename
    CX: bitmap number (0 = first or only)
    DX: flags
    SI: address of an information block
Loads a specified bitmap from a file. The flags are:
  Bit 0: set for a writeable bitmap, clear for a shared read-only bitmap
  Bit 1: place the bitmap in a separate memory segment
  Bit 2: write the segment name in the information block
  Bit 3: must be clear
The information block is written to as follows:
  Offset 0 (word): set to the width of the bitmap
  Offset 2 (word): set to the height of the bitmap
  Offset 4 to  17: set to the segment name (cstr), only if flag bit 2 is set


Fn $8D Sub $AF
gOpenMouseIcon fails
    AX: -> mouse icon identifier
    BX: (cstr) file name
    CX: number of icon within file
Loads a specified mouse icon from a file.


Fn $8D Sub $B0
gOpenFont fails
    AX: -> font identifier
    BX: (cstr) filename
Opens the specified font file.


Fn $8D Sub $31
gDrawBox cgc
    BX: address of a standard rectangle structure
Draws a box of the appropriate size. Note that a box with width and height of
3 will have exactly one empty pixel inside it.


Fn $8D Sub $B2
wLoadDYL fails
    AX: -> dyl identifier
    BX: (cstr) DYL segment name
Load a DYL into the window server. The DYL must already have been loaded into
memory with @@@@@@@


Fn $8D Sub $B3
gCreateBit fails
    AX: -> bitmap identifier
    @@: flags
    @@: address of an information block
Creates an uninitialized writeable bitmap. The flags are:
  Bit 0: must be clear
  Bit 1: place the bitmap in a separate memory segment
  Bit 2: write the segment name in the information block
  Bit 3: make the bitmap zero-sized
If the bitmap is zero-sized, nothing can be written to it; the size can be
increased later. The information block is:
  Offset 0 (word): width
  Offset 2 (word): height
  Offset 4 to  17: set to the segment name (cstr), only if flag bit 2 is set


Fn $8D Sub $34
wScrollWin
    BX: window or bitmap
    CX: address of offset structure
Identical to wScrollRect with the rectangle structure set to (0, 0, width,
height).


Fn $8D Sub $35
wDrawTextCursor
    BX: window
    CX: address of text cursor information
As wTextCursor, but the properties byte is ignored and treated as zero.


Fn $8D Sub $36
wInvalidateRect
    BX: window
    CX: address of a standard rectangle structure
Add the rectangle to the update region of the window. This will generate a
redraw event if necessary.


Fn $8D Sub $37
wBeginRedraw
    BX: window
    CX: address of a standard rectangle structure
Validate the window for redrawing (see wBeginRedrawWin) with the update region
set to the rectangle.


Fn $8D Sub $38
wValidateRect
    BX: window
    CX: address of a standard rectangle structure
Validate the indicated rectangle of the window (causing all pixels to be set
or cleared if the background mode is 1 or 2 - this applies to black and grey
separately), and remove that rectangle from the update region of the window.


Fn $8D Sub $B9
gSaveBit fails
    BX: (cstr) filename
    CX: bitmap identifier, window identifier, or zero
Writes a bitmap to the named file. A window identifier must be for a window
with a background redraw method of 3, in which case its off-screen bitmap is
used. Zero for the bitmap causes the entire screen to be saved. If the window
off-screen bitmap, or the screen, has a grey plane then a double-plane bitmap
is written.


Fn $8D Sub $3A
gClrRect cgc
    BX: standard rectangle structure
    CX: 0=set, 1=clear, 2=invert
Sets, clears, or inverts all pixels in the specified rectangle.


Fn $8D Sub $3B
wCallDYL
    BX: dyl identifier
    CX: function number
    DX: number of bytes of data to be passed
    DI: address of data to be passed
Call a function in a DYL loaded into the window server that has no result.


Fn $8D Sub $BC
wCallDYLreply fails
    AX: -> result
    BX: dyl identifier
    CX: function number
