Post by stiggity on Mar 14, 2021 4:38:41 GMT
Wendling:
Using the putaray routine, how can I make the x register the element I want to store the buffer into?
I don't see anywhere in the code, exactly how I know which element is being created..
The getaray routine is nice, and so is the putaray, but I've fiddled with using the X-Reg, as to control which element gets populated.. im doing something wrong. I'm sorry for being so redundant, but below is all I have. I don't really want to setup the element's # in BASIC. I apologize for such newb questions, and your help has been eye awakening.. have a look below.
Using the putaray routine, how can I make the x register the element I want to store the buffer into?
I don't see anywhere in the code, exactly how I know which element is being created..
The getaray routine is nice, and so is the putaray, but I've fiddled with using the X-Reg, as to control which element gets populated.. im doing something wrong. I'm sorry for being so redundant, but below is all I have. I don't really want to setup the element's # in BASIC. I apologize for such newb questions, and your help has been eye awakening.. have a look below.
in *=$1300
jmp putary
jmp getary ;+3 ;add buffer contents to array element
putary
lda $31 ; start of array memory
sta $fd
lda $32
sta $fe
clc ; skip the first 7 bytes of the array to get to the index
lda $fd
adc #07
sta $fd
bcc L1
inc $fe
L1
clc
LDX #1 ; go to the index nr in reg x
lda $fd
adc #03
sta $fd
bcc L2
inc $fe
L2
dex
bne L1
ldy length
lda $fd ; the location in the array is stored after the string.
sta buffer,y
iny
lda $fe
sta buffer,y
iny
sty len2
lda $35 ; Make room for string. Just 35/36 minus length string minus 2 for pointer.
sec
sbc len2
sta $35
lda $36
sbc #$00
sta $36
dey
L3
lda buffer,y ; store string in string memory
jsr stash35
dey
bpl L3
ldy #00
lda length ; store length of new string in array memory
jsr stashfd
iny
lda $35 ; store pointer low to new string in array memory
jsr stashfd
iny
lda $36 ; store pointer high to new string in array memory
jmp stashfd
;--------------------------------------------------------
getary
LDA $31
sta $FE
LDA $32
STA $FF
CLC
LDA $FE
ADC #7
STA $FE
BCC BRANCH
CLC
LDA $FF
ADC #1
STA $FF
BRANCH LDX #1 ;element number
LOOP1w CLC
LDA $FE
ADC #3
STA $FE
BCC BR2wa
CLC
LDA $FF
ADC #1
STA $FF
BR2wa DEX
BNE LOOP1w
LDY #2
jsr fetchfe
;LDA ($FE),y
STA $FD
dey
jsr fetchfe ;LDA ($FE),y
STa $FC ;holds element data
dey
jsr fetchfe ;LDA ($FE),y
sta point ;x (point) holds the length
ldy #0
qloop
cpy point
bcs print
jsr fetchfc ; lda ($FC),y
STA BUFFER,Y
inY
jmp qloop
PRINT RTS
;-----------------------------------------
fetchfe
LDA #$fe ;ZP pointer to use
LDX #1 ;bank index 1
JMP $FF74 ;kernal
fetchfc
LDA #$fc ;ZP pointer to use
LDX #1 ;bank index 1
JMP $FF74 ;kernal
;------------------------------------------
stash35 ; to store at 35/36 in string memory in bank1
pha
lda #$35
sta $02b9 ; modify the store address
pla
ldx #$7f ; bank1
jmp $02af
stashfd ; to store at fd/fe in the array memory in bank1
pha
lda #$fd
sta $02b9 ; modify the store address
pla
ldx #$7f ; bank1
jmp $02af
;----------------------------------------------
POINT .BYTE 0
buffer .text "Stiggity"
LENGTH .BYTE 8
LEN2 .BYTE 0