-- XGraphicsDefs.mesa
-- Mesa 6 version

-- Joe Maleson’s mesa graphics stuff, adapted for Tex
-- Last changed by Doug Wyatt, September 23, 1980 2:52 PM

DIRECTORY
SegmentDefs: FROM "SegmentDefs",
BitBltDefs: FROM "BitBltDefs";

XGraphicsDefs: DEFINITIONS =
BEGIN
Bitmap: TYPE = RECORD
[bank: SegmentDefs.BankIndex,
nWords: [0..377B],
nBits,nLines: CARDINAL,
bits: POINTER TO ARRAY [0..0) OF CARDINAL
];
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: SegmentDefs.BankIndex,
function: BitBltDefs.BBoperation,--2 bits
type: BoxType,--2 bits
gray: [0..16]--5 bits
];

StrikeFont: TYPE = RECORD
[oneBit,index,fixed: [0..1],
bank: SegmentDefs.BankIndex,
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]
];

--first, the routines using default bitMap (Screen)
PutPoint: PROCEDURE [x,y: CARDINAL];
ErasePoint: PROCEDURE [x,y: CARDINAL];
XorPoint: PROCEDURE [x,y: CARDINAL];

PutLine: PROCEDURE [x1,y1,x2,y2: CARDINAL];
EraseLine: PROCEDURE [x1,y1,x2,y2: CARDINAL];
XorLine: PROCEDURE [x1,y1,x2,y2: CARDINAL];

PutArea: PROCEDURE [x1,y1,x2,y2: CARDINAL];
EraseArea: PROCEDURE [x1,y1,x2,y2: CARDINAL];
XorArea: PROCEDURE [x1,y1,x2,y2: CARDINAL];
ReplaceArea: PROCEDURE [x1,y1,x2,y2: CARDINAL];

PutGray: PROCEDURE [x1,y1,x2,y2: CARDINAL];
EraseGray: PROCEDURE [x1,y1,x2,y2: CARDINAL];
XorGray: PROCEDURE [x1,y1,x2,y2: CARDINAL];
ReplaceGray: PROCEDURE [x1,y1,x2,y2: CARDINAL];

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

--now, routines specifying bitmaps
PutPointInBitmap: PROCEDURE [x,y: CARDINAL,b: POINTER TO Bitmap];
ErasePointInBitmap: PROCEDURE [x,y: CARDINAL,b: POINTER TO Bitmap];
XorPointInBitmap: PROCEDURE [x,y: CARDINAL,b: POINTER TO Bitmap];

PutLineInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
EraseLineInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
XorLineInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];

PutAreaInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
EraseAreaInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
XorAreaInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
ReplaceAreaInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
MaskAreaInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];

PutGrayInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
EraseGrayInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
XorGrayInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
ReplaceGrayInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];
MaskGrayInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,b: POINTER TO Bitmap];

PutBitmapInBitmap: PROCEDURE [b: POINTER TO Bitmap, x,y: CARDINAL,
dest: POINTER TO Bitmap];
EraseBitmapInBitmap: PROCEDURE [b: POINTER TO Bitmap, x,y: CARDINAL,
dest: POINTER TO Bitmap];
XorBitmapInBitmap: PROCEDURE [b: POINTER TO Bitmap, x,y: CARDINAL,
dest: POINTER TO Bitmap];
ReplaceBitmapInBitmap: PROCEDURE [b: POINTER TO Bitmap, x,y: CARDINAL,
dest: POINTER TO Bitmap];

--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];
PutGrayBitmapInBitmap: PROCEDURE [b: POINTER TO Bitmap, x,y: CARDINAL,
dest: POINTER TO Bitmap];

--and the real functions
SetPointInBitmap: PROCEDURE [x,y: CARDINAL,
fn: BitBltDefs.BBoperation, b: POINTER TO Bitmap];
SetLineInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,
fn: BitBltDefs.BBoperation, b: POINTER TO Bitmap];
SetAreaInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,
fn: BitBltDefs.BBoperation, b: POINTER TO Bitmap];
SetGrayInBitmap: PROCEDURE [x1,y1,x2,y2: CARDINAL,
fn: BitBltDefs.BBoperation, b: POINTER TO Bitmap];
SetBitmapInBitmap: PROCEDURE [b: POINTER TO Bitmap, x,y: CARDINAL,
fn: BitBltDefs.BBoperation, dest: POINTER TO Bitmap];

--routines exported by TextFns

TurnOnText: PROCEDURE;
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] RETURNS [nextX: CARDINAL];
ReplaceText: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode] RETURNS [nextX: CARDINAL];
EraseText: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode] RETURNS [nextX: CARDINAL];
XorText: PROCEDURE [s: STRING,x,y: CARDINAL,font: POINTER TO StrikeFont,mode: textMode] RETURNS [nextX: CARDINAL];

PutTextInBitmap: PROCEDURE [s: STRING, x,y: CARDINAL,
font: POINTER TO StrikeFont, mode: textMode, b: POINTER TO Bitmap]
RETURNS [nextX: CARDINAL];
ReplaceTextInBitmap: PROCEDURE [s: STRING, x,y: CARDINAL,
font: POINTER TO StrikeFont, mode: textMode, b: POINTER TO Bitmap]
RETURNS [nextX: CARDINAL];
EraseTextInBitmap: PROCEDURE [s: STRING, x,y: CARDINAL,
font: POINTER TO StrikeFont, mode: textMode, b: POINTER TO Bitmap]
RETURNS [nextX: CARDINAL];
XorTextInBitmap: PROCEDURE [s: STRING, x,y: CARDINAL,
font: POINTER TO StrikeFont, mode: textMode, b: POINTER TO Bitmap]
RETURNS [nextX: CARDINAL];

SetTextInBitmap: PROCEDURE [s: STRING, x,y: CARDINAL,
fn: BitBltDefs.BBoperation,
font: POINTER TO StrikeFont,
mode: textMode,
b: POINTER TO Bitmap]
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];
ReleaseBox: PROCEDURE [b: POINTER TO Box]; --release temp storage for current box
RemoveBox: PROCEDURE [b: POINTER TO Box]; --undisplay
DisplayBoxInBitMap: PROCEDURE [b: POINTER TO Box,x,y: CARDINAL,
bitmap: POINTER TO Bitmap];
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

XBitmapFns: PRIVATE PROGRAM;
XBoxFns: PRIVATE PROGRAM;
XTextFns: PRIVATE PROGRAM;
XGraphicsControl: PROGRAM;

END.