// P R I N T - DOVER // errors 1000 // get "Spruce.d" get "SpruceFiles.d" get "Orbit.d" // outgoing procedures external [ DrivePrinter ] // incoming procedures external [ SpruceError Max Min InitRam //SprucePrint AddToBin Announce AwaitPageSync IncBinSerial PrintNext ReadBands ReadClock ReadFont //CURSOR CursorChar CursorDigit // SprucePrintRes DoFunc ROSStatus // Timer (debug only) SetTimer TimerHasExpired //OS Zero DisableInterrupts EnableInterrupts ] // incoming statics external [ scanTicks // # of 38 usec. ticks in 4 printer scan lines. logBandRecordSize bandRecordSize nPagesPrinted Debug DebugSystem signalBand Func debugTrail knockResult numPrinted numMustPrint InitMeasure // Dover engine control monitoring stuff CloseMeasure TickMeasure Measure measureTable xmFonts // Font data will be read into Bank 1 via Bank 0, if set nRecs LowAdr FAvalue nBands stopsPrinting BinSerials ] // internal statics static [ timeOut=15*27 printHysteresis = 15 // print this many before allowing suspension, each time in // ~~ above number may want to increase for large runs, or something? simLateDisk // cStat ~~ Collect statistics on the appearance of Count-H (Dover only) // cStat ~~ Record minimum and maximum value of (nBands-current band) in // cStat ~~ count-H signal LAST appears during imaging of a page. // cStat ~~ Re-Initialize Sprint, or reset by hand, to reinitialize values cbMin = 32767 // cStat ~~ min value of (nBands-currentBand) cbMax = 0 // cStat ~~ max value -- nominal value is value of signalBand // delay ~~~~ debugging: delay per page to simulate printing debDelay = 0 // delay no delay std. // delay ~~~~ ] // File-wide structure and manifest declarations. manifest [ RTC=#430 debugTrailSize = 10*3 // Failure Code ranges -- see ROSCheck maxNotReady = 9 // not ready, but probably will be soon maxManual = 19 // Manual intervention required maxJam = 99 // Error during operation minDocumentError = 300 // Document inherently hard to print ] // ROSCheck values structure CT: [ invert bit 1 // bit is on when things are good malFnReq bit 1 // Dover malfunction bit must also be on or no error failureCode bit 6 wordIndex bit 4 bitIndex bit 4 ] manifest // factors for creating table entries [ Invert = #100000 MalFnReq = #40000 Code = 256 Word = 16 Bit = 1 ] // ----------------------------------------------------------- // DoverPrint Initialization // ----------------------------------------------------------- // Returns -1 if printing is successfully completed, else // nPagesPrinted, so can pick up where we left off. let DrivePrinter(pDoc, nPagesAlreadyPrinted, lvFailureCode) = valof [ // ******** See SpruceMeasure -- don't move declarations of next five local variables ******** let malfunction, proceedCode, nonF, coldStart, consecutiveErrors = nil, nil, nil, nil, nil // ******** let CommTab=vec 10 CommTab=(CommTab+1)&(-2) // If monitoring dover performance, these are real InitializeHardware(false) InitMeasure(measureTable, 2000, (lv malfunction)-1) coldStart=true consecutiveErrors=0 let knockKnock = false // time to let somebody in if true // Print (cont.) Slow Loop // Loop out to here when a new font set is required, or when // needing to completely restart the printer. [Slow // Find out which page to print next: let copy = nil let page=PrintNext(pDoc, lv copy, nPagesPrinted) if page eq 0 then [ knockKnock = false; IncBinSerial(BinSerials+0); break ] if knockKnock then break // go let somebody in // Read in font and relocate the pointers to characters: let font=page>>PageG.fontLoad*(size FontG/16)+pDoc>>DocG.Fonts // Next call returns location of ICC table, let FontTable = ReadFont(font, LowAdr, nRecs) unless xmFonts do for i=0 to pDoc>>DocG.ICCtotal-1 do // if rasters are in bank 1, they start at 0 FontTable!i=FontTable!i + LowAdr FontTable=FontTable-100000b // Figure out where buffers are. let nRecords= xmFonts? (pDoc>>DocG.ICCtotal+bandRecordSize-1) rshift logBandRecordSize, font>>FontG.nRecords let nfRecs=(nRecs-nRecords)/2 // max allowable band list size for normal alternation let LeftOver = LowAdr+(nRecords lshift logBandRecordSize) let LeftOverGuard = LeftOver+(loSize&(-4))-4 let buf1 = (LeftOver+loSize+8)&(-2) // ~~ all the 4's, 8's and 10's in here are cowardly slack let buf2=buf1+nfRecs lshift logBandRecordSize let curbuf=coldStart? buf2, buf1 // first real data imaged from buf1 // Now read in the bands for this page test coldStart then Zero(curbuf, nBands*2) or ReadBands(page, curbuf, nfRecs*2) // Initialize the Orbit, Dover, etc. InitializeHardware(false) let np = nil let tim = @RTC // Check for problems, wait for ready indication // wait for ready or some serious condition or for long enough unless Debug do [ np = ROSCheck(lvFailureCode, nPagesAlreadyPrinted, false) if np eq -1 break // ready if @lvFailureCode > maxNotReady % (@RTC-tim) > timeOut resultis np ] repeat // Try to empty Orbit buffers to clear them. This is to minimize // toner dumping on first (blank) page. compileif loSize ls 256 then [ foo=nil ] for i=0 to 31 do DoFunc(fReadBlock, 256, LeftOver) // Now feed first sheet: DoFunc(fControl, 21b) // Turn off adCommandBeamOn, if on, revert to normal modulation // ~~ causes glitch AdCommand(AdapterScales) DoFunc(fROSCommand, adBufferReset) // If Dover is already running, this StartPrint may not do the right // thing, because it may be sent during the "dead" time near // CS-5. FeedASheet() AwaitPageSync(0) //Wait for sendVideo to go off. // Print (cont.) Fast Loop [RunningLoop // Calculate a ROS command table: CommTab!0=signalBand+2 CommTab!1=adExternalCommand1 //No feed yet CommTab!2=signalBand+1 CommTab!3=adExternalCommand1 CommTab!4=10000b+signalBand // last entry nearing obsolescence 3-26-78 DCS CommTab!5=32 *256 //Status bits 0-3 of word 8 CommTab!6=-1 // Start Orbit working on the present page. DoFunc(fControl, #21) //Reset, clear behind DoFunc(fROSCommand, adBufferReset) LeftOver!0=0 //Initialize LeftOver table LeftOverGuard!1=-1 tim=@RTC // Start the microcode!!!! DoFunc(fSlot, CommTab, 20000, nBands-1, FAvalue, LeftOver, FontTable, curbuf-1, nil, nil, (copy lshift 5)+4) if Debug then // ~~delay [ // ~~delay while (@RTC-tim) < debDelay loop // ~~delay tim = @RTC // ~~delay don't invoke timeout code below ] // ~~delay // Prepare next page in parallel with imaging // Proceed code: // 0: Charge on ahead, full speed // 1: Pause because cannot fit bands or font for next page, // or because printing is done. // 2: Reprint this page, due to misfeed (Dover only). // 4: No sheet in pipe (Dover only) // Assume the page we are printing will be OK: unless coldStart then [ nPagesPrinted=nPagesPrinted+1 CursorDigit(nPagesPrinted) ] // See who's (maybe) knocking at my door // This logic is copied from SpruceUtilsRes: if we are not planning to defer to spooler, // don't trouble to shut down here, just to find that out there. Would be too expensive if (DebugSystem) eq 0 & numPrinted ge numMustPrint & knockResult & (nPagesPrinted-nPagesAlreadyPrinted) > printHysteresis then knockKnock = true // Find next page to work on: proceedCode=1 let nextbuf=curbuf xor buf1 xor buf2 let nextPage=PrintNext(pDoc,lv copy, nPagesPrinted) if (not knockKnock) & nextPage then [ if (nextPage>>PageG.fontLoad eq page>>PageG.fontLoad) & (nextPage>>PageG.nRecords le nfRecs) then [ proceedCode = 0 // Read in the bands for the next page: ReadBands(nextPage, nextbuf, coldStart? nfRecs*2, nfRecs) if simLateDisk then [ simLateDisk=simLateDisk xor 1 if (simLateDisk&1) eq 0 then Func!3=-1 ] DisableInterrupts() test Func!3 gr signalBand+3 then CommTab!1=adExternalCommand1+1 or proceedCode=4 EnableInterrupts() ] ] // Print (cont.) Wait for completion, analyze results // Now see if we actually printed this page properly. First, // wait for Orbit to announce it is finished. let imageTimeout = 4*27 while @#720 ne 0 do if (@RTC-tim) gr imageTimeout then [ Blast() // clear hardware, #720 // Machine dead or Orbit got behind and it wasn't detected // Will generally be overriden by more specific analysis @lvFailureCode = 19 // Manual intervention required break ] // Check Orbit status nonF = 0 let stat=Func!9 //Orbit printing status. let countBand = Func!8 // Band in which count-H last occurred (Dover only) // ~~ cStat cbMin = Min(cbMin, countBand) //~~ cStat if countBand