Skip to content

Commit 50f6f1f

Browse files
Clippy95Clippy95
authored andcommitted
Duel wield sway & FOV for PD, fix modifier for GE&PD (#38)
Co-authored-by: Clippy95 <[email protected]>
1 parent e925723 commit 50f6f1f

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed

src/xenia/emulator.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1558,8 +1558,10 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path,
15581558
0xD19F16A4, // stfs f12, 0x16A4(r31)
15591559
0xD19F1690, // stfs f12, 0x1690(r31)
15601560
0xD15F1694, // stfs f10, 0x1694(r31)
1561-
0xD0FF0CFC, // stfs f7, 0xCFC(r31)
1562-
0xD0BF0D00 // stfs f5, 0xD00(r31)
1561+
0xD0FF0CFC, // stfs f7, 0xCFC(r31) // Right gun x
1562+
0xD0BF0D00, // stfs f5, 0xD00(r31) // Right gun y
1563+
0xD07F14A0, // stfs f3, 0x14A0(r31) // Left gun x
1564+
0xD05F14A4 // stfs f2, 0x14A4(r31) // Left gun y
15631565
};
15641566

15651567
int patched = 0;

src/xenia/hid/winkey/hookables/goldeneye.cc

+46-13
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ struct RareGameBuildAddrs {
6868
uint32_t player_offset_gun_y;
6969
uint32_t player_offset_aim_mode;
7070
uint32_t player_offset_aim_multiplier;
71+
uint32_t player_offset_gun_left_x;
72+
uint32_t player_offset_gun_left_y;
7173
};
7274

7375
std::map<GoldeneyeGame::GameBuild, RareGameBuildAddrs> supported_builds = {
@@ -91,24 +93,27 @@ std::map<GoldeneyeGame::GameBuild, RareGameBuildAddrs> supported_builds = {
9193
// unfortunately gets triggered when health bar appears...
9294
{GoldeneyeGame::GameBuild::PerfectDark_Devkit_33,
9395
{0x825CBC59, 0x30303333, 0, 0, 0x82620E08, 0, 0x826284C4, 0x1A4C, 0x0,
94-
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0}},
96+
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0x179C, 0x14A0,
97+
0x14A4}},
9598
{GoldeneyeGame::GameBuild::PerfectDark_Release_52,
9699
{0x825EC0E5, 0x30303532, 0, 0, 0x826419C0, 0, 0x8264909C, 0x1A4C, 0x0,
97-
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0}},
100+
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0x179C, 0x14A0,
101+
0x14A4}},
98102
{GoldeneyeGame::GameBuild::PerfectDark_Devkit_102,
99103
{0x825EC0E5, 0x30313032, 0, 0, 0x82641A80, 0, 0x82649274, 0x1A4C, 0x0,
100-
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0}},
104+
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0x179C, 0x14A0,
105+
0x14A4}},
101106
// TODO: test these!
102107
/*
103108
{
104109
GoldeneyeGame::GameBuild::PerfectDark_Release_104,
105110
{0x825EC0D5, 0x30313034, 0, 0, 0x82641A80, 0, 0x82649264, 0x1A4C, 0x0,
106-
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0}
111+
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0, 0x14A0, 0x14A4}
107112
},
108113
{
109114
GoldeneyeGame::GameBuild::PerfectDark_Release_107,
110115
{0x825FC25D, 0x30313037, 0, 0, 0x8265A200, 0, 0x826619E4, 0x1A4C, 0x0,
111-
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0}
116+
0x14C, 0x15C, 0x1690, 0x1694, 0xCFC, 0xD00, 0x128, 0, 0x14A0, 0x14A4}
112117
},*/
113118
};
114119

