From ee6960ff7a782e889f00fd7dadce93a1643be588 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 8 Sep 2014 19:10:46 -0700 Subject: [PATCH] Hook the saveicon creation func in Growlanser IV. --- Core/HLE/ReplaceTables.cpp | 34 +++++++++++++++++++++++----------- Core/MIPS/MIPSAnalyst.cpp | 1 + 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 0df2c677ff..b32e962775 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -538,7 +538,7 @@ static int Hook_hexyzforce_monoclome_thread() { } static int Hook_starocean_write_stencil() { - u32 fb_address = currentMIPS->r[MIPS_REG_T7]; + const u32 fb_address = currentMIPS->r[MIPS_REG_T7]; if (Memory::IsVRAMAddress(fb_address) && !g_Config.bDisableStencilTest) { gpu->PerformStencilUpload(fb_address, 0x00088000); } @@ -546,7 +546,7 @@ static int Hook_starocean_write_stencil() { } static int Hook_topx_create_saveicon() { - u32 fb_address = currentMIPS->r[MIPS_REG_V0]; + const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); @@ -555,7 +555,7 @@ static int Hook_topx_create_saveicon() { } static int Hook_ff1_battle_effect() { - u32 fb_address = currentMIPS->r[MIPS_REG_A1]; + const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00088000); CBreakPoints::ExecMemCheck(fb_address, true, 0x00088000, currentMIPS->pc); @@ -565,7 +565,7 @@ static int Hook_ff1_battle_effect() { static int Hook_dissidia_recordframe_avi() { // This is called once per frame, and records that frame's data to avi. - u32 fb_address = currentMIPS->r[MIPS_REG_A1]; + const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { gpu->PerformMemoryDownload(fb_address, 0x00044000); CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, currentMIPS->pc); @@ -594,6 +594,17 @@ static int Hook_brandish_download_frame() { return 0; } +static int Hook_growlanser_create_saveicon() { + const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP] + 4); + const u32 fmt = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP]); + const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; + if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { + gpu->PerformMemoryDownload(fb_address, sz); + CBreakPoints::ExecMemCheck(fb_address, true, sz, currentMIPS->pc); + } + return 0; +} + // Can either replace with C functions or functions emitted in Asm/ArmAsm. static const ReplacementTableEntry entries[] = { // TODO: I think some games can be helped quite a bit by implementing the @@ -633,14 +644,15 @@ static const ReplacementTableEntry entries[] = { // { "vmmul_q_transp", &Replace_vmmul_q_transp, 0, REPFLAG_DISABLED }, - { "godseaterburst_blit_texture", &Hook_godseaterburst_blit_texture, 0, REPFLAG_HOOKENTER}, - { "hexyzforce_monoclome_thread", &Hook_hexyzforce_monoclome_thread, 0, REPFLAG_HOOKENTER, 0x58}, - { "starocean_write_stencil", &Hook_starocean_write_stencil, 0, REPFLAG_HOOKENTER, 0x260}, - { "topx_create_saveicon", &Hook_topx_create_saveicon, 0, REPFLAG_HOOKENTER, 0x34}, - { "ff1_battle_effect", &Hook_ff1_battle_effect, 0, REPFLAG_HOOKENTER}, + { "godseaterburst_blit_texture", &Hook_godseaterburst_blit_texture, 0, REPFLAG_HOOKENTER }, + { "hexyzforce_monoclome_thread", &Hook_hexyzforce_monoclome_thread, 0, REPFLAG_HOOKENTER, 0x58 }, + { "starocean_write_stencil", &Hook_starocean_write_stencil, 0, REPFLAG_HOOKENTER, 0x260 }, + { "topx_create_saveicon", &Hook_topx_create_saveicon, 0, REPFLAG_HOOKENTER, 0x34 }, + { "ff1_battle_effect", &Hook_ff1_battle_effect, 0, REPFLAG_HOOKENTER }, // This is actually used in other games, not just Dissidia. - { "dissidia_recordframe_avi", &Hook_dissidia_recordframe_avi, 0, REPFLAG_HOOKENTER}, - { "brandish_download_frame", &Hook_brandish_download_frame, 0, REPFLAG_HOOKENTER}, + { "dissidia_recordframe_avi", &Hook_dissidia_recordframe_avi, 0, REPFLAG_HOOKENTER }, + { "brandish_download_frame", &Hook_brandish_download_frame, 0, REPFLAG_HOOKENTER }, + { "growlanser_create_saveicon", &Hook_growlanser_create_saveicon, 0, REPFLAG_HOOKENTER, 0x7C }, {} }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 1d7da8a86f..514aecbfce 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -345,6 +345,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0xbf791954ebef4afb, 396, "expf", }, { 0xc0feb88cc04a1dc7, 48, "vector_negate_t", }, { 0xc1f34599d0b9146b, 116, "__subdf3", }, + { 0xc3089f66ee6f0a24, 464, "growlanser_create_saveicon", }, { 0xc319f0d107dd2f45, 888, "__muldf3", }, { 0xc35c10300b6b6091, 620, "floor", }, { 0xc3dbf3e6c80a0a51, 164, "dl_write_bone_matrix", },