Google
 

Trailing-Edge - PDP-10 Archives - AP-D543V_SB - cdrsrx.mac
There are 2 other files named cdrsrx.mac in the archive. Click here to see a list.
TITLE	CDRSRX - CARD READER SERVICE FOR MULTIPLE CARD READERS - V1106
SUBTTL	T. WACHS/TW/CF/WM/JE  TS  08 NOV 77
	SEARCH	F,S
	$RELOC
	$HIGH

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1973,1974,1975,1976,1977,1978 BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
XP VCDRSX,1106
		;PUT VERSION NUMBER IN GLOB LISTING AND LOADER STORAGE MAP

;EXTERNALS DEFINED IN CDR DEVICE DATA BLOCKS

	EXTERN	CDRCHK,CDRCNO,CDRCOL,CDRCON,CDRCSO,CDRCSZ,CDRCTR
	EXTERN	CDRDTI,CDRIAD,CDRIOS,CDRMIS,CDRPTR,CDRSPU
	EXTERN	CDRRDY,CDRSVE,CDRSV2,CDREX1,CDRADR,CDRRTR



;EXTERNALS FOUND IN OTHER PARTS OF THE MONITOR

	EXTERN	ADVBFF,CPOPJ1,CKS12,HNGSTP,CDRCHN
	EXTERN	ILLOUT,SETIOD,STOIOS,CLRACT,ADRERR,PBUFSZ

;INTERNALS FOR CDRDDB'S IN COMMON

	INTERN	CDRDSP,CDRINT,IDRDY,IRDYR,NOTRDY
COD029==5252		;12-0-2-4-6-8
COD026==4242		;12-2-4-8
CODEOF==7400		;12-11-0-1
NEWEOF==0017		;6-7-8-9 PUNCH.

;BITS IN LH OF S
COLUM1==100			;SET WHEN FIRST COL HAS NOT BEEN READ.
COLUM2==200			;SET WHEN SECOND COL HAS NOT BEEN READ.
CR029==400			;SET WHEN 029 TRANSLTN TO BE MADE.
FORGET==1000			;SET TO AVOID BUFFER ADVANCEMENT.
IGNRBT==2000			;SET TO AVOID USER BUFFER OVERFLOW.

IFN	FTCRTR,<

CRTRBL==4000

>
IFE	FTCRTR,<

CRTRBL==0

>

;BITS IN RH OF S
SPIMBT==1B29			;IO STATUS BIT FOR SUPER-IMAGE MODE.

;BUFFER SIZES
ASBFSZ==^D18			;BUFFER SIZE FOR ASCII MODE.
BIBFSZ==^D27			;BUFFER SIZE FOR BINARY MODE.
IMBFSZ==^D28			;BUFFER SIZE FOR IMAGE MODE.
SIBFSZ==^D81			;BUFFER SIZE FOR SUPER-IMAGE MODE.


;HARDWARE STATUS FLAGS FOR CDR
ITREN==1B18			;TROUBLE ENABLED.
IRDEN==1B19			;READY-TO-READ ENABLED.
F27PK==1B20			;PICK FAILURE FLAG, SET WITH ITRBL.
F27PC==1B21			;PHOTO CELL ERROR, SET WITH ITRBL.
F27CM==1B22			;CARD MOTION ERROR, SET WITH ITRBL.
F27ST==1B23			;STOP FLAG, SET WITH ITRBL OR EXTERNALLY.
FCIRD==1B24			;CARD IN READ FLAG.
F27HS==1B25			;HOPPER EMPTY/STACKER FULL FLAG, SET WITH ITRBL.
FRDCD==1B26			;READING CARD FLAG.
ITRBL==1B27			;TROUBLE INTERRUPT.
IDMSD==1B28			;DATA MISSED INTERRUPT.
IRDYR==1B29			;READY-TO-READ INTERRUPT.
IEOFL==1B30			;END OF FILE INTERRUPT.
IEOCD==1B31			;END OF CARD INTERRUPT.
IDRDY==1B32			;DATA READY INTERRUPT.
NOTRDY==ITRBL+IDMSD+IEOFL+IEOCD	;SYMBOL FOR TEST IN DDB'S


