From 5b0b5490cc30af4964ed7f8d8d1ed8cfe38f6ff1 Mon Sep 17 00:00:00 2001 From: jugeeya Date: Mon, 19 Feb 2024 21:22:54 -0800 Subject: [PATCH] Don't use once-per-cpu-frame to fix input recording/save state issues --- src/common/offsets.rs | 24 ++++++++++++------------ src/training/mod.rs | 25 +++++++++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/common/offsets.rs b/src/common/offsets.rs index b87fa59..9bf2e55 100644 --- a/src/common/offsets.rs +++ b/src/common/offsets.rs @@ -233,18 +233,18 @@ static NEEDLE_REUSED_UI: &[u8] = &[ impl_offset!(REUSED_UI); -// // OFFSET_OPCF = 0x6b7ffc (old: 0x6b7fdc) -// static NEEDLE_OPCF: &[u8] = &[ -// 0x68, 0xb6, 0x40, 0xf9, -// 0x09, 0x81, 0x49, 0x39, -// 0x69, 0xe1, 0xff, 0x35, -// 0x08, 0x55, 0x41, 0x39, -// 0x28, 0xe1, 0x1f, 0x37, -// 0xe0, 0x03, 0x13, 0xaa, -// 0x5b, 0x88, 0xf0, 0x97, -// 0xe9, 0x23, 0x43, 0x6d, -// ]; -// impl_offset!(OPCF); +// OFFSET_OPCF = 0x6b7ffc +static NEEDLE_OPCF: &[u8] = &[ + 0x68, 0xb6, 0x40, 0xf9, + 0x09, 0x81, 0x49, 0x39, + 0x69, 0xe1, 0xff, 0x35, + 0x08, 0x55, 0x41, 0x39, + 0x28, 0xe1, 0x1f, 0x37, + 0xe0, 0x03, 0x13, 0xaa, + 0x5b, 0x88, 0xf0, 0x97, + 0xe9, 0x23, 0x43, 0x6d, +]; +impl_offset!(OPCF); // OFFSET_FIM = 0x17504a0 static NEEDLE_FIM: &[u8] = &[ diff --git a/src/training/mod.rs b/src/training/mod.rs index 3cd125f..dd75bc7 100644 --- a/src/training/mod.rs +++ b/src/training/mod.rs @@ -123,6 +123,9 @@ fn once_per_frame_per_fighter(module_accessor: &mut BattleObjectModuleAccessor, } unsafe { + input_record::handle_recording(); + frame_counter::tick_ingame(); + tech::hide_tech(); if menu::menu_condition() { menu::spawn_menu(); } @@ -442,7 +445,7 @@ unsafe fn stale_handle(ctx: &mut InlineCtx) { #[skyline::hook(offset = *OFFSET_STALE_MENU, inline)] unsafe fn stale_menu_handle(ctx: &mut InlineCtx) { // Set the text pointer to where "mel_training_on" is located - let on_text_ptr = (getRegionAddress(Region::Text) as u64) + 0x42b215e; + let on_text_ptr = (getRegionAddress(Region::Text) as u64) + 0x42b315e; let x1 = ctx.registers[1].x.as_mut(); *x1 = on_text_ptr; } @@ -781,12 +784,12 @@ pub unsafe fn handle_article_get_int( // Instruction run on the completion of the CPU Control function // One instruction after the CPU Control function completes -#[skyline::hook(offset = 0x6b7fdc, inline)] -unsafe fn handle_once_per_cpu_frame(_ctx: &mut InlineCtx) { - input_record::handle_recording(); - frame_counter::tick_ingame(); - tech::hide_tech(); -} +// #[skyline::hook(offset = *OFFSET_OPCF, inline)] +// unsafe fn handle_once_per_cpu_frame(_ctx: &mut InlineCtx) { +// input_record::handle_recording(); +// frame_counter::tick_ingame(); +// tech::hide_tech(); +// } #[skyline::hook(offset = *OFFSET_FIM)] unsafe fn handle_final_input_mapping( @@ -863,6 +866,12 @@ pub fn training_mods() { .nop() .unwrap(); + println!( + "Searching for STALE_MENU offset first! : {}", + *OFFSET_STALE_MENU + ); + println!("Searching for STALE offset second! : {}", *OFFSET_STALE); + skyline::install_hooks!( // Mash airdodge/jump handle_get_command_flag_cat, @@ -911,7 +920,7 @@ pub fn training_mods() { // Clatter clatter::hook_start_clatter, // Notifications - handle_once_per_cpu_frame, + // handle_once_per_cpu_frame, // Input handle_final_input_mapping, // Charge