Hook open season

Fix #13252
original from #13326
This commit is contained in:
sum2012 2021-02-21 13:46:49 +08:00
parent dd980905a2
commit 00d2a050b8
2 changed files with 19 additions and 0 deletions

View file

@ -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 },
{}
};

View file

@ -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 {