It is currently Sat Oct 21, 2017 5:22 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: MMC1 - DQ4
PostPosted: Wed Jan 26, 2005 7:06 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
I've been having trouble with Dragon Quest 4 in my emu... it just gives me a grey screen.

I traced the code somewhat, and I found that it's swapping to an improper bank and running garbage code. I figure I must be doing the > 256k swapping wrong or something -- I haven't had any other problems with any other MMC1 games I've tried.

Here's a somewhat edited version of my MMC1 code. 'a' is the register written to on the final write (0-3), 'v' is the complete 5 bit written value:

Code:
   switch(a)
   {
   case 0:      /* $8000 - $9FFF      */
      if(v & 0x02)
      {
         if(v & 0x01)   DoHorzMirror();
         else         DoVertMirror();
      }
      else            Do1ScrMirror(v & 0x01);

      mprPRGSwapBank =   v & 0x04;
      mprPRGSwapSize =   v & 0x08;
      mprCHRSwapSize =   v & 0x10;
      break;

   case 1:      /* $A000 - $BFFF      */
      if(bChrRam)
         mprPRGHighBit =   (v & 0x10);
      else if(mprCHRSwapSize)
         SwapCHR(0,4,v);
      else
         SwapCHR(0,8,v >> 1);
      break;

   case 2:      /* $C000 - $DFFF      */
      if(!bChrRam && mprCHRSwapSize)
         SwapCHR(4,4,v);
      break;

   case 3:      /* $E000 - $FFFF      */
  // wram disable stuff here -- removed for this paste
      v = (v & 0x0F) | (u8)(mprPRGHighBit & 0x10);
      if(mprPRGSwapSize)
      {
         if(mprPRGSwapBank)   SwapPRG(0,4,v);
         else            SwapPRG(4,4,v);
      }
      else
         SwapPRG(0,8,v >> 1);
      break;
   }


The high swap bit is taken from the $A000-$BFFF register, no? or is it both that register and the other CHR register ($C000-$DFFF)?

This is the 512k DQ4 ROM ("Dragon Quest 4 (J).nes") -- I know there's supposedly a 1024k overdump ROM out there or something, but I think I have the right one.

Anyone have any ideas? Thanks. =)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 7:30 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
On the SUROM board, the upper PRG bank select bit is simply connected to the upper CHR ROM select line - this means that simply changing CHR banks will also instantly change your PRG ROM banks. It also means if you use 4KB CHR banks, both banks MUST have the SAME value in the upper bit, otherwise the PRG bank will constantly change as the PPU renders.

This is similar to the MMC3 issue posted in the other thread, in that it is easily fixed by using a single 'Sync' function for the mapper.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 7:41 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Awesome... that makes a whole lot of sense -- I'll try that out in a second.

Another thing that puzzled me about MMC1 is how it reacts when you abrupty change modes. Perhaps you could clarify that for me too? ^^

Say you're in 16k PRG swapping mode, and you have bank 0 swapped in at $8000 and bank F (last bank) in at $C000, then you switch to 32k mode... does that change what ROM is accessed where? or does new stuff sort of get swapped in? Ditto for the CHR setup... do things change if you switch from 4k CHR swapping to 8k? And vice versa? Do any games actually do this?

Anyway, thanks again for the tip ^^


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 8:47 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
It's the same as changing the bank flipping in MMC3 - if you change MMC1 reg0, it will immediately update PRG and CHR banks as well.
Also, when using the MMC1, there is only ONE PRG bank register. If you set it to 32KB PRG bank mode, it will use that register to map a single bank at 8000-FFFF using the value in reg3 (ignoring the bottom bit). If you set it to 16KB bank mode, you can either map 16KB bank [reg3] at 8000-BFFF and the last 16KB bank at C000-FFFF or the first 16KB bank at 8000-BFFF and 16KB bank [reg3] at C000-FFFF.
The mode select register does NOT allow you to select between multiple PRG bank registers - it simply changes the way the one PRG bank register is used.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 8:59 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Ah. Excellent.

Thanks again ^^


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 7:52 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
Finally got it all working. The game was running up until you started a game -- or a bit after the big "IV" shows on the title screen.. at which point it would crash. The one thing that was throwing me off was when the game changes the high bit (the 256k selection bit) that also determines which 16k gets swapped into $C000-$FFFF.

DQ4 leaves that range 'hard-wired' and only swaps out $8000-$BFFF... but when it changes which 256k block it's putting in $8000 that also changes which 256k block is used when taking the 16k for $C000-$FFFF

Just thought I'd bring that up just in case anyone else had the same problems as me. ^^

Thanks again Q


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 8 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