@@ -139,7 +144,7 @@ bool GoldeneyeGame::DoHooks(uint32_t user_index, RawInputState& input_state,
139144
if (!IsGameSupported()) {
140145
return false;
141146
}
142-
147+
auto title_id = kernel_state()->title_id();
143148
auto& game_addrs = supported_builds[game_build_];
144149

145150
// Move menu selection crosshair
@@ -290,6 +295,17 @@ bool GoldeneyeGame::DoHooks(uint32_t user_index, RawInputState& input_state,
290295
xe::be<float>* player_gun_y =
291296
(xe::be<float>*)(player + game_addrs.player_offset_gun_y);
292297

298+
// PD Duel Wield
299+
300+
static xe::be<float>* player_gun_left_x;
301+
static xe::be<float>* player_gun_left_y;
302+
if (title_id == kTitleIdPerfectDark) {
303+
player_gun_left_x =
304+
(xe::be<float>*)(player + game_addrs.player_offset_gun_left_x);
305+
player_gun_left_y =
306+
(xe::be<float>*)(player + game_addrs.player_offset_gun_left_y);
307+
}
308+
293309
uint32_t player_aim_mode =
294310
*(xe::be<uint32_t>*)(player + game_addrs.player_offset_aim_mode);
295311

@@ -298,6 +314,10 @@ bool GoldeneyeGame::DoHooks(uint32_t user_index, RawInputState& input_state,
298314
// Entering aim mode, reset gun position
299315
*player_gun_x = 0;
300316
*player_gun_y = 0;
317+
if (title_id == kTitleIdPerfectDark) {
318+
*player_gun_left_x = 0;
319+
*player_gun_left_y = 0;
320+
}
301321
}
302322
// Always reset crosshair after entering/exiting aim mode
303323
// Otherwise non-aim-mode will still fire toward it...
@@ -360,6 +380,10 @@ bool GoldeneyeGame::DoHooks(uint32_t user_index, RawInputState& input_state,
360380
*player_crosshair_y = chY;
361381
*player_gun_x = (chX * gun_multiplier);
362382
*player_gun_y = (chY * gun_multiplier);
383+
if (title_id == kTitleIdPerfectDark) {
384+
*player_gun_left_x = (chX * gun_multiplier);
385+
*player_gun_left_y = (chY * gun_multiplier);
386+
}
363387

364388
// Turn camera when crosshair is past a certain point
365389
float camX = (float)*player_cam_x;
@@ -490,6 +514,11 @@ bool GoldeneyeGame::DoHooks(uint32_t user_index, RawInputState& input_state,
490514
*player_crosshair_y = (gY * crosshair_multiplier);
491515
*player_gun_x = gX;
492516
*player_gun_y = gY;
517+
518+
if (title_id == kTitleIdPerfectDark) {
519+
*player_gun_left_x = gX;
520+
*player_gun_left_y = gY;
521+
}
493522
}
494523

495524
return true;
@@ -528,16 +557,20 @@ bool GoldeneyeGame::ModifierKeyHandler(uint32_t user_index,
528557
float thumb_lx = (int16_t)out_state->gamepad.thumb_lx;
529558
float thumb_ly = (int16_t)out_state->gamepad.thumb_ly;
530559

531-
// Work out angle from the current stick values
532-
float angle = atan2f(thumb_ly, thumb_lx);
560+
if (thumb_lx != 0 ||
561+
thumb_ly !=
562+
0) { // Required otherwise stick is pushed to the right by default.
533563

534-
// Sticks get set to SHRT_MAX if key pressed, use half of that
535-
float distance = (float)SHRT_MAX;
536-
distance /= 2;
564+
// Work out angle from the current stick values
565+
float angle = atan2f(thumb_ly, thumb_lx);
537566

538-
out_state->gamepad.thumb_lx = (int16_t)(distance * cosf(angle));
539-
out_state->gamepad.thumb_ly = (int16_t)(distance * sinf(angle));
567+
// Sticks get set to SHRT_MAX if key pressed, use half of that
568+
float distance = (float)SHRT_MAX;
569+
distance /= 2;
540570

571+
out_state->gamepad.thumb_lx = (int16_t)(distance * cosf(angle));
572+
out_state->gamepad.thumb_ly = (int16_t)(distance * sinf(angle));
573+
}
541574
// Return true to signal that we've handled the modifier, so default modifier
542575
// won't be used
543576
return true;

0 commit comments

Comments
 (0)