-- File: Press.mesa: Mesa version of Press
-- Last Edited: November 4, 1981 4:13 PM By: GWilliams
--added WriteLine of "BitFlinger"
DIRECTORY
AltoRam USING[LoadRamAndBoot],
ImageDefs USING [StopMesa],
IODefs USING[--CR, NUL, SP, TAB, ReadChar, WriteChar, WriteString,-- WriteLine],
PressDefs USING [copies, filePtr, Init, LockNeededCode, numPages, pageGarray, PrintInit, PSlot, ReadCommandFile],
PressNetDefs USING [GetBits],
SystemDefs USING [FreeHeapNode],
TridentDefs USING [PAGE, tfsdskPtr, TfsCloseDisk, VDA];
Press: PROGRAM
IMPORTS AltoRam, ImageDefs, IODefs, PressDefs, PressNetDefs, SystemDefs, TridentDefs
EXPORTS PressDefs
=
BEGIN OPEN AltoRam, IODefs, PressDefs, PressNetDefs, SystemDefs, TridentDefs;
serverMode: PUBLIC BOOLEAN ← FALSE;
uCodeLoaded: PUBLIC BOOLEAN ← FALSE;

abortFile
: PUBLIC ERROR=CODE;
MPress: PROC[] =
{
bitPageNumber: CARDINAL;
continue: BOOLEAN;
disk: tfsdskPtr;
firstDa: PAGE;
firstVDA: VDA;
i: CARDINAL;
j: INTEGER;
slotAndTridentBlv: WORD = 77764B;--let SLOT and Trident tasks run

WriteLine["Bit Flinger"];
DO
copies ← 1;
IF ~ReadCommandFile[] THEN GOTO done;--ReadCommandFile exits if serverMode=TRUE
IF serverMode THEN
{IF ~GetBits[] THEN GOTO done;--get a press.bits over the net & put on Trident
LoadRamAndBoot["MesaSlotMc.br", TRUE]};--reboot machine to stop ethernet drivers.

[disk, firstVDA, continue]←Init[];--load global settings from Press.state and open trident
IF ~continue THEN GOTO done;

bitPageNumber ← pageGarray[0].BitPage;--for debugging
firstDa ← LOOPHOLE [firstVDA];
WriteLine["Printing"];

LockNeededCode[];--Lock in code we’re going to need forever
FOR j IN[1..copies]
DO
PrintInit[! abortFile => GOTO done];--inits the printing engine
FOR i IN [0..numPages)
DO
PSlot[disk, @pageGarray[i], (IF ((i=numPages-1) AND (j=copies)) THEN TRUE ELSE FALSE), --i.e., laspage&lastcopy--
firstDa, filePtr! abortFile => GOTO done--bail out for now--];
ENDLOOP;
ENDLOOP;
--Clean up
FreeHeapNode[pageGarray];
[]←TfsCloseDisk[disk, TRUE];--free ddMgr

IF ~serverMode THEN EXIT;
ENDLOOP;

EXITS
done => NULL;
};--Procedure Press


--
Mainline code
MPress[];
ImageDefs.StopMesa[];--put into main program later.

END. -- Press
-- Last Edited: October 26, 1981 3:39 PM By: GWilliams
--changed to become a "server"
-- Last Edited: October 27, 1981 1:38 PM By: GWilliams
--added copies loop
-- Last Edited: October 28, 1981 11:02 AM By: GWilliams
--added term to evaluation of LastPage (an arg of PSlot)