Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to Zelda-HLE to allow multiple GBA connections #5376

Merged
merged 2 commits into from May 13, 2017

Conversation

ligfx
Copy link
Contributor

@ligfx ligfx commented May 5, 2017

RFC because I have really no idea what I'm doing with DSP code, and found this fix through a combination of scattered printfs and a small dose of "well, it looks right."

This fixes two bugs when running The Legend of Zelda: Four Swords Adventures with DSP-HLE:

  • Background music and some sounds stop working after connecting a GBA.
  • Only one GBA can be connected at a time.

screen shot 2017-05-05 at 2 54 41 am

I first noticed that Four Swords' background music cuts out after connecting a GBA, and Dolphin logs the following error messages:

55:50:162 Core/HW/DSPHLE/UCodes/Zelda.cpp:212 N[DSPHLE]: UCode being replaced.
55:50:163 Core/HW/DSPHLE/UCodes/UCodes.cpp:211 W[DSPHLE]: Trying to boot new ucode with DRAM download - not implemented
55:50:163 Core/HW/DSPHLE/UCodes/UCodes.cpp:247 I[DSPHLE]: Switching to GBA ucode
55:50:174 Core/HW/DSPHLE/UCodes/UCodes.cpp:215 W[DSPHLE]: Trying to boot new ucode with DRAM upload - not implemented
55:58:077 Core/HW/DSPHLE/UCodes/Zelda.cpp:230 N[DSPHLE]: Unknown end rendering action. Halting.
55:58:077 Core/HW/DSPHLE/UCodes/Zelda.cpp:232 N[DSPHLE]: UCode asked to halt. Stopping any processing.
55:58:077 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 807ed6c0 while we're halted.
55:58:077 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 807edb20 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00000000 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 0000d400 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00000000 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00010000 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00000000 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00020000 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00000000 while we're halted.
55:58:078 Core/HW/DSPHLE/UCodes/Zelda.cpp:294 W[DSPHLE]: Received mail 00030000 while we're halted.

The Zelda ucode gets only momentarily swapped out for the GBA one, but then stops replying to all mail! That probably shouldn't be happening.

I added some printf statements, and got the list of all mail sent to the Zelda ucode after it's swapped back in:

00000003 // looks like it will write 3 commands
82074000 // looks like a command
807ed6c0 // looks like a command
807edb20 // looks like a command
00000000
0000d400
00000000
00010000
00000000
00020000
00000000
00030000

The first few messages look like a three-command-write, which is only valid in MailState::WAITING, so I changed Zelda-HLE to set itself to that when swapping. That made the first few messages be accepted, but then a new error appeared:

00:44:526 Core/HW/DSPHLE/UCodes/Zelda.cpp:245 N[DSPHLE]: Sync mail (00000000) received when rendering was not active. Halting.

I was stumped here, so starting looking through the larger stream of messages Four Swords' was sending to the DSP. Every hundred messages or so, a pattern seemed to repeat itself:

cdd10003
00000003
82074000
807ee840
807eeca0
00000000

This is practically identical to the messages when a GBA is connected, except that the trigger to switch to GBA-HLE is cdd10001. Running the logic for cdd10003—which runs pending commands—before switching to GBA-HLE fixes all of the remaining errors.

ligfx added 2 commits May 5, 2017 02:24
Part 1/2 of a fix for using multiple GBAs in Four Swords Adventures.
Part 2/2 of a fix for using multiple GBAs in Four Swords Adventures.
@JMC47
Copy link
Contributor

JMC47 commented May 5, 2017

@delroth this may be one you want to review.

@endrift
Copy link
Contributor

endrift commented May 5, 2017

oh hey I wonder if this is why that was buggy in orca. Not a problem on my end!

@lioncash lioncash added the RFC Request for comments label May 5, 2017
@ligfx
Copy link
Contributor Author

ligfx commented May 6, 2017

Potentially also fixes https://bugs.dolphin-emu.org/issues/7294 , which sounds like the same issue with background music. Would someone with MegaMan X: Command Mission mind testing this out (cough@JMC47cough)?

@shuffle2 shuffle2 requested a review from delroth May 9, 2017 20:05
@shuffle2
Copy link
Contributor

shuffle2 commented May 9, 2017

Seems OK to me

@JMC47
Copy link
Contributor

JMC47 commented May 13, 2017

I tested Mega Man X: Command Mission and couldn't get the audio to cutout.

Also allows Final Fantasy: Crystal Chronicles to connect multiple GBAs without any issues with HLE audio.

@MayImilae
Copy link
Contributor

@delroth Do you want to review this?

@shuffle2 shuffle2 merged commit 67d640b into dolphin-emu:master May 13, 2017
@ligfx ligfx deleted the fixfourswordshle branch May 24, 2017 21:47
@ligfx ligfx changed the title [RFC] Tweaks to Zelda-HLE to allow multiple GBA connections Tweaks to Zelda-HLE to allow multiple GBA connections Jun 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for comments
6 participants