Skip to content

Commit

Permalink
Toggleable L + R + A Reset (#663)
Browse files Browse the repository at this point in the history
* Working w/ raw offset and no icon

* Use dynamic offsets

* Add icon

* Fixed layout.arc

* Cargo fmt
  • Loading branch information
GradualSyrup authored Feb 5, 2024
1 parent 312363d commit 6862c23
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/common/offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,17 @@ static NEEDLE_LAYOUT_ARC_MALLOC: &[u8] = &[
0xc1, 0xb6, 0x40, 0xf9,
0xc2, 0x57, 0x00, 0xb0,
];
impl_offset!(LAYOUT_ARC_MALLOC);
impl_offset!(LAYOUT_ARC_MALLOC);

// OFFSET_TRAINING_RESET_CHECK = 0x1378e30
static NEEDLE_TRAINING_RESET_CHECK: &[u8] = &[
0x1f, 0x09, 0x00, 0x71,
0x41, 0x1c, 0x00, 0x54,
0xe8, 0xf9, 0x01, 0xf0,
0x08, 0x7d, 0x42, 0xf9,
0x08, 0x01, 0x40, 0xf9,
0x09, 0xa1, 0x40, 0xb9,
0x3f, 0x05, 0x00, 0x71,
0x2b, 0x0a, 0x00, 0x54,
];
impl_offset!(TRAINING_RESET_CHECK);
Binary file modified src/static/layout.arc
Binary file not shown.
12 changes: 12 additions & 0 deletions src/training/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,16 @@ pub unsafe fn handle_add_damage(
original!()(damage_module, damage_to_add, param_2)
}

// Control L+R+A Resets
// This function already checks for training mode, so we don't need to check for training mode here
#[skyline::hook(offset = *OFFSET_TRAINING_RESET_CHECK, inline)]
unsafe fn lra_handle(ctx: &mut InlineCtx) {
let x8 = ctx.registers[8].x.as_mut();
if !(MENU.lra_reset.as_bool()) {
*x8 = 0;
}
}

// Set Stale Moves to On
// One instruction after stale moves toggle register is set to 0
#[skyline::hook(offset = *OFFSET_STALE, inline)]
Expand Down Expand Up @@ -915,6 +925,8 @@ pub fn training_mods() {
handle_article_get_int,
handle_fighter_effect,
handle_fighter_joint_effect,
// L+R+A Reset
lra_handle
);

items::init();
Expand Down
11 changes: 11 additions & 0 deletions training_mod_consts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub struct TrainingModpackMenu {
pub stale_dodges: OnOff,
pub tech_hide: OnOff,
pub update_policy: UpdatePolicy,
pub lra_reset: OnOff,
}

#[repr(C)]
Expand Down Expand Up @@ -200,6 +201,7 @@ pub static DEFAULTS_MENU: TrainingModpackMenu = TrainingModpackMenu {
stale_dodges: OnOff::ON,
tech_hide: OnOff::OFF,
update_policy: UpdatePolicy::default(),
lra_reset: OnOff::ON,
};

pub static mut MENU: TrainingModpackMenu = DEFAULTS_MENU;
Expand Down Expand Up @@ -729,6 +731,14 @@ impl_toggletrait! {
true,
1,
}
impl_toggletrait! {
OnOff,
"L+R+A Reset",
"lra_reset",
"L+R+A Reset: Reset Training Room when pressing L+R+A",
true,
1,
}
impl_toggletrait! {
RecordSlot,
"Recording Slot",
Expand Down Expand Up @@ -948,6 +958,7 @@ pub unsafe fn create_app<'a>() -> App<'a> {
misc_tab_submenus.push(to_submenu_stage_hazards());
misc_tab_submenus.push(to_submenu_hud());
misc_tab_submenus.push(to_submenu_update_policy());
misc_tab_submenus.push(to_submenu_lra_reset());
let misc_tab = Tab {
id: "misc",
title: "Misc Settings",
Expand Down

0 comments on commit 6862c23

Please sign in to comment.