From ea9a0182e43e3c1a33ea26d73b30fc4ebc29eea3 Mon Sep 17 00:00:00 2001 From: daniel229 Date: Fri, 26 Sep 2014 16:55:37 +0800 Subject: [PATCH 1/3] Replace download frame in Sora no kiseki FC --- Core/HLE/ReplaceTables.cpp | 10 ++++++++++ Core/MIPS/MIPSAnalyst.cpp | 1 + 2 files changed, 11 insertions(+) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 6c435a9aa8..eb2bba9b5e 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -690,6 +690,15 @@ static int Hook_kagaku_no_ensemble_download_frame() { return 0; } +static int Hook_soranokiseki_fc_download_frame() { + const u32 fb_address = currentMIPS->r[MIPS_REG_A2]; + if (Memory::IsVRAMAddress(fb_address)) { + gpu->PerformMemoryDownload(fb_address, 0x00044000); + CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, 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 @@ -747,6 +756,7 @@ static const ReplacementTableEntry entries[] = { { "suikoden1_and_2_download_frame_2", &Hook_suikoden1_and_2_download_frame_2, 0, REPFLAG_HOOKENTER, 0x48 }, { "rezel_cross_download_frame", &Hook_rezel_cross_download_frame, 0, REPFLAG_HOOKENTER, 0x54 }, { "kagaku_no_ensemble_download_frame", &Hook_kagaku_no_ensemble_download_frame, 0, REPFLAG_HOOKENTER, 0x38 }, + { "soranokiseki_fc_download_frame", &Hook_soranokiseki_fc_download_frame, 0, REPFLAG_HOOKENTER, 0x180 }, {} }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index e176219cdf..839108f3d4 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -344,6 +344,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0xb8bd1f0e02e9ad87, 156, "dl_write_light_dir", }, { 0xb8cfaeebfeb2de20, 7548, "_vfprintf_r", }, { 0xb97f352e85661af6, 32, "finitef", }, + { 0xba76a8e853426baa, 544, "soranokiseki_fc_download_frame", }, // Sora no kiseki FC { 0xbb3c6592ed319ba4, 132, "dl_write_fog_params", }, { 0xbb7d7c93e4c08577, 124, "__truncdfsf2", }, { 0xbdf54d66079afb96, 200, "dl_write_bone_matrix_3", }, From 4de7e893309406eb627ad010cc45407ed43373e2 Mon Sep 17 00:00:00 2001 From: daniel229 Date: Fri, 26 Sep 2014 17:13:01 +0800 Subject: [PATCH 2/3] Replace download frame in Sora no kiseki SC,and a comment for Sora no kiseki 3rd --- Core/HLE/ReplaceTables.cpp | 22 ++++++++++++++++++++++ Core/MIPS/MIPSAnalyst.cpp | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index eb2bba9b5e..873d17fbd5 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -699,6 +699,27 @@ static int Hook_soranokiseki_fc_download_frame() { return 0; } +static int Hook_soranokiseki_sc_download_frame() { + u32 fb_infoaddr; + if (!GetMIPSStaticAddress(fb_infoaddr, 0x28, 0x2C)) { + return 0; + } + const u32 fb_info = Memory::Read_U32(fb_infoaddr); + const MIPSOpcode fb_index_load = Memory::Read_Instruction(currentMIPS->pc + 0x34, true); + if (fb_index_load != MIPS_MAKE_LW(MIPS_GET_RT(fb_index_load), MIPS_GET_RS(fb_index_load), fb_index_load & 0xffff)) { + return 0; + } + const int fb_index_offset = (s16)(fb_index_load & 0xffff); + const u32 fb_index = (Memory::Read_U32(fb_info + fb_index_offset) + 1) & 1; + const u32 fb_address = 0x4000000 + (0x44000 * fb_index); + const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; + if (Memory::IsRAMAddress(dest_address)) { + gpu->PerformMemoryDownload(fb_address, 0x00044000); + CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, 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 @@ -757,6 +778,7 @@ static const ReplacementTableEntry entries[] = { { "rezel_cross_download_frame", &Hook_rezel_cross_download_frame, 0, REPFLAG_HOOKENTER, 0x54 }, { "kagaku_no_ensemble_download_frame", &Hook_kagaku_no_ensemble_download_frame, 0, REPFLAG_HOOKENTER, 0x38 }, { "soranokiseki_fc_download_frame", &Hook_soranokiseki_fc_download_frame, 0, REPFLAG_HOOKENTER, 0x180 }, + { "soranokiseki_sc_download_frame", &Hook_soranokiseki_sc_download_frame, 0, REPFLAG_HOOKENTER, }, {} }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 839108f3d4..fb90522bc4 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -326,7 +326,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0xafb2c7e56c04c8e9, 48, "vtfm_q", }, { 0xafc9968e7d246a5e, 1588, "atan", }, { 0xafcb7dfbc4d72588, 44, "vector_transform_3x4", }, - { 0xb07f9d82d79deea9, 536, "brandish_download_frame", }, // Brandish + { 0xb07f9d82d79deea9, 536, "brandish_download_frame", }, // Brandish, and Sora no kiseki 3rd { 0xb0db731f27d3aa1b, 40, "vmax_s", }, { 0xb0ef265e87899f0a, 32, "vector_divide_t_s", }, { 0xb183a37baa12607b, 32, "vscl_t", }, @@ -354,6 +354,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0xbfa8c16038b7753d, 868, "sakurasou_download_frame", }, // Sakurasou No Pet Na Kanojo { 0xc062f2545ef5dc39, 1076, "kirameki_school_life_download_frame", },// Kirameki School Life SP,and Boku wa Tomodati ga Sukunai { 0xc0feb88cc04a1dc7, 48, "vector_negate_t", }, + { 0xc1220040b0599a75, 472, "soranokiseki_sc_download_frame", }, // Sora no kiseki SC { 0xc1f34599d0b9146b, 116, "__subdf3", }, { 0xc3089f66ee6f0a24, 464, "growlanser_create_saveicon", }, // Growlanswer IV { 0xc319f0d107dd2f45, 888, "__muldf3", }, From aad301a97ab703f53e0f3cf2966168d0484376ba Mon Sep 17 00:00:00 2001 From: daniel229 Date: Sat, 27 Sep 2014 14:00:37 +0800 Subject: [PATCH 3/3] Replace download frame in Boku no Natsuyasumi 2 and 4 --- Core/HLE/ReplaceTables.cpp | 10 ++++++++++ Core/MIPS/MIPSAnalyst.cpp | 1 + 2 files changed, 11 insertions(+) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 873d17fbd5..6d2844fd2c 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -720,6 +720,15 @@ static int Hook_soranokiseki_sc_download_frame() { return 0; } +static int Hook_bokunonatsuyasumi4_download_frame() { + const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; + if (Memory::IsVRAMAddress(fb_address)) { + gpu->PerformMemoryDownload(fb_address, 0x00044000); + CBreakPoints::ExecMemCheck(fb_address, true, 0x00044000, 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 @@ -779,6 +788,7 @@ static const ReplacementTableEntry entries[] = { { "kagaku_no_ensemble_download_frame", &Hook_kagaku_no_ensemble_download_frame, 0, REPFLAG_HOOKENTER, 0x38 }, { "soranokiseki_fc_download_frame", &Hook_soranokiseki_fc_download_frame, 0, REPFLAG_HOOKENTER, 0x180 }, { "soranokiseki_sc_download_frame", &Hook_soranokiseki_sc_download_frame, 0, REPFLAG_HOOKENTER, }, + { "bokunonatsuyasumi4_download_frame", &Hook_bokunonatsuyasumi4_download_frame, 0, REPFLAG_HOOKENTER, 0x8C }, {} }; diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index fb90522bc4..693260f3b9 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -391,6 +391,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0xddfa5a85937aa581, 32, "vdot_q", }, { 0xe0214719d8a0aa4e, 104, "strstr", }, { 0xe029f0699ca3a886, 76, "matrix300_transform_by", }, + { 0xe086d5c9ce89148f, 212, "bokunonatsuyasumi4_download_frame", }, // Boku no Natsuyasumi 2 and 4, { 0xe093c2b0194d52b3, 820, "ff1_battle_effect", }, // Final Fantasy 1 { 0xe1107cf3892724a0, 460, "_memalign_r", }, { 0xe1724e6e29209d97, 24, "vector_length_t_2", },