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

DSPHLE: Add HLE version of libaesnd ucode #10793

Merged
merged 3 commits into from Jul 25, 2022

Conversation

Pokechu22
Copy link
Contributor

This PR adds an HLE version of the libaesnd ucode, which is used by newer homebrew (particularly homebrew with MOD music).

The libaesnd is a more advanced compared to the libasnd ucode, in that it uses more DSP features (in particular the stack registers, the wrapping registers, the accelerator, and extended instructions), but the actual ucode is organized in a cleaner way so this was easier to port. (That's not to say libasnd isn't impressive in its own way; it was developed when fewer DSP features were understood, and the tooling had to be developed with it.)

I've done limited testing with the modplay example included with libogc, and with the Harmony's Nightmare homebrew (which is somewhat weird, but it does feature both sound effects and music). Note that the latter behaves a bit weirdly (missing intro screen and phases of levels, and weird graphics) when started directly by Dolphin, but behaves fine if started by the (open) homebrew channel (even with wiiload).

I've implemented 3 versions, corresponding to 3 libogc releases. I've only tested the 2012 and 2020 versions, as I couldn't easily find any homebrew using the 2010 version. The history indicates a few other versions (including a mismatch between the binary and source in the repo), but they wouldn't have been present in a released version of libogc. See aesnd_ucode_versions.zip for a complete list of these.

Hashes of various possible versions for search purposes
Hashes of 1/dspmixer.bin: ector bd3a2733 crc 9d7d4b76 adler 44112f23 fletcher 66095ee4; 0400 bytes (0200 words)
Hashes of 1/dspmixer_nopad.bin: ector ef4e89cc crc bfd946f3 adler 36d32f23 fletcher 52395ee4; 03ea bytes (01f5 words)
Hashes of 1/compiled_pad.bin: ector bd3a6a67 crc ad983947 adler 9b152f92 fletcher 91aa9d15; 0400 bytes (0200 words)
Hashes of 1/compiled.bin: ector ef4e9a99 crc f868ced7 adler 844d2f92 fletcher d1bc9d15; 03ea bytes (01f5 words)
Hashes of 1/edited_pad.bin: ector bd3a2733 crc 9d7d4b76 adler 44112f23 fletcher 66095ee4; 0400 bytes (0200 words)
Hashes of 1/edited.bin: ector ef4e89cc crc bfd946f3 adler 36d32f23 fletcher 52395ee4; 03ea bytes (01f5 words)
Hashes of 2/dspmixer.bin: ector 4d99d39f crc 7b91d451 adler 64bf2c83 fletcher 3c8f148c; 03e0 bytes (01f0 words)
Hashes of 2/dspmixer_nopad.bin: ector 39f4d99d crc b306bb25 adler b2a42c83 fletcher 1377148c; 03dc bytes (01ee words)
Hashes of 2/compiled.bin: ector 39f4d99d crc b306bb25 adler b2a42c83 fletcher 1377148c; 03dc bytes (01ee words)
Hashes of 2/compiled_pad.bin: ector 4d99d39f crc 7b91d451 adler 64bf2c83 fletcher 3c8f148c; 03e0 bytes (01f0 words)
Hashes of 3/dspmixer.bin: ector 30528f51 crc 4a2cba80 adler 93d92366 fletcher a832c6b3; 03e0 bytes (01f0 words)
Hashes of 3/dspmixer_nopad.bin: ector 14a3d44c crc a5ca57bb adler 6da92366 fletcher 03aac6b3; 03c2 bytes (01e1 words)
Hashes of 3/compiled.bin: ector 14a3d44c crc a5ca57bb adler 6da92366 fletcher 03aac6b3; 03c2 bytes (01e1 words)
Hashes of 3/compiled_pad.bin: ector 30528f51 crc 4a2cba80 adler 93d92366 fletcher a832c6b3; 03e0 bytes (01f0 words)
Hashes of 4/compiled.bin: ector 0d9abc02 crc c098bab0 adler 7ea72781 fletcher 310099ff; 03ce bytes (01e7 words)
Hashes of 4/compiled_pad.bin: ector 008366af crc 4672b531 adler 45e62781 fletcher 9afc99ff; 03e0 bytes (01f0 words)
Hashes of 4/dspmixer.bin: ector 008366af crc 4672b531 adler 45e62781 fletcher 9afc99ff; 03e0 bytes (01f0 words)
Hashes of 4/dspmixer_nopad.bin: ector 0d9abc02 crc c098bab0 adler 7ea72781 fletcher 310099ff; 03ce bytes (01e7 words)
Hashes of 5/dspmixer.bin: ector 078066ab crc 5c7642c3 adler a18027bd fletcher 11a0d7fd; 03e0 bytes (01f0 words)
Hashes of 5/dspmixer_nopad.bin: ector 019aac1e crc 9dd06cef adler d60927bd fletcher 79b3d7fd; 03ce bytes (01e7 words)
Hashes of 5/compiled.bin: ector 019aac1e crc 9dd06cef adler d60927bd fletcher 79b3d7fd; 03ce bytes (01e7 words)
Hashes of 5/compiled_pad.bin: ector 078066ab crc 5c7642c3 adler a18027bd fletcher 11a0d7fd; 03e0 bytes (01f0 words)
Hashes of 6/compiled.bin: ector 84c680a9 crc 1b1beb1d adler 2d952c7f fletcher 24058e0e; 03e6 bytes (01f3 words)
Hashes of 6/compiled_pad.bin: ector a02a6131 crc a0872f31 adler b2b72c7f fletcher 5ac28e0e; 0400 bytes (0200 words)

