-- PressDefs.mesa
-- Written by Joe Maleson
-- Last changed by Doug Wyatt, September 29, 1980 1:27 PM

DIRECTORY
AltoFileDefs USING [FP,vDA],
StreamDefs USING [StreamHandle,DiskHandle],
DiscoDefs USING [DiskPosition];

PressDefs: DEFINITIONS =
BEGIN

--standard press file procedural interface

InitPressFileDescriptor
: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,filename: STRING];

SetSpaceX: PROCEDURE [p: POINTER TO PressFileDescriptor, micaX: CARDINAL];

SetSpaceY: PROCEDURE [p: POINTER TO PressFileDescriptor, micaY: CARDINAL];

ResetSpace: PROCEDURE [p: POINTER TO PressFileDescriptor];

PutSpace: PROCEDURE [p: POINTER TO PressFileDescriptor];

SetColor: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor, hue,sat,bright: [0..256)];

SetHue: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,hue: [0..256)];

SetSaturation: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,sat: [0..256)];

SetBrightness: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,bright: [0..256)];

SetFont: PUBLIC PROCEDURE [p: POINTER TO PressDefs.PressFileDescriptor,Name: STRING,PointSize: CARDINAL,Face: CARDINAL ← 0,Rotation: CARDINAL ← 0];

PutText: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,str: STRING,
xleft,ybase: CARDINAL];

PutRectangle: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor, xstart,ystart,xlen,ylen: CARDINAL];

PutTextHere: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,str: STRING];

PutRectangleHere: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor, xlen,ylen: CARDINAL];

StartOutline: PUBLIC PROCEDURE[p: POINTER TO PressFileDescriptor,x0,y0: CARDINAL];

PutMoveTo: PUBLIC PROCEDURE[p: POINTER TO PressFileDescriptor,xend,yend: CARDINAL];

PutDrawTo: PUBLIC PROCEDURE[p: POINTER TO PressFileDescriptor,xend,yend: CARDINAL];

PutCubic: PUBLIC PROCEDURE[p: POINTER TO PressFileDescriptor,x1,y1,x2,y2,x3,y3: REAL];
--Extend outline by cubic relative to current position
--xi is x coefficient of t↑i, etc.

EndOutline: PUBLIC PROCEDURE[p: POINTER TO PressFileDescriptor];

PutAltoDots: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,
x,y,nDots,nScanLines: CARDINAL,dots: POINTER];

PutPressDotsData: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,
x,y: CARDINAL,dotsData: POINTER TO PressDotsData,
nextScanLine: PROCEDURE RETURNS [POINTER]];

PutDots: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,
x,y,nPixels,nScanLines,bitsPerPixel,width,height: CARDINAL,dots: POINTER,
screenFrequency: CARDINAL ← 0,screenAngle: CARDINAL ← 45];

PutComputedDots: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,
x,y,nPixels,nScanLines,bitsPerPixel,width,height: CARDINAL,
nextScanLine: PROCEDURE RETURNS [POINTER],
screenFrequency: CARDINAL ← 0,screenAngle: CARDINAL ← 45,
min,max: CARDINAL ← 0];

PutDotsFromFile: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,
x,y,nPixels,nScanLines,bitsPerPixel,width,height: CARDINAL,dots: STRING,
screenFrequency: CARDINAL ← 0,screenAngle: CARDINAL ← 45,
min,max: CARDINAL ← 0];

WritePage: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor];

ClosePressFile: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor];

--low level utility functions

MulDiv: PUBLIC PROCEDURE [a,b,c:CARDINAL] RETURNS [CARDINAL];

SignedMulDiv: PUBLIC PROCEDURE [a,b,c:INTEGER] RETURNS [INTEGER];

SetBlock: PUBLIC PROCEDURE [buf: POINTER TO ARRAY [0..0) OF INTEGER,val,len: INTEGER];

WriteCommand: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor,Command: CARDINAL,Param: POINTER TO ARRAY [0..6) OF CARDINAL];

WriteDirectory: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor];

WritePartDirectory: PUBLIC PROCEDURE [p: POINTER TO PressFileDescriptor];

--font operations (from FontWidth)

EncodeFace: PUBLIC PROCEDURE [weight,slope,expansion: CHARACTER] RETURNS [INTEGER];

LookupFontName: PROCEDURE [s: StreamDefs.StreamHandle,famstr: STRING,face,siz,rot: INTEGER,bufx,bufy: POINTER TO ARRAY [0..256) OF INTEGER,boundbox: POINTER TO ARRAY [0..4) OF INTEGER] RETURNS[BOOLEAN];

--press object functions and data structures

OpenPressFile: PUBLIC PROCEDURE [fileName: STRING,pfp: POINTER TO PressFilePointers] RETURNS [nPages: CARDINAL];
OpenPressFileFromFP: PUBLIC PROCEDURE [fp: POINTER TO AltoFileDefs.FP,pfp: POINTER TO PressFilePointers] RETURNS [nPages: CARDINAL];

--userProc is really PROCEDURE[p: POINTER TO PressPage];
-- it is called once for each object on the page
GetPressPageFromFP
: PUBLIC PROCEDURE[fp: POINTER TO AltoFileDefs.FP,pageNumber: CARDINAL,p: POINTER TO PressPage,userProc: UNSPECIFIED ← 0];
ReadPressPage: PROCEDURE [pfp: POINTER TO PressFilePointers,pageNumber: CARDINAL,p: POINTER TO PressPage,userProc: UNSPECIFIED ← 0];

ReleasePressFilePointers
: PUBLIC PROCEDURE [pfp: POINTER TO PressFilePointers];

GetPressPage: PROCEDURE[fileName: STRING,pageNumber: CARDINAL,p: POINTER TO PressPage];

GetPressDotsData: PROCEDURE [obj: POINTER TO PressObject,dots: POINTER TO PressDotsData];

ReleasePressPage: PROCEDURE[p: POINTER TO PressPage];

PutPressPage: PROCEDURE[pfd: POINTER TO PressFileDescriptor,p: POINTER TO PressPage,dx: CARDINAL ← 0,dy: CARDINAL ← 0];

PressObject: TYPE = RECORD
[
link: POINTER TO PressObject,
micaX,micaY: CARDINAL,
command: PressDefs.ELCommand,

--to keep this data type autonomous, include all global state
hue,sat,br: [0..377B],
spaceX,spaceY: CARDINAL,
font: [0..17B],

--and stuff to get data from input stream
nDataBytes: [0..7777B],
diskPosition: DiscoDefs.DiskPosition
];

PressDotsData: TYPE = RECORD
[
nBitsPerPixel,nPixels,nLines: CARDINAL,
passPixels,displayPixels,passLines,displayLines: CARDINAL,
micaWidth,micaHeight: CARDINAL,
min,max: CARDINAL,
angle,frequency: CARDINAL,
opaque: BOOLEAN,
haveDot: BOOLEAN,--whether dotPosition is relevant
mode: [0..15],
fileName: STRING,--in case GetDotsFromFile
dotPosition,diskPosition: DiscoDefs.DiskPosition
];

PressFont: TYPE = RECORD
[
Family: STRING,
PointSize,Face,Rotation: CARDINAL,
Widths: POINTER TO ARRAY CHARACTER [0C..255C] OF CARDINAL
];

PressPage: TYPE = RECORD
[
leftX,bottomY,rightX,topY: CARDINAL,--bounding box in micas for page
ObjectList: POINTER TO PressObject,--linked list
FontDir: ARRAY[0..16] OF POINTER TO PressFont --allows 16 fonts+NIL trailer
];

PressFilePointers: TYPE = RECORD
[
FontDir: POINTER TO ARRAY [0..0) OF PressFontEntry,
PartDir: POINTER TO ARRAY [0..0) OF PartEntry,
vDAs: POINTER TO ARRAY [0..0) OF AltoFileDefs.vDA,
fontWidthsStream: StreamDefs.DiskHandle
];

--data structures and constants

Byte: TYPE = [0..377B];
PressPassword: CARDINAL = 27183;

PressFileDescriptor: TYPE = RECORD
[ outStream: StreamDefs.StreamHandle,
fontDir: POINTER TO FontDir,
partDir: POINTER TO PartDir,
EntityCommandLen: CARDINAL,
EntityCommandMaxLen: CARDINAL,
EntityCommands: POINTER TO PACKED ARRAY [0..2048) OF [0..256),
RecordStart: CARDINAL,
fontLen: CARDINAL,
partLen: CARDINAL,
numParts: CARDINAL,
numFonts: CARDINAL,
FirstCopy: CARDINAL,
LastCopy: CARDINAL,
solidCode: CHARACTER,
PressFileName: STRING,
UserName: STRING,
DateString: STRING,
--general page params
TopMarg,BottomMarg,LeftMarg,RightMarg: INTEGER,
--some stuff to do with current font etc.
CurSpaceX,CurSpaceY: CARDINAL,
CurHue,CurSat,CurBright: [0..256)
];

FontDir: TYPE = ARRAY [0..128) OF POINTER; -- to FontEntry or FontCharacter
PartDir: TYPE = ARRAY [0..128) OF PartEntry;
DocDir: TYPE = MACHINE DEPENDENT RECORD
[ Password: CARDINAL,
nRecs: CARDINAL,
nParts: CARDINAL,
partDirStart: CARDINAL,
partLength: CARDINAL,
spare1: CARDINAL,
date: LONG INTEGER,
firstCopy: INTEGER,
lastCopy: INTEGER,
firstPage: INTEGER,
lastPage: INTEGER,
spare2: Byte,
solidCode: CHARACTER,
spare3: ARRAY [13D..177B] OF CARDINAL,
fileName: PACKED ARRAY [ 0..51] OF CHARACTER,
userName: PACKED ARRAY [0..31] OF CHARACTER,
dateString: PACKED ARRAY [0..39] OF CHARACTER,
spare4: ARRAY [276B..377B] OF CARDINAL
];

