I'm currently using MMC3 for my game. Accounting for dropped frames I discovered I needed to make chr bankswapping atomic with sprite updates, as in the following. That part works fine.
What's really mysterious is that I'm now getting glitches with background chr-data. I've verified in the debugger my two variables bg_chr_bank0 and bg_chr_bank1 *are not modified* when this glitch occurs.
I'm having trouble imagining what else could be wrong, here. I know MMC3 is not subject to bus conflicts.
This is from my current nmi routine. All chr-rom banks are updated every frame based on what was calculated in the previous frame. I currently do not protect the bg chr updates the way I protect the spr chr updates, however, I verified that these values are not changing, yet the glitches appear in the bg tiles and nowhere else (they select the wrong tiles).
What's really mysterious is that I'm now getting glitches with background chr-data. I've verified in the debugger my two variables bg_chr_bank0 and bg_chr_bank1 *are not modified* when this glitch occurs.
I'm having trouble imagining what else could be wrong, here. I know MMC3 is not subject to bus conflicts.
This is from my current nmi routine. All chr-rom banks are updated every frame based on what was calculated in the previous frame. I currently do not protect the bg chr updates the way I protect the spr chr updates, however, I verified that these values are not changing, yet the glitches appear in the bg tiles and nowhere else (they select the wrong tiles).
Code:
lda #MMC3_SELECT_2K_CHR_BANK0
sta MMC3_BANK_SELECT
lda bg_chr_bank0
sta MMC3_BANK_DATA
lda #MMC3_SELECT_2K_CHR_BANK1
sta MMC3_BANK_SELECT
lda bg_chr_bank1
sta MMC3_BANK_DATA
lda sprites_ready
beq :+
lda #MMC3_SELECT_1K_CHR_BANK0
sta MMC3_BANK_SELECT
lda spr_chr_bank0
sta MMC3_BANK_DATA
lda #MMC3_SELECT_1K_CHR_BANK1
sta MMC3_BANK_SELECT
lda spr_chr_bank1
sta MMC3_BANK_DATA
lda #MMC3_SELECT_1K_CHR_BANK2
sta MMC3_BANK_SELECT
lda spr_chr_bank2
sta MMC3_BANK_DATA
lda #MMC3_SELECT_1K_CHR_BANK3
sta MMC3_BANK_SELECT
lda spr_chr_bank3
sta MMC3_BANK_DATA
jsr sprite_update_all
lda #0
sta sprites_ready
:
sta MMC3_BANK_SELECT
lda bg_chr_bank0
sta MMC3_BANK_DATA
lda #MMC3_SELECT_2K_CHR_BANK1
sta MMC3_BANK_SELECT
lda bg_chr_bank1
sta MMC3_BANK_DATA
lda sprites_ready
beq :+
lda #MMC3_SELECT_1K_CHR_BANK0
sta MMC3_BANK_SELECT
lda spr_chr_bank0
sta MMC3_BANK_DATA
lda #MMC3_SELECT_1K_CHR_BANK1
sta MMC3_BANK_SELECT
lda spr_chr_bank1
sta MMC3_BANK_DATA
lda #MMC3_SELECT_1K_CHR_BANK2
sta MMC3_BANK_SELECT
lda spr_chr_bank2
sta MMC3_BANK_DATA
lda #MMC3_SELECT_1K_CHR_BANK3
sta MMC3_BANK_SELECT
lda spr_chr_bank3
sta MMC3_BANK_DATA
jsr sprite_update_all
lda #0
sta sprites_ready
: