mirror of
https://github.com/Retropex/dolphin.git
synced 2025-05-12 11:20:46 +02:00
Gandrayda fix mp3 trilogy PAL
This commit is contained in:
parent
e5631ed351
commit
f1cea46228
@ -1825,7 +1825,6 @@ void FpsControls::init_mod_mp3(Region region) {
|
||||
prime::GetVariableManager()->register_variable("trigger_grapple");
|
||||
prime::GetVariableManager()->register_variable("new_beam");
|
||||
prime::GetVariableManager()->register_variable("beamchange_flag");
|
||||
int wiimote_shake_override_idx = PowerPC::RegisterVmcall(wiimote_shake_override);
|
||||
|
||||
if (region == Region::NTSC_U) {
|
||||
add_code_change(0x80080ac0, 0xec010072);
|
||||
@ -1846,7 +1845,6 @@ void FpsControls::init_mod_mp3(Region region) {
|
||||
|
||||
// Steps over bounds checking on the reticle
|
||||
add_code_change(0x80016f48, 0x48000120);
|
||||
add_code_change(0x800a8fc0, gen_vmcall(wiimote_shake_override_idx, 0));
|
||||
} else if (region == Region::PAL) {
|
||||
add_code_change(0x80080ab8, 0xec010072);
|
||||
add_code_change(0x8014d9e0, 0x60000000);
|
||||
@ -1870,6 +1868,8 @@ void FpsControls::init_mod_mp3(Region region) {
|
||||
|
||||
// Same for both.
|
||||
add_code_change(0x800614d0, 0x60000000, "visor_menu");
|
||||
const int wiimote_shake_override_idx = PowerPC::RegisterVmcall(wiimote_shake_override);
|
||||
add_code_change(0x800a8fc0, gen_vmcall(wiimote_shake_override_idx, 0));
|
||||
has_beams = false;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,49 @@
|
||||
#include "Core/PrimeHack/PrimeUtils.h"
|
||||
|
||||
namespace prime {
|
||||
namespace {
|
||||
std::string readin_str(u32 str_ptr) {
|
||||
std::ostringstream key_readin;
|
||||
for (char c; (c = read8(str_ptr)); str_ptr++) {
|
||||
key_readin << c;
|
||||
}
|
||||
return key_readin.str();
|
||||
}
|
||||
|
||||
u32 bsearch_strg_table(std::string const& key, u32 strg_header) {
|
||||
u32 bsearch_left = read32(strg_header + 0x14);
|
||||
int dist = read32(strg_header + 0x8);
|
||||
while (dist > 0) {
|
||||
int midpoint_offset = (dist * 4) & ~0x7;
|
||||
int half_dist = dist >> 1;
|
||||
std::string test_key = readin_str(read32(bsearch_left + midpoint_offset));
|
||||
if (test_key.compare(key) < 0) {
|
||||
dist -= (1 + half_dist);
|
||||
bsearch_left += midpoint_offset + 8;
|
||||
} else {
|
||||
dist = half_dist;
|
||||
}
|
||||
}
|
||||
return bsearch_left;
|
||||
}
|
||||
|
||||
void patch_strg_entry_mp3(u32 rgn) {
|
||||
u32 strg_header = GPR(31), key_ptr = GPR(4);
|
||||
|
||||
u32 patched_table_addr = rgn == 0 ? 0x80676c00 : 0x8067a400;
|
||||
std::string key = readin_str(key_ptr);
|
||||
if (key == "ShakeOffGandrayda") {
|
||||
u32 bsearch_result = bsearch_strg_table(key, strg_header);
|
||||
std::string found_key = readin_str(read32(bsearch_result));
|
||||
if (found_key == key) {
|
||||
u32 strg_val_index = read32(bsearch_result + 4);
|
||||
u32 strg_val_table = read32(strg_header + 0x1c);
|
||||
write32(patched_table_addr, strg_val_table + 4 * strg_val_index);
|
||||
}
|
||||
}
|
||||
GPR(3) = GPR(31);
|
||||
}
|
||||
}
|
||||
|
||||
void STRGPatch::run_mod(Game game, Region region) {
|
||||
switch (game) {
|
||||
@ -14,50 +57,15 @@ void STRGPatch::run_mod(Game game, Region region) {
|
||||
case Game::PRIME_3_STANDALONE:
|
||||
break;
|
||||
case Game::PRIME_3:
|
||||
run_mod_mp3();
|
||||
run_mod_mp3(region);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void patch_strg_entry(u32) {
|
||||
constexpr auto readin_str = [](u32 str_ptr) {
|
||||
std::ostringstream key_readin;
|
||||
for (char c; (c = read8(str_ptr)); str_ptr++) {
|
||||
key_readin << c;
|
||||
}
|
||||
return key_readin.str();
|
||||
};
|
||||
u32 strg_header = GPR(31), key_ptr = GPR(4);
|
||||
|
||||
std::string key = readin_str(key_ptr);
|
||||
if (key == "ShakeOffGandrayda") {
|
||||
u32 bsearch_left = read32(strg_header + 0x14);
|
||||
int dist = read32(strg_header + 0x8);
|
||||
while (dist > 0) {
|
||||
int midpoint_offset = (dist * 4) & ~0x7;
|
||||
int half_dist = dist >> 1;
|
||||
std::string test_key = readin_str(read32(bsearch_left + midpoint_offset));
|
||||
if (test_key.compare(key) < 0) {
|
||||
dist -= (1 + half_dist);
|
||||
bsearch_left += midpoint_offset + 8;
|
||||
} else {
|
||||
dist = half_dist;
|
||||
}
|
||||
}
|
||||
std::string found_key = readin_str(read32(bsearch_left));
|
||||
if (found_key == key) {
|
||||
u32 strg_val_index = read32(bsearch_left + 4);
|
||||
u32 strg_val_table = read32(strg_header + 0x1c);
|
||||
write32(0x80676c00, strg_val_table + 4 * strg_val_index);
|
||||
}
|
||||
}
|
||||
GPR(3) = GPR(31);
|
||||
}
|
||||
|
||||
void STRGPatch::run_mod_mp3() {
|
||||
u32 addr = 0x80676c00;
|
||||
void STRGPatch::run_mod_mp3(Region region) {
|
||||
u32 addr = region == Region::NTSC_U ? 0x80676c00 : 0x8067a400;
|
||||
char str[] = "&just=center;Mash Jump [&image=0x5FC17B1F30BAA7AE;] to shake off Gandrayda!";
|
||||
for (size_t i = 0; i < sizeof(str); i++) {
|
||||
write8(str[i], addr + i);
|
||||
@ -74,12 +82,15 @@ bool STRGPatch::init_mod(Game game, Region region) {
|
||||
case Game::PRIME_2_GCN:
|
||||
case Game::PRIME_3_STANDALONE:
|
||||
break;
|
||||
case Game::PRIME_3:
|
||||
case Game::PRIME_3: {
|
||||
int vmc_id = PowerPC::RegisterVmcall(patch_strg_entry_mp3);
|
||||
if (region == Region::NTSC_U) {
|
||||
int vmc_id = PowerPC::RegisterVmcall(patch_strg_entry);
|
||||
add_code_change(0x803cc3f4, gen_vmcall(vmc_id, 0));
|
||||
} else if (region == Region::PAL) {
|
||||
add_code_change(0x803cbb10, gen_vmcall(vmc_id, 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public:
|
||||
void on_state_change(ModState old_state) override {}
|
||||
|
||||
private:
|
||||
void run_mod_mp3();
|
||||
void run_mod_mp3(Region region);
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user