mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 16:49:58 -04:00
Bring the text speed setting from the 0.10.0 line into the VRAM pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -55,7 +55,7 @@ static const char *const known[] = {
|
||||
"HDR_HIGHLIGHTS", "HDR_HUE", "HDR_HUE_CLIP", "HDR_MATCH_SLOPE", "HDR_MIDGRAY", "HDR_SATURATION", "HDR_SHADOWS",
|
||||
"HDR_TONEMAP", "HDR_TONE_SLOPE", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "LANG", "LIB_PREBUILD",
|
||||
"BIG_BUILD_FREE_MB", "BIG_BUILD_MAX_MB", "BUILD_FREE_MB", "BUILD_RESERVE_MB", "LIB_PREBUILD_BIG", "LIB_PREBUILD_BIG_BG", "COMPUTE_WARM_REUSE", "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIB_WARM", "LINE_WIDTH", "POOL_SHOWN_FIRST", "POOL_DATA_FIRST", "TEX_REUSE_NAMED", "TEX_OVERWRITTEN_USED", "PIPE_LINK_MS", "FRAME_HOLD_MS", "PACE_SMOOTH", "OQ_BATCH", "CLEAR_SMALL_CPU", "GATE_WAIT_MS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MEM_CENSUS", "MEM_NEED_MB", "MENU_LANG", "MENU_SOUND_VOLUME", "MENU_TEST",
|
||||
"MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_CLICK", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MICROPHONE", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MONITOR", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOUSE_TRACE", "MOVIE_HOST", "MOVIE_PACE", "MOVIE_CLOCK", "TEST_HITCH", "SPRINT_BUTTON", "SPRINT_MODE", "SPRINT_BUTTON_PATCH",
|
||||
"MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_CLICK", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MICROPHONE", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MONITOR", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOUSE_TRACE", "MOVIE_HOST", "MOVIE_PACE", "MOVIE_CLOCK", "TEST_HITCH", "SPRINT_BUTTON", "SPRINT_MODE", "SPRINT_BUTTON_PATCH", "TEXT_SPEED", "TEXT_SPEED_PATCH",
|
||||
"MOTION_GUARD_DEGREES", "MOTION_POLICY_TRACE", "SELECTIVE_MOTION", "SELECTIVE_MOTION_RAW", // motion_owner.c, vk_fg_pose.inc
|
||||
"SKIN_MOTION", // vk_skin_motion.inc
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
@@ -122,7 +122,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"CONTACT_SHADOWS", "display"},
|
||||
{"PCSS", "display"},
|
||||
{"MODS_DIR", "mods"}, {"MODS_ORDER", "mods"}, {"MODS_DISABLED", "mods"}, {"MODS_REBUILD", "mods"},
|
||||
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
|
||||
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"}, {"TEXT_SPEED", "language"},
|
||||
{"VOLUME", "audio"}, {"AUDIO_CHANNELS", "audio"}, {"AUDIO_DEVICE", "audio"}, {"MICROPHONE", "audio"}, {"MENU_SOUND_VOLUME", "audio"},
|
||||
{"AUDIO_RAMP", "audio"}, {"AUDIO_CATCHUP", "audio"},
|
||||
{"MOTION", "input"}, {"SPRINT_BUTTON", "input"}, {"SPRINT_MODE", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"}, {"RUMBLE_HD", "input"}, {"DS3", "input"},
|
||||
@@ -244,6 +244,7 @@ static const CfgMeta metas[] = {
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART},
|
||||
{"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR|pl", RESTART},
|
||||
{"OPERATION_MODE", "docked", "docked|handheld", LIVE},
|
||||
{"TEXT_SPEED", "normal", "normal|fast|instant", LIVE}, // text_speed.c: the message window's typing
|
||||
{"ASSUME_FOCUS", "1", "0|1", LIVE}, // read on every focus change (ov_system.c)
|
||||
// Sound, Controls, Menu
|
||||
{"VOLUME", "100", "0..100", LIVE}, {"MENU_SOUND_VOLUME", "80", "0..100", LIVE}, {"AUDIO_CHANNELS", "stereo", "auto|stereo|5.1", LIVE}, // audio_mixer.c audio_channels_live
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "ov.h"
|
||||
#include "platform/platform.h"
|
||||
#include "sprint.h"
|
||||
#include "text_speed.h"
|
||||
|
||||
typedef struct { int64_t sampling; uint64_t buttons; int32_t lx, ly, rx, ry; uint32_t attributes, pad; } NpadState;
|
||||
typedef struct { int64_t sampling; int32_t x, y, dx, dy, wx, wy; uint32_t buttons, attributes; } MouseState;
|
||||
@@ -103,6 +104,7 @@ static void npad_states(Cpu *c, uint32_t want) {
|
||||
dbg_tick(c); // the debug menu's changes to the game, between two of its frames (debug_tools.c)
|
||||
if (live) dbg_pad(&s.buttons, &s.lx, &s.ly, &s.rx, &s.ry); // its free camera takes the sticks while it flies
|
||||
if (live) sprint_pad(&s.buttons); // the sprint button's presses, kept from the game during gameplay (sprint.c)
|
||||
if (live) text_speed_poll(); // the text_speed setting onto the patch page (text_speed.c)
|
||||
*out = s;
|
||||
ret_x(c, 1);
|
||||
}
|
||||
|
||||
63
runtime/text_speed.c
Normal file
63
runtime/text_speed.c
Normal file
@@ -0,0 +1,63 @@
|
||||
// Text speed for Ocarina of Time 1.1.1 (the patch set text_speed, recomp/patches-v111.txt). The message window shows
|
||||
// its text through a typewriter whose speed and waits the message's own tags set, and a press of the decide button
|
||||
// while it types shows the page at once, unless the window marked the message unskippable (a message that turns its
|
||||
// page by itself on a timer, and some window types). The set's two sites read the patch page words this file writes:
|
||||
//
|
||||
// +0x200 the typewriter of the message window while its message may be skipped, 0 otherwise (written by the game's
|
||||
// code at the first site, read at the second)
|
||||
// +0x208 the fast factor less one, as a float: 0 leaves the speed as it is
|
||||
// +0x20c 1 for instant: the window's skip runs on the first frame of each page, as if the button were pressed
|
||||
//
|
||||
// Setting text_speed (live): normal (the game's, and the set off), fast (the skippable messages type
|
||||
// TEXT_SPEED_FAST_FACTOR times as fast, their scripted waits as long as before) or instant (the skippable messages
|
||||
// show each page at once, as the game's skip does). Unskippable messages keep the game's speed under both.
|
||||
#include <stdatomic.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
#include "text_speed.h"
|
||||
|
||||
enum { SPEED_NORMAL, SPEED_FAST, SPEED_INSTANT };
|
||||
static const char *const speed_names[] = {"normal", "fast", "instant"};
|
||||
|
||||
#define PAGE_FACTOR 0x208
|
||||
#define PAGE_INSTANT 0x20c
|
||||
|
||||
static int setting_speed(void) {
|
||||
const char *v = cfg_value("NX2NAVI_TEXT_SPEED");
|
||||
for (int i = 0; i < (int)(sizeof speed_names / sizeof *speed_names); i++)
|
||||
if (v && !strcmp(v, speed_names[i])) return i;
|
||||
return SPEED_NORMAL;
|
||||
}
|
||||
|
||||
// Whether the set may run at all is read once, after the start: NX2NAVI_TEXT_SPEED_PATCH=0, or a mod whose code
|
||||
// patches the same sites (mods.c mods_exefs_switch), leaves it off then, and switching it on later must not undo that.
|
||||
static _Atomic int allowed = -1;
|
||||
static int speed_set(void) { return rt_patch_set("text_speed"); }
|
||||
int text_speed_available(void) {
|
||||
int a = atomic_load(&allowed);
|
||||
if (a < 0) {
|
||||
a = rt_patch_enabled(speed_set()) && rt_patch_page() != NULL;
|
||||
atomic_store(&allowed, a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
void text_speed_poll(void) {
|
||||
if (!text_speed_available()) return;
|
||||
int s = setting_speed(), set = speed_set();
|
||||
uint8_t *page = rt_patch_page();
|
||||
float factor = s == SPEED_FAST ? TEXT_SPEED_FAST_FACTOR - 1.0f : 0.0f;
|
||||
uint32_t bits;
|
||||
memcpy(&bits, &factor, sizeof bits);
|
||||
__atomic_store_n((uint32_t *)(page + PAGE_FACTOR), bits, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(page + PAGE_INSTANT, (uint8_t)(s == SPEED_INSTANT), __ATOMIC_RELAXED);
|
||||
static int logged = -1;
|
||||
if (s != logged) {
|
||||
logged = s;
|
||||
rt_log("text speed: %s", speed_names[s]);
|
||||
}
|
||||
if (rt_patch_enabled(set) != (s != SPEED_NORMAL)) rt_patch_switch(set, s != SPEED_NORMAL);
|
||||
}
|
||||
11
runtime/text_speed.h
Normal file
11
runtime/text_speed.h
Normal file
@@ -0,0 +1,11 @@
|
||||
// Text speed (text_speed.c): the patch set text_speed's page words and switch.
|
||||
#pragma once
|
||||
|
||||
// Called at every controller poll the game makes (ov_input.c npad_states): puts the text_speed setting on the patch
|
||||
// page and switches the set, so a change in the menu reaches the text that types next.
|
||||
void text_speed_poll(void);
|
||||
// 1 when the game version has the patch set text_speed and nothing keeps it off (NX2NAVI_TEXT_SPEED_PATCH=0, a mod
|
||||
// patching its sites): the Game tab shows the row then. The set itself runs only while the setting is not normal.
|
||||
int text_speed_available(void);
|
||||
// The factor the fast setting multiplies the message window's typing speed by.
|
||||
#define TEXT_SPEED_FAST_FACTOR 3.0f
|
||||
@@ -56,6 +56,7 @@ extern "C" {
|
||||
#include "save_share.h"
|
||||
#include "sprint.h"
|
||||
#include "sysinfo.h"
|
||||
#include "text_speed.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui_text.h"
|
||||
#include "vk_dlssg.h"
|
||||
@@ -1480,6 +1481,12 @@ static void tab_game(float scale) {
|
||||
static const UiTextId mode[] = {UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD};
|
||||
opt_choice("NX2NAVI_OPERATION_MODE", UI_MENU_OPERATION_MODE, mode, 2, UI_MENU_OPERATION_MODE_DESC);
|
||||
opt_toggle("NX2NAVI_ASSUME_FOCUS", UI_MENU_ASSUME_FOCUS, UI_MENU_ASSUME_FOCUS_DESC);
|
||||
// The message window's typing speed (text_speed.c), where the game version has the patch set text_speed; live. The
|
||||
// names follow the values in their cfg.c order.
|
||||
if (text_speed_available()) {
|
||||
static const UiTextId speed[] = {UI_MENU_TEXT_SPEED_NORMAL, UI_MENU_TEXT_SPEED_FAST, UI_MENU_TEXT_SPEED_INSTANT};
|
||||
opt_choice("NX2NAVI_TEXT_SPEED", UI_MENU_TEXT_SPEED, speed, 3, UI_MENU_TEXT_SPEED_DESC);
|
||||
}
|
||||
// discord_rpc.c reads the setting on its own thread and connects or clears the status within half a second
|
||||
opt_toggle("NX2NAVI_DISCORD_RPC", UI_MENU_DISCORD_RPC, UI_MENU_DISCORD_RPC_DESC);
|
||||
rows_saves();
|
||||
|
||||
@@ -297,6 +297,12 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODE_DOCKED] = "Docked", [UI_MENU_MODE_HANDHELD] = "Handheld",
|
||||
[UI_MENU_ASSUME_FOCUS] = "Keep running out of focus",
|
||||
[UI_MENU_ASSUME_FOCUS_DESC] = "Keeps the game running when you switch to another window.",
|
||||
[UI_MENU_TEXT_SPEED] = "Text speed",
|
||||
[UI_MENU_TEXT_SPEED_DESC] = "How fast the game's message windows show their text. Fast types three times as fast; "
|
||||
"instant shows each page at once. Text the game does not let you hurry, such as "
|
||||
"lines timed to a cutscene or a voice, keeps its speed.",
|
||||
[UI_MENU_TEXT_SPEED_NORMAL] = "Normal", [UI_MENU_TEXT_SPEED_FAST] = "Fast",
|
||||
[UI_MENU_TEXT_SPEED_INSTANT] = "Instant",
|
||||
|
||||
[UI_MENU_MODS_BUILTIN] = "Built into the port", [UI_MENU_MODS_INSTALLED] = "Installed mods",
|
||||
[UI_MENU_MODS_NONE] = "No mods yet. Unpack a mod into the mods folder, one folder per mod with its romfs folder "
|
||||
@@ -1071,6 +1077,12 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODE_DOCKED] = "В док-станции", [UI_MENU_MODE_HANDHELD] = "Портативный",
|
||||
[UI_MENU_ASSUME_FOCUS] = "Работать без фокуса",
|
||||
[UI_MENU_ASSUME_FOCUS_DESC] = "Игра продолжает работать, когда вы переключаетесь на другое окно.",
|
||||
[UI_MENU_TEXT_SPEED] = "Скорость текста",
|
||||
[UI_MENU_TEXT_SPEED_DESC] = "Как быстро окна сообщений игры показывают текст. Быстро: в три раза быстрее; "
|
||||
"мгновенно: каждая страница сразу целиком. Текст, который игра не даёт ускорить, "
|
||||
"например реплики в такт сценке или голосу, идёт с обычной скоростью.",
|
||||
[UI_MENU_TEXT_SPEED_NORMAL] = "Обычная", [UI_MENU_TEXT_SPEED_FAST] = "Быстро",
|
||||
[UI_MENU_TEXT_SPEED_INSTANT] = "Мгновенно",
|
||||
|
||||
[UI_MENU_MODS_BUILTIN] = "Встроенные в порт", [UI_MENU_MODS_INSTALLED] = "Установленные моды",
|
||||
[UI_MENU_MODS_NONE] = "Модов пока нет. Распакуйте мод в папку mods, каждый мод в свою папку с папкой romfs внутри, и "
|
||||
@@ -1691,6 +1703,12 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_FPS_60] = "60 FPS", [UI_MENU_FPS_90] = "90 FPS", [UI_MENU_FPS_120] = "120 FPS", [UI_MENU_FPS_144] = "144 FPS",
|
||||
[UI_MENU_ASSUME_FOCUS] = "Continuar rodando fora de foco",
|
||||
[UI_MENU_ASSUME_FOCUS_DESC] = "Mantém o jogo rodando quando você troca de janela.",
|
||||
[UI_MENU_TEXT_SPEED] = "Velocidade do texto",
|
||||
[UI_MENU_TEXT_SPEED_DESC] = "A rapidez com que as janelas de mensagem do jogo mostram o texto. Rápida escreve três "
|
||||
"vezes mais rápido; instantânea mostra cada página de uma vez. Textos que o jogo não "
|
||||
"deixa apressar, como falas sincronizadas com uma cena ou uma voz, mantêm a velocidade.",
|
||||
[UI_MENU_TEXT_SPEED_NORMAL] = "Normal", [UI_MENU_TEXT_SPEED_FAST] = "Rápida",
|
||||
[UI_MENU_TEXT_SPEED_INSTANT] = "Instantânea",
|
||||
[UI_MENU_FPS_DISPLAY] = "Taxa do monitor", [UI_MENU_FPS_DISPLAY_HZ] = "Taxa do monitor (%.0f Hz)",
|
||||
[UI_MENU_FPS_UNLIMITED] = "Sem limite",
|
||||
[UI_MENU_FPS_RTSS] = "limitado pelo RivaTuner Statistics Server",
|
||||
@@ -2464,6 +2482,11 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = {
|
||||
[UI_MENU_MODE_HANDHELD] = "掌机模式",
|
||||
[UI_MENU_ASSUME_FOCUS] = "后台保持运行",
|
||||
[UI_MENU_ASSUME_FOCUS_DESC] = "切换到其他窗口时游戏继续运行。",
|
||||
[UI_MENU_TEXT_SPEED] = "文字速度",
|
||||
[UI_MENU_TEXT_SPEED_DESC] = "游戏对话框显示文字的速度。快速为三倍速度;即时则每页立即全部显示。"
|
||||
"游戏不允许加快的文字(例如与过场动画或语音同步的台词)保持原速。",
|
||||
[UI_MENU_TEXT_SPEED_NORMAL] = "正常", [UI_MENU_TEXT_SPEED_FAST] = "快速",
|
||||
[UI_MENU_TEXT_SPEED_INSTANT] = "即时",
|
||||
[UI_MENU_VOLUME] = "音量",
|
||||
[UI_MENU_MENU_SOUNDS] = "菜单音效", [UI_MENU_MENU_SOUNDS_DESC] = "本菜单的音效音量。",
|
||||
[UI_MENU_VOLUME_DESC] = "游戏总音量。",
|
||||
|
||||
@@ -80,6 +80,8 @@ typedef enum {
|
||||
UI_MENU_GAME_LANG, UI_MENU_GAME_LANG_DESC, UI_MENU_GAME_LANG_AUTO,
|
||||
UI_MENU_OPERATION_MODE, UI_MENU_OPERATION_MODE_DESC, UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD,
|
||||
UI_MENU_ASSUME_FOCUS, UI_MENU_ASSUME_FOCUS_DESC,
|
||||
UI_MENU_TEXT_SPEED, UI_MENU_TEXT_SPEED_DESC, UI_MENU_TEXT_SPEED_NORMAL, UI_MENU_TEXT_SPEED_FAST,
|
||||
UI_MENU_TEXT_SPEED_INSTANT,
|
||||
|
||||
// Mods: the port's own patches and the player's mods folder (mods.c)
|
||||
UI_MENU_MODS_BUILTIN, UI_MENU_MODS_INSTALLED,
|
||||
|
||||
Reference in New Issue
Block a user