<> <> <> <<>> 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: BOOL _ FALSE; strip: BOOL _ FALSE; 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 POINTER _ LOOPHOLE[010000h]; buf1: LONG POINTER _ LOOPHOLE[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: CARDINAL _ MIN[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]; <> 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]; <> 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; <> }; currentHerald.password _ 0; [] _ GPIB.InitializeController[]; GPIB.InterfaceClear[]; GPIB.DevicesClear[]; END.