mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-08-18 21:17:34 -04:00
Add and implement all remaining axis inversion settings (#41)
* Add and implement all remaining axis inversion settings * Improve third person inversion description, move enum * Fix X axis inversion with analog camera * formatting * Remove boot map patch + fix newlines * invert vanilla camera properly * Fix comment * add more comments * fix demos and add wrapper functions * rename analog camera mode to third person camera mode * Fix first person Y inversion for demos (oops) * Change phrasing * reorder options
This commit is contained in:
@@ -130,7 +130,7 @@ void recomp_analog_camera_get(f32 *x, f32 *y) {
|
||||
s32 inverted_x, inverted_y;
|
||||
recomp_get_camera_inputs(&input_x, &input_y);
|
||||
recomp_get_analog_inverted_axes(&inverted_x, &inverted_y);
|
||||
*x = input_x * (inverted_x ? -1.0f : 1.0f);
|
||||
*x = input_x * (inverted_x ? 1.0f : -1.0f);
|
||||
*y = input_y * (inverted_y ? -1.0f : 1.0f);
|
||||
}
|
||||
|
||||
@@ -146,6 +146,69 @@ f32 recomp_analog_camera_get_y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
s32 recomp_get_third_person_inverted_x() {
|
||||
s32 inverted_x, inverted_y;
|
||||
if (recomp_in_demo_playback_game_mode()) {
|
||||
inverted_x = TRUE;
|
||||
} else {
|
||||
recomp_get_analog_inverted_axes(&inverted_x, &inverted_y);
|
||||
}
|
||||
|
||||
return inverted_x;
|
||||
}
|
||||
|
||||
s32 recomp_get_third_person_inverted_y() {
|
||||
s32 inverted_x, inverted_y;
|
||||
if (recomp_in_demo_playback_game_mode()) {
|
||||
inverted_y = FALSE;
|
||||
} else {
|
||||
recomp_get_analog_inverted_axes(&inverted_x, &inverted_y);
|
||||
}
|
||||
|
||||
return inverted_y;
|
||||
}
|
||||
|
||||
s32 recomp_get_flying_and_swimming_inverted_x() {
|
||||
s32 inverted_x, inverted_y;
|
||||
if (recomp_in_demo_playback_game_mode()) {
|
||||
inverted_x = FALSE;
|
||||
} else {
|
||||
recomp_get_flying_and_swimming_inverted_axes(&inverted_x, &inverted_y);
|
||||
}
|
||||
return inverted_x;
|
||||
}
|
||||
|
||||
s32 recomp_get_flying_and_swimming_inverted_y() {
|
||||
s32 inverted_x, inverted_y;
|
||||
if (recomp_in_demo_playback_game_mode()) {
|
||||
inverted_y = TRUE;
|
||||
} else {
|
||||
recomp_get_flying_and_swimming_inverted_axes(&inverted_x, &inverted_y);
|
||||
}
|
||||
return inverted_y;
|
||||
}
|
||||
|
||||
s32 recomp_get_first_person_inverted_x() {
|
||||
s32 inverted_x, inverted_y;
|
||||
if (recomp_in_demo_playback_game_mode()) {
|
||||
inverted_x = TRUE;
|
||||
} else {
|
||||
recomp_get_first_person_inverted_axes(&inverted_x, &inverted_y);
|
||||
}
|
||||
return inverted_x;
|
||||
}
|
||||
|
||||
s32 recomp_get_first_person_inverted_y() {
|
||||
s32 inverted_x, inverted_y;
|
||||
if (recomp_in_demo_playback_game_mode()) {
|
||||
inverted_y = FALSE;
|
||||
} else {
|
||||
recomp_get_first_person_inverted_axes(&inverted_x, &inverted_y);
|
||||
}
|
||||
return inverted_y;
|
||||
}
|
||||
|
||||
|
||||
// @recomp Check whether the analog camera stick is currently held.
|
||||
bool recomp_analog_camera_held() {
|
||||
if (recomp_analog_camera_enabled() && recomp_analog_camera_allowed()) {
|
||||
@@ -175,20 +238,30 @@ void recomp_analog_camera_update() {
|
||||
}
|
||||
|
||||
// @recomp Updates the current yaw based on the analog camera's horizontal movement.
|
||||
// Also allows axis inversion for vanilla (non-analog) camera.
|
||||
RECOMP_PATCH int func_8029105C(s32 arg0) {
|
||||
if (func_80298850())
|
||||
return FALSE;
|
||||
|
||||
// @recomp: Allow camera axis inversion on the vanilla camera
|
||||
float axisInversionModifier = -1;
|
||||
bool inverted_x = recomp_get_third_person_inverted_x();
|
||||
if (inverted_x) {
|
||||
axisInversionModifier = 1;
|
||||
}
|
||||
|
||||
// @recomp Update the analog camera input.
|
||||
recomp_analog_camera_update();
|
||||
|
||||
if (bainput_should_rotate_camera_left() && ncDynamicCamA_func_802C1DB0(-45.0f)) {
|
||||
// @recomp Account for axis inversion
|
||||
if (bainput_should_rotate_camera_left() && ncDynamicCamA_func_802C1DB0(-45.0f * axisInversionModifier)) {
|
||||
func_80291488(arg0);
|
||||
func_8029103C();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (bainput_should_rotate_camera_right() && ncDynamicCamA_func_802C1DB0(45.0f)) {
|
||||
// @recomp Account for axis inversion
|
||||
if (bainput_should_rotate_camera_right() && ncDynamicCamA_func_802C1DB0(45.0f * axisInversionModifier)) {
|
||||
func_80291488(arg0);
|
||||
func_8029103C();
|
||||
return TRUE;
|
||||
@@ -561,3 +634,147 @@ RECOMP_PATCH void pfsManager_readData() {
|
||||
if (!pfsManagerContStatus.errno)
|
||||
osContGetReadData(pfsManagerContPadData);
|
||||
}
|
||||
|
||||
extern f32 bastick_getX(void);
|
||||
extern f32 bastick_getY(void);
|
||||
|
||||
// @recomp Patched to allow configuring Y axis inversion when flying
|
||||
RECOMP_PATCH void func_802A3648(void){
|
||||
// @recomp Get the axis inversion setting
|
||||
s32 inverted_y = recomp_get_flying_and_swimming_inverted_y();
|
||||
|
||||
// @recomp Apply axis inversion setting
|
||||
f32 tmp_f0 = inverted_y ? bastick_getY() : -bastick_getY();
|
||||
|
||||
if(tmp_f0 < 0.0f)
|
||||
pitch_setIdeal(ml_map_f(tmp_f0, -1.0f, 0.0f, 300.0f, 360.0f));
|
||||
else
|
||||
pitch_setIdeal(ml_map_f(tmp_f0, 0.0f, 1.0f, 0.0f, 80.0f));
|
||||
}
|
||||
|
||||
// @recomp Patched to allow configuring X axis inversion when flying
|
||||
RECOMP_PATCH void func_802A354C(void){
|
||||
f32 yaw_range;
|
||||
f32 roll_range;
|
||||
f32 sp2C;
|
||||
|
||||
// @recomp Get the axis inversion setting
|
||||
s32 inverted_x = recomp_get_flying_and_swimming_inverted_x();
|
||||
|
||||
// @recomp Apply axis inversion setting
|
||||
sp2C = inverted_x ? -bastick_getX() : bastick_getX();
|
||||
if(bakey_held(BUTTON_R)){
|
||||
yaw_setVelocityBounded(500.0f, 30.0f);
|
||||
yaw_range = 6.0f;
|
||||
roll_range = 85.0f;
|
||||
}
|
||||
else{
|
||||
yaw_setVelocityBounded(500.0f, 2.0f);
|
||||
yaw_range = 3.0f;
|
||||
roll_range = 75.0f;
|
||||
}
|
||||
roll_setIdeal(ml_map_f(sp2C, -1.0f, 1.0f, -roll_range, roll_range));
|
||||
yaw_setIdeal(mlNormalizeAngle(yaw_getIdeal() + ml_map_f(sp2C, -1.0f, 1.0f, yaw_range, -yaw_range)));
|
||||
}
|
||||
|
||||
// @recomp Patched to allow configuring Y axis inversion when swimming
|
||||
f32 func_802A716C();
|
||||
RECOMP_PATCH void func_802A7304() {
|
||||
f32 temp_f0;
|
||||
|
||||
// @recomp Get the axis inversion setting
|
||||
s32 inverted_y = recomp_get_flying_and_swimming_inverted_y();
|
||||
|
||||
pitch_setAngVel(ml_interpolate_f(func_802A716C(), 70.0f, 30.0f), 0.9f);
|
||||
|
||||
// @recomp Apply axis inversion setting
|
||||
temp_f0 = inverted_y ? bastick_getY() : -bastick_getY();
|
||||
if (temp_f0 < 0.0f) {
|
||||
pitch_setIdeal(ml_map_f(temp_f0, -1.0f, 0.0f, 275.0f, 360.0f));
|
||||
return;
|
||||
}
|
||||
pitch_setIdeal(ml_map_f(temp_f0, 0.0f, 1.0f, 0.0f, 85.0f));
|
||||
}
|
||||
|
||||
// @recomp Patched to allow configuring X axis inversion when swimming
|
||||
RECOMP_PATCH void func_802A71D8(void) {
|
||||
f32 yaw_range;
|
||||
f32 sp38;
|
||||
f32 roll_range;
|
||||
f32 sp30;
|
||||
|
||||
// @recomp Get the axis inversion setting
|
||||
s32 inverted_x = recomp_get_flying_and_swimming_inverted_x();
|
||||
|
||||
// @recomp Apply axis inversion setting
|
||||
sp30 = inverted_x ? -bastick_getX() : bastick_getX();
|
||||
sp38 = func_802A716C();
|
||||
if (bakey_held(BUTTON_R)) {
|
||||
roll_range = 45.0f;
|
||||
yaw_range = 4.3f;
|
||||
yaw_setVelocityBounded(250.0f, 20.0f);
|
||||
} else {
|
||||
roll_range = 35.0f;
|
||||
yaw_range = ml_interpolate_f(sp38, 3.1f, 2.4f);
|
||||
yaw_setVelocityBounded(90.0f, ml_interpolate_f(sp38, 3.8f, 2.2f));
|
||||
}
|
||||
roll_setIdeal(ml_map_f(sp30, -1.0f, 1.0f, -roll_range, roll_range));
|
||||
yaw_setIdeal(mlNormalizeAngle(yaw_getIdeal() + ml_map_f(sp30, -1.0f, 1.0f, yaw_range, -yaw_range)));
|
||||
}
|
||||
|
||||
extern s32 ncFirstPersonCamera_getState(void);
|
||||
extern void ncFirstPersonCamera_getZoomedInRotation(f32 *);
|
||||
extern void ncFirstPersonCamera_setZoomedOutRotation(f32 src[3]);
|
||||
extern bool func_8028B254(s32 arg0);
|
||||
extern void __bsDroneLook_getEyePos(f32 arg0[3]);
|
||||
extern enum bs_e func_8029BDBC(void);
|
||||
extern void ncFirstPersonCamera_setZoomedOutPosition(f32 src[3]);
|
||||
|
||||
// @recomp: Patched to allow inverting the first person camera
|
||||
RECOMP_PATCH void bsDroneLook_update(void) {
|
||||
s32 next_state;
|
||||
f32 eye_rotation[3];
|
||||
f32 eye_position[3];
|
||||
f32 dt;
|
||||
s32 exit_first_person;
|
||||
|
||||
// @recomp: Get the axis inversion setting
|
||||
s32 inverted_x = recomp_get_first_person_inverted_x();
|
||||
s32 inverted_y = recomp_get_first_person_inverted_y();
|
||||
float x = inverted_x ? -bastick_getX() : bastick_getX();
|
||||
float y = inverted_y ? bastick_getY() : -bastick_getY();
|
||||
|
||||
next_state = 0;
|
||||
dt = time_getDelta();
|
||||
if (ncFirstPersonCamera_getState() == FIRSTPERSON_STATE_2_IDLE) {
|
||||
//camera is in "idle" state
|
||||
ncFirstPersonCamera_getZoomedInRotation(eye_rotation);
|
||||
// @recomp: Apply the axis inversion setting
|
||||
eye_rotation[0] -= y * 90.0f * dt;
|
||||
eye_rotation[1] -= x * 90.0f * dt;
|
||||
eye_rotation[2] = 0.0f;
|
||||
eye_rotation[0] = (eye_rotation[0] > 180.0f) ? ml_max_f(305.0f, eye_rotation[0]) : ml_min_f(70.0f, eye_rotation[0]);
|
||||
ncFirstPersonCamera_setZoomedOutRotation(eye_rotation);
|
||||
yaw_setIdeal(eye_rotation[1] + 180.0f);
|
||||
|
||||
exit_first_person = FALSE;
|
||||
// 1st person cancelled via input
|
||||
if (bakey_pressed(BUTTON_B) || bakey_pressed(BUTTON_A) || bakey_pressed(BUTTON_C_UP)) {
|
||||
exit_first_person = TRUE;
|
||||
}
|
||||
// 1st person cancelled via entering water
|
||||
if (player_inWater()) {
|
||||
if (player_getTransformation() == TRANSFORM_1_BANJO && player_getWaterState() == BSWATERGROUP_0_NONE) {
|
||||
exit_first_person += TRUE;
|
||||
}
|
||||
} else if (func_8028B254(25) == 0) {
|
||||
exit_first_person += TRUE;
|
||||
}
|
||||
if (exit_first_person) {
|
||||
next_state = func_8029BDBC();
|
||||
}
|
||||
}
|
||||
__bsDroneLook_getEyePos(eye_position);
|
||||
ncFirstPersonCamera_setZoomedOutPosition(eye_position);
|
||||
bs_setState(next_state);
|
||||
}
|
||||
@@ -22,6 +22,8 @@ DECLARE_FUNC(void, recomp_get_mouse_deltas, float* x, float* y);
|
||||
DECLARE_FUNC(void, recomp_get_inverted_axes, s32* x, s32* y);
|
||||
DECLARE_FUNC(s32, recomp_get_analog_cam_enabled);
|
||||
DECLARE_FUNC(void, recomp_get_analog_inverted_axes, s32* x, s32* y);
|
||||
DECLARE_FUNC(void, recomp_get_flying_and_swimming_inverted_axes, s32* x, s32* y);
|
||||
DECLARE_FUNC(void, recomp_get_first_person_inverted_axes, s32* x, s32* y);
|
||||
DECLARE_FUNC(void, recomp_get_camera_inputs, float* x, float* y);
|
||||
DECLARE_FUNC(void, recomp_set_right_analog_suppressed, s32 suppressed);
|
||||
|
||||
|
||||
@@ -48,3 +48,5 @@ osContGetReadData_recomp = 0x8F0000AC;
|
||||
bcopy_recomp = 0x8F0000B0;
|
||||
recomp_get_note_saving_enabled = 0x8F0000B4;
|
||||
recomp_get_cutscene_aspect_ratio = 0x8F0000B8;
|
||||
recomp_get_flying_and_swimming_inverted_axes = 0x8F0000BC;
|
||||
recomp_get_first_person_inverted_axes = 0x8F0000C0;
|
||||
|
||||
Reference in New Issue
Block a user