PartType: TYPE = CARDINAL;
Page: PartType = 0;
Font: PartType = 1;
ExternalFileDirectory: PartType = 2;
PartEntry: TYPE = MACHINE DEPENDENT RECORD
[ Type: PartType,
RecordStart: CARDINAL,
RecordLength: CARDINAL,
PaddingLength: CARDINAL
];

PressFontEntry: TYPE = MACHINE DEPENDENT RECORD
[ EntryLength: CARDINAL,
FontSet: Byte,
Font: Byte,
M: Byte,
N: Byte,
Family: PACKED ARRAY [0..20) OF CHARACTER,
Face: Byte,
Source: Byte,
Size: CARDINAL,
Rotation: CARDINAL
];
FontEntry: TYPE = RECORD
[ EntryLength: CARDINAL,
FontSet: Byte,
Font: Byte,
M: Byte,
N: Byte,
Family: STRING,
Face: Byte,
Source: Byte,
Size: CARDINAL,
Rotation: CARDINAL
];
FontCharacter: TYPE = MACHINE DEPENDENT RECORD
[ EntryLength: CARDINAL,
FontSet: Byte,
Font: Byte,
M: Byte,
AllOnes: Byte,
Zero: CARDINAL,
ObjectList: POINTER
];

MRR: Byte = 0;
MIR: Byte = 1;
BRR: Byte = 2;
BIR: Byte = 3;
EntityCommandTrailer: TYPE = MACHINE DEPENDENT RECORD
[
Type: Byte,
FontSet: Byte,
BeginByte,ByteLen: ARRAY[0..1] OF CARDINAL,
Xe,Ye,Left,Bottom,Width,Height,EntityLen: CARDINAL
];

--General constants
MicasPerInch: INTEGER=2540;
PointsPerInch: INTEGER=72;
MicaHeight: INTEGER = MicasPerInch*11;
MicaWidth: INTEGER = (MicasPerInch/2)*17;
maxFonts: CARDINAL = 16;
--Entity list commands;
ELCommand: TYPE = [0..377B];
ELShowCharactersShort: ELCommand = 0;
ELSkipCharactersShort: ELCommand = 40B;
ELShowCharactersAndSkip: ELCommand = 100B;
ELSetSpaceXShort: ELCommand = 140B;
ELSetSpaceYShort: ELCommand = 150B;
ELFont: ELCommand = 160B;
ELSkipControlBytesImmediate: ELCommand = 353B;
ELAlternative: ELCommand = 354B;
ELOnlyOnCopy: ELCommand = 355B;
ELSetX: ELCommand = 356B;
ELSetY: ELCommand = 357B;
ELShowCharacters: ELCommand = 360B;
ELSkipCharacters: ELCommand = 361B;
ELSkipControlBytes: ELCommand = 362B;
ELShowCharacterImmediate: ELCommand = 363B;
ELSetSpaceX: ELCommand = 364B;
ELSetSpaceY: ELCommand = 365B;
ELResetSpace: ELCommand = 366B;
ELSpace: ELCommand = 367B;
ELSetBrightness: ELCommand = 370B;
ELSetHue: ELCommand = 371B;
ELSetSaturation: ELCommand = 372B;
ELShowObject: ELCommand = 373B;
ELShowDots: ELCommand = 374B;
ELShowDotsOpaque: ELCommand = 375B;
ELShowRectangle: ELCommand = 376B;
ELNop: ELCommand = 377B;

--Data list commands;
DLMoveTo: CARDINAL = 0;
DLDrawTo: CARDINAL = 1;
DLDrawCurve: CARDINAL = 2;

DLSetCoding: CARDINAL = 1;
--byte
DLSetWindow: CARDINAL = 1;
--word
DLSetMode: CARDINAL = 2;
--byte
DLSetSize: CARDINAL = 2;
--word
DLDotsFollow: CARDINAL = 3;
--word
DLGetDotsFromFile: CARDINAL = 4;
--word
DLGetDotsFromPressFile: CARDINAL = 5;
--word
DLSetSamplingProperties: CARDINAL = 6;
--word

DLSSPInputIntensity: CARDINAL = 0;
--word
DLSSPOutputIntensity: CARDINAL = 1;
--word
DLSSPScreen: CARDINAL = 2;
--word
DLSSPDot: CARDINAL = 3;
--word
END.

Doug Wyatt, September 29, 1980 1:27 PM
removed FontDef, EntityDef
no longer includes GraphicsDefs