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

AX: Implement loop_counter and support UCodes without LPF #5211

Merged
merged 3 commits into from Apr 8, 2017

Conversation

merryhime
Copy link
Contributor

@merryhime merryhime commented Apr 6, 2017

Uses constexpr if and hence requires C++17. This approach is possible without constexpr if but would be much uglier.

I decided to replace the preprocessor AX_GC and AX_WII defines with a configuration template parameter. This allowed for further variants in AX functionality to be supported via constexpr if.

While one can now semi-trivially remove the need for the global variables in AXVoice.h after this change, I've decided to leave that to another PR.

(P.S.: delroth did all the hard work, this just implements the fix.)

Edit: Now uses copies for layout differences.

@merryhime
Copy link
Contributor Author

merryhime commented Apr 6, 2017

  • Requires at least cmake 3.8-rc4 for C++17 support.
  • Ugly formatting due to clang-format's lack of support for constexpr if: LLVM Bug.

@BhaaLseN
Copy link
Member

BhaaLseN commented Apr 6, 2017

MSVC doesn't support if constexpr, not even with VS 2017 :(

Other than that, why do you need a dedicated NoLpf PB struct? Unless I missed something, the only difference is the lpf member (and hence the different padding size); which you could just ignore in the NoLpf case on GC (unless this triggers an unused member warning due to being removed by the if constexpr)

@merryhime
Copy link
Contributor Author

@BhaaLseN The existence of the lpf member moves the location/offset of loop_counter.

@BhaaLseN
Copy link
Member

BhaaLseN commented Apr 6, 2017

Ah, duh. Forgot about that. Nvm then.

@JMC47
Copy link
Contributor

JMC47 commented Apr 7, 2017

So, with MS not supporting that (yet), what's going to happen to this?

@merryhime
Copy link
Contributor Author

My plan was to wait until C++17 is a thing in Dolphin and for MSVC if constexpr support.

@BhaaLseN
Copy link
Member

BhaaLseN commented Apr 7, 2017

Looking at this again, isn't this the reason why we have to care about the struct layout (and potentially create duplicates)?
I could imagine an alternate solution where the members are swapped/copied by hand, using the correct offsets for the given AX variant...not sure if this is something we want to consider though.

@delroth
Copy link
Member

delroth commented Apr 7, 2017

@BhaaLseN that's what I ended up doing for Zelda HLE, see https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp#L885

I'm not against doing the same thing for AX.

@shuffle2
Copy link
Contributor

shuffle2 commented Apr 7, 2017

can't you just use unions for this (instead of the #ifdef stuff)?

Required for Rogue Squadron.
@merryhime
Copy link
Contributor Author

Updated to use copies for the alternate layout.

@merryhime merryhime changed the title [RFC] AX: Implement loop_counter and support UCodes without LPF AX: Implement loop_counter and support UCodes without LPF Apr 8, 2017
{
switch (crc)
{
case 0x4e8a8b21:

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@@ -253,8 +253,9 @@ struct AXPB
PBSampleRateConverter src;
PBADPCMLoopInfo adpcm_loop_info;
PBLowPassFilter lpf;

This comment was marked as off-topic.

This comment was marked as off-topic.

@JMC47
Copy link
Contributor

JMC47 commented Apr 8, 2017

LGTM. I completed the first three missions of RS2 (reported to crash with the hack in Ishiiruka) and they seem to be working fine here. Rogue Squadron 3 isn't working well in Dolphin right now, but, in the parts of the game I got to it also works.

As a bonus, it appears that Pac-Man World Rally is fixed. The audio now seems to be roughly the same as LLE. Instead of having some sounds super loud, and some super quiet, they all now play fairly loud, but can be adjusted in the options. The game appears louder than most on console as well.

@@ -81,17 +81,50 @@ union AXBuffers
};

// Read a PB from MRAM/ARAM
void ReadPB(u32 addr, PB_TYPE& pb)
void ReadPB(u32 addr, PB_TYPE& pb, bool has_lpf = true)

This comment was marked as off-topic.

{
case 0x4e8a8b21:
return false;
default:

This comment was marked as off-topic.

Copy link
Member

@delroth delroth left a comment

Choose a reason for hiding this comment

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

Overall LGTM, thanks a lot.

Copy link
Member

@BhaaLseN BhaaLseN left a comment

Choose a reason for hiding this comment

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

Theres also

// TODO: find other UCode versions with different mixer_control values
referencing the magic CRC. Is that mixer control thingy related to LPF, or is that something different?

@@ -80,18 +80,63 @@ union AXBuffers
#endif
};

// Determines if this version of the UCode has a PBLowPassFilter in its AXPB layout.
bool HasLpf(u32 crc)

This comment was marked as off-topic.

This comment was marked as off-topic.

@delroth
Copy link
Member

delroth commented Apr 8, 2017

I'm fine with merging this now because even if other UCode versions have the same weirdness, it should only impact LPF emulation which is presently disabled due to other issues. I think it's a good compromise.

@delroth delroth merged commit e863604 into dolphin-emu:master Apr 8, 2017
@merryhime merryhime deleted the ax branch April 8, 2017 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants