-- file DisplayDefs
-- last edited by Brotz, January 15, 1981 3:30 PM

DIRECTORY
Ascii,
Mopcodes,
ovD: FROM "OverviewDefs";

dsD: DEFINITIONS =

BEGIN

-- Purpose: contains those procedures that directly use bitmaps, fonts, and the cursor.


-- "Public" Variables (for initialization)

bbtPtr, charBbtPtr, pictureBbtPtr: BbtPtr;


-- Public Types

ScreenXCoord: TYPE = CARDINAL;
ScreenYCoord: TYPE = CARDINAL;

FaceType: TYPE = {plainFace, boldFace, italicFace};

CursorShape: TYPE = {lineArrow, charArrow, thumbMarker, scroll, scrollUp, scrollDown,
bullsEye, hourGlass, boundaryPad, invisibleCursor, questionMark, invertQuestionMark};

PictureClass: TYPE = {triangle, caret, leftEdgeCaret, boundaryPad, selectionThumbMark,
resetMenuIcon};

BitBltFunction: TYPE = CARDINAL;

GrayBitPattern: TYPE = ARRAY [0 .. 3] OF UNSPECIFIED;

GrayShade: TYPE = {white, black, lightGray, darkGray, dottedLine};

Font: TYPE = POINTER; -- address of a font base


-- Private Types

DCBptr: TYPE = POINTER TO DCB;

DCB: TYPE = MACHINE DEPENDENT RECORD
[next: DCBptr,
resolution: restype,
background: backgtype,
indenting: [0..77B], -- in units of 16 bits
width: [0..377B], -- in units of 16 bits and must be even
bitmap: BitMapPtr,
height: CARDINAL]; -- in units of double scan lines

restype: TYPE = {high, low};

backgtype: TYPE = {white, black};

BitMap: TYPE = UNSPECIFIED; -- a flagrent lie, but the best the type system can do
BitMapPtr: TYPE = ORDERED POINTER TO BitMap;

-- Global constants --

bmWidth: CARDINAL = 30;

numScanLines: CARDINAL = 720;

xOrigin: ScreenXCoord = 64;
yOrigin: ScreenYCoord = 40;

lineHeight: CARDINAL = 12;

DCBorg: POINTER TO DCBptr = LOOPHOLE[420B];

DCBnil: DCBptr = LOOPHOLE[0]; -- indicates end of DCB chain

cursorX: POINTER TO CARDINAL = LOOPHOLE[426B];

cursorY: POINTER TO CARDINAL = LOOPHOLE[427B];

Bbt: TYPE = MACHINE DEPENDENT RECORD
[pad: [0..1777B] ← 0,
sourcealt, destalt: BOOLEAN ← FALSE, -- TRUE to use alternate memory bank
func: [0 .. 17B],
unused: CARDINAL ← 0,
-- BitBlt function codes:
-- replace:(0) d ← s’
-- paint:(1) d ← s’ ior d
-- invert:(2) d ← s’ xor d
-- erase:(3) d ← ~s’ and d
--
-- source: (0) s’ = s
-- complementOfSource:(4) s’ = ~s
-- sourceAndGray: (8) s’ = s and g
-- gray:(12) s’ = g
dbca: BitMapPtr,-- destination bitmap’s base core address
dbmr: CARDINAL ← dsD.bmWidth, -- destination bitmap’s width in words
dlx,-- destination left x relative to bitmap
dty,-- destination top y relative to bitmap
dw,-- width of rectangle in bits
dh: CARDINAL,-- height of rectangle in bits
sbca: BitMapPtr,-- source bitmap base core address
sbmr,-- source bitmap’s width in words
slx,-- source left x relative to bitmap
sty: CARDINAL,-- source top y relative to bitmap
gray: GrayBitPattern ← NULL];-- four words of gray pattern

BbtPtr: TYPE = POINTER TO Bbt;

replace: BitBltFunction = 0;
paint: BitBltFunction = 1;
invert: BitBltFunction = 2;
erase: BitBltFunction = 3;
source: BitBltFunction = 0;
complementOfSource: BitBltFunction = 4;
sourceAndGray: BitBltFunction = 8;
gray: BitBltFunction = 12;

XWord: TYPE = MACHINE DEPENDENT RECORD
[widthOrExtension: [0 .. 77777B], -- either a width field or an extension
hasNoExtension: [0 .. 1]]; -- determines the interpretation of above field
XwPtr: TYPE = POINTER TO XWord;

CharFont: TYPE = MACHINE DEPENDENT RECORD
[width: [0 .. 77777B], -- either a width field or an extension
hasNoExtension: [0 .. 1], -- determines the interpretation of above field
ySkip: [0 .. 377B), -- scan lines to skip before inserting char in bitmap
height: [0 .. 377B)]; -- height of char bitmap
CharFontPtr: TYPE = POINTER TO CharFont;

LegalCharacters: TYPE = CHARACTER[0C .. Ascii.CR + (ovD.LineBreakValue - 0C)];

CharPropertyTable: TYPE = PACKED ARRAY LegalCharacters OF CharProperty;

CharProperty: TYPE = MACHINE DEPENDENT
{white, alpha, digit, alphaNumeric, punctuation, illegal, (15)};

cursorBM: POINTER TO CursorBitMap = LOOPHOLE[431B];

CursorBitMap: TYPE = ARRAY [0 .. 16) OF UNSPECIFIED;

PictureBitMap: TYPE = ARRAY [0 .. 12) OF UNSPECIFIED;

HotSpot: TYPE = RECORD [x, y: INTEGER];

CursorObject: TYPE = RECORD
[hotSpot: HotSpot,
bitMap: CursorBitMap];

CursorTable: TYPE = ARRAY CursorShape OF CursorObject;

Dimensions: TYPE = RECORD [width, height: [0 .. 377B]];

PictureObject: TYPE = RECORD
[dimensions: Dimensions,
bitmap: PictureBitMap];

PictureTable: TYPE = ARRAY PictureClass OF PictureObject;


ClearDCBs: PROCEDURE = INLINE {DCBorg↑ ← DCBnil};

Display: PROGRAM;


-- Character-Oriented Procedures


PutCharInBitMap: PROCEDURE [char: CHARACTER, x: ScreenXCoord, y: ScreenYCoord,
face: FaceType] RETURNS [ScreenXCoord];
-- Places char in standard bitmap at screen position x,y in the specified face. Uses the
-- standard Laurel display font. Assuming that the caller knows what he is doing,
-- PutCharInBitmap makes no check of whether the point x,y is covered by bitmap; if
-- given out of range arguments, PutCharInBitmap will overwrite memory. Returns first
-- free ScreenXCoord.


PutStringInBitMap: PROCEDURE [x: ScreenXCoord, y: ScreenYCoord, s: STRING,
face: FaceType] RETURNS [newRightX: ScreenXCoord];
-- Puts all characters of s into the bitmap starting at x in face.


Underline: PROCEDURE [leftx, rightx: ScreenXCoord, y: ScreenYCoord];
-- Underlines [leftx, rightx) in a line of characters at position y in the standard font.


RemoveUnderline: PROCEDURE [leftx, rightx: ScreenXCoord, y: ScreenYCoord];
-- Remove possible underline [leftx, rightx) in a line of characters at position y in the
-- standard font.


GetCharRightX: PROC [char: CHARACTER, leftX: ScreenXCoord]
RETURNS [rightX: ScreenXCoord];
-- Given a char positioned at leftX, returns its rightX. Char is
-- always masked to 7 bits. Tab widths may vary depending on
-- leftX are handled.


GetStaticCharWidth: PROC [char: CHARACTER]
RETURNS [CARDINAL];
-- Returns the width of char in bit positions, ignoring screen position. Char is always masked to 7 bits.


GetVisibleCharWidth: PROCEDURE [char: CHARACTER] RETURNS [CARDINAL];
-- Returns the width of char in bit positions, ignoring screen position. Widths of visible tab and CR are considered.


GetStringWidth: PROCEDURE [s: STRING, face: FaceType] RETURNS [width: CARDINAL];
-- Adds character widths for an entire string; returns the sum.


GetCharProperty: PROCEDURE [char: CHARACTER, property: CharProperty]
RETURNS [BOOLEAN];
-- Returns TRUE iff char has property.


GetCharBreakProp: PROCEDURE [char: CHARACTER]
RETURNS[property: CharProperty];
-- Returns break property {white, alphaNumeric, punctuation} for char.


-- Region-Oriented Procedures


InvertRectangle: PROCEDURE [left, right: ScreenXCoord, top, bottom: ScreenYCoord,
grayShade: GrayShade ← black];
-- Inverts (XORs) grayShade into the specified half-open rectangle.


ReplaceRectangle: PROCEDURE [left, right: ScreenXCoord, top, bottom: ScreenYCoord,
grayShade: GrayShade];
-- Sets all bits in the specified half-open rectangle using grayShade.


ClearRectangle: PROCEDURE [left, right: ScreenXCoord, top, bottom: ScreenYCoord] =
INLINE {ReplaceRectangle[left, right, top, bottom, white]};


BlackenRectangle: PROCEDURE [left, right: ScreenXCoord, top, bottom: ScreenYCoord] =
INLINE {ReplaceRectangle[left, right, top, bottom, black]};


SlideRectangleHorizontally: PROCEDURE [left, right: ScreenXCoord,
top, bottom: ScreenYCoord, deltaX: INTEGER];
-- Slides rectangle horizontally deltaX raster points. Clears vacated area.


ItalicizeRectangle: PROCEDURE [left, right: ScreenXCoord, top: ScreenYCoord,
lineHeight: CARDINAL];
-- Slants bitmap from [left, right - lineHeight/2 +1, top, top + lineHeight] to [left, right, top,
-- top + lineHeight];


SlideFullWidthRectangleVertically: PROCEDURE [top, bottom: ScreenYCoord,
newTop: ScreenYCoord];
-- The display in the rectangle [top .. bottom) is moved so that its new top is at newTop.
-- The prior contents of the target region is overwritten. All intervening and vacated
-- areas are cleared.


MoveFullWidthRectangleVertically: PROCEDURE [top, bottom: ScreenYCoord,
newTop: ScreenYCoord];
-- The display in the rectangle [top .. bottom) is moved so that its new top is at newTop.
-- The prior contents of the target region is overwritten. All intervening and vacated
-- areas are not cleared.


BitBlt: PRIVATE PROCEDURE [ptr: BbtPtr] =
-- See hardware manual.
MACHINE CODE BEGIN Mopcodes.zLI0; Mopcodes.zBITBLT END;


-- Picture Oriented Procedures


SetCursor: PROCEDURE [shape: CursorShape];
-- Sets the cursor to the specified shape. The hardware cursor point is maintained at the
-- current position.


ChangeCursor: PROCEDURE [shape: CursorShape];
-- Changes the cursor to the specified shape. The sensitive point is maintained at the
-- current position.


GetCursor: PROCEDURE RETURNS [shape: CursorShape, sensitiveX, sensitiveY: INTEGER];
-- Returns the current cursor shape and sensitive point offsets.


GetPictureParameters: PROCEDURE [picture: PictureClass]
RETURNS [width, height: CARDINAL];
-- Returns width and height in bits of picture.


PaintPicture: PROCEDURE [x: ScreenXCoord, y: ScreenYCoord, picture: PictureClass,
function: BitBltFunction];
-- BitBlt’s picture onto the display at x,y according to the function specified. Each function
-- corresponds to the bitblt function code + source.



END. -- of DisplayDefs --