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

Perfect Dark Zero support #37

Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
pause flag
Clippy95 committed Dec 12, 2024
commit 0d08feb5c9bdd9269627036a74d0ea229aad65a9
19 changes: 18 additions & 1 deletion src/xenia/hid/winkey/hookables/PerfectDarkZero.cc
Original file line number Diff line number Diff line change
@@ -46,12 +46,13 @@ struct GameBuildAddrs {
// with a patch.
uint32_t gun_x_offset;
uint32_t fovscale_address;
uint32_t pause_offset;
};

std::map<PerfectDarkZeroGame::GameBuild, GameBuildAddrs> supported_builds{
{PerfectDarkZeroGame::GameBuild::PerfectDarkZero_TU0,
{"CLIENT.Ph.Rare-PerfectDarkZero", 0x820BD7A4, 0x82D2AD38, 0x16A7, 0x150,
0x1674, 0x1670, 0xF9C, 0xFA0, 0x82E1B930}}};
0x1674, 0x1670, 0xF9C, 0xFA0, 0x82E1B930, 0x16A3}}};

PerfectDarkZeroGame::~PerfectDarkZeroGame() = default;

@@ -113,6 +114,8 @@ bool PerfectDarkZeroGame::DoHooks(uint32_t user_index,
// Not in game
return false;
}

if (IsPaused()) return false;
xe::be<uint32_t> x_address;
bool in_cover = InCover();

@@ -255,6 +258,20 @@ bool PerfectDarkZeroGame::DoHooks(uint32_t user_index,
return true;
}

bool PerfectDarkZeroGame::IsPaused() {
xe::be<uint32_t>* base_address =
kernel_memory()->TranslateVirtual<xe::be<uint32_t>*>(
supported_builds[game_build_].base_address);

uint8_t* pause_flag = kernel_memory()->TranslateVirtual<uint8_t*>(
*base_address + supported_builds[game_build_].pause_offset);
if (*pause_flag != 0) {
return true;
} else {
return false;
}
}

bool PerfectDarkZeroGame::InCover() {
xe::be<uint32_t>* base_address =
kernel_memory()->TranslateVirtual<xe::be<uint32_t>*>(
2 changes: 2 additions & 0 deletions src/xenia/hid/winkey/hookables/PerfectDarkZero.h
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ class PerfectDarkZeroGame : public HookableGame {
bool DoHooks(uint32_t user_index, RawInputState& input_state,
X_INPUT_STATE* out_state);

bool IsPaused();

bool InCover();

std::string ChooseBinds();