News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: N64 Save Type Hacking  (Read 1367 times)

binkers87

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
N64 Save Type Hacking
« on: January 16, 2017, 07:19:53 pm »
Where would I find the save type settings within the rom file?  For example let's say I wanted to convert Zelda Majoras mask (FlashRAM) into saving via SRAM. Is it  just a matter of changing a byte in the rom from 01 to 02 or something or are we talking reprogramming a larger portion of the game all together?

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: N64 Save Type Hacking
« Reply #1 on: January 17, 2017, 11:46:24 am »
From what little I've read, I'm almost sure Flash requires different programming to access than SRAM.
(apparently one of the bigger headaches of GBA emulation is figuring out chip IDs for different carts to make Flash work)
So changing to SRAM would require some ASM hacking.
"My watch says 30 chickens" Google, 2018

binkers87

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: N64 Save Type Hacking
« Reply #2 on: January 17, 2017, 03:00:28 pm »
Thanks Mike. What about Eeprom to sram . I see more hacks done that way

Zoinkity

  • Hero Member
  • *****
  • Posts: 562
    • View Profile
Re: N64 Save Type Hacking
« Reply #3 on: January 17, 2017, 04:50:24 pm »
SRAM and eeprom are different devices and are accessed in different ways.  You talk to eeprom the way you talk to controllers, through PIF commands.  By comparison, communicating with SRAM and FLASH is normal hardware access, like carts, using DMAs and word writes after setting proper EPI settings.

There was only one vendor for SRAM chips from what I know, but there were multiple vendors for FLASH chips.  You have to query the chip type; set the EPI settings for the corresponding pulse width, page size, latency, etc.; and possibly alter the protocol a little bit for communication.  I haven't exactly gone through all the code for each one.  Emulators cheat and always report MX_PROTO_A.

SRAM is effectively a blob of memory at a given address, usually mapped to A8000000.  They burst the whole thing in one go, which would mean it has a fairly hard limit of 0x20000 bytes unless you write your own interface for it.  If you aren't using stock chips then you'd pretty much have to do that anyway.
A couple games use their own hand-rolled save hardware.

The important point here though is that all of these have different sizes.  Cart eeprom comes in a 4k and 16k, SRAM as previously mentioned, and FLASH is larger still.  Downconverting from FLASH to SRAM will limit the number of usable save files or lead to data loss; upconverting from any type to any other requires changing code and is relatively pointless since you're wasting all that unused data.

I'd suggest reversing the code used in several titles to see how it's done for specific types.  Looking at homebrew source code isn't terribly helpful for understanding hardware behaviour and often masks complexity.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6885
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: N64 Save Type Hacking
« Reply #4 on: January 17, 2017, 10:47:38 pm »
Oh, so I read Majora's Mask had the Zelda traditional three save files in Japan, but nuked one to give the west Owl Saves?
"My watch says 30 chickens" Google, 2018