LIST,0   1
         PCC      0
PRT:     SET      1
         SYSTEM   ADM:A00
         TITLE    'RAVEN CONTROL PROGRAM - REVISION LEVEL 3L '
         SPACE 15
***********************************************************
***********************************************************
***********************************************************
*  FILE NAME:  S:3L:B2
*
*   DESCRIPTION: RAVEN SOURCE CODE FOR B2 MACHINE
*
*  DATE OF LAST CHANGE:  6/24/82
*
*  CHANGE ORIGNATOR:  DAVID MATEEN
*
***********************************************************
***********************************************************
*
*   THE FOLLOWING ITEMS REPRESENT POST 'B1' CHANGES.
*
* PAPER BUCKLE TIME INCREASED FROM 60 MS. TO 70 MS
* PAPER FEED DELAY FOR THE FIRST COPY (10/14/81)
* LOGIC LOCKUP DUE TO STATE POINTER PROBLEM RESOLVED
* ON-LINE MODE IS MAINTAINED IF OFF-LINE KEY IS PUSHED DURING ON-LINE JO
B
*   ( NO TEST BARS PATTERN )
* E4 JAM TIMER IS FROM INVERTER ON EVENT    (11/16/81)
* E4 JAM BECOMES HARD JAM (SOFT JAM FOR B1)
* MAIN DRIVE, HV.& FUSER  TURN ON CHANGED FROM
*        160 MS. TO 220 MS.
*        400 MS. TO 460 MS.
*        760 MS. TO 820 MS.
*   (REDUCES OCCURENCE  OF STREAKING OF COPIES)
* SHUTTER SOLENOID 50% DUTY CYCLE ,1.1 SEC. PULL IN TIME
*    (PREVENTS SOLENOID OVERHEATING)
* THE FAN TIMER IS ALLOWED TO RUN IN MACHINE JAM MODES
*   (EXCEPT WHEN DOOR IS OPEN)
* THE USART IS RE-INITIALIZED IF RXRDY, PE, OE, OR FE DOES NOT OCCUR
*    (PREVENTS USART LOCKUP DUE TO ELECTROSTATIC DISCHARGE)
* NEW EXPANDED DIAGNOSTICS INCLUDE  THE FOLLOWING:
*     COMPONENT CONTROL
*     LIMITED TIMING CHECKS
*     REVISED FUSER SET UP
* OFFSET PRINT COMMANDS ACCEPTANCE
* ON-LINE STATUS CHANGED TO ASCII '<' FROM ASCII 'W'  (11/9/81)
* STACKER CONTROL CODE INCLUDING OFFSET HAS BEEN INCORPORATED
* ROM CHECKSUM & RAM CHECK INCORPORATED
* NEW FUSER ALGORITHM IMPLEMENTED
* ON TIME REDUCTION CODE ADDED ( GO TO SLEEP AFTER 1.5 HR )
* A 'J' IS DISPLAYED NOT AN 'A'
* LOW TONER CODE HAS BEEN ADDED
* TRAY FULL  CODE HAS BEEN ADDED
* KEYBOARD BEEPER CODE HAS BEEN IMPLEMENTED
* DISPLAY IS BLANKED WHEN OFF-LINE KEY IS PUSHED.
* 3 MINUTES MINIMUM ZAP FEATURE HAS BEEN INCLUDED
* THRU'PUT WINDOW HAS BEEN EXPANDED TO 3.7 SEC. FOR
* DELAYED PRINT COMMANDS (11/9/81)
* KEYBOARD IS ENABLED DURING C4 JAM   (11/16/81)
* OFF-LINE STATUS 'V' & KEYSTROKE '=' IS SENT WHEN OFF-LINE KEY IS PUSHE
D
*              (11/16/81)
* STANDBY STATUS 'A' & KEYSTROKE '<' IS SENT WHEN ON-LINE KEY IS PUSHED
*              (11/16/81)
* BEEPER HAS BEEN MOVED TO BIT 5 ON OUTPUT PORT#1   (11/19/81)
* STACKER EVENTS ARE REFERENCED FROM PAGE SYNC  (11/23/81)
* SERVER DEFINED DISPLAY CODE 'F' HAS BEEN ADDED (11/24/81)
* ABOUT TO GO TO SLEEP STATUS CODE HAS BEEN IMPLEMENTED (11/25/81)
* 'L1' HAS BECOME A NON BLINKING DISPLAY CODE (11/24/81)
* 'C3' & 'E5' IS NOW A BLINKING DISPLAY CODE (11/25/81)
* LOW TONER STATUS CODE ASCII 'Y' IS SENT TO SERVER AT THE END
* OF THE PRINT CYCLE (11/24/81)
* SERVER CAN OVER WRITE L1,J1,F5 DISPLAY CODES &
* CANNOT OVER WRITE E2,E3,E4,C3,C4,E5 DISPLAY CODES (11/24/81)
* TRAY FULL CHECK IS DURING TRAIL EDGE @ EXIT JAM INTERROGATION
*             (11/24/81)
* DISPLAY LEADING ZEROES ARE NOT SUPPRESED OR ADDED (12/10/81)
* BLADE OFF IS DURING FAN OFF EVENT  (12/8/81)
* ADDITIONAL TIME IS ADDED TO BLADE & FAN OFF EVENTS
* DURING CYCLE OUT (12/10/81)
* 'E4' JAM CHECK IS 650 MS. FROM INVERTER  ON  (12/10/81)
* 'E3' JAM CHECK IS 4540 MS. FROM REG ROLLS ON (12/10/81)
* STACKER IS NOT POSITIONED TO JAM ACCESS POSITION
* DURING CYCLE OUT  (12/10/81)
* 'C4' JAM CHECK IS 870 MS. FROM PAPER FEED EVENT  (12/15/81)
* SUBSTITUTED GO TO SLEEP FUNCTION FOR CHECKSUM IN
* DIAGNOSTICS 3-61.   (12/17/81)
* DIAGNOSTICS 8-3 ENERGIZES LOWER TRAY FEEDER  (12/17/81)
* DIAGNOSTICS 8-55 DISPLAYS REAL TIME FOR LOWER TRAY FEED TO
* REGISTRATION SWITCH ACTUATION  (12/17/81).
* DIAGNOSTICS 10-2 ENERGIZES STACKER INVERTER (1/5/82)
* DIAGNOSTICS 10-3 ENERGIZES STACKER OFFSET CLUTCH (1/5/82)
* EXIT SW. COMPONENT CONTROL CODE IS NOW 10-6 INSTEAD OF 8-6 (1/5/82).
* DIAGNOSTICS 6-1 IS FOR SHUTTER ACTUATION (1/5/82)
* SERVER DISPLAYED NUMBER IS NOT BLANKED DURING RUN (1/12/82)
*
*                   3L UPDATES
*                   **********
*
* CORRECTED OFFSET PROBLEM DURING C4 JAM OR CYCLING OFF-LINE. (4/8/82)
* RUN:READY TO FEED STATUS IS NOT SENT DURING CYCLING OFF LINE  (4/8/82)
* CORRECTED 50% DUTY CYCLE PROBLEM DURING DIAGNOSTICS 6-1  (4/8/82)
* SERVER CANNOT DISPLAY DURING E2,E3,E4,E5 & C4    (4/8/82)
* SERVER CAN DISPLAY IF TRAY IS TOGGLED DURING C4   (4/8/82)
* KEY DISPLAY INFORMATION IS NOT STORED WHEN ON-LINE    (4/8/82)
* SEQUNCING  DIAGNOSTICS HAS BEEN REMOVED    (4/8/82)
* TRAY STATUS Q IS SENT TO SERVER & C3 IS DISPLAYED IF TRAY
* IS OPENED PRIOR TO C4 JAM.  (4/30/82)
* REDUNDANT CLEAR PRNT:FLG IN DVL@OFF ROUT. REMOVED  (5/4/82)
* REDUNDANT CLEAR CMD:FLG IN BLD@OFF REMOVED   (5/4/82)
* REDUNDANT INITIALIZATION FOR PAP:PNT & PAP:CNT IN COP:FEED
* HAS BEEN REMOVED.      (5/4/82)
* DURING CYCLING OFF-LINE STATE ONLY ONE ASCII 'U' IS SENT
* INSTEAD OF TWO.      (5/7/82)
* BLADE & FAN IS PRESERVED IF TRANSITION IS FROM OFF-LINE
* TO ON-LINE.      (5/7/82)
* CORRECTED WRONG OR NO FEED WHEN ASCII 'P' & 'N'
* IS SENT SIMULTANEOUSLY BY SERVER DURING COPY RUN. (5/7/82)
* STACK OVERFLOW PROTECTION CODE, ADDED.      (5/11/82/)
* REMOVED CHK:INT ROUTINE, DUE TO LOCKUPS.    (5/11/82)
* ADDED AN EXTRA FUSER OFF, TO INSURE THAT IT GETS
* EXECUTED AGAIN DURING CYCLE OUT IF MISSED THE FIRST TIME
* ARROUND.      (5/13/82)
* FUSER REGULATION DURING ZAP INSTEAD OF FULL ON.     (5/14/82)
* FUSER UNDER-TEMP DURING RUN, INITIATES ZAP CYCLE PRECEEDED
* BY CYCLE OUT. STANDBY STATUS 'A' IS NOT SENT PRIOR TO '@'.  (5/21/82)
* 3 MINUTES WAIT CYCLE SHALL INHIBIT KEYBOARD FUNCTION.    (5/21/82)
* REVISION LEVEL 3L IS DISPLAYED INSTEAD OF 2L.   (5/24/82)
* GO TO SLEEP COMMAND ASCII 'Z' IS SERVICED ONLY DURING READY,
* OR ELSE IT WILL BE REJECTED WITH AN 'O'; ILLEGAL SEQ.   (5/26/82)
* IOT RESPONSE TO SERVER PRINT COMMAND, SHALL BE ASCII 'Q'
* FOLLOWED BY ASCII 'O'. HOWEVER FOR ALL SUBSEQUENT PRINT COMMANDS
* THE RESPONSE WILL BE ASCII 'O'. (5/26/82)
* IOT RESPONSE TO SERVER COMMANDS DURING CYCLING OFFLINE STATE
* IS AS FOLLOWS:       (5/26/82)
*
*   A) 'O'; ILLEGAL SEQUENCE FOR PRINT COMMANDS.
*   B) 'N'; COMMAND UNRECOGNIZED FOR ILLEGAL COMMANDS
*   C) 'U'; CYCLING OFF LINE FOR READ OR DISPLAY STATUS COMMAND
*   D) 'O'; ILLEGAL SEQUENCE FOR GO TO SLEEP COMMAND
*
* OFF LINE KEY TRANSITION ASCII '=' IS NOT SEND DURING OFF LINE.  (5/27/
82)
* GO TO SLEEP TIMER IS RE-INIT.( BETWEEN ABOUT TO
* GOTO SLEEP & GOTO SLEEP ), IF SERVER COMMAND IS RECIEVED. (6/2/82)
* GOTO SLEEP TIMER IS ACTIVE ONLY DURING ON-LINE READY STATE, ASCII 'A'.
*                   (6/9/82)
* 360 MS HAS BEEN ADDED TO DEVELOPER OFF EVENT.    (6/9/82)
         PAGE
BRANCH:  SET      SHORT:
*
* THIS IS A MAP OF RESERVED RAM WITH A DESCRIPTION OF EACH BYTE.
*
*************************************************************
*
*
* PAGE 0:  ALL DISPLAY ENCODING AND KEYBOARD DECODING
*   IS DONE ON THIS PAGE.
*
*************************************************************
*
TEMP3    EQU      R0       USED DURING PWR UP & DISPLAY
TEMP5    EQU      R1       USED DURING PWR UP & DISPLAY
*
KBD:REG  EQU      R2       KEYBOARD ENABLE/DISABLE & DEBOUNCE
COL      EQU      R3       ENTERED COLUMN -- KEYBOARD
ROW      EQU      R4       ENTERED ROW -- KEYBOARD
DSP      EQU      R5       DISPLACEMENT IN KEYBOARD TABLE
*
DGN:SAV  EQU      R6       DIAG. REAL TIME VALUE
TIM:WRK  EQU      R7       SCRATCH PAD REGISTERS USED
SECS     EQU      R8       FOR COMPUTING REAL TIME DURING
H:MS     EQU      R9       DIAGNOSTICS TIMING TEST
*
ZERO:FLG EQU      R10      ZERO DISPLAY ENTRY PROCESSING FLAGS
*
SOP:PTR  EQU      R11      START OF PATTERN:POINTER;FUSER CONTROL
*
TEMP4    EQU      R12      TEMP REG. USED IN DISPLAY ROUT.
DSP:TENS EQU      R13      SEG. CODE TO DISPLAY 10'S DIGIT R13
DSP:ONES EQU      R14      SEG. CODE TO DISPLAY 1'S DIGIT  R14
CPY:SEL  EQU      R15      PROGRAMMED NUMBER OF COPIES BCD R15
*
         PAGE
*
***********************************************************
*
* PAGE 1:  THIS PAGE CONTAINS THE I/O BYTES, OPERATION
*          FLAGS, AND FUSER PATTERN GENERATION INFO.
**********************************************************
*
IN:ZERO  EQU     R0        PREVIOUS INPUT PORT 0 INFO      R16
IN:ONE   EQU     R1        PREVIOUS INPUT PORT 1 INFO      R17
IN:TWO   EQU     R2        PREVIOUS INPUT PORT 2 INFO      R18
ADVAL    EQU     R3        P LESS N IS USED IN FUSER ROUT  R19
TEMP1    EQU     R4        USED IN FUSER ROUTINE           R20
FLAG2    EQU     R5        BIT FLAGS (DEFINED BELOW)       R21
FLAG3    EQU     R6        MORE BIT FLAGS                  R22
COUNTER  EQU     R7        USED DURING FEEDER TURN OFF     R23
FMASK    EQU     R24       FUSER PATTERN MASK              R24
CUR:PTR  EQU     R25       FUSER CURRENT PATTERN BYTE PTR. R25
SCRATCH  EQU     R10       SCRATCH REGISTER                R26
ROUT0    EQU     R11       PORT 0 OUTPUT INFORMATION       R27
ROUT1    EQU     R12       PORT 1 OUTPUT INFORMATION       R28
ROUT2    EQU     R13       PORT 2 OUTPUT INFORMATION       R29
ROUT3    EQU     R14       PORT 3 OUTPUT INFORMATION       R30
*
FAULTS   EQU     R15       FAULT CODE INFO',BCD VALUE      R31
         PAGE
***********************************************************
*                                                         *
* PAGE 2:  STATE CHECKER BYTES AND REGISTER SAVE LOCATIONS*
*          FOR INTERRUPT ROUTINES.                        *
*                                                         *
*                                                         *
***********************************************************
*
TBL:CNT  EQU     R0        USED IN STATE CHECKER           R32
TIM:CNT  EQU     R1        USED IN STATE CHECKER           R33
IOT:STAT EQU     R2        PRESENT IOT STATUS              R34
TEMP2    EQU     R3        USED BY STATE CHECKER           R35
FLAG1    EQU     R4        OFFSET & DIAGNOSTICS FLAGS      R36
TEMP6    EQU     R5        USED BY USART INTERRUPT HANDLER R37
COMMAND  EQU     R6        SERVER COMMAND REGISTER         R38
FEED:COM EQU     R7        SERVER FEED COMMAND BYTE        R39
LOOP:CNT EQU     R8        TEST BAR COUNT REGISTER         R40
FAN:CTR  EQU     R9        FAN CONTROL COUNTER             R41
TIM:SAV  EQU     R10       USED FOR TESTING DISABLED TIMER R42
DISPLAY  EQU     R11       PREVIOUS DISPLAY INFORMATION    R43
PREV:STA EQU     R12       PREVIOUS IOT STATUS INFORMATION R44
OS:BYTE  EQU     R13       OFFSET COPY COUNT               R45
SAVESR   EQU     R46       SAVE STATUS REG IN INTERRUPT    R46
SAVET    EQU     R47       SAVE T REGISTER IN INTERRUPT    R47
*
*
**********************************************************
** PAGE 3:  ALL EVENT POINTERS AND COUNTERS (TIMERS)     *
*          RESIDE ON THIS PAGE.
*
*
**********************************************************
*
DIVIDER  EQU     R0        20 MS TIMER CELL                R48
*TEMP    EQU     R1        Z:XING TEMP USED TO SAVE T FOR  R49
*                            BLINKING DIGIT DISPLAY
STAT:PNT EQU     R2        STATE EVENT POINTER             R50
TEST:PNT EQU     R3        TEST MODE POINTER               R51
PAGE:PNT EQU     R4        PAGE SYNC. POINTER              R52
STAK:PNT EQU     R5        STACKER EVENT POINTER           R53
PAP:PNT  EQU     R6        PAPER FEED EVENT POINTER        R54
TIM1:PNT EQU     R7        JAM1 POINTER (TE @ REG,LE @     R55
*                            EXIT, AND  BILLING METER OFF
TIM2:PNT EQU     R8        JAM2 POINTER (TE @EXIT          R56
*                            AND FLASHING JAM CODES
STAT:CNT EQU     R9        STATE EVENT COUNTER             R57
TEST:CNT EQU     R10       TEST MODE COUNTER               R58
PAGE:CNT EQU     R59       PAGE SYNC. COUNTER              R59
STAK:CNT EQU     R60       STACKER EVENT COUNTER           R60
PAP:CNT  EQU     R61       PAPER PATH TIME COUNTER         R61
TIM1:CNT EQU     R62       JAM EVENT #1 COUNTER            R62
TIM2:CNT EQU     R63       JAM EVENT #2 COUNTER            R63
*
****************************
         PAGE
**********************************************************
**********************************************************
*
* SYSTEM EQUATES
*
*
***********************************************************
*
*  INPUT ORGANIZATION
*    ALL INPUTS ARE ACTIVE LOW EXCEPT Z:XING
*
IN0      EQU      X'00'            INPUT PORT 0
KB:ROW1  EQU      0                KEYBOARD MATRIX              (J9-12)
KB:ROW2  EQU      1                KEYBOARD MATRIX              (J9-11)
KB:ROW3  EQU      2                KEYBOARD MATRIX              (J9-01)
KB:ROW4  EQU      3                KEYBOARD MATRIX              (J9-06)
REG:SW   EQU      4                REG. SW. IN PAPER PATH
EXIT:SW  EQU      5                EXIT SW. IN PAPER PATH
DOOR:ILK EQU      6                DOOR INTERLOCK
ZAP:THM  EQU      7                ZAP THERMO
*
*
IN1      EQU      X'01'             INPUT PORT 1
*SPARE   EQU      0                 UNUSED INPUT
*SPARE   EQU      1                 UNUSED INPUT
*SRARE   EQU      2                 UNUSED INPUT
*SPARE   EQU      3                 UNUSED INPUT
TRAY:SEN EQU      4                 TRAY FULL  SENSOR
Z:XING   EQU      5                 ZERO CROSSING INPUT
*SPARE   EQU      6                 UNUSED INPUT
TRAY:SW  EQU      7                 TRAY SWITCH
*
IN2      EQU      X'02'            INPUT PORT 2
SERV:OFF EQU      0                SERVER TURNED OFF
SERV:DIS EQU      1                SERVER DISCONNECTED
*SPARE   EQU      2                UNUSED INPUT
LO:TONER EQU      3                 LOW TONER INDICATION
*SPARE   EQU      4                UNUSED INPUT
*SPARE   EQU      5                UNUSED INPUT
*SPARE   EQU      6                 UNUSED INPUT
TRAY:FUL EQU      7                TRAY FULL SWITCH
*
         PAGE
********************************************************
*
* OUTPUT ORGANIZATION
*
OUT0     EQU      X'03'            OUTPUT PORT 0
******************************************************
*  BITS 0-6 ARE MULTIPLEXED VIA PORT 1 FOR 1) FRONT
*  PANEL LED'S, 2) SEGMENTS FOR 1'S DIGIT, AND 3) SEG-
*  MENTS FOR 10'S DIGIT.
******************************************************
SEG:A    EQU      0                 DISPLAY SEGMENT A
SEG:B    EQU      1                 DISPLAY SEGMENT B
OFF:LINE EQU      2                 OFF LINE / SEGMENT D
ON:LINE  EQU      3                ON LINE / SEGMENT E          (J9-08)
*SPARE   EQU      4                 SPARE LED
SEG:F    EQU      5                 DISPLAY SEGMENT F
SEG:G    EQU      6                 DISPLAY SEGMENT G
*SPARE   EQU      7                 UNUSED OUTPUT
*
*
OUT1     EQU      X'04'            OUTPUT PORT 1
LED:RTN  EQU      0                SELECTS PORT 0 FOR FRONT PANEL LEDS
LED:ONE  EQU      1                SELECTS PORT 0 FORUNITS DIGIT
LED:TEN  EQU      2                SELECTS PORT 0 FOR TENS DIGIT
HV:DC    EQU      3                HIGH VOLTAGE DC
*SPARE   EQU      4                 SPARE OUTPUT
BEEPER   EQU      5                 BEEPER
UP:TRAY  EQU      6                UPPER TRAY CLUTCH            (J4-02)
LWR:TRAY EQU      7                LOWER TRAY CLUTCH           (J4-14)
*
OUT2     EQU      X'05'            OUTPUT PORT 2
TEST:1   EQU      0                 TEST 1
GO:SLEEP EQU      1                 GO TO SLEEP
INVERT   EQU      2                 STACKER INVERTER SOLENOID
SHUT:R   EQU      3                 SHUTTER (DC)
*SPARE   EQU      4                 UNUSED OUTPUT
*SPARE   EQU      5                 UNDEFINED (TTL)
OFF:SET  EQU      6                 OFFSET SOLENOID
*SPARE   EQU      7                 NOT USED
*
*
OUT3     EQU      X'06'            OUTPUT PORT 3
BL:SOL   EQU      0                 BLADE SOLENOID
MN:DRV   EQU      1                MAIN DRIVE MOTOR             (J8-03)
FAN      EQU      2                 COOLING FAN
FUS:LMP  EQU      3                FUSER LAMP                   (J8-15)
DEV:CLU  EQU      4                DVL CLUTCH                   (J4-12)
REG:ROLL EQU      5                REGISTRATION ROLLS           (J7-02)
BIL:MTR1 EQU      6                 PRINT COUNTER
WD:TMR   EQU      7                WATCH DOG TIMER
         PAGE
