Project

General

Profile

Emulator Issues #9840

Resident Evil 2, Resident Evil 3: Nemesis Audio Issues

Added by JMC4789 about 3 years ago. Updated about 1 month ago.

Status:
Accepted
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Current
Regression:
Yes
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
5.0-560
Fixed in:

Description

Game Name?

Resident Evil 2 - GHAE08
Resident Evil 3: Nemesis - GLEE08

MD5 Hash? (right click the game in the game list, properties, info tab, MD5 Hash: Compute)

Resident Evil 2 - ee2967ed8ccda671999a5151f2026723
Resident Evil 3 - 428abf23e4c06dbfcbd3cea2fa577385

What's the problem? Describe what went wrong.

In areas with multiple music tracks, the game's streaming audio system causes issues in Dolphin. We removed the ARAM-DMA hack because it was causing issues in other games, so now audio is broken. Note, this only affects areas with two or more music tracks; areas with a single music track (ambiance counts as a music track) there are no issues.

What steps will reproduce the problem?

The first area of Resident Evil 2: Leons story has fire and music, and thus is a perfect reproduction spot. The music will cut in and then overwrite itself and die. Then it'll do it again every 5 or 6 seconds.

If you copy and paste this into your browser you should be able to hear the issue first hand

https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/285685537%3Fsecret_token%3Ds-77Ym4

Which versions of Dolphin did you test on? Does using an older version of Dolphin solve your issue? If yes, which versions of Dolphin used to work?

Before 5.0-560 everything seems to work fine. That is the start of the regression, the removal of the ARAM-DMA hack.

What are your PC specifications? (CPU, GPU, Operating System, more)

Intel Core i5-3570K @ 3.4GHz
NVIDIA GeForce GTX 1070
Windows 10

Is there any other relevant information? (e.g. logs, screenshots,
configuration files)

Nope.

ARAM_interrupt_test.dol (119 KB) ARAM_interrupt_test.dol JMC4789, 01/25/2019 01:59 AM

Related issues

Has duplicate Emulator - Emulator Issues #9778: Resident Evil 2/3 Audio IssuesDuplicate

Has duplicate Emulator - Emulator Issues #10558: RE 3 Nemesis sounds cut bugDuplicate

History

#1 Updated by JosJuice about 3 years ago

#2 Updated by JosJuice about 3 years ago

  • Milestone set to Current

#3 Updated by JMC4789 almost 3 years ago

  • Status changed from New to Accepted

#4 Updated by JosJuice about 2 years ago

#5 Updated by Chopin almost 2 years ago

It's been quite a few years since the games Resident Evil 2/3 bug at the sound level.
Can we hope for the resolution of the problem soon?
Because since Dolphin manages the Wii I feel that the GameCube is a little left out ...

#6 Updated by Helios almost 2 years ago

It's a blocker so we can't release another stable until the blocker status is either removed or it's fixed.

Beyond that, Dolphin is an unpaid OSS project so nobody can be forced to work on anything they don't feel like.

#7 Updated by Chopin almost 2 years ago

I understand that Dolphin is free and developers are not paid. Besides, I love Dolphin and I thank the developers of all hearts but I just note that despite the frequent updates, the GameCube seems to be abandoned and I find it a shame.

Especially on a very old version, this bug was fixed I conclude that the solution is not very far ...

#8 Updated by Helios almost 2 years ago

GC isn't abandoned. This is just a bug nobody feels like looking into right now.

The Wii and GC are mostly the same hardware as far as the user is concerned. Most "Wii" fixes are applicable to GC games as well.

And if you think we focus more on Wii, don't look at our emulated wiimote code that has sat for years ;)

#9 Updated by Chopin almost 2 years ago

Oki oki, I want to believe you. It's just the impression I got.

I cross my fingers so that it unlocks quickly because I love RE 2/3 on GC :)

#10 Updated by JMC4789 almost 2 years ago

The reason why this no longer works is because it never actually worked correctly. We removed a hack (that was breaking other games...) in hopes that the correct behavior would be found eventually. We're fairly certain what the cause is, but, there may not be an easy way to implement that without destroying performance.

#11 Updated by Chopin almost 2 years ago

Ok, why not set up a manually activated hack? I know it's a case by case but we would have at least one solution until the problem is really fixed.

#12 Updated by niccop over 1 year ago

This will be fixed in Dolphin 6.0?

#13 Updated by Chopin over 1 year ago

Do not dream :)

For my trip, it's been a long time since I believe in it anymore

#14 Updated by niccop over 1 year ago

:( this is bad.

#15 Updated by JMC4789 over 1 year ago

A per-game hack will have to be added for this, but, my attempt to add it back in failed because some of the functionality used only for the hack was removed later on.

Someone with remedial coding knowledge could re-add the hack though.

#16 Updated by niccop over 1 year ago

So apparently it's a difficult problem to solve, that's sad. Anyway, we can only wait. :/

#17 Updated by Nucleoprotein over 1 year ago

Hello,

Apparently 1 line fixes this:

  GenerateDSPInterrupt(INT_ARAM);

in Do_ARAM_DMA() just after s_dspState.DMAState = 1;

Maybe real hardware do interrupt at start and end of ARAM DMA transfer (or when DMAState changes 1 -> 0 or 0 -> 1)?
Dunno what above fix breaks ...

#18 Updated by wesleyspipes over 1 year ago

Nucleoprotein wrote:

Hello,

Apparently 1 line fixes this:

  GenerateDSPInterrupt(INT_ARAM);

in Do_ARAM_DMA() just after s_dspState.DMAState = 1;

Maybe real hardware do interrupt at start and end of ARAM DMA transfer (or when DMAState changes 1 -> 0 or 0 -> 1)?
Dunno what above fix breaks ...

What are the next steps to possibly incorporating this? Can you provide a test build? Maybe start off making this a per game hack for now?

#19 Updated by Lyle.Tafoya 11 months ago

Nucleoprotein wrote:

Hello,

Apparently 1 line fixes this:

  GenerateDSPInterrupt(INT_ARAM);

in Do_ARAM_DMA() just after s_dspState.DMAState = 1;

Maybe real hardware do interrupt at start and end of ARAM DMA transfer (or when DMAState changes 1 -> 0 or 0 -> 1)?
Dunno what above fix breaks ...

I just compiled dolphin from source with this change applied to DSP.cpp and now the music in Resident Evil 2 works correctly. Are there any negative implications to this patch? What does the Dolphin team require for this to get merged in? Has anyone submitted a formal pull request?

#20 Updated by JMC4789 11 months ago

We decided to make a hardware test to check this change.

This hack is 100% wrong, and not a real fix. Sorry. The interrupt is confirmed to fire at the end.

I've uploaded the test in case you want to confirm. On console, 99.99999999998553% of the xfer has happened by the time the interrupt fires.

Master vs Dolphin times - total xfer time for hw: 6607823, dolphin: 6722226. Meanwhile with the hack, it ends up 0.02% of the transfer time.

Credit to Booto for writing the test!

#21 Updated by SilandaUK 10 months ago

Lyle.Tafoya wrote:

Nucleoprotein wrote:

Hello,

Apparently 1 line fixes this:

  GenerateDSPInterrupt(INT_ARAM);

in Do_ARAM_DMA() just after s_dspState.DMAState = 1;

Maybe real hardware do interrupt at start and end of ARAM DMA transfer (or when DMAState changes 1 -> 0 or 0 -> 1)?
Dunno what above fix breaks ...

I just compiled dolphin from source with this change applied to DSP.cpp and now the music in Resident Evil 2 works correctly. Are there any negative implications to this patch? What does the Dolphin team require for this to get merged in? Has anyone submitted a formal pull request?

It's worth being aware that although the hack works fine for Resident Evil 2+3, it can break other games. P.N.03 being one. I added the hack to my builds as a config file option which defaults to off because of this.

#22 Updated by JMC4789 10 months ago

Or we could put our efforts together to try to fix this in a way that doesn't require any hacks...

Even a game-patch would be better at this point.

#23 Updated by phire 8 months ago

The interesting thing is just how instant the interrupt has to be.

According to JMC4789's tests: Anything 13 cycles or less works. Anything longer than 13 cycles is broken.

I've been doing some de-compiling of RE2 and it looks like the only thing that happens within approximately 13 cycles of triggering the DMA copy is re-enabling interrupts (the sdk DMA's code disables interrupts while it's setting up the DMA transfer).

One theory is that dolphin has a bug which causes DMA interrupts that are scheduled while interrupts are disabled to be delayed for a very long time, which means the instant dma hack actually delays the interrupt timing.

Another theory is that a previous dolphin bug has corrupted a game data structure somewhere, and the early interrupt is somehow 'uncorrupting' the data structure.

More testing is required.

#24 Updated by phire 8 months ago

Nope, it turns out skid_au was right. It is dcache related.

There is a bug in the routine the game uses to upload the music to ARAM.

It reads the music off the disk in 40KB chunks, and then uses an SDK function which DMAs it to ARAM in 4KB chunks.

But it never waits for the ARAM DMA to finish before it starts reading the next 40KB chunk to the same buffer in memory. This shouldn't really be an issue, ARAM dma is much faster than the DVD drive and should complete long before the DI DMA overwrites it.

However, the game developer decided to memset the 40KB buffer before calling DVDRead(). Who knows why the developer decided to do this, it will be overwritten anyway.

why is dolphin broken?
Because dolphin receives the first ARAM DMA request, copies 1000 bytes into ARAM. But the game wipes the buffer (or at least the first 2000 bytes) before second ARAM dma request comes (its the ARAM DMA interrupt handler which initiates the next DMA transfer)

Why does the instant ARAM dma hack fix it?
Because dolphin now completes all 10 ARAM DMA copies before the game can memset the buffer.

Why does this work on hardware?
Because the SDK's DVDRead function calls dcacheInvalidate on the buffer before sending off the DVD request. The buffer is only 40KB, so it's more or less guaranteed to still be in L2 cache, even though the dcacheInvalidate doesn't immediately follow the memset call.

Because the buffer is invalided, the memset buffer never makes it to main ram. ARAM DMA reads out of main ram and completes long before the DVD read completes.

#25 Updated by phire 8 months ago

Here is a patch for GHAE08:

I only expect it to work for Leon's Story and it might fail depending on how you navigate thorugh the menu before selecting Leon's story

[OnFrame_Enabled]
$fix dcache issue
[OnFrame]
$fix dcache issue
0x8055ACBC:dword:0x7C000378

#26 Updated by shatteredlites 8 months ago

phire wrote:

Here is a patch for GHAE08:

I only expect it to work for Leon's Story and it might fail depending on how you navigate thorugh the menu before selecting Leon's story

[OnFrame_Enabled]
$fix dcache issue
[OnFrame]
$fix dcache issue
0x8055ACBC:dword:0x7C000378

yep only leons story, didn't try very much just made sure the opening area played. Claire on the other hand still breaks

#27 Updated by Nucleoprotein 8 months ago

Thanks phire for explaining problem.
As dcache emulation I think will not happen soon (or never?), we can expect any hack/game patch to be implemented in official builds?

#28 Updated by Murgatroide 7 months ago

Nucleoprotein wrote:

Thanks phire for explaining problem.
As dcache emulation I think will not happen soon (or never?), we can expect any hack/game patch to be implemented in official builds?

phire wrote:

Here is a patch for GHAE08:

I only expect it to work for Leon's Story and it might fail depending on how you navigate thorugh the menu before selecting Leon's story

[OnFrame_Enabled]
$fix dcache issue
[OnFrame]
$fix dcache issue
0x8055ACBC:dword:0x7C00

shatteredlites wrote:

phire wrote:

Here is a patch for GHAE08:

I only expect it to work for Leon's Story and it might fail depending on how you navigate thorugh the menu before selecting Leon's story

[OnFrame_Enabled]
$fix dcache issue
[OnFrame]
$fix dcache issue
0x8055ACBC:dword:0x7C000378

yep only leons story, didn't try very much just made sure the opening area played. Claire on the other hand still breaks

excuse me, would somebody be so kind to tell me how and where i have to use the patch before mentioned.

#29 Updated by Chopin about 1 month ago

And for the European version (GHAP08) ?

Also available in: Atom PDF