mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Patches for Resident Evil 2/3 audio issues
These games are erroneously zeroing buffers before they can be fully copied to ARAM by DMA. The responsible memset() calls are followed by a call to DVDRead() which issues dcbi instructions that effectively cancel the memset() on real hardware. Because Dolphin lacks dcache emulation, the effects of the memset() calls are observed, which causes missing audio. In a comment on the original bug, phire noted that the issue can be corrected by simply nop'ing out the offending memset() calls. Because the games dynamically load different .rel executables based on the character and/or language, the addresses of these calls can vary. To deal generally with the problem of code being dynamically loaded to fixed, known addresses, the patch engine is extended to support conditional patches which require a match against a known value. This sort of thing is already achievable with Action Replay/Gecko codes, but their use depends on enabling cheats globally in Dolphin, which is not a prerequisite shared by patches. Patches are included for every region, character, and language combination. They are enabled by default. The end result is an approximation of the games' behavior on real hardware without the associated complexity of proper dcache emulation. https://bugs.dolphin-emu.org/issues/9840
This commit is contained in:
@ -90,6 +90,11 @@ void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, I
|
||||
bool success = true;
|
||||
success &= TryParse(items[0], &pE.address);
|
||||
success &= TryParse(items[2], &pE.value);
|
||||
if (items.size() >= 4)
|
||||
{
|
||||
success &= TryParse(items[3], &pE.comparand);
|
||||
pE.conditional = true;
|
||||
}
|
||||
|
||||
const auto iter =
|
||||
std::find(s_patch_type_strings.begin(), s_patch_type_strings.end(), items[1]);
|
||||
@ -184,16 +189,20 @@ static void ApplyPatches(const std::vector<Patch>& patches)
|
||||
{
|
||||
u32 addr = entry.address;
|
||||
u32 value = entry.value;
|
||||
u32 comparand = entry.comparand;
|
||||
switch (entry.type)
|
||||
{
|
||||
case PatchType::Patch8Bit:
|
||||
PowerPC::HostWrite_U8(static_cast<u8>(value), addr);
|
||||
if (!entry.conditional || PowerPC::HostRead_U8(addr) == static_cast<u8>(comparand))
|
||||
PowerPC::HostWrite_U8(static_cast<u8>(value), addr);
|
||||
break;
|
||||
case PatchType::Patch16Bit:
|
||||
PowerPC::HostWrite_U16(static_cast<u16>(value), addr);
|
||||
if (!entry.conditional || PowerPC::HostRead_U16(addr) == static_cast<u16>(comparand))
|
||||
PowerPC::HostWrite_U16(static_cast<u16>(value), addr);
|
||||
break;
|
||||
case PatchType::Patch32Bit:
|
||||
PowerPC::HostWrite_U32(value, addr);
|
||||
if (!entry.conditional || PowerPC::HostRead_U32(addr) == comparand)
|
||||
PowerPC::HostWrite_U32(value, addr);
|
||||
break;
|
||||
default:
|
||||
// unknown patchtype
|
||||
|
Reference in New Issue
Block a user