Skip to content

Commit

Permalink
Perfect Dark Zero support (#37)
Browse files Browse the repository at this point in the history
* Perfect Dark Zero support

* Add sway

* Add cover camera

* pause flag

* clamp cover

* Change calculation of FOVscaling for FOV patch

* Patch gun sway

* TU3 support

* Right Stick emulation for intro mission

* lint

* Fix pointer crash

* lint

* Read compile date & version instead of build name

* Platinum Hits verison support, modifier & initial bindings

* Different pointer for Platinum Hits and remove address range check for radians X

* Sniper ADS fov fix

* remove pdz_scale_base_fov_sens cvar

* rebase

* Gun sway edits for ADS

* Turret camera support, only tested for TU3

* Local player address for TU3, fixes coop thanks to @A1eNaz for helping me find it

* Port multi base address to TU0 & Plat hits for coop fix

* universal_address chain for isSpecialCam

* Hovercraft cam support

* Jetpac unsupported note

* Emulate LS with mouse when using gadgets.

* Disable mouse LS emulation if SHIFT is held down

* Jetpac cam support

* Update README.md

---------

Co-authored-by: Clippy95 <[email protected]>
  • Loading branch information
Clippy95 and Clippy95 authored Dec 14, 2024
1 parent cb7a86c commit a07ff93
Show file tree
Hide file tree
Showing 6 changed files with 670 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Mousehook implements mouse input into games by injecting into game memory, most
| Bloody Good Time | | 584109B3 | Fair |
| Postal III | | 4541080F | Fair |
| GoldenEye XBLA | Nov 16th 2007, also renamed as 'Aug 25th 2007' | 584108A9 | Good | <sub> Camera X rotation might not work when using the tank in the Runway and Street level |
| Perfect Dark Zero | TU0,TU3 & Platinum Hits base | 4D5307D3 | Good | <sub> No mousehook for Spycam in <br/>Mousehook bindings break in menus and switches to using HID.Winkey bindings.|
| Perfect Dark XBLA | b33, b52 (TU0) & b102 | 584109C2 | Fair |<sub> Camera doesn't work with the camspy <br/>No mousehook for HoverBike |
| Halo 3 | TU0/TU3 & 08172 'delta' | 4D5307E6 | Fair |
| Halo 3: ODST | | 4D530877 | Fair |
Expand Down
35 changes: 35 additions & 0 deletions bindings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@ Down = Down
Left = Left
Right = Right

[4D5307D3 Default - Perfect Dark Zero]
; Perfect Dark Zero modifier reduces LS movement to 1/2 (ie allows for a 'walk' button)
Shift = Modifier
W = LS-Up
S = LS-Down
A = LS-Left
D = LS-Right
E = A
R = X
Q = LB
F = B
B = B
LClick = RT
RClick = LT
MClick = RB
T = RB
MWheelUp = B
MWheelDown = Y
Mouse4 = Y
Mouse5 = LB
Enter = Start
Tab = Back
1 = Y
2 = Left
3 = Right
4 = Up
5 = Down
Ctrl = LS
C = LS
V = RS
Up = RS-Up
Down = RS-Down
Left = RS-Left
Right = RS-Right

; Configure these binds in-game.
; Sprint = D-PAD LEFT
; Pick Block = D-PAD RIGHT
Expand Down
28 changes: 28 additions & 0 deletions src/xenia/emulator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,34 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
}
}

if (module->title_id() == 0x4D5307D3) {
struct PDZPatchOffsets {
const char* build_string;
uint32_t build_string_addr;
uint32_t gun_y_read_camera_address;
uint32_t gun_x_read_camera_address;
};

std::vector<PDZPatchOffsets> supported_builds{
// TU0 Base version, compiled 9 November 2005
{"09.11.05.0052", 0x820CED70, 0x8253EDA0, 0x8253EDA8},
// TU3 Base version, compiled 19 September 2006
{"19.09.06.0082", 0x820CD9E0, 0x8254E4D8, 0x8254E4E0},
// TU15 (15.0) Platinum Hits, compiled 12 September 2006
{"12.09.06.0081", 0x820CD9C0, 0x8254E508, 0x8254E510}};
for (auto& build : supported_builds) {
const char* build_ptr = reinterpret_cast<const char*>(
module->memory()->TranslateVirtual(build.build_string_addr));
if (strcmp(build_ptr, build.build_string) != 0) {
continue;
}
// Gun sway is read from RS camera movement, we decouple it by moving it's
// pointer to +0xF9C for Y and + 0xFA0 for X.
patch_addr(build.gun_y_read_camera_address, 0xC0230F9C);
patch_addr(build.gun_x_read_camera_address, 0xC0230FA0);
}
}

// Initializing the shader storage in a blocking way so the user doesn't
// miss the initial seconds - for instance, sound from an intro video may
// start playing before the video can be seen if doing this in parallel with
Expand Down
Loading

0 comments on commit a07ff93

Please sign in to comment.