From d1b5bdf0f97bae85c1e90c7faf78a3eaf7ca33ae Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 29 Oct 2026 12:55:16 -0700 Subject: [PATCH 01/53] Switch: read the on-screen keyboard and type on it with feedback Games open the Switch's own keyboard for names (e.g. BDSP's player name). keyboard_enter_code() types on it blind from an assumed starting key, so it can't recover from a press the keyboard ignored while sliding in, or start from wherever the keyboard left its cursor. SystemKeyboardDetector recognizes the keyboard (OK blue, or grey while the field is empty), find_system_keyboard_cursor() reads the key under the cursor, and system_keyboard_field_has_text() says whether the field is empty. Unit tests cover all three on six reference screenshots (CommandLineTests, NintendoSwitch/SystemKeyboardDetector). type_on_system_keyboard() in FastCodeEntry reads the cursor before each key and moves it with keyboard_get_path(), now declared in the header, over KEYBOARD_POSITIONS, so it shares the key grid and the wrap-around moves with blind code entry and also supports AZERTY. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../ComputerPrograms_UnitTestRunner.cpp | 2 + .../NintendoSwitch_SystemKeyboardDetector.cpp | 141 ++++++++++++++++++ .../NintendoSwitch_SystemKeyboardDetector.h | 66 ++++++++ .../NintendoSwitch_KeyboardCodeEntry.h | 9 ++ .../NintendoSwitch_SystemKeyboardTyping.cpp | 108 ++++++++++++++ .../NintendoSwitch_SystemKeyboardTyping.h | 39 +++++ SerialPrograms/cmake/SourceFiles.cmake | 4 + 7 files changed, 369 insertions(+) create mode 100644 SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.cpp create mode 100644 SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h create mode 100644 SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.cpp create mode 100644 SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.h diff --git a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp index 75af30e3e6..e4cc0a7488 100644 --- a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp +++ b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp @@ -25,6 +25,7 @@ #include "NintendoSwitch/Inference/NintendoSwitch_CheckOnlineDetector.h" #include "NintendoSwitch/Inference/NintendoSwitch_FailedToConnectDetector.h" +#include "NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h" #include "NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h" #include "NintendoSwitch/Programs/Typewriter/NintendoSwitch_Typewriter_Tests.h" @@ -59,6 +60,7 @@ UnitTestDatabase make_UNIT_TESTS_ALL(){ Kernels::add_tests(ret); NintendoSwitch::add_tests_CheckOnlineDetector(ret); NintendoSwitch::add_tests_FailedToConnectDetector(ret); + NintendoSwitch::add_tests_SystemKeyboardDetector(ret); NintendoSwitch::add_tests_UpdatePopupDetector(ret); NintendoSwitch::Typewriter::add_tests_TypewriterTextMapping(ret); NintendoSwitch::PokemonFRLG::add_tests(ret); diff --git a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.cpp b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.cpp new file mode 100644 index 0000000000..428abbafa3 --- /dev/null +++ b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.cpp @@ -0,0 +1,141 @@ +/* System Keyboard Detector + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/GlobalAutoPaths.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "CommonFramework/ImageTools/ImageStats.h" +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "CommonTools/Images/SolidColorTest.h" +#include "NintendoSwitch_SystemKeyboardDetector.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ + +// Centres of the four rows of character keys, and of the first column and the +// spacing between columns, as fractions of the screen. +static constexpr double KEY_ROW_Y[] = {0.500, 0.593, 0.681, 0.770}; +static constexpr double KEY_COL_X0 = 0.077; +static constexpr double KEY_COL_STEP = 0.075; + + +SystemKeyboardDetector::SystemKeyboardDetector(Color color) + : m_color(color) + , m_key_panel(0.15, 0.555, 0.65, 0.020) + , m_bottom_bar(0.10, 0.935, 0.35, 0.030) + , m_ok_button(0.875, 0.760, 0.045, 0.020) +{} +void SystemKeyboardDetector::make_overlays(VideoOverlaySet& items) const{ + items.add(m_color, m_key_panel); + items.add(m_color, m_bottom_bar); + items.add(m_color, m_ok_button); +} +bool SystemKeyboardDetector::detect(const ImageViewRGB32& screen){ + if (!is_white(extract_box_reference(screen, m_key_panel)) || + !is_white(extract_box_reference(screen, m_bottom_bar)) + ){ + return false; + } + // OK is blue, or flat grey while the field is empty (disabled). + const ImageStats ok = image_stats(extract_box_reference(screen, m_ok_button)); + return is_solid(ok, {0.172, 0.276, 0.552}) || is_grey(ok, 600, 690); +} + + +bool find_system_keyboard_cursor(const ImageViewRGB32& screen, int& row, int& col){ + // The cursor is a cyan border around one key. Neighbouring keys overlap that border, + // so take the centroid of all cyan pixels and map it to the nearest key. + const ImageFloatBox area(0.02, 0.44, 0.84, 0.38); + ImageViewRGB32 keys = extract_box_reference(screen, area); + double count = 0, sum_x = 0, sum_y = 0; + for (size_t y = 0; y < keys.height(); y++){ + for (size_t x = 0; x < keys.width(); x++){ + const uint32_t pixel = keys.pixel(x, y); + const int red = (pixel >> 16) & 0xff; + const int green = (pixel >> 8) & 0xff; + const int blue = pixel & 0xff; + if (red < 150 && green > 200 && blue > 190){ + count++; + sum_x += (double)x; + sum_y += (double)y; + } + } + } + // The border is about 0.15% of the screen; a few stray pixels are not a cursor. + if (count < 0.0005 * screen.width() * screen.height()){ + return false; + } + const double cx = area.x + sum_x / count / keys.width() * area.width; + const double cy = area.y + sum_y / count / keys.height() * area.height; + col = (int)std::lround((cx - KEY_COL_X0) / KEY_COL_STEP); + row = 0; + for (int r = 1; r < 4; r++){ + if (std::abs(KEY_ROW_Y[r] - cy) < std::abs(KEY_ROW_Y[row] - cy)){ + row = r; + } + } + return 0 <= col && col < 11; +} + +bool system_keyboard_field_has_text(const ImageViewRGB32& screen){ + // Left part of the field, after the caret's position on an empty field. + const ImageStats stats = image_stats(extract_box_reference(screen, ImageFloatBox(0.11, 0.235, 0.19, 0.030))); + return stats.stddev.sum() > 30; +} + + +// One screenshot and what each function should read from it. +class Test_SystemKeyboardDetector : public UnitTest{ +public: + // cursor_row/col: -1 for a screen without the keyboard. + Test_SystemKeyboardDetector(const std::string& image, bool keyboard, int cursor_row, int cursor_col, bool has_text) + : UnitTest("NintendoSwitch::SystemKeyboardDetector - " + image) + , m_image(UNIT_TEST_RESOURCE_PATH() + image) + , m_keyboard(keyboard) + , m_cursor_row(cursor_row) + , m_cursor_col(cursor_col) + , m_has_text(has_text) + {} + + virtual UnitTestResult run(Logger& logger, CancellableScope& scope) const override{ + ImageRGB32 image(m_image); + if (SystemKeyboardDetector().detect(image) != m_keyboard){ + return false; + } + if (!m_keyboard){ + return true; + } + int row = -1; + int col = -1; + return find_system_keyboard_cursor(image, row, col) + && row == m_cursor_row && col == m_cursor_col + && system_keyboard_field_has_text(image) == m_has_text; + } + +private: + std::string m_image; + bool m_keyboard; + int m_cursor_row; + int m_cursor_col; + bool m_has_text; +}; + + +void add_tests_SystemKeyboardDetector(UnitTestDatabase& database){ + const std::string folder = "NintendoSwitch/SystemKeyboardDetector/"; + // The OK button is blue with text in the field and grey without. + database.add(folder + "BDSP-PlayerName-Empty.png", true, 0, 0, false); + database.add(folder + "BDSP-FriendName-Typed.png", true, 0, 0, true); + database.add(folder + "BDSP-Dialog.png", false, -1, -1, false); + database.add(folder + "HomeMenu.png", false, -1, -1, false); + database.add(folder + "HomeMenu-OnlineLicensePopup.png", false, -1, -1, false); + database.add(folder + "UserSelect.png", false, -1, -1, false); +} + + + +} +} diff --git a/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h new file mode 100644 index 0000000000..7a2952a2ce --- /dev/null +++ b/SerialPrograms/Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h @@ -0,0 +1,66 @@ +/* System Keyboard Detector + * + * From: https://github.com/PokemonAutomation/ + * + * The Switch's own on-screen keyboard, which games open for names (e.g. the + * player's name in BDSP): detect it, find the key under its cursor, and tell + * whether its text field is empty. Typing with it is in + * Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.h. + * + * Measured on 1920x1080 captures of the QWERTY layout. + * + */ + +#ifndef PokemonAutomation_NintendoSwitch_SystemKeyboardDetector_H +#define PokemonAutomation_NintendoSwitch_SystemKeyboardDetector_H + +#include +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonTools/VisualDetector.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ + + +// White key panel and bottom bar, and the OK button (blue, or grey while the +// field is empty). +class SystemKeyboardDetector : public StaticScreenDetector{ +public: + SystemKeyboardDetector(Color color = COLOR_CYAN); + + virtual void make_overlays(VideoOverlaySet& items) const override; + virtual bool detect(const ImageViewRGB32& screen) override; + +private: + Color m_color; + ImageFloatBox m_key_panel; + ImageFloatBox m_bottom_bar; + ImageFloatBox m_ok_button; +}; +class SystemKeyboardWatcher : public DetectorToFinder{ +public: + SystemKeyboardWatcher(Color color = COLOR_CYAN) + : DetectorToFinder("SystemKeyboardWatcher", std::chrono::milliseconds(250), color) + {} +}; + + +// The key under the cursor, as row (0: digits .. 3: "zxcv") and column (0..10). +// The keyboard remembers the cursor between uses, so read it, don't assume it. +// Returns false if no cursor border is visible. +bool find_system_keyboard_cursor(const ImageViewRGB32& screen, int& row, int& col); + +// Whether the text field holds any text. Pressing B on an empty field closes the +// keyboard, so delete only while this is true. +bool system_keyboard_field_has_text(const ImageViewRGB32& screen); + + + +void add_tests_SystemKeyboardDetector(UnitTestDatabase& database); + + + +} +} +#endif diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h index 7048582ea0..38f4f4d841 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h +++ b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h @@ -8,10 +8,12 @@ #define PokemonAutomation_NintendoSwitch_KeyboardCodeEntry_H #include +#include #include "Controllers/StandardHid/StandardHid_Keyboard.h" #include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" #include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" #include "NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardEntryMappings.h" +#include "NintendoSwitch_CodeEntryTools.h" namespace PokemonAutomation{ namespace NintendoSwitch{ @@ -19,6 +21,13 @@ namespace FastCodeEntry{ +// The D-pad moves from "source" to "destination" on the on-screen keyboard, +// wrapping around the sides when that is shorter, then ENTER_CHAR. +std::vector keyboard_get_path( + KeyboardEntryPosition source, + KeyboardEntryPosition destination +); + // Automatically select between keyboard or pro controller depending on the // controller type. void keyboard_enter_code( diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.cpp new file mode 100644 index 0000000000..43a3329df5 --- /dev/null +++ b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.cpp @@ -0,0 +1,108 @@ +/* System Keyboard Typing + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h" +#include "NintendoSwitch_KeyboardCodeEntry.h" +#include "NintendoSwitch_SystemKeyboardTyping.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace FastCodeEntry{ + +using namespace std::chrono_literals; + + +namespace{ + +constexpr Milliseconds MOVE_HOLD = 100ms; // One key per press, without auto-repeat. +constexpr Milliseconds MOVE_RELEASE = 200ms; +constexpr Milliseconds WRAP_RELEASE = 400ms; // Wrapping around a side animates for longer. +constexpr Milliseconds SETTLE = 300ms; // Before reading the cursor after moving it. +constexpr Milliseconds KEY_HOLD = 80ms; +constexpr Milliseconds KEY_RELEASE = 300ms; + +// A press made while the keyboard is still sliding in is ignored, so the +// cursor is read again after each try until it is on the target. +constexpr size_t MAX_MOVE_TRIES = 10; + + +bool read_cursor(VideoStream& stream, ProControllerContext& context, KeyboardEntryPosition& position){ + context.wait_for_all_requests(); + VideoSnapshot screen = stream.video().snapshot(); + int row = -1; + int col = -1; + if (!screen || !find_system_keyboard_cursor(screen, row, col)){ + return false; + } + position = {(uint8_t)row, (uint8_t)col}; + return true; +} + +void move_cursor(VideoStream& stream, ProControllerContext& context, KeyboardEntryPosition target, char ch){ + for (size_t attempt = 0; attempt < MAX_MOVE_TRIES; attempt++){ + KeyboardEntryPosition cursor; + if (!read_cursor(stream, context, cursor)){ + pbf_wait(context, SETTLE); + continue; + } + if (cursor.row == target.row && cursor.col == target.col){ + return; + } + for (CodeEntryAction action : keyboard_get_path(cursor, target)){ + if (!is_move(action)){ + continue; + } + const bool wrap = ((uint8_t)action & 0x80) != 0; + const DpadPosition direction = (DpadPosition)((uint8_t)action & 0x7f); + pbf_press_dpad(context, direction, MOVE_HOLD, wrap ? WRAP_RELEASE : MOVE_RELEASE); + } + pbf_wait(context, SETTLE); + } + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::string("System keyboard: the cursor did not reach '") + ch + "'.", + stream + ); +} + +} + + + +void type_on_system_keyboard( + VideoStream& stream, ProControllerContext& context, + const std::string& text, + KeyboardLayout layout +){ + const std::map& positions = KEYBOARD_POSITIONS(layout); + for (char ch : text){ + // Letters are listed under their uppercase key. + auto iter = positions.find((char)std::toupper((unsigned char)ch)); + if (iter == positions.end()){ + OperationFailedExceptionWithScreenshot::fire( + ErrorReportMode::SEND_ERROR_REPORT, + std::string("System keyboard: no key for '") + ch + "'.", + stream + ); + } + move_cursor(stream, context, iter->second, ch); + if (std::isupper((unsigned char)ch)){ + pbf_press_button(context, BUTTON_LCLICK, 100ms, 250ms); + } + pbf_press_button(context, BUTTON_A, KEY_HOLD, KEY_RELEASE); + } + context.wait_for_all_requests(); +} + + + +} +} +} diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.h b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.h new file mode 100644 index 0000000000..b0ec331111 --- /dev/null +++ b/SerialPrograms/Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.h @@ -0,0 +1,39 @@ +/* System Keyboard Typing + * + * From: https://github.com/PokemonAutomation/ + * + * Types text on the Switch's on-screen keyboard with a Pro Controller, reading + * the cursor from the video before each key. Unlike keyboard_enter_code(), + * which moves blind from an assumed starting key, it works wherever the + * keyboard left its cursor and catches presses the keyboard ignored. + * + */ + +#ifndef PokemonAutomation_NintendoSwitch_SystemKeyboardTyping_H +#define PokemonAutomation_NintendoSwitch_SystemKeyboardTyping_H + +#include +#include "CommonFramework/Tools/VideoStream.h" +#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h" +#include "NintendoSwitch_KeyboardEntryMappings.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace FastCodeEntry{ + + +// Types `text` (letters, digits and the symbols on the keyboard's first page) +// on the open keyboard. An uppercase letter is typed with Shift (left stick +// click). Throws, with a screenshot, for a character that has no key, or if +// the cursor can't be read or doesn't reach a key. +void type_on_system_keyboard( + VideoStream& stream, ProControllerContext& context, + const std::string& text, + KeyboardLayout layout = KeyboardLayout::QWERTY +); + + +} +} +} +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 39c48d531e..f82e61647b 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1323,6 +1323,8 @@ file(GLOB LIBRARY_SOURCES Source/NintendoSwitch/Inference/NintendoSwitch_SelectedSettingDetector.h Source/NintendoSwitch/Inference/NintendoSwitch_StartGameUserSelectDetector.cpp Source/NintendoSwitch/Inference/NintendoSwitch_StartGameUserSelectDetector.h + Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.cpp + Source/NintendoSwitch/Inference/NintendoSwitch_SystemKeyboardDetector.h Source/NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.cpp Source/NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h Source/NintendoSwitch/NintendoSwitch_ConsoleHandle.cpp @@ -1374,6 +1376,8 @@ file(GLOB LIBRARY_SOURCES Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_KeyboardCodeEntry.h Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_NumberCodeEntry.cpp Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_NumberCodeEntry.h + Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.cpp + Source/NintendoSwitch/Programs/FastCodeEntry/NintendoSwitch_SystemKeyboardTyping.h Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.cpp Source/NintendoSwitch/Programs/NintendoSwitch_FriendCodeAdder.h Source/NintendoSwitch/Programs/NintendoSwitch_FriendDelete.cpp From ea47c4bcec3d4112238eb94148def1dee54b6e6b Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 9 Nov 2026 10:40:16 -0800 Subject: [PATCH 02/53] AutoStory: replay recorded frames through the real watchers A frame source serves a recording's frames (".png") by virtual time, and replay_until / replay_events feed them to VisualInferenceCallbacks or a ScreenEventObserver at the inference period on one thread, so a console failure can become a deterministic test of the real detectors. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../ComputerPrograms_UnitTestRunner.cpp | 1 + .../AutoStory/Pokemon_AutoStory_Tests.h | 2 + .../Pokemon/AutoStory/Pokemon_FrameReplay.cpp | 121 +++++++++++ .../Pokemon/AutoStory/Pokemon_FrameReplay.h | 115 +++++++++++ .../AutoStory/Pokemon_FrameReplay_Tests.cpp | 191 ++++++++++++++++++ SerialPrograms/cmake/SourceFiles.cmake | 3 + 6 files changed, 433 insertions(+) create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.cpp create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp diff --git a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp index 2f878a6551..e75bd9d513 100644 --- a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp +++ b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp @@ -81,6 +81,7 @@ UnitTestDatabase make_UNIT_TESTS_ALL(){ Pokemon::add_tests_ScreenEvents(ret); Pokemon::add_tests_Interrupts(ret); Pokemon::add_tests_Transitions(ret); + Pokemon::add_tests_FrameReplay(ret); Pokemon::add_tests_StoryActions(ret); Pokemon::add_tests_StoryInterrupts(ret); Pokemon::add_tests_StoryEvents(ret); diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h index 10c5ab8848..180f2ff64f 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h @@ -21,6 +21,8 @@ void add_tests_ScreenEvents(UnitTestDatabase& database); void add_tests_Interrupts(UnitTestDatabase& database); // The transition tracker and the games' fade profiles. void add_tests_Transitions(UnitTestDatabase& database); +// Recorded frames replayed through the detectors on a virtual clock. +void add_tests_FrameReplay(UnitTestDatabase& database); // Story action tables, the variant parser and the table executor. void add_tests_StoryActions(UnitTestDatabase& database); // The table executor's looks for interrupts between steps. diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.cpp new file mode 100644 index 0000000000..e1b9df7eac --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.cpp @@ -0,0 +1,121 @@ +/* Frame Replay + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Filesystem/Filesystem.h" +#include "Pokemon_FrameReplay.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +namespace{ + +// The time a frame file's name gives ("1250.png" -> 1250), or -1 when the +// name is not all digits or the file not a .png. +long long frame_time_of(const Filesystem::Path& file){ + if (file.extension().string() != ".png"){ + return -1; + } + const std::string stem = file.stem().string(); + if (stem.empty() || stem.size() > 9){ + return -1; + } + for (char c : stem){ + if (!std::isdigit((unsigned char)c)){ + return -1; + } + } + return std::stoll(stem); +} + +} // namespace + + +ReplayFrameSource::ReplayFrameSource(std::vector frames) + : m_frames(std::move(frames)) +{ + std::stable_sort(m_frames.begin(), m_frames.end(), [](const ReplayFrame& a, const ReplayFrame& b){ + return a.at < b.at; + }); +} + +ReplayFrameSource ReplayFrameSource::from_folder(const std::string& folder){ + std::vector frames; + if (Filesystem::is_directory(folder)){ + for (const Filesystem::Path& file : Filesystem::list_directory(folder)){ + const long long ms = frame_time_of(file); + if (ms >= 0){ + frames.push_back(ReplayFrame{.at = Milliseconds(ms), .file = file.string()}); + } + } + } + if (frames.empty()){ + throw FileException(nullptr, PA_CURRENT_FUNCTION, "No .png frames to replay.", folder); + } + return ReplayFrameSource(std::move(frames)); +} + +Milliseconds ReplayFrameSource::last_frame() const{ + return m_frames.empty() ? Milliseconds(0) : m_frames.back().at; +} + +VideoSnapshot ReplayFrameSource::frame_at(Milliseconds at, WallClock origin) const{ + auto after = std::upper_bound(m_frames.begin(), m_frames.end(), at, [](Milliseconds time, const ReplayFrame& frame){ + return time < frame.at; + }); + if (after == m_frames.begin()){ + return VideoSnapshot(); + } + ReplayFrame& frame = *(after - 1); + if (!frame.image){ + frame.image = std::make_shared(frame.file); + } + VideoSnapshot out; + out.frame = frame.image; + out.timestamp = origin + at; + return out; +} + + +ReplayHit replay_until( + const ReplayFrameSource& source, ReplayWindow window, + const std::vector& callbacks, + WallClock origin, Milliseconds period +){ + for (Milliseconds now = window.start; now < window.end; now += period){ + const VideoSnapshot frame = source.frame_at(now, origin); + if (!frame){ + continue; + } + for (size_t c = 0; c < callbacks.size(); c++){ + if (callbacks[c]->process_frame(frame)){ + return ReplayHit{.index = (int)c, .at = now}; + } + } + } + return ReplayHit{}; +} + +ScreenEventLog replay_events( + const ReplayFrameSource& source, ReplayWindow window, + ScreenEventObserver& observer, + WallClock origin, Milliseconds period +){ + ScreenEventLog log; + for (Milliseconds now = window.start; now < window.end; now += period){ + const VideoSnapshot frame = source.frame_at(now, origin); + log.record(observer.observe(frame, origin + now), origin + now); + } + return log; +} + + + +} // namespace Pokemon +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h new file mode 100644 index 0000000000..12214cb444 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h @@ -0,0 +1,115 @@ +/* Frame Replay + * + * From: https://github.com/PokemonAutomation/ + * + * Recorded console frames, replayed through the real detectors on a + * virtual clock, so a console failure becomes a deterministic test. The + * story sims script what a screen shows (a label per frame); a replay + * shows what the console showed and lets the game's own watchers and + * ScreenEventObserver judge it. + * + * A recording is a folder of frames named by their time in ms from its + * start ("0.png", "1250.png"), as the captured transitions + * (Pokemon_Transitions_Tests.cpp). A frame shows until the next one. + * Recordings are too big for this repo; tests read them from + * CommandLineTests//FrameReplay// and skip when it is missing. + * + * From the stream history (an error report's Video.mp4, kept when the + * "Stream History" setting is on), cut the seconds around the failure at + * 20 frames a second, then rename frame N to its time, (N - 1) * 50 ms: + * ffmpeg -ss -t -i Video.mp4 -vf fps=20 %d.png + * + * One thread, no real time: the caller says which window of the recording + * each action watched, and the replay feeds those frames at the inference + * period, as run_until / wait_until would. + * + */ + +#ifndef PokemonAutomation_Pokemon_FrameReplay_H +#define PokemonAutomation_Pokemon_FrameReplay_H + +#include +#include +#include +#include "Common/Cpp/Time.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" +#include "Pokemon_ScreenEvents.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// One recorded frame: when it showed, from the recording's start, and the +// image, or the file it loads from on first use. +struct ReplayFrame{ + Milliseconds at = Milliseconds(0); + std::string file = {}; + std::shared_ptr image = {}; +}; + + +// Recorded frames, served by virtual time. Not thread-safe: images load +// on first use. +class ReplayFrameSource{ +public: + explicit ReplayFrameSource(std::vector frames); + + // Every ".png" in `folder`. Throws FileException if it has none. + static ReplayFrameSource from_folder(const std::string& folder); + + size_t size() const{ + return m_frames.size(); + } + // When the last frame showed. + Milliseconds last_frame() const; + + // The frame showing at `at`: the last one at or before it, stamped + // `origin + at`. None before the first frame. + VideoSnapshot frame_at(Milliseconds at, WallClock origin) const; + +private: + mutable std::vector m_frames; +}; + + +// How often a replay looks: the inference loop's default period. +constexpr Milliseconds REPLAY_PERIOD = Milliseconds(50); + +// Part of a recording an action watched, in ms from its start, end +// excluded: the hold of a leg run_until watched, or a wait_until after it. +struct ReplayWindow{ + Milliseconds start = Milliseconds(0); + Milliseconds end = Milliseconds(0); +}; + +// The first callback that stopped a replay, and when. +struct ReplayHit{ + // Its index in the callbacks; -1 if none did. + int index = -1; + Milliseconds at = Milliseconds(0); +}; + +// Feeds `callbacks` the frames of `window`, one look per `period`, each +// callback in order on each look, until one returns true: wait_until on a +// recording. Frames are stamped `origin + time`. +ReplayHit replay_until( + const ReplayFrameSource& source, ReplayWindow window, + const std::vector& callbacks, + WallClock origin, Milliseconds period = REPLAY_PERIOD +); + +// What `observer` sees over `window`, one look per `period`, as a +// ScreenEventWatcher's log; the judges (Pokemon_Interrupts.h) read it. +ScreenEventLog replay_events( + const ReplayFrameSource& source, ReplayWindow window, + ScreenEventObserver& observer, + WallClock origin, Milliseconds period = REPLAY_PERIOD +); + + + +} // namespace Pokemon +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp new file mode 100644 index 0000000000..ea2bc0294d --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp @@ -0,0 +1,191 @@ +/* Frame Replay Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The frame source and the replay loop, on synthetic frames: a door's + * black between two overworld frames, watched by the shared + * BlackScreenOverWatcher the walks use and by the shared fade test. + * + */ + +#include +#include +#include +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" +#include "CommonTools/VisualDetectors/BlackScreenDetector.h" +#include "Pokemon_AutoStory_Tests.h" +#include "Pokemon_FrameReplay.h" +#include "Pokemon_Interrupts.h" +#include "Pokemon_ScreenEvents.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + +namespace{ + +using namespace std::chrono_literals; + +const WallClock T0 = WallClock() + std::chrono::hours(1); + +// A textured frame: a fine checkerboard, never a fade. +std::shared_ptr overworld_frame(){ + auto image = std::make_shared(64, 36); + for (size_t y = 0; y < image->height(); y++){ + for (size_t x = 0; x < image->width(); x++){ + image->pixel(x, y) = (x + y) % 2 == 0 ? 0xff306030 : 0xffd0e0a0; + } + } + return image; +} + +std::shared_ptr black_frame(){ + auto image = std::make_shared(64, 36); + image->fill(0xff000000); + return image; +} + +// A door: the overworld, black from 1000 ms to 1500 ms, the overworld again. +ReplayFrameSource door_recording(){ + return ReplayFrameSource({ + {.at = 0ms, .image = overworld_frame()}, + {.at = 1000ms, .image = black_frame()}, + {.at = 1500ms, .image = overworld_frame()}, + }); +} + +// Only the shared fade test, as every game's observer reports it. +class FadeObserver : public ScreenEventObserver{ +public: + virtual ScreenEvents observe(const VideoSnapshot& frame, WallClock) override{ + if (!frame){ + return {}; + } + return fade_events(fade_of_screen(*frame.frame)); + } + virtual void make_overlays(VideoOverlaySet&) const override{} +}; + + +UnitTestResult test_frame_at(){ + const ReplayFrameSource source = door_recording(); + if (source.size() != 3 || source.last_frame() != 1500ms){ + return "the recording does not hold its three frames"; + } + const VideoSnapshot black = source.frame_at(1499ms, T0); + if (!black || fade_of_screen(*black.frame) != WarpFade::BLACK || black.timestamp != T0 + 1499ms){ + return "the frame at 1499 ms is not the black one, stamped 1499 ms"; + } + if (fade_of_screen(*source.frame_at(1500ms, T0).frame) != WarpFade::NONE){ + return "the frame at 1500 ms is not the overworld"; + } + const ReplayFrameSource late({{.at = 200ms, .image = black_frame()}}); + if (late.frame_at(100ms, T0)){ + return "a frame shows before the first one"; + } + return true; +} + +UnitTestResult test_missing_folder(){ + try{ + ReplayFrameSource::from_folder("FrameReplay/no such recording/"); + }catch (FileException&){ + return true; + } + return "a missing folder gave a recording"; +} + +// The walks' wait for a warp (BlackScreenOverWatcher after the hold) sees +// the door when it watches from before the black. +UnitTestResult test_watcher_sees_fade(){ + BlackScreenOverWatcher arrival; + const ReplayHit hit = replay_until(door_recording(), {0ms, 8000ms}, {&arrival}, T0); + if (hit.index != 0 || hit.at < 1500ms || hit.at > 1700ms){ + return std::format("expected the watcher to stop 1500 to 1700 ms in, got index {} at {} ms", hit.index, hit.at.count()); + } + return true; +} + +// A watcher started once the black is over never fires: a walk that holds +// onto a door and only then waits for the fade reports "no fade" though +// the warp happened. +UnitTestResult test_late_watcher_misses_fade(){ + BlackScreenOverWatcher arrival; + const ReplayHit hit = replay_until(door_recording(), {1600ms, 9600ms}, {&arrival}, T0); + if (hit.index != -1){ + return std::format("expected no stop, got index {} at {} ms", hit.index, hit.at.count()); + } + return true; +} + +UnitTestResult test_events_judged(){ + const ReplayFrameSource source = door_recording(); + FadeObserver observer; + const ScreenEventLog log = replay_events(source, {0ms, 3000ms}, observer, T0); + const InterruptWindow whole{T0, T0 + 3000ms}; + const WarpJudgement seen = judge_warp(log, whole, InterruptKnobs{}, SceneChange::DIFFERENT).judgement; + if (seen != WarpJudgement::WARPED){ + return std::format("from the start: expected warped, got {}", warp_judgement_name(seen)); + } + FadeObserver late_observer; + const ScreenEventLog late = replay_events(source, {1600ms, 3000ms}, late_observer, T0); + const WarpJudgement missed = judge_warp(late, whole, InterruptKnobs{}, SceneChange::DIFFERENT).judgement; + if (missed != WarpJudgement::NO_FADE){ + return std::format("after the black: expected no fade, got {}", warp_judgement_name(missed)); + } + return true; +} + + +struct FrameReplayInput{ + std::string name; + std::function body; +}; + +// The body checks its own expectations. +struct FrameReplayExpectation{ +}; + +struct FrameReplayCase{ + FrameReplayInput input; + FrameReplayExpectation expectation; +}; + +class Test_FrameReplay : public UnitTest{ +public: + explicit Test_FrameReplay(FrameReplayCase test_case) + : UnitTest("Pokemon::FrameReplay - " + test_case.input.name) + , m_input(std::move(test_case.input)) + {} + virtual UnitTestResult run(Logger&, CancellableScope&) const override{ + return m_input.body(); + } + +private: + FrameReplayInput m_input; +}; + +const FrameReplayCase FRAME_REPLAY_CASES[] = { + {.input = {"the frame showing at a time", test_frame_at}}, + {.input = {"a missing recording throws", test_missing_folder}}, + {.input = {"the warp watcher sees a door's black", test_watcher_sees_fade}}, + {.input = {"a warp watcher started after the black misses it", test_late_watcher_misses_fade}}, + {.input = {"the replayed events judged as a warp", test_events_judged}}, +}; + +} // namespace + + +void add_tests_FrameReplay(UnitTestDatabase& database){ + for (const auto& item : FRAME_REPLAY_CASES){ + database.add(item); + } +} + + + +} // namespace Pokemon +} // namespace PokemonAutomation diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index fc888392dc..117c31badf 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1498,6 +1498,9 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/AutoStory/Pokemon_AutoStorySelect_Tests.h Source/Pokemon/AutoStory/Pokemon_AutoStoryStats.h Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h + Source/Pokemon/AutoStory/Pokemon_FrameReplay.cpp + Source/Pokemon/AutoStory/Pokemon_FrameReplay.h + Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp Source/Pokemon/AutoStory/Pokemon_Interrupts.cpp Source/Pokemon/AutoStory/Pokemon_Interrupts.h Source/Pokemon/AutoStory/Pokemon_Interrupts_Tests.cpp From 1d0cef56f9cb14f2a394a8f45b88b4309e31832a Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 9 Nov 2026 10:43:55 -0800 Subject: [PATCH 03/53] AutoStory frame replay: designated test cases; keep the runner's registration function at 50 lines Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../ComputerPrograms_UnitTestRunner.cpp | 1 - .../Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp index e75bd9d513..c40f6db961 100644 --- a/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp +++ b/SerialPrograms/Source/ComputerPrograms/ComputerPrograms_UnitTestRunner.cpp @@ -55,7 +55,6 @@ namespace ComputerPrograms{ UnitTestDatabase make_UNIT_TESTS_ALL(){ UnitTestDatabase ret; - add_tests_QtEventThreadPool(ret, GlobalThreadPools::computation_normal()); add_tests_Sockets(ret, GlobalThreadPools::unlimited_normal()); add_tests_BlackBorderDetector(ret); diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp index ea2bc0294d..c07748a3d0 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp @@ -169,11 +169,11 @@ class Test_FrameReplay : public UnitTest{ }; const FrameReplayCase FRAME_REPLAY_CASES[] = { - {.input = {"the frame showing at a time", test_frame_at}}, - {.input = {"a missing recording throws", test_missing_folder}}, - {.input = {"the warp watcher sees a door's black", test_watcher_sees_fade}}, - {.input = {"a warp watcher started after the black misses it", test_late_watcher_misses_fade}}, - {.input = {"the replayed events judged as a warp", test_events_judged}}, + {.input = {"the frame showing at a time", test_frame_at}, .expectation = {}}, + {.input = {"a missing recording throws", test_missing_folder}, .expectation = {}}, + {.input = {"the warp watcher sees a door's black", test_watcher_sees_fade}, .expectation = {}}, + {.input = {"a warp watcher started after the black misses it", test_late_watcher_misses_fade}, .expectation = {}}, + {.input = {"the replayed events judged as a warp", test_events_judged}, .expectation = {}}, }; } // namespace From 2a9ecac8ea54e5a75b833418dd38c004bd2aaadd Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 9 Nov 2026 11:02:03 -0800 Subject: [PATCH 04/53] AutoStory frame replay: the warp watcher watches along the hold The late-watcher case showed a fade missed by a watch that starts after the hold; it now replays the walk's watch (WatchAlong over the hold, then the same watcher on) and checks it sees a door's black that is over before a 2000 ms hold ends, while a watcher started at the end of the hold still misses it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/Pokemon_FrameReplay_Tests.cpp | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp index c07748a3d0..841fa718eb 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay_Tests.cpp @@ -17,6 +17,7 @@ #include "Common/Cpp/TestRunners/UnitTest.h" #include "Common/Cpp/TestRunners/UnitTestDatabase.h" #include "CommonTools/VisualDetectors/BlackScreenDetector.h" +#include "Pokemon/Navigation/Pokemon_LegWalker.h" #include "Pokemon_AutoStory_Tests.h" #include "Pokemon_FrameReplay.h" #include "Pokemon_Interrupts.h" @@ -109,14 +110,24 @@ UnitTestResult test_watcher_sees_fade(){ return true; } -// A watcher started once the black is over never fires: a walk that holds -// onto a door and only then waits for the fade reports "no fade" though -// the warp happened. -UnitTestResult test_late_watcher_misses_fade(){ +// A walk that holds onto a door for 2000 ms, past the black: its watcher +// sees the hold's frames (WatchAlong) and so the black, over before the +// hold ends. A watcher started once the black is over never fires: the +// walk then reported "no fade" though the warp happened (00.27, console +// B, 2026-11-09 01:41, the warp to CeruleanCity, watched from 1.3 s into +// the hold). +UnitTestResult test_watcher_along_hold_sees_fade(){ + const ReplayFrameSource source = door_recording(); BlackScreenOverWatcher arrival; - const ReplayHit hit = replay_until(door_recording(), {1600ms, 9600ms}, {&arrival}, T0); - if (hit.index != -1){ - return std::format("expected no stop, got index {} at {} ms", hit.index, hit.at.count()); + WatchAlong along(arrival); + const ReplayHit during = replay_until(source, {0ms, 2000ms}, {&along}, T0); + if (during.index != -1 || !along.fired()){ + return std::format("expected the hold not stopped and the fade seen, got index {}, seen {}", during.index, along.fired()); + } + BlackScreenOverWatcher late; + const ReplayHit missed = replay_until(source, {2000ms, 10000ms}, {&late}, T0); + if (missed.index != -1){ + return std::format("expected a watcher started after the black to miss it, got index {} at {} ms", missed.index, missed.at.count()); } return true; } @@ -172,7 +183,7 @@ const FrameReplayCase FRAME_REPLAY_CASES[] = { {.input = {"the frame showing at a time", test_frame_at}, .expectation = {}}, {.input = {"a missing recording throws", test_missing_folder}, .expectation = {}}, {.input = {"the warp watcher sees a door's black", test_watcher_sees_fade}, .expectation = {}}, - {.input = {"a warp watcher started after the black misses it", test_late_watcher_misses_fade}, .expectation = {}}, + {.input = {"a warp watcher along the hold sees a black over before it ends", test_watcher_along_hold_sees_fade}, .expectation = {}}, {.input = {"the replayed events judged as a warp", test_events_judged}, .expectation = {}}, }; From ad654be579b81d15b454a06a6d563e95ba97f329 Mon Sep 17 00:00:00 2001 From: dayfine Date: Mon, 9 Nov 2026 11:07:51 -0800 Subject: [PATCH 05/53] AutoStory frame replay: how to cut a failure capture's video into a case Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Source/Pokemon/AutoStory/Pokemon_FrameReplay.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h index 12214cb444..f3d56e386a 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_FrameReplay.h @@ -19,6 +19,16 @@ * 20 frames a second, then rename frame N to its time, (N - 1) * 50 ms: * ffmpeg -ss -t -i Video.mp4 -vf fps=20 %d.png * + * A failed AutoStory event saves its own (Pokemon_AutoStoryFailureCapture.h) + * in USER_FILE_PATH()//AutoStoryFailures/