Merge pull request #5656 from Tilka/dsphle

DSPHLE: fix volume in NTSC IPL ucode
This commit is contained in:
Tilka 2017-06-21 07:14:22 +01:00 committed by GitHub
commit 4d0dd93098
3 changed files with 21 additions and 12 deletions

View File

@ -232,6 +232,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename)
constexpr u32 JAP_v1_0 = 0x6DAC1F2A; constexpr u32 JAP_v1_0 = 0x6DAC1F2A;
// https://bugs.dolphin-emu.org/issues/8936 // https://bugs.dolphin-emu.org/issues/8936
constexpr u32 JAP_v1_1 = 0xD235E3F9; constexpr u32 JAP_v1_1 = 0xD235E3F9;
constexpr u32 JAP_v1_2 = 0x8BDABBD4;
// Redump // Redump
constexpr u32 PAL_v1_0 = 0x4F319F43; constexpr u32 PAL_v1_0 = 0x4F319F43;
// https://forums.dolphin-emu.org/Thread-ipl-with-unknown-hash-dd8cab7c-problem-caused-by-my-pal-gamecube-bios?pid=435463#pid435463 // https://forums.dolphin-emu.org/Thread-ipl-with-unknown-hash-dd8cab7c-problem-caused-by-my-pal-gamecube-bios?pid=435463#pid435463
@ -258,6 +259,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename)
break; break;
case JAP_v1_0: case JAP_v1_0:
case JAP_v1_1: case JAP_v1_1:
case JAP_v1_2:
ipl_region = DiscIO::Region::NTSC_J; ipl_region = DiscIO::Region::NTSC_J;
break; break;
case PAL_v1_0: case PAL_v1_0:

View File

@ -260,7 +260,7 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
case 0x6ca33a6d: // Zelda TP GC - US case 0x6ca33a6d: // Zelda TP GC - US
case 0xd643001f: // Super Mario Galaxy - US case 0xd643001f: // Super Mario Galaxy - US
case 0x6ba3b3ea: // GC IPL - PAL case 0x6ba3b3ea: // GC IPL - PAL
case 0x24b22038: // GC IPL - US case 0x24b22038: // GC IPL - NTSC
case 0x2fcdf1ec: // Zelda FSA - US case 0x2fcdf1ec: // Zelda FSA - US
case 0x4be6a5cb: // Pikmin 1 GC - US case 0x4be6a5cb: // Pikmin 1 GC - US
case 0x267fd05a: // Pikmin 1 GC - PAL case 0x267fd05a: // Pikmin 1 GC - PAL

View File

