NEW
  AUTO 3,1
*--------------------------------------
DRV.TERM		cld

				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		sta ZPDevID				DEV.ID 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 SETREADAUX
				sta SETWRITEAUX
				
				cmp (ZPDCBPtr)			#S.DCB.TTY.DEVID
				
				beq .1					CS

				clc

.1				ror bActive
				sta SET80STORE
				jsr .8

				sta CLRREADAUX
				sta 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 CLRREADAUX
				lda (ZPBufPtr)
				sta SETREADAUX
				rts
*--------------------------------------
TERM.GetDevName	sta CLRREADAUX

				lda Dev.Table-1,x
				clc
				adc #S.FD.DEV
				tay
				
				lda Dev.Table,x
				adc /S.FD.DEV

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