Skip to content

Commit

Permalink
Saints Row 1 support & additions to Saints Row 2 (#39)
Browse files Browse the repository at this point in the history
* SR1 fixup.
Patches to allow mouse in-game to work, temporary RS sens fix, / X-axis addition over frametime as the game does so, this fixes sens changing with framerate.

* Havok frametime fix for SR1&2, rename SaintsRow to SaintsRow2

* Pause flag, fix menu & vehicle flag addreses, should fix missions.

* bindings

* Add support for @Tervel1337 SR1 fine aim plugin

* Don't hog GetModule path for fine aim plugin & default havok frametime fix to false

* Slowdown slow_pan_horizontal_multiplier & slow_pan_vertical_multiplier_address

* Update both normal Y axis and unused fine aim Y axis.
This isn't done in the original game as it seems to be unfinished but this is much more preferable.

* isPaused flag, enhances plugin check.

* Improve sens/slow pan multiplier patch

* Better drive cam patch for Saints Row 1

* Port Hold Fine Aim for Saints Row 2
https://github.com/Clippy95/RowInput/blob/8f2dd873c2bccd6d48b7b868cabc36297587f13a/addons/HoldFineAIM.cpp
also nop havok write address for SR2

* Lint havok fix

* Patch to increase vehicle rotation limit for Saints Row 1

* Always apply FOV for SR2

* sniper zoom function address, used to holdfineaim for snipers, since the zoom seems to be different from normal fineaim.

* Sensible max limit for sr1_increase_vehicle_rotation_limit.

* bindings: rename Saints Row to Saints Row 1

---------

Co-authored-by: Clippy95 <[email protected]>
  • Loading branch information
2 people authored and marinesciencedude committed Nov 6, 2024
1 parent fa121b6 commit d51e96d
Show file tree
Hide file tree
Showing 8 changed files with 723 additions and 45 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This is a fork of [emoose's Xenia build](https://github.com/emoose/xenia) as ori
| Halo Reach | TU0/TU1 |
| Halo 4 | TU0/TU8 |
| Crackdown 2 | TU0/TU5 |
| Saints Row | TU1 |
| Saints Row 2 | TU3 |
| Dark Messiah of Might and Magic | Singleplayer & Multiplayer |
| Just Cause | TU0 |
Expand Down
68 changes: 68 additions & 0 deletions bindings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,74 @@ Down = Down
Left = Left
Right = Right

[545107D1 Default - Saints Row 1]
W = LS-Up
S = LS-Down
A = LS-Left
D = LS-Right
CapsLock = Modifier
Ctrl = LS
C = LS
LClick = RT
RClick = LT
Mouse5 = B
Tab = B
F = Y
R = A
Space = X
V = LB
1 = Up
2 = Down
3 = Left
4 = Right
Z = Down
LShift = RB
;Tidle on US keyboard "`"
' = Start
Enter = Start
;Back is unused but for any mods that utilize it.
P = Back
Up = RS-Up
Down = RS-Down
Left = RS-Left
Right = RS-Right
[545107D1 Vehicle - Saints Row 1]
W = A
S = X
A = LS-Left
D = LS-Right
Q = LB
E = RB
CapsLock = Modifier
Ctrl = LS
C = LS
LClick = RT
RClick = LT
Mouse5 = B
Tab = B
F = Y
R = A
Space = LT
V = LB
1 = Up
2 = Down
3 = Left
4 = Right
Z = Down
MWheelDown = Left
MWheelUp = Right
LShift = RB
;Tidle on US keyboard "`"
' = Start
Enter = Start
;Back is unused but for any mods that utilize it.
P = Back
Up = RS-Up
Down = RS-Down
Left = RS-Left
Right = RS-Right

[555307DC Default - Far Cry Instincts Predator]
CapsLock = Modifier
W = LS-Up
Expand Down
105 changes: 99 additions & 6 deletions src/xenia/emulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,34 @@ DEFINE_bool(ge_remove_blur, false,
DEFINE_bool(ge_debug_menu, false,
"(GoldenEye) Enables the debug menu, accessible with LB/1",
"MouseHook");
DEFINE_bool(sr2_better_drive_cam, true,
"(Saints Row 2) unties X rotation from vehicles when "
"auto-centering is disabled akin to GTA IV.",
DEFINE_bool(sr_better_drive_cam, true,
"(Saints Row 1&2) unties X rotation from vehicles when "
"auto-centering is disabled, this makes the camera similar to the "
"GTA series vehicle camera.",
"MouseHook");

DEFINE_bool(sr2_better_handbrake_cam, true,
"(Saints Row 2) unties X rotation from vehicles when "
"handbraking akin to SR1.",
"MouseHook");

DEFINE_bool(
sr2_hold_fine_aim, true,
"(Saints Row 2) Switches fineaim (ADS) from a toggle to hold press.",
"MouseHook");

DEFINE_bool(sr_havok_fix_frametime, false,
"(Saints Row 1&2) Fixes cutscene object synchronization and doors "
"teleporting on high fps, as seen in Juiced Patch. (Causes "
"Performance loss at a higher FPSes.) ",
"MouseHook");

DEFINE_bool(sr1_increase_vehicle_rotation_limit, true,
"(Saints Row 1) Patch vehicle vertical rotation limit to be mostly "
"the same "
"as on-foot.",
"MouseHook");

DEFINE_bool(allow_game_relative_writes, false,
"Not useful to non-developers. Allows code to write to paths "
"relative to game://. Used for "
Expand Down Expand Up @@ -1659,6 +1677,79 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
}
}

if (module->title_id() == 0x545107D1) {
struct SR1PatchOffsets {
uint32_t check_addr;
uint32_t check_value;
uint32_t beNOP;
uint32_t mousefix_addr1;
uint32_t mousefix_addr2;
uint32_t mousefix_addr3;
uint32_t aim_assist_xbtl; // File declares aim_assist values.
uint32_t havok_write_frametime_address1;
uint32_t havok_write_frametime_address2;
uint32_t vehicle_rotationXWrite_addr_start; // lfs f0, (flt_827F9B04 -
// 0x827F99A0)(r31) -- no
// idea how I figured this,
// or why/how it works.
uint32_t vehicle_rotationYLimit_max_read_addr1;
uint32_t vehicle_rotationYLimit_max_read_addr2;
uint32_t vehicle_rotationYLimit_min_read_addr1;
uint32_t max_float_addr_lis1;
uint32_t max_float_addr_lis2;
uint32_t min_float_addr_lis1;
uint32_t write_max_value1; // making it same as on-foot causes the camera
// to clip.
};
std::vector<SR1PatchOffsets> supported_builds = {
// TU1 Release build
{0x82050304, 0x7361696E, 0x60000000, 0x8249db00, 0x8249dd28, 0x8249dd50,
0x82079cbc, 0x82195324, 0x8225BD8C, 0x8211D604, 0x82772D90, 0x8211FC8C,
0x82772DB0, 0xC108C88C, 0xC00BC88C, 0xC0C8B850, 0x8208C88C},
};
for (auto& build : supported_builds) {
auto* test_addr = (xe::be<uint32_t>*)module->memory()->TranslateVirtual(
build.check_addr);
if (*test_addr != build.check_value) {
continue;
}
// Write beNOP to each write address
patch_addr(build.mousefix_addr1, build.beNOP);
patch_addr(build.mousefix_addr2, build.beNOP);
patch_addr(build.mousefix_addr3, build.beNOP);
if (cvars::disable_autoaim && build.aim_assist_xbtl) {
patch_addr(build.aim_assist_xbtl, build.beNOP);
}
if (cvars::sr_havok_fix_frametime &&
build.havok_write_frametime_address1 &&
build.havok_write_frametime_address2) {
patch_addr(build.havok_write_frametime_address1, build.beNOP);
patch_addr(build.havok_write_frametime_address2, build.beNOP);
}
if (cvars::sr_better_drive_cam &&
build.vehicle_rotationXWrite_addr_start) {
uint32_t addr = build.vehicle_rotationXWrite_addr_start;
for (int i = 0; i < 4; ++i) {
patch_addr(addr, build.beNOP);
addr += 0x4;
}
}
if (cvars::sr1_increase_vehicle_rotation_limit &&
build.vehicle_rotationYLimit_max_read_addr1) {
// 827FA3F8 , 827FA3F4 for current rotation limit, maybe lower the max
// value because it clips into the vehicle?
patch_addr(build.vehicle_rotationYLimit_max_read_addr1,
build.max_float_addr_lis1);
patch_addr(build.vehicle_rotationYLimit_max_read_addr2,
build.max_float_addr_lis2);
patch_addr(build.vehicle_rotationYLimit_min_read_addr1,
build.min_float_addr_lis1);
patch_addr(build.write_max_value1, 0xbf000000);
}
break;
}
}

if (module->title_id() == 0x545107FC) {
struct SR2PatchOffsets {
uint32_t check_addr;
Expand Down Expand Up @@ -1702,6 +1793,7 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
uint32_t Vehicle_RotationXWrite_addr1;
uint32_t Vehicle_RotationXWrite_addr2; // Handbrake.
uint32_t aim_assist_xbtl; // File declares aim_assist values.
uint32_t havok_write_frametime_address1;
};

std::vector<SR2PatchOffsets> supported_builds = {
Expand All @@ -1711,7 +1803,7 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
0x8247832c, 0x821a4b84, 0x824e6a68, 0x824e7f50, 0x824e6b8c, 0x82478934,
0x824e6b2c, 0x82478330, 0x82478094, 0x821a4b88, 0x82B7A5AC, 0x82B7A5A8,
0x82B77C04, 0x82B77C08, 0x82B77C0C, 0x82B77C08, 0x82B77C10, 0x821A4D20,
0x821A4D18, 0x821a1f74, 0x821A2A2C, 0x820A61C0},
0x821A4D18, 0x821a1f74, 0x821A2A2C, 0x820A61C0, 0x8221CEAC},
};

for (auto& build : supported_builds) {
Expand Down Expand Up @@ -1751,7 +1843,7 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
patch_addr(build.multiplierread_addr5, build.zero_patch1);
patch_addr(build.sensYvalue_addr1, build.zero_patch1);
patch_addr(build.sensXvalue_addr2, build.zero_patch1);
if (cvars::sr2_better_drive_cam && build.Vehicle_RotationXWrite_addr1) {
if (cvars::sr_better_drive_cam && build.Vehicle_RotationXWrite_addr1) {
patch_addr(build.Vehicle_RotationXWrite_addr1, build.beNOP);
}

Expand All @@ -1762,7 +1854,8 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
if (cvars::disable_autoaim && build.aim_assist_xbtl) {
patch_addr(build.aim_assist_xbtl, build.beNOP);
}

if (cvars::sr_havok_fix_frametime && build.havok_write_frametime_address1)
patch_addr(build.havok_write_frametime_address1, build.beNOP);
break;
}
}
Expand Down
Loading

0 comments on commit d51e96d

Please sign in to comment.