Here is some code to illustrate what I'm talking about.
; Code to be assembled with ASM6
; This is a routine which will handle all of my text writing.
texthandler:
jsr wait_for_vblank
lda text_coordinate1
sta $2006
lda text_coordinate2
sta $2006
ldx #$00
- lda __, x ; this line is what I need help with.
cmp #$ff ; ff is a line terminator. When ff is reached, the text line is finished.
beq +
sta $2007
inx
jmp -
+ rts
text_line1:
db $00,$16,$0e,$10,$0a,$16,$0a,$17,$00,$12,$1c,$00,$0a,$00,$0c,$18,$19,$22,$1b,$12,$10,$11,$1d,$00,$18,$0f,$00,$00,$00,$ff
text_line2:
db $0c,$0a,$19,$0c,$18,$16,$24,$00,$1d,$11,$12,$1c,$00,$12,$1c,$00,$0a,$00,$17,$18,$17,$25,$19,$1b,$18,$0f,$12,$1d,$00,$ff
Is there a way I can make the LDA __,X above have an address that changes, so it will read a given line when I set it to it?
The only thing I can think of are the LDA Indirect opcodes, but I researched them, and I wasn't sure if they would do the trick. I know that I can read a value that is stored in an address, and get output that way, but I was just wondering if it is possible to change the table address that is read by the LDA, so I can use this routine for any line of text?
For instance, if I have:
LDA text_line1, x
Later on, I want to change that text_line1 to text_line2. Can that be done using the indirect LDA?
Thanks.