A2osX/SYS/KERNEL.S.SLIST.txt
2019-01-30 16:23:00 +00:00

351 lines
5.8 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.Add
.DA SLIST.Lookup
.DA SLIST.GetByID
.DA SLIST.UpdateByID
.DA SLIST.New
.DA SLIST.Free
*--------------------------------------
SLIST.Add jsr SLIST.Search
bcc .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
.HS B0 BCS
.99 sec
ldx ZPSListID
ldy ZPSListID+1
.9 rts
*--------------------------------------
SLIST.Lookup jsr SLIST.Search
bcs .9
sty .8+1 Save Key Length
jsr SLIST.GetBlockByte
tax
jsr MEM.SetDataByte
.1 jsr SLIST.GetNextBlockByte
jsr MEM.SetDataByte
dex
bne .1
.8 lda #$ff SELF MODIFIED
ldx ZPSListID
ldy ZPSListID+1
clc
.9 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.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.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
*--------------------------------------
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
jsr SLIST.GetBlockByte
tax
beq .9
.1 ldy #0
.2 jsr MEM.GetKeyCharY
bcs .40
iny
sta .3+1
jsr SLIST.GetNextBlockByte
.3 cmp #$ff SELF MODIFIED
bne .4
dex
bne .2
jsr MEM.GetKeyCharY
bcs .8 End of Key....match!!!!
jsr SLIST.GetNextBlockByte
bra .41
.8 jsr SLIST.GetNextBlockByte Advance to DATA LEN
clc Y = Key Length
rts
.40 inx
.4 jsr SLIST.GetNextBlockByte skip remaining key chars
dex
bne .4
.41 tax A=get Data Len
.5 jsr SLIST.GetNextBlockByte skip data bytes
dex
bne .5
jsr SLIST.GetNextBlockByte
ldx SLIST.IndexOfs
stx ZPSListID+1
ldx SLIST.BlockOfs
stx ZPSListID
tax
bne .1
.9 sec
rts
*--------------------------------------
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.IndexOfs .BS 1
SLIST.BlockOfs .BS 1
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.SLIST
LOAD USR/SRC/SYS/KERNEL.S
ASM