-- File: ColorPressUtils.mesa
-- Last Edited: November 6, 1981 2:00 PM By: GWilliams
DIRECTORY
AltoRam USING[DoSilentBoot],
ImageDefs USING [StopMesa],
IODefs USING[--CR, NUL, SP, TAB, ReadChar, WriteChar, WriteString,-- WriteLine],
PressDefs USING [copies, filePtr, Init, LockNeededCode, numPages, pageGarray, PrintInit, PSlot, ReadCommandFile],
ColorPressDefs USING [ColorEnum],
PressNetDefs USING [GetBits],
SystemDefs USING [FreeHeapNode],
TridentDefs USING [PAGE, tfsdskPtr, TfsCloseDisk, VDA];
ColorPressUtils: PROGRAM
IMPORTS AltoRam, ImageDefs, IODefs, PressDefs, ColorPressDefs, SystemDefs, TridentDefs
EXPORTS ColorPressDefs
=
BEGIN OPEN AltoRam, IODefs, ColorPressDefs, PressDefs, SystemDefs, TridentDefs;
firstBand, LastBand: CARDINAL;
bitMargin: CARDINAL;--we’ll use the smallest
diskOut: tfsdskPtr ← NIL;--export this to ColorPressDefs
filePtrOut: filePtr = @fp;
fp: FP;
magentaFirstScan: CARDINAL;
yellowFirstScan: CARDINAL;
cyanFirstScan: CARDINAL;
outPageGArray: POINTER TO ARRAY OF PageG;
firstScanLine: ARRAY [magenta..cyan] OF CARDINAL;
lastScanLine: ARRAY[magenta..cyan] OF CARDINAL;
firstScanWord: ARRAY[magenta..cyan] OF CARDINAL;
lastScanWord: ARRAY[magenta..cyan] OF CARDINAL;
bitPage: ARRAY[magenta..cyan] OF CARDINAL;
thisColorUsed: ARRAY[magenta..cyan] OF BOOLEAN;--may not be bits there for this color
diskIn, diskOut: PUBLIC tfsdskPtr;
InitOutFile: PROC[]=--do general initialization
--this is called after we know there is an input file
{
outPageGArray ← AllocateHeapNode[PageGLength*numPages];
--now get the first trident buffer of image for each color, and init the output buffer
imageSegment[magenta] ← NewDataSegment[DefaultBase, 4];--get 1K
imageSegment[yellow] ← NewDataSegment[DefaultBase, 4];--get 1K
imageSegment[cyan] ← NewDataSegment[DefaultBase, 4];--get 1K
imageBuf[magenta] ← SegmentAddress[imageSegment[magenta]];
imageBuf[yellow] ← SegmentAddress[imageSegment[yellow]];
imageBuf[cyan] ← SegmentAddress[imageSegment[yellow]];
};--InitOutFile
InitPage: PROC[disk: tfsdskPtr, pageNum] RETURNS[totalScansOut, scanLenOut]=
{pNum: CARDINAL ← pageNum - 1;
mag: CARDINAL ← pageNum*nPrinterColors;
yel: CARDINAL ← mag + 1;
cya: CARDINAL ← yel + 1;
--in all of this it is important to remember that LastBand-FirstBand may be <0
firstBand ← MIN[pageGarray[mag].FirstBand, MIN[pageGarray[yel].FirstBand, pageGarray[cya].FirstBand]];
lastBand ← MAX[pageGarray[mag].LastBand, MAX[pageGarray[yel].LastBand, pageGarray[cya].LastBand]];
bitMargin ← MIN[pageGarray[mag].BitMargin, MIN[pageGarray[yel].BitMargin, pageGarray[cya].BitMargin]];
--bitMargin ← bitMargin/16;----this was a bit count
--calculate the intersection of the output scan with each of the colors
firstScanWord[magenta] ← (pageGarray[mag].BitMargin - bitMargin)/16;
firstScanWord[yellow] ← (pageGarray[yel].BitMargin - bitMargin)/16;
firstScanWord[cyan] ← (pageGarray[cya].BitMargin - bitMargin)/16;
--at this point, bitMargin is the MIN of the three bitMargins
lastScanWord[magenta] ← firstScanWord[magenta] + pageGarray[mag].BitWc;
lastScanWord[yellow] ← firstScanWord[yellow] + pageGarray[yel].BitWc;
lastScanWord[cyan] ← firstScanWord[cyan] + pageGarray[cya].BitWc;
scanLenOut ← MAX[lastScanWord[magenta], MAX [lastScanWord[yellow], lastScanWord[cyan]]];
totalScansOut ← (lastBand - firstBand + 1) * bandWidth;
--get the first load of each color
ReadPage[pageGArray[pNum*nPrinterColors].BitPage, imageBuf[magenta]];
ReadPage[pageGArray[pNum*nPrinterColors +1].BitPage, imageBuf[yellow]];
ReadPage[pageGArray[pNum*nPrinterColors + 2].BitPage, imageBuf[cyan]];
};--Procedure InitPage
GetNextWord: PUBLIC PROC[scanWordNo, scanLineNo: CARDINAL, color: ColorEnum] RETURNS [wrd: CARDINAL]=
{IF ~(scanLineNo IN [firstScanLine[color]..lastScanLine[color]]) THEN RETURN [0];
IF ~(scanWordNo IN [firstScanWord[color]..lastScanWord[color]) THEN RETURN[0];
};--GetNextWord
CloseOutFile: PUBLIC PROC[]=
{firstPageBuffer: POINTER;
firstPageSeg: DataSegmentHandle;
--write out the pageGArray, free its storage, then
firstPageSeg ← NewDataSegment[DefaultBase, 4];--get 1K
firstPageBuffer ← SegmentAddress[firstPageSeg];
firstPageBuffer[0] ← numPages;
firstPageBuffer[1] ← PageGLength;
firstPageBuffer[2] ← printerMode;
firstPageBuffer[3] ← PressPassword;
COPY[outPageGArray, PageGLength*numPages, @firstPageBuffer[4]];
WritePage[1, firstPageBuffer];--write to trident: ColorPress.bits
DeleteDataSegment[firstPageSeg];
[]←TfsCloseDisk[diskOut, TRUE];--free ddMgr
FreeHeapNode[outPageGArray];
};--CloseOutFile
END. -- ColorPressUtils