-- File: ColorPress.mesa: this pack reads Press.bits and writes ColorPress.bits. ColorPress.bits must already exist. The output can be used to drive an n-Color laser printer
-- Last Edited: November 6, 1981 1:50 PM By: GWilliams
DIRECTORY
ImageDefs USING [StopMesa],
IODefs USING[--CR, NUL, SP, TAB, ReadChar, WriteChar, WriteString,-- WriteLine],
PressDefs USING [filePtr, Init, numPages, pageGarray],
ColorPressDefs USING [diskIn, diskOut, filePtrOut, InitPage],
SystemDefs USING [FreeHeapNode],
TridentDefs USING [PAGE, tfsdskPtr, TfsCloseDisk, VDA];
ColorPress: PROGRAM
IMPORTS AltoRam, ImageDefs, IODefs, PressDefs, SystemDefs, TridentDefs
EXPORTS PressDefs
=
BEGIN OPEN AltoRam, IODefs, PressDefs, SystemDefs, TridentDefs;
serverMode: PUBLIC BOOLEAN ← FALSE;
uCodeLoaded: PUBLIC BOOLEAN ← FALSE;
ColorEnum: TYPE = {magenta, yellow, cyan};
abortFile: PUBLIC ERROR=CODE;
CPress: PROC[] =
{
bitPageNumber: CARDINAL;
continue: BOOLEAN;
firstDaIn: PAGE;
firstVDAIn, firstVDAOut: VDA;
i: CARDINAL;

WriteLine["Color Press Bits creator, writes to file ColorPress.bits"];

--don’t read Com.cm
[diskIn, firstVDAIn, continue]←Init[];--load global settings from Press.state and open trident
IF ~continue THEN GOTO done;

[continue] ← InitOutFile[];--set up outgoing pageG array
IF ~continue THEN GOTO done;--don’t need to close the input disk as we’re exiting the program.
firstDaIn ← LOOPHOLE [firstVDA];--don’t need

FOR i IN [0..numPages)
DO
[totalScans, scanLenOut] ← InitPage[diskOut, i];--initializes outgoing pageG ’s, globals, and synchronizes reading
--use nColors PageG’s per real page
FOR scanLineNum IN [0..totalScans)--totalScans is union of all 3 colors
DO
FOR scanLenIx: CARDINAL IN [0..scanLenOut)
DO
magentaWord ← GetNextWord[scanLineNum, magenta];
yellowWord ← GetNextWord[scanLineNum, yellow];
cyanWord ← GetNextWord[scanLineNum, cyan];
mask ← 100000B;
FOR j: CARDINAL IN [0..15]
DO
PutBit[BITAND[magentaWord, mask]];
PutBit[BITAND[yellowWord, mask]];
PutBit[BITAND[cyanWord, mask]];
mask ← BITSHIFT[mask, -1];--shift right by 1
ENDLOOP;--for j: CARD..
ENDLOOP;--for scanLenIx..
ENDLOOP;--for scanLineNum
WriteScanLine[scanLineNum];--see if at band bound; re-init etc.
ENDLOOP;--for i IN ..
CloseOutFile[];--write out the first page (pageG’s etc.) and close the Disk.
--Clean up
FreeHeapNode[pageGarray];--this is the input file’s pageGarray
[]←TfsCloseDisk[diskIn, TRUE];--free ddMgr


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


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

END. -- CPress