@ -78,7 +78,7 @@ static const std::map<u32, u32> UCODE_FLAGS = {
{0x24B22038, LIGHT_PROTOCOL | FOUR_MIXING_DESTS | TINY_VPB | VOLUME_EXPLICIT_STEP | NO_CMD_0D | {0x24B22038, LIGHT_PROTOCOL | FOUR_MIXING_DESTS | TINY_VPB | VOLUME_EXPLICIT_STEP | NO_CMD_0D |
WEIRD_CMD_0C}, WEIRD_CMD_0C},
// GameCube IPL/BIOS, PAL. // GameCube IPL/BIOS, PAL.
{0x6BA3B3EA, LIGHT_PROTOCOL | FOUR_MIXING_DESTS | NO_CMD_0D | WEIRD_CMD_0C}, {0x6BA3B3EA, LIGHT_PROTOCOL | FOUR_MIXING_DESTS | NO_CMD_0D},
// Pikmin 1 GC NTSC. // Pikmin 1 GC NTSC.
// Animal Crossing. // Animal Crossing.
{0x4BE6A5CB, LIGHT_PROTOCOL | NO_CMD_0D | SUPPORTS_GBA_CRYPTO}, {0x4BE6A5CB, LIGHT_PROTOCOL | NO_CMD_0D | SUPPORTS_GBA_CRYPTO},
@ -427,8 +427,8 @@ void ZeldaUCode::RunPendingCommands()
switch (command) switch (command)
{ {
case 0x00: case 0x00:
case 0x0A: case 0x0A: // not a NOP in the NTSC IPL ucode but seems unused
case 0x0B: case 0x0B: // not a NOP in both IPL ucodes but seems unused
case 0x0F: case 0x0F:
// NOP commands. Log anyway in case we encounter a new version // NOP commands. Log anyway in case we encounter a new version
// where these are not NOPs anymore. // where these are not NOPs anymore.
@ -483,10 +483,15 @@ void ZeldaUCode::RunPendingCommands()
const_patterns[i] = Common::swap16(data_ptr[0x100 + i]); const_patterns[i] = Common::swap16(data_ptr[0x100 + i]);
m_renderer.SetConstPatterns(std::move(const_patterns)); m_renderer.SetConstPatterns(std::move(const_patterns));
// The sine table is only used for Dolby mixing
// which the light protocol doesn't support.
if ((m_flags & LIGHT_PROTOCOL) == 0)
{
std::array<s16, 0x80> sine_table; std::array<s16, 0x80> sine_table;
for (size_t i = 0; i < 0x80; ++i) for (size_t i = 0; i < 0x80; ++i)
sine_table[i] = Common::swap16(data_ptr[0x200 + i]); sine_table[i] = Common::swap16(data_ptr[0x200 + i]);
m_renderer.SetSineTable(std::move(sine_table)); m_renderer.SetSineTable(std::move(sine_table));
}
u16* afc_coeffs_ptr = (u16*)HLEMemory_Get_Pointer(Read32()); u16* afc_coeffs_ptr = (u16*)HLEMemory_Get_Pointer(Read32());
std::array<s16, 0x20> afc_coeffs; std::array<s16, 0x20> afc_coeffs;
@ -532,7 +537,7 @@ void ZeldaUCode::RunPendingCommands()
return; return;
// Command 0C: used for multiple purpose depending on the UCode version: // Command 0C: used for multiple purpose depending on the UCode version:
// * IPL NTSC/PAL, Luigi's Mansion: TODO (unknown as of now). // * IPL NTSC, Luigi's Mansion: TODO (unknown as of now).
// * Pikmin/AC: GBA crypto. // * Pikmin/AC: GBA crypto.
// * SMS and onwards: NOP. // * SMS and onwards: NOP.
case 0x0C: case 0x0C:
@ -590,6 +595,7 @@ void ZeldaUCode::SendCommandAck(CommandAck ack_type, u16 sync_value)
{ {
// The light protocol uses the address of the command handler in the // The light protocol uses the address of the command handler in the
// DSP code instead of the command id... go figure. // DSP code instead of the command id... go figure.
// FIXME: LLE returns a different value
sync_value = 2 * ((sync_value >> 8) & 0x7F) + 0x62; sync_value = 2 * ((sync_value >> 8) & 0x7F) + 0x62;
m_mail_handler.PushMail(0x80000000 | sync_value); m_mail_handler.PushMail(0x80000000 | sync_value);
} }
@ -843,6 +849,7 @@ struct ZeldaAudioRenderer::VPB
// Samples stored in MRAM at an arbitrary sample rate (resampling is // Samples stored in MRAM at an arbitrary sample rate (resampling is
// applied, unlike PCM16_FROM_MRAM_RAW). // applied, unlike PCM16_FROM_MRAM_RAW).
SRC_PCM16_FROM_MRAM = 33, SRC_PCM16_FROM_MRAM = 33,
// TODO: 2, 6
}; };
u16 samples_source_type; u16 samples_source_type;
@ -1264,7 +1271,7 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
// providing a target volume. // providing a target volume.
s16 volume_delta; s16 volume_delta;
if (m_flags & VOLUME_EXPLICIT_STEP) if (m_flags & VOLUME_EXPLICIT_STEP)
volume_delta = (vpb.channels[i].target_volume << 16); volume_delta = vpb.channels[i].target_volume;
else else
volume_delta = vpb.channels[i].target_volume - vpb.channels[i].current_volume; volume_delta = vpb.channels[i].target_volume - vpb.channels[i].current_volume;
@ -1433,7 +1440,7 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb)
s16* pattern = m_const_patterns.data() + pattern_offset; s16* pattern = m_const_patterns.data() + pattern_offset;
u32 pos = vpb->current_pos_frac << 6; // log2(PATTERN_SIZE) u32 pos = vpb->current_pos_frac << 6; // log2(PATTERN_SIZE)
u32 step = vpb->resampling_ratio << 5; u32 step = vpb->resampling_ratio << 5; // FIXME: ucode 24B22038 shifts by 6 (?)
for (size_t i = 0; i < buffer->size(); ++i) for (size_t i = 0; i < buffer->size(); ++i)
{ {