Skip to content

Commit

Permalink
Merge pull request #50 from UltiNaruto/master
Browse files Browse the repository at this point in the history
Added support to unsupported versions
  • Loading branch information
shiiion authored Apr 12, 2021
2 parents d41e507 + 5171cf1 commit 51a5b06
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 50 deletions.
22 changes: 12 additions & 10 deletions Source/Core/Core/PrimeHack/AddressDBInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ void init_db(AddressDB& addr_db) {
addr_db.register_dynamic_address(Game::PRIME_1_GCN, "angular_vel", "player", {rt(0x14c, 0x15c, 0)});
addr_db.register_dynamic_address(Game::PRIME_1_GCN, "firstperson_pitch", "player", {rt(0x3ec, 0x3fc, 0)});
addr_db.register_dynamic_address(Game::PRIME_1_GCN, "ball_state", "player", {rt(0x2f4, 0x304, 0)});
addr_db.register_dynamic_address(Game::PRIME_1_GCN, "freelook_rotation_speed", "tweak_player", { mrt1(0x280) });
addr_db.register_dynamic_address(Game::PRIME_1_GCN, "air_transitional_friction", "tweak_player", { mrt1(0x180) });

// object list = state mgr + x810
// camera mgr = state mgr + x870
Expand Down Expand Up @@ -100,14 +102,14 @@ void init_db(AddressDB& addr_db) {
addr_db.register_dynamic_address(Game::PRIME_2, "area_layers_vector", "state_manager", {mrt1(0x1e38), mrt1(0x8), rt0});


addr_db.register_address(Game::PRIME_2_GCN, "state_manager", 0x803db6e0, 0x803dc900);
addr_db.register_address(Game::PRIME_2_GCN, "tweakgun_offset", -0x6e1c, -0x6e14);
addr_db.register_address(Game::PRIME_2_GCN, "tweak_player_offset", -0x6e3c, -0x6e34);
addr_db.register_address(Game::PRIME_2_GCN, "tweakgui_offset", -0x6e20, -0x6e18);
addr_db.register_address(Game::PRIME_2_GCN, "conn_vec_offset", 0x14, 0x14);
addr_db.register_address(Game::PRIME_2_GCN, "seq_timer_vec_offset", 0x3c, 0x3c);
addr_db.register_address(Game::PRIME_2_GCN, "seq_timer_fire_size", 0x18, 0x18);
addr_db.register_address(Game::PRIME_2_GCN, "seq_timer_time_offset", 0x10, 0x10);
addr_db.register_address(Game::PRIME_2_GCN, "state_manager", 0x803db6e0, 0x803dc900, 0x803de690);
addr_db.register_address(Game::PRIME_2_GCN, "tweakgun_offset", -0x6e1c, -0x6e14, -0x6ddc);
addr_db.register_address(Game::PRIME_2_GCN, "tweak_player_offset", -0x6e3c, -0x6e34, -0x6dfc);
addr_db.register_address(Game::PRIME_2_GCN, "tweakgui_offset", -0x6e20, -0x6e18, -0x6de0);
addr_db.register_address(Game::PRIME_2_GCN, "conn_vec_offset", 0x14, 0x14, 0x14);
addr_db.register_address(Game::PRIME_2_GCN, "seq_timer_vec_offset", 0x3c, 0x3c, 0x3c);
addr_db.register_address(Game::PRIME_2_GCN, "seq_timer_fire_size", 0x18, 0x18, 0x18);
addr_db.register_address(Game::PRIME_2_GCN, "seq_timer_time_offset", 0x10, 0x10, 0x10);
addr_db.register_dynamic_address(Game::PRIME_2_GCN, "camera_manager", "state_manager", {mrt1(0x151c), mrt1(0x14)});
addr_db.register_dynamic_address(Game::PRIME_2_GCN, "object_list", "state_manager", {mrt1(0x810), rt0});
addr_db.register_dynamic_address(Game::PRIME_2_GCN, "world", "state_manager", {mrt1(0x1604), rt0});
Expand Down Expand Up @@ -155,7 +157,7 @@ void init_db(AddressDB& addr_db) {
addr_db.register_address(Game::PRIME_3_STANDALONE, "state_manager", 0x805c4f98, 0x805c7598, 0x805caa58); // +0x1010 object list
addr_db.register_address(Game::PRIME_3_STANDALONE, "tweakgun", 0x8067d78c, 0x8067fdb4, 0x806835fc);
addr_db.register_address(Game::PRIME_3_STANDALONE, "motion_vf", 0x802e2508, 0x802e3be4, 0x802e5ed8);
addr_db.register_address(Game::PRIME_3_STANDALONE, "dna_scanner_vftable", 0x80599b50);
addr_db.register_address(Game::PRIME_3_STANDALONE, "dna_scanner_vftable", 0x80599b50, 0x8059c140, 0x8059f580);
addr_db.register_address(Game::PRIME_3_STANDALONE, "cursor_base", 0x8067dc18, 0x80680240, 0x80683a88);
addr_db.register_address(Game::PRIME_3_STANDALONE, "cursor_dlg_enabled", 0x805c70c7, 0x805c96df, 0x805ccbd7);
addr_db.register_address(Game::PRIME_3_STANDALONE, "boss_info_base", 0x8067c0e4, 0x8067e70c, 0x80681f54);
Expand All @@ -164,7 +166,7 @@ void init_db(AddressDB& addr_db) {
addr_db.register_address(Game::PRIME_3_STANDALONE, "gun_lag_toc_offset", -0x5fb0, -0x5f98, -0x5f68);
addr_db.register_address(Game::PRIME_3_STANDALONE, "powerups_size", 12, 12, 12);
addr_db.register_address(Game::PRIME_3_STANDALONE, "powerups_offset", 0x58, 0x58, 0x58);
addr_db.register_address(Game::PRIME_3_STANDALONE, "bloom_offset", 0x80589410);
addr_db.register_address(Game::PRIME_3_STANDALONE, "bloom_offset", 0x80589410, 0x8058b9d8, 0x8058edd8);
addr_db.register_dynamic_address(Game::PRIME_3_STANDALONE, "camera_manager", "state_manager", {mrt1(0x10), mrt1(0xc), mrt1(0x16)});
addr_db.register_dynamic_address(Game::PRIME_3_STANDALONE, "perspective_info", "camera_manager", {mrt1(0x2), mrt1(0x14), rt0});
addr_db.register_dynamic_address(Game::PRIME_3_STANDALONE, "object_list", "state_manager", {rt0, mrt1(0x1010), rt0});
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Core/PrimeHack/HackManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ void HackManager::run_active_mods() {
active_game = Game::PRIME_2_GCN;
active_region = Region::NTSC_U;
}
else if (region_code == FOURCC('G', '2', 'M', 'J')) {
active_game = Game::PRIME_2_GCN;
active_region = Region::NTSC_J;
}
else if (region_code == FOURCC('G', '2', 'M', 'P')) {
active_game = Game::PRIME_2_GCN;
active_region = Region::PAL;
Expand Down
8 changes: 8 additions & 0 deletions Source/Core/Core/PrimeHack/Mods/ContextSensitiveControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,18 @@ bool ContextSensitiveControls::init_mod(Game game, Region region) {
add_code_change(0x801fdb5c, lis);
add_code_change(0x801fdb64, ori);
add_code_change(0x801fdb6c, lfs);

add_code_change(0x801ffd7c, lis);
add_code_change(0x801ffd80, ori);
add_code_change(0x801ffd84, lfs);
} else if (region == Region::PAL) {
add_code_change(0x801fc5a8, lis);
add_code_change(0x801fc5b0, ori);
add_code_change(0x801fc5b8, lfs);

add_code_change(0x801fe7c8, lis);
add_code_change(0x801fe7cc, ori);
add_code_change(0x801fe7d0, lfs);
}
break;
default:
Expand Down
18 changes: 15 additions & 3 deletions Source/Core/Core/PrimeHack/Mods/DisableHudMemoPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ void DisableHudMemoPopup::init_mod_mp1(Region region) {
add_code_change(0x801ed734, 0x48000018);
add_code_change(0x801ed75c, vmc_fix_time);
add_code_change(0x801cc964, vmc_fix_justification);
} else { // region == Region::NTSC_J
add_code_change(0x801ee014, 0x48000018);
add_code_change(0x801ee03c, vmc_fix_time);
add_code_change(0x801cd208, vmc_fix_justification);
}
}

Expand Down Expand Up @@ -118,7 +122,11 @@ void DisableHudMemoPopup::init_mod_mp3(Game game, Region region) {
} else if (game == Game::PRIME_3_STANDALONE) {
if (region == Region::NTSC_U) {
add_code_change(0x8021fe80, vmc_restart_audio);
} else {}
} else if (region == Region::PAL) {
add_code_change(0x80220f10, vmc_restart_audio);
} else { // region == Region::NTSC_J
add_code_change(0x8022251c, vmc_restart_audio);
}
}
}

Expand All @@ -135,14 +143,18 @@ bool DisableHudMemoPopup::init_mod(Game game, Region region) {
add_code_change(0x801f3354, 0x48000018);
} else if (region == Region::PAL) {
add_code_change(0x801f586c, 0x48000018);
} else {}
} else { // region == Region::NTSC_J
add_code_change(0x801f2368, 0x48000018);
}
break;
case Game::PRIME_2_GCN:
if (region == Region::NTSC_U) {
add_code_change(0x800bb10c, 0x48000018);
} else if (region == Region::PAL) {
add_code_change(0x800bb1a0, 0x48000018);
} else {}
} else { // region == Region::NTSC_J
add_code_change(0x800bbe9c, 0x48000018);
}
break;
case Game::PRIME_3:
case Game::PRIME_3_STANDALONE:
Expand Down
85 changes: 58 additions & 27 deletions Source/Core/Core/PrimeHack/Mods/FpsControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void FpsControls::run_mod(Game game, Region region) {
run_mod_mp3(game, region);
break;
case Game::PRIME_1_GCN:
run_mod_mp1_gc();
run_mod_mp1_gc(region);
break;
case Game::PRIME_2_GCN:
run_mod_mp2_gc();
Expand Down Expand Up @@ -303,7 +303,7 @@ void FpsControls::run_mod_mp1(Region region) {
}
}

