DSPHLE: Add Desert Bus libasnd ucode variants

This commit is contained in:
Pokechu22 2022-12-19 22:37:35 -08:00
parent a1c4861ad8
commit 66b3686d84
3 changed files with 25 additions and 2 deletions

View File

@ -54,9 +54,15 @@ constexpr u32 FLAGS_SAMPLE_FORMAT_BYTES_SHIFT = 16;
constexpr u32 SAMPLE_RATE = 48000;
bool ASndUCode::SwapLeftRight() const
{
return m_crc == HASH_DESERT_BUS_2011 || m_crc == HASH_DESERT_BUS_2012;
}
bool ASndUCode::UseNewFlagMasks() const
{
return m_crc == HASH_2011 || m_crc == HASH_2020 || m_crc == HASH_2020_PAD;
return m_crc == HASH_2011 || m_crc == HASH_2020 || m_crc == HASH_2020_PAD ||
m_crc == HASH_DESERT_BUS_2011 || m_crc == HASH_DESERT_BUS_2012;
}
ASndUCode::ASndUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
@ -383,7 +389,13 @@ void ASndUCode::DoMixing(u32 return_mail)
}
// Both paths jmpr $AR3, which is an index into sample_selector
const auto [new_r, new_l] = (this->*sample_function)();
auto [new_r, new_l] = (this->*sample_function)();
if (SwapLeftRight())
{
// The Desert Bus versions swapped the left and right input channels so that left
// comes first, and then right. Before, right came before left.
std::swap(new_r, new_l);
}
// out_samp: "multiply sample x volume" - left is put in $ax0.h, right is put in $ax1.h
// All functions jumped to from sample_selector jump or fall through here (zero_samples also

View File

@ -51,6 +51,14 @@ public:
// https://github.com/extremscorner/libogc2/commit/0b64f879808953d80ba06501a1c079b0fbf017d2
// https://github.com/extremscorner/libogc-rice/commit/ce22c3269699fdbd474f2f28ca2ffca211954659
static constexpr u32 HASH_2020_PAD = 0xbad876ef;
// Variant used in Desert Bus v1.04 - this is based off of the code in libogc (as it existed in
// 2011, even though that code only became used in 2020), but the left and right channels are
// swapped. Padded to 0x0620 bytes.
static constexpr u32 HASH_DESERT_BUS_2011 = 0xfa9c576f;
// Variant used in Desert Bus v1.05 - this is the same as the previous version, except 4 junk
// instructions were added to the start, which do not change behavior in any way. Padded to 0x0620
// bytes.
static constexpr u32 HASH_DESERT_BUS_2012 = 0x614dd145;
private:
void DMAInVoiceData();
@ -60,6 +68,7 @@ private:
void ChangeBuffer();
void DoMixing(u32 return_mail);
bool SwapLeftRight() const;
bool UseNewFlagMasks() const;
std::pair<s16, s16> ReadSampleMono8Bits() const;

View File

@ -313,6 +313,8 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
case ASndUCode::HASH_2011:
case ASndUCode::HASH_2020:
case ASndUCode::HASH_2020_PAD:
case ASndUCode::HASH_DESERT_BUS_2011:
case ASndUCode::HASH_DESERT_BUS_2012:
INFO_LOG_FMT(DSPHLE, "CRC {:08x}: ASnd chosen (Homebrew)", crc);
return std::make_unique<ASndUCode>(dsphle, crc);