// P R I N T // 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 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 printerForward 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 ] // 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? // sFix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // sFix ~~ At present, Sequoia "not ready" bit never presents itself // sFix ~~ Some print sequences require an engine runout, followed // sFix ~~ by a restart -- this delay waits for shutdown before continuing readyTimeOut // sFix ~~ set 0 at start, non-zero for outer loop continuation sReadyTimeOut=2*27+20 // sFix ~~ can tune this from Swat until it's right // sFix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 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 ] // ----------------------------------------------------------- // Print 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 = 0, 0, 0, 0, 0 // ******** let CommTab=vec 10 CommTab=(CommTab+1)&(-2) // If monitoring performance, these are real InitializeHardware(false) InitMeasure(measureTable, 2000, (lv malfunction)-1) consecutiveErrors=0 let knockKnock = false // time to let somebody in if true let stopPrint, okPrint = #60000, #60001 // 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; 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= buf1 // first real data imaged from buf1 // Now read in the bands for this page ReadBands(page, curbuf, nfRecs*2) // Initialize the Orbit, 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 // sFix ~~~~~ possibly wait for shutdown ~~~~~~~~~~~~~~~~~~ [ // sFix ~~~~~ while (@RTC-tim) < readyTimeOut loop readyTimeOut = sReadyTimeOut // sFix ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ np = ROSCheck(lvFailureCode, nPagesAlreadyPrinted, false) if np eq -1 break // ready if @lvFailureCode > maxNotReady % (@RTC-tim) > timeOut resultis np ] repeat ] // sFix ~~~~~ // 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) DoFunc(fROSCommand, adBufferReset) FeedASheet() AwaitPageSync(0) //Wait for sendVideo to go off. // Print (cont.) Fast Loop [RunningLoop // Calculate a ROS command table for the device: CommTab!0=signalBand CommTab!1=stopPrint //Stop unless proven otherwise (below) CommTab!2=-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 // Proceed code: // 0: Charge on ahead, full speed // 1: Pause because cannot fit bands or font for next page, // or because printing is done. // Assume the page we are printing will be OK: 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 //Unless this page gets messed up we will continue printing. [ if (nextPage>>PageG.fontLoad eq page>>PageG.fontLoad) & (nextPage>>PageG.nRecords le nfRecs) then [ proceedCode = 0 // Read in the bands for the next page: CommTab!1=okPrint // don't stop ReadBands(nextPage, nextbuf, nfRecs) ] ] // 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 = 10*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. // Fatal error detected by microcode -- invalid Band entry -- possibly broken processor if stat<