This PR also includes some minor cleanup for #10763.

@Adamillo
Copy link

Adamillo commented Jun 29, 2022

Since this PR and the other PR covers libasnd and libaesnd, does that mean that the error where it tells you to use DSP LLE can be removed? Or are there still some homebrews which have weird exceptions where DSP HLE doesn't work and the error still displays?

@Pokechu22
Copy link
Contributor Author

I assume you're referring to these messages:

imageimage

Due to how DSPHLE works, they're still needed. We attempt to match the uCode to use based on the hash of the code the game sends, but if the game sends code we don't recognize, that error appears. Games (and particularly homebrew) can send anything they want. For official games, this might just be a version of the uCode we don't recognize (see e.g. #10686 where a demo version of a game used a different uCode version). We need to do something in that case, and an error message is the best solution.

For homebrew specifically, there are two cases I know of where unknown uCode will be used. The first is homebrew that uses the DSP for obfuscation (devolution does this, though it doesn't boot far enough in Dolphin to see it) - this is specific to the homebrew in question and would be a lot of work to HLE (for no real benefit). The second is DSPSpy, which is used to send completely arbitrary uCode to the DSP to test features of the DSP; since it's for testing it also doesn't make sense to HLE it.

That said, the message itself won't show up for homebrew using libasnd or libaesnd now (at least for normal versions of it). It probably would make sense to make the message be more direct: "This title is incompatible with DSP HLE. Use DSP LLE for proper emulation." There shouldn't be any more cases where this triggers on official games, and the fallback of treating it as AX uCode doesn't work right for homebrew (or official games that use an unknown version of the zelda uCode, as was the case for the Pikmin demo).

@Adamillo
Copy link

I see, so that error message won't appear as often and is still needed in some rare cases, got it

@JMC47
Copy link
Contributor

JMC47 commented Jul 17, 2022

Is this more or less done now?

@Pokechu22
Copy link
Contributor Author

Yes, just waiting on a review.

@Adamillo
Copy link

Can someone review this if they can?

Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me from a coding style point of view. I can't assess the audio part and its behaviour. I tested this PR with modplay and wii-tac-toe.

However, I haven't tested this PR with EDuke32 which uses a libaesnd's mod from tueidj.

Regardless, LGTM.

@JMC47 JMC47 merged commit bfd03cd into dolphin-emu:master Jul 25, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants