Problem with mapper 66 on emulators or everdrive n8?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
nesrocks
Posts: 427
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Problem with mapper 66 on emulators or everdrive n8?

Post by nesrocks » Tue Jun 04, 2019 8:05 pm

My Ghostbusters romhack uses mapper 66. It always worked fine on all emulators and also on my krikzz everdrive n8. At some point there was a modification to the rom that broke compatibility with the everdrive and virtuanes: the game won't boot up (gray screen). Only now I've noticed it.

The rom was expanded from 2 PRG banks to 4. So, rom addresses 0x0000-0x7FFF in the original to 0x0000-0xFFFF in the new one for PRG. This was working on all emulators and the everdrive. But a modification on the end of the final bank seems to be causing trouble with the everdrive and with virtuanes, even though fceux tells me that code isn't run at startup at all. So, either the everdrive and virtuanes isn't implementing the mapper correctly, or all other emulators aren't. Any idea?

Works:

Code: Select all

 03:FFF2:A9 0F     LDA #$0F
 03:FFF4:8D F3 FF  STA $FFF3 = #$0F
 03:FFF7:00        BRK
 03:FFF8:00        BRK
 03:FFF9:00        BRK
 03:FFFA:F2        UNDEFINED
 03:FFFB:FF        UNDEFINED
 03:FFFC:F2        UNDEFINED
 03:FFFD:FF        UNDEFINED
 03:FFFE:F2        UNDEFINED
 03:FFFF:FF        UNDEFINED
Won't work (though fceux insists this isn't even run/read at boot up):

Code: Select all

 03:FFF3:A9 0F     LDA #$0F  // notice that the address is different now by 1 byte
 03:FFF5:8D F3 FF  STA $FFF3 = #$A9
 03:FFF8:00        BRK
 03:FFF9:00        BRK
 03:FFFA:F2        UNDEFINED
 03:FFFB:FF        UNDEFINED
 03:FFFC:F2        UNDEFINED
 03:FFFD:FF        UNDEFINED
 03:FFFE:F2        UNDEFINED
 03:FFFF:FF        UNDEFINED
Just wanted to share. I'll try modifying the code so it stays in the same address. I'm guessing it must be more likely that the mapper 66 implementation on everdrive isn't perfect and it's starting on the wrong bank or something, and out of chance it was working before.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

User avatar
Dwedit
Posts: 4233
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Problem with mapper 66 on emulators or everdrive n8?

Post by Dwedit » Tue Jun 04, 2019 8:28 pm

I'd double check Unknown Initial Bank State, and Bus Conflicts.

Unknown Initial State: Make sure all banks will lead to valid bootup code at their reset vector. For the secondary banks, you'd want to switch to the first bank and run the normal boot code (try copying a small write and jump into RAM).
Bus conflicts: When writing to the ROM area of a cartridge (mapper registers), make sure the value in ROM at that address matches.
Last edited by Dwedit on Tue Jun 04, 2019 8:31 pm, edited 1 time in total.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
koitsu
Posts: 4214
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Problem with mapper 66 on emulators or everdrive n8?

Post by koitsu » Tue Jun 04, 2019 8:29 pm

I suspect this is the hard-wired/fixed bank in the ROM (I cannot be bothered to look up mapper 66 to verify). Assuming it is, the answer becomes semi-obvious:

Original and modified:

$FFFA = NMI vector, points to $FFF2
$FFFC = RESET vector, points to $FFF2
$FFFE = IRQ/BRK vector, points to $FFF2

For whatever reason, you've chosen to omit the code at $FFF2 in the modified version ("won't work"). I suspect that byte is not $EA (nop), and even more so strongly suspect that it's a byte of an instruction (either valid or invalid opcode) that has operand bytes associated with it. Let's pretend the byte at $FFF2 happens to be $AD (lda absolute). The code executed then becomes this:

Code: Select all

FFF2: AD A9 0F    lda $0fa9
FFF5: 8D F2 FF    sta $fff3
FFF8: ...
In other words: your vectors (especially RESET) are now wrong -- off by one byte -- and thus the code executed does not match what you think will happen.

User avatar
nesrocks
Posts: 427
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Problem with mapper 66 on emulators or everdrive n8?

Post by nesrocks » Tue Jun 04, 2019 9:13 pm

Thanks guys, I think I got it working. It seems indeed that virtuanes and the everdrive are starting with banks 2-3 active. And yeah, my vectors on bank 3 were blatantly wrong! I also fixed the bank 3 reset vector so it won't result in bus conflicts. Thank you!
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

Post Reply