NEW
  AUTO 3,1
				.LIST OFF
*--------------------------------------
* CONT.New hCTX,F						2
*--------------------------------------
CONT.New		jsr OBJ.Create			A = Class
				bcs .9

				>PULLA
				ldy #S.OBJ.F
				sta (ZPObjPtr),y

				>PULLA
				ldy #S.OBJ.hParent
				sta (ZPObjPtr),y

				>SYSCALL2 GetMemPtr
				>STYA ZPPtr2

				ldy #S.CTX.W
				lda (ZPPtr2),y
				ldy #S.OBJ.W
				sta (ZPObjPtr),y

				ldy #S.CTX.H
				lda (ZPPtr2),y
				ldy #S.OBJ.H
				sta (ZPObjPtr),y

				jmp OBJ.SetX2Y2

.9				>POP 2
				rts
*--------------------------------------
CONT.Insert		>SYSCALL2 GetMemPtr		A = hParent
				>STYA ZPPtr2

				ldy #S.OBJ.Childs

.1				lda (ZPPtr2),y
				beq .2

				iny
				cpy #S.OBJ
				bcc .1

				lda #E.OOH
*				sec
				rts

.2				lda hObj
				sta (ZPPtr2),y

				ldy #S.OBJ.S
				lda (ZPPtr2),y
				ora #S.OBJ.S.bHasChilds
				sta (ZPPtr2),y

				ldy #S.OBJ.InnerX
				lda (ZPPtr2),y

				ldy #S.OBJ.X1
				clc
				adc (ZPObjPtr),y
				sta (ZPObjPtr),y

				ldy #S.OBJ.InnerY
				lda (ZPPtr2),y

				ldy #S.OBJ.Y1
				clc
				adc (ZPObjPtr),y
				sta (ZPObjPtr),y

				jmp OBJ.SetX2Y2
*--------------------------------------
CONT.Run		lda (pStack)			Event
				cmp #C.TAB
				bne .9

				ldy #1
				lda (pStack),y			hObj
				jsr OBJ.FindActive
				bcs .9

				>PUSHA					hActive

				phy						index

				ldy #2
				lda (pStack),y			hObj
				>SYSCALL2 GetMemPtr
				>STYA ZPPtr1

.10				ply

.1				iny
				cpy #S.OBJ
				bne .2

				ldy #S.OBJ.Childs

.2				lda (ZPPtr1),y
				beq .1

				cmp (pStack)			same as hActive ?
				beq .8

				phy

				>SYSCALL2 GetMemPtr
				>STYA ZPPtr2

				ldy #S.OBJ.S
				lda (ZPPtr2),y
				and #S.OBJ.S.bDisabled+S.OBJ.S.bHidden
				bne .10

				ply
				lda (ZPPtr1),y
				pha

.3				lda (pStack)
				jsr OBJ.Deactivate
				inc pStack				discard old hActive

				pla
				>PUSHA					new hActive
				jsr OBJ.Activate2

.8				inc pStack				discard hActive

				clc
				rts

.9				lda #0
				sec
				rts
*--------------------------------------
CONT.Draw		ldy #S.OBJ.InnerW
				lda (ZPObjPtr),y

				tax
				lda #C.SPACE

.1				jsr LB.COut
				dex
				bne .1

				clc
				rts
*--------------------------------------
MAN
SAVE usr/src/lib/libtui.s.cont
LOAD usr/src/lib/libtui.s
ASM