ENTRY	CDRSRX		;THIS NAME LETS BUILD PICK BETWEEN 2 CDRSER'S


;DISPATCH TABLE
	JRST	CDRONL		;CHECK TO SEE IF CDR IS ON LINE
	POPJ	P,0		;SPECIAL ERROR STATUS
	JRST	GTBFSZ		;GET BUFFER SIZE AS FCTN OF MODE
	JRST	CDRINI		;INITIALIZATION
	JRST	CDRHNG		;HUNG DEVICE
CDRDSP:	JRST	CDRREL		;RELEASE
	JRST	ILLOUT		;CLOSE CALLED ONLY ON ILLEGAL OUTPUT
	JRST	ILLOUT		;OUTPUT IS ILLEGAL


;HERE ON INPUT UUO TO START READER.
CDRSRX:
IFN	FTCRTR,<		;IF CDR TROUBLE INTERCEPT
	TLZN	S,CRTRBL	;TROUBLE DETECTED ON INTERRUPT?
	JRST	CDSET		;NO
	MOVEM	S,CDRIOS(F)	;YES, SAVE S (CRTRBL OFF)
	JRST	TKUSER		;AND CALL HNGSTP
>
CDSET:	PUSHJ	P,CDRONL	;CDR ON LINE?
	  JRST	TKUSER		;NO, READER MUST BE OFF, TELL USER.
CDSET1:	TLNN	S,IOBEG
	JRST	CDRGO
	TLZ	S,CR029+FORGET+IGNRBT	;YES. SET UP FOR 1ST TIME
	MOVSI	T2,PCDRAS##	;SET UP FOR ASCII CARDS
	TRNN 	S,10		;REALLY ASCII?
	JRST	SETPTR		;YES.
	MOVSI	T2,PCDRBI##	;BINARY AND IMAGE BYTE SIZE= 12.
IFN FTCDRSI,<
	TRNE	S,SPIMBT	;IS THIS SUPER-IMAGE MODE?
	MOVSI	T2,PCDRSI##	;SUPER-IMAGE BYTE SIZE = 36.
>	;END CONDITIONAL ON FTCDRSI
SETPTR:	MOVEM	T2,CDRPTR(F)	;SET BYTE SIZE
CDRGO:	TLZ	S,IOBEG		;CLEAR VIRGIN DEVICE BIT.
	PUSHJ	P,NEWBUF##	;INITIALIZE NEW BUFFER
	JRST	ADRERR		;ADDRESS ERROR
CDRGO1:	SETZM	CDRMIS(F)
	MOVEI	U,IEOFL
	XCT	CDRCSO(F)	;EOF BUTTON PRESSED?
	TLNE	S,IOEND		;EOF?
	JRST	EOF		;YES-PROCESS IT NOW
IFN FTCDRSI,<
	TRNE	S,SPIMBT	;IS S SET FOR SUPER-IMAGE MODE?
	PUSHJ	P,SETSPI	;YES, SET UP THE BLKI PTR: SUPIMG.
>	;END CONDITIONAL ON FTCDRSI
	TLO	S,COLUM1+COLUM2	;NO. INIT FOR COLUMN 1
	MOVEM	R,CDRADR(F)	;SAVE R FOR INTERRUPT ROUTINE
	MOVEI	T1,1670+CDRCHN	;SET UP CONO FOR NEXT CARD
	MOVEI	U,ITREN+IRDYR
	XCT	CDRCSO(F)	;WAS TROUBLE ENCOUNTERED OR CARD READY?
	MOVEI	T1,370+CDRCHN	;YES. SET CONO FOR READY-TO-READ
	MOVE	U,T1		;GET BITS FOR CONO INTO U
	ANDI	T1,500		;GET INTERRUPT ENABLE BITS
	ADDI	T1,270		;GET OTHER INTERRUPT BITS
	PUSHJ	P,SETDLV	;SET UP DATA LEVEL INTERRUPT
	TRO	S,IOACT		;CANT USE SETACT AS IT ZEROES IOW
	JRST	STOIOS		;WHICH MAY BE ON AFTER IGNORING A CARD
