NEW
  AUTO 3,1
				.LIST OFF
*--------------------------------------
TBOX.New		>LDYAI 1024
				>SYSCALL2 GetMem
				bcs .9

				>STYA ZPPtr1
				txa
				
				ldy #S.TBOX.hBuf
				sta (ZPObjPtr),y
				
				lda #0
				sta (ZPPtr1)

				ldy #S.TBOX.CurX
				
.1				sta (ZPObjPtr),y
				iny
				cpy #S.TBOX.DocY+1
				bne .1
				
				clc

.9				rts
*--------------------------------------
TBOX.Destroy	ldy #S.TBOX.hBuf
				lda (ZPObjPtr),y
				beq .8
	
				>SYSCALL2 FreeMem
	
.8				clc
				rts
*--------------------------------------
TBOX.Run		lda (pStack)			Event
				cmp #C.SPACE
				bcc .8


.9				sec

.8
				rts
*--------------------------------------
TBOX.Draw		ldy #S.OBJ.InnerW
				lda (ZPObjPtr),y

				tax
				lda #C.SPACE

.1				jsr LIB.LineBufCOut
				dex
				bne .1

				clc
				rts
*--------------------------------------
TBOX.Activate	jsr LIB.LineBufInit
				
				ldy #S.OBJ.InnerX
				lda (ZPObjPtr),y
				clc
				ldy #S.TBOX.CurX
				adc (ZPObjPtr),y
				tax

				ldy #S.OBJ.InnerY
				lda (ZPObjPtr),y
				clc
				ldy #S.TBOX.CurY
				adc (ZPObjPtr),y
				tay
				jsr LIB.GotoXY

				ldx #SEQ.CURON-SEQS
				jsr LIB.LineBufSeqOut
				
				jmp LIB.LineBufOut
*--------------------------------------
TBOX.Deactivate	jsr LIB.LineBufInit

				ldx #SEQ.CUROFF-SEQS
				jsr LIB.LineBufSeqOut
				
				jmp LIB.LineBufOut
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.tbox
LOAD usr/src/lib/libtui.s
ASM