* KBD:REG ALLOCATIONS ***(PG 0 - R2)***************************
*
ONE:ENT  EQU      0                 ONE'S SEGMENT ENABLE/DISABLE
TEN:ENT  EQU      1                 TEN'S SEGMENT ENABLE/DISABLE
TEST:ENT EQU      2                 TEST ENABLE/DISABLE
CLR:ENT  EQU      3                 CLEAR ENABLE/DISABLE
ON:ENT   EQU      4                 ON LINE ENABLE/DISABLE
OFF:ENT  EQU      5                 OFF LINE ENABLE/DISABLE
*BIT6                               DEBOUNCE COUNTER
*BIT7                               DEBOUNCE COUNTER
*
*
* FLAG1 ALLOCATIONS
CHN6:FLG EQU      1                 CHAIN 6 DIAGNOSTICS
DIAG:FLG EQU      2                 DIAGNOSTICS ENABLE
CHN3:FLG EQU      3                 DIAGNOSTICS CHAIN 3
CHN8:FLG EQU      4                 DIAGNOSTICS CHAIN 8
CHN9:FLG EQU      5                 DIAGNOSTICS CHAIN 9
CN10:FLG EQU      6                 DIAGNOSTICS CHAIN 10
CONT:FLG EQU      7                 DIAGNOSTICS CONTINOUS COPY CYCLE
*
*
* FLAG2 ALLOCATIONS
PRNT:FLG EQU      0                START PRINT CYCLE COLD
SOFT:JAM EQU      1                SOFT JAM(C-4)
OFF:FLG  EQU      2                 OFF LINE KEY DEPRESSION DURING
*                                   ON LINE WHILE IN RUN MODE.
RUN:FLG  EQU      3                RUN MODE-INHIBIT STRT PT
WDT:FLG  EQU      4                 WATCH DOG TIMER
SERV:FLG EQU      5                SERVER TERMINATION INTERROGATION
ZAP:FLG  EQU      6                FUSER IN ZAP MODE
JAM:FLG  EQU      7                HARD JAM, IMMEDIATE DN
*
* FLAG3 ALLOCATIONS
FUS:ON   EQU      0                FUSER LAMP IS ON
CMD:FLG  EQU      1                SERVER COMMAND ACKNOWLEDGED
SHUT:FLG EQU      2                 SHUTTER 50% DUTY CYCLE ENABLE
READ:FLG EQU      3                READ THE A/D CONVERTOR
WDT:MEM  EQU      4                 WATCH DOG TIMER & MEMORY TEST
WAIT:FLG EQU      5                 MINIMUM STANDBY FLAG
REG:FLG  EQU      6                REG SW FLAG
TMR:FLG  EQU      7                REG SW CHECK ENABLE
*
* OS:BYTE REGISTER ALLOCATIONS
*
OS:FLG3  EQU      0                 OFFSET FLAG3
OS:FLG2  EQU      1                 OFFSET FLAG2
OS:FLG1  EQU      2                 OFFSET FLAG1
*BITS 5-7 ARE RESERVED FOR OFFSET FUNCTION
         PAGE
*
**********************************************************
*
* GENERAL SYSTEM EQUATES
*
KBD:CLR  EQU      X'0A'            LOCK OUT KYBD
BLANK:   EQU      X'00'            SEG. INFO FOR BLANK CHAR
ZERO:    EQU      X'3F'            SEG. INFO FOR ZERO CHAR
RE:PROG  EQU      X'F5'            ENABLE KYBD DIGITS
IN:CNT   EQU      X'F4'            USED FOR ONBOARD TIMER (TIC)
OUT:CNT  EQU      X'7F'            SET FOR 5.04 MS @ 2.4576MHZ (TOC)
*
*
BIT0     EQU      0
BIT1     EQU      1
BIT2     EQU      2
BIT3     EQU      3
BIT4     EQU      4
BIT5     EQU      5
BIT6     EQU      6
BIT7     EQU      7
*
*
         PAGE
*
**********************************************************************
************************************************************************
*
*
*  USART INTERRUPT HANDLER EQUATES
*
READ:MSK EQU      X'20'             READ STATUS COMMAND
UNREC:MK EQU      X'4E'             COMMAND UNRECOGNIZED MASK
PROT:ERR EQU      X'4D'             PROTOCOL ERROR MASK
LSB:MSK  EQU      X'0F'             ZERO SUPRESSION FOR DISPLAY
*
*
***********************************
*    COMMUNICATION'S I/O          *
***********************************
*
*
DATA:RW  EQU      X'08'             USART DATA READ/WRITE PORT
CMD:MODE EQU      X'09'             USART MODE & COMMAND INSTRUCTION
*                                   WRITE PORT.
STAT:RD  EQU      X'09'             USART STATUS READ PORT
*
*
*
         PAGE
*******************************************************************
*
* RESTART AND EXTERNAL INTERRUPT VECTORS
*
RESTRT:  JMP      START:UP          POWER ON RESET
         JMP      INT:HAND          EXTERNAL INTERRUPT HANDLER
*
*
***************************************************************
*                                                             *
*  TIMER INTERRUPT ROUTINE                                    *
*                                                             *
*      THIS ROUTINE IS CALLED UPON A TIMER OVERFLOW INTERRUPT *
*    WHICH HAPPENS EVERY 5 MS.  THE INTERRUPT IS DIVIDED OUT  *
*    BY INCREMENTING THE DIVIDER BYTE SO THAT WE HAVE 20 MS.  *
*    RESOLUTION.  DIVIDER IS CHECKED IN STATE CHECKER TO SEE  *
*    IF IT IS ZERO.  WHEN IT IS, IT IS RESET TO -4 AND ALL    *
*    ACTIVE TIMER CELLS (I.E. THOSE NOT EQUAL TO 'FF' ARE     *
*    INCREMENTED.                                             *
*                                                             *
***************************************************************
*
*
*
TIME:INT MOVD     SAVET,T           SAVE THE T REGISTER
         MOV      T,SR
         MOVD     SAVESR,T          SAVE THE PROGRAM STATUS REG.
         LPI      1
         STB      TMR:FLG           CHECK REG SW
         IOR      FLAG3,T
*
         LPI      3                 TIMER WORK RAM IS ON PAGE 3
         CLR      TIMI              RESET TIMER INTERRUPT LATCH
*
* UPDATE ALL ACTIVE TIMER CELLS
*
         IBNZ     DIVIDER,ALL:OVER  INCREMENT DIVIDER
ALL:OVER JMP      RESTORE           RESTORE T AND SR AND RETURN
*
*
*
         PAGE
***************************************************************
*                                                             *
*  INTERRUPT HANDLER                                          *
*                                                             *
*      THIS ROUTINE POLL  INPUTS TO DETERMINE THE TYPE OF     *
*    EXTERNAL INTERRUPT RECEIVED.  ZERO CROSSING HAS THE HIGH-*
*    EST PRIORITY.  A USART INTERRUPT IS RECOGNIZED ONLY IF   *
*    RXRDY BIT IS TRUE.                                       *
*                                                             *
*                                                             *
***************************************************************
*
INT:HAND MOVD     SAVET,T           SAVE T REG IN SAVET REG
         MOV      T,SR
         MOVD     SAVESR,T          AND STATUS REGISTER IN SAVESR REG.
         LPI      1
         INP      T,IN1             IF Z:XING INPUT IS HIGH EX-
         JT       Z:XING,ZERO:X        DO ZERO CROSSING ROUTINE
         LPI      2                 ELSE:
         INP      T,STAT:RD              CHECK USART STATUS
         JT       1,USRT@INT              IF:  RXRDY  BIT IS TRUE
*                                               DO USART ROUTINE
         JT       3,PCOL@ERR              ELSEIF: PARITY ERROR
*                                                SEND STATUS  'M'
         JT       4,PCOL@ERR              ELSEIF: OVERRUN ERROR
*                                                SEND STATUS 'M'
         JT       5,PCOL@ERR              ELSEIF: FRAMING ERROR
*                                                SEND STATUS 'M'
         MVI      TEMP6,0                 ELSE:
         JMP      INI:USRT                   INITIALIZE USART
*                                            FOR NOISE.
PCOL@ERR JMP      PCOL:ERR
*
USRT@INT JMP      USRT:INT
*
         PAGE
*******************************************************************
* THE FOLLOWING IS THE ZERO CROSSING ROUTINE
* SEVEN  FUNCTIONS ARE PERFORMED EVERY 8.33MS
* THEY ARE:
*     1) PERFORM REGISTRATION CHECKS TO SET A TRAILING EDGE FLAG
*        AND TURN OFF THE PAPER FEEDER AND REG ROLLS
*     2) MONITOR THE DOOR INTERLOCKS
*     3) SCAN THE KEYBOARD SWITCHES FOR ANY NEW CLOSURES
*     4) REFRESH THE OUTPUTS
*     5) UPDATE THE FUSER REGULATION CYCLE
*     6) UPDATE THE DISPLAYS
*******************************************************************
ZERO:X   MOV      T,ROUT3           IF: TRIAC IS ALREADY ACTIVE
         JT       FUS:LMP,NOT:YET       DO NOT TURN ON TRIAC YET
         OUT      OUT3,ROUT3        ELSE:
*                                        TURN ON FUSER TRIAC NOW
*                                    (NOTE THAT THE FUSER ROUTINE IS
*                                    EXECUTED LATER IN THIS ROUTINE
*                                    FOR THE NEXT ZERO CROSSING)
NOT:YET  DIM      EXTF              DISABLE EXTERNAL INT. FLAG
         MOV      T,ROUT1
         MVI      ROUT1,X'F8'       TURN OFF ALL OUTPUT STROBES
         AND      ROUT1,T           TO AVOID SHADOWING
         OUT      OUT1,ROUT1
         JT       0,DO:1S           CASE:
         JT       1,DO:10S             THIRD BIT SET:
DO:LEDS  STB      LED:RTN                 SET THE FIRST STROB BIT
         IOR      ROUT1,T
         MOV      T,ROUT0                 GET LED INFO INTO T REG
         JMP      PUTOUTS
DO:1S    STB      LED:ONE              FIRST BIT SET:
         IOR      ROUT1,T                 SET THE SECOND STROBE BIT
         LPI      0                       ELSE:
         MOV      T,DSP:ONES                 GET ONES DISPLAY INFO
         JMP      PUTOUTS
DO:10S   STB      LED:TEN              SECOND BIT SET:
         IOR      ROUT1,T                 SET THE THIRD STROBE BIT
         LPI      0                       ELSE:
         MOV      T,DSP:TENS                 GET TENS DISPLAY INFO
PUTOUTS  LPI      1                    RESTORE T
         OUT      OUT0,T            OUTPUT THE NEW DISPLAY INFO
         OUT      OUT1,ROUT1        THEN OUTPUT STROBE TO CHANNEL
         OUT      OUT2,ROUT2        INFO TO PROPER OUTPUT
*
         MOV      T,FLAG3
         CPL      T                 IF: 50% DUTY CYLCLE FLAG SET
         JT       SHUT:FLG,CK:AUDI
         MVI      T,X'4D'               PRESERVE A/O MOD,INVERTER
         AND      ROUT2,T               & OFFSET OUTPUTS,
         MVI      T,X'08'
         ADD      ROUT2,T               BUT TOGGLE SHUTTER SOL.
*
CK:AUDI  LPI      1
         MOV      T,FLAG3           IF A/D READ FLAG IS SET
         CPL      T
         JT       READ:FLG,NO:READ
         STRT     ADC                  START THE CONVERSION AND
          CLB       7              RESET THE NEW ADC FLAG TO ALLOW
          AND       ADVAL,T          RE-SETTING FUSER ALGORITHM.
         CLB      READ:FLG             CLEAR THE READ FLAG
         AND      FLAG3,T
NO:READ  INP      IN:ONE,IN1        REFRESH THE INPUT REGISTERS
         INP      IN:ZERO,IN0
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         OUT      OUT3,ROUT3        FUSER TRIAC IS ACTIVATED HERE
*                                   APPROX. 188 USEC. LATER FOR
*                                   EMI/RFI FILTERING.
         LPI      1
         INP     T,IN2              CHECK SERVER OFF OR DISCONNECTED POR
T
         CAL      SERV:STK          CHECK PAPER TRAY AND STACKER TRAY
*
*
***********************************
* CHECK FOR A CHANGE IN IOT STATUS*
***********************************
*
CHK:STAT LPI      1
         MOV      T,FLAG2           IF OFF FLAG TRUE(CYC
*        LING OFF LINE), SEND CHANGES IN STATUS IE. JAM
*        INFORMATION.
         JT       OFF:FLG,SEN:STAT
         MOV      T,ROUT0
         JT       OFF:LINE,KEY:ON     IF: ON LINE MODE IS TRUE
SEN:STAT LPI      2
         MOV      T,IOT:STAT          LOAD IOT PRESENT STATUS AND
         CMP      PREV:STA,T          COMPARE WITH PREVIOUS STATUS
         JZ       KEY:ON              IF: IT HAS CHANGED
         OUT      DATA:RW,T              TRANSMIT AND UPDATE STATUS
         MOV      PREV:STA,T        ELSEIF: OFF LINE MODE
*                                           SEND OFF LINE STATUS 'V'
*
***************************
* CHECK THE INTERLOCKS    *
***************************
KEY:ON   LPI      1
         MOV      T,IN:ZERO
         CPL      T
         JT       DOOR:ILK,DOOR:CK  IF THE DOOR IS CLOSED:
         LPI      2
         LCB      IOT:STAT,X'48',KEY@BRD
         CLR      T                 ANDIF: DOOR WAS OPENED PREVIOUSLY
         AND      FLAG1,T
         LPI      0                      CLEAR DIAG. FLAGS
         MVI      KBD:REG,X'C0'         ENABLE KEYBOARD
         MVI      CPY:SEL,0            CLEAR KEYBOARD ENTRY REG.
         LPI      3
         MVI      TIM2:PNT,0            TURN OFF BLINK TIMER
         MVI      TIM2:CNT,X'FF'
         LPI      1                     CHECK PAPER PATH FOR JAMS
         CAL      PPR:CK
KEY@BRD  LPI      1
         MOV      T,FLAG3           IF: NOT IN 3 MIN. WAIT
         JT       WAIT:FLG,WTREST
         MOV      T,FLAG2
         JT       JAM:FLG,KEY:BD    ORIF: NOT HARD JAM
         JT       RUN:FLG,CK:TRSW   ORIF: RUN MODE
         JMP      KEY:BD
CK:TRSW  MOV      T,IN:ONE
         JT       TRAY:SW,KEY:BD
         LPI      2                    PRELOAD IOT STATUS WITH ASCII 'Q'
         MVI      IOT:STAT,X'51'    ELSE:
KEY:BD   CAL      KEY:BRD                SCAN KEYBOARD
         JMP      WTREST
*
DOOR:CK  CAL      DIA:ROUT          IF: DOOR IS OPENED FOR THE
         CAL      CK:DR                 FIRST TIME
         LPI      2                   TURN OFF OUTPUTS & TIMERS
         MVI      IOT:STAT,X'48'       SEND DOOR OPENED STATUS 'H'
         LPI      1                   IF: DOOR OPEN CODE NOT 'E5'
         LCB      FAULTS,X'E5',LOAD:E5    DISPLAY E5 & ENTER
         JMP      STK:OFF                 HARD SHUT DOWN STATE
LOAD:E5  MVI      FAULTS,X'E5'
         STB      JAM:FLG
         IOR      FLAG2,T
         CAL      BL@ON
STK:OFF  LPI      3
         MVI      STAK:CNT,X'FF'       DISABLE STACKER INVERTER TIMER
*
******************************************
* GET READY TO RETURN TO BACKGROUND      *
******************************************
*
WTREST   LPI      1
         CAL      FUSER             DO FUSER ALG FOR NEXT ZERO CROSSING
*
*
RESTORE  LPI      2
         MOV      T,R15             RESTORE T REG
         MOV      SR,R14            AND STATUS REGISTER
         RFI                        RETURN TO BACKGROUND OR TIMER
         PAGE
*
         ORG      X'F0'
*
***********************************************
* KEYBOARD SCAN DELAY IS PROVIDED TO INSURE   *
* KEY INPUT FILTERING PRIOR TO READ STROBE.   *
* THE ADDRESS OF THESE ROUTINES MUST START AT *
* XF0 FOR PROPER OPERATION.                   *
***********************************************
*
*
IN:COL4  NOP
         INP      T,X'80'
         RFS
*
IN:COL3  NOP
         INP      T,X'40'
         RFS
*
IN:COL2  NOP
         INP      T,X'20'
         RFS
*
IN:COL1  NOP
         INP      T,X'10'
         RFS
         PAGE
************************************
*                                  *
*    KEYBOARD READ ROUTINE         *
*                                  *
************************************
*
*        ROW -- ROW INPUT
*        COL -- COLUMN INPUT
*        DSP -- DISPLACEMENT IN KEYBOARD TABLE
*        KBD:REG -- DEBOUNCE COUNTER AND ENABLE/DISABLE BITS
*
KEY:BRD  LPI      0
         LCJ      KBD:REG,X'FF',READ   KBD:REG = FF MEANS
         RFS                           KEYBOARD IS DISABLED
*
***** COLUMN 1
READ     MVI      DSP,0             SET DISPLACEMENT FOR COLUMN 1
         CAL      IN:COL1           READ ADDRESS OF COLUMN 1
         CAL      MSB:MSK           MASK OFF MSB
         JNZ      DECODE            IF NO ENTRY RECOGNIZED
*                                      PROCEED TO COLUMN 2
***** COLUMN 2
         MVI      DSP,4             SET DISPLACEMENT FOR COLUMN 2
         CAL      IN:COL2           READ ADDRESS OF COLUMN 2
         CAL      MSB:MSK           MASK OFF MSB
         JNZ      DECODE            IF NO ENTRY RECOGNIZED
*                                      PROCEED TO COLUMN 3
***** COLUMN 3
         MVI      DSP,8             SET DISPLACEMENT FOR COLUMN 3
         CAL      IN:COL3           READ ADDRESS OF COLUMN 3
         CAL      MSB:MSK           MASK OFF MSB
         JNZ      DECODE            IF NO ENTRY RECOGNIZED
*                                      PROCEED TO COLUMN 4
***** COLUMN 4
         MVI      DSP,12            SET DISPLACEMENT FOR COLUMN 4
         CAL      IN:COL4           READ ADDRESS OF COLUMN 4
         CAL      MSB:MSK           MASK OFF MSB
         JNZ      DECODE            IF NO ENTRY RECOGNIZED
*
***** NO ENTRY MADE
         MVI      T,X'3F'              CLEAR DEBOUNCE BITS 6 & 7
         AND      KBD:REG,T            TO SHOW KEY HAS BEEN RELEASED
NOT:CLR  LPI      1
         CLB      BEEPER
         AND      ROUT1,T              TURN OFF BEEPER
         RFS                           RETURN (NO ENTRIES MADE)
         PAGE
************************************
*                                  *
*   DECODE INPUTTED COLUMN         *
*                                  *
************************************
*
DECODE   CLB      BIT6              MAKE SURE KEY FROM LAST
         CMP      KBD:REG,T         ENTRY HAS BEEN RELEASED
         JLT      NOT:CLR           IF DEBOUNCE BITS ARE NOT CLEAR
*                                      WAIT FOR KEY TO BE RELEASED
***** DETERMINE ROW
         MOV      T,COL             PUT INPUTTED COLUMN IN COL
         MVI      ROW,0             SET UP FOR ROW 1
         JT       BIT0,ROW:FND
         MVI      ROW,1             SET UP FOR ROW 2
         JT       BIT1,ROW:FND
         MVI      ROW,2             SET UP FOR ROW 3
         JT       BIT2,ROW:FND
         MVI      ROW,3             SET UP FOR ROW 4
         JT       BIT3,ROW:FND
*
***** SHOULD NOT GET HERE
         RFS
*
ROW:FND  MOV      T,ROW
         ADD      DSP,T             ADD ROW TO COLUMN DISPLACEMENT
         MVI      T,KBD:TBL
         ADD      DSP,T             ADD KEYBOARD TABLE ADDRESS TO DSP
         MOV      T,DSP
         MPM      T,HIADDR(KBD:TBL) LOAD ADDRESS OF ENTRY (OR ADDRESS)
         MOV      DSP,T             AND STORE IT IN DSP