TKUSER:	HRRZ	T2,DEVBUF(F)	;ADR OF BUFFER HDR
IFN FTKA10,<
	TLO	T2,R
>
	EXCTUX	<HRRZ T1,@T2>	;CURRENT USER BUFFER
	PUSHJ	P,UADRCK##
	HLL	T1,T2
	EXCTUX	<SKIPGE @T1>	;DOES IT CONTAIN DATA?
IFN FTKI10!FTKL10,<
	PJRST	RTEVM##		;YES, GIVE IT TO THE USER
>
IFN FTKA10,<
	POPJ	P,
>
	MOVSI	T1,DVOFLN	;OFF-LINE BIT
	IORM	T1,DEVCHR(F)	;LITE IT
	PUSHJ	P,HNGSTP	;PROBLEM. OPR CAN CORRECT AND CONT.
	JRST	CDSET1		;TRY IT AGAIN.

;SUBROUTINE TO SEE IF THE CDR IS ON LINE
; RETURN CPOPJ1 IF IT IS

CDRONL:	MOVEI	U,F27ST+F27HS	;STOP CONDITION TO BE CONTINUED BY THE OPR?
	XCT	CDRCSZ(F)	;CONSZ FROM DDB
	POPJ	P,		;YES, TELL THE OPR
	MOVEI	U,IRDYR+IEOFL	;IF WE ARE HERE, READER CAN BE ON OR OFF
	XCT	CDRCSO(F)	;BUT IF ON, THIS BETTER SKIP
	POPJ	P,		;OFF
	JRST	CPOPJ1		;ON
;HERE TO GET BUFFER SIZE, CALLED DURING INIT UUO.
GTBFSZ:	MOVEI	T1,ASBFSZ	;ASSUME ASCII.
	TRNN	M,10		;C(UUO) IS USER'S INIT ARG.
	JRST	GPBFS1		;ASCII.
	MOVEI	T1,BIBFSZ	;NOT ASCII. ASSUME BINARY.
	TRNE	M,4		;BINARY?
	JRST	GPBFS1		;YES.
	MOVEI	T1,IMBFSZ	;MUST BE IMAGE MODE.
IFN FTCDRSI,<
	TRNE	M,1B29		;SUPER-IMAGE?
	MOVEI	T1,SIBFSZ	;YES, 80 WORDS OF DATA/BUFFER.
GPBFS2:	POPJ	P,		;RETURN WITH BUFFER SIZE IN TAC.
>	;END CONDITIONAL ON FTCDRSI
GPBFS1:	TRZ	M,1B29		;SUPER-IMAGE ALLOWED ONLY
	POPJ	P,		;IF INITIALIZED FOR IMAGE MODE.

IFN FTCDRSI,<
;HERE TO INITIALIZE BLKI PTR USED FOR SUPER-IMAGE MODE.
SETSPI:	MOVN	T1,CDRCTR(F)	;NEG NUMBER OF BYTES.
	HRLZ	T1,T1		;MAKE IT THE NEG CNTR IN BLKI PTR.
	HRRI	T1,@CDRPTR(F)	;PICK UP ADDRESS TO FIRST SRD OF BUFFER.
	MOVEM	T1,CDRSUP##(F)	;SET PTR.
	POPJ	P,		;AND PRETURN READY TO PROCESS A CARD.
>	;END CONDITIONAL ON FTCDRSI

;SUBROUTINE TO DISABLE INTERRUPTS ON FLAG LEVEL AND ENABLE INTERRUPTS
;ON DATA LEVEL. CALLED WITH CONO BITS IN AC(U) AND CONSO BITS
;IN AC(T1)

SETDLV:	HLLZS	CRFCON##(F)	;DISABLE FLAG LEVEL PI
	CONO	PI,PI.OFF	;DISABLE PI'S WHILE CHANGING LEVELS
	HRRM	T1,CDRCON(F)	;AND SET UP INTERRUPT LOCATION
	XCT	CDRCNO(F)	;START CARD READER
	CONO	PI,PI.ON	;TURN PI SYSTEM BACK ON
	POPJ	P,		;AND RETURN
;THIS IS THE ENTRY POINT FOR THE INTERRUPT LEVEL SERVICE FOR THE CDR

CDRINT:
IFN FT5UUO,<
	SKIPN	CDRMIS##(F)	;DONT CHANGE STATUS IF ERROR
	XCT	CRXSTS##(F)	;STORE STATUS.
>
	XCT	CDRRDY(F)	;SKIP IF DATA READY FLAG
	JRST	NOTDAT		;NOT DATA READY, FIND OUT WHAT
	AOS	CDRCOL(F)	;COUNT FOR DETECTION OF SPURIOS EOC INTERRUPTS.
IFN FTCDRSI,<
	SKIPN	CDRSUP##(F)	;SUPER-IMAGE MODE?
	JRST	NORMOD		;NO, PROCESS NORMALLY.
	XCT	CDRBKI##(F)	;YES, XMIT TO USER'S BUFFER.
	JRST	.+2		;NON-SKIP IF CDRCTR COLUMNS PROCESSED.
	JRST	CDREX1(F)	;ROOM FOR MORE COLUMNS, DISMISS INTERRUPT.

;HERE WHEN 80 CHARS HAVE BEEN XMTD TO USER.
	MOVEM	U,CDRSV2(F)	;SAVE AC(U)
	HRRZ	U,CDRSUP##(F)	;PICK UP LAST PTR ADR
	HRRM	U,CDRPTR(F)	; AND STORE IT  FOR WRD CNT CALC.
	SETZM	CDRSUP##(F)	;TURN OFF SUPER-IMAGE TEMPORARILY.
	HRLZI	U,IGNRBT	;IGNORE THE REST OF THE WORD
	IORM	U,DEVIOS(F)	;SAVE IOS
	MOVE	U,CDRSV2(F)	;RESTORE U
	JRST	CDREX1(F)	;AND EXIT

>	;END CONDITIONAL ON FTCDRSI
;HERE TO PROCESS NON SUPER-IMAGE MODE INPUT.

NORMOD:	MOVEM	U,CDRSV2(F)	;SAVE AC U
	MOVE	U,DEVIOS(F)	;GET STATUS WORD
	TLNE	U,FORGET+IGNRBT	;PROCESS IT?
	JRST	IGNORE		;NO, READ AND DISMISS
	TRNN	U,7		;SKIP IF NOT ASCII OR IMAGE
	TRNN	U,10		;SKIP IF IMAGE MODE
	JRST	NOTIMG		;ASCII OR BINARY
	XCT	CDRDTI(F)	;READ DATA INTO U
	EXCH	R,CDRADR(F)	;ADDRESS OF USER
	IDPB	U,CDRPTR(F)	;PUT INTO USER'S BUFFER
	HRLZI	U,IGNRBT	;BIT TO IGNORE REST OF CARD
	SOSG	CDRCTR(F)	;ROOM FOR MORE?
	IORM	U,DEVIOS(F)	;NO, SET IGNORE BIT
	EXCH	R,CDRADR(F)	;RESTORE R
	JRST	CDRXIT		;RESTORE IT AND EXIT

;HERE TO READ AND THROW AWAY THE COLUMN
IGNORE:	XCT	CDRDTI(F)	;READ THE COLUMN
CDRXIT:	MOVE	U,CDRSV2(F)	;RESTORE U
	JRST	CDREX1(F)	;AND EXIT
;HERE IF DATA IS IN ASCII MODE, READ AND CONVERT
NOTIMG:	XCT	CDRDTI(F)	;READ THE COLUMN INTO U
	EXCH	U,CDRSV2(F)	;SAVE DATA, RESTORE U
	JSR	CDRSVE(F)	;SAVE INTERRUPT AC'S
	HRRZ	U,CDRSV2(F)	;GET BACK DATA
	MOVE	R,CDRADR(F)	;ADDRESS OF USER
	MOVE	S,DEVIOS(F)	;GET STATUS WORD TO S
	TLZE	S,COLUM1	;FIRST COLUMN?
	JRST	FSTCOL		;YES, MAKE SPECIAL CHECKS
CDRDIS:	TRNN	S,10		;ASCII?
	JRST	CDRASC		;YES, CONVERT IT
	JRST	DISRET		;NO, STORE BINARY DATA IN USER'S BUFFER
;HERE ON INTERRUPTS OTHER THAN DATA READY

NOTDAT:	XCT	CDRRTR(F)	;SKIP IF READY TO READ INTERRUPT
	JRST	CRFLAG		;GO PROCESS NON-DATA INTERRUPT.
	MOVEM	U,CDRSV2(F)	;READY TO READ, SAVE U
	MOVEI	U,670		;GET INTERRUPT MASK
	HRRM	U,CDRCON(F)	;AND SET UP INTERRUPT LOCATION
	MOVEI	U,1670+CDRCHN	;GET CONO BITS
	XCT	CDRCNO(F)	;START CARD MOVING.
	MOVE	U,CDRSV2(F)	;RESTORE U
	JRST	CDREX1(F)	;AND EXIT
;HERE WHEN AN ASCII CHARACTER IS READ
CDRASC:	SETZB	T1,T2
	JUMPE	U,CDRAS2	;0-PICK UP AN ASCII BLANK
	CAIN	U,5000
	MOVEI	U,4202
	CAIN	U,3000
	MOVEI	U,2202
	LDB	T2,[XWD 110300,U]
	TRNE	U,3
	TRC	T2,7
	TRNE	U,74
	TRO	T2,10
	TRNE	U,314
	TRO	T1,2
	TRNE	U,525
	TRO	T1,1
	TLNE	S,CR029		;AN 029 CARD READ?
	TRO	T2,20		;NO. BUMP T2 TO 026 TABLE
CDRAS2:	LDB	U,CRCVPT##(T1)	;PICK UP ASCII CHAR FROM TABLE
DISRET:	IDPB	U,CDRPTR(F)	;STORE CHAR IN USERS BUFFER
	SOSLE	CDRCTR(F)	;ROOM FOR MORE?
	POPJ	P,		;YES, EXIT
	TLO	S,IGNRBT	;IGNORE REST OF CARD
STODIS:	MOVEM	S,CDRIOS(F)	;SAVE STATUS
	POPJ	P,		;AND EXIT

CRFLAG:	MOVEM	U,CDRSV2(F)	;SAVE AC
	HLLZS	CDRCON(F)	;DISABLE DATA LEVEL INTERRUPT
	MOVEI	U,660		;SET UP FLAG LEVEL INTERRUPT
	HRRM	U,CRFCON(F)	;TO CATCH CHANGE OF PI LEVELS
	MOVEI	U,CRFCHN##+ITRBL+IRDYR  ;GET FLAG LEVEL PI
	XCT	CDRCNO(F)	;CHANGE INTERRUPT LEVELS
	MOVE	U,CDRSV2(F)	;RESTORE U
	JRST	CDREX1(F)	;AND DISMISS
;HERE WHEN THE 1ST COLUMN OF A CARD HAS BEEN READ.
FSTCOL:	TLNN	S,COLUM2	;REALLY FIRST COL?
	JRST	NOTFST		;NO, IT'S THE 2ND COL.
	CAIE	U,CODEOF+NEWEOF	;YES, IS IT AN EOF?
	CAIN	U,CODEOF	;MAYBE, CHECK ANOTHER STYLE OF EOF.
	JRST	EOFCRD		;YES, GO PROCESS.
	CAIN	U,NEWEOF	;MAYBE, SEE IF ITS THE NEW EOF.
	JRST	EOFCRD		;YES, PROCESS.
NOTFST:	TRNE	S,10		;ASCII CARD?
	JRST	NOTASC		;NO
	CAIN	U,COD026	;YES. IS IT AN 026 CARD?
	JRST	SET026		;YES. HANDLE IT
	CAIE	U,COD029
	JRST	SETIOS
	TLZ	S,CR029
	TLO	S,FORGET
