A2osX/SYS/KERNEL.S.RDR.txt
2015-03-15 23:00:40 +01:00

152 lines
2.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.

PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
* S.NewBufRdr
* In :
* PULLB = DATA hMem
* PULLB = Delim Char
* PULLW = Size of DATA
* Out :
* A = hMem To newly created BufRdr
*--------------------------------------
S.NewBufRdr >PUSHWI S.BUFRDR.SIZE
>PUSHBI 0 0 = no option
jsr S.GetMem
bcs .98
phx save hMem
>STYA ZPQuickPtr1
ldy #S.BUFRDR.hMEM
>PULLB (ZPQuickPtr1),y
ldy #S.BUFRDR.DELIM
>PULLB (ZPQuickPtr1),y
ldy #S.BUFRDR.LEN+1
>PULLB (ZPQuickPtr1),y
dey
>PULLB (ZPQuickPtr1),y
ldy #S.BUFRDR.IDX
lda #0
sta (ZPQuickPtr1),y
iny
sta (ZPQuickPtr1),y
pla
clc
rts
.98 pha
>PULLA
>PULLYA
pla
.99 rts
*--------------------------------------
* S.BufRdrReadA
* In :
* A = hMem To BufRdr
* Out :
* CC: Y,A = PTR to line (PSTR)
* CS: EOF
*--------------------------------------
S.BufRdrReadA jsr S.GetMemPtrA
>STYA ZPQuickPtr1
ldy #S.BUFRDR.hMEM
jsr S.GetMemPtrA
>STYA ZPQuickPtr2 PTR to DATA
ldy #S.BUFRDR.IDX
lda (ZPQuickPtr1),y
sta ZPQuickPtr3 IDX
clc
adc ZPQuickPtr2 PTR=PTR+IDX
sta ZPQuickPtr2
iny
lda (ZPQuickPtr1),y
sta ZPQuickPtr3+1
adc ZPQuickPtr2+1
sta ZPQuickPtr2+1
ldy #S.BUFRDR.LEN
lda (ZPQuickPtr1),y
sta ZPQuickPtr4
iny
lda (ZPQuickPtr1),y
sta ZPQuickPtr4+1
stz TmpBuffer256
ldy #S.BUFRDR.DELIM
.1 lda ZPQuickPtr4
bne .2
lda ZPQuickPtr4
beq .8
dec ZPQuickPtr4+1
.2 dec ZPQuickPtr4
lda (ZPQuickPtr2)
inc ZPQuickPtr2
bne .3
inc ZPQuickPtr2+1
.3 inc ZPQuickPtr3
bne .4
inc ZPQuickPtr3+1
.4 cmp (ZPQuickPtr1),y DELIM
beq .8
inc TmpBuffer256
beq .8
ldx TmpBuffer256
sta TmpBuffer256,x
bra .1
.8 lda TmpBuffer256
bne .81
sec
rts
.81 ldy #S.BUFRDR.IDX
lda ZPQuickPtr3
sta (ZPQuickPtr1),y
iny
lda ZPQuickPtr3+1
sta (ZPQuickPtr1),y
ldy #S.BUFRDR.LEN
lda ZPQuickPtr4
sta (ZPQuickPtr1),y
iny
lda ZPQuickPtr4+1
sta (ZPQuickPtr1),y
>LDYAI TmpBuffer256
clc
rts
*--------------------------------------
* S.BufRdrCloseA
* In :
* A = hMem To BufRdr
*--------------------------------------
S.BufRdrCloseA pha
jsr S.GetMemPtrA
>STYA S.BUFRDR.hMEM
ldy #S.BUFRDR.hMEM
lda (S.BUFRDR.hMEM),y
jsr S.FreeMemA
pla
jsr S.FreeMemA
clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.RDR
LOAD SYS/KERNEL.S
ASM