I'm having trouble figuring out exactly how to set up this game to use the MMC5 mapper. I snooped around Disch's FF1 Namcot disassembly (found here: http://www.romhacking.net/forum/index.php?topic=24899.0
) so I have a rough idea of the parts that need changing. And I have his mapper documents, and have read a few other forum threads... only to get more confused.
I decided on MMC5 for a few reasons:
Disch said it "wouldn't be the most difficult thing ever."
2 extra sound channels! Nice.
I do very much like the idea of the multiplication thing it can do.
I don't want to use the Namcot disassembly because its a little scary, and the disassembly is too different. Many labels are changed, things are uncommented, and on top of that, I don't know if I can use any extra RAM, or if it only works with sound stuff. I don't feel I need the super extra sound channels...
What I think I understand so far:
I need to set up the iNes header.
I need to set up the mapper inside "OnReset".
I need to set up how "SwapPRG" works differently.
If I use extra sound channels, I have to mute them separately when the game mutes the rest.
What I don't understand (potentially everything):
What values to use in setting up the iNes header.
Everything I need to initialize inside "OnReset"
How to set up "SwapPRG" at all.
If there is more I need to do with the amount of banks; nes.cfg and build.bat.
What I've done so far:
I've created a mostly-empty bank, Bank_0Z.asm, containing:
It is my understanding that this will fill itself up with 0s. My intention will be to swap to this bank when I need to do any custom code...
I've set up build.bat and nes.cfg the way Disch has it in the Namcot disassembly, replacing "musicengine.bin" with "Bank_0Z.asm". I'm using his filler.dat file as well. Bank F is set to the last bank still; I understand why this is necessary.
Do I need to make more "empty" banks, or change how big "filler.dat" is, to make sure the rom comes out to the right size? If I need to pad out filler.dat, how large should it be? It currently goes up to 000BC000--752 KB (3x the size of the original FF, minus the 16 KB for Bank Z). Am I off by 16 bytes or more?
To initialize the mapper in Bank F, I've done this so far:
SEI ; Set Interrupt flag (prevent IRQs from occuring)
STA $2000 ; Disable NMIs
STA unk_FE ; clear some PPU related areas in RAM
STA $2001 ; disable Spr/BG rendering (shut off PPU)
CLD ; clear Decimal flag (just a formality, doesn't really do anything)
LDX #$02 ; wait for 2 vblanks to occurs (2 full frames)
BIT $2002 ; This is necessary because the PPU requires some time to "warm up"
BPL @Loop ; failure to do this will result in the PPU basically not working
; X = 0
STX $5100 ; 32k PRG-RAM (is this what I want?)
STX $5101 ; 8k for CHR Mode Select (is this what I want?)
INX ; 01
STX $5103 ; Allow writing to PRG-RAM B?
INX ; 02
STX $5102 ; Allow writing to PRG-RAM A?
STX $5104 ; ExRAM mode Ex2
STX $5105 ; Hopefully, Vertical mirroring?
STA $4016 ; clear joypad strobe?? This seems like an odd place to do it since it doesn't read joy data here =P
STA $4015 ; turn off all sound channels
STA $5015 ; turn off all sound channels (MMC5)
STA $4010 ; disble DMC IRQs
STA $4017 ; set alternative pAPU frame counter method, reset the frame counter, and disable APU IRQs
;DEX ; X was previously 0, this makes it FF
TXS ; transfer it to the Stack Pointer (resetting the SP)
; STX unk_0100 ; ??? (commented out in Namcot version, so I did it here too.)
JSR ClearBGPalette ; clear the BG palette
LDA #$06 ; swap to bank 6 again (even though we just did) .. but why? We never use
JSR SwapPRG ; anything in bank 6
JMP GameStart_L ; jump to the start of the game!
I'm not sure if I'm missing things, or if I have the right settings for the registers I do have... There's a list in Disch's MMC5 document, but I don't know what's necessary.
For the "PRG_Swap", I don't know what to do at all.
The original has it STA-ing to $FFF9. From what I've read, it sounds like MMC5 uses either $5113, $5115, or even $5117? Is there more that needs to be done here, or is it as simple as STA and RTS?
I'm worried that even what I think I understand, I am massively confusing myself over...