ETROM / 256k SRAM problems. Need advice

A place that you can discuss reproduction of classic titles or "licensed-for-reproduction" homebrew for personal use.

Moderators: B00daW, Moderators

Forum rules
1. NO BLATANT PIRACY. This includes reproducing homebrew less than 10 years old, with the exception of free software.
2. No advertising your reproductions, with the exception of free software.
3. Be nice. See RFC 1855 if you aren't sure what this means.
Mbumstead
Posts: 19
Joined: Wed Aug 21, 2013 5:00 pm

ETROM / 256k SRAM problems. Need advice

Post by Mbumstead »

I am attempting to modify a ETROM to hold 2 - 256k SRAM chips so I can build a copy of the new updated Legend of Link by infidelity that has 3 separate save files. I know that an EWROM has the 256 SRAM but on this nesdev wiki page ( http://wiki.nesdev.com/w/index.php/ExROM ) it says at the bottom that the ETROM can be modified by using the SL15 solder pad instead of the CL15. I've got everything built but what's happening is when I try to select through the three save files only two of them will work. The third file freezes the game up. You can select between files 1 and 2 without any issues and they save fine. But when you try to select the third file it scrambles the screen, or blacks out the screen.

Does anyone have any idea what would be causing this to happen ?

If you need any further info please let me know.

And thank you , in advance , for your time and help.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: ETROM / 256k SRAM problems. Need advice

Post by lidnariq »

Unfortunately, I did my best to determine the function of NES-ETROM CL15/SL15 based on pictures of the front and back (hence the "some unknown pin on the MMC5" bit)

So, if it's easy enough for you to program a new ROM, I could write a simple test ROM that would verify what's going on with RAM.

... Also, it really looks like Infidelity's LoZ1 MMC5 hack expects a single 32K RAM in slot one. You say you swapped both 8 KiB RAMs for two 32 KiB RAMs and changed the jumper, so nothing's obvious there... Could you verify that what I wrote about CL15/SL15 does what the wiki says it does?
Mbumstead
Posts: 19
Joined: Wed Aug 21, 2013 5:00 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by Mbumstead »

Yes , I can do that. I'll post back here ASAP.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: ETROM / 256k SRAM problems. Need advice

Post by lidnariq »

... thinking a little more about the behavior you describe, maybe my observation about PRG RAM A14 being connected is what's wrong ?

Infidelity wrote that the crash comes from trying to switch between banks 0 and 1-or-2 and having that fail ( http://acmlm.kafuka.org/board/thread.ph ... 703#163703 ) ... so if it only crashes on slot 2, that could be equivalent to only finding 16 KiB of RAM??
Mbumstead
Posts: 19
Joined: Wed Aug 21, 2013 5:00 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by Mbumstead »

Ok. I've checked both ways and this is what I've got.

CL15 - SRAM26 to MMC5 83 (PRG RAM + CE)

SL15 - SRAM26 to MMC5 69 ( PRG RAM A13)

Hope that helps. Let me know if you need anything else.


Also, I am the one who built the copy for Infidelity using a EWROM. the wierd thing about that one was that it did this exact same thing at first. I recycled the game about 6 times and it quit freezing and started working correctly. He has told me it is still working fine. I have no answer on how it started working at all. It was freezing just like this and then it just quit.
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: ETROM / 256k SRAM problems. Need advice

Post by infidelity »

I just want to explain how my sram works in this game, in regards to MMC5. But first a brief explanation to how the original Legend of Zelda works.

First, The Legend of Zelda heavily uses $6000-$7FFF for PRG-RAM, since 3 quarters of the $C000-$FFFF rom bank are occupied with DPCM samples.

With The Legend of Link, I use the MMC5 mapper which allows me to have 4 individual SRAM pages, 2000 bytes each.

The MMC5 uses the register $5113, to swap out the SRAM pages. Since my game only uses 3 save files, I only use the first 6000 bytes. (3 SRAM pages of 2000 bytes each)

Now here is how I accomplish creating the additional 2 SRAM pages without crashing the rom (at least on all 3 major PC emulators FCEUX, Nestopia & Nintendulator)

After you exit the title screen, the 1st sram page gets all of the PRG-RAM installed, and various other values. This is how the original Zelda does this. Now, once the SRAM page is finished being stored, the rom is then supposed to initiate the Registration Screen. In my game, I create a sub routine to custom asm, to prepare the creation of the other 2 SRAM pages. What I do, is copy the first byte of the first address of Page 0 in $5113, and then I swap out Page 0 to Page 1, and then I paste the value to the same address in Page 1, then I swap out Page 1 and load Page 2 and then paste the same value to the same address within Page 2. Then I bring back Page 0, load the next value from the next address, and I repeat this entire process until all 2000 bytes from Page 0 have been copied into Page's 1 & 2.

The end result, is this file i'm linking for all to see. http://www.filedropper.com/zelda-thelegendoflink You need a hex viewing program to see it. But this file shows 2 carbon copies of the first 2000 bytes, when the registration screen comes on.

$0-$1FFF SRAM Page 0 $5113 mmc5 (File 1)
$2000-$3FFF SRAM Page 1 $5113 mmc5 (File 2)
$4000-$5FFF SRAM Page 2 $5113 mmc5 (File 3)
$6000-$7FFF BLANK. NOT IN USE.

So when on the registration screen after all has been created, you cycle through the files with the D-PAD. When on File 1, that's showing the first 2000 bytes of the SRAM/mmc5's $5113, which is occupying the NES's $6000-$7FFF addresses. When you select File 2, the game swaps out mmc5's $5113's Page 0, to Page 1, which is $2000-$3FFF in the SRAM, and then has that occupying the NES's $6000-$7FFF addresses. When you select File 3, the game swaps out the mmc5's $5113's Page 1, to Page 2, which is $4000-$5FFF in the SRAM, and then has that occupying the NESs $6000-$7FFF addresses.

I've done extensive tests with this on all 3 PC emulators. All 3 emulators store, swap, save, load, everything correctly.

I hope this information helps in regards to real MMC5 hardware. :-)
Last edited by infidelity on Sat Nov 05, 2016 5:10 am, edited 6 times in total.
Mbumstead
Posts: 19
Joined: Wed Aug 21, 2013 5:00 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by Mbumstead »

lidnariq wrote:... thinking a little more about the behavior you describe, maybe my observation about PRG RAM A14 being connected is what's wrong ?

Infidelity wrote that the crash comes from trying to switch between banks 0 and 1-or-2 and having that fail ( http://acmlm.kafuka.org/board/thread.ph ... 703#163703 ) ... so if it only crashes on slot 2, that could be equivalent to only finding 16 KiB of RAM??

I don't think so. I've lifted pin 1 of the SRAM (A14) and it would only save one file. It would select between 1 and 2 but it was only 1 file. I saved the name "AAA" in slot 1 but it would show up in slot 2 too. So that was telling me that it wasn't recognizing any more than the one file. And when doing that file 3 would still freeze.
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: ETROM / 256k SRAM problems. Need advice

Post by infidelity »

lidnariq wrote:... thinking a little more about the behavior you describe, maybe my observation about PRG RAM A14 being connected is what's wrong ?

Infidelity wrote that the crash comes from trying to switch between banks 0 and 1-or-2 and having that fail ( http://acmlm.kafuka.org/board/thread.ph ... 703#163703 ) ... so if it only crashes on slot 2, that could be equivalent to only finding 16 KiB of RAM??
I was explaining a scenario for a crash.

"If the MMC5 $5113 is swapping, and nothing has been written to the new page by the time it is swapped into $6000-$7FFF, then the game will crash."

If you swap in a blank 2000 byte page into $6000-$7FFF, the game will instantly crash. This is due to the massive amount of PRG-RAM that is going on to run the game. When you have nothing but 00's occupying $6000-$7FFF, then all of the PRG-RAM is gone, and when the game returns to wherever within $6000-$7FFF, the game will instantly crash.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: ETROM / 256k SRAM problems. Need advice

Post by lidnariq »

To make sure I understand: because LoZ1 is an FDS port, it copies data and code from PRG-ROM into PRG-RAM. If it tries to execute stuff in PRG-RAM before the MMC5 bankswitching duplication has happened, that will cause a crash.

So when does the duplication process happen? What would lead to this race condition where it tries to swap banks before the code has been correctly duplicated?

Does the program data/code in $6000-$7FFF (as opposed to the save game) ever change? (edit: listing the files in the FDS version insinuate the answer is no: only two images have a load chunk below $8000, and one of those looks like the save game initializer) Would Mbumstead's observation of "it crashing on the EWROM repro for the first six power cycles" be consistent with the hypothesis that: it doesn't change, and correctly seeding the RAM is all that's necessary to prevent crashes?

(Also, I assume when you write "2000 bytes" you meant "$2000 bytes"?)
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: ETROM / 256k SRAM problems. Need advice

Post by infidelity »

Yes the $6000-$7FFF is copied from ROM and stored to RAM, and certain values will get switched and altered, like level construction of the dungeons, palettes, various other values, like the HP power o links sword.

Idk the exact location of my sub routine, I'm away from my laptop. But I feel what your trying to ask is vearing off topic.
mr-volk
Posts: 18
Joined: Mon Oct 21, 2013 11:32 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by mr-volk »

I also made repro with 32KB and it have same problems with save-freezes.
Does anybody resolve it with real HW?
mr-volk
Posts: 18
Joined: Mon Oct 21, 2013 11:32 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by mr-volk »

Freezes between save selects becouse SRAM filled with FF (when it empty). I solder battery to sram, write 00 (and also sav file from emulator) - no freezes between selects. But when i power off and power on famicom - game dont boot. I read sram to save file. Save file in attach.
Attachments
Legend of Zelda_.zip
(6.36 KiB) Downloaded 290 times
philenotfound
Posts: 11
Joined: Sun Oct 16, 2016 1:03 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by philenotfound »

Have the same problem with an EWROM. Freezes in save select. After that it freezes everytime earlier (in the intro).
Still haven't figured it out yet.
infidelity
Posts: 490
Joined: Fri Mar 01, 2013 4:46 am

Re: ETROM / 256k SRAM problems. Need advice

Post by infidelity »

I think I solved the issue. Waiting for confirmation before I release a revision, that my adjustments work on real hw now.
philenotfound
Posts: 11
Joined: Sun Oct 16, 2016 1:03 pm

Re: ETROM / 256k SRAM problems. Need advice

Post by philenotfound »

Awesome, if you want I can also test it, I have a socketed board ready atm.
Post Reply