I'm attempting to convert FFIII from the MMC3 to MMC5 (mostly for the extra PRG-ROM and the challenge); it mostly works perfectly but I've run into a snag with battle scenes. When they begin, instead of the battle music the victory music plays at several times the normal tempo and the screen looks like this:
The BG goes crazy and displays garbage data or correct gfx in the wrong places; the player character sprites function normally at first but are slowly overwritten by garbage pixels. The battle itself is fully functional - you can input commands like normal and once the battle finishes you return to the map screen with everything looking as it should. It's just the audio and graphics that are wrong. I haven't been able to pin down exactly what's causing the problem but I believe it to be related to the NMI interrupt used for battle*:
$07FB67 - NMI interrupt (battle scenes)
1F:FB57 48 PHA
ADF37C LDA $7CF3
F012 BEQ $FB71
20CBF8 JSR $F8CB @Storing some values from ($06,$09,$0C,05) -> ($2000,$2001,$2005,$2005)
A503 LDA $0003
8502 STA $0002
8D0352 STA $5203 @Set scanline target #
A501 LDA $01 @Load byte indicating whether to enable IRQs
8D0452 STA $5204 @Enable IRQs if bit was 00 set, or disable if clear
1F:FB71 A900 LDA #$00
8505 STA $0005
The unmodified routine looks like this:
If I change the STA $5204 to a LDA, or never set bit 07, the battle screen looks like this:
Menu BG is missing and there is some garbage in its place, but everything else functions perfectly.
If it would help, I have a .zip folder here
which contains all my notes on the mapper-related routines plus notes on the changes I've made so far, an IPS patch for the conversion to apply to the translated ROM, a movie file demonstrating what happens when you enter battle, and a savestate just before the first battle of the game.
*FF3's NMI and BRK interrupt vectors point to $100 and $103 in memory, respectively, allowing the program to modify them at runtime. They're either just RTI or a JUMP to some other code in the fixed banks.
Okay, I figured out the problem: I forgot to modify the BRK interrupt (at $7FB40) to use MMC5 registers; figures it'd be a silly mistake like that. Now battles display properly and sound plays back at the normal speed. However, I still have the problem where regular battles play the victory music instead of the battle music. Not sure what to do there...
Edit: Hah, and in boss battles the Tozas music plays. Looks like all battle music is getting their ID shifted for some reason.
Turns out I missed a one-time bankswitch routine used to load music banks. Swapped it to use MMC5 registers and params, and now the right tune plays!