So I'm trying to create an asteroid out of background tiles and I'm running into issues where garbage is showing up in my background under certain conditions.
If I write 4 or 5 tiles to the background everything is fine. I am trying to copy over 4 entire rows of tiles starting with the top left corner of my large asteroid. (this isn't meant to be a long term solution, just a test)
If I tweak the cpx at the bottom to have #4 or #5 in it, the copy works fine. If I have #40 or #50 I get garbage all over the background.
I also tried something roughly like this (killed the code so this isn't exactly what I was testing).
This also gives me garbage in my background.
Do I have too much code in my nmi? Or am I fundamentally doing this the wrong way?
Thanks
If I write 4 or 5 tiles to the background everything is fine. I am trying to copy over 4 entire rows of tiles starting with the top left corner of my large asteroid. (this isn't meant to be a long term solution, just a test)
Code:
lda PPU_STATUS ; PPU_STATUS = $2002
lda #$21
sta PPU_ADDR ; PPU_ADDR = $2006
lda #$08
sta PPU_ADDR ; PPU_ADDR = $2006
@render_loop:
lda asteroid_background,x ;#LARGE_ASTEROID_SPRITE_START
sta PPU_DATA
inx
cpx #40 ; I've been playing with this number
bne @render_loop
lda #$21
sta PPU_ADDR ; PPU_ADDR = $2006
lda #$08
sta PPU_ADDR ; PPU_ADDR = $2006
@render_loop:
lda asteroid_background,x ;#LARGE_ASTEROID_SPRITE_START
sta PPU_DATA
inx
cpx #40 ; I've been playing with this number
bne @render_loop
If I tweak the cpx at the bottom to have #4 or #5 in it, the copy works fine. If I have #40 or #50 I get garbage all over the background.
I also tried something roughly like this (killed the code so this isn't exactly what I was testing).
Code:
lda PPU_STATUS ; PPU_STATUS = $2002
lda #$21
sta PPU_ADDR ; PPU_ADDR = $2006
lda #$08
sta PPU_ADDR ; PPU_ADDR = $2006
@render_loop:
lda asteroid_background,x ;#LARGE_ASTEROID_SPRITE_START
sta PPU_DATA
inx
cpx #4
bne @render_loop
lda PPU_STATUS ; PPU_STATUS = $2002
lda #$21
sta PPU_ADDR ; PPU_ADDR = $2006
lda #$28
sta PPU_ADDR ; PPU_ADDR = $2006
@render_loop_2:
lda asteroid_background,x ;#LARGE_ASTEROID_SPRITE_START
sta PPU_DATA
inx
cpx #4
bne @render_loop_2
lda #$21
sta PPU_ADDR ; PPU_ADDR = $2006
lda #$08
sta PPU_ADDR ; PPU_ADDR = $2006
@render_loop:
lda asteroid_background,x ;#LARGE_ASTEROID_SPRITE_START
sta PPU_DATA
inx
cpx #4
bne @render_loop
lda PPU_STATUS ; PPU_STATUS = $2002
lda #$21
sta PPU_ADDR ; PPU_ADDR = $2006
lda #$28
sta PPU_ADDR ; PPU_ADDR = $2006
@render_loop_2:
lda asteroid_background,x ;#LARGE_ASTEROID_SPRITE_START
sta PPU_DATA
inx
cpx #4
bne @render_loop_2
This also gives me garbage in my background.
Do I have too much code in my nmi? Or am I fundamentally doing this the wrong way?
Thanks