mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-18 06:07:29 +00:00
510 lines
8.9 KiB
Plaintext
510 lines
8.9 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
*--------------------------------------
|
||
ZPSListDataOfs .EQ ZPMEMMGR+8
|
||
ZPSListDataLen .EQ ZPMEMMGR+10
|
||
ZPSListIBlkPtr .EQ ZPMEMMGR+12
|
||
ZPSListDBlkPtr .EQ ZPMEMMGR+14
|
||
*--------------------------------------
|
||
SLIST.KeyLen .BS 1
|
||
SLIST.DataLen .BS 2
|
||
SLIST.nDataCnt .BS 2
|
||
SLIST.nBufCnt .BS 2
|
||
SLIST.bStringMode .BS 1
|
||
SLIST.bAppend0 .BS 1
|
||
SLIST.KeyID .EQ *
|
||
SLIST.BytePtr .BS 1
|
||
SLIST.BlockPtr .BS 1
|
||
SLIST.KeyID.Save .BS 2
|
||
*--------------------------------------
|
||
SLISTX.SListGetData
|
||
jsr SLIST.Select
|
||
|
||
jsr SLIST.SkipKey
|
||
jsr SLIST.GetDataLen
|
||
|
||
lda SLIST.DataLen
|
||
sec
|
||
sbc ZPSListDataOfs Offset
|
||
eor #$ff
|
||
sta SLIST.nDataCnt
|
||
|
||
lda SLIST.DataLen+1
|
||
sbc ZPSListDataOfs+1
|
||
eor #$ff
|
||
sta SLIST.nDataCnt+1 Data remaining
|
||
|
||
bcc .99 Offset Beyond DataLen
|
||
|
||
lda ZPSListDataOfs Skip to Offset
|
||
ldx ZPSListDataOfs+1
|
||
jsr SLIST.SkipDataAX
|
||
|
||
stz SLIST.bAppend0
|
||
|
||
lda FORPNT
|
||
ora FORPNT+1
|
||
bne .12 buffer provided
|
||
|
||
>LDYA SLIST.DataLen
|
||
|
||
iny
|
||
bne .11
|
||
inc +1 for ending 0
|
||
|
||
sec
|
||
ror SLIST.bAppend0
|
||
|
||
.11 ldx #SYS.GetMem
|
||
jsr K.SYSCALL2.MAIN !!! Get a buffer In MAIN Mem !!!
|
||
bcs .9
|
||
stx .88+1
|
||
>STYA FORPNT
|
||
|
||
.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 .80
|
||
|
||
.3 bit SLIST.bStringMode
|
||
bmi .4 String mode : until CR
|
||
|
||
inc SLIST.nBufCnt
|
||
bne .4
|
||
inc SLIST.nBufCnt+1
|
||
beq .80 not string mode : until end of buffer
|
||
|
||
.4 jsr SLIST.GetNextByte
|
||
bit SLIST.bStringMode
|
||
bpl .5
|
||
|
||
cmp #C.CR
|
||
beq .81
|
||
|
||
.5 jsr SHARED.FORPNT.PutNext
|
||
inc ZPSListDataLen
|
||
bne .2
|
||
inc ZPSListDataLen+1
|
||
bra .2
|
||
|
||
.99 lda #E.EMPTYKEY
|
||
sec
|
||
.9 rts
|
||
|
||
.80 lda SLIST.bStringMode
|
||
ora SLIST.bAppend0
|
||
bpl .82
|
||
|
||
.81 lda #0
|
||
jsr SHARED.FORPNT.PutNext
|
||
|
||
.82 >LDYA ZPSListDataLen
|
||
.88 ldx #$ff SELF MODIFIED
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
SLISTX.SListAddData
|
||
jsr SLIST.Select
|
||
|
||
jsr SLIST.SkipKey
|
||
|
||
ldy SLIST.BytePtr
|
||
lda (ZPSListDBlkPtr),y
|
||
pha
|
||
clc
|
||
adc ZPSListDataLen
|
||
sta (ZPSListDBlkPtr),y
|
||
php
|
||
jsr SLIST.ToNextByte skip LEN lo
|
||
|
||
plp
|
||
ldy SLIST.BytePtr
|
||
lda (ZPSListDBlkPtr),y
|
||
pha
|
||
adc ZPSListDataLen+1
|
||
sta (ZPSListDBlkPtr),y
|
||
jsr SLIST.ToNextByte skip LEN hi
|
||
|
||
plx
|
||
pla
|
||
jsr SLIST.SkipDataAX
|
||
lda ZPSListDataLen
|
||
eor #$ff
|
||
sta ZPSListDataLen
|
||
|
||
lda ZPSListDataLen+1
|
||
eor #$ff
|
||
sta ZPSListDataLen+1
|
||
|
||
sec
|
||
|
||
.1 inc ZPSListDataLen
|
||
bne .2
|
||
inc ZPSListDataLen+1
|
||
beq .8
|
||
|
||
.2 jsr SHARED.FORPNT.GetNext
|
||
bcc .3
|
||
|
||
jsr SLIST.SetBlockByte override ending 0, already allocated
|
||
clc
|
||
bra .1
|
||
|
||
.3 jsr SLIST.AddDataByte
|
||
bcc .1
|
||
rts
|
||
|
||
.8 lda #0
|
||
jmp SLIST.AddDataByte Add an extra 0 to stop Search here
|
||
*--------------------------------------
|
||
SLISTX.SListSetData
|
||
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 SHARED.FORPNT.GetNext
|
||
jsr SLIST.SetBlockByte
|
||
bra .1
|
||
|
||
.8 clc
|
||
rts
|
||
.9 lda #E.DATALEN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
SLISTX.SListGetByID
|
||
jsr SLIST.Select
|
||
|
||
jsr SLIST.GetNextByte
|
||
tax
|
||
beq .9
|
||
|
||
ldy #0
|
||
|
||
.1 phy
|
||
jsr SLIST.GetNextByte
|
||
ply
|
||
|
||
jsr SHARED.FORPNT.PutNext
|
||
|
||
iny
|
||
dex
|
||
bne .1
|
||
|
||
txa lda #0
|
||
|
||
jsr SHARED.FORPNT.PutNext
|
||
|
||
jsr SLIST.SkipData
|
||
>LDYA SLIST.KeyID
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.NOKEY
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
SLISTX.SListNewKey
|
||
jsr SLIST.Search
|
||
bcc .99
|
||
|
||
>LDYA SLIST.KeyID
|
||
>STYA SLIST.KeyID.Save End of list
|
||
|
||
lda SLIST.KeyLen
|
||
jsr SLIST.SetBlockByte override ending 0, already allocated
|
||
|
||
ldy #0
|
||
|
||
.1 jsr SHARED.TXTPTR.GetY
|
||
jsr SLIST.AddDataByte
|
||
bcs .9
|
||
|
||
iny
|
||
cpy SLIST.KeyLen
|
||
bne .1
|
||
|
||
lda #0 Data Len lo = 0
|
||
jsr SLIST.AddDataByte
|
||
bcs .9
|
||
|
||
lda #0 Data Len hi = 0
|
||
jsr SLIST.AddDataByte
|
||
bcs .9
|
||
|
||
lda #0 Ending Len = 0
|
||
jsr SLIST.AddDataByte
|
||
bcs .9
|
||
|
||
>LDYA SLIST.KeyID.Save
|
||
ldx SLIST.KeyLen
|
||
* clc
|
||
rts
|
||
|
||
.99 lda #E.DUPKEY
|
||
sec
|
||
.9 rts
|
||
*--------------------------------------
|
||
SLISTX.SListLookup
|
||
jsr SLIST.Search
|
||
bcs .9
|
||
|
||
ldx SLIST.KeyLen
|
||
.9 rts
|
||
*--------------------------------------
|
||
SLISTX.SListFree
|
||
pha
|
||
|
||
jsr K.GetMemPtr
|
||
>STYA .1+1
|
||
|
||
ldx #0
|
||
|
||
.1 lda $ffff,x SELF MODIFIED
|
||
beq .8
|
||
|
||
jsr K.FreeMem
|
||
inx
|
||
bra .1
|
||
|
||
.8 pla
|
||
jmp K.FreeMem
|
||
*--------------------------------------
|
||
SLISTX.SListNew >LDYAI 128 32k Max before out of memory!!!
|
||
ldx #S.MEM.F.INIT0+8 index
|
||
jsr MEM.GetMem.YAX
|
||
bcs .9
|
||
|
||
>STYA ZPSListIBlkPtr
|
||
stx .8+1
|
||
|
||
>LDYAI 256
|
||
ldx #4 data
|
||
jsr MEM.GetMem.YAX
|
||
bcs .9
|
||
|
||
>STYA ZPSListDBlkPtr
|
||
|
||
lda #0
|
||
sta (ZPSListDBlkPtr)
|
||
txa
|
||
sta (ZPSListIBlkPtr)
|
||
|
||
.8 lda #$ff SELF MODIFIED
|
||
.9 rts
|
||
*--------------------------------------
|
||
* PRIVATE
|
||
*--------------------------------------
|
||
SLIST.Search jsr K.GetMemPtr
|
||
>STYA ZPSListIBlkPtr
|
||
|
||
lda (ZPSListIBlkPtr)
|
||
jsr K.GetMemPtr
|
||
>STYA ZPSListDBlkPtr
|
||
|
||
ldy #$ff
|
||
|
||
.1 iny
|
||
jsr SHARED.TXTPTR.GetY
|
||
beq .11
|
||
|
||
jsr SHARED.IsIDValid
|
||
bcc .1
|
||
|
||
.11 sty SLIST.KeyLen
|
||
|
||
stz SLIST.BytePtr
|
||
stz SLIST.BlockPtr
|
||
|
||
.2 >LDYA SLIST.KeyID
|
||
>STYA SLIST.KeyID.Save
|
||
|
||
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 SHARED.TXTPTR.GetY
|
||
|
||
.4 cmp #$ff SELF MODIFIED
|
||
bne .5
|
||
|
||
iny
|
||
cpy SLIST.KeyLen
|
||
bne .3
|
||
|
||
>LDYA SLIST.KeyID.Save
|
||
clc
|
||
rts
|
||
|
||
.5 >LDYA SLIST.KeyID.Save
|
||
|
||
jsr SLIST.Select.I move back...
|
||
jsr SLIST.Next
|
||
bra .2
|
||
|
||
.9 lda #E.NOKEY
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
SLIST.Select jsr K.GetMemPtr
|
||
>STYA ZPSListIBlkPtr
|
||
|
||
>LDYA TXTPTR
|
||
|
||
SLIST.Select.I >STYA SLIST.KeyID
|
||
|
||
ldy SLIST.BlockPtr
|
||
|
||
lda (ZPSListIBlkPtr),y
|
||
jsr K.GetMemPtr
|
||
>STYA ZPSListDBlkPtr
|
||
|
||
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
|
||
bcs SLIST.ToNextBlock
|
||
.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
|
||
SLIST.ToNextByte
|
||
inc SLIST.BytePtr
|
||
bne .8
|
||
|
||
pha
|
||
jsr SLIST.ToNextBlock
|
||
pla
|
||
.8 rts
|
||
*--------------------------------------
|
||
SLIST.AddDataByte
|
||
phy
|
||
ldy SLIST.BytePtr
|
||
sta (ZPSListDBlkPtr),y
|
||
inc SLIST.BytePtr
|
||
bne .8
|
||
|
||
phx
|
||
>LDYAI 256
|
||
ldx #4
|
||
jsr MEM.GetMem.YAX
|
||
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
|
||
rts
|
||
*--------------------------------------
|
||
SLIST.SetBlockByte
|
||
ldy SLIST.BytePtr
|
||
sta (ZPSListDBlkPtr),y
|
||
inc SLIST.BytePtr
|
||
bne SLIST.ToNextBlock.RTS
|
||
*--------------------------------------
|
||
SLIST.ToNextBlock
|
||
inc SLIST.BlockPtr
|
||
ldy SLIST.BlockPtr
|
||
lda (ZPSListIBlkPtr),y
|
||
jsr K.GetMemPtr
|
||
>STYA ZPSListDBlkPtr
|
||
SLIST.ToNextBlock.RTS
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/sys/kernel.s.slistx
|
||
LOAD usr/src/sys/kernel.s
|
||
ASM
|