mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 17:59:58 -04:00
Run the water and floor surface simulations at their own 60 steps a second above 60 fps on 1.1.1.
The physics' two water managers and the game's interactive floor simulation (the Deku Tree's ground webs) step their surfaces in fixed steps of 1/60 s, as many whole steps as the frame's time holds, and drop the fraction, so every frame shorter than 1/60 s ran none and the surfaces stood still above 60 fps. The new set owater (water_steps, on by default) calls the page between the division and the game's cut, which keeps the fraction per object; at 60 fps the count is the game's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ static int save_ok = 1; // the last cfg_save_to wrote (o
|
||||
// Every name the runtime reads (and the patch sets in generated/), without the prefix. A file key outside this list is
|
||||
// logged as unknown. A new variable goes here too, or its ini key logs a harmless "unknown key" line.
|
||||
static const char *const known[] = {
|
||||
"CORES", "TM_DISPATCH", "NVN2_CS_TABLE", "SKIP_SHADERS", "MOVIE_DEBAND", "MOVIE_FPS", "MOVIE_SKIP", "MOVIE_OVERLAY", "MOVIES", "NPLN", "NVN2_PROGRAMS", "NVN_TRAP", "OCARINA_REALTIME", "ONESHOT_BUDGET", "ONESHOT_WAIT_MS", "OCARINA_STEP", "PHYSICS_STEPS", "PICKUP_COUNT", "MOVIE_PTS", "STEP_STEADY", "VI_HZ", "VI_VRR", "TIME_DUMP", "SHADER_DUMP", "SHOT_AFTER", "SHOT_DIR", "SHOT_EVERY", // Switch 2 port: movie skip (romfs.c), NVN2 proc traps (nvn_procs.c)
|
||||
"CORES", "TM_DISPATCH", "NVN2_CS_TABLE", "SKIP_SHADERS", "MOVIE_DEBAND", "MOVIE_FPS", "MOVIE_SKIP", "MOVIE_OVERLAY", "MOVIES", "NPLN", "NVN2_PROGRAMS", "NVN_TRAP", "OCARINA_REALTIME", "ONESHOT_BUDGET", "ONESHOT_WAIT_MS", "OCARINA_STEP", "PHYSICS_STEPS", "PICKUP_COUNT", "WATER_STEPS", "MOVIE_PTS", "STEP_STEADY", "VI_HZ", "VI_VRR", "TIME_DUMP", "SHADER_DUMP", "SHOT_AFTER", "SHOT_DIR", "SHOT_EVERY", // Switch 2 port: movie skip (romfs.c), NVN2 proc traps (nvn_procs.c)
|
||||
"AA", "AA_LOG", "AB", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CATCHUP", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_GAME_PRIO", "AUDIO_OFF", "AUDIO_PREFILL_MS", "AUDIO_RAMP", "AUDIO_STATS",
|
||||
"BARRIER_GAME", "MESH_AHEAD", "MESH_FALLBACK", "MESH_FALLBACK_MB", "MESH_FALLBACK_WORKERS", "PROBE_MESHFB_DIR",
|
||||
"BACKGROUND_WINDOW", "BIND_A", "BIND_B", "BIND_DOWN", "BIND_L", "BIND_LCLICK", "BIND_LEFT", "BIND_LSTICK_DOWN", "BIND_LSTICK_LEFT",
|
||||
@@ -102,7 +102,8 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"GUEST_OPT", "performance"}, {"PASS_TIMES", "diagnostics"}, {"DUMP_KEY", "diagnostics"},
|
||||
{"FPS_LIMIT", "frame rate"}, {"FPS60", "frame rate"}, {"RTSS", "frame rate"},
|
||||
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
||||
{"PHYSICS_STEPS", "frame rate"}, {"PICKUP_COUNT", "frame rate"}, {"MOVIE_PTS", "frame rate"}, {"STEP_STEADY", "frame rate"},
|
||||
{"PHYSICS_STEPS", "frame rate"}, {"PICKUP_COUNT", "frame rate"}, {"WATER_STEPS", "frame rate"},
|
||||
{"MOVIE_PTS", "frame rate"}, {"STEP_STEADY", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"MONITOR", "display"}, {"OUTPUT_RES", "display"}, {"GAME_ASPECT", "display"}, {"GAME_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"SHARPNESS", "display"}, {"STANDIN_FILTER", "display"}, {"SCENE_SHARE", "display"}, {"ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
@@ -242,6 +243,8 @@ static const CfgMeta metas[] = {
|
||||
{"REALTIME", "1", "0|1", RESTART}, {"CLOTH_REALTIME", "1", "0|1", RESTART},
|
||||
{"MODS_REBUILD", "auto", "auto|off", RESTART},
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART},
|
||||
// the set owater of patches-v111.txt (frame_rate.c frame_rate_sim_host): water and floor surfaces' fixed steps
|
||||
{"WATER_STEPS", "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
|
||||
|
||||
@@ -488,7 +488,8 @@ static double ocarina_step(double dt) {
|
||||
// above 60 fps, the cut loses the fraction every frame. whole_frames keeps it per counter (by its guest address) and
|
||||
// hands out the whole part, so each counter moves at the game's pace at any frame rate; at a step of exactly one it
|
||||
// gives what the game computes. A value that is not positive, or too large for a count, is cut as fcvtzs cuts it.
|
||||
// The water's ripples keep their remainders per water object in a table of their own (frame_rate_water_host).
|
||||
// The water's ripples keep their remainders per water object in a table of their own (frame_rate_water_host), and so do
|
||||
// the fixed steps of the water and floor surfaces (frame_rate_sim_host).
|
||||
#define WHOLE_SLOTS 8
|
||||
#define WATER_SLOTS 64
|
||||
typedef struct { uint64_t at; float rem; uint64_t used; } WholeSlot; // used: whole_calls at the slot's last use
|
||||
@@ -573,6 +574,43 @@ void frame_rate_water_host(Cpu *c) {
|
||||
}
|
||||
}
|
||||
|
||||
// The fixed steps of the physics' height-field surfaces (patches-v111.txt owater): the water managers (main+0x3875f20,
|
||||
// main+0x3882660) and the interactive floors' simulation (main+0x632cb0, the spider webs' sinking floor). Each update
|
||||
// divides its seconds by 1/60 s into s0 and cuts that to the number of steps of exactly 1/60 s it runs (at most 3),
|
||||
// dropping the fraction, so every frame shorter than 1/60 s ran none. The site calls this between the division and
|
||||
// the game's own cut: s0 becomes the whole steps in the quotient plus the remainder kept for the object in x19, as a
|
||||
// float the cut keeps exactly, and only s0 changes (its upper lanes stay zero, as the division left them). A quotient
|
||||
// that is not positive, or too large for a count, stays for the cut. The remainders are in a table of their own: an
|
||||
// object that shares slots with the counters above would lose its fraction to them.
|
||||
// NX2NAVI_TRACE=perf: every 10 s, the steps the objects were given beside those the cut alone would have given.
|
||||
#define SIM_SLOTS 8
|
||||
static WholeSlot sim_slot[SIM_SLOTS];
|
||||
|
||||
void frame_rate_sim_host(Cpu *c) {
|
||||
uint32_t bits = (uint32_t)c->v[0];
|
||||
float steps;
|
||||
memcpy(&steps, &bits, 4);
|
||||
uint32_t whole = whole_take(sim_slot, SIM_SLOTS, c->x[19], steps);
|
||||
if (steps > 0.0f && steps < 2147483648.0f) { // whole_take's own range: outside it the game's cut stands
|
||||
float f = (float)whole;
|
||||
memcpy(&bits, &f, 4);
|
||||
c->v[0] = bits;
|
||||
}
|
||||
if (rt_trace & RT_TRACE_PERF) {
|
||||
static uint64_t t0, asked, given, cut;
|
||||
uint64_t now = plat_now_ns(), n = 0, g = 0, k = 0, t = 0;
|
||||
plat_mutex_lock(&whole_lock);
|
||||
asked++, given += whole, cut += cut_fcvtzs(steps);
|
||||
if (!t0) t0 = now;
|
||||
if (now - t0 >= 10000000000ull) n = asked, g = given, k = cut, t = now - t0, t0 = now, asked = given = cut = 0;
|
||||
plat_mutex_unlock(&whole_lock);
|
||||
if (n)
|
||||
rt_log("frame rate: the water and floor surfaces got %llu fixed steps in %.1f s, asked %llu times (cut to "
|
||||
"whole steps each time, as the game cuts them, %llu)", (unsigned long long)g, t / 1e9,
|
||||
(unsigned long long)n, (unsigned long long)k);
|
||||
}
|
||||
}
|
||||
|
||||
// The 60 Hz frames the game steps at each update where the set ostep gives them (Ocarina); 1 elsewhere, the game's own
|
||||
// nominal frame. The mouse camera divides by it (mouse_direct.c): the game multiplies camera input by this step.
|
||||
float frame_step_frames(void) {
|
||||
|
||||
@@ -409,6 +409,7 @@ double frame_step_limit_hz(void); // the frame rate the
|
||||
double frame_step_game_hz(void); // the rate the game draws at under the limit; 0 unknown
|
||||
void frame_rate_day_host(Cpu *c); // the time of day's seconds a frame (set ostep, page +0xf60)
|
||||
void frame_rate_water_host(Cpu *c); // the water's ripple steps a frame (set ostep, page +0xf50)
|
||||
void frame_rate_sim_host(Cpu *c); // water and floor surfaces' fixed steps (set owater, page +0xf20)
|
||||
float frame_step_frames(void); // the 60 Hz frames the game steps per update (set ostep), else 1
|
||||
void frame_step_flight(float *page, float *game, uint64_t *presents); // flight.c: the step at a host present
|
||||
// rtss_limit.c: RivaTuner Statistics Server takes the frame limit where it runs
|
||||
|
||||
@@ -32,12 +32,13 @@ uint8_t rt_patch_on[RT_PATCH_COUNT > 0 ? RT_PATCH_COUNT : 1]; // read by the g
|
||||
#ifdef RT_PATCH_PAGE
|
||||
#include "debug_tools.h"
|
||||
__attribute__((constructor)) static void freecam_register(void) { rt_register_host(RT_PATCH_PAGE + 0xf70, dbg_freecam_host); }
|
||||
// The time of day's site of the set ostep (patches-v111.txt) calls the page's +0xf60 and the water renderer's site
|
||||
// its +0xf50 (frame_rate.c).
|
||||
// The time of day's site of the set ostep (patches-v111.txt) calls the page's +0xf60, the water renderer's site its
|
||||
// +0xf50, and the surfaces' fixed-step sites of the set owater its +0xf20 (frame_rate.c).
|
||||
__attribute__((constructor)) static void day_register(void) {
|
||||
if (!RT_V111) return;
|
||||
rt_register_host(RT_PATCH_PAGE + 0xf60, frame_rate_day_host);
|
||||
rt_register_host(RT_PATCH_PAGE + 0xf50, frame_rate_water_host);
|
||||
rt_register_host(RT_PATCH_PAGE + 0xf20, frame_rate_sim_host);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// a load (no update of Link within GAMEPLAY_POLLS polls) start nothing: B closes the pause menu, and that press is the
|
||||
// menu's. Under the game's Swap Jump Controls B is the jump, which a B sprint button keeps from the game while Link
|
||||
// moves: L3 is the one to use then.
|
||||
// Patch page slots: the set's sites call +0xf40 and +0xf30; +0xf50 to +0xff0 belong to other sets (runtime/patches.c,
|
||||
// mouse_direct.c, ov_zstd.c). A slot registered twice ends the start (dispatch.c rt_register_host).
|
||||
// Patch page slots: the set's sites call +0xf40 and +0xf30; +0xf20 and +0xf50 to +0xff0 belong to other sets
|
||||
// (runtime/patches.c, mouse_direct.c, ov_zstd.c). A slot registered twice ends the start (dispatch.c rt_register_host).
|
||||
//
|
||||
// Link's state: the id at [[[[Link +0x18] +0x270] +0x188] +0x1c0] +0x28 (+0x4c when that reads 0x11a, a state that
|
||||
// wraps another), the same field main+0x4aed50 compares with 1 (Walk) before the game starts a sprint.
|
||||
|
||||
Reference in New Issue
Block a user