It is currently Thu Nov 14, 2019 8:04 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Nov 12, 2019 5:32 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 328
I'm not fluent in c++, but I've been attempting to modify certain functions within the MMC5 mapper. So far I've been able to adjust the output size of the .sav file, but I need to adjust how many swappable wram pages are available. Register $5113 goes from 00-07, giving you 8 individual 2000 byte pages. But I need 32 pages (00-1F), and when you go higher than 07 within $5113, it repeats the other previous pages due to the bits involved.

Anyone with c++ knowledge that'd be willing to help would be greatly appreciated.


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 6:39 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21688
Location: NE Indiana, USA (NTSC)
32 pages is 256 KiB of RAM. What application needs that much RAM?

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 9:52 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 328
I'm creating a new project where the player can construct & save. I dont want to spoil any details as to what I'm trying to accomplish, but it works. I just need more available wram, which is why I've been trying to modify the mmc5.cpp file.


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 11:01 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 328
So I'm hoping there's someone who can help me out with this.


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 12:07 pm 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 990
There's an "& 7" in a couple places around 5113 setting there. You'd change that to 31. But there may be many other places needing modification.


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 12:13 pm 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 328
I'll edit that tonight. I know there's another section that looks to deal with the actual swapping of pages. They were "case"'s

case 0
case 1
case 2
case 4
case 8

I tried fiddling with that area but wasnt getting the correct results. Shouldn't have expected much since I can't write c++ :-/


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 1:57 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7629
Location: Canada
We're talking about FCEUX's mmc5.cpp?

Check the GenMMC5_Init function at the bottom to set the save game size, in particular info->SaveGameLen needs to be set to the size of your WRAM for saving and loading to disk to work. You'll notice this is full of 3 special case hacks currently, so I guess you'll need another special case for 256k.

Secondly in MMC5_Init you'll need some way to specify WRAMSIZE... The iNES 2 header can specify WRAM size, and if info->ines2 is true it will show up in info->wram_size and/or info->battery_warm_size. You'll want to make MMC5_Init pay attention to that instead of just guessing it via CRC.

Go over all the uses of the actual bankswitch registers and see how the value is used to select a bank (search for uses of MMC5WRAM). It looks like & 7 is hardcoded in a bunch of locations, so... replace those with a mask variable I guess. Probably something to set in MMC5_Init to 7 generically, or something like (WRAMSIZE>>13)-1 when specified via iNES 2?

Also there's MMC5WRAMIndex which seems to map the smaller sizes to a 64k master. This needs to be expanded from 8 entries to 32, and BuildWRAMSizeTable should fill it with the values 0 to 31 for the 256k case, I guess?

There might be other stuff, too, but that's as far as I want to dig here speculatively. MMC5 is a big mapper implementation with a lot of historical hacky stuff in it. What you're asking can certainly be done, but it's not quite trivial.


Top
 Profile  
 
PostPosted: Tue Nov 12, 2019 5:17 pm 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 328
Thank you rainwarrior, I'm going to start making adjustments/changes the best I can.

EDIT

So these are the changes I've made, but still no luck with swapping newer pages. I do however have the .sav outputting perfectly at 256kb.

BuildWRAMSizeTable(void)
Code:
for (x = 0; x < 32; x++) {   //infidelity 11-12-19

case 0: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7   //infidelity 11-12-19 (case 0 - case 32)
      case 1: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 2: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 3: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 4: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 5: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 6: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 7: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 8: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 9: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 10: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 11: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 12: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 13: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 14: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 15: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 16: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 17: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 18: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 19: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 20: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 21: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 22: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 23: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 24: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 25: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 26: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 27: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 28: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 29: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 30: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 31: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7
      case 32: MMC5WRAMIndex[x] = x; break;                   //0,1,2,3,4,5,6,7


MMC5WRAM(uint32 A, uint32 V)
Code:
V = MMC5WRAMIndex[V & 0x1F];   //infidelity 11-12-19


DECLFW(Mapper5_write)
Code:
      case 0x5113:
         WRAMPage = V;
         MMC5WRAM(0x6000, V & 0x1F);   //infidelity 11-12-19


MMC5Synco(void)
Code:
MMC5WRAM(0x6000, WRAMPage & 0x1F);   //infidelity 11-12-19


GenMMC5Init(CartInfo * info, int wsize, int battery)
Code:
WRAM = (uint8*)FCEU_gmalloc(wsize * 262144);   //infidelity 11-12-19

         info->SaveGameLen[0] = 262144;   //infidelity 11-12-19
      else
         info->SaveGameLen[0] = 262144;   //infidelity 11-12-19


Top
 Profile  
 
PostPosted: Wed Nov 13, 2019 5:38 am 
Offline

Joined: Fri Mar 01, 2013 4:46 am
Posts: 328
Do my current changes look ok? Especially my changes to & 7 ?

Any further assistance would be great. I can't progress any further with this, not even sure if what I've done is correct.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: MSN [Bot] and 9 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