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.STATCODE
				lda (ZPIOCTL),y
				bra TERM.TOAUX

TERM.CONTROL
TERM.OPEN
TERM.CLOSE		pha						DEV.ID in A for OPEN
				jsr TERM.GetDCB
				pla
				bra TERM.TOAUX
				
TERM.READ
TERM.WRITE		jsr TERM.GetIOCTLBufCntDCB
*--------------------------------------
TERM.TOAUX		sta SETREADAUX
				sta SETWRITEAUX
				jsr .1
				sta CLRREADAUX
				sta CLRWRITEAUX
				rts
				
.1				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 ZPCount
				iny
				lda (ZPIOCTL),y
				eor #$ff
				sta ZPCount+1
*--------------------------------------
TERM.GetDCB		ldy #S.FD.DEV.DCBPTR
				lda (pFD),y
				sta ZPDCBPtr

				iny
				lda (pFD),y
				sta ZPDCBPtr+1

				iny						S.FD.DEV.BUFPTR
				lda (pFD),y
				sta ZPBufBase
				
				iny
				lda (pFD),y
				sta ZPBufBase+1

				lda (ZPDCBPtr)			#S.DCB.TTY.DEVID
				cmp DevMgr.ASCREEN
				beq .1					CS

				clc

.1				ror bActive

				rts
*--------------------------------------
TERM.GetBufByte	sta CLRREADAUX
				lda (ZPBufPtr)
				sta SETREADAUX
				rts
*--------------------------------------
TERM.GetDevName	sta CLRREADAUX

				lda (ZPDCBPtr)			#S.DCB.TTY.DEVID
				tax
				lda Dev.Table-1,x
				clc
				adc #S.FD.DEV
				sta TXTPTR
				
				lda Dev.Table,x
				adc /S.FD.DEV

				sta TXTPTR+1
				sta SETREADAUX
				rts
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.TERM
LOAD USR/SRC/SYS/KERNEL.S
ASM
