I have some trouble updating a specific background tile, specifically finding the address to write the new tile to.
My game contains 8px grid movement, so my x and y values already are 8px units (I've read somewhere that this is necessary).
What I would like to know is how to calculate the new address.
So basically, something like this:
My game contains 8px grid movement, so my x and y values already are 8px units (I've read somewhere that this is necessary).
What I would like to know is how to calculate the new address.
So basically, something like this:
Code:
UpdateTiles:
LDA p1y
ASL
ASL
ASL
ASL
ASL ; player Y-coord times 32
STA tile_y
LDA p1x
STA tile_x ; player X-coord
; calculate high and low address with x and y
LDA $2006
LDA addr_lo
STA $2006
LDA addr_hi
STA $2006
LDA #$39
STA $2007
LDA p1y
ASL
ASL
ASL
ASL
ASL ; player Y-coord times 32
STA tile_y
LDA p1x
STA tile_x ; player X-coord
; calculate high and low address with x and y
LDA $2006
LDA addr_lo
STA $2006
LDA addr_hi
STA $2006
LDA #$39
STA $2007