News:

11 March 2016 - Forum Rules

Main Menu

FF3j MMC5 conversion

Started by Kea, December 25, 2015, 11:34:22 PM

Previous topic - Next topic

Kea

I've made an IPS patch (link) for FFIII on the Famicom that changes the mapper from MMC3 to MMC5. I haven't playtested the whole game to check for errors but am 99% sure it works correctly. I made this patch to challenge myself, but maybe others will be interested too.

Original message in the spoiler; I've since fixed the problems described inside.
Spoiler
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:
Spoiler
[close]
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
8A TXA
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
18 CLC
6A ROR
6A ROR
8D0452 STA $5204 @Enable IRQs if bit was 00 set, or disable if clear
1F:FB71 A900 LDA #$00
8505 STA $0005
68 PLA
AA TAX
68 PLA
40 RTI


The unmodified routine looks like this:
Spoiler
$07FB67
1F:FB57 48 PHA
8A TXA
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
8D00C0 STA $C000 @Set scanline target #
8D01E0 STA $C001 @Reset IRQ counter
A601 LDX $0001
9D00E0 STA $E000,X @Enable IRQs if bit 00 clear, or disable if set
1F:FB71 A900 LDA #$00
8505 STA $0005
68 PLA
AA TAX
68 PLA
40 RTI
[close]

If I change the STA $5204 to a LDA, or never set bit 07, the battle screen looks like this:
Spoiler
[close]
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!
[close]