Holy Diver Batman MMC1 (M1_P128K.nes)

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
breathermachine
Posts: 20
Joined: Wed Oct 21, 2015 10:28 pm

Holy Diver Batman MMC1 (M1_P128K.nes)

Post by breathermachine »

I'm currently implementing WRAM (battery backed and not) for MMC1 using Holy Diver Batman as test roms. However, my emulator dies on M1_128K.nes. I assume that it has no WRAM because there are other MMC1 roms that I think have (M1_P128K_C32K_S8K.nes, M1_P128K_C32K_W8K.nes, etc.)

Debugging my emulator, M1_128K.nes does seem to make a write at $6000-$7FFF although my emulator ignores the write as the test rom has no WRAM.

Can anyone elaborate on this?
Thank you!
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by tepples »

It's checking to make sure there isn't any RAM.
breathermachine
Posts: 20
Joined: Wed Oct 21, 2015 10:28 pm

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by breathermachine »

Somewhere I'm not sure yet but when I enable WRAM for M1_P128K.nes (i.e. by honoring the write request), the rom does not crash. Although I'm not sure if honoring the write request is the right thing to do. If I don't honor the write request, the emulator dies on an illegal opcode (probably due to jumping to an uninitialized location).
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by tepples »

If so, that's a bug. I'd like to see the log of the last few instructions before the crash when emulating missing WRAM.
breathermachine
Posts: 20
Joined: Wed Oct 21, 2015 10:28 pm

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by breathermachine »

Here is a snippet

Code: Select all

0443  8D 00 A0  STA $A000 = FF                  A:04 X:10 Y:03 P:24 SP:FD
0446  4A        LSR A                           A:04 X:10 Y:03 P:24 SP:FD
0447  88        DEY                             A:02 X:10 Y:03 P:24 SP:FD
0448  D0 F9     BNE $443                        A:02 X:10 Y:02 P:24 SP:FD
0443  8D 00 A0  STA $A000 = FF                  A:02 X:10 Y:02 P:24 SP:FD
0446  4A        LSR A                           A:02 X:10 Y:02 P:24 SP:FD
0447  88        DEY                             A:01 X:10 Y:02 P:24 SP:FD
0448  D0 F9     BNE $443                        A:01 X:10 Y:01 P:24 SP:FD
0443  8D 00 A0  STA $A000 = FF                  A:01 X:10 Y:01 P:24 SP:FD
0446  4A        LSR A                           A:01 X:10 Y:01 P:24 SP:FD
0447  88        DEY                             A:00 X:10 Y:01 P:27 SP:FD
0448  D0 F9     BNE $443                        A:00 X:10 Y:00 P:27 SP:FD
044A  60        RTS                             A:00 X:10 Y:00 P:27 SP:FD
Unsupported opcode encountered $FF, PC=$C01C
breathermachine
Posts: 20
Joined: Wed Oct 21, 2015 10:28 pm

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by breathermachine »

Here is my read logic for $6000-$7FFF read

Code: Select all

// WRAM/battery backed ram
if (address >= 0x6000 && address <= 0x7FFF)
{
	if (battPRGRAM)
		return battPRGRAM[address & 0x1FFF];
	return 0xFF;
}
And here is my write logic

Code: Select all

// WRAM/Battery backed ram write
if (address >= 0x6000 && address <= 0x7FFF)
{
	if (battPRGRAM && !ramChipDisable)
		battPRGRAM[address & 0x1FFF] = value;
}
I have assumed 8KB WRAMs for now (I think this shouldn't affect M1_128K.nes)
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by tepples »

It looks like it's returning into la la land right after bankswitching CHR ($A000). Or is it also bankswitching PRG ($E000)?
breathermachine
Posts: 20
Joined: Wed Oct 21, 2015 10:28 pm

Re: Holy Diver Batman MMC1 (M1_P128K.nes)

Post by breathermachine »

Ok got it fixed! :D

It was due to a stupid typo in my PRG bankswitching code as I inadvertently used CHR banking mode as the check for PRG banking mode.
Finally got SGROM to work!

:D

I'm surprised that my emulator got this far considering this was a crucial part in PRG bankswitching..
Post Reply