mirror of
https://github.com/Kekun/primehack.git
synced 2024-06-02 20:17:41 -04:00
Gandrayda fix mp3 trilogy NTSC
This commit is contained in:
parent
a31962eecc
commit
e5631ed351
|
@ -505,6 +505,7 @@ add_library(core
|
|||
PrimeHack/Mods/FriendVouchers.h
|
||||
PrimeHack/Mods/DisableHudMemoPopup.cpp
|
||||
PrimeHack/Mods/ElfModLoader.cpp
|
||||
PrimeHack/Mods/STRGPatch.cpp
|
||||
PrimeHack/EmuVariableManager.cpp
|
||||
PrimeHack/HackConfig.cpp
|
||||
PrimeHack/HackManager.cpp
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "Core/PrimeHack/Mods/Noclip.h"
|
||||
#include "Core/PrimeHack/Mods/SkipCutscene.h"
|
||||
#include "Core/PrimeHack/Mods/SpringballButton.h"
|
||||
#include "Core/PrimeHack/Mods/STRGPatch.h"
|
||||
#include "Core/PrimeHack/Mods/ViewModifier.h"
|
||||
#include "Core/PrimeHack/Mods/ContextSensitiveControls.h"
|
||||
#include "Core/PrimeHack/Mods/FriendVouchers.h"
|
||||
|
@ -102,6 +103,7 @@ void InitializeHack() {
|
|||
hack_mgr.add_mod("unlock_hypermode", std::make_unique<UnlockHypermode>());
|
||||
hack_mgr.add_mod("map_controller", std::make_unique<MapController>());
|
||||
hack_mgr.add_mod("motd", std::make_unique<Motd>());
|
||||
hack_mgr.add_mod("strg_patch", std::make_unique<STRGPatch>());
|
||||
|
||||
hack_mgr.enable_mod("skip_cutscene");
|
||||
hack_mgr.enable_mod("fov_modifier");
|
||||
|
@ -109,6 +111,7 @@ void InitializeHack() {
|
|||
hack_mgr.enable_mod("bloom_intensity");
|
||||
hack_mgr.enable_mod("map_controller");
|
||||
hack_mgr.enable_mod("motd");
|
||||
hack_mgr.enable_mod("strg_patch");
|
||||
|
||||
// Enable no PrimeHack control mods
|
||||
if (!Config::Get(Config::PRIMEHACK_ENABLE))
|
||||
|
|
|
@ -1814,6 +1814,10 @@ void FpsControls::init_mod_mp2_gc(Region region) {
|
|||
} else {}
|
||||
}
|
||||
|
||||
void wiimote_shake_override(u32) {
|
||||
GPR(26) = CheckJump() ? 1 : 0;
|
||||
}
|
||||
|
||||
void FpsControls::init_mod_mp3(Region region) {
|
||||
prime::GetVariableManager()->register_variable("grapple_lasso_state");
|
||||
prime::GetVariableManager()->register_variable("grapple_hand_x");
|
||||
|
@ -1821,6 +1825,7 @@ 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);
|
||||
|
@ -1841,6 +1846,7 @@ 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);
|
||||
|
|
89
Source/Core/Core/PrimeHack/Mods/STRGPatch.cpp
Normal file
89
Source/Core/Core/PrimeHack/Mods/STRGPatch.cpp
Normal file
|
@ -0,0 +1,89 @@
|
|||
#include "Core/PrimeHack/Mods/STRGPatch.h"
|
||||
#include "Core/PrimeHack/PrimeUtils.h"
|
||||
|
||||
namespace prime {
|
||||
|
||||
void STRGPatch::run_mod(Game game, Region region) {
|
||||
switch (game) {
|
||||
case Game::PRIME_1:
|
||||
case Game::PRIME_1_GCN:
|
||||
case Game::PRIME_1_GCN_R1:
|
||||
case Game::PRIME_1_GCN_R2:
|
||||
case Game::PRIME_2:
|
||||
case Game::PRIME_2_GCN:
|
||||
case Game::PRIME_3_STANDALONE:
|
||||
break;
|
||||
case Game::PRIME_3:
|
||||
run_mod_mp3();
|
||||
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;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
bool STRGPatch::init_mod(Game game, Region region) {
|
||||
switch (game) {
|
||||
case Game::PRIME_1:
|
||||
case Game::PRIME_1_GCN:
|
||||
case Game::PRIME_1_GCN_R1:
|
||||
case Game::PRIME_1_GCN_R2:
|
||||
case Game::PRIME_2:
|
||||
case Game::PRIME_2_GCN:
|
||||
case Game::PRIME_3_STANDALONE:
|
||||
break;
|
||||
case Game::PRIME_3:
|
||||
if (region == Region::NTSC_U) {
|
||||
int vmc_id = PowerPC::RegisterVmcall(patch_strg_entry);
|
||||
add_code_change(0x803cc3f4, gen_vmcall(vmc_id, 0));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
18
Source/Core/Core/PrimeHack/Mods/STRGPatch.h
Normal file
18
Source/Core/Core/PrimeHack/Mods/STRGPatch.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "Core/PrimeHack/PrimeMod.h"
|
||||
#include "Core/PrimeHack/Transform.h"
|
||||
|
||||
namespace prime {
|
||||
|
||||
class STRGPatch : public PrimeMod {
|
||||
public:
|
||||
void run_mod(Game game, Region region) override;
|
||||
bool init_mod(Game game, Region region) override;
|
||||
void on_state_change(ModState old_state) override {}
|
||||
|
||||
private:
|
||||
void run_mod_mp3();
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue