NovaSquirrel / Mesen-X

Mesen X is a cross-platform (Windows & Linux) NES/Famicom emulator built in C++ and C#. This fork is meant to gather development efforts from different forks. Deprecated; see https://github.com/SourMesen/Mesen2/
https://www.mesen.ca
GNU General Public License v3.0
161 stars 29 forks source link

[Bug] N163 Sound RAM initialisation does not follow RAM initialisation settings #145

Closed TakuikaNinja closed 1 year ago

TakuikaNinja commented 1 year ago

After discovering that "Erika to Satoru no Yume Bouken" uses uninitialised N163 Sound RAM as wavetable data, I have been testing the Sound RAM initialisation in various emulators. The test ROM I am using and the spreadsheet of the results can be found in this NESdev forum thread: https://forums.nesdev.org/viewtopic.php?t=24349 Mesen and Mesen-X appear to always initialise the Sound RAM with zeroes regardless of the option chosen as the RAM initialisation option. This is (of course) inaccurate to real hardware, and caused a massive headache when debugging the patch I was making for this game. I was only able to verify the patch because FCEUX correctly initialises the Sound RAM based on the RAM initialisation setting.

Current Mesen-X behaviour (RAM init = random values): n163_soundram_init_000

Correct behaviour (FCEUX, RAM init = random values): n163_soundram_init-0

negativeExponent commented 1 year ago

See if PR satisfies this requirement....

TakuikaNinja commented 1 year ago

Awesome, but it might be worth checking the games which use the Sound RAM as a crude form of WRAM or SRAM. (Battle Fleet, Famista '90, Kaijuu Monogatari, Mindseeker)

negativeExponent commented 1 year ago

it should not be necessary in this case, since audio ram init starts before Mesen-X' LoadBattery function, which treats _internalRAM as a battery save if battery flag is enabled.

update us if it indeed causes problems.

negativeExponent commented 1 year ago

ok i do see the issue now. if rom has battery and ram init is not zero, then this will be saved as "saved data" which is suppose to be not.

re-adjusted and sent PR, which is crude (im not well familiar with C++ and object thingies) and ugly but should still work. Basically leave ram initialized with 00 when battery flag is enabled, else reinit ram based on ram initialization settings.

@TakuikaNinja let us know if this works now

TakuikaNinja commented 1 year ago

I just made a save in both the current repo & latest stable versions at the earliest point I could in Kaijuu Monogatari. The save file data is identical. :+1: