DIRECTORY
BitBltDefs: FROM "BitBltDefs";

GraphicsDefs: DEFINITIONS =
BEGIN
Bitmap: TYPE = RECORD
[bank: [0..77B], --6 bits for Box (idiotic space optimization)
nWords: [0..377B],
nBits,nLines: CARDINAL,
bits: POINTER TO ARRAY [0..0) OF CARDINAL
];
Rectangle: TYPE = RECORD
[
x1,y1,x2,y2: INTEGER --with x1<x2, y1<y2
];
BoxType: TYPE = {normal,outline,gray};
Box: TYPE = RECORD
[boxBitmap: Bitmap,
savedBits: POINTER TO ARRAY [0..0) OF CARDINAL, --used when moving around
displayBitmap: Bitmap,
displayX,displayY: CARDINAL,
displayed: BOOLEAN,--1 bit(i.e.,whether displayX,Y are valid)
savedBank: [0..77B], --6 bits
function: BitBltDefs.BBoperation,--2 bits
type: BoxType,--2 bits
gray: [0..16]--5 bits
];

StrikeFont: TYPE = RECORD
[oneBit,index,fixed: [0..1],
bank: [0..77B],
minCode,maxCode: CARDINAL,
maxWidth: CARDINAL,
strikeBodyWordLength: CARDINAL,
ascent,descent: CARDINAL,
wordsPerScanLine: CARDINAL,
bitmap: POINTER TO ARRAY [0..0) OF CARDINAL,
xInSegment: POINTER TO ARRAY [0..0) OF CARDINAL
];
textMode: TYPE = [0..3];
normal: textMode = 0;
italic: textMode = 1;
bold: textMode=2;

--routines exported by BitmapFns

SetDefaultBitmap: PROCEDURE [width,height: CARDINAL];
TurnOnGraphics: PROCEDURE RETURNS [POINTER TO Bitmap];
GetDefaultBitmapHandle: PROCEDURE RETURNS [POINTER TO Bitmap];
SetXMAlloc: PROCEDURE [Allocate: PROCEDURE [nwords: CARDINAL] RETURNS [LONG POINTER],Free: PROCEDURE [LONG POINTER],AllocateFromBank: PROCEDURE [nwords: CARDINAL,bank: CARDINAL] RETURNS [LONG POINTER]];
GetXMAlloc: PROCEDURE RETURNS [Allocate: PROCEDURE [nwords: CARDINAL] RETURNS [LONG POINTER],Free: PROCEDURE [LONG POINTER],AllocateFromBank: PROCEDURE [nwords: CARDINAL,bank: CARDINAL] RETURNS [LONG POINTER]];

PutPoint: PROCEDURE [x,y: CARDINAL,b: POINTER TO Bitmap ← NIL];
ErasePoint: PROCEDURE [x,y: CARDINAL,b: POINTER TO Bitmap ← NIL];
XorPoint: PROCEDURE [x,y: CARDINAL,b: POINTER TO Bitmap ← NIL];

PutLine
: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
EraseLine: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
XorLine: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];

PutArea
: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
EraseArea: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
XorArea: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
ReplaceArea: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
MaskArea: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];

PutGray
: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
EraseGray: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
XorGray: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
ReplaceGray: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];
MaskGray: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap ← NIL];

PutBitmap
: PROCEDURE [b: POINTER TO Bitmap,x,y: CARDINAL,dest: POINTER TO Bitmap ← NIL];
EraseBitmap: PROCEDURE [b: POINTER TO Bitmap,x,y: CARDINAL,dest: POINTER TO Bitmap ← NIL];
XorBitmap: PROCEDURE [b: POINTER TO Bitmap,x,y: CARDINAL,dest: POINTER TO Bitmap ← NIL];
ReplaceBitmap: PROCEDURE [b: POINTER TO Bitmap,x,y: CARDINAL,dest: POINTER TO Bitmap ← NIL];

--grey square functions (affect subsequent PutArea commands)
SetGrayThresholds: PROCEDURE [POINTER TO ARRAY [0..17B] OF CARDINAL];
SetGrayLevel
: PROCEDURE [CARDINAL]; --set intensity value for area stuff
GetGrayBlock: PROCEDURE RETURNS [gray0,gray1,gray2,gray3: CARDINAL];
PutGrayBitmap: PROCEDURE [b: POINTER TO Bitmap,x,y: CARDINAL,
dest: POINTER TO Bitmap ← NIL];

--Area function: copy (with possible rescaling)
TransferRectangle: PROCEDURE [src,dest: POINTER TO Bitmap,
srcRectangle,destRectangle: POINTER TO Rectangle,
fn: BitBltDefs.BBoperation ← replace,type: BitBltDefs.BBsourcetype ← block];

--and the real functions
SetPoint: PROCEDURE [x,y: CARDINAL,fn: BitBltDefs.BBoperation,
b: POINTER TO Bitmap ← NIL];
SetLine: PROCEDURE [x1,y1,x2,y2: CARDINAL,fn: BitBltDefs.BBoperation,
b: POINTER TO Bitmap ← NIL];
SetArea: PROCEDURE [x1,y1,x2,y2: CARDINAL,fn: BitBltDefs.BBoperation,
b: POINTER TO Bitmap ← NIL];
SetGray: PROCEDURE [x1,y1,x2,y2: CARDINAL,fn: BitBltDefs.BBoperation,
b: POINTER TO Bitmap ← NIL];
SetBitmap: PROCEDURE [b: POINTER TO Bitmap,
x,y: CARDINAL,fn: BitBltDefs.BBoperation,dest: POINTER TO Bitmap ← NIL];

--routines exported by TextFns

GetStrikeHandle: PROCEDURE [fontName: STRING] RETURNS [POINTER TO StrikeFont];
GetFontNameArray: PROCEDURE RETURNS [POINTER TO ARRAY [0..0) OF STRING,CARDINAL];

PutText
: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode,b: POINTER TO Bitmap ← NIL] RETURNS [nextX: CARDINAL];
ReplaceText: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode,b: POINTER TO Bitmap ← NIL] RETURNS [nextX: CARDINAL];
EraseText
: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode,b: POINTER TO Bitmap ← NIL] RETURNS [nextX: CARDINAL];
XorText
: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode,b: POINTER TO Bitmap ← NIL] RETURNS [nextX: CARDINAL];

SetText
: PROCEDURE [s: STRING,x,y: CARDINAL,fn: BitBltDefs.BBoperation,font: POINTER TO GraphicsDefs.StrikeFont,mode: GraphicsDefs.textMode,b: POINTER TO GraphicsDefs.Bitmap ← NIL] RETURNS [nextX: CARDINAL];

PutRotatedText: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,cosTheta,sinTheta: INTEGER];
PutRotatedTextInBitmap: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,cosTheta,sinTheta: INTEGER,b: POINTER TO Bitmap];

--routines exported by BoxFns

CreateBox: PROCEDURE [b: POINTER TO Box,width,height: CARDINAL];
DisplayBox: PROCEDURE [b: POINTER TO Box,x,y: CARDINAL,
bitmap: POINTER TO Bitmap ← NIL];
ReleaseBox: PROCEDURE [b: POINTER TO Box]; --release temp storage for current box
RemoveBox: PROCEDURE [b: POINTER TO Box]; --undisplay
DestroyBox: PROCEDURE [b: POINTER TO Box,restore: BOOLEAN];
CursorInBox: PROCEDURE [b: POINTER TO Box] RETURNS [BOOLEAN];
MoveBox: PROCEDURE [b: POINTER TO Box,cornerX,cornerY: CARDINAL];
PaintBox: PROCEDURE [b: POINTER TO Box]; --update current display
END.