From 00d2a050b8c90e06f42dcce08b1708dd299845a3 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 21 Feb 2021 13:46:49 +0800 Subject: [PATCH] Hook open season Fix #13252 original from #13326 --- Core/HLE/ReplaceTables.cpp | 18 ++++++++++++++++++ Core/MIPS/MIPSAnalyst.cpp | 1 + 2 files changed, 19 insertions(+) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index e2148da633..7a12d8f617 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -1277,6 +1277,23 @@ static int Hook_worms_copy_normalize_alpha() { return 0; } +static int Hook_openseason_data_decode() { + static u32 firstWritePtr = 0; + + u32 curWritePtr = currentMIPS->r[MIPS_REG_A0]; + u32 endPtr = currentMIPS->r[MIPS_REG_A1]; + u32 writeBytes = currentMIPS->r[MIPS_REG_V0]; + u32 startPtr = curWritePtr - writeBytes; + if (Memory::IsVRAMAddress(startPtr) && (firstWritePtr == 0 || startPtr < firstWritePtr)) { + firstWritePtr = startPtr; + } + if (Memory::IsVRAMAddress(endPtr) && curWritePtr == endPtr) { + gpu->PerformMemoryUpload(firstWritePtr, endPtr - firstWritePtr); + firstWritePtr = 0; + } + return 0; +} + #define JITFUNC(f) (&MIPSComp::MIPSFrontendInterface::f) // Can either replace with C functions or functions emitted in Asm/ArmAsm. @@ -1391,6 +1408,7 @@ static const ReplacementTableEntry entries[] = { { "starocean_clear_framebuf", &Hook_starocean_clear_framebuf_after, 0, REPFLAG_HOOKEXIT, 0 }, { "motorstorm_pixel_read", &Hook_motorstorm_pixel_read, 0, REPFLAG_HOOKENTER, 0 }, { "worms_copy_normalize_alpha", &Hook_worms_copy_normalize_alpha, 0, REPFLAG_HOOKENTER, 0x0CC }, + { "openseason_data_decode", &Hook_openseason_data_decode, 0, REPFLAG_HOOKENTER, 0x2F0 }, {} }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 9602ed97fc..6b6f02571f 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -504,6 +504,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0xfe4f0280240008e9, 28, "vavg_q", }, { 0xfe5dd338ab862291, 216, "memset", }, // Metal Gear Solid: Peace Walker demo { 0xffc8f5f8f946152c, 192, "dl_write_light_color", }, + { 0x249a3c5981c73480, 1472, "openseason_data_decode", }, // Open Season }; namespace MIPSAnalyst {