Mapper 69 troubles

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Mapper 69 troubles
by on (#105293)
I'm implementing Mapper 69 and having some troubles. Specifically, Batman: Return of the Joker. It is setting the following FME7 registers:

$8000 = $08
$A000 = $C0

and then a few hundred cycles later it JSR's to $6000! According to the wiki, that means that its jumping into RAM, IE dynamically written code. I double checked with a Bizhawk trace, and it indeed does the exact same thing there. The difference is of course that I have different code in RAM than Bizhawk.

So my question is, is PRAM initialized specially in some way for Mapper 69? I believe right now I'm just clearing it to 0.

Note: The jump to $6000 occurs at cycle 508,357 for me (Bizhawk is roughly the same cycle for the jump):
9917 20 JSR A:A8 X:F7 Y:FF P:81 SP:FD Cy:508357
Re: Mapper 69 troubles
by on (#105295)
That mapper can also map PRG-ROM pages into $6000-7FFF, not just PRG-RAM.

http://wiki.nesdev.com/w/index.php/INES_Mapper_069 wrote:
R:8 controls $6000-7FFF. It can map in PRG-RAM, PRG-ROM, or leave it unmapped (open bus), depending on the
mode it sets:

R:8: [ERPP PPPP]
E = Enable RAM (0=disabled, 1=enabled)
R = RAM/ROM select (0=ROM, 1=RAM)
P = PRG page

if E=0 and R=1, RAM is selected, but it's disabled, resulting in open bus. In case it's still unclear:

R=0: ROM @ $6000-7FFF
R=1, E=0: Open Bus @ $6000-7FFF
R=1, E=1: RAM @ $6000-7FFF


When the game is jumping to $6000, it's probably expecting a PRG-ROM page to be mapped in there.
Re: Mapper 69 troubles
by on (#105296)
EnigmaWave wrote:
That mapper can also map PRG-ROM pages into $6000-7FFF, not just PRG-RAM.

http://wiki.nesdev.com/w/index.php/INES_Mapper_069 wrote:
R:8 controls $6000-7FFF. It can map in PRG-RAM, PRG-ROM, or leave it unmapped (open bus), depending on the
mode it sets:

R:8: [ERPP PPPP]
E = Enable RAM (0=disabled, 1=enabled)
R = RAM/ROM select (0=ROM, 1=RAM)
P = PRG page

if E=0 and R=1, RAM is selected, but it's disabled, resulting in open bus. In case it's still unclear:

R=0: ROM @ $6000-7FFF
R=1, E=0: Open Bus @ $6000-7FFF
R=1, E=1: RAM @ $6000-7FFF


When the game is jumping to $6000, it's probably expecting a PRG-ROM page to be mapped in there.


Yeah, but writing 8 into 8000, C0 into A000 maps RAM, not ROM. Which is why this is all confusing if the code is indeed expecting ROM. Bizhawk has the same behavior of jumping into RAM if it implements Mapper 69 to spec.
Re: Mapper 69 troubles
by on (#105299)
/side rant. MMC5 is crazy complicated compared to other mappers. I'm not even sure where to start implementing it. Need to re-read the docs again.
Re: Mapper 69 troubles
by on (#105300)
Ok, I've just finished running BM:ROTJ in my emu to see what it does, it looks like jumping to PRG-RAM is the correct behavior.

I turned on logging from the first write to $6000-$7FFF until the first jump to $6000 to locate the loop where it fills PRG-RAM:

Code:
Log Excerpts

First iteration:
98F8  AD 07 20  LDA $2007 = A9                  A:5F X:1E Y:00 P:22 SP:FD CYC:194 SL:257
98FB  91 10     STA ($10),Y = 6000 @ 6000 = 20  A:A9 X:1E Y:00 P:A0 SP:FD CYC:206 SL:257
98FD  A5 12     LDA $12 = 5F                    A:A9 X:1E Y:00 P:A0 SP:FD CYC:224 SL:257
98FF  38        SEC                             A:5F X:1E Y:00 P:20 SP:FD CYC:233 SL:257
9900  E9 01     SBC #$01                        A:5F X:1E Y:00 P:21 SP:FD CYC:239 SL:257
9902  85 12     STA $12 = 5F                    A:5E X:1E Y:00 P:21 SP:FD CYC:245 SL:257
9904  B0 03     BCS $9909                       A:5E X:1E Y:00 P:21 SP:FD CYC:254 SL:257
9909  C8        INY                             A:5E X:1E Y:00 P:21 SP:FD CYC:263 SL:257
990A  D0 EC     BNE $98F8                       A:5E X:1E Y:01 P:21 SP:FD CYC:269 SL:257

Last iteration:
98F8  AD 07 20  LDA $2007 = FF                  A:01 X:00 Y:5E P:21 SP:FD CYC:116 SL:147
98FB  91 10     STA ($10),Y = 7E00 @ 7E5E = 85  A:FF X:00 Y:5E P:A1 SP:FD CYC:128 SL:147
98FD  A5 12     LDA $12 = 01                    A:FF X:00 Y:5E P:A1 SP:FD CYC:146 SL:147
98FF  38        SEC                             A:01 X:00 Y:5E P:21 SP:FD CYC:155 SL:147
9900  E9 01     SBC #$01                        A:01 X:00 Y:5E P:21 SP:FD CYC:161 SL:147
9902  85 12     STA $12 = 01                    A:00 X:00 Y:5E P:23 SP:FD CYC:167 SL:147
9904  B0 03     BCS $9909                       A:00 X:00 Y:5E P:23 SP:FD CYC:176 SL:147
9909  C8        INY                             A:00 X:00 Y:5E P:23 SP:FD CYC:185 SL:147
990A  D0 EC     BNE $98F8                       A:00 X:00 Y:5F P:21 SP:FD CYC:191 SL:147


Probably a good place to check next.
Re: Mapper 69 troubles
by on (#105301)
EnigmaWave wrote:
Ok, I've just finished running BM:ROTJ in my emu to see what it does, it looks like jumping to PRG-RAM is the correct behavior.

I turned on logging from the first write to $6000-$7FFF until the first jump to $6000 to locate the loop where it fills PRG-RAM:

Code:
Log Excerpts

First iteration:
98F8  AD 07 20  LDA $2007 = A9                  A:5F X:1E Y:00 P:22 SP:FD CYC:194 SL:257
98FB  91 10     STA ($10),Y = 6000 @ 6000 = 20  A:A9 X:1E Y:00 P:A0 SP:FD CYC:206 SL:257
98FD  A5 12     LDA $12 = 5F                    A:A9 X:1E Y:00 P:A0 SP:FD CYC:224 SL:257
98FF  38        SEC                             A:5F X:1E Y:00 P:20 SP:FD CYC:233 SL:257
9900  E9 01     SBC #$01                        A:5F X:1E Y:00 P:21 SP:FD CYC:239 SL:257
9902  85 12     STA $12 = 5F                    A:5E X:1E Y:00 P:21 SP:FD CYC:245 SL:257
9904  B0 03     BCS $9909                       A:5E X:1E Y:00 P:21 SP:FD CYC:254 SL:257
9909  C8        INY                             A:5E X:1E Y:00 P:21 SP:FD CYC:263 SL:257
990A  D0 EC     BNE $98F8                       A:5E X:1E Y:01 P:21 SP:FD CYC:269 SL:257

Last iteration:
98F8  AD 07 20  LDA $2007 = FF                  A:01 X:00 Y:5E P:21 SP:FD CYC:116 SL:147
98FB  91 10     STA ($10),Y = 7E00 @ 7E5E = 85  A:FF X:00 Y:5E P:A1 SP:FD CYC:128 SL:147
98FD  A5 12     LDA $12 = 01                    A:FF X:00 Y:5E P:A1 SP:FD CYC:146 SL:147
98FF  38        SEC                             A:01 X:00 Y:5E P:21 SP:FD CYC:155 SL:147
9900  E9 01     SBC #$01                        A:01 X:00 Y:5E P:21 SP:FD CYC:161 SL:147
9902  85 12     STA $12 = 01                    A:00 X:00 Y:5E P:23 SP:FD CYC:167 SL:147
9904  B0 03     BCS $9909                       A:00 X:00 Y:5E P:23 SP:FD CYC:176 SL:147
9909  C8        INY                             A:00 X:00 Y:5E P:23 SP:FD CYC:185 SL:147
990A  D0 EC     BNE $98F8                       A:00 X:00 Y:5F P:21 SP:FD CYC:191 SL:147


Probably a good place to check next.


You are a god send! Thank you so much!
Re: Mapper 69 troubles
by on (#105302)
Nestopia's source says:
Code:
  if (!(data & 0x40) || (data & 0x80))
    wrk.Source( !(data & 0x40) ).SwapBank<SIZE_8K,0x0000>( data );
  break;

And trying to play B:ROTJ(E) or Dynamite Batman(J), it worked for me.

This seems to be slightly wrong; writes which would have set open-bus here are instead ignored. (But that's not the problem you're reporting)

In any case:
Zelex wrote:
So my question is, is PRAM initialized specially in some way for Mapper 69? I believe right now I'm just clearing it to 0.
No, and even if it were, it wouldn't be initialized to valid code. I have to assume somehow your emulator isn't dealing with RAM correctly... er, what EnigmaWave said.
Re: Mapper 69 troubles
by on (#105308)
I found the typo :) Batman working! thx so much =D Looking forward to showing the forum my latest handy work =D New thread soon, maybe next year.