Skip to content

Commit

Permalink
Only catch up when setting CHR banks
Browse files Browse the repository at this point in the history
  • Loading branch information
hcs64 committed May 20, 2024
1 parent a15a647 commit 0575216
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/mappers/mapper4.asm
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ if {defined LOG_MMC3} {
addi sp, -8
}

lw t1, ppu_catchup_cb (r0)
// delay slot?
beqz t1,+
nop // delay slot?
sw ra, cpu_rw_handler_ra (r0)
jalr t1
nop
lw ra, cpu_rw_handler_ra (r0)
+

andi t0, cpu_t1, 0b0110'0000'0000'0000
andi t1, cpu_t1, 1
srl t0, 13-1
Expand Down Expand Up @@ -278,6 +268,16 @@ mmc3_prgrom_update_done:
nop

macro mmc3_map_2k_chr(page_addr) {
lw t1, ppu_catchup_cb (r0)
// delay slot?
beqz t1,+
nop // delay slot?
sw ra, cpu_rw_handler_ra (r0)
jalr t1
nop
lw ra, cpu_rw_handler_ra (r0)
+

ls_gp(lw t0, chrrom_start)
ls_gp(lwu t2, chrrom_mask)
andi t1, cpu_t0, 0b1111'1110 // low bit unused
Expand All @@ -290,6 +290,16 @@ macro mmc3_map_2k_chr(page_addr) {
sw t0, ppu_map + {page_addr}/0x400*4+4 (r0)
}
macro mmc3_map_1k_chr(page_addr) {
lw t1, ppu_catchup_cb (r0)
// delay slot?
beqz t1,+
nop // delay slot?
sw ra, cpu_rw_handler_ra (r0)
jalr t1
nop
lw ra, cpu_rw_handler_ra (r0)
+

ls_gp(lw t0, chrrom_start)
ls_gp(lwu t2, chrrom_mask)
sll t1, cpu_t0, mmc3_chrrom_page_shift
Expand Down

0 comments on commit 0575216

Please sign in to comment.