Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

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

Closed
TakuikaNinja opened this issue Jan 10, 2023 · 5 comments · Fixed by #146
Closed

Comments

@TakuikaNinja
Copy link

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
Copy link

negativeExponent commented Jan 10, 2023

See if PR satisfies this requirement....

@TakuikaNinja
Copy link
Author

TakuikaNinja commented Jan 10, 2023

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
Copy link

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
Copy link

negativeExponent commented Jan 12, 2023

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
Copy link
Author

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. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants