User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Neon64 with Savestates

Fri Dec 23, 2016 8:46 am

Hi,
I made a small hack which adds savestate functionality to the Neon64 NES emulator.
The states are not permanent and the expansion pak is mandatory. The code should be back up device independent. Testet on the 64drive and in CEN64.

The functionality can be accessed by the R+L Menu.

Happy cheating :)

[Update]
Features of 0.3b mod compared to original 1.2b:
- Temporary save state in Expansion Pak memory
- Persistent save state in N64 SRAM
- NES SRAM to N64 SRAM redirection (saving to Memory Pak can still be used)
- Screenshot functionality (64drive USB)
- Dither filter disabled
Requirements:
- Expansion Pak
- Dezaemon 3D SRAM (emulation)
Attachments
neon64-v3b-src.rar
(71.34 KiB) Downloaded 89 times
neon64-v3b-bin.rar
(20.5 KiB) Downloaded 104 times
neon64-capture-util.rar
(887 Bytes) Downloaded 89 times
Last edited by Visor on Sat Jan 21, 2017 5:13 pm, edited 1 time in total.

User avatar
marshallh
Site Admin
Posts: 104
Joined: Fri Jun 13, 2014 12:39 am

Re: Neon64 with Savestates

Thu Dec 29, 2016 9:23 pm

Great work, I'll test soon.
Another thing that might be useful is to move the saving from Controller PAK sram to the Save SRAM (at 0x0800 0000). It is a lot easier to use than banging on SI which is necessary for the controller pak.
If that works I can edit the menu to support per-game save files for the emulator.

User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Re: Neon64 with Savestates

Sun Jan 01, 2017 11:09 am

Hi marshallh, that would of course be amazing since I also would not have to consider anymore how to implement FAT32 support with reasonable effort in U64ASM. My current built uses the Dezaemon 3D SRAM variant. Chip1 for the NES-SRAM and chip2+3 for the experimental save state functionality. If you consider the later unnecessary this design also works with the common 256K SRAM variant, than without persistent save states. I will probably upload a new build with SRAM saving tomorrow.

User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Re: Neon64 with Savestates

Mon Jan 02, 2017 2:28 am

New features in version 0.2
- NES-SRAM to N64-SRAM redirection
- Temporary save states basic error handling
- Permanent save states in N64-SRAM (BETA)

Until the Dezaemon 3D SRAM handling for the emulator is activated in the 64drive menu the new features will only work via USB or via an appended ROM file and manual SRAM activation. It would be amazing if you could enable SRAM emulation when you start the emulator marshallh :-)

The permanent save state feature is unfinished and does currently not save the sprites. So you will see a lot of garbage on the screen. Will hopefully be fixed in an upcoming version.

More detailed information on the new features:
https://themanbehindcurtain.blogspot.de ... ction.html
(If linking to external information is forbidden, feel free to delete the link)
Last edited by Visor on Sat Jan 21, 2017 5:11 pm, edited 1 time in total.

User avatar
marshallh
Site Admin
Posts: 104
Joined: Fri Jun 13, 2014 12:39 am

Re: Neon64 with Savestates

Mon Jan 02, 2017 2:44 pm

Added to new test version: http://64drive.retroactive.be/menu.bin

Seems to work, I tested with Kirby. When the NES > 64 SRAM is selected, it triggers a save writeback as expected, and reloads on the next boot from menu.

I have noticed a few audio bugs, mostly when starting Kirby (I haven't tested others) I have no sound, then if I bring up the L+R menu I hear an increasingly loud broken screech, then Kirby music plays when I unpause.

Also a suggestion: for some reason Neon64 by default has the VI dither filter turned on. This could not only free up ram bandwidth but also make things look less splotchy.

Code: Select all

To disable dither filter in VI control reg: Before ; Control la t1, 0x00013002 ; 16 bit/pixel sw t1, 0(t0) After ; Control la t1, 0x00003002 ; 16 bit/pixel sw t1, 0(t0) Just zero the 16th bit. You will also need to fix this in the separate PAL video init. (inits.inc)

User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Re: Neon64 with Savestates

Tue Jan 03, 2017 4:52 am

Added to new test version: http://64drive.retroactive.be/menu.bin

Seems to work, I tested with Kirby. When the NES > 64 SRAM is selected, it triggers a save writeback as expected, and reloads on the next boot from menu.
Thank you for the super-fast implementation into the menu!
I have noticed a few audio bugs, mostly when starting Kirby (I haven't tested others) I have no sound, then if I bring up the L+R menu I hear an increasingly loud broken screech, then Kirby music plays when I unpause.
I tested three different Kirby roms and can sadly not reproduce the lack of sound after initialization, strange. Maybe a bad rom or one of the non-deterministic bugs hcs mentions in his notes. Sometimes the emulator does not load the rom at all for me, but very rare case. The loud screech/crackle happens on a lot of roms. Not sure what causes it. Might look into it, but the pre calculated hex tables for sound in atables.inc have zero comments so no promises.
Also a suggestion: for some reason Neon64 by default has the VI dither filter turned on. This could not only free up ram bandwidth but also make things look less splotchy.
Thanks again, I added the change to NTSC and PAL mode. Even so I see zero difference on my tiny debugging TV, with my bad eyes. Your dog with the four asian girls and two blue cups still looks sharper ;)

New features in version 0.3
- RSP backup code
- SRAM savestate errorhandling
- NES Graphics Compiler Cache invalidation
- disable dither filter (thx marshallh)
- small fixes

Detailed changelog will follow later. Will be the last fast update for the time being due to work. Thanks to the added RSP backup and cache invalidation the permanent savestates fully work in Super Mario Bros. 1 and 3. In other games loading, killing yourself once and loading again can restore the cache. This works e.g. in Super Mario Bros. 2, Contra, Kirby, Metroid and Megamen. The emulator is obviously not designed to get its entire pattern table cache deleted between two frames. So the results will vary depending on the game. But the described strategy should work for most games.

Resetting back to 64drive menu would also be nice via L+R menu, but since the N64 seems to support no software triggered reset according to the NMI docs this seems not feasible to realize for now.

User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Re: Neon64 with Savestates

Sat Jan 21, 2017 5:14 pm

Updated the first post with most recent version.
Permanent save state now works for most games without palette or pattern glitches.
Also ported the v64 jr screenshot feature to 64drive. Framebuffer can be dumped over USB and converted with the attached python script.

User avatar
hcs
Posts: 1
Joined: Fri Mar 24, 2017 11:19 pm

Re: Neon64 with Savestates

Sat May 06, 2017 10:10 am

Thank you very much for your improvements, particularly save states! I'm impressed that you could make sense of my "outsider art".

User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Re: Neon64 with Savestates

Wed May 10, 2017 3:30 pm

Thank you very much for your improvements, particularly save states! I'm impressed that you could make sense of my "outsider art".
No problem was definitely fun working on your code. The development log and code comments were very helpful. I thought about implementing cheats/game genie codes, but editing the save state files seems sufficient for now. Also if the 64drive gets cheat support the NES codes can probably be converted to N64 codes.

User avatar
Visor
Posts: 9
Joined: Mon Dec 05, 2016 5:45 pm
Contact: Website

Re: Neon64 with Savestates

Fri Dec 29, 2017 3:12 am

I have noticed a few audio bugs, ... if I bring up the L+R menu I hear an increasingly loud broken screech, then Kirby music plays when I unpause.
I finally got my UltraHDMI and can now reproduce the high frequency "loud broken screech" in the L+R menu. It happens roughly 50% of the time if you enter the L+R menu. The thing is this only happens over HDMI audio and is not present on the RCA Audio.

I debugged it down to the audio smoothness function of Neon64. Neon64 fills the audio buffer with the same byte, which creates silence over RCA, but a constant sound over the UltraHDMI Audio.

As a small workaround I am now clearing the audio buffer every time the L+R menu is entered, which creates a short "plop" sound, but no more constant sound. The small fix is attached to this post as version 0.3c.
In short, if you are using RCA audio stay with 0.3b for audio smoothness and if you want to use HDMI audio try version 0.3c.

As a full fix, the libdragon audio pause silence interrupt handler could be ported to Neon64 or the UltraHDMI audio could maybe behave similar to the RCA audio.
Attachments
neon64-v3c-src.rar
(71.16 KiB) Downloaded 25 times
neon64-v3c-bin.rar
(20.51 KiB) Downloaded 26 times

Return to “General”