PDInterpOutputPanasonicImpl.mesa
Copyright © 1984, 1985, 1986, Xerox Corporation. All rights reserved.
Tim Diebert: April 25, 1986 1:42:57 pm PST
DIRECTORY
Basics, Convert, GPIB, PDFileFormat, PDInterpBasic, PDInterpOutput, PDInterpBitmap, PDInterpSysCalls, PDQueue, Process, RefText, Rope, XBus;
PDInterpOutputPanasonicImpl: PROGRAM
IMPORTS Basics, GPIB, Convert, PDInterpBitmap, PDInterpSysCalls, Process, RefText, XBus
EXPORTS PDInterpOutput = BEGIN
bitsPerWord: NAT = Basics.bitsPerWord;
currentHerald: PDFileFormat.Herald;
currentStartImage: PDFileFormat.StartImage;
currentBandNumber: NAT ← 0;
bandWords: INT ← 0;
band: PDInterpBitmap.BitmapDesc ← [sOrigin: 0, fOrigin: 0, sMin: 0, fMin: 0, sSize: 0, fSize: 0, pointer: NIL, rast: 0, lines: 0];
bandWordsAllocated: CARDINAL ← 0;
feed: BOOLFALSE;
strip: BOOLFALSE;
deviceAddr: GPIB.DeviceAddr ← 16;
bandsSent: CARDINAL ← 0;
bandsToSend: CARDINAL ← 0;
zeros: PDInterpBitmap.BitmapDesc ← [sOrigin: 0, fOrigin: 0, sMin: 0, fMin: 0, sSize: 0, fSize: 0, pointer: NIL, rast: 0, lines: 0];
zerosWordsAllocated: CARDINAL ← 0;
CurrentBandDesc: PROC RETURNS [PDInterpBitmap.BitmapDesc] = {
band.sOrigin ← currentHerald.bandSSize*(currentBandNumber+currentStartImage.passBands);
PDInterpBitmap.Clear[band];
RETURN [band]
};
mBusCtl: POINTER = LOOPHOLE[2];
lBusOutData: POINTER = LOOPHOLE[2];
lBusInData: POINTER = LOOPHOLE[2];
mBusAddr: POINTER = LOOPHOLE[3];
lBusAddr: POINTER = LOOPHOLE[3];
MemWrite: PROCEDURE[add: LONG POINTER, data: WORD] = INLINE
BEGIN
XBus.WriteM[mBusAddr, Basics.HighHalf[LOOPHOLE[add]]];
XBus.WriteL[lBusAddr, Basics.LowHalf[LOOPHOLE[add]]];
XBus.WriteM[mBusCtl, 8902H];
XBus.WriteL[lBusOutData, data];
END;
MoveToMB: PROC[from: LONG POINTER, to: LONG POINTER, wordCount: CARDINAL] = TRUSTED BEGIN
cnt: CARDINAL ← wordCount/8;
FOR i: CARDINAL IN [0 .. cnt) DO
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
MemWrite[to, from^];
to ← to + 2; -- bytes
from ← from + SIZE [WORD];
ENDLOOP;
END;
mbZeros: LONG POINTERLOOPHOLE[010000h];
buf1: LONG POINTERLOOPHOLE[020000h];
quadWordCnt: CARDINAL ← 0;
words: CARDINAL ← 0;
StartImage: PUBLIC PROC [herald: PDFileFormat.Herald, startImage: PDFileFormat.StartImage, request: PDQueue.Request]
RETURNS [PDInterpBitmap.BitmapDesc] = {
rast: NAT = (herald.imageFSize+bitsPerWord-1)/bitsPerWord;
bytes: CARDINAL ← rast * 2;
command: REF TEXT ← RefText.ObtainScratch[200];
linesToSend: CARDINALMIN[herald.imageSSize, 5500];
words ← rast * herald.bandSSize; -- In the band.
bandsToSend ← MIN[herald.imageSSize/herald.bandSSize, 110];
command.length ← 0;
quadWordCnt ← words/4;
currentHerald ← herald;
currentStartImage ← startImage;
currentBandNumber ← 0;
feed ← startImage.feed;
strip ← startImage.strip;
IF words > bandWordsAllocated OR bandWordsAllocated = 0 THEN {
IF band.pointer # NIL THEN PDInterpSysCalls.FreeSpace[band.pointer];
band.pointer ← PDInterpSysCalls.AllocateSpace[words];
bandWordsAllocated ← words;
};
IF words > zerosWordsAllocated OR zerosWordsAllocated = 0 THEN {
IF zeros.pointer # NIL THEN PDInterpSysCalls.FreeSpace[zeros.pointer];
zeros.pointer ← PDInterpSysCalls.AllocateSpace[words];
zerosWordsAllocated ← words;
};
zeros.sOrigin ← 0;
zeros.fOrigin ← 0;
zeros.sMin ← 0; zeros.fMin ← 0; zeros.sSize ← herald.bandSSize;
zeros.fSize ← rast*bitsPerWord; zeros.rast ← rast; zeros.lines ← herald.bandSSize;
PDInterpBitmap.Clear[zeros];
IF feed THEN BEGIN
numbers: REF TEXT ← RefText.ObtainScratch[120];
commandR: Rope.ROPE;
GPIB.DevicesClear[];
numbers ← RefText.AppendTextRope[to: numbers, from: Convert.RopeFromCard[bytes]];
numbers ← RefText.AppendChar[to: numbers, from: ',];
numbers ← RefText.AppendTextRope[to: numbers, from: Convert.RopeFromCard[linesToSend]];
numbers ← RefText.Append[to: numbers, from: ",0,0\n\l"];
GPIB.SelectedDeviceClear[deviceAddr];
IF herald.deviceCode = color400
THEN BEGIN
command ← RefText.Append[to: command, from: "AY"]; -- Yellow
command ← RefText.Append[to: command, from: numbers];
commandR ← RefText.TrustTextAsRope[command];
GPIB.WriteDevice[deviceAddr, commandR];
command.length ← 0;
command ← RefText.Append[to: command, from: "AM"]; -- Magenta
command ← RefText.Append[to: command, from: numbers];
commandR ← RefText.TrustTextAsRope[command];
GPIB.WriteDevice[deviceAddr, commandR];
command.length ← 0;
command ← RefText.Append[to: command, from: "AC"]; -- Cyan
command ← RefText.Append[to: command, from: numbers];
commandR ← RefText.TrustTextAsRope[command];
GPIB.WriteDevice[deviceAddr, commandR];
END
ELSE BEGIN
GPIB.WriteDevice[deviceAddr, "EY\n\l"]; -- Skip Y
GPIB.WriteDevice[deviceAddr, "EM\n\l"]; -- Skip C
GPIB.WriteDevice[deviceAddr, "EC\n\l"]; -- Skip M
END;
command.length ← 0;
command ← RefText.Append[to: command, from: "AK"]; -- Black
command ← RefText.Append[to: command, from: numbers];
commandR ← RefText.TrustTextAsRope[command];
GPIB.WriteDevice[deviceAddr, commandR];
command.length ← 0;
GPIB.WriteDevice[deviceAddr, "PL\n\l"]; -- A3 Paper
GPIB.WriteDevice[deviceAddr, "C\n\l"]; -- Cut it
GPIB.WriteDevice[deviceAddr, "O900\n\l"]; -- 900 second timeout
GPIB.WriteDeviceInitial[deviceAddr, "T\n\l"]; -- Start
RefText.ReleaseScratch[numbers];
END;
MoveToMB[from: zeros.pointer, to: mbZeros, wordCount: words];
FOR i: CARDINAL IN [0 .. startImage.passBands-1) DO
GPIB.WriteDMABlock[deviceAddr, mbZeros, words*2, FALSE];
DO
IF GPIB.CheckDMADone[] THEN EXIT;
ENDLOOP;
Process.Yield[];
ENDLOOP;
IF startImage.passBands >= 1 THEN
GPIB.WriteDMABlock[deviceAddr, mbZeros, words*2, FALSE];
bandsSent ← startImage.passBands;
band.sOrigin ← 0;
band.fOrigin ← startImage.fMinPage;
band.sMin ← 0;
band.fMin ← 0;
band.sSize ← herald.bandSSize;
band.fSize ← rast*bitsPerWord;
band.rast ← rast;
band.lines ← herald.bandSSize;
bandWords ← words;
RefText.ReleaseScratch[command];
RETURN [CurrentBandDesc[]]
};
EndBand: PUBLIC PROC RETURNS [PDInterpBitmap.BitmapDesc] = {
DO
IF GPIB.CheckDMADone[] THEN EXIT;
Process.Yield[];
ENDLOOP;
MoveToMB[from: band.pointer, to: buf1, wordCount: words];
GPIB.WriteDMABlock[deviceAddr, buf1, words*2, FALSE];
GPIB.WriteDeviceBlock[deviceAddr, band.pointer, quadWordCnt, FALSE];
Process.Yield[];
bandsSent ← bandsSent + 1;
currentBandNumber ← currentBandNumber + 1;
RETURN [CurrentBandDesc[]]
};
EndImage: PUBLIC PROC [request: PDQueue.Request] = {
DO
IF GPIB.CheckDMADone[] THEN EXIT;
Process.Yield[];
ENDLOOP;
FOR i: CARDINAL IN [bandsSent .. bandsToSend) DO
GPIB.WriteDMABlock[deviceAddr, mbZeros, words*2, FALSE];
GPIB.WriteDeviceBlock[deviceAddr, zeros.pointer, quadWordCnt, FALSE];
DO
IF GPIB.CheckDMADone[] THEN EXIT;
Process.Yield[];
ENDLOOP;
ENDLOOP;
IF strip THEN Process.Pause[Process.SecondsToTicks[15]];
};
ReprintLastPage: PUBLIC PROC [copies: CARDINAL] = {
IF currentHerald.password # PDFileFormat.passwordValue THEN RETURN;
currentHerald.copies ← copies;
PrintPage[];
};
currentHerald.password ← 0;
[] ← GPIB.InitializeController[];
GPIB.InterfaceClear[];
GPIB.DevicesClear[];
END.