From 69027bc48808d1ae09c50dd75a9b166aa301f29c Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 18 Jun 2017 23:50:09 +0100 Subject: [PATCH 1/5] DSPHLE: add another Japanese IPL checksum I'm not actually sure it's version 1.2 but it doesn't really matter anyway. --- Source/Core/Core/Boot/Boot.cpp | 2 ++ Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index aedd11c417..2b695073e5 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -232,6 +232,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename) constexpr u32 JAP_v1_0 = 0x6DAC1F2A; // https://bugs.dolphin-emu.org/issues/8936 constexpr u32 JAP_v1_1 = 0xD235E3F9; + constexpr u32 JAP_v1_2 = 0x8BDABBD4; // Redump 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 @@ -258,6 +259,7 @@ bool CBoot::Load_BS2(const std::string& boot_rom_filename) break; case JAP_v1_0: case JAP_v1_1: + case JAP_v1_2: ipl_region = DiscIO::Region::NTSC_J; break; case PAL_v1_0: diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp index ced544be98..8eaf746154 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.cpp @@ -260,7 +260,7 @@ std::unique_ptr UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii) case 0x6ca33a6d: // Zelda TP GC - US case 0xd643001f: // Super Mario Galaxy - US case 0x6ba3b3ea: // GC IPL - PAL - case 0x24b22038: // GC IPL - US + case 0x24b22038: // GC IPL - NTSC case 0x2fcdf1ec: // Zelda FSA - US case 0x4be6a5cb: // Pikmin 1 GC - US case 0x267fd05a: // Pikmin 1 GC - PAL From a46430851d9ca75535a06d9fdda4f68e7d96e283 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Tue, 20 Jun 2017 21:49:39 +0100 Subject: [PATCH 2/5] DSPHLE: the IPL PAL ucode's 0xC command is a nop --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index ae1cc5496a..eef76401cb 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -78,7 +78,7 @@ static const std::map UCODE_FLAGS = { {0x24B22038, LIGHT_PROTOCOL | FOUR_MIXING_DESTS | TINY_VPB | VOLUME_EXPLICIT_STEP | NO_CMD_0D | WEIRD_CMD_0C}, // 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. // Animal Crossing. {0x4BE6A5CB, LIGHT_PROTOCOL | NO_CMD_0D | SUPPORTS_GBA_CRYPTO}, @@ -532,7 +532,7 @@ void ZeldaUCode::RunPendingCommands() return; // 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. // * SMS and onwards: NOP. case 0x0C: From 578ae3c8a1a6b98ffa9cb2397961829ad4f9bf5c Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Tue, 20 Jun 2017 21:59:33 +0100 Subject: [PATCH 3/5] DSPHLE: the light protocol has no sine table The sine table is only used for Dolby mixing which the light protocol doesn't support. --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index eef76401cb..92f0e66ee3 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -483,10 +483,15 @@ void ZeldaUCode::RunPendingCommands() const_patterns[i] = Common::swap16(data_ptr[0x100 + i]); m_renderer.SetConstPatterns(std::move(const_patterns)); - std::array sine_table; - for (size_t i = 0; i < 0x80; ++i) - sine_table[i] = Common::swap16(data_ptr[0x200 + i]); - m_renderer.SetSineTable(std::move(sine_table)); + // The sine table is only used for Dolby mixing + // which the light protocol doesn't support. + if ((m_flags & LIGHT_PROTOCOL) == 0) + { + std::array sine_table; + for (size_t i = 0; i < 0x80; ++i) + sine_table[i] = Common::swap16(data_ptr[0x200 + i]); + m_renderer.SetSineTable(std::move(sine_table)); + } u16* afc_coeffs_ptr = (u16*)HLEMemory_Get_Pointer(Read32()); std::array afc_coeffs; From b2a3827ecb646cfd3286e6b4eda518cd9865b1d7 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 21 Jun 2017 06:57:58 +0100 Subject: [PATCH 4/5] DSPHLE: fix volume in NTSC IPL ucode --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index 92f0e66ee3..dc051a6a24 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -1269,7 +1269,7 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id) // providing a target volume. s16 volume_delta; if (m_flags & VOLUME_EXPLICIT_STEP) - volume_delta = (vpb.channels[i].target_volume << 16); + volume_delta = vpb.channels[i].target_volume; else volume_delta = vpb.channels[i].target_volume - vpb.channels[i].current_volume; From e504da6f04554a75c826b578337b77b59fd06b17 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 21 Jun 2017 07:07:10 +0100 Subject: [PATCH 5/5] DSPHLE: add a few comments --- Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp index dc051a6a24..0ad5d6a318 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp @@ -427,8 +427,8 @@ void ZeldaUCode::RunPendingCommands() switch (command) { case 0x00: - case 0x0A: - case 0x0B: + case 0x0A: // not a NOP in the NTSC IPL ucode but seems unused + case 0x0B: // not a NOP in both IPL ucodes but seems unused case 0x0F: // NOP commands. Log anyway in case we encounter a new version // where these are not NOPs anymore. @@ -595,6 +595,7 @@ void ZeldaUCode::SendCommandAck(CommandAck ack_type, u16 sync_value) { // The light protocol uses the address of the command handler in the // DSP code instead of the command id... go figure. + // FIXME: LLE returns a different value sync_value = 2 * ((sync_value >> 8) & 0x7F) + 0x62; m_mail_handler.PushMail(0x80000000 | sync_value); } @@ -848,6 +849,7 @@ struct ZeldaAudioRenderer::VPB // Samples stored in MRAM at an arbitrary sample rate (resampling is // applied, unlike PCM16_FROM_MRAM_RAW). SRC_PCM16_FROM_MRAM = 33, + // TODO: 2, 6 }; u16 samples_source_type; @@ -1437,8 +1439,8 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb) u16 pattern_offset = pattern_info.idx * PATTERN_SIZE; s16* pattern = m_const_patterns.data() + pattern_offset; - u32 pos = vpb->current_pos_frac << 6; // log2(PATTERN_SIZE) - u32 step = vpb->resampling_ratio << 5; + u32 pos = vpb->current_pos_frac << 6; // log2(PATTERN_SIZE) + u32 step = vpb->resampling_ratio << 5; // FIXME: ucode 24B22038 shifts by 6 (?) for (size_t i = 0; i < buffer->size(); ++i) {