NEW
  AUTO 3,1
*--------------------------------------
IBlkPtr			.EQ ZPMEMMGR+12
DBlkPtr 		.EQ ZPMEMMGR+14			
*--------------------------------------
KeyID			.EQ *
iByte			.BS 1
iBlk			.BS 1
*--------------------------------------
BLISTX.New		sta SLISTX.Opt

				>LDYAI 128				32k Max before out of memory!!!
				ldx #S.MEM.F.INIT0+8	index
				jsr MEM.GetMem.YAX
				bcs .9
				
				>STYA IBlkPtr
				stx .8+1
				
				>LDYAI 256
				ldx #4					data
				jsr MEM.GetMem.YAX
				bcs .9
				
				>STYA DBlkPtr

				lda #0
				sta (DBlkPtr)

				lda SLISTX.Opt
				sta (IBlkPtr)
				
				txa
				ldy #1
				sta (IBlkPtr),y
				
.8				lda #$ff				SELF MODIFIED
*				clc
.9				rts
*--------------------------------------
BLISTX.Free		pha

				jsr K.GetMemPtr
				>STYA .1+1
				
				ldx #1

.1				lda $ffff,x				SELF MODIFIED
				beq .8
				
				phx
				jsr K.FreeMem
				
				plx
				inx
				bra .1
				
.8				pla
				jmp K.FreeMem
*--------------------------------------
BLISTX.GetNByte	ldy iByte
				lda (DBlkPtr),y

BLISTX.2NByte	inc iByte
				bne .8

				pha
				jsr BLISTX.2NBlk
				pla
.8				rts
*--------------------------------------
BLISTX.AddByte	phy
				ldy iByte
				sta (DBlkPtr),y
				inc iByte
				bne .8

				phx
				>LDYAI 256
				ldx #4
				jsr MEM.GetMem.YAX
				bcs .9

				>STYA DBlkPtr
				txa
				inc iBlk 
				ldy iBlk 
				sta (IBlkPtr),y

*				stz iByte
				plx
				
.8				ply
				clc
				rts

.9				plx
				ply
				rts
*--------------------------------------
BLISTX.SetBlkByte
				ldy iByte
				sta (DBlkPtr),y
				inc iByte
				bne BLISTX.RTS
*--------------------------------------
BLISTX.2NBlk	inc iBlk
				ldy iBlk
				lda (IBlkPtr),y
				jsr K.GetMemPtr
				>STYA DBlkPtr
BLISTX.RTS		rts
*--------------------------------------
MAN
SAVE usr/src/sys/kernel.s.blistx
LOAD usr/src/sys/kernel.s
ASM
