Ship by default a free DSP ROM that can handle most games with LLE

At the end of July 2011, LM published a free DSP ROM that works with games
using the Zelda UCode. His ROM only has the code to handle UCode loading and a
few utility functions, the rest is missing. This includes the four large sound
mixing functions used by the AX UCode and the DROM containing coefficients used
for polyphase resampling in AX.

This is an improved, updated version of this ROM, which changes the following:

- We now have a free DROM that works for polyphase resampling by "emulating"
  linear interpolation. The coefficients contained in the DROM are normally a
  list of { c1, c2, c3, c4 } which are used to interpolate a sample value from
  four previous samples:
    out_sample = prev1 * c1 + prev2 * c2 + prev3 * c3 + prev4 * c4

  The coefficients are chosen depending on the fractional part of the current
  position (basically, our position between the previous and the next sample).
  We can use this fact to generate (c1, c2, c3, c4) for each possible
  fractional part so that:
    out_sample = prev3 * curr_pos + prev4 * (1 - curr_pos)

  Which is the formula for linear interpolation between prev3 and prev4. Linear
  interpolation is not as good as polyphase resampling but it still works very
  well and I couldn't really hear any difference between the two. If someone
  wants to generate real polyphase filter coefficients, they are welcome to
  submit a patch.

- The IROM now contains the 4 mixing functions used by the AX UCode: mix_add,
  mix_add_two, mix_add_ramp, mix_add_ramp_two. They are large, inlined
  functions (probably for performance reasons) in the official DSP IROM, our
  version prefers to use a loop. This *should* be more performant with our DSP
  JIT implementation, but I did not benchmark that.

Because the new DSP ROM is working just as well as the official ROM in 95% of
cases, it is now shipped by default with Dolphin and will be used with DSPLLE
if you don't have an official DSP ROM in User/GC. It will still display a panic
alert at every boot to notice you that you are using a non official DSP ROM
made by us, which is not perfect.

Games using the CARD, IPL or GBA UCodes are still broken. I don't know what
games this actually impacts, but this is a very small proportion compared to
what works.
This commit is contained in:
Pierre Bourdon 2013-03-16 23:54:55 +01:00
parent c7d75ee437
commit 9a404ca6d4
7 changed files with 1238 additions and 28 deletions

BIN
Data/Sys/GC/dsp_coef.bin Normal file

Binary file not shown.

BIN
Data/Sys/GC/dsp_rom.bin Normal file

Binary file not shown.

View file

@ -77,37 +77,50 @@ static bool LoadRom(const char *fname, int size_in_words, u16 *rom)
// Returns false iff the hash fails and the user hits "Yes"
static bool VerifyRoms(const char *irom_filename, const char *coef_filename)
{
static const u32 hash[] = { 0x66f334fe, 0xf3b93527 };
static const u32 hash_mini[] = { 0x9c8f593c, 0x10000001 };
static const int size[] = { DSP_IROM_BYTE_SIZE, DSP_COEF_BYTE_SIZE };
const u16 *data[] = { g_dsp.irom, g_dsp.coef };
u32 h = 0;
u8 count = 0;
for (int i = 0; i < 2; i++)
struct DspRomHashes
{
h = HashAdler32((u8*)data[i], size[i]);
u32 hash_irom; // dsp_rom.bin
u32 hash_drom; // dsp_coef.bin
} KNOWN_ROMS[] = {
// Official Nintendo ROM
{ 0x66f334fe, 0xf3b93527 },
if (h == hash_mini[i])
{
count++;
}
else if (h != hash[i])
{
if (AskYesNoT("%s has an incorrect hash.\n"
"Would you like to stop now to fix the problem?\n"
"If you select \"No\", audio will be garbled.",
(i == 0) ? irom_filename : coef_filename))
return false;
}
// LM1234 replacement ROM (Zelda UCode only)
{ 0x9c8f593c, 0x10000001 },
// delroth's improvement on LM1234 replacement ROM (Zelda and AX only,
// IPL/Card/GBA still broken)
{ 0xd9907f71, 0xb019c2fb }
};
u32 hash_irom = HashAdler32((u8*)g_dsp.irom, DSP_IROM_BYTE_SIZE);
u32 hash_drom = HashAdler32((u8*)g_dsp.coef, DSP_COEF_BYTE_SIZE);
int rom_idx = -1;
for (u32 i = 0; i < sizeof (KNOWN_ROMS) / sizeof (KNOWN_ROMS[0]); ++i)
{
DspRomHashes& rom = KNOWN_ROMS[i];
if (hash_irom == rom.hash_irom && hash_drom == rom.hash_drom)
rom_idx = i;
}
if (count == 2)
if (rom_idx < 0)
{
PanicAlertT("You are using free dsp roms made by Dolphin Team.\n"
"Only Zelda ucode games will work correctly with them.\n");
if (AskYesNoT("Your DSP ROMs have incorrect hashes.\n"
"Would you like to stop now to fix the problem?\n"
"If you select \"No\", audio might be garbled."))
return false;
}
if (rom_idx == 1)
PanicAlertT("You are using an old free DSP ROM made by the Dolphin Team.\n"
"Only games using the Zelda UCode will work correctly.\n");
if (rom_idx == 2)
PanicAlertT("You are using a free DSP ROM made by the Dolphin Team.\n"
"All Wii games will work correctly, and most GC games should "
"also work fine, but the GBA/IPL/CARD UCodes will not work.\n");
return true;
}

View file

@ -144,13 +144,13 @@ bool DSPLLE::Initialize(void *hWnd, bool bWii, bool bDSPThread)
m_bDSPThread = bDSPThread;
m_InitMixer = false;
std::string irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM;
std::string coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF;
std::string irom_file = File::GetUserPath(D_GCUSER_IDX) + DSP_IROM;
std::string coef_file = File::GetUserPath(D_GCUSER_IDX) + DSP_COEF;
if (!File::Exists(irom_file))
irom_file = File::GetUserPath(D_GCUSER_IDX) + DSP_IROM;
irom_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_IROM;
if (!File::Exists(coef_file))
coef_file = File::GetUserPath(D_GCUSER_IDX) + DSP_COEF;
coef_file = File::GetSysDirectory() + GC_SYS_DIR DIR_SEP DSP_COEF;
if (!DSPCore_Init(irom_file.c_str(), coef_file.c_str(), AudioCommon::UseJIT()))
return false;

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,28 @@
Legal GC/WII DSP IROM replacement (v0.2)
-------------------------------------------------------
- coef: crafted to use a linear interpolation when resampling (instead of
having a real 4 TAP FIR filter)
- irom: added all the mixing functions, some functions not used by AX/Zelda are
still missing
Should work with all AX, AXWii and Zelda UCode games. Card/IPL/GBA are most
likely still broken with it and require a real DSP ROM.
delroth
16/march/2013
Legal GC/WII DSP IROM replacement (v0.1)
-------------------------------------------------------
- coef: fake (zeroes)
- irom: reversed and rewrote ucode loading/reset part, everything else is missing
Good enough for Zelda ucode games (and maybe some AX too):
- WII: SMG 1/2, Pikmin 1/2 WII, Zelda TP WII, Donkey Kong Jungle Beat (WII), ...
- GC: Mario Kart Double Dash, Luigi Mansion, Super Mario Sunshine, Pikmin 1/2, Zelda WW, Zelda TP, ...
Basically... If game is not using coef and irom mixing functions it will work ok.
Dolphin emulator will report wrong CRCs, but it will work ok with mentioned games.
LM
31/july/2011