*
***** DEBOUNCE
         STB      BIT6              SET T TO '40' (BIT 6 OF T)
         ADD      KBD:REG,T         BITS 6 & 7 ARE USED FOR DEBOUNCE
         CLB      BIT6              SET T TO 'BF'
         CMP      KBD:REG,T
         JLT      REC:ENT           IF BITS 6 & 7 ARE NOT SET
         RFS                           DEBOUNCE IS NOT COMPLETE
         PAGE
*
***********************************
*                                 *
*   KEYBOARD ENTRY RECOGNIZED     *
*                                 *
***********************************
*
REC:ENT  LPI      1
         STB      BEEPER            BEEP KEYBOARD ENTRY
         IOR      ROUT1,T
         LPI      0
         MVI      T,10
         CMP      DSP,T
         JGE      NUMBER            IF DISPLACEMENT IS >= 10
*                                      ENTRY IS A FUNCTION
*****************************
*                           *
*   FUNCTION SWITCH FOUND   *
*                           *
*****************************
*
         MOV      T,DSP             ACTIVATE FUNCTION KEY
         JIT
*
**************************************
*                                    *
*   NUMBER ENTRY RECOGNIZED          *
*                                    *
**************************************
*
***** CHECK FOR FIRST NUMBER ENTERED
*
NUMBER   MOV      T,KBD:REG
         JT       TEN:ENT,NO:ENT
         JT       ONE:ENT,TRY:TENS  IF ONE'S ENTRY ALREADY MADE
         STB      ONE:ENT             TRY FOR TENS ENTRY
         IOR      KBD:REG,T         ELSE:
         CAL      ENTER:0               SET ONES ENTRY FLAG
         MVI      T,X'F0'               SET IST ZERO ENTRY FLAG
         AND      CPY:SEL,T             SEND KEY INFO' TO SERVER
         JMP      DSP:NUM               IF: OFF LINE
         PAGE                          DISPLAY KEY ENTRY
***** SECOND NUMBER
*
TRY:TENS STB      ONE:ENT              DISABLE ONES ENTRY
         IOR      KBD:REG,T
         CAL      ENTER:0              SET 2ND ZERO ENTRY FLAG
         MOV      T,CPY:SEL
         ADD      CPY:SEL,T
         MOV      T,CPY:SEL            START SHIFTING ONE'S ENTRY
         ADD      CPY:SEL,T            TO TEN'S
         MOV      T,CPY:SEL
         ADD      CPY:SEL,T
         MOV      T,CPY:SEL
         ADD      CPY:SEL,T
DSP:NUM  MOV      T,DSP
         IOR      CPY:SEL,T           DISPLAY KEY ENTRY
         CAL      KEY:CODE            SEND KEY INFO' TO
         CAL      SEL:DSP             SERVER
NO:ENT   RFS
*
*
MSB:MSK  CPL      T                 RETURNED IN T (0 = ON)
         MVI      COL,X'0F'
         AND      COL,T             MASK OFF BITS 4 THRU 7
         RFS
         PAGE
************************************************************************
*
*************************************************
*************************************************
* MACHINE FUNCTIONS:  JUMPED TO FROM KEYBOARD   *
* SCAN IF THE RESPECTIVE FUNCTION SWITCH IS MADE*
*  NOTE THAT ALL KYBD FUNCTION LABELS MUST START*
*  AFTER ADDRESS X'180' AS THIS DISTINGUISHES   *
*  FROM NUMERIC KEYS.                           *
*************************************************
*************************************************
*
***************************
*   OFF LINE FUNCTION     *
*   SUBROUTINE            *
***************************
*
*
OFFLINE: MOV      T,KBD:REG
         JT       OFF:ENT,NO:ACTN   IF: OFF LINE KEY DISABLED
         LPI      1                     RETURN
         MOV      T,ROUT0
         JT       OFF:LINE,CHK:DIAG IF: ON-LINE BEFORE
         MVI      T,X'3D'               SEND KEY STATUS '='
         OUT      DATA:RW,T             & IOT STATUS 'V'
*        DELAY TO AVOID DATA COLLISION.
         MVI      SCRATCH,-50       DELAY HERE INSTEAD
INC:     IBNZ     SCRATCH,INC:      OF CALLING  TX:RDY
                 DISABLE DIAGNOSTICS
         CAL      DIA:ROUT             TURN OFF DIAG. OUTPUTS,
         LPI      3                    DISPLAY & 3MIN. TIMEOUT
         MVI      TEST:CNT,X'FF'
         MVI      PAP:CNT,X'FF'
         JMP      BLK:DSP
ON:STAT  LPI      2                 SEND ON-LINE KEY & STANDBY
         MVI      T,X'3C'           STATUS ASCII '<' & 'A'
         OUT      DATA:RW,T
*
*
*******************************
*                             *
*   NO ACTION FUNCTION KEY    *
*                             *
*******************************
*
NO:ACTN  RFS
         PAGE
*********************************************************************
*********************************************************************
*   EVENT CODE RESIDES ON THIS PAGE OF ROM.  RGT:PAGE IS JUMPED TO  *
*   FROM THE STATE/EVENT CHECKER ROUTINE SO THAT EVENTS MAY BE      *
*   CALLED WITH A 'JIT' INSTRUCTION.  EVENTS THAT CANNOT FIT ON THIS*
*   PAGE ARE VECTORED TO A SPOT IN HIGHER (LOWER) MEMORY WITH A JUMP*
*   INSTRUCTION.                                                    *
*                                                                   *
*********************************************************************
*********************************************************************
          ORG       X'200'
RGT:PAGE LPI      1
         JIT                        JUMP TO (CALL) THE CURRENT EVENT
         PAGE
****************************************************************
* COLD START STATE:  TURNS ON ALL REQUIRED OUTPUTS AND SETS    *
*FLAG FOR THE NEXT A/D READING. PAGE SYNC. COUNTER IS ACTIVATED.. *
****************************************************************
* EVENT #1  *
*************
START:C  STB      BL:SOL            PLACE THE BLADE CLEANER ON THE DRUM
         IOR      ROUT3,T
         STB      READ:FLG          REQUEST A/D READING IN NEXT Z:XING
         IOR      FLAG3,T
         STB      RUN:FLG           SET RUN FLAG
         IOR      FLAG2,T
         MOV      T,ROUT0           IF ON-LINE MODE,DO NOT
         JT       ON:LINE,NO:OFFL   ENABLE KEY BOARD
         LPI      0                 IF: DIAGNOSTICS MODE
         MVI      KBD:REG,X'C3'
NO:OFFL  RFS                           INHIBIT NUMERIC ENTRY
*
*************
* EVENT #2  *
*************
*
*
DRV:ON   STB      MN:DRV            TURN ON THE MAIN DRIVE AND
         IOR      ROUT3,T
         STB      FAN
         IOR      ROUT3,T           TURN ON FAN
         LPI      3
         MVI      PAGE:PNT,SYNC:UP    INIT. PAGE SYNC TIMER
         MVI      PAGE:CNT,95          FOR FIRST PAGE SYNC
         LPI      2
         MOV      T,FLAG1
         CPL      T
         JT       DIAG:FLG,DRIV:RET
         LPI      0
         LCB      CPY:SEL,X'39',CHK:0
         JMP      DRIV:RET
CHK:0    LCB      CPY:SEL,X'10',CHK:38
DRIV:RET LPI      1
         CLB      TEST:1
         AND      ROUT2,T
         RFS
CHK:38   LCB      CPY:SEL,X'38',DRIV:RET
*                                   IF: DIAGNOSTICS 3-9 OR 3-10
         LPI      1                     TURN ON A/O MODU.
         STB      TEST:1            ELSEIF: DIAG. 3-8
         IOR      ROUT2,T               TURN A/O MODU. OFF
         RFS
         PAGE
*************
* EVENT 3   *
*************
************************************
*  HIGH VOLTAGE ON EVENT           *
************************************
HV:ON    STB      HV:DC             TURN ON THE HIGH VOLTAGE DC
         IOR      ROUT1,T
         STB      FUS:ON            TURN ON THE FUSER
         IOR      FLAG3,T
         RFS
*
*
***************
*   EVENT 4   *
***************
******************************
*   SHUTTER ON EVENT         *
******************************
*
SHUT:ON  MOV      T,ROUT0
         JT       ON:LINE,SHUTR     IF: OFF LINE MODE
         LPI      0                 ANDIF: DIAGNOSTIC MODE 3-9
         LCB      CPY:SEL,X'39',SHUTR
         RFS                           LEAVE SHUTTER OFF
*
SHUTR    LPI      1                 ELSE:
         STB      SHUT:R
         IOR      ROUT2,T                TURN ON SHUTTER
         RFS
*
*
************
* EVENT #5 *
*************
*************************************
*                                   *
*    DEVELOPER ON EVENT             *
*                                   *
*************************************
*
DEV:ON   STB      DEV:CLU           TURN ON THE DEVELOPER
         IOR      ROUT3,T
         MOV      T,ROUT0
         JT       ON:LINE,SET:SFLG  IF: OFF LINE MODE
         LPI      0                 ANDIF: DIAGNOSTIC MODE 3-9
         LCB      CPY:SEL,X'39',SET:SFLG
         JMP      DEV:RET               DO NOT ENABLE SHUTTER
*                                       50% DUTY CYCLE
SET:SFLG LPI      1                 ELSE:
         STB      SHUT:FLG
         IOR      FLAG3,T               ENABLE SHUTTER 50% DUTY CYCLE
DEV:RET  RFS
         PAGE
*
****************************************
*  JUMP TABLE FOR OFF PAGE EVENTS      *
****************************************
*
TE:EXIT  JMP      TE@EXIT
TE:REG   JMP      TE@REG
LE:EXIT  JMP      LE@EXIT
BILL:OFF JMP      BILL@OFF
BL:OFF   JMP      BL@OFF
BL:ON    JMP      BL@ON
SYNC:OUT JMP      SYNC@OUT
RR:OFF   JMP      RR@OFF
OFST:OFF JMP      OFST@OFF
INV:ON   JMP      INV@ON
INV:OFF  JMP      INV@OFF
SFT:JAM  JMP      SFT@JAM
MIN:LOOP JMP      3MIN:WT
FAN:CNT  JMP      FAN@CNT
ST:SLEEP JMP      ST@SLEEP
DSP:OFF  JMP      DSP@OFF
DSP:SECS JMP      SEC:DSP
DSP:BLN  JMP      BLN:DSP
DSP:MS   JMP      MS:DSP
DSP:BLNO JMP      BLNO:DSP
FUS:OUT  JMP      FUS@OUT
DRV:OFF  JMP      DRV@OFF
BLD:OFF  JMP      BLD@OFF
DGN:HV   JMP      DGN@HV
HV:OFF   JMP      HV@OFF
PRE:CYC  JMP      PRE@CYC
DVL:OFF  JMP      DVL@OFF
SLEEP:   JMP      SLEEP@
OLINE:V  JMP      V:OLINE
RR:ON    JMP      RR@ON
         PAGE
*************************************
*                                   *
*   TEST PATTERN STATE:             *
*   TEST OUTPUT BIT IS TOGGLED TO   *
*   INITIATE BAR PATTERN TEST SEQ.  *
*   TEST BAR OUTPUT IS ACTIVE LOW   *
*   I.E WHEN OUTPUT IS HIGH THE     *
*   IMAGE IS WHITE AND VICE VERSA.  *
*                                   *
*************************************
*
TEST:ON2 LPI      2
         IBNZ     LOOP:CNT,TEST:ON  IF: TEST BAR COUNT = 9
         LPI      1                     TURN OFF A/O MODULATOR
         CLB      TEST:1            ELSE:
         AND      ROUT2,T                TURN IT ON
         RFS
TEST:ON  LPI      1
         STB      TEST:1
         IOR      ROUT2,T
         LPI      3
         MVI      TEST:PNT,TEST:TBL1
         MVI      TEST:CNT,0        SET POINTER
         RFS                        TO TURN OFF TEST 1 BIT
TEST:OFF CLB      TEST:1
         AND      ROUT2,T           TEST 1 BIT OFF
         JMP      INI:TTMR
TEST:ON1 LPI      2
         MVI      LOOP:CNT,-9           SET 9 TEST BAR LINES
         LPI      1
         STB      TEST:1                TURN A/O MODUL OFF FOR 420 MS
         IOR      ROUT2,T
INI:TTMR LPI      3
         MVI      TEST:CNT,0
         RFS
         PAGE
         PAGE
***********************************************
* DOCUMENT READY STATE:  PAPER FEEDER IS ON,  *
* REG ROLL CLUTCH ON,UPDATE FUSER A/D VALUE,  *
* START PAGE SYNC TIMER,SEND RUN:READY STATUS *
* TO SERVER,START JAM INTERROGATION TIMERS &  *
* INITIATE CYCLE OUT IF COINCIDENCE.          *
***********************************************
****************************
* EVENT #1 PAPER FEEDER ON *
****************************
COP:FEED MOV      T,FLAG2
         JT       PRNT:FLG,FEED:
         STB      PRNT:FLG
         IOR      FLAG2,T
         MOV      T,IN:ZERO         IF: PAPER HAS ALREADY BEEN FED
         CPL      T                     DO NOT FEED ANOTHER SHEET
         JT       REG:SW,CLR:FEED       (TRUE ONLY FOR COLD START)
FEED:    MOV      T,FLAG2           IF: CYCLING OFF ON-LINE
         JT       OFF:FLG,ONLINE       COMPLETE ON-LINE JOB FIRST
         MOV      T,ROUT0
         JT       ON:LINE,ONLINE    IF: OFF LINE MODE
         LPI      0                       IF: KEYBOARD ENTRY = 2
         LCB      CPY:SEL,2,DIA:55        ORIF: KEY ENTRY 3-32 OR 8-55
         JMP      ENB:LWR                     ENERGIZE LOWER TRAY
DIA:55   LCB      CPY:SEL,X'55',DIA:32
         JMP      ENB:LWR
DIA:32   LCB      CPY:SEL,X'32',TST:1
         JMP      ENB:LWR                  ELSE:
TST:1    LCB      CPY:SEL,1,DIA:30
         JMP      ENB:UPPR                       ENERGIZE UPPER TRAY
DIA:30    LCB     CPY:SEL,X'30',TEST:0
         JMP      ENB:UPPR
TEST:0   LCB      CPY:SEL,BLANK:,ENB:UPPR
         JMP      ENB:UPPR
ONLINE   LPI      2
         MOV      T,FEED:COM        IF: PRINT COMMAND UPPER TRAY
         JT       4,ENB:UPPR
         JMP      ENB:LWR                 ENERGIZE UPPER TRAY
ENB:UPPR LPI      1
         STB      UP:TRAY           ELSE:
         IOR      ROUT1,T
         JMP      SET:CTR                 ENERGIZE LOWER TRAY
ENB:LWR  LPI      1
         STB      LWR:TRAY
         IOR      ROUT1,T
SET:CTR  LPI      1
         CLR      T
         MOV      COUNTER,T        RESET CNTR TO AVOID ROLL OVER
CLR:FEED LPI      2
         MVI      FEED:COM,0
         LPI      1
         MOV      T,FLAG2           IF: CYCLING OFFLINE
         JT       OFF:FLG,OFF:FEED     SEND 'J', STATUS 'U'
         LPI      2                 ELSE:
         MVI      IOT:STAT,X'4A'         SEND RUN:FEEDING STATUS 'J'
NO:FEED  RFS
*
OFF:FEED MVI      T,X'4A'
         OUT      DATA:RW,T
         RFS
         PAGE
         ORG      X'300'
*
*
*********************************
* EVENT #2 (REGISTRATION EVENT) *
*********************************
*
RR@ON    STB      REG:ROLL
         IOR      ROUT3,T
         OUT      OUT3,ROUT3        TURN ON REG ROLLS IMMEDIATELY
         CLB      CMD:FLG           CLEAR COM. ACKN. FLAG
         AND      FLAG3,T
         LPI      3
         MVI      PAGE:CNT,0        INIT. UPPER TRAY PAGE SYNC.
         MVI      PAGE:PNT,SYNC:UP
         LPI      1
         MOV      T,FLAG2           IF: NOT CYCLING OFF LINE
         JT       SOFT:JAM,AD:FLG   ANDIF: NOT C4 JAM
         JT       OFF:FLG,AD:FLG    ANDIF: NOT TRAY OPEN STATUS 'Q'
LOAD:K   LPI      2
         MVI      IOT:STAT,X'4B'        PRE-LOAD STATUS 'K'
AD:FLG   LPI      1
         STB      READ:FLG          READ FUSER A/D VALUE DURING
         IOR      FLAG3,T           NEXT ZERO-CROSSING.
         LPI      3
         MVI      T,SLP:TBL
         CMP      TIM1:PNT,T        IF: GOTO SLEEP TIMER ACTIVE
         JNE      TE:ON
         LPI      2                     INITIALIZE FAN ON COUNT
         MVI      FAN:CTR,0             TO ZERO.
TE:ON    LPI      3
         MVI      TIM1:PNT,TAT:REG  START TRAIL EDGE AT REG,L.E
         MVI      TIM1:CNT,0         @ EXIT JAM TIMERS
         LPI      2
         LCB      FAN:CTR,196,DEC:FCNT
         RFS
*                                   IF: FAN COUNT IS <=60
DEC:FCNT MVI      T,-1
         ADD      FAN:CTR,T            INCREMENT FAN COUNT
         RFS
         PAGE
*
*********************************
* EVENT #3 (PRE-CYCLE OUT EVENT) *
*                               *
*   DECISION FOR CYCLE OUT IS   *
*   MADE IN THIS EVENT.         *
*********************************
*
PRE@CYC  DIF
         INP      T,IN0
         JT       ZAP:THM,CHK:FEED  IF: FUSER UNDER TEMP.
         LPI      2
         MVI      IOT:STAT,X'49'       SEND STATUS 'I' TO SERVER
         JMP      CYC:OUT3             & START CYCLE OUT
CHK:FEED MOV      T,FLAG2
         JT       SOFT:JAM,CYC:OUT2   IF: SOFT JAM 'C4'
         LPI      2                       START CYCLE OUT
         MOV      T,FEED:COM        IF:FEED COMMAND
         JT       6,CK:B4              IF: LOWER TRAY REQ'D
         MOV      T,FLAG1                  INIT.LWR TRAY PAGE SYNC
         JT       CONT:FLG,SAMP:RET ELSEIF: DIAG. TIMING CHECK MODE
CYC:OUT2 LPI      1
         CLB      PRNT:FLG              STAY IN CONTINUOUS COPY CYCLE
         AND      FLAG2,T
         CLB      CMD:FLG           ELSE:
         AND      FLAG3,T
CYC:OUT3 LPI      3                     CLEAR PRINT ENABLE FLAG
         MVI      PAGE:CNT,X'FF'
         MVI      STAT:PNT,CYCL:TBL     & ALSO COMM. ACKN. FLAG
         MVI      STAT:CNT,0
SAMP:RET RFS                        START CYCLE OUT EVENT
*
CK:B4    CPL      T
         JT       4,SAMP:OFF
         RFS
*
SAMP:OFF LPI      3
         MVI      PAGE:PNT,SYNC:LO
         RFS
*
         PAGE
*
***********************************
* EVENT 1 (CYCLE OUT STATE)       *
***********************************
DVL@OFF  CLB      DEV:CLU           TURN OFF THE DEVELOPER
         AND      ROUT3,T
         RFS
*
******************************
*  EVENT 2 (CYCLE OUT STATE) *
******************************
HV@OFF   CLB      HV:DC             TURN OFF THE COROTRONS
         AND      ROUT1,T
         CLB      SHUT:R            TURN OFF SHUTTER
         AND      ROUT2,T
         CLB      SHUT:FLG          CLEAR SHUTTER 50% DUTY CYCLE FLAG
         AND      FLAG3,T
         RFS
******************************
* EVENT 3 (CYCLE OUT STATE)  *
******************************
FUS@OUT  DIF
         CLB      FUS:ON            TURN OFF FUSER
         AND      FLAG3,T
         LPI      3
         MVI      STAT:CNT,0        RE-INITIALIZE  STATE COUNTER
         RFS                        FOR SUBSEQUENT CYCLE OUT EVENTS
*                                   (EXCEEDS 5100MS TIMER LIMIT)
*
******************************
* EVENT 4 (CYCLE OUT STATE)  *
******************************
DRV@OFF  CLB      MN:DRV            TURN OFF MAIN DRIVE
         AND      ROUT3,T
         MOV      T,FLAG2           IF: CYCLING OFFLINE
         CPL      T
         JT       OFF:FLG,OFF:DRRT
         LPI      2
         MVI      IOT:STAT,X'56'       PRELOAD OFF-LINE STATUS 'V'
OFF:DRRT RFS
*
*
***********************************
*   DIAGNOSTICS: HVPS ON EVENT    *
***********************************
*
DGN@HV   STB      HV:DC             TURN ON HVPS(COROTRONS)
         IOR      ROUT1,T
         RFS
         PAGE
*
******************************
* EVENT 5 (CYCLE OUT STATE)  *
******************************
*
BLD@OFF  MVI      T,X'BB'           TURN OFF INVERTER &
         AND      ROUT2,T           OFFSET SOLENOID.
         CLB      RUN:FLG           CLEAR RUN FLAG
         AND      FLAG2,T
         MOV      T,FLAG2
         CPL      T
         JT       OFF:FLG,CLR:FLG4
         CLB      OFF:FLG           IF: OFF LINE IS TRUE
         AND      FLAG2,T               CLEAR OFF LINE FLAG
CLR:FLG4 LPI      2
         MVI      T,X'FC'           RESTORE DIAGNOSTIC FLAGS
         AND      FLAG1,T
         MVI      OS:BYTE,0         CLEAR OFFSET FUNCTION REGISTER
         LPI      0
         MVI      KBD:REG,X'C0'     ENABLE KEYBOARD
         LPI      1
         MOV      T,FLAG2
         JT       SOFT:JAM,BLNK:ON  IF: SOFT JAM TRUE
         INP      T,IN0                   START 'C4' JAM BLINK
         CPL      T
         JT       ZAP:THM,DRV:RET   IF: FUSER UNDER TEMP.
         MOV      T,IN:ONE          ORIF: TRAY NOT SELECTED
         CPL      T                    DONT SEND STANDBY STATUS 'A'
         JT       TRAY:SW,DRV:RET
         LPI      2                    START DISPLAY BLINK
         MOV      T,FLAG1           IF: DIAG. MODE
         JT       DIAG:FLG,REF:DSP      PUT BACK DIAG CODE
SEN:STBY LPI      2                     ON THE DISPLAY
         LCB      IOT:STAT,X'58',SEND:A
         RFS                        IF: TRAY FULL STATUS 'X'
SEND:A   LPI      1                     DO NOT SEND 'A'
         MOV      T,ROUT0
         JT       OFF:LINE,OFF:STAT IF: OFF LINE MODE
         LPI      2                     PRELOAD OFF-LINE STATUS 'V'
         MVI      IOT:STAT,X'41'    ELSE:
DRV:RET  RFS                             PRELOAD ON-LINE STATUS 'A'
BLNK:ON  JMP      BL@ON
REF:DSP  LPI      0
         MOV      T,CPY:SEL         DISPLAY DIAG. CODE
         JMP      DSPLY
*
OFF:STAT LPI      2
         MVI      IOT:STAT,X'56'
         RFS
         PAGE
*
*********************************************************
* HARD JAM EVENTS:  LOOK FOR BREAKING OF INTERLOCKS AND *
* CLEARANCE OF PAPER DURING NEXT ZERO CROSSING.         *
*********************************************************
******************************
* EVENT   HARD  JAM STATE    *
******************************
*
***********************************
*   PAPER JAM DETECTION ROUTINE   *
***********************************
*
PPR:PATH MOV      T,IN:ZERO
         JT       REG:SW,CHK:E4     IF EITHER PAPER PATH SW IS MADE:
         JMP      E2:JAM               DECLARE 'E2' OR 'E4' JAM
CHK:E4   JT       EXIT:SW,PPR:RET   ELSE:
         JMP      E4:JAM                 IF: HARD JAM FLAG CLEAR
         MOV      T,FLAG2
         JT       JAM:FLG,OFF:DRRT       ANDIF: DIAG. MODE
PPR:RET  JMP      DSP:DIAG
************************************          PUT BACK DIAG CODE
*      'E2' JAM SET UP ROUTINE     *
************************************
*
E2:JAM   MVI      FAULTS,X'E2'      LOAD E2 FAULT CODE IN
         LPI      2                 DISPLAY REGISTER.
         MVI      IOT:STAT,X'44'    SEND STATUS 'D' TO SERVER
         JMP      DSP:BLNK          AND START DISPLAY BLINK
*
*
************************************
*      'E4' JAM SET UP ROUTINE     *
************************************
*
E4:JAM   MVI      FAULTS,X'E4'      LOAD E4 FAULT CODE IN
         LPI      2
         MVI      IOT:STAT,X'46'    SEND STATUS 'F' TO SERVER
DSP:BLNK LPI      1
         STB      JAM:FLG           SET HARD JAM FLAG
         IOR      FLAG2,T
         LPI      3
         MVI      PAP:CNT,X'FF'     STOP 3 MIN. WAIT TIMER
         LPI      0
         MVI      KBD:REG,X'FF'     DISABLE KEYBOARD
         JMP      BL@ON             START DISPLAY BLINK
*
         PAGE
********************************************************
*  TIMER 1 EVENTS; TRAIL EDGE AT REG SNAPSHOT, LEAD    *
*  EDGE AT EXIT SNAPSHOT, BILLING METER ON & OFF AND   *
*  REGISTRATION ROLLS DEACTUATION.                     *
********************************************************
*
************
* EVENT 1  *
********************************
*   REG. ROLLS TURN OFF EVENT  *
********************************
*
RR@OFF   CLB      REG:ROLL
         AND      ROUT3,T           TURN OFF REG ROLLS
         CLB      OFF:SET
         AND      ROUT2,T           TURN OFF OFFSET SOL.
         LPI      3
         MVI      STAK:CNT,0        START STACKER TIMER
         MVI      STAK:PNT,STK:TBL
         RFS
*
*
*
************
* EVENT 2  *
********************************
* TRAIL EDGE AT REG. JAM CHECK *
********************************
*
TE@REG   CAL      E2:JAM            DECLARE E2 JAM
         JMP      HRD:JAM           JUMP TO HARD JAM
*
*
**************
* EVENT 3    *
*********************************
*   LEAD EDGE @ EXIT JAM EVENT  *
*********************************
*
LE@EXIT  MVI      FAULTS,X'E3'      SET FAULT CODE TO 'E3'
         LPI      2
         MVI      IOT:STAT,X'45'    JAM  STATUS TO 'E'
         JMP      HRD:JAM
*
*
***********
* EVENT 4 *
***********
**************************************************
* TIMER 2 EVENTS:  TRAIL EDGE AT EXIT JAM CHECK. *
**************************************************
*
TE@EXIT  CAL      E4:JAM            SET UP E4 JAM
         JMP      HRD:JAM
*                                   & ENTER HARD JAM
         PAGE
*
****************************
* EVENT #4 (TIMER 1 EVENT) *
****************************
*  TURN BILLING METER OFF  *
****************************
BILL@OFF CLB      BIL:MTR1          TURN OFF THE BILLING METERS
         AND      ROUT3,T
         RFS
*
*
*****************************
*                           *
*   BLANK DISPLAY DURING    *
*   DISPLAY BLINK.          *
*                           *
*****************************
*
BL@OFF   LPI      0
         CLR      T                 CLEAR ONES & TENS
         MOV      DSP:ONES,T        DISPLAY REGS.
         MOV      DSP:TENS,T
         RFS
*
         PAGE
         ORG      X'400'
*
**********************************************************************
* STATE CHECKER:  UPDATE TIMERS WHEN APPROPRIATE, EXECUTE EVENTS THAT*
* HAVE TIMED OUT.                                                    *
**********************************************************************
STATE:CK LPI      3
         DIF
         DIM      TIMF              DISABLE TIMER INTERRUPT
         EIF                        (DIF & EIF  MUST PRECEED AND
*                                   FOLLOW RESPECTIVELY FOR DIM TIMF)
         MOV      T,DIVIDER         IF: DIVIDER HAS REACHED
         JT       7,STATE:1             THE LAST COUNTER
         MVI      DIVIDER,249           INITIALIZE POINTER TO (R57)
UP:DATE  DIF
         MOV      T,*DIVIDER            TO CHECK ALL STATE &
         CPL      T                     JAM COUNTERS
         JZ       NXT:CNT              IF COUNTER IS NOT X'FF'
         NEG      T                       THEN INCREMENT THAT COUNTER
         MOV      *DIVIDER,T
NXT:CNT  EIF
         IBNZ     DIVIDER,UP:DATE      CONT. LOOP UNTIL ALL CELLS CHKD
         MVI      DIVIDER,-4           REINIT. THE 20MS DIVIDER REG.
         LPI      1
         MOV      T,FLAG3
         CPL      T                 IF: DIAGNOSTICS 3-62
         JT       WDT:MEM,TMR:WD
         LPI      0
         LCB      CPY:SEL,X'62',TMR:WD   MAKE WDT FAIL
         JMP      STATE:1
TMR:WD   LPI      1
         STB      WDT:FLG           FLAG TO INDICATE TIMER INTERRUPT
         IOR      FLAG2,T           HAS OCCURRED.
STATE:1  EIM      TIMF              ENABLE TIMER INTERRUPT
         LPI      1
         MOV      T,FLAG3
         CPL      T
         JT       TMR:FLG,NO:TMR    IF: TIMER INT. HAS OCCURED
         JMP      CHK:REG
CHK:RET  LPI      1                     CHECK REG. SWITCH
         CLB      TMR:FLG               CLEAR TIMER INT. INDICATION
         AND      FLAG3,T               FLAG.
NO:TMR   LPI      2
         MVI      TBL:CNT,242       INITIALIZE TBL:CNT POINTER TO R50
         MVI      TIM:CNT,249       AND TIM:CNT TO R57
         LPI      1
         DIF                       D
         INP      T,IN1            TEST IF ZERO CROSSING INPUT
         JT       Z:XING,ST1         IS STILL HIGH
         EIM      EXTF             ELSE RE-ENABLE INTERUPT MASK
ST1      EIF
         MOV      T,FLAG2
         CPL      T
         JT       WDT:FLG,STATE:WT  IF: WDT FLAG IS NOT SET
         STB      WD:TMR                 DO SYSTEM RESET
         ADD      ROUT3,T           ELSE:
         CLB      WDT:FLG                 TOGGLE WDT
         AND      FLAG2,T
STATE:WT LPI      2
         MOV      T,*TBL:CNT        OBTAIN THE COUNT OF THE NEXT
         MPM      T,HIADDR(ST:TBL)   SCHEDULED EVENT FROM THE TABLE
         MOV      TEMP2,T
         MOV      T,*TIM:CNT        IF ITS TIME FOR THE NEXT EVENT:
         CMP      TEMP2,T              THEN GET THE ADR OF THAT EVENT
         JNZ      NEXT:CK
         DIF
         CAL      INCREM               INCREMENT THE POINTER TO NXT EV.
         MOV      T,TEMP2
         MPM      T,HIADDR(ST:TBL)
         EIF
         CAL      RGT:PAGE
         EIF
NEXT:CK  LPI      2
         IBNZ     TBL:CNT,NXT1     UPDATE TABLE AND TIMER COUNTERS
NXT1     IBNZ     TIM:CNT,STATE:WT
         JMP      STATE:CK           THEN BEGIN STATE CHECKER
*                                      AGAIN
         PAGE
*************************************
* DISPLAY 7 SEGEMENT ENCODE TABLE   *
* SEGMENTS OFF ARE ONES             *
*************************************
DSP:TBL  DB       X'3F'             DIGIT 0
         DB       X'06'             DIGIT 1
         DB       X'5B'             DIGIT 2
         DB       X'4F'             DIGIT 3
         DB       X'66'             DIGIT 4
         DB       X'6D'             DIGIT 5
         DB       X'7D'             DIGIT 6
         DB       X'07'             DIGIT 7
         DB       X'7F'             DIGIT 8
         DB       X'67'             DIGIT 9
         DB       X'9E'             DIGIT J
         DB       X'38'             DIGIT L
         DB       X'39'             DIGIT C
         DB       X'5E'             DIGIT D
         DB       X'79'             DIGIT E
         DB       X'71'             DIGIT F
*
*
******************************************************
* KEYBOARD DECODE TABLE                              *
* FUNCTIONS ARE ADDRESS INFORMATION, AND DIGITS ARE  *
* SEGMENT INFORMATION.                               *
******************************************************
KBD:TBL  DB       X'08'                   EIGHT
         DB       X'05'                   FIVE
         DB       ABSVAL(CLEAR:)&X'FF'    CLEAR
         DB       ABSVAL(OFFLINE:)&X'FF'  OFFLINE - SPARE
         DB       X'07'                   SEVEN
         DB       X'04'                   FOUR
         DB       X'00'                   ZERO
         DB       ABSVAL(ONLINE:)&X'FF'   ON LINE
         DB       X'06'                   SIX
         DB       X'03'                   THREE
         DB       X'09'                   NINE
         DB       ABSVAL(TEST:)&X'FF'     TEST
         DB       X'01'                   ONE
         DB       X'02'                   TWO
         DB       ABSVAL(OFFLINE:)&X'FF'  OFF LINE
         DB       ABSVAL(OFFLINE:)&X'FF'  OFF LINE
*
         PAGE
**************************************
**************************************
* STATE AND EVENT TABLE              *
**************************************
**************************************
*
*          *** CAUTION ***
*
*  USE 20.16 MS RESOLUTION FOR TABLE EVENTS.
*  TIMER INTERRUPT RESOLUTION HAS BEEN MODIFIED TO 5.04 MS
*  IN ORDER TO AVOID SYNCHRONIZATION WITH ZERO-XING.
*
*****************************************
*  STATE EVENTS                         *
*****************************************
* COLD START STATE *
********************
ST:TBL   DB       1                 20 MS
         DB       ABSVAL(START:C)&X'FF'
         DB       11                220 MS
         DB       ABSVAL(DRV:ON)&X'FF'
ST:TB1   DB       23                460 MS
         DB       ABSVAL(HV:ON)&X'FF'
         DB       41                820  MS
         DB       ABSVAL(SHUT:ON)&X'FF'
         DB       95                1920 MS
         DB       ABSVAL(DEV:ON)&X'FF'
*
*****************************
* DOCUMENT READY STATE      *
*****************************
REG:TBL  DB       61                1220 MS
         DB       ABSVAL(RR:ON)&X'FF'
PCYC:TBL DB       244               4920 MS
         DB       ABSVAL(PRE:CYC)&X'FF'
*
*
**************************
* TEST 1 PRINT STATE     *
**************************
TEST:TBL DB       21                420 MS
         DB       ABSVAL(TEST:ON1)&X'FF'
TEST:TBL1 DB      2                 40 MS
         DB       ABSVAL(TEST:OFF)&X'FF'
         DB       19                380 MS
         DB       ABSVAL(TEST:ON2)&X'FF'
*
         PAGE
***************************
*    FEEDER STATE         *
***************************
FD:TBL   DB       14                280  MS
         DB       ABSVAL(COP:FEED)&X'FF'
         DB       57                1150 MS
         DB       ABSVAL(SFT:JAM)&X'FF'
****************************
*  CYCLE  OUT STATE        *
****************************
CYCL:TBL DB       35                700  MS
         DB       ABSVAL(DVL:OFF)&X'FF'
         DB       86                1640 MS
         DB       ABSVAL(HV:OFF)&X'FF'
         DB       192               3880 MS
         DB       ABSVAL(FUS:OUT)&X'FF'
         DB       132               2660 MS
         DB       ABSVAL(DRV:OFF)&X'FF'
         DB       253               5100 MS
         DB       ABSVAL(BLD:OFF)&X'FF'
         DB       254               5120 MS
         DB       ABSVAL(FAN:CNT)&X'FF'
*
*******************************
*    STACKER CONTROL STATE    *
*******************************
*
STK:TBL  DB       183               3688 MS
         DB       ABSVAL(INV:ON)&X'FF'
INV:TBL  DB       6                 120  MS
         DB       ABSVAL(INV:OFF)&X'FF'
         DB       66                1330 MS
         DB       ABSVAL(OFST:OFF)&X'FF'
         DB       0
*
INV:TBL2 DB       84                1700 MS
         DB       ABSVAL(INV:OFF)&X'FF'
         PAGE
*
********************************
*  TIMER 2 EVENT TABLE         *
********************************
TAT:EXIT DB       32                650  MS
         DB       ABSVAL(TE:EXIT)&X'FF'
BIL:TBL  DB       37                750  MS
         DB       ABSVAL(BILL:OFF)&X'FF'
         DB       0
****************************
* TIMER 1 EVENT TABLE      *
****************************
TAT:REG  DB       206               4160 MS
         DB       ABSVAL(TE:REG)&X'FF'
RR:TBL   DB       213               4300 MS
         DB       ABSVAL(RR:OFF)&X'FF'
LAT:EXIT DB       225               4540 MS
         DB       ABSVAL(LE:EXIT)&X'FF'
***************************
* BLINK TABLE FOR TIMER 2 *
***************************
BL:FLT   DB       33                660 MS
         DB       ABSVAL(BL:OFF)&X'FF'
DIS:OFF  DB       50                1000 MS
         DB       ABSVAL(BL:ON)&X'FF'
         DB       0
*
*************************
*  JAM STATE            *
*************************
JAM:HRD  DB       70                1400 MS
         DB       ABSVAL(DRV:OFF)&X'FF'
         DB       72
         DB       ABSVAL(OLINE:V)&X'FF'
         DB       75                1500 MS
         DB       ABSVAL(BILL:OFF)&X'FF'
*****************************
* 3 SEC/COPY FAN ON TIME;   *
* TIMER 1                   *
*****************************
TIM:TBL  DB       149               3000 MS
         DB       ABSVAL(FAN:CNT)&X'FF'
         DB       0
*
*******************************
*   GO TO SLEEP EVENT         *
*******************************
*
SLP:TBL  DB       213               4300 MS
         DB       ABSVAL(ST:SLEEP)&X'FF'
         DB       200               4000 MS
         DB       ABSVAL(SLEEP:)&X'FF'
         PAGE
*
*****************************
*   PAGE SYNC. TABLE        *
*****************************
*
SYNC:UP  DB       193               3880 MS
         DB       ABSVAL(SYNC:OUT)&X'FF'
*
SYNC:LO  DB       186               3740 MS
         DB       ABSVAL(SYNC:OUT)&X'FF'
*
***************************
*   STANDBY TABLE         *
***************************
*
MIN:TBL  DB       149               3000 MS
         DB       ABSVAL(MIN:LOOP)&X'FF'
*
*********************************
*  LEDS ON & DISPLAY ON WITH '88'  *
*********************************
*
TKEY:TBL DB       10                200 MS
         DB       ABSVAL(DSP:OFF)&X'FF'
         DB       0
*
*
*******************************
*   REAL TIME DISPLAY TABLE   *
*******************************
*
RT:DSP   DB       1
         DB       ABSVAL(DSP:SECS)&X'FF'   REAL TIME DISPLAY
         DB       33                660 MS.
         DB       ABSVAL(DSP:BLN)&X'FF'
MIL:SEC  DB       49                580 MS.
         DB       ABSVAL(DSP:MS)&X'FF'
         DB       82                164 MS.
         DB       ABSVAL(DSP:BLNO)&X'FF'
         DB       0
*
**************************************
* DIAGNOSTICS: HIGH VOLTAGE ON EVENT *
**************************************
*
DIAG:TBL DB       23                460 MS
         DB       ABSVAL(DGN:HV)&X'FF'
         DB       0
*
DIA:TBL2 DB       55                1100 MS
         DB       ABSVAL(SET:SFLG)&X'FF'
         DB       254
         DB       ABSVAL(DEV:RET)&X'FF'
         DB       254
         DB       ABSVAL(DEV:RET)&X'FF'
         PAGE
***************************************
*        FUSER CONTROL FOR MOHAWK     *
*                                     *
*        FULL CYCLE CONTROL OVER 16   *
*        FULL CYCLE PERIOD.           *
*        16 BIT PATTERN ROTATED       *
*        EVERY OTHER ZERO CROSSING    *
*        CONTROLS DUTY CYCLE AND      *
*        PROVIDES VOUT=VIN(ROOT N/16) *
*                                     *
*        OPERATING PERIOD IS=16/LF    *
***************************************
*
*        USES PAGE 1 RAM CELLS
         ORG      X'500'           $$$$$$$$$$$$$$$$$$$$$$$$$$$$
*
FUSER    MOV      T,FLAG3
         JT       FUS:ON,FUSER:ON   IF FUSER FLAG IS OFF
         CLB      7                    RESET NEW ADVAL FLAG
         AND      ADVAL,T
         JMP      GO:ZAP               JUMP TO CK FOR ZAP CONDITION
FUSER:ON MOV      T,ADVAL
         JT       7,REGULATE
         MOV      ADVAL,ADC         STORE ADC VALUE
         LPI      2
         MOV      T,FLAG1
         CPL      T
         JT       CN10:FLG,DO:PAT   IF: DIAGNOSTIC FLAG IS SET
         LPI      0                 ANDIF: DIAGNOSTICS #1
         LCB      CPY:SEL,X'71',DO:PAT
         LPI      1
         MOV      T,ADVAL
         MOVD     DGN:SAV,T
         CAL      REAL:
         LPI      0
         MOV      T,DGN:SAV            DISPLAY A/D VALUE
         MOV      SECS,T               & SAVE IT TWICE
DO:PAT   LPI      1
         EQU  $
         MVI  T,MID:ADC-1       IF ADVAL<35
         CMP  ADVAL,T
         JRGT DET04
*                                   START AT MIDDLE OF TABLE
         MVI  CUR:PTR,(ABSVAL(FTABL)&X'FF')+56
         JMP  DET05             ELSE
DET04    EQU  $                     START AT THE TOP OF THE TABLE
         MVI  CUR:PTR,ABSVAL(FTABL)&X'FF'
DET05    EQU  $                 ENDIF
         MVI  FMASK,-9
DET02    MOV  T,CUR:PTR         DO WHILE @CUR:PTR =< ADVAL
         MPM  T,HIADDR(FTABL)
         CMP  ADVAL,T
         JRGT DET03
         JEQ  DET03
         MVI  T,7                   ADVANCE CUR:PTR
         ADD  CUR:PTR,T
         IJNZ FMASK,DET02       ENDDO WHILE NOT PAST END OF TBL
DET03    EQU  $
DET01    EQU  $             ENDIF
END:SET  STB  7             SET NEW:ADC FLAG IN ADVAL
         IOR  ADVAL,T
         MOV      T,CUR:PTR
         MOVD     SOP:PTR,T         INIT. FUSER PATTERN POINTERS
         MVI      FMASK,0