SETIOS:	MOVEM	S,CDRIOS(F)	;SAVE S
	TLNN	S,FORGET	;FORGET REST OF CARD?
	JRST	CDRDIS		;NO. PROCESS IT
	POPJ	P,		;YES. DISMISS INTERRUPT
SETFRG:	TLOA	S,FORGET	;SET BIT TO FORGET ABOUT CARD
NOTASC:	TRNN	S,4		;COL 1 OF A NOT ASCII CARD
	JRST	SETIOS		;IMAGE MODE - NO PROCESSING
	TLZN	S,COLUM2	;COLUMN1?
	JRST	COL2IN		;NO. COLUMN2 JUST READ
	MOVEI	T1,-5(U)	;COL1 - IS THERE A 7-9 PUNCH?
	TRNE	T1,17
	TRO	S,IOIMPM	;NO. SET ERROR BIT
	LSH	U,-6		;COLUMNS 12-3 ARE WORD COUNT
	JUMPE	U,SETFRG	;FORGET CARD IF WRDCNT=0
	PUSH	P,U		;SAVE U
	IMULI	U,3		;COMPUTE ITEM COUNT
	CAMGE	U,CDRCTR(F)	;MORE THAN THE BUFFER CAN HOLD?
	MOVEM	U,CDRCTR(F)	;NO. SAVE AS REAL COUNT
	POP	P,U		;GET WRDCNT
	HRRM	U,@CDRPTR(F)	;IN R.H. OF 1ST DATA WORD OF BUFFER
	TLO	S,COLUM1	;SET TO PICK UP COLUMN2 
	JRST	STODIS		;STORE S AND RETURN

;HERE WHEN COL 2 OF A BINARY CARD WAS READ
COL2IN:	MOVSM	U,CDRCHK(F)	;COLUMN2 IS CHECKSUM
	HRLM	U,@CDRPTR(F)	;ALSO IN L.H. OF 1ST DATA WORD
	JRST	STODIS		;STORE S AND RETURN
;HERE ON A NON-DATA CDR INTERRUPT
INTERNAL CRFINT

CRFINT:	MOVE	S,CDRIOS(F)	;AND GET STATUS INTO S
	MOVE	R,CDRADR(F)	;RESTORE R
	MOVEI	U,IEOCD
	XCT	CDRCSO(F)	;END OF CARD?
	JRST	NOTEOC		;NO
	MOVE	U,CDRCOL(F)	;YES, EOC INTERRUPT.
	SKIPE	CDRMIS(F)
	JRST	DONCNT
	CAIGE	U,^D79
	JRST	SPUEOC		;NO, ASSUME SPURIOUS INTERRUPT.
DONCNT:	SETOM	CDRCOL(F)	;YES, RE-INIT COL CNT.
	AOS	CDRCNT##(F)
	TLZE	S,FORGET	;FORGET ABOUT CARD?
	JRST	CDRGO1		;YES, START TO READ NEXT CARD.
IFN FTCDRSI,<
	SKIPN	CDRSUP##(F)	;IF CDRSUP NON-ZERO, CDRPTR MUST BE SET.
	JRST	NTSUPI		;CDRPTR ALREADY SET OR NOT IN SUPER-IMAGE MODE.
	HRRZ	U,CDRSUP##(F)	;PICK UP LWA OF XFR.
	HLL	U,CDRIAD##(F)	;LIGHT (R) IF A KA
	MOVEM	U,CDRPTR(F)	;SET IN PTR FOR WORD CNT CALC.
	SETZM	CDRSUP##(F)	;FLAG THAT ITS DONE.
>	;END CONDITIONAL ON FTCDRSI
NTSUPI:	TRNE	S,10		;BINARY?
	JRST	BINEOC		;YES. CHECK CHKSUM
	MOVEI	U,15		;NO. INSERT <CR>
	IDPB	U,CDRPTR(F)
	MOVEI	U,12		;INSERT <LF>
	IDPB	U,CDRPTR(F)
