A2osX/SYS/KERNEL.S.SLIST.txt
2019-03-21 07:07:38 +00:00

485 lines
8.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
*--------------------------------------
X.SLIST jmp (.1-SYS.SListGetData,x)
.1 .DA SLIST.GetData
.DA SLIST.AddData
.DA SLIST.SetData
.DA SLIST.GetByID
.DA SLIST.NewKey
.DA SLIST.Lookup
.DA SLIST.New
.DA SLIST.Free
*--------------------------------------
SLIST.GetData jsr SLIST.Select
jsr SLIST.SkipKey
jsr SLIST.GetDataLen
lda SLIST.DataLen
sec
sbc ZPMemMgrSize
eor #$ff
sta SLIST.nDataCnt
lda SLIST.DataLen+1
sbc ZPMemMgrSize
eor #$ff
sta SLIST.nDataCnt+1 Data remaining
bcc .99
.10 lda ZPMemMgrSize
ldx ZPMemMgrSize+1
jsr SLIST.SkipDataAX
lda ZPSListDataPtr
ora ZPSListDataPtr+1
bne .12
>LDYA SLIST.DataLen
jsr MEM.GetMainBuf
bcs .9
stx .82+1
>STYA ZPSListDataPtr
.12 lda ZPSListDataLen
ora ZPSListDataLen+1
sec
beq .1 String Mode
lda ZPSListDataLen
eor #$ff
sta SLIST.nBufCnt
lda ZPSListDataLen+1
eor #$ff
sta SLIST.nBufCnt+1
clc
.1 ror SLIST.bStringMode
stz ZPSListDataLen
stz ZPSListDataLen+1
.2 inc SLIST.nDataCnt
bne .3
inc SLIST.nDataCnt+1
beq .8
.3 inc SLIST.nBufCnt
bne .4
inc SLIST.nBufCnt+1
beq .8
.4 jsr SLIST.GetNextByte
bit SLIST.bStringMode
bpl .5
cmp #C.CR
beq .7
.5 jsr MEM.SetDataByte
inc ZPSListDataLen
bne .2
inc ZPSListDataLen+1
bra .2
.99 lda #E.NODATA
sec
.9 rts
.7 jsr SLIST.GetNextByte
.8 bit SLIST.bStringMode
bpl .81
lda #0
jsr MEM.SetDataByte
inc ZPSListDataLen
bne .81
inc ZPSListDataLen+1
.81 >LDYA ZPSListDataLen
.82 ldx #$ff SELF MODIFIED
clc
rts
*--------------------------------------
SLIST.AddData jsr SLIST.Select
jsr SLIST.SkipKey
>LDYA SLIST.KeyID Save DataLen location
>STYA ZPSListKeyID to update later
jsr SLIST.SkipData
lda ZPSListDataLen
pha
clc
adc SLIST.DataLen
sta SLIST.DataLen
pla
eor #$ff
sta ZPSListDataLen
lda ZPSListDataLen+1
pha
adc SLIST.DataLen+1
sta SLIST.DataLen+1
pla
eor #$ff
sta ZPSListDataLen+1
.1 inc ZPSListDataLen
bne .2
inc ZPSListDataLen+1
beq .8
.2 jsr MEM.GetDataByte
jsr SLIST.AddBlockByte
bcc .1
rts
.8 lda #0
jsr SLIST.AddBlockByte Make sure 0 follow DATA
bcs .9
jsr SLIST.Select.I go back to DataLen Location
lda SLIST.DataLen
jsr SLIST.SetBlockByte
lda SLIST.DataLen+1
jsr SLIST.SetBlockByte
clc
.9 rts
*--------------------------------------
SLIST.SetData jsr SLIST.Select
jsr SLIST.SkipKey
jsr SLIST.GetDataLen
lda SLIST.DataLen
cmp ZPSListDataLen
bne .9
ldx SLIST.DataLen+1
cpx ZPSListDataLen+1
bne .9
eor #$ff
sta SLIST.nDataCnt
txa
eor #$ff
sta SLIST.nDataCnt+1
.1 inc SLIST.nDataCnt
bne .2
inc SLIST.nDataCnt+1
beq .8
.2 jsr MEM.GetDataByte
jsr SLIST.SetBlockByte
bra .1
.8 clc
rts
.9 lda #E.DATALEN
sec
rts
*--------------------------------------
SLIST.GetByID jsr SLIST.Select
jsr SLIST.GetNextByte
tax
beq .9
ldy #0
.1 phy
jsr SLIST.GetNextByte
ply
jsr MEM.SetKeyCharY
iny
dex
bne .1
txa lda #0
jsr MEM.SetKeyCharY
jsr SLIST.SkipData
>LDYA SLIST.KeyID
clc
rts
.9 lda #E.NOKEY
sec
rts
*--------------------------------------
SLIST.NewKey jsr SLIST.Search
bcc .99
lda SLIST.KeyLen
jsr SLIST.AddBlockByte
bcs .9
ldy #0
.1 jsr MEM.GetKeyCharY
jsr SLIST.AddBlockByte
bcs .9
iny
cpy SLIST.KeyLen
bne .1
lda #0
jsr SLIST.AddBlockByte
bcs .9
lda #0
jsr SLIST.AddBlockByte
bcs .9
>LDYA ZPSListKeyID
ldx SLIST.KeyLen
clc
rts
.99 lda #E.DUPKEY
sec
.9 rts
*--------------------------------------
SLIST.Lookup jsr SLIST.Search
bcs .9
>LDYA ZPSListKeyID
ldx SLIST.KeyLen
.9 rts
*--------------------------------------
SLIST.New >LDYAI 160 40k Max before out of memory!!!
jsr K.GetMem0
bcs .9
>STYA ZPSListIBlkPtr
stx .8+1
>LDYAI 256
jsr K.GetMem0
bcs .9
txa
sta (ZPSListIBlkPtr)
.8 lda #$ff SELF MODIFIED
.9 rts
*--------------------------------------
SLIST.Free sta .8+1
jsr K.GetMemPtr
>STYA .1+1
ldx #0
.1 lda $ffff,x SELF MODIFIED
beq .8
jsr K.FreeMem
inx
bra .1
.8 lda #$ff SELF MODIFIED
jmp K.FreeMem
*--------------------------------------
* PRIVATE
*--------------------------------------
SLIST.Select jsr K.GetMemPtr
>STYA ZPSListIBlkPtr
SLIST.Select.I ldy ZPSListKeyID+1
sty SLIST.BlockPtr
lda (ZPSListIBlkPtr),y
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
lda ZPSListKeyID
sta SLIST.BytePtr
rts
*--------------------------------------
SLIST.Search jsr K.GetMemPtr
>STYA ZPSListIBlkPtr
stz SLIST.BlockPtr
lda (ZPSListIBlkPtr)
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
stz SLIST.BytePtr
ldy #$ff
.1 iny
jsr MEM.GetKeyCharY
bcc .1
sty SLIST.KeyLen
.2 >LDYA SLIST.KeyID
>STYA ZPSListKeyID
ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y
beq .9
cmp SLIST.KeyLen
bne .5
jsr SLIST.GetNextByte Skip Len
ldy #0
.3 phy
jsr SLIST.GetNextByte
sta .4+1
ply
jsr MEM.GetKeyCharY
.4 cmp #$ff SELF MODIFIED
bne .5
iny
cpy SLIST.KeyLen
bne .3
clc
rts
.5 >LDYA ZPSListKeyID
>STYA SLIST.KeyID
jsr SLIST.Next
bra .2
.9 lda #E.NOKEY
sec
rts
*--------------------------------------
SLIST.Next jsr SLIST.SkipKey
SLIST.SkipData jsr SLIST.GetDataLen
lda SLIST.DataLen
ldx SLIST.DataLen+1
SLIST.SkipDataAX
clc
adc SLIST.BytePtr
sta SLIST.BytePtr
txa
adc SLIST.BlockPtr
sta SLIST.BlockPtr
tay
lda (ZPSListIBlkPtr),y
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
rts
*--------------------------------------
SLIST.SkipKey ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y Get KeyLen
sec
adc SLIST.BytePtr
sta SLIST.BytePtr
bcc .8
inc SLIST.BlockPtr
lda SLIST.BlockPtr
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
.8 rts
*--------------------------------------
SLIST.GetDataLen
jsr SLIST.GetNextByte Get DataLenLo
sta SLIST.DataLen
jsr SLIST.GetNextByte Get DataLenHI
sta SLIST.DataLen+1
rts
*--------------------------------------
SLIST.GetNextByte
ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y
inc SLIST.BytePtr
bne .8
pha
inc SLIST.BlockPtr
lda SLIST.BlockPtr
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
pla
.8 rts
*--------------------------------------
SLIST.AddBlockByte
phy
ldy SLIST.BytePtr
sta (ZPSListDBlkPtr),y
inc SLIST.BytePtr
bne .8
phx
>LDYAI 256
jsr K.GetMem0
bcs .9
>STYA ZPSListDBlkPtr
txa
inc SLIST.BlockPtr
ldy SLIST.BlockPtr
sta (ZPSListIBlkPtr),y
* stz SLIST.BytePtr
plx
.8 ply
clc
rts
.9 plx
ply
sec
rts
*--------------------------------------
SLIST.SetBlockByte
ldy SLIST.BytePtr
sta (ZPSListDBlkPtr),y
inc SLIST.BytePtr
bne .8
inc SLIST.BlockPtr
ldy SLIST.BlockPtr
lda (ZPSListIBlkPtr),y
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
* stz SLIST.BlockPtr
.8 rts
*--------------------------------------
SLIST.KeyLen .BS 1
SLIST.DataLen .BS 2
SLIST.nDataCnt .BS 2
SLIST.nBufCnt .BS 2
SLIST.bStringMode .BS 1
SLIST.KeyID .EQ *
SLIST.BytePtr .BS 1
SLIST.BlockPtr .BS 1
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.SLIST
LOAD USR/SRC/SYS/KERNEL.S
ASM