*
**************************************************
*
*        ADVANCE PATTERN PTRS AND REGULATE
*
*        INPUTS - FMASK, CUR:PTR, SOP:PTR
*        OUTPUTS - FMASK, CUR:PTR, FUS:LMP BIT
*
***************************************************
REGULATE MOV  T,FMASK       SHIFT FMASK LEFT ONE BIT
         ADD  FMASK,T
         JNZ  ADV00         IF FMASK = 0 (BIT OFF LEFT END)
         STB  0                 REINITIALIZE MASK TO 1
         MOV  FMASK,T
         MVI  T,-1              DECR CUR:PTR
         ADD  CUR:PTR,T
         MOVD T,SOP:PTR         IF CUR:PTR PAST END OF PATTERN
         CMP  CUR:PTR,T
         JRGT ADV01
         MVI  CUR:PTR,6             CUR:PTR TO BEG. OF PATTERN
         ADD  CUR:PTR,T
         MVI      FMASK,2
ADV01    EQU  $                 ENDIF
ADV00    EQU  $             ENDIF
         MOV  T,CUR:PTR     IF @CUR:PTR (AND) MASK <> 0
         MPM  T,HIADDR(FTABL)
         MOV  TEMP1,T
         MOV  T,FMASK
         AND  TEMP1,T
         JZ   ADV02
         STB  FUS:LMP           TURN ON FUSER LAMP
         IOR  ROUT3,T
         JMP  ADV03         ELSE
ADV02    EQU  $
GO:ZAP   CLB  FUS:LMP           TURN OFF FUSER LAMP
         AND  ROUT3,T
ADV03    EQU  $             ENDIF
*******************************************************
* CHECK ZAP THERMOSTAT TO SEE IF UNDER TEMP OR NOT.   *
*******************************************************
*
CK:ZAP   MOV      T,FLAG2
         JT       RUN:FLG,FU:NO:ZP    IF: LAST JOB COMPLETED
         MOV      T,IN:ZERO
         JT       ZAP:THM,FU:NO:ZP  ANDIF THERMOSTAT REQUESTS ZAP
         CPL      T
         JT       REG:SW,END:FUS    ANDIF BOTH PAPER PATH SWITCHES CLEAR
         JT       EXIT:SW,END:FUS
         MOV      T,FLAG2
         JT       ZAP:FLG,AROUND    ANDIF NOT ALREADY NOT ZAPPING
         CLB      FAN               TURN OFF FAN
         AND      ROUT3,T
         MVI      FAULTS,X'B1'      DISPLAY  'L1'
         CAL      DSP:FLT
         LPI      2
         MVI      IOT:STAT,X'40'    LOAD FUSER UNDERTEMP STATUS
AROUND   LPI      1
         STB      ZAP:FLG           SET ZAP FLAG TO INDICATE ZAP MODE
         IOR      FLAG2,T
         STB      FUS:ON            AND TO TURN ON FUSER TRIAC
         IOR      FLAG3,T
         LPI      0
         MVI      KBD:REG,X'FF'     DISABLE KEYBOARD
END:FUS  RFS
FU:NO:ZP MOV      T,FLAG2
         CPL      T                 IF: FUSER ZAP CYCLE IS OVER
         JT       ZAP:FLG,END:FUS
         MOV      T,ROUT0              IF: 3 MIN. WAIT ACTIVE
         JT       OFF:LINE,ST:BY           STAY IN WAIT STATE
STND:BY  MOV      T,FLAG3               ELSE:
         JT       WAIT:FLG,WAIT@           ENTER STANDBY
ST:BY    MOV      T,IN:ZERO                  SEND STATUS 'A'
         CPL      T                       CLEAR DISPLAY & FLAGS
         JT       ZAP:THM,BLNK:
         CAL      SEND:A
         CAL      INI:SL                  START GOTO SLEEP TIMER
BLNK:    CAL      BLNK:DSP
STBY:RET CLR      T
         MOV      FLAG2,T
         MVI      T,X'20'
         AND      FLAG3,T
         LPI      0
         MVI      KBD:REG,X'C0'          ENABLE KEYBOARD
         LPI      1
         RFS
*
WAIT@    CAL      WAIT:
         LPI      1
         JMP      STBY:RET
         PAGE
*
******************************
*        SEND OFFLINE STATUS IN CASE
*        OF JAM WHILE CYCLING OFF
*        LINE
*******************************************
*
*
V:OLINE  MOV      T,FLAG2           IF OFF FLAG TRUE,
         CPL      T                 SEND THE OFF LINE STATUS
         JT       OFF:FLG,END:V     NOW AND RESET THE FLAG
         MVI      T,X'56'
         OUT      DATA:RW,T
         CLB      OFF:FLG
         AND      FLAG2,T
END:V    RFS
*
         PAGE
*
**********************************
*                                *
* PAGE SYNC STATUS IS SENT TO    *
* SERVER WHEN SYN:CNT TIMES OUT  *
*                                *
**********************************
*
SYNC@OUT MOV      T,FLAG2
         JT       OFF:FLG,PGE:SYNC     IF: OFF LINE KEY PUSHED
         MOV      T,ROUT0                   DURING ONLINE MODE
         JT       OFF:LINE,SET:TMRS    ORIF: ON LINE MODE
PGE:SYNC CAL      TX:RDY                  IF: TXRDY IS TRUE
         MVI      T,X'52'                     SEND PAGE SYNC. 'R'
         OUT      DATA:RW,T                  IMMEDIATELY
SET:TMRS LPI      3                 INITIALIZE TIMERS FOR
         MVI      PAP:PNT,FD:TBL    REG ROLLS ON & FEEDER ON
         MVI      PAP:CNT,0         EVENTS.
         MVI      STAT:PNT,REG:TBL
         MVI      STAT:CNT,0
         LPI      1
         MOV      T,ROUT0
         JT       ON:LINE,SYNC:RET   IF: OFF LINE ACTIVE
         LPI      2
         MOV      T,FLAG1
         JT       CONT:FLG,SYNC:RET
         JT       CHN3:FL     TEST:PAT          ELSE:
NEXT1    LCB      CPY:SEL,2,CHN:31       IF: TEST MODES 0,1 & 2
         JMP      TEST:PAT
S:TEST   LPI      0                      ORIF: DIAGNOSTICS 3-1
CHN:31   LCB      CPY:SEL,X'31',CHN32    ORIF: DIAGNOSTICS 3-2
         JMP      TEST:PAT
CHN32    LCB      CPY:SEL,X'32',SYNC:RET
TEST:PAT LPI      3
         MVI      TEST:PNT,TEST:TBL
         MVI      TEST:CNT,0                   START TEST PATTERN TIMER
SYNC:RET RFS
*
         PAGE
         ORG      X'600'
***************************************
*                                     *
* START UP POWER ON RESET             *
*                                     *
***************************************
START:UP DIF
         CAL      STRT:UP2          SAVE ADDRESS OF NO:STRT ON STACK
*
NO:STRT  JMP      NO:STRT           ONLY WAY TO GET HERE IS
*                                   VIA AN EXTRA RFI OR RFS.
STRT:UP2 LPI      0
         CAL      CHK:MEM           CHECK RAMS & ROMS
         CAL      USRT:RS           CLEAR USART BUFFERS
         CAL      USRT:INI          INITIALIZE USART
         CAL      IN:COL2           READ ZERO KEY
         JT       2,ON:LED          IF: ZERO KEY DEPRESSED
         INP      T,IN0             ANDIF: DOOR INT'LOCK MADE
         CPL      T
         JT       DOOR:ILK,ON:LED
         CAL      DSP:FLT
         LPI      0
         MVI      KBD:REG,X'C0'     SUPPRESS ZERO BUT ENABLE KYBD
         LPI      2                      DISPLAY 2L
         STB      DIAG:FLG              ENABLE DIAGNOSTICS
         IOR      FLAG1,T
         LPI      1
         MVI      ROUT0,X'84'           OFF LINE LED ON &
         MVI      T,X'56'
         OUT      DATA:RW,T             SEND OFF LINE STATUS 'V'
         JMP      PORT:0            ELSE:
ON:LED   LPI      1
         LCB      FAULTS,X'BB',LEDS:ON
         MVI      T,X'38'               IF: CHECKSUM FAILURE
         OUT      OUT0,T
LB:OUT   STB      LED:TEN                   DISPLAY 'LL'
         OUT      OUT1,T
         IBNZ     TEMP1,LB:OUT              & MULTIPLEX IT
BL:OUT   STB      LED:ONE                   @ 5 MS. PER SEGMENT
         OUT      OUT1,T                     RATE.
         IBNZ     TEMP1,BL:OUT
         CLR      T
         OUT      OUT1,T            TURN OFF THE MUX STROBES
         JMP      START:UP                  DO NOT POWER UP
LEDS:ON  MVI      ROUT0,X'88'
PORT:0   OUT      OUT0,ROUT0             ELSE:
         LPI      3                           TURN ON ON-LINE LED
         MVI      T,X'FF'                   & DISPLAY '2L'
         MOV      TEST:CNT,T
         MOV      PAGE:CNT,T
         MOV      PAP:CNT,T         TURN OFF ALL TIMERS
         MOV      STAT:CNT,T
         MOV      TIM1:CNT,T
         MOV      STAK:CNT,T
         MOV      TIM2:CNT,T
         LPI      1
         MOV      T,ROUT0           IF: NOT DIAGNOSTIC MODE
         JT       OFF:LINE,SET:WDT
         LPI      2
         MVI      LOOP:CNT,-60          SET STANDBY TO 3 MINUTES
         CAL      WAIT:
SET:WDT  LPI      1
         INP      IN:ZERO,IN0       READ INITIAL INPUTS
         INP      IN:ONE,IN1
         CAL      PPR:CK            CHECK PAPER PATH
         CAL      TIMR:ON
         EIM      EXTF              ENABLE THE EXTERNAL INTERRUPTS
         EIF                        ENABLE THE SYSTEM INTERRUPTS
         JMP      STATE:CK          WAIT FOR A CHANGE IN STATE
*
CHK:MEM  MVI      R0,62
         LCB      R0,62,RAM:FAIL    IF: REG.R0 DOES NOT COMPARE
         MVI      R0,-63                WITH COMPLEMENT OF -63 AND -63
         LCB      R0,X'C1',RAM:FAIL
*                                       DECLARE RAM FAILURE
FIL:REG  MOV      T,R0
         MOV      *R0,T
         IBNZ     R0,FIL:REG        FILL ALL RAM REGS WITH
*                                   RELATIVE ADDRESSES
         MVI      R0,-63
REG:CHK  MOV      T,*R0
         CMP      R0,T              COMPARE RAM  WITH REL ADDR.
         JNZ      RAM:FAIL          IF: RAM REG  NOT EQUAL
         IBNZ     R0,REG:CHK            DECLARE RAM FAILURE
*
         MVI      R0,-63
FIL:REGC MOV      T,R0
         CPL      T
         MOV      *R0,T             FILL ALL RAM REGS. WITH
         IBNZ     R0,FIL:REGC       COMPLEMENT OF REL. ADDR.
*
         MVI      R0,-63
REG:CHKC MOV      T,*R0
         CPL      T                 COMPARE RAM REG. WITH
         CMP      R0,T              COMPLEMENT OF REL. ADDR.
         JNZ      RAM:FAIL          IF: RAM REG. NOT EQUAL
         IBNZ     R0,REG:CHKC           DECLARE RAM FAILURE
*
         CLR      T
         MVI      R0,-63            IF: RAM REGS. O.K
CLR:RAMS MOV      *R0,T
         IBNZ     R0,CLR:RAMS           CLEAR ALL RAMS
         MVI      KBD:REG,X'70'
         STB      WD:TMR            ALLOW APPROX. 60 MS.
         OUT      OUT3,T            FOR WDT TOGGLE.
*
SUM0     MOV      T,R0
         MPM      T,0
         ADD      R1,T
         MOV      T,R0
         MPM      T,1
         ADD      R1,T
         MOV      T,R0
         MPM      T,2
         ADD      R1,T              ADD CONTENTS OF ALL ROM
         MOV      T,R0              LOCATIONS TO R1.
         MPM      T,3
         ADD      R1,T
         MOV      T,R0
         MPM      T,4
         ADD      R1,T
         MOV      T,R0
         MPM      T,5
         ADD      R1,T
         MOV      T,R0
         MPM      T,6
         ADD      R1,T
         MOV      T,R0
         MPM      T,7
         ADD      R1,T
         MOV      T,R0
         MPM      T,8
         ADD      R1,T
         MOV      T,R0
         MPM      T,9
         ADD      R1,T
         MOV      T,R0
         MPM      T,X'A'
         ADD      R1,T
         MOV      T,R0
         MPM      T,X'B'
         ADD      R1,T
         MOV      T,R0
         MPM      T,X'C'
         ADD      R1,T
         MOV      T,R0
         MPM      T,X'D'
         ADD      R1,T
         MOV      T,R0
         MPM      T,X'E'
         ADD      R1,T
         MOV      T,R0
         MPM      T,X'F'
         ADD      R1,T
         IBNZ     KBD:REG,INC:R0
         CLR      T
         OUT      OUT3,T            WDT TOGGLE
INC:R0   IBNZ     R0,SUM0
*
         NEG      T                 SUBTRACT THE VALUE OF THE
         ADD      R1,T              CHECKSUM BYTE (LOC FFF CONTENTS
         NEG      T                 STILL IN T REG)
         CMP      R1,T              COMPARE THE SUM TO CHECKSUM BYTE
*
         LPI      1
         MVI      FAULTS,X'3B'
         JEQ      DSP:2L            IF: CHECKSUM FAILED
RAM:FAIL LPI      1
         MVI      FAULTS,X'BB'          DISPLAY LL
DSP:2L   RFS
*
*
         PAGE
*
         ORG      X'700'
*
**********************************
*    GO TO SLEEP EVENT; TIMER 1  *
**********************************
*
ST@SLEEP MOV      T,FLAG3           IF: 3 MINUTE WAIT STATE
         JT       WAIT:FLG,SLP:RET      RETURN
         LPI      2
         MOV      T,FLAG1
         CPL      T
         JT       DIAG:FLG,INC:SLP  IF: DIAG. MODE
         LCB      LOOP:CNT,43,INC:SLP
         CAL      DIAG:OFF             TURN OFF DIAG. OUTPUTS
INC:SLP  LPI      2
         LCB      LOOP:CNT,0,INC:FCTR    AFTER 3 MIN.
         JMP      INC:LCTR
INC:FCTR IBNZ     LOOP:CNT,INI:STBL IF: OUTTER COUNTER = 0
INC:LCTR IBNZ     FAN:CTR,INI:FCTR  ANDIF: INNER COUNTER = 0
         LPI      3
         MVI      TIM1:CNT,0           SEND ABOUT TO GOTO
         LPI      2                    SLEEP STATUS ASCII 'Y'
         MVI      IOT:STAT,X'59'
         RFS                             INITIALIZE OUTTER COUNTER
*                                        & GO TO SLEEP EVENT TABLE
INI:FCTR MVI      LOOP:CNT,-255
INI:STBL LPI      3
         MVI      TIM1:CNT,0
         MVI      TIM1:PNT,SLP:TBL
SLP:RET  RFS
*
*
*******************************
*   ENTER GOTO SLEEP STATE    *
*******************************
*
SLEEP@   MOV      T,ROUT0
         JT       OFF:LINE,SLP:RET
         LPI      2
         LCB      IOT:STAT,X'59',SLP:RET
         LPI      1
         STB      GO:SLEEP          IF: STATUS 'Y'; ABOUT TO GOTO SLEEP
         IOR      ROUT2,T           ANDIF: ON-LINE MODE
         RFS                          GOTO SLEEP NOW
         PAGE
*
*************************************
*                                   *
* REGISTRATION SWITCH INTERROGATION *
* DONE IN STATE CHECKER.            *
*                                   *
*************************************
CHK:REG  MOV      T,ROUT3
         JT       MN:DRV,CK:EXSW    IF: MAIN DRIVE IS OFF
         STB      TEST:1
         IOR      ROUT2,T               TURN OFF A/O MOD.
         JMP      CHK:RET
*
CK:EXSW  JMP      EXIT:CK           ELSE:
EXT:RET  LPI      1                      IF: EXIT SW. JAM TIMER ACTIVE
         INP      T,IN0                     CHECK EXIT SW
         JT       REG:SW,TE:LOOK         ELSE
         MOV      T,FLAG3                    INTERROGATE REG SW.
         JT       REG:FLG,BUCKLE
         STB      REG:FLG                    IF LEAD EDGE IS FOUND
         IOR      FLAG3,T
         MVI      COUNTER,-14                  INIT. FEEDER BUCKLE
         MOV      T,ROUT0                      TIMER TO 70.56 MS.
         JT       ON:LINE,FEED:OFF
         LPI      0
         LCB      CPY:SEL,X'51',CK:55
         JMP      DSP:TIM
CK:55    LCB      CPY:SEL,X'55',FEED:OFF
DSP:TIM  MOVD     T,PAP:CNT         IF:DIAG. 8-51 OR 8-55
         MOV      DGN:SAV,T            DISPLAY TIME BETWEEN FEEDERS
         CAL      REAL:TIM             ON AND REG SW. ACTUATION.
FEED:OFF JMP      CHK:RET
*
BUCKLE   IBNZ     COUNTER,REG:END
         MOV      T,ROUT1
         JT       UP:TRAY,FDR:OFF   IF: FEEDERS ARE ON
         JT       LWR:TRAY,FDR:OFF  ANDIF: 70.56 MS. AFTER
         JMP      CHK:RET                   LE@REG
FDR:OFF  CLB      UP:TRAY
         AND      ROUT1,T
         CLB      LWR:TRAY             TURN OFF FEEDERS
         AND      ROUT1,T
         OUT      OUT1,ROUT1           LOAD PAPER SEQUENCE CODE
         JMP      CHK:RET
*
TE:LOOK  MOV      T,FLAG3
         CPL      T
         JT       REG:FLG,REG:END   IF: TRAIL EDGE AT REG. SW.
         CLB      REG:FLG              RESET LE@REG FLAG
         AND      FLAG3,T
         LPI      1
         MOV      T,ROUT0
         JT       ON:LINE,LE:TIMR
         LPI      2
         MOV      T,FLAG1
         CPL      T
         JT       CONT:FLG,LE:TIMR    IF: OFF LINE KEY
         LPI      0                       DISABLE DIAG. 8-52
         LCB      CPY:SEL,X'52',LE:TIMR
         MOVD     T,TIM1:CNT        IF: DIAG. 8-52
         MOV      DGN:SAV,T            DISPLAY TIME BETWEEN REG ROLLS ON
         CAL      REAL:TIM             AND REG SWITCH DEACTUATION.
LE:TIMR  LPI      3
         MVI      TIM1:PNT,RR:TBL      BUMP POINTER FOR LE@EXIT CHECK
REG:END  JMP      CHK:RET
*
*
*
*
****************************************
*        EXIT SWITCH INTERROGATION     *
****************************************
*
EXIT:CK  LPI      3
         MVI      T,LAT:EXIT
         CMP      TIM1:PNT,T        IF: POINTER @ LE@EXIT
         JNE      E4:CHK                CHECK EXIT SW.
         LPI      1
         MOV      T,IN:ZERO
         JT       EXIT:SW,LECK:RET  IF: EXIT SW IS MADE
         MOV      T,ROUT0
         JT       ON:LINE,BMP:TIM1
         LPI      0
         LCB      CPY:SEL,X'53',BMP:TIM1
         MOVD     T,TIM1:CNT        IF: DIAGNOSTICS 8-53
         MOV      DGN:SAV,T
         CAL      REAL:TIM             DISPLAY EXIT SW. DE-ACT.
BMP:TIM1 LPI      3                    TIME FROM INVERTER ON EVENT.
         MVI      TIM1:PNT,BL:FLT
LECK:RET JMP      CHK:RET           BUMP E3 JAM TIMER
         PAGE
*
***************************
* TRAIL EDGE @ EXIT CHECK *
***************************
*
E4:CHK   MVI      T,TAT:EXIT
         CMP      TIM2:PNT,T        IF: TE@EXIT TIMER SET
         JNE      E4:FIN
*
         LPI      1
         MOV      T,IN:ZERO         ANDIF: EXIT SW. DE-ACTUATED
         CPL      T
         JT       EXIT:SW,E4:FIN
         LPI      3
         MVI      TIM2:PNT,BIL:TBL     BUMP TE@EXIT TIMER TO
         LPI      1                    BILLING METER OFF EVENT
         MOV      T,ROUT0
         JT       ON:LINE,TE:EX1
         LPI      0
         LCB      CPY:SEL,X'54',TE:EX1
         MOVD     T,TIM2:CNT
         MOV      DGN:SAV,T         IF: DIAGNOSTICS 8-54
         CAL      REAL:TIM             DISPLAY REG.SW DEACTUATION
TE:EX1   CAL      CHK:STAK             TO EXIT SW. DE-ACTUATION TIME
         LPI      1
         STB      BIL:MTR1
         IOR      ROUT3,T           CHECK STACKER
         MOV      T,FLAG2           TURN ON PRINT COUNTER
         JT       OFF:FLG,PAGE:DEL      ( BILLING METER )
         MOV      T,ROUT0
         JT       OFF:LINE,E4:FIN   IF: OFF LINE KEY PRESSED DURING
PAGE:DEL CAL      TX:RDY                ON LINE MODE.
         MVI      T,X'53'           ORIF: ON LINE MODE
         OUT      DATA:RW,T              IF: TRANSMIT READY
E4:FIN   JMP      EXT:RET                    SEND PAGE DELIV.
*                                            STATUS 'S'
          PAGE
*********************************************************
*        DISPLAY ROUTINES
*********************************************************
*
*
*
***************************************************************
*********ROUTINE TO PUT A CHARACTER ON THE DISPLAY*************
***************************************************************
*
DSPLY    LPI      0
         MOV      TEMP4,T           SAVE CHARACTERS
         MOV      TEMP5,T
*
         MVI      T,X'0F'           ISOLATE LOW ORDER CHARACTER
         AND      TEMP4,T
*
         CPL      T                 ISOLATE HIGH ORDER
         AND      TEMP5,T
*
         MVI      T,DSP:TBL         GET SEGMENT PATTERN FOR
         ADD      TEMP4,T           LOW ORDER CHARACTER
         MOV      T,TEMP4
         MPM      T,HIADDR(DSP:TBL)
         MOV      DSP:ONES,T
*
SF:O     MVI      T,X'0F'           SET UP LOOP
         CMP      TEMP5,T           TO COUNTER #
         JGE      SF:1              IN HIGH ORDER
         MVI      T,-16
         ADD      TEMP5,T           ACCUMMULATE #
         STB      0                 IN LOW ORDER
         ADD      TEMP5,T
         JMP      SF:O
*
SF:1     MVI      T,DSP:TBL
         ADD      TEMP5,T
         MOV      T,TEMP5           GET SEGMENT PATTERN
         MPM      T,HIADDR(DSP:TBL)   FOR 10'S DIGIT
         MOV      DSP:TENS,T
*
         MVI      T,X'3F'           SURPRESS LEADING 0'S
         CMP      DSP:TENS,T
         JNE      :OK
         MOV      T,ZERO:FLG
         JT       1,:OK
         MVI      DSP:TENS,BLANK:
:OK      RFS
*
         PAGE
*
***********************************
* EVENT #1  HARD JAM DUMMY STATE  *
* IMMEDIATE SHUTDOWN TO AVOID FIRE*
***********************************
*
HRD:JAM  LPI      1
         STB      PRNT:FLG          SET COLD START FLAG
          IOR       FLAG2,T
         CLR      T                 CLEAR FLAG3 BYTE
          AND       FLAG3,T
         LPI      2
         AND      FLAG1,T           CLEAR DIAG.  FLAGS
         AND      OS:BYTE,T         CLEAR OFFSET REG.
         LPI      1
         STB      INVERT            TURN ON INVERTER
         IOR      ROUT2,T
         MVI      T,X'87'           TURN OFF ALL OUTPUTS EXCEPT
         AND      ROUT3,T           BLADE,FAN & MAIN DRIVE
         STB      JAM:FLG           SET  HARD JAM FLG TO FORCE
         IOR      FLAG2,T           BREAKING OF INTERLOCKS.
         LPI      0
         MVI      KBD:REG,X'FF'
         LPI      3
         MVI      STAK:CNT,0        TURN OFF INVERTER AFTER 1.7 SEC.
         MVI      STAK:PNT,INV:TBL2
         LPI      1
         MVI      T,X'B7'           TURN OFF SHUTTER & OFFSET
         AND      ROUT2,T
         CLB      SOFT:JAM          CLEAR SOFT JAM FLAG
         AND      FLAG2,T
         CAL      BL:ON
CK:DR    LPI      1
         MVI      T,X'07'           TURN OFF PAPER FEED CLUTCHES
         AND      ROUT1,T           AND HIGH VOLTAGE DC.
         LPI      3
         CLR      T
         MOV      STAT:CNT,T        RESET THE STATE EVENT COUNTER
         MVI      STAT:PNT,JAM:HRD   AND THE POINTER TO HARD JAM
         CPL      T                 DISABLE ALL OTHER COUNTERS
         MOV      PAGE:CNT,T        TO PREVENT MULTIPLE JAMS
         MOV      TEST:CNT,T
         MOV      PAP:CNT,T
         MOV      TIM1:CNT,T
         RFS
         PAGE
************************************************
*    THIS SUBROUTINE IS USED BY TEST KEY       *
************************************************
STRT:SUB LPI      1
         MOV      T,FLAG3
         JT       WAIT:FLG,END:ST   IF: 3 MINUTES WAIT STATE
         MOV      T,FLAG2
         JT       JAM:FLG,END:ST    ORIF: HARD JAM CONDITION
         JT       ZAP:FLG,END:ST    ORIF: ZAP CONDITION
         CPL      T
         JT       SOFT:JAM,BL:DSP       SEND COMMAND NOT ACCEPTED
         CLB      SOFT:JAM              ILLEGAL SEQUENCE 'O'- RETURN
         AND      FLAG2,T           ELSE:
BL:DSP   CAL      DSP:DIAG               BLANK DISPLAY
         LPI      2
         CLR      T
         MOV      DISPLAY,T             CLEAR DISPLAY REG.
         LPI      3
         MVI      STAT:PNT,ST:TBL        SET STATE POINTER TO START COLD
         MOV      STAT:CNT,T
CK:TIMR1 LPI      3
         MVI      T,LAT:EXIT
         CMP      TIM1:PNT,T       IF TIM1 PNTR AT TIM:TBL OR >
         JRLE     END:STRT           STOP TIM1 CNTR
         MVI      TIM1:CNT,X'FF'
END:STRT LPI      1
         JMP      WT@REST
END:ST   MOV      T,ROUT0           IF: THIS ROUT. IS CALLED
         JT       ON:LINE,SAVE@         VIA USART INTERRUPT
WT@REST  MOV      T,ROUT0
         JT       OFF:LINE,RETN:       RETURN TO RESTORE IN ZERO:XING
         JMP      RESTORE
SAVE@    JMP      SAVE:             ELSEIF: CALLED VIA TEST KEY
RETN:    RFS
*                                         RETURN TO WTREST IN ZERO:XING
*
*
DSP:DIAG MOV      T,ROUT0
         JT       OFF:LINE,REF@DSP  IF: OFF LINE ; REF. DISPLAY
         LCB      FAULTS,X'C4',CHK:C3
         CAL      BLNK:DSP          IF: C4 JAM; BLANK DISPLAY
CHK:C3   LCB      FAULTS,X'C3',TEST:RUN
         CAL      BLNK:DSP          IF: C3 JAM; BLANK DISPLAY
TEST:RUN MOV      T,FLAG2           IF: RUN FLG; DON'T BLANK
         JT       RUN:FLG,RETN:     THE DISPLAY
         JMP      BLNK:DSP          ANDIF: KEY ENTRY IS NOT ZERO
REF@DSP  CAL      BLNK:OFF
         LPI      0                      DISPLAY KEY ENTRY
         LCB      CPY:SEL,0,DSP:ON  ELSE:
         JMP      BLNK:DSP               BLANK DISPLAY
DSP:ON   JMP      REF:DSP                & SEND STANDBY STATUS 'A'
         PAGE
*****************************************************
*  SYSTEM ROUTINE TO INCREMENT TO NEXT STATE.       *
*    CALLED BY STATE CHECKER                        *
*****************************************************
INCREM   MOV      T,*TBL:CNT
         CPL      T
         NEG      T
         MOV      TEMP2,T           INCREMENT THE TABLE COUNTER BY 2
         CPL      T                    INC IS DONE BY ONES COMPL THE 2'S
         NEG      T                      COMPLEMENT.
         MOV      *TBL:CNT,T
         RFS
         PAGE
*
*
**************************************
*                                    *
*    SUBROUTINE FOR DISPLAYING       *
*    NUMERIC KEY ENTRY DURING        *
*    OFF LINE TEST 1 MODE            *
*                                    *
**************************************
*
SEL:DSP  LPI      1
         MOV      T,ROUT0
         JT       ON:LINE,RETN:
         LPI      0                 IF: OFF LINE ACTIVE
         MOV      T,CPY:SEL             DISPLAY KEY ENTRY
         JMP      DSPLY
*
*
*
**************************************
*                                   *
*   SUBROUTINE TO BLANK UNIT AND    *
*   TENS DIGIT.                     *
*                                   *
*************************************
*
BLNK:DSP LPI      0
         CLR      T
         MOV      DSP:TENS,T        TURN OFF DISPLAY
         MOV      DSP:ONES,T
         MVI      T,X'FC'           MASK OFF THE DIGIT ENTRY FLGS
         AND      ZERO:FLG,T        CLR ZERO ENTRY FLAGS
         LPI      1
         MVI      FAULTS,0          CLEAR DISPLAY FAULTS REG.
BLNK:OFF LPI      1
         MOV      T,FLAG2
         JT       RUN:FLG,BLNK:RET  IF: NOT RUN MODE
         LPI      3
         MVI      TIM2:CNT,X'FF'    TURN OFF BLINK TIMER
         MVI      TIM2:PNT,0
BLNK:RET LPI      1
         RFS
*
**************************************************
*    SET UP DISPLAY FAULT CODE AND BLINK TIMER   *
*  FOR 2/3 SEC. ON AND 1/3 OFF. (TIMER 2 USED)   *
**************************************************
BL@ON    LPI      3
         CLR      T
         MOV      TIM2:CNT,T        SET UP TIMER 2 FOR BLINK EVENTS
         MVI      TIM2:PNT,BL:FLT
DSP:FLT  MOVD     T,R31                  DISPLAY FAULT CODE
         JMP      DSPLY
*
         PAGE
*
*************************************
*                                   *
*    KEYBOARD ENTRY IS DECODED      *
*    HERE FOR KEY STATUS TRANS-     *
*    MISSION TO SERVER.             *
*                                   *
*************************************
*
KEY:CODE LPI      1
         MOV      T,ROUT0
         JT       OFF:LINE,KEY:RET  IF: ON-LINE MODE
         LPI      0
         MVI      CPY:SEL,0            DO NOT STORE KEY INFO'
         MOV      T,DSP
         LPI      2
         MVI      TEMP6,X'30'          DECODE KEY INFO'
         IOR      TEMP6,T
         MOV      T,TEMP6
         OUT      DATA:RW,T            & TRANSMIT IT TO SERVER
KEY:RET  LPI      0
         RFS                        ELSE:
*                                         RETURN
*
*
*******************************
*  CLEAR KEY FUNCTION ROUTINE *
*******************************
*
CLR:KEY  MOV      T,KBD:REG         IF: CLEAR KEY DISABLED
         JT       CLR:ENT,NO@ACTN        RETURN
*                                   ELSE:
*                                        DO CLEAR KEY FUNCTION
         LPI      2
         MOV      T,FLAG1
         CPL      T                 IF: DIAGNOSTIC MODE
         JT       DIAG:FLG,DSP:CLR
         CLB      CONT:FLG              DISABLE DIAG. CONTINUOUS
         AND      FLAG1,T               COPY CYCLE.
         LPI      0
         MVI      KBD:REG,X'C0'         ENABLE THE KEYBOARD
         LPI      1
         MOV      T,FLAG2
         JT       RUN:FLG,KEY:RET
         CAL      DIA:ROUT              TURN OFF ALL OUTPUTS
         LPI      0
         MVI      CPY:SEL,0         CLEAR KEY ENTRY REG.
         JMP      REV:LEVL              BACK TO REVISION LEVEL
DSP:CLR  LPI      0
         MVI      CPY:SEL,0         ELSE:
         CAL      BLK:DSP               BLANK DISPLAY
CLR:STAT MOV      T,ROUT0                IF: ON LINE
         JT       ON:LINE,CLR:              SEND KEY STATUS ':'
         RFS
CLR:     MVI      T,X'3A'
         OUT      DATA:RW,T         RETURN
NO@ACTN RFS
         PAGE
*
*******************************
*    TEST KEY FUNCTION        *
*******************************
*
TEST@    MOV      T,KBD:REG
         JT       TEST:ENT,NO@ACTN  IF: TEST KEY DISABLED
         LPI      1                     RETURN
         MOV      T,ROUT0
         JT       ON:LINE,START:1   IF: OFF LINE MODE & STANDBY
         MOV      T,FLAG2
         JT       RUN:FLG,NO@ACTN
         CAL      STRT:SLP              START 3 MINUTE TIMER
         JMP      DIA:MODE              DO DIAGNOSTIC ROUTINE
START:1  MVI      T,X'3B'           ELSE:
         OUT      DATA:RW,T             SEND TEST KEY STATUS ';'
START:2  RFS
*
*****************************
* PAPER PATH JAM CHECK;DONE *
* DURING POWER UP.          *
*****************************
*
PPR:CK   MOV      T,IN:ZERO
         JT       REG:SW,E4:CK      IF: PAPER UNDER REG. OR EXIT SW.
         JMP      E2:JAM
E4:CK    JT       EXIT:SW,STANDBY       ENTER HARD JAM STATE
         JMP      E4:JAM            ELSE:
STANDBY  LPI      2
         MOV      T,FLAG1
         LPI      1
         JT       DIAG:FLG,START:2
         JMP      STND:BY
         PAGE
         ORG      X'900'
*
******************************************
*                                        *
*    ROUTINE CHECKS SERVER TERMINATIONS. *
*    STACKER TRAY, PAPER TRAY AND        *
*    LOW TONER SWITCHES ARE ALSO         *
*    CHECKED HERE                        *
*                                        *
******************************************
*
SERV:STK JT       SERV:OFF,RST:USRT
         JT       SERV:DIS,RST:USRT IF: SERVER OFF OR DISCONNECTED
         MOV      T,FLAG2               RESET USART
         CPL      T                 ELSE:
         JT       SERV:FLG,CHK:FLG2
         CLB      SERV:FLG                IF: USART WAS OFF BEFORE
         AND      FLAG2,T
         CAL      USRT:INI                    RE-INIT. USART
CHK:FLG2 LPI      1
         MOV      T,FLAG2
         JT       JAM:FLG,CHK:WAIT  IF: HARD JAM & NOT WAIT STATE
         JT       RUN:FLG,TRAY:RET  ANDIF: NOT RUN STATE
CHK:WAIT LCB      FAULTS,X'B1',CK:TRA
         RFS
CK:TRA   MOV      T,IN:ZERO         ANDIF: DOOR IS NOT OPEN
         CPL      T
         JT       DOOR:ILK,TRAY:RET        CHECK TRAY SWITCH
*
*
*  PAPER   TRAY SWITCH INTERROGATION
*
         MOV      T,IN:ONE
         JT       TRAY:SW,TRAY:OK
         LCB      FAULTS,X'C3',LOAD:C3
         RFS
LOAD:C3  MOV      T,FLAG2
         JT       JAM:FLG,TRAY:RET  IF: NOT HARD JAM
         MVI      FAULTS,X'C3'      ANDIF: TRAY IS OPEN
         CAL      BL@ON                DISPLAY TRAY OPEN FAULT 'C3'
         LPI      2                    PRE-LOAD TRAY OPEN STATUS 'Q'
         MVI      IOT:STAT,X'51'
OK:RET   LPI      1                 ELSE:
TRAY:RET RFS
*                                         CHECK PAPER PATH
TRAY:OK  LCB      FAULTS,X'C3',STK:TRAY
         MOV      T,FLAG2
         JT       JAM:FLG,PR:PTH
         MVI      FAULTS,0
         CLB      SOFT:JAM               ALLOW SERVER TO DISPLAY
         AND      FLAG2,T                STATUS IF TRAY WAS OPENED
         JMP      TRAY:CLR              AFTER 'C4' JAM.
*
PR:PTH   JMP      PPR:PATH
         PAGE
*
*  STACKER TRAY SWITCH INTERROGATION *
*
STK:TRAY MOV      T,FLAG2           IF: HARD JAM
         JT       JAM:FLG,TRAY:RET  ORIF: SOFT JAM
         JT       SOFT:JAM,TRAY:RET      RETURN
         LPI      2
         LCB      IOT:STAT,X'58',STK:SW
         JMP      STK:SW2
STK:SW   LPI      1
         INP      T,IN2             IF: STACKER TRAY FULL
         JT       TRAY:FUL,CK:TONER    DISPLAY 'F5'
         JMP      TRA:FULL          ELSE:
*                                        CHECK PAPER PATH
STK:SW2  LPI      1
         INP      T,IN2
         CPL      T
         JT       TRAY:FUL,TFLT:RT
         JMP      TRAY:CLR
*
*  LOW TONER INTERROGATION  *
*
*
CK:TONER LPI      1
         MOV      T,FLAG2
         JT       RUN:FLG,TFLT:RT     IF: RUN MODE
         LPI      2                      DO NOT CHECK TONER
         LCB      IOT:STAT,X'54',TONR:SW
         JMP      TONR:SW2
TONR:SW  LPI      1
         INP      T,IN2
         JT       LO:TONER,TFLT:RT
         MVI      FAULTS,X'A1'
*                                   IF: LOW TONER CONDITION
DIAG9:3  LPI      2
         MOV      T,FLAG1
         CPL      T
         JT       DIAG:FLG,TONR:FLT   IF: DIAG. 9-3
         LPI      0
         LCB      CPY:SEL,X'93',TONR:FLT
         JMP      TFLT:RT                 RETURN
*
TONR:FLT LPI      1                   ELSE:
         CAL      DSP:FLT             DISPLAY 'J1'
         LPI      2
         MVI      IOT:STAT,X'54'      SEND STATUS 'T'  TO SERVER
TFLT:RT  LPI      1                 ELSE:
         RFS                             CHECK IF DIAG. MODE
*                                        IF TRUE
TONR:SW2 LPI      1                        PUT BACK DIAG. CODE
         INP      T,IN2                    ON DISPLAY.
         CPL      T
         JT       LO:TONER,TFLT:RT     RETURN TO STANDBY
TRAY:CLR CAL      BL@OFF               BLANK DISPLAY
         LPI      1
         CAL      SEND:A
         LPI      1                 IF: ON-LINE & READY (STATUS 'A')
         MOV      T,ROUT0
         JT       OFF:LINE,NO:SLEEP      RE-INIT. GOTO SLEEP TIMER
         CAL      INI:SL
NO:SLEEP LPI      1
         MOV      T,FLAG2
         JT       RUN:FLG,TRAY:RET
         JMP      DSP:DIAG
*
         PAGE
*
******************************
*   USART RESET ROUTINE:     *
*  ACTIVE WHEN SERVER IS     *
*  TURNED OFF OR DISCON-     *
*  NECTED.                   *
******************************
*
RST:USRT STB      SERV:FLG
         IOR      FLAG2,T
         CAL      USRT:RS
         JMP      CHK:FLG2
         PAGE
*
*********************************************
**     DIAGNOSTIC DISPLAY                  **
**        ROUTINES                         **
**                                         **
**     USED FOR DISPLAYING REAL TIME       **
**     RESULTS FOR DIAGNOSTIC TIMING       **
**     TESTS                               **
*********************************************
*********************************************
**
SEC:DSP  LPI      0
         CLB      1
         AND      ZERO:FLG,T
         MOV      T,SECS
         JMP      DSPLY              DISPLAY SECONDS
*
BLNO:DSP LPI      3                 TURN OFF REAL TIME DISPLAY TIMER
         MVI      TEST:CNT,X'FF'
BLN:DSP  LPI      0
         CLR      T                 BLANK DISPLAY
         AND      DSP:ONES,T
         AND      DSP:TENS,T
         RFS
*
MS:DSP   LPI      0
         STB      1
         IOR      ZERO:FLG,T
         MOV      T,DGN:SAV         DISPLAY MILLISECONDS
         JMP      DSPLY
         PAGE
*
************************************
*                                  *
* STACKER SWITCH INTERROGATION:    *
*  STACKER FAULT F5 IS DISPLAYED   *
*  AND STACKER FULL STATUS IS SENT *
*  TO SERVER IF SWITCH IS MADE..   *
*                                  *
************************************
*
CHK:STAK LPI      1
         MOV      T,FLAG2
         JT       JAM:FLG,F5:RET    IF: NO HARD JAM
         INP      T,IN2             ANDIF: STACKER TRAY SW. IS MADE
         JT       TRAY:FUL,F5:RET1
TRA:FULL MVI      FAULTS,X'F5'          DISPLAY F5 & SEND
         CAL      DSP:FLT               STATUS 'X' TO SERVER
         LPI      2
         MVI      IOT:STAT,X'58'
         LPI      1
F5:RET   RFS
F5:RET1  LCB      FAULTS,X'F5',F5:RET ON THE OTHER HAND,
         MVI      FAULTS,0          IF AN F5 WAS DECLARED
*        ON A PREVIOUS COPY CYCLE AND THE FAULT HAS BEEN
*        CLEARED IN THE MEANTIME, CLEAR FAULTS AND BLANK
*        THE DISPLAY NOW.
         JMP      BL@OFF
         PAGE
*
**************************************
*       STACKER CONTROL ROUTINE      *
**************************************
*
INV@ON   STB      INVERT            TURN ON INVERTER
         IOR      ROUT2,T
         LPI      3
         MVI      TIM2:PNT,TAT:EXIT
         MVI      TIM2:CNT,0        START TE@EXIT TIMER
         MVI      STAK:CNT,0        RE-INIT. STACKER TIMER
*
         LPI      1
         MOV      T,ROUT0           IF: ON-LINE MODE
         JT       ON:LINE,CK:OS     ORIF: CYCLING OFF LINE
         MOV      T,FLAG2
         JT       OFF:FLG,CK:OS          PROCESS OFFSET
         LPI      0                 ELSE:
         LCB      CPY:SEL,2,INV:RET      IF: TEST MODE 2
         JMP      OFFS:ON                    TURN ON OFFSET SOL.
