NEW
  AUTO 3,1
*--------------------------------------
DRV.TERM		jmp (.1,x)

.1				.DA TERM.STATUS
				.DA A2osX.BADCALL
				.DA A2osX.BADCALL
				.DA A2osX.BADCALL
				.DA TERM.CONTROL
				.DA A2osX.BADCALL
				.DA TERM.OPEN
				.DA TERM.CLOSE
				.DA TERM.READ
				.DA TERM.WRITE
*--------------------------------------
TERM.STATUS		jsr TERM.GetIOCTLBufCntDCB
				
				ldy #S.IOCTL.S
				lda (ZPIOCTL),y
				tay
				bra TERM.TOAUX
*--------------------------------------
TERM.OPEN		
* hFD in A for OPEN

TERM.CONTROL
TERM.CLOSE		jsr TERM.GetDCB

				bra TERM.TOAUX
*--------------------------------------
TERM.READ
TERM.WRITE		jsr TERM.GetIOCTLBufCntDCB
*--------------------------------------
TERM.TOAUX		lda A2osX.ASCREEN
				
				sta IO.SETREADAUX
				sta IO.SETWRITEAUX
				
				cmp (ZPDCBPtr)			#S.DCB.TTY.DEVID
				
				beq .1					CS

				clc

.1				ror bActive

				jsr .8

				sta IO.CLRREADAUX
				sta IO.CLRWRITEAUX
				rts
				
.8				jmp (TERMX,x)
*--------------------------------------
TERM.GetIOCTLBufCntDCB
				>STYA ZPIOCTL

				ldy #S.IOCTL.BUFPTR
				lda (ZPIOCTL),y
				sta ZPBufPtr
				iny 
				lda (ZPIOCTL),y
				sta ZPBufPtr+1

				iny						#S.IOCTL.BYTECNT

				lda (ZPIOCTL),y
				eor #$ff
				sta ZPCnt
				iny
				lda (ZPIOCTL),y
				eor #$ff
				sta ZPCnt+1
*--------------------------------------
TERM.GetDCB		ldy #S.FD.DEV.DCBPTR
				
				lda (pFD),y
				sta ZPDCBPtr

				iny
				lda (pFD),y
				sta ZPDCBPtr+1

				rts
*--------------------------------------
TERM.GetBufByte	sta IO.CLRREADAUX
				lda (ZPBufPtr)
				sta IO.SETREADAUX
				rts
*--------------------------------------
TERM.GetDevName	sta IO.CLRREADAUX
				
				lda pFD
				clc
				adc #S.FD.DEV
				sta TXTPTR
				
				lda pFD+1
				adc /S.FD.DEV
				sta TXTPTR+1

				sta IO.SETREADAUX
				rts
*--------------------------------------
MAN
SAVE usr/src/sys/kernel.s.term
LOAD usr/src/sys/kernel.s
ASM