NXTCRD:	TLZ	S,IGNRBT	;SET UP TO READ NEXT CARD
	MOVEI	T1,@CDRPTR(F)	;LAST ADDRESS
	MOVEI	T2,@CDRIAD(F)	;FIRST ADDRESS (-1)
	SUBI	T1,1(T2)	;COMPUTE NUMBER OF WORDS STORED
	HRRM	T1,1(T2)	;STORE IN 1ST WORD OF BUFFER
				;IN IO WAIT?
	PUSHJ	P,SETIOD	;YES. TAKE OUT
	PUSHJ	P,ADVBFF	;ADVANCE BUFFERS
	JRST	CDROFF		;NEXT BUFFER NOT EMPTY
	MOVEI	U,F27ST+F27HS
	XCT	CDRCSO(F)	;SKIP IF STOP CONDITION
	TRNE	S,IODERR+IOIMPM+IODTER	;BUFFER AVAILABLE, ANY ERRORS?
	JRST	CDROFF		;YES, TURN OFF CDR.
	JRST	CDRGO		;NO, PROCEES READING CARDS.

;HERE TO PROCESS SPURIOUS EOC INTERRUPTS.

SPUEOC:	AOS	CDRSPU(F)
	MOVEI	T1,IEOCD+CDRCHN	;SET TO CLEAR EOC
	MOVEI	U,ITREN
	XCT	CDRCSZ(F)	;TROUBLE ENABLED?
	TRO	T1,ITRBL	;YES
	MOVEI	U,IRDEN
	XCT	CDRCSZ(F)	;RDY TO READ ENABLED?
	TRO	T1,IRDYR	;YES
	MOVE	U,T1
	ANDI	T1,500
	ADDI	T1,270
	PUSHJ	P,SETDLV	;GO BACK TO DATA LEVEL
	SKIPGE	CDRCOL(F)	;ARE WE ACTIVELY PROCESSING A CARD?
	POPJ	P,		;NO, DISMISS SINCE THIS SHOULDN'T HARM.
	MOVEI	U,^D79		;YES, FLAG IT AND LET ANY FURTHER
	MOVEM	U,CDRCOL(F)	; SPURIOUS INTERRUPTS FOR THIS CARD PASS THRU.
	JRST	SETERR		;FLAG IT AND DISMISS.
;HERE ON THE END OF A BINARY CARD

BINEOC:	TRNN	S,4		;REALLY BINARY?
	JRST	NXTCRD		;IMAGE MODE 
	MOVEI	T2,@CDRIAD(F)	;ADDRESS OF BUFFER
	PUSHJ	P,CKS12		;COMPUTE CHECKSUM
	CAME	T1,CDRCHK(F)	;DOES IT COMPARE WITH CARD'S CHKSUM?
	TRO	S,IODTER	;NO. LIGHT A BIT
	JRST	NXTCRD		;START READ OF NEXT CARD
SET026:	TLOA	S,CR029		;026 - RESET 029 BIT
EOFCRD:	TLO	S,IOEND		;EOF - LIGHT BIT
	JRST	SETFRG		;FORGET REST OF CARD
NOTEOC:	MOVEI	U,IEOFL
	XCT	CDRCSZ(F)	;EOF BUTTON PRESSED?
	JRST	EOF		;YES.
	MOVEI	U,ITRBL
	XCT	CDRCSO(F)	;TROUBLE?
	JRST	NOTRBL		;NO, PROCEED
	MOVEI	U,CDRCHN
	MOVEI	T1,270
	PUSHJ	P,SETDLV	;GO BACK TO DATA LEVEL
NOTRBL:	MOVEI	U,F27PC+F27CM+IDMSD
	XCT	CDRCSO(F)	;ERROR EXCEPT PICK OR STOP BUTTON?
	JRST	SETRDY		;NO. GO SET READY-TO-READ INTERRUPT