CK:OS    LPI      2
         DIF
         MOV      T,OS:BYTE         SHIFT OFFSET BYTE
         ADD      OS:BYTE,T
         MVI      T,X'E6'
         AND      OS:BYTE,T         CLEAR BIT 5 & OS:FLG3
         JC       OFFS:ON           IF: CARRY FLAG IS SET
INV:RET  RFS                            ENABLE OFFSET SOL.
*                                   ELSE:
*
OFFS:ON  LPI      1
         STB      OFF:SET                 RETURN
         IOR      ROUT2,T
         RFS
*
OFST@OFF CLB      OFF:SET            TURN OFF OFFSET SOL.
         AND      ROUT2,T
         RFS
*
INV@OFF  CLB      INVERT
         AND      ROUT2,T           TURN OFF INVERTER
         RFS
         PAGE
         ORG      X'9F1'
*
**********************************************
*                                            *
*        SERVER COMMUNICATIONS HANDLER       *
*                                            *
**********************************************
*
USRT:INT LPI      1
         MOV      T,FLAG2           IF: CYCLING OFF LINE
         JT       OFF:FLG,CHK:COM       PROCESS COMMANDS
         MOV      T,ROUT0
         JT       ON:LINE,CHK:COM   IF: OFF LINE TEST MODE
         LPI      2
         INP      T,DATA:RW             DUMMY READ DATA
         JMP      STAT:V               (DATA MUST BE READ AFTER
*                                       EVERY USART INTERRUPT)
CHK:COM  LPI      3
         MVI      T,SLP:TBL-1
         CMP      TIM1:PNT,T        IF: TIMER 1 PNT @ SLP:TBL OR >
         JRGT     INI@SL
         JMP      CK:CMD
INI@SL   CAL      INI:SL               RE-INIT. GOTO SLEEP TIMER
CK:CMD   LPI      2
         INP      T,DATA:RW         READ SERVER COMMAND DATA
*
         JT       6,PRINT:          IF: PRINT COMMAND
         JT       5,CHK:4               PROCESS PRINT COMMAND INFO'
         JMP      COM:UNR
CHK:4    JT       4,DISPLAY:        ELSEIF: DISPLAY STATUS COMMAND
         JMP      READ:                    PROCESS DISPLAY INFO'
*                                   ELSEIF: READ STATUS COMMAND
*                                          SEND IOT CURRENT STATUS
*                                   ELSE:
*                                        SEND COMMAND UNRECOGNIZED
*                                        STATUS 'N'
PRINT:   MOV      TEMP6,T
         MVI      T,X'5A'
         CMP      TEMP6,T           IF: GO TO SLEEP COMMAND
         JNZ      CHK:UNR              IF: STANDBY READY MODE
         LCB      IOT:STAT,X'41',SAVE:
         LPI      1
         STB      GO:SLEEP              GO TO SLEEP IMMEDIATELY
         IOR      ROUT2,T              ELSE:
         JMP      RES:TORE               SEND 'O'; ILLEGAL SEQ.
*
CHK:UNR  INP      T,DATA:RW
         MVI      TEMP6,X'AE'       CHECK FOR OTHER POOSIBLE
         AND      TEMP6,T           COMBINATION OF PRINT
         JNZ      COM:UNR           COMMANDS.
*                                   IF: PRINT COMMD. NOT FOUND
*                                      COMMD. UNREC. STATUS 'N'
         PAGE
         LPI      1
         MOV      T,FLAG2
         JT       OFF:FLG,SAVE:
         MOV      T,FLAG3           IF: MULTIPLE PRINT COMMANDS
         JT       CMD:FLG,SAVE:     ORIF: TRAY SW. DE-SELECTED
         MOV      T,IN:ONE          ORIF: CYCLING OFF LINE
         CPL      T                     IGNORE PRINT COMMANDS
         JT       TRAY:SW,SAVE:         SEND ASCII 'O'; ILLEGAL SEQ.
         LPI      2
         MOV      T,OS:BYTE
         JT       OS:FLG1,SET:FLG2
         STB      OS:FLG1           IF: FIRST PRINT COMMAND
         IOR      OS:BYTE,T
         INP      T,DATA:RW            IF: OFFSET NOT REQ'D
         MOV      FEED:COM,T
         JT       0,SET:BIT7              DISABLE OFFSET SOL.
         CLB      7                    ELSE:
         AND      OS:BYTE,T               ENABLE OFFSET SOL.
         JMP      CHK:RUN
*
SET:BIT7 STB      7
         IOR      OS:BYTE,T
         JMP      CHK:RUN
*
SET:FLG2 JT       OS:FLG2,CHK:OS
         STB      OS:FLG2           IF: 2ND PRINT COMMAND
         IOR      OS:BYTE,T
         INP      T,DATA:RW            IF: OFFSET NOT REQ'D
         MOV      FEED:COM,T
         JT       0,SET:BIT6              DISABLE OFFSET SOL.
         CLB      6
         AND      OS:BYTE,T            ELSE:
         JMP      CHK:RUN
*                                         ENABLE OFFSET SOL.
SET:BIT6 STB      6
         IOR      OS:BYTE,T
         JMP      CHK:RUN
*
CHK:OS   STB      OS:FLG3
         IOR      OS:BYTE,T         SET OFFSET FLAG3
         INP      T,DATA:RW
         MOV      FEED:COM,T        IF: PRINT COMMANDS > 2
         JT       0,SET:BIT5
         CLB      5                    IF: OFFSET NOT REQ'D
         AND      OS:BYTE,T
         JMP      CHK:RUN                  DISABLE OFFSET
*
SET:BIT5 STB      5                    ELSE:
         IOR      OS:BYTE,T
*                                         ENABLE OFFSET SOL.
CHK:RUN  LPI      1
         MOV      T,FLAG2
         CPL      T
         JT       PRNT:FLG,1ST:CPY
         LPI      2                 IF: RUN:READY TO FEED 'K'
         LCB      IOT:STAT,X'4B',SAVE: FEED NEXT COPY
         LPI      1                 ELSE:
         MOV      T,FLAG2           IF RUN FLAG, DON'T
         JT       RUN:FLG,NO:BLNK     BLANK THE DISPLAY
         CAL      BLNK:DSP               BLANK DISPLAY
NO:BLNK  STB      CMD:FLG                START FROM COLD STATE
         IOR      FLAG3,T
         JMP      RESTORE               INHIBIT MULTIPLE PRINT COMMANDS
SAVE:    LPI      2
         MVI      TEMP6,X'4F'
         JMP      SEND:STA
1ST:CPY  STB      CMD:FLG
         IOR      FLAG3,T
         JMP      STRT:SUB
*
         PAGE
DISPLAY: LPI      1
         MOV      T,FLAG2           IF: CYCLING OFF LINE
         JT       OFF:FLG,STAT:U        SEND STATUS 'U'
         JT       SOFT:JAM,SAVE:    IF: C4 JAM
         JT       JAM:FLG,SAVE:     ORIF: HARD JAM
         LCB      FAULTS,X'C3',STAT:DSP
         JMP      SAVE:             ORIF: TRAY OR DOOR OPEN
STAT:DSP LPI      2
         INP      T,DATA:RW              DO NOT SERVICE DISPLAY COMMAND
         MVI      TEMP6,X'3F'
         CMP      TEMP6,T
         JZ       BLNK:DIS          ELSEIF: BLANK DISPLAY COMMAND
DSP:STAT MVI      TEMP6,LSB:MSK         BLANK DISPLAY
         AND      TEMP6,T               .
         MOV      T,DISPLAY         GET PREVIOUS DIGIT INFORMATION
         LPI      0
         MOV      TEMP4,T           PLACE IT IN TENS DIGIT
         MVI      T,X'0F'
         AND      TEMP4,T
         MVI      TEMP3,-4
SHF:L    MOV      T,TEMP4
         ADD      TEMP4,T
         IBNZ     TEMP3,SHF:L
*
         MOV      T,TEMP4
         LPI      2
         MOV      DISPLAY,T
         MOV      T,TEMP6
         IOR      DISPLAY,T
         LPI      0
         CAL      ENTER:0           CALL ZERO SUPPRESSION ROUT.
         LPI      2
         MOV      T,DISPLAY
         CAL      DSPLY             ELSE:
         MVI      T,X'4C'
         OUT      DATA:RW,T         SEND KEY PRESSED STATUS 'L'
         JMP      RESTORE                TO THE SERVER.
*
READ:    MOV      TEMP6,T
         MVI      T,X'2F'           IF DIPLAY 'F' COMMAND
         CMP      TEMP6,T
         JZ       DISPLAY:             DISPLAY 'F'
*
         INP      T,DATA:RW
         MOV      TEMP6,T           IF: READ STATUS COMMAND
         MVI      T,READ:MSK            SEND MACHINE STATUS
         CMP      TEMP6,T
         JNZ      COM:UNR
STAT:U   LPI      2
         LCB      PREV:STA,X'59',NOT:Y
         JMP      RESTORE
NOT:Y    MOV      T,IOT:STAT
         OUT      DATA:RW,T
         JMP      RESTORE
*
COM:UNR  MVI      T,X'51'
         AND      FEED:COM,T        MASK OFF ILLEGAL COMMANDS
         MVI      TEMP6,UNREC:MK    AND SEND COMMAND UNRECOGNIZED
         JMP      SEND:STA          STATUS TO SERVER.
*
PCOL:ERR MVI      TEMP6,X'4D'       LOAD PARITY ERROR MASK
INI:USRT INP      T,DATA:RW         DUMMY READ DATA
         CAL      USRT:RS           RESET USART
         CAL      USRT:INI          RE-INI. USART
SEND:STA LPI      2
         MOV      T,TEMP6           SEND IOT STATUS
         OUT      DATA:RW,T
RES:TORE JMP      RESTORE
*
BLNK:DIS LPI      1
         MOV      T,FLAG2
         JT       SOFT:JAM,CLR:DSP  IF: SOFT JAM CONDITION
         LPI      3
         MVI      T,BL:FLT-1        ORIF: BLINK TIMER ACTIVE
         CMP      TIM2:PNT,T
         JRGT     CLR:DSP               DO NOT BLANK DISPLAY
         CAL      BLNK:DSP          ELSE:
         MVI      T,X'4C'               BLANK DISPLAY
         OUT      DATA:RW,T
CLR:DSP  LPI      2                     SEND STATUS 'L'
         CLR      T
         MOV      DISPLAY,T         CLEAR PRESENT DISPLAY INFO'
         JMP      RESTORE
*
STAT:V   MVI      T,X'56'
         OUT      DATA:RW,T
         JMP      RESTORE
*
         PAGE
*
*************************************
*     USART RESET ROUTINE           *
*************************************
*
USRT:RS  CLR      T
         OUT      CMD:MODE,T
         OUT      CMD:MODE,T        OUTPUT 3 ZEROES AS COMMANDS
         OUT      CMD:MODE,T        BEFORE SETTING 'IR' BIT IN
         MVI      T,X'40'           COMMAND REGISTER.
         OUT      CMD:MODE,T        (A QUIRK OF INTEL 8251)
         RFS
*
*************************************
*    USART INITIALIZATION ROUTINE   *
*************************************
*
USRT:INI MVI      T,X'5A'
         OUT      CMD:MODE,T        SEND MODE INSTRUCTION
         MVI      T,X'35'
         OUT      CMD:MODE,T        SEND COMMAND INSTRUCTION
         INP      T,DATA:RW         DUMMY READ DATA
         RFS
*
         PAGE
*
*
*************************************
*                                   *
* DIAGNOSTIC ROUTINE ACTIVE DURING  *
* OFF LINE STATE.ROUTINE CORRESPOND-*
* ING WITH NUMERIC KEY ENTRY IS     *
* ACTIVATED BY PUSHING TEST BUTTON. *
*                                   *
*************************************
*
DIA:MODE LPI      2
         MOV      T,FLAG1           IF: UNDER DIAGNOSTICS
         JT       DIAG:FLG,CHK:CHN     DO CHAIN SELECTION
         LPI      0                 ELSE:
         LCB      CPY:SEL,BLANK:,DIAG:1
         JMP      STRT:SUB              IF: NO KEY ENTRY
DIAG:1   LCB      CPY:SEL,1,DIAG:2      ORIF: KEY ENTRY = 1
         JMP      STRT:SUB                FEED FROM UPPER TRAY
*
DIAG:2   LCB      CPY:SEL,2,DIAG:RET    ELSEIF: KEY ENTRY = 2
         JMP      STRT:SUB
*                                           FEED FROM LOWER TRAY
*
CHK:CHN  JT       CHN3:FLG,SYS:TST  IF: KEY 3; ENTER CHAIN 3 DIAG.
         JT       CHN6:FLG,COMP:61  ELSEIF: KEY 6; ENTER CHAIN 6 DIAG.
         JT       CHN8:FLG,COMP@81  ELSEIF: KEY 8; ENTER CHAIN 8 DIAG.
         JT       CHN9:FLG,COMP@91  ELSEIF: KEY 9; ENTER CHAIN 9 DIAG.
         JT       CN10:FLG,COMP@01  ELSEIF: KEY 10; ENTER CHAIN 10 DIAG.
*
*   TEST KEY INTERROGATION  *
*
         LPI      0
         LCB      CPY:SEL,0,CHK:ENT
*                                   ELSEIF: NO NUMERIC ENTRY
TEST:KEY LPI      3
         MVI      TEST:PNT,TKEY:TBL     DEBOUNCE TEST KEY FOR 200 MS
         MVI      TEST:CNT,0            AND LOOK AT IT AGAIN.
         RFS
*
DSP@OFF  LPI      0
         LCB      CPY:SEL,0,DIA:MODE    AGAIN MAKE SURE NO NUM. ENTRY
CHK:TST  LPI      1
         INP      T,X'40'                  IF: TEST KEY RELEASED
         CPL      T
         JT       3,REP:TEST
         MVI      T,X'04'
         AND      ROUT0,T                    TURN OFF DISPLAY &
         JMP      TESTK:LV                   RETURN TO REV. LEVEL
*
REP:TEST STB      ON:LINE                  ELSE:
         IOR      ROUT0,T                    TURN ON ON-LINE LED
         MVI      FAULTS,X'88'               & 7 SEGMENT LEDS WITH
         CAL      DSP:FLT                     '88'
         JMP      TEST:KEY                    & LOOK FOR TEST
*                                              KEY AGAIN.
CHK:ENT  LPI      0
         LCB      CPY:SEL,3,CHAIN:6
         LPI      2                 ELSE:
         STB      CHN3:FLG               IF: KEY ENTRY 3
         IOR      FLAG1,T                  SELECT CHAIN 3
         RFS
*
CHAIN:6  LCB      CPY:SEL,6,CHAIN:8
         LPI      2                       ELSEIF: KEY ENTRY 6
         STB      CHN6:FLG                    SELECT CHAIN 6
         IOR      FLAG1,T
         RFS
*
CHAIN:8  LCB      CPY:SEL,8,CHAIN:9      ELSEIF: KEY ENTRY 8
         LPI      2
         STB      CHN8:FLG                   SELECT CHAIN 8
         IOR      FLAG1,T
         RFS
*
CHAIN:9  LCB      CPY:SEL,9,CHAIN:10
         LPI      2                      ELSEIF: KEY ENTRY 9
         STB      CHN9:FLG
         IOR      FLAG1,T                    SELECT CHAIN 9
         RFS
*
CHAIN:10 LCB      CPY:SEL,X'10',BAD:ENT  ELSEIF: KEY ENTRY 10
         LPI      2
         STB      CN10:FLG                   SELECT CHAIN 10
         IOR      FLAG1,T
         RFS                             ELSE:
*
BAD:ENT  MOV      T,CPY:SEL                 FLASH WRONG ENTRY
         MOVD     R31,T
         JMP      BL@ON
*
*
****************************************
*    SYSTEM TEST & COMPONENT CONTROL   *
****************************************
*
*
****************************
*    CHAIN 3 DIAGNOSTICS   *
****************************
SYS:TST  LPI      0
         LCB      CPY:SEL,X'31',SYS:TST2
         JMP      STRT:SUB          ELSEIF: CHAIN 3-0
*                                          MAKE COPY FROM UPPER TRAY
SYS:TST2 LCB      CPY:SEL,X'32',SYS:TST3
         JMP      STRT:SUB          ELSEIF: CHAIN 3-2
*                                         MAKE A COPY FROM LWR TRAY
SYS:TST3 LCB      CPY:SEL,X'33',DIAG:4
AO:MODU  LPI      1
         CLB      TEST:1            ELSEIF: COMPONENT CODE = 33
         AND      ROUT2,T                   TURN ON A/O MODUL.
         STB      MN:DRV                    ALONG WITH MAIN DRIVE
         IOR      ROUT3,T                  (LASER HITS THE DRUM)
         OUT      OUT3,ROUT3
         RFS
*
DIAG:4   LCB      CPY:SEL,X'34',DIAG:5
DIAG:4A  LPI      1
         STB      MN:DRV            ELSEIF: COMPONENT CODE 34
         IOR      ROUT3,T
         STB      TEST:1                   TURN ON MAIN DRIVE
         IOR      ROUT2,T                  TURN OFF A/O MODUL.
         STB      SHUT:R                   TURN ON SHUTTER SOL.
         IOR      ROUT2,T                  & SHUTTER 50% DUTY
         LPI      3                        CYCLE AFTER 1.1 SEC.
         MVI      PAP:PNT,DIA:TBL2
         MVI      PAP:CNT,0
         RFS
*
DIAG:5   LCB      CPY:SEL,X'35',DIAG:6
         CAL      DRV:HV            ELSEIF: COMPONENT CODE = 35
         CAL      DIAG:4A                  TURN MAIN DRV,HIGH VOLT.
         JMP      AO:MODU                  SHUTTER & A/O MODULATOR
*
DIAG:6   LCB      CPY:SEL,X'36',DIAG:7
DRV:HV   LPI      1                 ELSEIF: COMPONENT CODE = 36
         STB      MN:DRV
         IOR      ROUT3,T                   TURN ON MAIN DRIVE
         STB      TEST:1
         IOR      ROUT2,T                   A/O MODULATOR OFF
         LPI      3
         MVI      TEST:PNT,DIAG:TBL
         MVI      TEST:CNT,0                & HVPS(COROTRONS).
         RFS
*
*
DIAG:7   LCB      CPY:SEL,X'37',DIAG:8
         CAL      DRV:HV            ELSEIF: COMPONENT CODE = 37
         JMP      DIAG:4A                   TURN ON DRIVE,HI. VOLT
*
DIAG:8   LCB      CPY:SEL,X'38',DIAG:9
         JMP      STRT:SUB          ELSEIF: COMPONENT CODES 38,39 OR 3-1
0
*                                      START PRINT CYCLE
DIAG:9   LCB      CPY:SEL,X'39',DIAG:10
         JMP      STRT:SUB
DIAG:10  LCB      CPY:SEL,X'10',COMP:311
         JMP      STRT:SUB
DIAG:RET RFS                             RETURN
*
COMP:311 LPI      0
         LCB      CPY:SEL,X'11',COMP:361 IF: CHAIN 3-11 DIAGNOSTICS
         LPI      1
         STB      BIL:MTR1              TURN ON BILLING METER FOR 3 MIN
         IOR      ROUT3,T
         RFS
*
COMP:361 LCB      CPY:SEL,X'61',COMP:62
         LPI      1
         STB      GO:SLEEP          ELSEIF: COMPONENT CODE 3-61
         IOR      ROUT2,T                GO TO SLEEP
         RFS
*
COMP:62  LCB      CPY:SEL,X'62',BAD:ENT
         LPI      1
         STB      WDT:MEM
         IOR      FLAG3,T
         RFS
*                                         TEST WATCH DOG TIMER
*                                   ELSE:
*                                         FLASH WRONG ENTRY
COMP@01  JMP      COMP:01
COMP@91  JMP      COMP:91
COMP@81  JMP      COMP:81
*
*
*
****************************
*    CHAIN 6 DIAGNOSTICS   *
****************************
*
COMP:61  LPI      0
         LCB      CPY:SEL,X'61',BAD:ENT
         LPI      1                 ELSEIF: COMPONENT CODE 61
         STB      SHUT:R                TURN ON SHUTTER SOL.
         IOR      ROUT2,T               & START SHUTTER SOL.
         LPI      3                     50% DUTY CYCLE AFTER
         MVI      TEST:PNT,DIA:TBL2     1.1 SEC.
         MVI      TEST:CNT,0           TURN OFF AFTER 3 MIN.
         RFS
*
         ORG      X'C00'
****************************
*   CHAIN 8 DIAGNOSTICS    *
****************************
*
*
COMP:81  LPI      0
         LCB      CPY:SEL,X'81',COMP:82
         LPI      1
         STB      UP:TRAY           IF: COMPONENT CODE = 81
         IOR      ROUT1,T               TURN ON UPPER TRAY FEEDER
         RFS
*
COMP:82  LCB      CPY:SEL,X'82',COMP:83
         LPI      1
         INP      T,IN0             IF: COMPONENT CODE = 82
         CPL      T
         JT       REG:SW,CLR:SW     ANDIF: REG. SW. NOT ACTIVE
         JMP      ONLN:ON              TURN ON ON-LINE LED
*
COMP:83  LCB      CPY:SEL,X'83',COMP:84
         LPI      1                 IF: COMP. CODE = 83
         STB      LWR:TRAY              TURN ON FEEDERS
         IOR      ROUT1,T
         RFS
