It is currently Thu Dec 14, 2017 1:11 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Nov 03, 2015 9:13 pm 
Offline

Joined: Wed Oct 21, 2015 10:28 pm
Posts: 20
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!


Top
 Profile  
 
PostPosted: Tue Nov 03, 2015 9:22 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19342
Location: NE Indiana, USA (NTSC)
It's checking to make sure there isn't any RAM.


Top
 Profile  
 
PostPosted: Tue Nov 03, 2015 9:27 pm 
Offline

Joined: Wed Oct 21, 2015 10:28 pm
Posts: 20
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).


Top
 Profile  
 
PostPosted: Tue Nov 03, 2015 9:30 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19342
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Tue Nov 03, 2015 9:42 pm 
Offline

Joined: Wed Oct 21, 2015 10:28 pm
Posts: 20
Here is a snippet

Code:
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


Top
 Profile  
 
PostPosted: Tue Nov 03, 2015 9:51 pm 
Offline

Joined: Wed Oct 21, 2015 10:28 pm
Posts: 20
Here is my read logic for $6000-$7FFF read
Code:
// WRAM/battery backed ram
if (address >= 0x6000 && address <= 0x7FFF)
{
   if (battPRGRAM)
      return battPRGRAM[address & 0x1FFF];
   return 0xFF;
}


And here is my write logic
Code:
// 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)


Top
 Profile  
 
PostPosted: Tue Nov 03, 2015 10:45 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19342
Location: NE Indiana, USA (NTSC)
It looks like it's returning into la la land right after bankswitching CHR ($A000). Or is it also bankswitching PRG ($E000)?


Top
 Profile  
 
PostPosted: Wed Nov 04, 2015 8:59 pm 
Offline

Joined: Wed Oct 21, 2015 10:28 pm
Posts: 20
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..


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group