mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 15:01:16 +01:00
Merge pull request #10898 from Pokechu22/dsp-hle-homebrew-padding
DSPHLE: Support padded versions of libasnd and libaesnd uCodes
This commit is contained in:
commit
2a56113a5b
@ -70,12 +70,14 @@ constexpr u32 ACCELERATOR_GAIN_16_BIT = 0x0800;
|
||||
|
||||
bool AESndUCode::SwapLeftRight() const
|
||||
{
|
||||
return m_crc == HASH_2012 || m_crc == HASH_EDUKE32 || m_crc == HASH_2020;
|
||||
return m_crc == HASH_2012 || m_crc == HASH_EDUKE32 || m_crc == HASH_2020 ||
|
||||
m_crc == HASH_2020_PAD || m_crc == HASH_2022_PAD;
|
||||
}
|
||||
|
||||
bool AESndUCode::UseNewFlagMasks() const
|
||||
{
|
||||
return m_crc == HASH_EDUKE32 || m_crc == HASH_2020;
|
||||
return m_crc == HASH_EDUKE32 || m_crc == HASH_2020 || m_crc == HASH_2020_PAD ||
|
||||
m_crc == HASH_2022_PAD;
|
||||
}
|
||||
|
||||
AESndUCode::AESndUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
|
||||
@ -161,7 +163,7 @@ void AESndUCode::HandleMail(u32 mail)
|
||||
break;
|
||||
case MAIL_TERMINATE:
|
||||
INFO_LOG_FMT(DSPHLE, "AESndUCode - MAIL_TERMINATE: {:08x}", mail);
|
||||
if (true) // currently no mainline libogc uCode has this issue fixed
|
||||
if (m_crc != HASH_2022_PAD)
|
||||
{
|
||||
// The relevant code looks like this:
|
||||
//
|
||||
|
@ -39,6 +39,16 @@ public:
|
||||
// First included with libogc 2.1.0 on June 15, 2020: https://devkitpro.org/viewtopic.php?t=9079
|
||||
// https://github.com/devkitPro/libogc/commit/eac8fe2c29aa790d552dd6166a1fb195dfdcb825
|
||||
static constexpr u32 HASH_2020 = 0x84c680a9;
|
||||
// Padded version of the above (0x0400 bytes), added to libogc-rice on June 16, 2012 (that's the
|
||||
// commit author date; the commit date is November 24, 2016) and libogc2 on 25 May 2020. Used by
|
||||
// Not64 and OpenTTD (starting with the December 1, 2012 release).
|
||||
// https://github.com/extremscorner/libogc-rice/commit/cfddd4f3bec77812d6d333954e39d401d2276cd8
|
||||
// https://github.com/extremscorner/libogc2/commit/89ae39544e22f720a9c986af3524f7e6f20e7293
|
||||
static constexpr u32 HASH_2020_PAD = 0xa02a6131;
|
||||
// July 19, 2022 version (padded to 0x0400 bytes) - fixed MAIL_TERMINATE. This is not currently
|
||||
// included in libogc, only in libogc2 and libogc-rice (which generate a padded header file).
|
||||
// https://github.com/extremscorner/libogc2/commit/38edc9db93232faa612f680c91be1eb4d95dd1c6
|
||||
static constexpr u32 HASH_2022_PAD = 0x2e5e4100;
|
||||
|
||||
private:
|
||||
void DMAInParameterBlock();
|
||||
|
@ -54,6 +54,11 @@ constexpr u32 FLAGS_SAMPLE_FORMAT_BYTES_SHIFT = 16;
|
||||
|
||||
constexpr u32 SAMPLE_RATE = 48000;
|
||||
|
||||
bool ASndUCode::UseNewFlagMasks() const
|
||||
{
|
||||
return m_crc == HASH_2011 || m_crc == HASH_2020 || m_crc == HASH_2020_PAD;
|
||||
}
|
||||
|
||||
ASndUCode::ASndUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
|
||||
{
|
||||
}
|
||||
@ -239,9 +244,8 @@ void ASndUCode::DoMixing(u32 return_mail)
|
||||
|
||||
// start_main
|
||||
|
||||
const u32 sample_format_mask = (m_crc == HASH_2011 || m_crc == HASH_2020) ?
|
||||
NEW_FLAGS_SAMPLE_FORMAT_MASK :
|
||||
OLD_FLAGS_SAMPLE_FORMAT_MASK;
|
||||
const u32 sample_format_mask =
|
||||
UseNewFlagMasks() ? NEW_FLAGS_SAMPLE_FORMAT_MASK : OLD_FLAGS_SAMPLE_FORMAT_MASK;
|
||||
const u32 sample_format = m_current_voice.flags & sample_format_mask;
|
||||
const u32 sample_format_step =
|
||||
(m_current_voice.flags & FLAGS_SAMPLE_FORMAT_BYTES_MASK) >> FLAGS_SAMPLE_FORMAT_BYTES_SHIFT;
|
||||
@ -255,8 +259,7 @@ void ASndUCode::DoMixing(u32 return_mail)
|
||||
};
|
||||
const auto sample_function = sample_selector[sample_format];
|
||||
|
||||
const u32 pause_mask =
|
||||
(m_crc == HASH_2011 || m_crc == HASH_2020) ? NEW_FLAGS_VOICE_PAUSE : OLD_FLAGS_VOICE_PAUSE;
|
||||
const u32 pause_mask = UseNewFlagMasks() ? NEW_FLAGS_VOICE_PAUSE : OLD_FLAGS_VOICE_PAUSE;
|
||||
|
||||
if ((m_current_voice.flags & pause_mask) == 0)
|
||||
{
|
||||
@ -417,8 +420,7 @@ void ASndUCode::ChangeBuffer()
|
||||
m_current_voice.start_addr = m_current_voice.start_addr2;
|
||||
m_current_voice.backup_addr = m_current_voice.start_addr2;
|
||||
|
||||
const u32 loop_mask =
|
||||
(m_crc == HASH_2011 || m_crc == HASH_2020) ? NEW_FLAGS_VOICE_LOOP : OLD_FLAGS_VOICE_LOOP;
|
||||
const u32 loop_mask = UseNewFlagMasks() ? NEW_FLAGS_VOICE_LOOP : OLD_FLAGS_VOICE_LOOP;
|
||||
|
||||
if ((m_current_voice.flags & loop_mask) == 0)
|
||||
{
|
||||
|
@ -43,6 +43,14 @@ public:
|
||||
// provided in the repo. There appear to be no behavior differences from the 2011 version.
|
||||
// https://github.com/devkitPro/libogc/compare/bfb705fe1607a3031d18b65d603975b68a1cffd4~...d20f9bdcfb43260c6c759f4fb98d724931443f93
|
||||
static constexpr u32 HASH_2020 = 0xdbbeeb61;
|
||||
// Variant of the above used in libogc-rice and libogc2 starting on December 11, 2020 and padded
|
||||
// to 0x0620 bytes. These forks have gcdsptool generate a header file instead of a bin file
|
||||
// (followed by bin2o), so padding is still applied (for libogc-rice, the header is manually
|
||||
// generated, while libogc2 generates it as part of the build process).
|
||||
// https://github.com/extremscorner/libogc2/commit/80e01cbd8ead0370d98e092b426f851f21175e60
|
||||
// https://github.com/extremscorner/libogc2/commit/0b64f879808953d80ba06501a1c079b0fbf017d2
|
||||
// https://github.com/extremscorner/libogc-rice/commit/ce22c3269699fdbd474f2f28ca2ffca211954659
|
||||
static constexpr u32 HASH_2020_PAD = 0xbad876ef;
|
||||
|
||||
private:
|
||||
void DMAInVoiceData();
|
||||
@ -52,6 +60,8 @@ private:
|
||||
void ChangeBuffer();
|
||||
void DoMixing(u32 return_mail);
|
||||
|
||||
bool UseNewFlagMasks() const;
|
||||
|
||||
std::pair<s16, s16> ReadSampleMono8Bits() const;
|
||||
std::pair<s16, s16> ReadSampleStereo8Bits() const;
|
||||
std::pair<s16, s16> ReadSampleMono16Bits() const;
|
||||
|
@ -288,6 +288,7 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
|
||||
case ASndUCode::HASH_2009:
|
||||
case ASndUCode::HASH_2011:
|
||||
case ASndUCode::HASH_2020:
|
||||
case ASndUCode::HASH_2020_PAD:
|
||||
INFO_LOG_FMT(DSPHLE, "CRC {:08x}: ASnd chosen (Homebrew)", crc);
|
||||
return std::make_unique<ASndUCode>(dsphle, crc);
|
||||
|
||||
@ -295,6 +296,8 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
|
||||
case AESndUCode::HASH_2012:
|
||||
case AESndUCode::HASH_EDUKE32:
|
||||
case AESndUCode::HASH_2020:
|
||||
case AESndUCode::HASH_2020_PAD:
|
||||
case AESndUCode::HASH_2022_PAD:
|
||||
INFO_LOG_FMT(DSPHLE, "CRC {:08x}: AESnd chosen (Homebrew)", crc);
|
||||
return std::make_unique<AESndUCode>(dsphle, crc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user