void FpsControls::run_mod_mp1_gc() {
void FpsControls::run_mod_mp1_gc(Region region) {
u8 version = read8(0x80000007);
if (version != 0) {
return;
Expand Down Expand Up @@ -360,6 +360,14 @@ void FpsControls::run_mod_mp1_gc() {
writef32(0, (tweak_player + 0x84) + i * 4);
writef32(0, (tweak_player + 0x84) + i * 4 - 32);
}

LOOKUP_DYN(freelook_rotation_speed);
LOOKUP_DYN(air_transitional_friction);

// Freelook rotation speed tweak
write32(0x4f800000, freelook_rotation_speed);
// Air translational friction changes to make diagonal strafe match normal speed
writef32(0.25f, air_transitional_friction);
}

void FpsControls::run_mod_mp2(Region region) {
Expand Down Expand Up @@ -1465,7 +1473,6 @@ void FpsControls::init_mod_mp1_gc(Region region) {
add_code_change(0x80014820, 0x4e800020);
add_code_change(0x8000e73c, 0x60000000);
add_code_change(0x8000f810, 0x48000244);
add_code_change(0x8045c488, 0x4f800000);
// When attached to a grapple point and spinning around it
// the player's yaw is adjusted, this ensures only position is updated
// Grapple point yaw fix
Expand All @@ -1489,7 +1496,6 @@ void FpsControls::init_mod_mp1_gc(Region region) {
add_code_change(0x80015258, 0x4e800020);
add_code_change(0x8000ec64, 0x60000000);
add_code_change(0x8000fd20, 0x4800022c);
add_code_change(0x803e43b4, 0x4f800000);
// Grapple point yaw fix
add_code_change(0x8016fc54, 0x7fa3eb78);
add_code_change(0x8016fc58, 0x38810064); // 6c-8 = 64
Expand All @@ -1502,7 +1508,6 @@ void FpsControls::init_mod_mp1_gc(Region region) {
add_code_change(0x80017884, 0x9afd09d4, "show_crosshair"); // stb r23, 0x9d4(r29)
add_code_change(0x80017888, 0x4e800020, "show_crosshair"); // blr


add_strafe_code_mp1_pal();
} else {}
}
Expand Down Expand Up @@ -1572,11 +1577,11 @@ void FpsControls::init_mod_mp2_gc(Region region) {
if (region == Region::NTSC_U) {
add_code_change(0x801b00b4, 0x48000050);
add_code_change(0x801aef58, 0x60000000);
//add_code_change(0x80015ed8, 0x4e800020);
add_code_change(0x800129c8, 0x4e800020);
add_code_change(0x801af160, 0x60000000);
add_code_change(0x801b0248, 0x48000078);
add_code_change(0x801af450, 0x48000a34);
// Enable strafing with left/right on L-Stick
add_code_change(0x8018846c, 0xc022a5b0);
add_code_change(0x80188104, 0x4800000c);
// Grapple point yaw fix
Expand All @@ -1590,15 +1595,36 @@ void FpsControls::init_mod_mp2_gc(Region region) {
add_code_change(0x80015ee8, 0x4e800020, "show_crosshair"); // blr

add_code_change(0x800614f8, 0xc022d3e8);
} else if (region == Region::NTSC_J) {
add_code_change(0x801b1e6c, 0x48000050);
add_code_change(0x801b0d10, 0x60000000);
add_code_change(0x80013414, 0x4e800020);
add_code_change(0x801b0f18, 0x60000000);
add_code_change(0x801b2000, 0x48000078);
add_code_change(0x801b1208, 0x48000a34);
// Enable strafing with left/right on L-Stick
add_code_change(0x80189f70, 0xc022a5c8);
add_code_change(0x80189c08, 0x4800000c);
// Grapple point yaw fix
add_code_change(0x8011e918, 0x389d0054);
add_code_change(0x8011e91c, 0x4bf2cd91);

add_code_change(0x8001695c, 0x3aa00001, "show_crosshair"); // li r21, 1
add_code_change(0x80016960, 0x8add1268, "show_crosshair"); // lbz r22, 0x1268(r29)
add_code_change(0x80016964, 0x52b63672, "show_crosshair"); // rlwimi r22, r21, 6, 25, 25 (00000001)
add_code_change(0x80016968, 0x9add1268, "show_crosshair"); // stb r22, 0x1268(r29)
add_code_change(0x8001696c, 0x4e800020, "show_crosshair"); // blr

add_code_change(0x80061fc0, 0xc022d400);
} else if (region == Region::PAL) {
add_code_change(0x801b03c0, 0x48000050);
add_code_change(0x801af264, 0x60000000);
//add_code_change(0x80015f74, 0x4e800020);
add_code_change(0x80012a2c, 0x4e800020);
add_code_change(0x801af46c, 0x60000000);
add_code_change(0x801b0554, 0x48000078);
add_code_change(0x801af75c, 0x48000a34);
add_code_change(0x80188754, 0xc022d16c);
// Enable strafing with left/right on L-Stick
add_code_change(0x80188754, 0xc022a5a0);
add_code_change(0x801883ec, 0x4800000c);
// Grapple point yaw fix
add_code_change(0x8011dbf8, 0x389d0054);
Expand All @@ -1610,7 +1636,7 @@ void FpsControls::init_mod_mp2_gc(Region region) {
add_code_change(0x80015f80, 0x9add1268, "show_crosshair"); // stb r22, 0x1268(r29)
add_code_change(0x80015f84, 0x4e800020, "show_crosshair"); // blr

add_code_change(0x800615f8, 0xc022d3c0);
add_code_change(0x800615f8, 0xc022d3c0); // not c022d3d8 ???
} else {}
}

Expand Down Expand Up @@ -1696,24 +1722,26 @@ void FpsControls::init_mod_mp3_standalone(Region region) {
// Steps over bounds checking on the reticle
add_code_change(0x80017290, 0x48000120);
} else if (region == Region::NTSC_J) {
// Out of comission, fix me!!
//add_code_change(0x80081018, 0xec010072);
//add_code_change(0x80153ed4, 0x60000000);
//add_code_change(0x80153eac, 0x60000000);
//add_code_change(0x8013a054, 0x60000000);
//add_code_change(0x8013969c, 0x60000000);
//add_code_change(0x8000ae44, 0x4bffaa3d);
//add_code_change(0x8008129c, 0x60000000);
//add_code_change(0x80080320, 0x480000e4);
//add_code_change(0x80184fd4, 0x60000000);

//add_code_change(0x80075f0c, 0x80061958, "visor_menu");

//// Grapple Lasso
//add_grapple_lasso_code_mp3(0x800E003C, 0x80176B20, 0x80177908);

//add_control_state_hook_mp3(0x80005880, Region::NTSC_J);
//add_grapple_slide_code_mp3(0x801849e8);
add_code_change(0x80081018, 0xec010072);
add_code_change(0x80153ed4, 0x60000000);
add_code_change(0x80153eac, 0x60000000);
add_code_change(0x8013a054, 0x60000000);
add_code_change(0x8013969c, 0x60000000);
add_code_change(0x8000ae44, 0x4bffaa3d);
add_code_change(0x8008129c, 0x60000000);
add_code_change(0x80080320, 0x480000e4);
add_code_change(0x80184fd4, 0x60000000);

add_code_change(0x80075f0c, 0x80061958, "visor_menu");

// Grapple Lasso
add_grapple_lasso_code_mp3(0x800E003C, 0x80176B20, 0x80177908);

add_control_state_hook_mp3(0x80005880, Region::NTSC_J);
add_grapple_slide_code_mp3(0x801849e8);

// Steps over bounds checking on the reticle
add_code_change(0x80017258, 0x48000120);
} else if (region == Region::PAL) {
add_code_change(0x80080e84, 0xec010072);
add_code_change(0x80152d50, 0x60000000);
Expand All @@ -1732,6 +1760,9 @@ void FpsControls::init_mod_mp3_standalone(Region region) {

add_control_state_hook_mp3(0x80005880, Region::PAL);
add_grapple_slide_code_mp3(0x801837dc);

// Steps over bounds checking on the reticle
add_code_change(0x80017258, 0x48000120);
} else {}
has_beams = false;
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/PrimeHack/Mods/FpsControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FpsControls : public PrimeMod {
void run_mod_mp1(Region region);
void run_mod_mp2(Region region);
void run_mod_mp3(Game game, Region region);
void run_mod_mp1_gc();
void run_mod_mp1_gc(Region region);
void run_mod_mp2_gc();

void CheckBeamVisorSetting(Game game);
Expand Down Expand Up @@ -66,7 +66,6 @@ class FpsControls : public PrimeMod {

// Required due to MP3
bool has_beams;
bool fighting_ridley;

// We store our pitch value interally to have full control over it
float pitch;
Expand Down
13 changes: 7 additions & 6 deletions Source/Core/Core/PrimeHack/Mods/Invulnerability.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,20 @@ class Invulnerability : public PrimeMod {
add_code_change(0x8014d258, 0x60000000);
}
else { // region == Region::NTSC-J
// This was never tested on a new game
//add_code_change(0x8014b0ac, 0x3c60804e);
//add_code_change(0x8014b0b0, 0x38633cf8);
//add_code_change(0x8014b0b4, 0x4e800020);
add_code_change(0x8014b0d4, 0x4800000c);
add_code_change(0x8014b0ec, 0x60000000);
}
break;
case Game::PRIME_2_GCN:
if (region == Region::NTSC_U) {
add_code_change(0x8000ec08, 0x3c60803d);
add_code_change(0x8000ec0c, 0x6063aa28);
add_code_change(0x8000ec10, 0x4e800020);
}
else if (region == Region::PAL) {
} else if (region == Region::NTSC_J) {
add_code_change(0x8000f624, 0x3c60803d);
add_code_change(0x8000f628, 0x6063d9d8);
add_code_change(0x8000f62c, 0x4e800020);
} else if (region == Region::PAL) {
add_code_change(0x8000ec4c, 0x3c60803d);
add_code_change(0x8000ec50, 0x6063bc48);
add_code_change(0x8000ec54, 0x4e800020);
Expand Down
9 changes: 9 additions & 0 deletions Source/Core/Core/PrimeHack/Mods/Noclip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,15 @@ bool Noclip::init_mod(Game game, Region region) {
add_code_change(0x801865f4, 0xd0210088);
add_code_change(0x801865f8, 0xd0010078);
add_code_change(0x801865fc, 0x4bec395d);
} else if (region == Region::NTSC_J) {
noclip_code_mp2_gc(0x803dfb7c, 0x80420000, 0x8004b6ac);
add_code_change(0x801880d8, 0x60000000);
add_code_change(0x801880e0, 0x60000000);
add_code_change(0x801880e8, 0x60000000);
add_code_change(0x801880f0, 0xd0410098);
add_code_change(0x801880f4, 0xd0210088);
add_code_change(0x801880f8, 0xd0010078);
add_code_change(0x801880fc, 0x4bec2939);
} else if (region == Region::PAL) {
noclip_code_mp2_gc(0x803dddfc, 0x80420000, 0x8004ad44);
add_code_change(0x801868bc, 0x60000000);
Expand Down
10 changes: 8 additions & 2 deletions Source/Core/Core/PrimeHack/Mods/PortalSkipMP2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ bool PortalSkipMP2::init_mod(Game game, Region region) {
} else if (region == Region::PAL) {
add_code_change(0x801e8e60, fix_vmc, "disable_portal_cutscene");
add_code_change(0x801e8e74, 0x48000114, "disable_portal_cutscene");
}
} else { // region == Region::NTSC_J
add_code_change(0x801e5948, fix_vmc, "disable_portal_cutscene");
add_code_change(0x801e5950, 0x48000114, "disable_portal_cutscene");
}
} else if (game == Game::PRIME_2_GCN) {
const int fix_portal_terminal_fn = PowerPC::RegisterVmcall(fix_layer_bits);
const u32 fix_vmc = gen_vmcall(fix_portal_terminal_fn, 0);
Expand All @@ -160,7 +163,10 @@ bool PortalSkipMP2::init_mod(Game game, Region region) {
} else if (region == Region::PAL) {
add_code_change(0x800b7228, fix_vmc, "disable_portal_cutscene");
add_code_change(0x800b7240, 0x48000120, "disable_portal_cutscene");
}
} else { // region == Region::NTSC_J
add_code_change(0x800b7f24, fix_vmc, "disable_portal_cutscene");
add_code_change(0x800b7f3c, 0x48000120, "disable_portal_cutscene");
}
} else {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/PrimeHack/Mods/SkipCutscene.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class SkipCutscene : public PrimeMod {
case Game::PRIME_2_GCN:
if (region == Region::NTSC_U) {
add_return_one(0x80142340);
} else if (region == Region::NTSC_J) {
add_return_one(0x80143330);
} else if (region == Region::PAL) {
add_return_one(0x8014257c);
}
Expand Down
Loading

0 comments on commit 51a5b06

Please sign in to comment.