So this is a pretty simple one - I'd like to have a variable determine which nametable to draw in my subroutine.
What does work is if I make a constant (SCREEN00 = Nametable00) and then load my nametable through my subroutine, it works fine.
There is an intermediary step, however...if I set constants for a few nametables and want to set a variable to determine which one to draw (nextNametable), I'm doing this...
It would seem to me that now the variable nextNameTable should house the same stuff that SCREEN00 housed...so if I jump to the subroutine...
...it seems like it should do the same thing - the variable and the constant it's pointing to should be interchangeable, shouldn't they?
Again, this is my higher level language understanding actually tripping me up rather than helping me here...
What does work is if I make a constant (SCREEN00 = Nametable00) and then load my nametable through my subroutine, it works fine.
There is an intermediary step, however...if I set constants for a few nametables and want to set a variable to determine which one to draw (nextNametable), I'm doing this...
Code:
;;set up the variable earlier in the code - that's just fine.
LDA SCREEN00
STA nextNameTable
LDA SCREEN00
STA nextNameTable
It would seem to me that now the variable nextNameTable should house the same stuff that SCREEN00 housed...so if I jump to the subroutine...
Code:
LoadNametable:
LDA $2002
LDA #$20
STA $2006
LDA #$00
STA $2006
LDA #<nextNameTable ;;note, this works fine when it is SCREEN00
STA addrLo
LDA #>nextNameTable ;;note, this works fine when it is SCREEN00
STA addrHi
LDX #$04
LDY #$00
LoadNametableLoop:
LDA #$00
STA $2001
LDA (addrLo),y
STA $2007
INY
BNE LoadNametableLoop
INC addrHi
DEX
BNE LoadNametableLoop
RTS
LDA $2002
LDA #$20
STA $2006
LDA #$00
STA $2006
LDA #<nextNameTable ;;note, this works fine when it is SCREEN00
STA addrLo
LDA #>nextNameTable ;;note, this works fine when it is SCREEN00
STA addrHi
LDX #$04
LDY #$00
LoadNametableLoop:
LDA #$00
STA $2001
LDA (addrLo),y
STA $2007
INY
BNE LoadNametableLoop
INC addrHi
DEX
BNE LoadNametableLoop
RTS
...it seems like it should do the same thing - the variable and the constant it's pointing to should be interchangeable, shouldn't they?
Again, this is my higher level language understanding actually tripping me up rather than helping me here...