From 661826e9bef3f8d8f918b7ab093a07845b78f40a Mon Sep 17 00:00:00 2001 From: machinewrapped Date: Sun, 22 Nov 2026 16:13:23 +0100 Subject: [PATCH] Add option to keep crouch after using camera --- runtime/camera_stealth.c | 33 +++++++++++++++++++++ runtime/control_settings.c | 2 +- runtime/settings.c | 2 ++ runtime/settings.h | 1 + runtime/ui/game_options.mm | 5 ++++ runtime/ui/i18n/de.inc | 3 ++ runtime/ui/i18n/es.inc | 3 ++ runtime/ui/i18n/fr.inc | 3 ++ runtime/ui/i18n/he.inc | 3 ++ runtime/ui/i18n/it.inc | 3 ++ runtime/ui/i18n/ja.inc | 3 ++ runtime/ui/i18n/ko.inc | 3 ++ runtime/ui/i18n/nl.inc | 3 ++ runtime/ui/i18n/pt.inc | 3 ++ runtime/ui/i18n/ru.inc | 3 ++ runtime/ui/i18n/th.inc | 3 ++ runtime/ui/i18n/zh-Hans.inc | 3 ++ runtime/ui/i18n/zh-Hant.inc | 3 ++ tools/game_sites.py | 24 +++++++++++++++ tools/patches.py | 59 +++++++++++++++++++++++++++++++++++++ tools/test_camera_stealth.c | 56 +++++++++++++++++++++++++++++++++++ 21 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 runtime/camera_stealth.c create mode 100644 tools/test_camera_stealth.c diff --git a/runtime/camera_stealth.c b/runtime/camera_stealth.c new file mode 100644 index 000000000..5119ba7fb --- /dev/null +++ b/runtime/camera_stealth.c @@ -0,0 +1,33 @@ +// Gameplay > Keep crouch after camera (settings.h camera_keep_stealth): remember whether Link was crouched +// when opening the Camera rune and return to crouch idle instead of standing idle when Camera finishes normally. +// Patches in the Player AI selector and Camera::leave() (tools/patches.py _camera_enter_start, +// _camera_exit_finished, _camera_exit_active, _camera_leave) record entry, choose the exit state, and clear stale +// state on any non-normal Camera exit. +#include +#include + +#include "hle.h" +#include "settings.h" + +static uint64_t g_camera_stealth_player; +static bool g_camera_stealth_crouched; + +void rt_camera_stealth_enter(uint64_t player, int is_squat) { + g_camera_stealth_player = player; + g_camera_stealth_crouched = player != 0 && is_squat != 0; +} + +int rt_camera_stealth_exit(uint64_t player) { + bool restore = g_settings.camera_keep_stealth && g_camera_stealth_crouched && + player != 0 && player == g_camera_stealth_player; + g_camera_stealth_crouched = false; + g_camera_stealth_player = 0; + return restore ? 1 : 0; +} + +void rt_camera_stealth_leave(void) { + g_camera_stealth_crouched = false; + g_camera_stealth_player = 0; +} + +RT_ON_RESET(camera_stealth_reset) { rt_camera_stealth_leave(); } diff --git a/runtime/control_settings.c b/runtime/control_settings.c index b03cc77d8..3cc3adafe 100644 --- a/runtime/control_settings.c +++ b/runtime/control_settings.c @@ -66,7 +66,7 @@ static const Setting settings[] = { B(god_mode), B(one_hit_kill), I(damage_taken, 25, 400, NULL), I(damage_dealt, 25, 400, NULL), I(text_language, 0, 0, NULL), I(voice_language, 0, 0, NULL), B(save_backups), B(stick_cam_on), I(stick_cam_x, STICK_CAM_MIN, STICK_CAM_MAX, NULL), I(stick_cam_y, STICK_CAM_MIN, STICK_CAM_MAX, NULL), B(toggle_zl), B(toggle_zr), I(menu_text_size, 80, 150, NULL), - B(auto_continue), B(menu_tip_seen), + B(auto_continue), B(menu_tip_seen), B(camera_keep_stealth), }; #undef B #undef I diff --git a/runtime/settings.c b/runtime/settings.c index 3e9efadbf..231b3eed2 100644 --- a/runtime/settings.c +++ b/runtime/settings.c @@ -451,6 +451,7 @@ void settings_load(void) { else if (!strcmp(key, "quick_drop")) g_settings.quick_drop = atoi(val) != 0; else if (!strcmp(key, "quick_sort")) g_settings.quick_sort = atoi(val) != 0; else if (!strcmp(key, "discord_rpc")) g_settings.discord_rpc = atoi(val) != 0; + else if (!strcmp(key, "camera_keep_stealth")) g_settings.camera_keep_stealth = atoi(val) != 0; else if (!strcmp(key, "dpad_move")) g_settings.dpad_move = atoi(val) != 0; else if (!strcmp(key, "menu_wrap")) g_settings.menu_wrap = atoi(val) != 0; else if (!strcmp(key, "prompts_follow")) g_settings.prompts_follow = atoi(val) != 0; @@ -948,6 +949,7 @@ bool settings_save_to(const char *path) { int ts = g_settings.text_speed; fprintf(f, "text_speed = %s\n", k_text_speed[ts >= 0 && ts < TEXT_SPEED_COUNT ? ts : TEXT_SPEED_NORMAL]); fprintf(f, "menu_tip_seen = %d\n", g_settings.menu_tip_seen); + fprintf(f, "camera_keep_stealth = %d\n", g_settings.camera_keep_stealth); bind_settings_save(f); fclose(f); return true; diff --git a/runtime/settings.h b/runtime/settings.h index 8ddd3702c..3cdb8e023 100644 --- a/runtime/settings.h +++ b/runtime/settings.h @@ -241,6 +241,7 @@ typedef struct { bool auto_continue; // Gameplay > Start at Continue: past the start screen into the latest save (hle/input.c) int text_speed; // TEXT_SPEED_*: dialogue text appearance speed (Normal, Fast, Instant) bool menu_tip_seen; // the start screen's one-time "how to open the menu" note was shown (first PLAY ever) + bool camera_keep_stealth; // Gameplay > Keep crouch after camera (runtime/camera_stealth.c) } Settings; #define RUMBLE_STRENGTH_MIN 10 diff --git a/runtime/ui/game_options.mm b/runtime/ui/game_options.mm index a9556400d..62fdf16f8 100644 --- a/runtime/ui/game_options.mm +++ b/runtime/ui/game_options.mm @@ -1056,6 +1056,11 @@ void build_items(void) { #endif // Gameplay + v.push_back(toggle(P_GAMEPLAY, "Keep crouch after camera", + "Return to crouching after closing the Camera rune if you were crouched when opening it.", + [](const Item &) { return (int)g_settings.camera_keep_stealth; }, + [](const Item &, int x) { g_settings.camera_keep_stealth = x; }, 0)); + v.push_back(toggle(P_GAMEPLAY, "Quick inventory sorting", "Sort weapons, bows and shields in the quick selector. Requires game version 1.9.0.", [](const Item &) { return (int)g_settings.quick_sort; }, diff --git a/runtime/ui/i18n/de.inc b/runtime/ui/i18n/de.inc index 9e5386972..dd40655af 100644 --- a/runtime/ui/i18n/de.inc +++ b/runtime/ui/i18n/de.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Intel XeSS wird heruntergeladen") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Dynamisch: rendert die 3D-Szene kleiner, wenn Frames langsam sind, und wieder schärfer, wenn nicht; bleibt in voller Größe, wo das nichts bringt.") T("About mods", "Über Mods") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Mods stammen von anderen Leuten, nicht von Savage Wind. Wir prüfen, testen und unterstützen sie nicht und sind nicht verantwortlich für das, was sie tun, auch wenn sie das Spiel oder deine Spielstände beschädigen. Sichere deine Spielstände, bevor du einen ausprobierst, und schalte Mods aus, bevor du einen Fehler meldest: Eine Meldung zu einem Fehler, den ein Mod verursacht, wird sofort geschlossen. Savage-Wind-Versionen enthalten nie Mods; künftig empfehlen wir vielleicht einige, die gut mit Savage Wind laufen.") + +T("Keep crouch after camera", "Nach Kamera geduckt bleiben") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Kehrt nach dem Schließen des Fotomoduls in die Hocke zurück, wenn du beim Öffnen geduckt warst.") diff --git a/runtime/ui/i18n/es.inc b/runtime/ui/i18n/es.inc index 7cfb7cbb7..7af2a4893 100644 --- a/runtime/ui/i18n/es.inc +++ b/runtime/ui/i18n/es.inc @@ -1260,3 +1260,6 @@ T("Downloading Intel XeSS", "Descargando Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Dinámico: renderiza la escena 3D más pequeña cuando los fotogramas van lentos y más nítida cuando no; se queda a tamaño completo donde eso no gana nada.") T("About mods", "Sobre los mods") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Los mods los hacen otras personas, no Savage Wind. No los revisamos, probamos ni damos soporte, y no nos hacemos responsables de lo que hagan, incluso si rompen el juego o tus partidas. Haz una copia de tus partidas antes de probar uno y desactiva los mods antes de reportar un error: un reporte de un error causado por un mod se cierra de inmediato. Las versiones de Savage Wind nunca incluyen mods; en el futuro quizá recomendemos algunos que funcionen bien con Savage Wind.") + +T("Keep crouch after camera", "Mantener sigilo tras la cámara") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Vuelve a agacharse al cerrar el módulo de la cámara si estabas agachado al abrirlo.") diff --git a/runtime/ui/i18n/fr.inc b/runtime/ui/i18n/fr.inc index 89adbc608..1d02191d7 100644 --- a/runtime/ui/i18n/fr.inc +++ b/runtime/ui/i18n/fr.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Téléchargement de Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Dynamique : rend la scène 3D plus petite quand les images sont lentes, plus nette quand elles ne le sont pas ; reste en pleine taille là où ça n'apporte rien.") T("About mods", "À propos des mods") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Les mods sont faits par d'autres personnes, pas par Savage Wind. Nous ne les vérifions pas, ne les testons pas et ne les prenons pas en charge, et nous ne sommes pas responsables de ce qu'ils font, y compris s'ils cassent le jeu ou vos sauvegardes. Sauvegardez vos parties avant d'en essayer un, et désactivez les mods avant de signaler un bug : le signalement d'un bug causé par un mod est fermé immédiatement. Les versions de Savage Wind n'incluent jamais de mods ; à l'avenir, nous pourrons en recommander certains qui fonctionnent bien avec Savage Wind.") + +T("Keep crouch after camera", "Rester accroupi après l'appareil photo") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Revient en position accroupie en fermant le module Appareil photo si vous étiez accroupi en l'ouvrant.") diff --git a/runtime/ui/i18n/he.inc b/runtime/ui/i18n/he.inc index d23da92b4..8837ab710 100644 --- a/runtime/ui/i18n/he.inc +++ b/runtime/ui/i18n/he.inc @@ -1260,3 +1260,6 @@ T("Downloading Intel XeSS", "מוריד את Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "דינמי: מרנדר את סצנת ה-3D קטנה יותר כשהפריימים איטיים וחדה יותר כשלא; נשארת בגודל מלא כשאין בכך תועלת.") T("About mods", "על מודים") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "המודים נוצרים על ידי אנשים אחרים, לא על ידי Savage Wind. איננו בודקים, מנסים או תומכים בהם, ואיננו אחראים למה שהם עושים, כולל אם הם שוברים את המשחק או את השמירות שלך. גבה את השמירות לפני שאתה מנסה מוד, וכבה את המודים לפני דיווח על באג: דיווח על באג שנגרם על ידי מוד ייסגר מיד. גרסאות Savage Wind לעולם אינן כוללות מודים; בעתיד אולי נמליץ על כמה שעובדים טוב עם Savage Wind.") + +T("Keep crouch after camera", "הישארות בכריעה אחרי המצלמה") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "חזרה למצב כריעה לאחר סגירת רונת המצלמה אם היית כפוף בעת פתיחתה.") diff --git a/runtime/ui/i18n/it.inc b/runtime/ui/i18n/it.inc index 075f46d38..5aa536635 100644 --- a/runtime/ui/i18n/it.inc +++ b/runtime/ui/i18n/it.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Download di Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Dinamico: rende la scena 3D più piccola quando i frame sono lenti, più nitida quando non lo sono; resta a piena dimensione dove non serve.") T("About mods", "Informazioni sulle mod") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Le mod sono fatte da altre persone, non da Savage Wind. Non le controlliamo, non le testiamo e non le supportiamo, e non siamo responsabili di ciò che fanno, anche se rompono il gioco o i tuoi salvataggi. Fai una copia dei salvataggi prima di provarne una e disattiva le mod prima di segnalare un bug: la segnalazione di un bug causato da una mod viene chiusa subito. Le versioni di Savage Wind non includono mai mod; in futuro potremmo consigliarne alcune che funzionano bene con Savage Wind.") + +T("Keep crouch after camera", "Resta accovacciato dopo la fotocamera") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Torna in posizione accovacciata chiudendo il modulo Scattaimmagini se eri accovacciato all'apertura.") diff --git a/runtime/ui/i18n/ja.inc b/runtime/ui/i18n/ja.inc index 7f8bed7e3..20ee7c365 100644 --- a/runtime/ui/i18n/ja.inc +++ b/runtime/ui/i18n/ja.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Intel XeSS をダウンロード中") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "動的:フレームが遅いときは 3D シーンを小さく、速いときは鮮明にレンダリングします。効果がない環境ではフルサイズのままです。") T("About mods", "MOD について") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "MOD は Savage Wind ではなく、ほかの人が作ったものです。私たちは MOD の確認・テスト・サポートを行わず、ゲームやセーブデータが壊れた場合も含め、MOD の動作について責任を負いません。試す前にセーブデータをバックアップし、不具合を報告する前には MOD をオフにしてください。MOD が原因の不具合の報告はすぐにクローズされます。Savage Wind のリリースに MOD が含まれることはありません。今後、Savage Wind でよく動く MOD を紹介することはあるかもしれません。") + +T("Keep crouch after camera", "カメラ終了後にしゃがみを維持") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "しゃがみ状態でウツシエを開いたとき、閉じたあとにしゃがみ状態に戻します。") diff --git a/runtime/ui/i18n/ko.inc b/runtime/ui/i18n/ko.inc index 18346ad05..ee2c4b180 100644 --- a/runtime/ui/i18n/ko.inc +++ b/runtime/ui/i18n/ko.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Intel XeSS 다운로드 중") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "동적: 프레임이 느릴 때 3D 장면을 더 작게, 빠를 때 더 선명하게 렌더링합니다. 이득이 없는 환경에서는 전체 크기를 유지합니다.") T("About mods", "모드 안내") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "모드는 Savage Wind가 아니라 다른 사람들이 만든 것입니다. 저희는 모드를 확인하거나 테스트하거나 지원하지 않으며, 게임이나 세이브가 망가지는 경우를 포함해 모드가 하는 일에 책임지지 않습니다. 모드를 써 보기 전에 세이브를 백업하고, 버그를 신고하기 전에는 모드를 꺼 주세요. 모드 때문에 생긴 버그 신고는 바로 닫힙니다. Savage Wind 릴리스에는 모드가 포함되지 않습니다. 앞으로 Savage Wind에서 잘 작동하는 모드를 추천할 수는 있습니다.") + +T("Keep crouch after camera", "사진기 사용 후 웅크리기 유지") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "웅크린 상태에서 사진기 룬을 열었다면 닫을 때 다시 웅크린 상태로 돌아갑니다.") diff --git a/runtime/ui/i18n/nl.inc b/runtime/ui/i18n/nl.inc index 36361d27e..c1f465d19 100644 --- a/runtime/ui/i18n/nl.inc +++ b/runtime/ui/i18n/nl.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Intel XeSS wordt gedownload") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Dynamisch: rendert de 3D-scène kleiner als frames traag zijn, scherper als dat niet zo is; blijft op volle grootte waar het niets oplevert.") T("About mods", "Over mods") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Mods worden door anderen gemaakt, niet door Savage Wind. We controleren, testen en ondersteunen ze niet en zijn niet verantwoordelijk voor wat ze doen, ook niet als ze het spel of je saves breken. Maak een back-up van je saves voordat je er een probeert, en zet mods uit voordat je een bug meldt: een melding van een bug die een mod veroorzaakt, wordt meteen gesloten. Savage Wind-releases bevatten nooit mods; in de toekomst raden we misschien een paar aan die goed werken met Savage Wind.") + +T("Keep crouch after camera", "Gehurkt blijven na camera") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Keer terug naar gehurkte houding na het sluiten van de Camerarune als je gehurkt was bij het openen.") diff --git a/runtime/ui/i18n/pt.inc b/runtime/ui/i18n/pt.inc index b63277b21..8d2e1868b 100644 --- a/runtime/ui/i18n/pt.inc +++ b/runtime/ui/i18n/pt.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Baixando Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Dinâmico: renderiza a cena 3D menor quando os quadros ficam lentos e mais nítida quando não; mantém o tamanho cheio onde isso não ganha nada.") T("About mods", "Sobre os mods") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Os mods são feitos por outras pessoas, não pelo Savage Wind. Não os verificamos, testamos nem damos suporte, e não somos responsáveis pelo que fazem, incluindo se estragarem o jogo ou os seus saves. Faça uma cópia dos seus saves antes de experimentar um e desative os mods antes de reportar um erro: um relatório de um erro causado por um mod é fechado de imediato. As versões do Savage Wind nunca incluem mods; no futuro talvez recomendemos alguns que funcionem bem com o Savage Wind.") + +T("Keep crouch after camera", "Manter agachado após a câmera") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Volta a ficar agachado ao fechar a runa Câmera se você estava agachado ao abri-la.") diff --git a/runtime/ui/i18n/ru.inc b/runtime/ui/i18n/ru.inc index e1c0c123f..23bf84b0b 100644 --- a/runtime/ui/i18n/ru.inc +++ b/runtime/ui/i18n/ru.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "Загрузка Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "Динамический: рендерит 3D-сцену меньше, когда кадры идут медленно, и резче, когда нет; остаётся в полном размере там, где это ничего не даёт.") T("About mods", "О модах") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "Моды делают другие люди, а не Savage Wind. Мы их не проверяем, не тестируем и не поддерживаем и не отвечаем за то, что они делают, в том числе если они ломают игру или ваши сохранения. Сделайте копию сохранений, прежде чем пробовать мод, и выключите моды, прежде чем сообщать об ошибке: сообщение об ошибке, которую вызвал мод, сразу закрывается. Релизы Savage Wind никогда не включают моды; в будущем мы, возможно, порекомендуем некоторые, которые хорошо работают с Savage Wind.") + +T("Keep crouch after camera", "Оставаться в приседе после камеры") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "Возвращает Линка в присед после закрытия руны камеры, если он присел до её открытия.") diff --git a/runtime/ui/i18n/th.inc b/runtime/ui/i18n/th.inc index 0dc5f99c1..cac866f87 100644 --- a/runtime/ui/i18n/th.inc +++ b/runtime/ui/i18n/th.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "กำลังดาวน์โหลด Intel Xe T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "ไดนามิก: เรนเดอร์ฉาก 3D เล็กลงเมื่อเฟรมช้า และคมขึ้นเมื่อเร็ว คงขนาดเต็มเมื่อไม่ได้ประโยชน์") T("About mods", "เกี่ยวกับม็อด") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "ม็อดสร้างโดยผู้อื่น ไม่ใช่ Savage Wind เราไม่ได้ตรวจสอบ ทดสอบ หรือดูแลม็อด และไม่รับผิดชอบต่อสิ่งที่ม็อดทำ รวมถึงหากม็อดทำให้เกมหรือเซฟเสียหาย สำรองเซฟก่อนลองม็อด และปิดม็อดก่อนรายงานบั๊ก รายงานบั๊กที่เกิดจากม็อดจะถูกปิดทันที รุ่นเผยแพร่ของ Savage Wind จะไม่รวมม็อดใด ๆ ในอนาคตเราอาจแนะนำม็อดบางตัวที่เล่นกับ Savage Wind ได้ดี") + +T("Keep crouch after camera", "คงท่าย่อตัวหลังใช้กล้อง") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "กลับสู่ท่าย่อตัวหลังปิดรูนกล้อง หากคุณย่อตัวอยู่ก่อนเปิดใช้งาน") diff --git a/runtime/ui/i18n/zh-Hans.inc b/runtime/ui/i18n/zh-Hans.inc index 5022f2c0b..235a8886a 100644 --- a/runtime/ui/i18n/zh-Hans.inc +++ b/runtime/ui/i18n/zh-Hans.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "正在下载 Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "动态:帧率低时缩小 3D 场景,帧率够时恢复清晰;降档无收益的环境保持原生尺寸。") T("About mods", "关于模组") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "模组由其他人制作,而非 Savage Wind。我们不检查、不测试也不支持模组,对模组造成的任何后果概不负责,包括游戏或存档损坏。试用模组前请备份存档,报告错误前请先关闭模组;由模组导致的错误报告会被立即关闭。Savage Wind 的发布版本绝不包含模组;将来我们可能会推荐一些与 Savage Wind 配合良好的模组。") + +T("Keep crouch after camera", "关闭照相机后保持蹲伏") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "如果在蹲伏状态下打开照相机,关闭照相机后将恢复蹲伏状态。") diff --git a/runtime/ui/i18n/zh-Hant.inc b/runtime/ui/i18n/zh-Hant.inc index e36752bc0..5816ae755 100644 --- a/runtime/ui/i18n/zh-Hant.inc +++ b/runtime/ui/i18n/zh-Hant.inc @@ -1261,3 +1261,6 @@ T("Downloading Intel XeSS", "正在下載 Intel XeSS") T("Dynamic: renders the 3D scene smaller when frames are slow, sharper when they aren't; stays full size where that gains nothing.", "動態:幀率低時縮小 3D 場景,幀率足夠時恢復清晰;降檔無收益的環境保持原生尺寸。") T("About mods", "關於模組") T("Mods are made by other people, not by Savage Wind. We don't check, test or support them, and we aren't responsible for what they do, including if they break the game or your saves. Back up your saves before trying one, and turn mods off before reporting a bug: a report of a bug a mod causes is closed right away. Savage Wind releases never include mods; in the future we may suggest some we've found to play well with Savage Wind.", "模組由其他人製作,而非 Savage Wind。我們不檢查、不測試也不支援模組,對模組造成的任何後果概不負責,包括遊戲或存檔損壞。試用模組前請備份存檔,回報錯誤前請先關閉模組;由模組導致的錯誤回報會被立即關閉。Savage Wind 的發行版本絕不包含模組;將來我們可能會推薦一些與 Savage Wind 搭配良好的模組。") + +T("Keep crouch after camera", "關閉照相機後保持蹲伏") +T("Return to crouching after closing the Camera rune if you were crouched when opening it.", "如果在蹲伏狀態下開啟照相機,關閉照相機後將恢復蹲伏狀態。") diff --git a/tools/game_sites.py b/tools/game_sites.py index 5ef248299..ca0b26bd3 100644 --- a/tools/game_sites.py +++ b/tools/game_sites.py @@ -330,6 +330,24 @@ # _horse_crash, _horse_look_ahead; Cheats > Sure-footed horse) Site('horse_crash', 'code', 'b9403428 7100111f 54000001/ff00001f d10303ff 6d072beb f90053f5 6d0823e9 a9097bfd', 0), Site('horse_look_ahead', 'code', 'd105c3ff fd00a3e8 f900affc a914fbfd a9164ff4 910523fd aa0103f4 aa0003f3', 0), + # Gameplay > Keep crouch after camera (tools/patches.py _camera_*; runtime/camera_stealth.c): crouch idle + # target in the Player AI selector, Camera entry, the two Camera -> Wait exit branches, and Camera::leave(). + Site('camera_squat_idle', 'code', + 'f9400008 f9431d08 d63f0100 36000000/fff8001f 90000001/9f00001f 91000021/ffc003ff 14000000/fc000000 ' + 'aa1303e0 94000000/fc000000 37000000/fff8001f', 4), + Site('camera_enter_start', 'code', + 'f9400668 90000001/9f00001f 91000021/ffc003ff aa1303e0 b94c4109 121e7929 b90c4109 94000000/fc000000', 0), + Site('camera_exit_finished', 'code', + '90000008/9f00001f 91000108/ffc003ff 91004335 910483e1 a91223f5 aa1303e0 94000000/fc000000 37000000/fff8001f ' + '90000008/9f00001f 91000108/ffc003ff 910023e1 aa1303e0 a900a3f5 94000000/fc000000 37000000/fff8001f ' + '90000008/9f00001f 91000108/ffc003ff 91004335 910443e1 a91123f5 aa1303e0 94000000/fc000000 37000000/fff8001f ' + '90000008/9f00001f 91000108/ffc003ff 910403e1 aa1303e0 a91023f5 94000000/fc000000 37000000/fff8001f ' + '90000008/9f00001f 91000108/ffc003ff 91004335 9103c3e1', 7), + Site('camera_exit_active', 'code', + '36000000/fff8001f 14000000/fc000000 f9400268 aa1303e0 f9406908 d63f0100 f9400008 f9401108', 1), + Site('camera_leave', 'code', + '94000000/fc000000 14000000/fc000000 90000008/9f00001f 91000108/ffc003ff f9400100 14000000/fc000000 ' + 'a9be7bfd f9000bf3 910003fd aa0003f3 f9400400 94000000/fc000000 37000000/fff8001f 94000000/fc000000', 4), # the pouch taking arrows off for the player's bow (tools/patches.py _remove_arrows; Accessibility > Infinite arrows) Site('pouch_remove_arrows', 'code', 'd101c3ff a9017bfd a9026ffc a90367fa a9045ff8 a90557f6 a9064ff4 910043fd ' '90000008/9f00001f aa0003f3 f9400108/ffc003ff aa0103e0', 0), @@ -508,6 +526,7 @@ ('stamina_store',), ('sprint_cost', 'sprint_press_cost', 'battle_info_field', 'battle_info_b', 'battle_info_c'), # (Cheats > Free sprint: without them it does nothing) ('horse_crash', 'horse_look_ahead'), # (Cheats > Sure-footed horse: without them it does nothing) + ('camera_squat_idle', 'camera_enter_start', 'camera_exit_finished', 'camera_exit_active', 'camera_leave'), ('tp_gate',), # (a far teleport of the control endpoint: without it a long jump freezes the world) ('item_tick', 'pouch_item_get', 'pouch_mgr'), ('horse_cam_lr',), @@ -731,6 +750,11 @@ 'battle_info_c': 0x7001349648, 'horse_crash': 0x70006b16c4, 'horse_look_ahead': 0x70006b4218, + 'camera_squat_idle': 0x7000ca9ef0, + 'camera_enter_start': 0x7000caa6f4, + 'camera_exit_finished': 0x7000cabfb4, + 'camera_exit_active': 0x7000cacfac, + 'camera_leave': 0x7000ca3734, 'item_tick': 0x7000cc4c3c, 'pouch_item_get': 0x7000d921bc, 'pouch_mgr': 0x7001e18570, diff --git a/tools/patches.py b/tools/patches.py index 2f13427ae..c527bb708 100644 --- a/tools/patches.py +++ b/tools/patches.py @@ -1180,6 +1180,61 @@ def _tp_gate(gen, a): f' /* {a:#x}: sub sp, sp, #0xa0 (is the ground around Link still loading?) */') +# Gameplay > Keep crouch after camera (runtime/camera_stealth.c): when Link enters the Camera rune (`カメラ`), the +# normal camera action clears his crouch bit and leaves him standing (`待機`) on exit. Record his crouch bit before +# entering, route normal Camera exits back to crouch idle (`しゃがみ待機`) when enabled, and clear pending state on +# Camera::leave() so non-normal exits (damage, demos, climbing, water) never leave stale state behind. +def _adrp_add_cstr(gen, a): + w0, w1 = _word(gen, a), _word(gen, a + 4) + assert (w0 & 0x9f000000) == 0x90000000, hex(w0) + assert (w1 & 0xffc00000) == 0x91000000 and ((w1 >> 5) & 31) == (w0 & 31), (hex(w0), hex(w1)) + va = adrp_page(w0, a) + ((w1 >> 10) & 0xfff) + off = va - gen.base + end = gen.nso.image.index(0, off) + return bytes(gen.nso.image[off:end]).decode('utf-8') + + +def _camera_enter_start(gen, a): + assert _word(gen, a) == 0xf9400668, hex(_word(gen, a)) # ldr x8, [x19, #8] + assert _adrp_add_cstr(gen, a + 4) == 'カメラ' + return ('{ extern void rt_camera_stealth_enter(uint64_t, int); uint64_t p = LD64(c->x[19] + 8); ' + 'rt_camera_stealth_enter(p, p ? (int)((LD32(p + 0xcec) >> 2) & 1u) : 0); c->x[8] = p; }' + f' /* {a:#x}: ldr x8, [x19, #8] (Camera entry: record crouch bit) */') + + +def _camera_exit_finished(gen, a): + w = _word(gen, a) + assert (w & 0xfff8001f) == 0x37000000, hex(w) # tbnz w0, #0, stand + assert _adrp_add_cstr(gen, a - 28) == 'カメラ' + stand = gen.lift(a).target + squat = gen.sites['camera_squat_idle'] + assert _adrp_add_cstr(gen, stand) == '待機' + assert _adrp_add_cstr(gen, squat) == 'しゃがみ待機' + return (f'{{ extern int rt_camera_stealth_exit(uint64_t); if (c->x[0] & 1) {{ ' + f'if (rt_camera_stealth_exit(LD64(c->x[19] + 8))) {{ goto L_{squat:x}; }} ' + f'goto L_{stand:x}; }} }}' + f' /* {a:#x}: tbnz w0, #0, {stand:#x} (Camera finished: restore crouch idle) */') + + +def _camera_exit_active(gen, a): + w = _word(gen, a) + assert (w & 0xfc000000) == 0x14000000, hex(w) # b stand + stand = gen.lift(a).target + squat = gen.sites['camera_squat_idle'] + assert _adrp_add_cstr(gen, stand) == '待機' + assert _adrp_add_cstr(gen, squat) == 'しゃがみ待機' + return (f'{{ extern int rt_camera_stealth_exit(uint64_t); ' + f'if (rt_camera_stealth_exit(LD64(c->x[19] + 8))) {{ goto L_{squat:x}; }} ' + f'goto L_{stand:x}; }}' + f' /* {a:#x}: b {stand:#x} (Camera active exit: restore crouch idle) */') + + +def _camera_leave(gen, a): + assert _word(gen, a) == 0xf9400100, hex(_word(gen, a)) # ldr x0, [x8] + return ('{ extern void rt_camera_stealth_leave(void); rt_camera_stealth_leave(); c->x[0] = LD64(c->x[8]); }' + f' /* {a:#x}: ldr x0, [x8] (Camera::leave: clear pending crouch state) */') + + PATCHES = { 'ui_layout_draw': _ui_layout_draw, 'ui_layout_pane': _ui_layout_pane, @@ -1311,6 +1366,10 @@ def _tp_gate(gen, a): 'battle_info_c': _battle_info(2), 'horse_crash': _horse_crash, 'horse_look_ahead': _horse_look_ahead, + 'camera_enter_start': _camera_enter_start, + 'camera_exit_finished': _camera_exit_finished, + 'camera_exit_active': _camera_exit_active, + 'camera_leave': _camera_leave, 'item_tick': _item_tick, } diff --git a/tools/test_camera_stealth.c b/tools/test_camera_stealth.c new file mode 100644 index 000000000..f44534712 --- /dev/null +++ b/tools/test_camera_stealth.c @@ -0,0 +1,56 @@ +// Standalone behavior checks for Gameplay > Keep crouch after camera (runtime/camera_stealth.c). +// clang -O1 -Wall -Wextra -Werror -Iruntime tools/test_camera_stealth.c -o build/test_camera_stealth +#include +#include + +#include "../runtime/hle.h" +#undef RT_ON_RESET +#define RT_ON_RESET(fn) static void fn(void) +#include "../runtime/camera_stealth.c" + +Settings g_settings; + +int main(void) { + const uint64_t player = 0x12345678ull; + + // 1. Option disabled: enter crouched -> exit returns 0 and consumes state. + g_settings.camera_keep_stealth = false; + rt_camera_stealth_enter(player, 1); + assert(rt_camera_stealth_exit(player) == 0); + g_settings.camera_keep_stealth = true; + assert(rt_camera_stealth_exit(player) == 0); + + // 2. Option enabled: enter crouched -> exit returns 1 once, second exit returns 0. + rt_camera_stealth_enter(player, 1); + assert(rt_camera_stealth_exit(player) == 1); + assert(rt_camera_stealth_exit(player) == 0); + + // 3. Option enabled: enter standing -> exit returns 0. + rt_camera_stealth_enter(player, 0); + assert(rt_camera_stealth_exit(player) == 0); + + // 4. Option enabled: interrupted Camera exit (leave) clears pending crouch. + rt_camera_stealth_enter(player, 1); + rt_camera_stealth_leave(); + assert(rt_camera_stealth_exit(player) == 0); + + // 5. Option enabled: new standing entry overwrites stale crouch state. + rt_camera_stealth_enter(player, 1); + rt_camera_stealth_enter(player, 0); + assert(rt_camera_stealth_exit(player) == 0); + + // 6. Player pointer checks: mismatched or zero player cannot restore, and zero clears state. + rt_camera_stealth_enter(player, 1); + assert(rt_camera_stealth_exit(player + 0x10) == 0); + rt_camera_stealth_enter(player, 1); + assert(rt_camera_stealth_exit(0) == 0); + rt_camera_stealth_enter(0, 1); + assert(rt_camera_stealth_exit(player) == 0); + + // 7. Reboot reset clears pending crouch state. + rt_camera_stealth_enter(player, 1); + camera_stealth_reset(); + assert(rt_camera_stealth_exit(player) == 0); + + puts("ok: camera stealth enter, exit, leave, pointer mismatch, zero and reset passed"); +}