A2osX/SYS/KERNEL.S.SLIST.txt
2019-03-14 16:51:02 +00:00

373 lines
6.1 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.SListAddData,x)
.1 .DA SLIST.AddData
.DA SLIST.GetData
.DA SLIST.SetData
.DA SLIST.GetByID
.DA SLIST.NewKey
.DA SLIST.Lookup
.DA SLIST.New
.DA SLIST.Free
*--------------------------------------
SLIST.AddData jsr SLIST.Select
bcs .99 Lookup succeeded...DUP
ldy #$ff
.1 iny
jsr MEM.GetKeyCharY
bcc .1
sty .8+1
tya
beq .9 CS
jsr SLIST.AddBlockByte
bcs .9
ldy #0
.2 jsr MEM.GetKeyCharY
bcs .3
jsr SLIST.AddBlockByte
bcs .9
iny
bra .2
.3 jsr MEM.GetDataByte
tax
jsr SLIST.AddBlockByte
bcs .9
.4 jsr MEM.GetDataByte
jsr SLIST.AddBlockByte
bcs .9
dex
bne .4
.8 lda #$ff SELF MODIFIED
clc
rts
.99 lda #E.NOPKEY
sec
.9 rts
*--------------------------------------
SLIST.GetData
*--------------------------------------
SLIST.SetData
clc
rts
*--------------------------------------
SLIST.GetByID jsr SLIST.Select
jsr SLIST.GetBlockByte
tax
beq .9
ldy #0
jsr MEM.SetKeyCharY
.1 jsr SLIST.GetNextBlockByte
iny
jsr MEM.SetKeyCharY
dex
bne .1
jsr SLIST.GetNextBlockByte
tax
jsr MEM.SetDataByte
.2 jsr SLIST.GetNextBlockByte
jsr MEM.SetDataByte
dex
bne .2
jsr SLIST.GetNextBlockByte
clc
.HS B0 BCS
.9 sec
ldx SLIST.BlockOfs
ldy SLIST.IndexOfs
rts
*--------------------------------------
SLIST.NewKey jsr SLIST.Search
bcc .99
>LDYA SLIST.IndexOfs
>STYA ZPSListID
lda SLIST.KeyLen
jsr SLIST.AddBlockByte
bcs .9
ldy #0
.1 lda (ZPSListKeyPtr),y
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 ZPSListID
clc
rts
.99 lda #E.DUPKEY
sec
.9 rts
*--------------------------------------
SLIST.UpdateByID
jsr SLIST.Select
jsr SLIST.GetBlockByte
tax
.1 jsr SLIST.GetNextBlockByte
dex
bne .1
jsr SLIST.GetNextBlockByte set pos at DATALEN
jsr MEM.GetDataByte
tax
jsr SLIST.SetBlockByte
.4 jsr MEM.GetDataByte
jsr SLIST.SetBlockByte
dex
bne .4
clc
rts
*--------------------------------------
SLIST.Lookup jsr SLIST.Search
bcs .9
>LDYA ZPSListID
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
ldy ZPSListID+1
sty SLIST.IndexOfs
lda (ZPSListIBlkPtr),y
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
lda ZPSListID
sta SLIST.BlockOfs
rts
*--------------------------------------
SLIST.Search jsr K.GetMemPtr
>STYA ZPSListIBlkPtr
stz SLIST.IndexOfs
stz ZPSListID+1
lda (ZPSListIBlkPtr)
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
stz SLIST.BlockOfs
stz ZPSListID
ldy #$ff
.1 iny
jsr MEM.GetKeyCharY
bcc .1
sty SLIST.KeyLen
jsr SLIST.GetBlockByte
beq .9
.2 cmp SLIST.KeyLen
bne .4
ldy #0
.3 jsr SLIST.GetNextBlockByte
cmp (ZPSListKeyPtr),y
bne .4
iny
cpy SLIST.KeyLen
bne .3
clc
rts
.4
jsr SLIST.GetNextBlockByte
ldx SLIST.IndexOfs
stx ZPSListID+1
ldx SLIST.BlockOfs
stx ZPSListID
jsr SLIST.GetBlockByte
bne .2
.9 lda #E.NOKEY
sec
rts
*--------------------------------------
SLIST.Skip
*--------------------------------------
SLIST.GetNextBlockByte
phy
ldy SLIST.BlockOfs
iny
beq .1
lda (ZPSListDBlkPtr),y
sty SLIST.BlockOfs
ply
rts
.1 ldy SLIST.IndexOfs
iny
lda (ZPSListIBlkPtr),y
beq .9 Exit with A=0
sty SLIST.IndexOfs
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
stz SLIST.BlockOfs
lda (ZPSListDBlkPtr)
.9 ply
rts
SLIST.GetBlockByte
phy
ldy SLIST.BlockOfs
lda (ZPSListDBlkPtr),y
ply
rts
*--------------------------------------
SLIST.AddBlockByte
phy
ldy SLIST.BlockOfs
sta (ZPSListDBlkPtr),y
inc SLIST.BlockOfs
bne .8
phx
>LDYAI 256
jsr K.GetMem0
bcs .9
>STYA ZPSListDBlkPtr
txa
inc SLIST.IndexOfs
ldy SLIST.IndexOfs
sta (ZPSListIBlkPtr),y
* stz SLIST.BlockOfs
plx
.8 ply
clc
rts
.9 plx
ply
sec
rts
*--------------------------------------
SLIST.SetBlockByte
phy
ldy SLIST.BlockOfs
sta (ZPSListDBlkPtr),y
inc SLIST.BlockOfs
bne .8
inc SLIST.IndexOfs
ldy SLIST.IndexOfs
lda (ZPSListIBlkPtr),y
beq *
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
* stz SLIST.BlockOfs
.8 ply
rts
*--------------------------------------
SLIST.KeyLen .BS 1
SLIST.IndexOfs .BS 1
SLIST.BlockOfs .BS 1
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.SLIST
LOAD USR/SRC/SYS/KERNEL.S
ASM