SETERR:	TRO	S,IODERR	;YES. SET  ERROR BIT
	MOVEI	T1,670
	MOVEI	U,IDMSD+CDRCHN
	PUSHJ	P,SETDLV	;GO BACK TO DATA LEVEL
	SETOM	CDRMIS##(F)
	PJRST	STOIOS##
STOERR:	PUSHJ	P,CDROFF	;DISABLE INTERRUPTS SINCE IOACT CLEARED BY DEVERR

IFN	FTCRTR,<
	TLO	S,CRTRBL	;SET TROUBLE BIT IF CDR TROUBLE INTERCEPT
>
	MOVEM	S,CDRIOS(F)	;STORE STATUS
IFN	FTCRTR,<
	PJRST	DEVERR##	;AND REPORT ERROR
>
IFE	FTCRTR,<
	POPJ	P,		;DISMISS INTERRUPT
>
EOF:	TLO	S,IOEND+IOBEG	;EOF - LIGHT BIT
CDRREL:	MOVEI	T1,0		;
	DPB	T1,PBUFSZ	;ZERO OUT BUFFER SIZE.
	SETOM	CDRCOL(F)	;INITIALIZE COLUMN COUNT.
IFN FTCDRSI,<
	SETZM	CDRSUP##(F)	;TURN OFF SUPERIMAGE MODE.
>
IFN	FTCRTR,<		;IF CDR TROUBLE INTERCEPT
	TLZ	S,CRTRBL	;CLEAR TROUBLE BIT
>
CDROFF:
	MOVEI	U,10000		;CONTROLLER RESET BIT
	XCT	CDRCNO(F)
	HLLZS	CDRCON(F)	;RESET INTERUPT LOC
	HLLZS	CRFCON(F)	;ALSO FLAG LEVEL
	PUSHJ	P,SETIOD	;TAKE OUT OF IO WAIT
IFN FTKI10!FTKL10,<
	PUSHJ	P,RTEVM##	;RETRUN ANY EVM
>
	JRST	CLRACT		;ZERO IOACT, STORE S AND RETURN

SETRDY:	MOVEI	U,F27HS
	XCT	CDRCSZ(F)
	JRST	TSTINR
	MOVEI	U,10000		;CONTROLLER RESET BIT
	XCT	CDRCNO(F)	;RESET READ-A-CARD FLOP
	JRST	CDRGO		;ENABLE FOR READY TO READ

;HERE ON HOPPER/STACKER ERROR
TSTINR:	MOVEI	U,FCIRD
	XCT	CDRCSZ(F)	;CARD IN READER?
	POPJ	P,		;YES, IGNORE INTERRUPT (TRBL NOT ENEBLED)
	PJRST	STOERR		;NO, GO INTERCEPT THE ERROR


CDRINI:	MOVEI	U,10000		;CONTROLLER RESET BIT
	XCT	CDRCNO(F)
	HLLZS	CDRCON(F)	;CLEAR SKIP CHAIN MASK FLAGS
	HLLZS	CRFCON(F)	; FOR BOTH DATA AND FLAGS
	SETOM	CDRCOL(F)	;INITIALIZE COLUMN COUNT
IFN FTCDRSI,<			;IF SUPERIMAGE MODE
	SETZM	CDRSUP##(F)	;TURN OFF SUPERIMAGE MODE
>
	JRST	CPOPJ1		;SKIP RETURN TO FORCE CALL FOR EACH CDR

;HERE ON HUNG DEVICE TIME OUT IF TROUBLE INTERCEPT ENABLED
IFN FTCRTR,<
CDRHNG:	MOVEI	U,F27PC+F27CM+FCIRD	;IF PHOTO CELL DARK, CARD MOTION
	XCT	CDRCSZ(F)	; ERROR, OR CARD IN READER AFTER TIME OUT
	TRO	S,IODERR	;LIGHT AN ERROR BIT
	PUSHJ	P,CDRREL	;RELEASE AND TURN OFF CDR
	AOS	(P)		;SKIP RETURN SO NO HUNG MESSAGE
	PJRST	STOERR		;AND RETURN
>
IFE FTCRTR,<CDRHNG=CDRREL>
	END