I have a db(s) of my backgrounds (rooms) like this:
rooms_db:
.word Room0, Room1
where Room0 is simply like:
Room0:
.db $27,$27,$27,$27,$27,$27,$27,$27,$27,$27, etc.
Room1:
.db $27,$27,$27,$27,$27,$27,$27,$27,$27,$27, etc.
I cannot make work my load background routine from those pointers in rooms_db, load code is:
LoadBackground:
LDA #$00 ; Turn off the PPU in the Main Code First
STA $2001
LDA $2002 ; read PPU status to reset the high/low latch
LDA #$20
STA $2006 ; write the high byte of $2000 address
LDA #$00
STA $2006 ; write the low byte of $2000 address
LDX #$00
LDA #LOW(rooms_db)
STA pointerLo ; put the low byte of the address of background into pointer
LDA #HIGH(rooms_db)
STA pointerHi ; put the high byte of the address into pointer
LDX #$00 ; start at pointer + 0
LDY #$00
OutsideLoop:
InsideLoop:
LDA [pointerLo], y ; copy one background byte from address in pointer plus Y
STA $2007 ; this runs 256 * 4 times
INY ; inside loop counter
CPY #$00
BNE InsideLoop ; run the inside loop 256 times before continuing down
INC pointerHi ; low byte went 0 to 256, so high byte needs to be changed now
INX
CPX #$04
BNE OutsideLoop ; run the outside loop 256 times before continuing down
RTS
With that I was expecting to load Room0, just as if I explicitly hard coded it instead of "rooms_db"
rooms_db:
.word Room0, Room1
where Room0 is simply like:
Room0:
.db $27,$27,$27,$27,$27,$27,$27,$27,$27,$27, etc.
Room1:
.db $27,$27,$27,$27,$27,$27,$27,$27,$27,$27, etc.
I cannot make work my load background routine from those pointers in rooms_db, load code is:
LoadBackground:
LDA #$00 ; Turn off the PPU in the Main Code First
STA $2001
LDA $2002 ; read PPU status to reset the high/low latch
LDA #$20
STA $2006 ; write the high byte of $2000 address
LDA #$00
STA $2006 ; write the low byte of $2000 address
LDX #$00
LDA #LOW(rooms_db)
STA pointerLo ; put the low byte of the address of background into pointer
LDA #HIGH(rooms_db)
STA pointerHi ; put the high byte of the address into pointer
LDX #$00 ; start at pointer + 0
LDY #$00
OutsideLoop:
InsideLoop:
LDA [pointerLo], y ; copy one background byte from address in pointer plus Y
STA $2007 ; this runs 256 * 4 times
INY ; inside loop counter
CPY #$00
BNE InsideLoop ; run the inside loop 256 times before continuing down
INC pointerHi ; low byte went 0 to 256, so high byte needs to be changed now
INX
CPX #$04
BNE OutsideLoop ; run the outside loop 256 times before continuing down
RTS
With that I was expecting to load Room0, just as if I explicitly hard coded it instead of "rooms_db"