*
COMP:84  LCB      CPY:SEL,X'84',COMP:51
         LPI      1
         STB      REG:ROLL          IF: COMPONENT CODE 84
         IOR      ROUT3,T               TURN ON REG ROLLS
         RFS
*
*
COMP:51  LCB      CPY:SEL,X'51',COMP:52
CONT:CPY LPI      2
         STB      CONT:FLG          IF: DIAGNOSTICS 8-51,8-52,
         IOR      FLAG1,T               8-53,8-54 OR 8-55
         LPI      1                     START CONTINUOUS COPY CYCLE
         JMP      STRT:SUB          ELSE:
*                                        FLASH WRONG ENTRY
COMP:52  LCB      CPY:SEL,X'52',COMP:53
         JMP      CONT:CPY
*
COMP:53  LCB      CPY:SEL,X'53',COMP:54
         JMP      CONT:CPY
*
COMP:54  LCB      CPY:SEL,X'54',COMP:55
         JMP      CONT:CPY
COMP:55  LCB      CPY:SEL,X'55',BAD@ENT
         JMP      CONT:CPY
*
TEST@KEY JMP      TEST:KEY
*
         PAGE
*
**********************************
*     CHAIN 9 DIAGNOSTICS        *
**********************************
*
COMP:91  LPI      0
         LCB      CPY:SEL,X'91',COMP:92
         LPI      1                 IF: COMPONENT CODE = 91
         STB      BL:SOL
         IOR      ROUT3,T                  TURN ON BLADE SOL. FOR 3 MIN.
         RFS
*
COMP:92  LCB      CPY:SEL,X'92',COMP:93
         LPI      1                 ELSEIF: COMPONENT CODE = 92
         STB      DEV:CLU
         IOR      ROUT3,T                  TURN ON DEVELOPER FOR
         RFS
*
COMP:93  LCB      CPY:SEL,X'93',BAD@ENT
         LPI      1                 ELSEIF: COMPONENT CODE = 93
         INP      T,IN2             ANDIF: TONER SW. ACTIVE LOW
         CPL      T
         JT       LO:TONER,CLR:SW
         JMP      ONLN:ON              LEAVE ON-LINE LED ON FOR
*                                      3 MINUTES.
*
*
*
********************************
*     CHAIN 10 DIAGNOSTICS     *
********************************
*
*
COMP:01  LPI      0
         LCB      CPY:SEL,1,COMP:2
         LPI      1                 ELSEIF: COMPONENT CODE = 10-1
         STB      FAN
         IOR      ROUT3,T                  TURN ON FAN FOR 3 MIN.
         RFS
*
COMP:2   LCB      CPY:SEL,2,COMP:3
         LPI      1                 ELSEIF: COMPONENT CODE 10-2
         STB      INVERT
         IOR      ROUT2,T                TURN ON INVERTER
         RFS
*
COMP:3   LCB      CPY:SEL,3,COMP:6
         LPI      1                 ELSEIF: COMPONENT CODE 10-3
         STB      OFF:SET
         IOR      ROUT2,T              TURN ON OFFSET SOL.
         RFS
*
COMP:6   LCB      CPY:SEL,6,COMP:71
         LPI      1                 IF: COMPONENT CODE = 10-6
         INP      T,IN0             ANDIF: EXIT SW NOT ACTIVE
         CPL      T
         JT       EXIT:SW,CLR:SW          TURN ON ON-LINE LED
ONLN:ON  MOV      T,ROUT0
         JT       ON:LINE,TEST@KEY
         STB      ON:LINE
         IOR      ROUT0,T
         JMP      TEST:KEY
*
COMP:71  LCB      CPY:SEL,X'71',BAD@ENT
         LPI      2
         STB      CONT:FLG          ELSEIF: COMPONENT CODE 71
         IOR      FLAG1,T               ENABLE CONT. COPY CYCLE
         JMP      STRT:SUB              & DISPLAY A/D VALUE (1-64)
*                                   ELSE:
BAD@ENT  JMP      BAD:ENT                DISPLAY BAD ENTRY
*
*
CLR:SW   CAL      TEST:KEY          IF: SWITCH IS ACTIVE
         JMP      ONLN:OFF             TURN OFF ON-LINE LED
*
         PAGE
*
*************************************
*                                   *
* DIAGNOSTIC SUBROUTINE TO TURN OFF *
* ALL ACTIVE OUTPUTS.               *
*                                   *
*************************************
*
DIA:ROUT LPI      2
         MOV      T,FLAG1
         JT       CN10:FLG,FN:OFF
         JT       CHN9:FLG,BLA:OFF
         JMP      CLR:FLG3
BLA:OFF  LPI      0
         LCB      CPY:SEL,X'91',CLR:FLG3
         JMP      FNBL:OFF
FN:OFF   LPI      0
         LCB      CPY:SEL,1,CLR:FLG3 IF: DIAGNOSTICS 10-1
FNBL:OFF LPI      1                 ORIF: DIAGNOSTICS 9-1
         MVI      T,X'80'               TURN OFF ALL OUTPUTS ON
*                                       PORT 3, EXCEPT WDT
         AND      ROUT3,T           ELSE:
         JMP      CLR:REST
CLR:FLG3 LPI      1                     PRESERVE FAN,BLADE & WDT
         MVI      T,X'85'                TURN OFF OTHER OUTPUTS
         AND      ROUT3,T
CLR:REST CLR      T                     PRESERVE WAIT FLAG
         AND      ROUT2,T
         MVI      T,X'20'                CLEAR OTHER FLAGS
         AND      FLAG3,T
         MVI      T,X'17'
         AND      ROUT1,T           TURN OFF OUTPUTS ON PORT 2
         LPI      0                 TURN OFF FEEDER & HV DC
         CLB      ONE:ENT           ENABLE ONES ENTRY
         AND      KBD:REG,T
         RFS
*
*
*
*********************************
*   THIS ROUTINE IS CALLED      *
*   DURING DIAGNOSTICS WHEN     *
*   CLEAR KEY IS PUSHED.        *
*********************************
*
REV:LEVL LPI      2
         STB      DIAG:FLG
         AND      FLAG1,T           CLEAR ALL DIAG. CHAIN FLAGS
         LPI      3                 BUT PRESERVE DIAGNOSTIC MODE
         MVI      PAP:CNT,X'FF'     DISABLE 3 MIN. TIME OUT
         CAL      BLNK:DSP          CLEAR DISPLAY & KEYBOARD REGS.
TESTK:LV LPI      1
         MVI      FAULTS,X'3B'      DISPLAY REVISION LEVEL '3L'
         JMP      DSP:FLT
         PAGE
*
*
************************************
*    THIS ROUT. DE-ACTIVATES ALL   *
*    ACTIVE OUTPUTS DURING DIAG.   *
************************************
*
DIAG:OFF LPI      3
         MVI      TEST:CNT,X'FF'
ONLN:OFF LPI      1
         CLB      ON:LINE              TURN OFF ON LINE LED
         AND      ROUT0,T              & ACTIVE OUTPUTS.
         CLR      T
         AND      ROUT2,T
         STB      WD:TMR            PRESERVE WDT
         AND      ROUT3,T
         MVI      T,X'07'
         AND      ROUT1,T
         CLB      SHUT:FLG          CLEAR THE SHUTTER FLAG
         AND      FLAG3,T
         RFS
*
***************************************
*    3 MINUTES TIME OUT ROUTINE       *
*    DURING ON-LINE POWER UP.         *
***************************************
*
3MIN:WT  LPI      2
         IBNZ     LOOP:CNT,STBY:TBL
         LPI      1                 IF: 3MIN. WAIT OVER
         CLB      WAIT:FLG             ENTER STANDBY
         AND      FLAG3,T              CLEAR WAIT MODE
         JMP      ST:BY
*
*
WAIT:    LPI      1                 ELSE:
         STB      WAIT:FLG
         IOR      FLAG3,T                ENTER 3 MIN. WAIT STATE
         MVI      FAULTS,X'B1'
         CAL      DSP:FLT                DISPLAY 'L1' ON DISPLAY
         LPI      2
         MVI      IOT:STAT,X'40'         SEND WAIT STATUS '@'
STBY:TBL LPI      3                      TO SERVER
         MVI      PAP:PNT,MIN:TBL        INIT. TIMER FOR  3 MIN. WAIT
         MVI      PAP:CNT,0
         JMP      BLNK:OFF              & TURN OFF DISPLAY BLINK
*
        PAGE
         ORG      X'D00'
*************************************
*                                   *
*    SOFT JAM STATE                 *
*                                   *
*************************************
*
*
***********************************************
***********************************************
*
SFT@JAM  MOV      T,IN:ONE
         JT       TRAY:SW,CHK:RGSW
         MVI      FAULTS,X'C3'      IF: TRAY DE-SELECTED
         LPI      2
         MVI      IOT:STAT,X'51'        DISPLAY C3 & SEND 'Q'
         JMP      DR:CK
CHK:RGSW MOV      T,IN:ZERO         ELSE:
         CPL      T
         JT       REG:SW,NO:JAM         IF: PAPER NOT AT REG. SW
         MVI      FAULTS,X'C4'              DISPLAY C4 &
         LPI      2
         MVI      IOT:STAT,X'42'            SEND STATUS 'Q'
DR:CK    CAL      CK:DR                 START CYCLE OUT
         MVI      STAT:PNT,PCYC:TBL
         MVI      STAT:CNT,0
         MVI      T,SLP:TBL
         CMP      TIM1:PNT,T        IF: SLEEP TIMER WAS ACTIVE
         JNE      SET:SJAM              BEFORE.
         LPI      2
         MVI      FAN:CTR,0             INIT. FAN OFF COUNTER TO 0
SET:SJAM LPI      1
         STB      SOFT:JAM              DECLARE FEEDER FAULT
         IOR      FLAG2,T
         CLB      REG:ROLL             TURN OFF REG ROLLS
         AND      ROUT3,T
         CLB      PRNT:FLG               ENABLE COLD START STATE
         AND      FLAG2,T
         MOVD     T,R31
         JMP      DSPLY
*
NO:JAM   RFS
         PAGE
*
*********************************
*         FAN OFF EVENT         *
*********************************
*
FAN@CNT  MOV      T,FLAG2           IF: HARD JAM MODE
         JT       JAM:FLG,CHK:DOOR     CHECK DOOR
         JT       RUN:FLG,END:FAN   ELSEIF: RUN MODE
CHK:DOOR MOV      T,IN:ZERO              RETURN
         CPL      T
         JT       DOOR:ILK,TIM@OUT  IF: DOOR OPEN
         LPI      2                    DO NOT INC. FAN REG.
         LCB      FAN:CTR,0,FAN:1   ELSEIF: FAN OFF TIME IS COMPLETE
         LPI      1                     TURN OFF FAN
         CLB      FAN
         AND      ROUT3,T
         CLB      BL:SOL                TURN OFF BLADE SOL.
         AND      ROUT3,T
INI:SL   LPI      2
         LCB      IOT:STAT,X'59',CHK:A
         JMP      STRT:SLP
CHK:A    LCB      IOT:STAT,X'41',END:FAN
STRT:SLP LPI      3                 IF: ABOUT TO GOTO SLEEP
         MVI      TIM1:PNT,SLP:TBL  ORIF: STANDBY READY 'A'
         MVI      TIM1:CNT,0          RE-INIT. GOTO SLEEP TIMER
         LPI      2                 IF: ABOUT TO GOTO SLEEP STATUS 'Y', 
TRUE
         LCB      IOT:STAT,X'59',SLP:TIME
         MVI      PREV:STA,X'59'      LOAD PREVIOS STATUS WITH 'Y'
         MVI      IOT:STAT,X'41'      SEND STANDBY READY STATUS 'A'
SLP:TIME MVI      FAN:CTR,-5
         MVI      LOOP:CNT,-255
END:FAN  RFS
*
FAN:1    IBNZ     FAN:CTR,TIM@OUT
*
TIM@OUT  LPI      3
         MVI      TIM1:CNT,0        RE-INIT. TIMER TO
         MVI      TIM1:PNT,TIM:TBL  CHECK FAN AGAIN
         RFS
*
*
         PAGE
*
************************************************
**     SUBROUTINE:  REAL:TIM                  **
**                                            **
**   THIS SUBROUTINE IS USED TO CONVERT THE   **
**   NUMBER OF 20MS. TIMING COUNTS INTO A     **
**   REAL TIME VALUE (SECS. AND MS.)          **
**                                            **
**                                            **
** ENTER:                                     **
**     DGN:SAV = # OF 20MS. COUNTS            **
**                                            **
** EXIT:                                      **
**    TEMP 5  = # OF SECONDS                  **
**    DGN:SAV(HI-ORDER) = 100'S MS.           **
**    DGN:SAV(LO-ORDER) = 10'S MS.            **
**                                            **
************************************************
**
REAL:TIM LPI      0
         MVI      T,-50             FIRST DIVIDE OUT
         CAL      DV:LOOP           # OF SECONDS
         MOV      SECS,T            AND SAVE
*
         MOV      T,DGN:SAV         CONVERT REMAING # OF
         ADD      DGN:SAV,T         COUNTS TO MS. BY MULITPLYING
*                                   BY 2(0)
*
REAL:    MVI      T,-10             NOW DIVIDE OUT #
         CAL      DV:LOOP           OF 100 MS.
         MOV      H:MS,T            AND SAVE
*
         MVI      TEMP3,-4          GET # OF 100 MS
SF:UP    MOV      T,H:MS
         ADD      H:MS,T
         IBNZ     TEMP3,SF:UP
*
         MOV      T,H:MS
         LPI      0
         IOR      DGN:SAV,T
*
         LPI      3
         MVI      TEST:CNT,0        START THE REAL TIME DISPLAY
         MVI      TEST:PNT,RT:DSP
*
         LPI      1
REAL:EX  RFS
         PAGE
*
**********************************************
** SUBROUTINE: DV:LOOP                      **
**                                          **
** PURPOSE:   TO PERFORM DIVIDE             **
**            FOR REAL:TIM SUBROUTINE       **
**                                          **
** ENTER:                                   **
**     T = DIVISOR                          **
**   DGN:SAV = DIVIDEND                     **
**                                          **
** EXIT:                                    **
**    T = QUOTIENT                          **
**  DGN:SAV = REMAINDER                     **
**********************************************
**
DV:LOOP  LPI      0
         MVI      TIM:WRK,0
DV:LOOP1 ADD      DGN:SAV,T
         JNC      DV:LOOP2
         IBNZ     TIM:WRK,DV:LOOP1
DV:LOOP2 NEG      T
         ADD      DGN:SAV,T
         MOV      T,TIM:WRK
         RFS
         PAGE
*
*****************************
*    ON BOARD TIMER SET UP  *
*       ROUTINE.            *
*****************************
*
TIMR:ON  MVI      T,IN:CNT          SET UP ON BOARD TIMER FOR A
         MOV      TIC,T             5 MS INTERRUPT.
         MVI      T,OUT:CNT
         MOV      TOC,T
         STRT     TIM               START THE TIMER
CHK:INT2 EIM      TIMF              ENABLE THE TIMER INTERRUPT
         RFS
*
*
*********************************
*    DISPLAY ZERO ROUTINE       *
*********************************
*
ENTER:0  LPI      0
         MOV      T,ZERO:FLG        SET 1ST & 2ND ZERO ENTRY FLAGS
         JT       0,SECOND:0        IF FIRST BIT SET,
         STB      0
         IOR      ZERO:FLG,T
         RFS
SECOND:0 STB      1                 SET THE SECOND BIT
         IOR      ZERO:FLG,T
         RFS
*
*
         SPACE    2
*********************************************
*                                           *
*  THIS ROUTINE IS CALLED WHEN PAGE SYNC OR *
*  PAGE DELIVERED OR  RUN:READY TO FEED     *
*  STATUS IS SENT.                          *
*  TXRDY  (TRANSMIT READY) IS CHECKED ON    *
*  USART BEFORE ANY OF THE ABOVE STATUS IS  *
*  BEING SENT.                              *
*                                           *
*********************************************
*
TX:RDY   LPI      2
         MVI      LOOP:CNT,-29
DEC:CNT  IBNZ     LOOP:CNT,CHK:RDY
         RFS
CHK:RDY  INP      T,STAT:RD         READ USART STATUS REGISTER
         CPL      T                 IF: TXRDY IS NOT TRUE
         JT       0,DEC:CNT             GO THRU' DELAY LOOP
         RFS                        ELSE:
*                                        RETURN
*
         PAGE
*
*
*   OFF LINE KEY ROUTINE
*
CHK@DIAG LPI      2
         MOV      T,FLAG1
         CPL      T                 IF: DIAGNOSTIC MODE
         JT       DIAG:FLG,OFF@ON
         JT       CONT:FLG,DIA@ROUT     IF: CONTINUOUS COPY CYCLE
         CLB      CONT:FLG
         AND      FLAG1,T                   DISABLE COPY CYCLE
         LPI      1
         RFS
*                                       ELSE:
DIA@ROUT LPI      1
         MOV      T,FLAG2                 IF: NOT RUN MODE
         JT       RUN:FLG,OFF:RET            TURN OFF OUTPUTS
         CAL      DIA:ROUT
         LPI      3
         MVI      TEST:CNT,X'FF'        & REAL TIME DISPLAY DIAG TMR.
OFF@ON   LPI      1
         STB      OFF:LINE                 ACTIVATE ON-LINE LED
         IOR      ROUT0,T
         CLB      ON:LINE                  TURN OFF OFF-LINE LED
         AND      ROUT0,T
OFF:RET  RFS
         PAGE
**************************************************
*
*        PROC PATS, FOR BUILDING THE
*             PATTERN TABLE
*
*************************************************
PATS     CNAME
         PROC
LF       EQU  $
         DB   AF(1)&X'3F'
         DB   AF(2)
         DB   AF(3)
         DB   AF(4)
         DB   AF(5)
         DB   AF(6)
         DB   AF(7)&X'FE'
PATS1    SET      AF(1)
         PEND
************************************************
*
*        FUSER CONTROL PATTERN TABLE
*
*        FOR EACH ENTRY:
*        1ST BYTE - ADC COMPARE VALUE (MAX FOR RANGE)
*        BYTES 2-7 - PATTERN BYTES
*
*        PATTERN IS SCANNED IN DESCENDING ADDRESS
*    ORDER, AND FOR EACH BYTE, FROM BIT 0 TO BIT
*    7.  AT THE END OF THE 6 BYTES, IT RESTARTS.
*
*         ******* CAUTION ********
* THIS TABLE MUST START AT ADDRESS > 0
*
****************************************************
*
                 ORG        X'E01'
*             ***** 47 OF 47 *****
*
FTABL    PATS 53,X'FF',X'FF',X'FF',X'FF',X'FF',X'FE'
*
*             ***** 46 OF 47 *****
*
         PATS 50,X'FF',X'FF',X'FE',X'FF',X'FF',X'FE'
*
*
*             ***** 45 OF 47 *****
*
         PATS 48,X'FF',X'FB',X'FF',X'FF',X'FD',X'FE'
*
*             ***** 44 OF 47 *****
*
         PATS 45,X'FF',X'FB',X'FF',X'F7',X'FF',X'EE'
*
*             ***** 43 OF 47 *****
*
         PATS 44,X'FF',X'EF',X'FD',X'FF',X'EF',X'FC'
*
*             ***** 42 OF 47 *****
*
         PATS 41,X'7F',X'BF',X'DF',X'EF',X'F7',X'FE'
*
*             ***** 41 OF 47 *****
*
         PATS 38,X'7F',X'BF',X'7F',X'BF',X'7F',X'BE'
*
*             ***** 40 OF 47 *****
*
         PATS 36,X'EF',X'DF',X'BF',X'7E',X'F7',X'EE'
*
*             ***** 39 OF 47 *****
*
         PATS 33,X'7E',X'F7',X'EF',X'DE',X'F7',X'BE'
*
MID:ADC  EQU      PATS1             NOTE-MUST FOLLOW 8TH ENTRY
*
         PAGE
*             ***** 38 OF 47 *****
*
         PATS 31,X'7B',X'DE',X'F7',X'BD',X'EF',X'DE'
*
*             ***** 37 OF 47 *****
*
         PATS 28,X'7B',X'DE',X'F7',X'BD',X'ED',X'EE'
*
*             ***** 36 OF 47 *****
*
         PATS 24,X'77',X'BB',X'DD',X'EE',X'DD',X'EE'
*
*             ***** 35 OF 47 *****
*
         PATS 21,X'77',X'BB',X'77',X'BB',X'76',X'EE'
*
*             ***** 34 OF 47 *****
*
         PATS 18,X'6D',X'ED',X'BD',X'BD',X'BD',X'B6'
         PAGE
*
*             ***** 33 OF 47 *****
*
         PATS 15,X'BD',X'B6',X'DB',X'6D',X'B6',X'F6'
*
*             ***** 32 OF 47 *****
*
         PATS 12,X'ED',X'B6',X'DB',X'6D',X'B6',X'DA'
*
*             ***** 31 OF 47 *****'
*
         PATS 08,X'6D',X'B6',X'DB',X'6D',X'B6',X'DA'
*
*             ***** 30 OF 47 *****
*
LAST:PAT PATS 05,X'6B',X'6B',X'6D',X'6D',X'B6',X'DA'
*
         PAGE
         ORG      X'FFF'
*
******************************
* THIS BYTE IS RESERVED FOR  *
* CHECKSUM.                  *
******************************
*
CK:SUM   DB       0
*
         END

!