Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saints Row 1 support & additions to Saints Row 2 #39

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions bindings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,70 @@ 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 = Left
2 = 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 = Left
2 = 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