TerminalFace.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Levin on June 6, 1983 2:51 pm
Russ Atkinson (RRA) January 29, 1985 0:46:05 am PST
Doug Wyatt, April 12, 1985 3:01:02 pm PST
Processor-independent interface to keyboard, mouse, cursor, and bitmap display.
DIRECTORY
TerminalDefs USING [Background, Cursor, KeyBits, Position];
TerminalFace: CEDAR DEFINITIONS
~ BEGIN OPEN TerminalDefs;
Keyboard
keyboard: READONLY LONG POINTER TO READONLY KeyBits;
GetKeyboard: PROC RETURNS [KeyBits]
~ TRUSTED INLINE { RETURN[keyboard^] };
Mouse
mousePosition: READONLY LONG POINTER TO READONLY Position;
GetMousePosition: PROC RETURNS [Position]
~ TRUSTED INLINE { RETURN[mousePosition^] };
Returns the current mouse position.
SetMousePosition: PROC [Position];
Sets the mouse position.
Cursor
cursorPosition: READONLY LONG POINTER TO Position;
Position of the cursor's upper left corner, relative to the screen's upper left corner.
GetCursorPosition: PROC RETURNS [Position]
~ TRUSTED INLINE { RETURN[cursorPosition^] };
SetCursorPosition: PROC [position: Position]
~ TRUSTED INLINE { cursorPosition^ ← position };
SetCursorPattern: PROC [cursor: Cursor];
Sets the cursor bitmap to the indicated pattern.
Bitmap Display
There is no provision for multiple black-and-white displays on a single machine.
The display has two state variables: mode and background. The mode has three values: on, off, and disconnected; the background has two values: white and black. When the system is booted, state = disconnected, and background = white.
hasBuffer: READONLY BOOL;
TRUE => display implementation provides real memory for bitmap;
FALSE => client provides real memory for bitmap.
pixelsPerInch: READONLY CARDINAL; -- Size of a pixel
refreshRate: READONLY CARDINAL; -- Times per second that entire screen is refreshed
interlaced: READONLY BOOL; -- Is the refresh two-way interlaced?
width: READONLY NAT; -- width of display in pixels (bits)
height: READONLY NAT; -- height of display in pixels (scan lines)
wordsPerLine: READONLY NAT; -- number of words per scan line
Connect: UNSAFE PROC [base: LONG POINTER];
Caller supplies the address of a block of height*wordsPerLine words; base must be even, and the block must not cross a 64k boundary. Display must be in 'disconnected' mode; connects display to specified bitmap and leaves it in 'off' mode. The bitmap does not appear on the screen until the display is turned on (see below).
Disconnect: PROC;
Display must be in 'off' mode; places display in 'disconnected' mode. Turns screen black, and minimizes consumption of resources (e.g. microprocessor time, memory accesses, etc.). The virtual memory area used for the bitmap may be reused for other purposes while the display is disconnected. The real memory may be reclaimed by the party providing it (i.e. if 'hasBuffer' is FALSE, the face client may reclaim the real memory; if 'hasBuffer' is TRUE, the face implementation may reclaim the real memory.)
TurnOn: UNSAFE PROC;
Display must be in 'off' mode; places display in 'on' mode, causing bitmap to be displayed.
Caution: connected bitmap MUST BE PINNED before this operation is invoked.
TurnOff: PROC;
Display must be in 'on' mode; places display in 'off' mode, causing background color to be displayed on screen.
SetBackground: PROC [background: Background];
white => normal (black on white) view of bitmap (0=>white, 1=>black);
black => inverted (white on black) view of bitmap (0=>black, 1=>white);
hasBorder: READONLY BOOL; -- Is border pattern implemented?
SetBorderPattern: PROC [oddPairs, evenPairs: [0..377B]];
Defines bit pattern shown in visible screen area (if any) outside bitmap. The bit pattern for an individual scan line is defined by displaying a single byte repeatedly along the entire scan line. The same pattern is shown on alternating pairs of lines. (Byte for even pairs shown on lines -4, -3, 0, 1, 4, 5, etc. Byte for odd pairs shown on lines -2, -1, 2, 3, 6, 7, etc.)
Monitor Control
MonitorType: TYPE = {alto, lf};
There are two basic types of monitors that can be connected to D-machines: the narrow Alto-style monitor and the wide LF (large-format) monitor.
Alto monitors run at a fixed field rate (60 hz) which it is not reasonable to change. LF monitors normally run at a field rate of approximately 77 hz. However, this may be reduced to 60 hz for compatibility with videotape and other TV equipment.
To complicate matters, there are two brands of LF monitors presently in use, one made by Ball Brothers and the other by Phillips. They respond in different ways to having their field rate reduced, and require different waveforms for reasonable results.
The software cannot detect which brand of LF monitor is connected; this must be determined by the user. Shine a light through the ventilation slots in the top of the housing. If there is a horizontal logic board at the bottom (under the neck of the picture tube) then it is a Ball Brothers monitor. If the logic board is vertically oriented on the left-hand side (with a bunch of adjustments on the top) then it is a Phillips monitor.
After changing the field rate, it may be necessary to adjust the monitor to restore the proper position of the picture. This is more likely to be needed with a Ball Brothers monitor than with a Phillips monitor.
monitorType: MonitorType;
the monitor connected to this machine
FieldRate: TYPE = {normalAlto, normalLF, lfBall60hz, lfPhillips60hz};
SetFieldRate: PROC [rate: FieldRate] RETURNS [ok: BOOL];
Establishes the new field rate, in a machine-independent fashion. Returns TRUE if the operation is reasonable and is implemented on this machine.
SetVerticalWaveforms: PROC [sync, visible, topBorder: CARDINAL] RETURNS [ok: BOOL];
Sets the vertical waveform parameters to arbitrary values. Sync is the duration of the sync pulse in scan lines; visible is the duration of the visible field including top and bottom borders (i.e., everything except sync); topBorder is the duration of the top border.
All numbers describe scan lines in the even field and must be greater than zero.
For an LF monitor, the standard values are sync=18, visible=430, topBorder=14.
To obtain the normal field rate requires that sync+visible = 448.
To obtain the 60 hz field rate requires that sync+visible = 578.
At present, on the Dorado the three values can be adjusted independently; on the Dolphin and Dandelion nothing may be changed.
Returns TRUE if the operation is implemented on this machine; no other check is made for reasonableness of the operation.
Sound generator
hasSoundGenerator: READONLY BOOL; -- is sound generator implemented?
Beep: PROC [frequency, duration: CARDINAL];
Emits a beep of the specified frequency (in Hz.) and duration (in milliseconds).
Initialization
globalStateSize: READONLY CARDINAL;
Initialize: UNSAFE PROC [globalState: LONG POINTER, wakeVF: WORD];
This procedure initializes the implementation; 'globalState' is a client supplied block of globalStateSize words, 16-word aligned, permanently allocated in first 64K of address space; 'wakeVF' is the wakeup mask for vertical-field interrupts (i.e. refresh of scan lines 0 and 1). [Is 16 word alignment of globalState area necessary on D0?]
InitializeCleanup: PROC;
Initializes the DeviceCleanup coroutine. Client should call this exactly once.
END.