so everything was working fine with my project until I decided to use some RAM for a collision map (basically an array to hold a 0 for empty space, 1 for occupied space).
After creating the collision map I lose my picture, however the debugger shows my nametable is all there and looks fine on the PPU.
First question is, is there a common denominator to help debug through when the screen is black but the nametable looks fine?
Second question is, does anything in the code stand out as obvious? By the way, prior to updating the nametable I wait for vblank, turn off rendering, write to the PPU, then try to update my collision map. I wait for vblank again, then turn rendering back on.
Code: Select all
nt_collision_ptr .rs 2 ; pointer to nametable collision map
Code: Select all
Reset_nt_collision_ptr:
; set collision pointer to page 2 in RAM
LDA #$00 ; low byte
STA nt_collision_ptr
LDA #$01 ; high byte
STA nt_collision_ptr + 1
;done, $0100
RTS
Code: Select all
Update_collision_map:
JSR Reset_nt_collision_ptr
LDX #$00
LDY #$00
update_collision_loop:
LDA [nametable_ptr], y
CMP #TILE_CLEAR
BNE solid_tile
; empty space
LDA #$00
STA [nt_collision_ptr], y
JMP resume_collision_load
solid_tile:
LDA #$01
STA [nt_collision_ptr], y
resume_collision_load:
INY
CPY #$00 ; wrap around = 256 tiles
BNE update_collision_loop
; see if next set needs to be processed
INC nt_collision_ptr + 1
LDY #$00
INX
CPX #$04
BNE update_collision_loop
RTS