From 6f6417e66a0f59d0b66ca706682fd0bd31b57478 Mon Sep 17 00:00:00 2001
From: jugeeya <jugeeya@live.com>
Date: Thu, 25 Jul 2019 20:42:29 -0700
Subject: [PATCH] input recording kinda works???

---
 code-mod-framework                 |  2 +-
 source/training/input_recorder.hpp | 19 ++++++++++++++++++-
 source/training_mods.hpp           |  5 +++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/code-mod-framework b/code-mod-framework
index 5dd3ce1..31d3dba 160000
--- a/code-mod-framework
+++ b/code-mod-framework
@@ -1 +1 @@
-Subproject commit 5dd3ce1250c1b111781a4e98586d6e50e9fbc4a2
+Subproject commit 31d3dbaa86d24d33335d8ada715201c50f00750d
diff --git a/source/training/input_recorder.hpp b/source/training/input_recorder.hpp
index 592959f..5d612a8 100644
--- a/source/training/input_recorder.hpp
+++ b/source/training/input_recorder.hpp
@@ -51,12 +51,15 @@ int get_command_flag_cat(u64 module_accessor, int category, int flag, bool& repl
         } else {
             if (INPUT_RECORD_STATE == NONE) {
                 if (ControlModule::check_button_on(module_accessor, CONTROL_PAD_BUTTON_CATCH) &&
-                    ControlModule::check_button_trigger(module_accessor, CONTROL_PAD_BUTTON_APPEAL_S_L))
+                    ControlModule::check_button_trigger(module_accessor, CONTROL_PAD_BUTTON_APPEAL_S_L)) {
+                    print_string(module_accessor, "PRERECORD");
                     INPUT_RECORD_STATE = INPUT_PRE_RECORDING;
+                }
             } else if (INPUT_RECORD_STATE == INPUT_PRE_RECORDING) {
                 if (category == FIGHTER_PAD_COMMAND_CATEGORY1) {
                     curr_pre_frame++;
                     if (curr_pre_frame == NUM_PRE_FRAME - 1) {
+                        print_string(module_accessor, "RECORDING");
                         INPUT_RECORD_STATE = INPUT_RECORDING;
                         curr_pre_frame = 0;
                     }
@@ -75,10 +78,24 @@ int get_command_flag_cat(u64 module_accessor, int category, int flag, bool& repl
                     };
 
                     if (curr_frame == NUM_FRAME_INPUTS - 1) {
+                        print_string(module_accessor, "PLAYBACK");
                         INPUT_RECORD_STATE = INPUT_PLAYBACK;
                         curr_frame = 0;
                     }
                 }
+            } else if (INPUT_RECORD_STATE == INPUT_PLAYBACK) {
+                if (ControlModule::check_button_on(module_accessor, CONTROL_PAD_BUTTON_CATCH) &&
+                    ControlModule::check_button_trigger(module_accessor, CONTROL_PAD_BUTTON_APPEAL_S_R)) {
+                    print_string(module_accessor, "STOP");
+                    INPUT_RECORD_STATE = NONE;
+                    for (size_t i = 0; i < NUM_FRAME_INPUTS; i++)
+                        frame_inputs[i] = FrameInput{};
+                    curr_frame = 0;
+                }
+
+                if (category == FIGHTER_PAD_COMMAND_CATEGORY1) {
+                    curr_frame = (curr_frame + 1) % NUM_FRAME_INPUTS;
+                }
             }
         }
     }
diff --git a/source/training_mods.hpp b/source/training_mods.hpp
index 7ed6ec5..e724b95 100644
--- a/source/training_mods.hpp
+++ b/source/training_mods.hpp
@@ -21,6 +21,7 @@
 #include "training/mash.hpp"
 #include "training/selection.hpp"
 #include "training/shield.hpp"
+#include "training/input_recorder.hpp"
 
 using namespace lib;
 using namespace app::lua_bind;
@@ -75,6 +76,10 @@ int get_command_flag_cat_replace(u64 module_accessor, int category) {
     int (*get_command_flag_cat)(u64, int) = (int (*)(u64, int)) load_module_impl(control_module, 0x350);
     int flag = get_command_flag_cat(control_module, category);
 
+    bool replace;
+    int ret = InputRecorder::get_command_flag_cat(module_accessor, category, flag, replace);
+    if (replace) return ret;
+
     Mash::get_command_flag_cat(module_accessor, category, flag);
     Ledge::get_command_flag_cat(module_accessor, category, flag);