mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 09:19:58 -04:00
Keep movies with their sound at any frame rate: one movie frame per update, and the pacer keeps the movie's slots through a late frame.
The game's movie player adds the time manager's step to an accumulator at each update and advances the movie by whole pictures of it, at most the player's limit per update, which is one for the Triforce movie. While a movie plays the game is held at 60 updates a second, but every late frame cost an update, the pacer started its slots again from the late one, and the steady step's payback of the lost time came as steps over one frame, which the player cannot turn into more than one picture. So each late frame put the picture further behind the sound, which plays by the clock, and it never caught up. While a movie plays the step is now exactly one movie frame, and the pacer keeps the movie's slots through a lateness of up to a second, presenting the frames after a late one at once until the game is back on them. The updates then average the movie's rate, and the picture, the event's update count and the game's clock all stay with the sound. movie_clock = 0 gives the earlier behaviour. The movie log now measures the picture on screen against real time where the game releases it (the game fetches pictures ahead into a list of its own) and reports it at the end of each movie. test_hitch = <every>:<ms> makes a frame that much late every so many presents, for test runs. Measured on the Triforce movie (event Dm_Kokiri_0095, 7,040 pictures, 117 s), one exe with movie_clock = 0 against 1, and a 70 ms late frame every two seconds (test_hitch = 120:70), as a run with natural hitches had shown a drift of 40 ms every ten seconds. Drift of the picture on screen behind real time, from the movie's first 10 s to its end: fps_limit before (updates/s, drift at the end) after (updates/s, drift over the movie) unlimited 58.86, 2,187 ms behind 60.22, flat at 53 to 55 ms 144 58.86, 2,196 ms behind 60.04, flat at -11 to -15 ms 120 58.98, 2,257 ms behind 60.20, flat at -1 to 0 ms 60 58.88, 2,220 ms behind 59.98, flat at -21 to -22 ms Without the late frames both kept time (unlimited: before flat at 21 ms, after flat at -13 ms). The selftest, --probe-cfg, --probe-kernel, --probe-movie and tests/frame_step_check.py pass; the check now plays a movie started at 240 fps with late and short frames and needs exactly one frame every update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -235,6 +235,8 @@ double frame_step_game_hz(void) {
|
||||
// RivaTuner Statistics Server (rtss_limit.c) gets the same limit; while it limits this process the pacer holds no
|
||||
// frames, so the two never stack. NX2NAVI_RTSS=0 and frame generation (RTSS would count the generated frames) keep it out.
|
||||
static double paced_hz; // the game frames a second the newest frame_step_cap_ns paces at (ocarina_step); 0: none
|
||||
static int movie_paced; // the movie rate the newest frame_step_cap_ns paces at (ocarina_step, frame_step_movie_hz); 0: none
|
||||
int frame_step_movie_hz(void) { return movie_paced; }
|
||||
uint64_t frame_step_cap_ns(void) {
|
||||
frame_limit_live();
|
||||
static int rtss_allowed = -1;
|
||||
@@ -245,6 +247,12 @@ uint64_t frame_step_cap_ns(void) {
|
||||
int rtss = rtss_allowed && !vk_fg_wanted() && !vk_dlssg_active();
|
||||
int gen = generated_factor();
|
||||
int movie_hz = movie_cap_hz();
|
||||
static int movie_clock = -1; // NX2NAVI_MOVIE_CLOCK=0: the steady step and the usual pacing through a movie too
|
||||
if (movie_clock < 0) {
|
||||
const char *e = cfg_get("NX2NAVI_MOVIE_CLOCK");
|
||||
movie_clock = !(e && !strcmp(e, "0"));
|
||||
}
|
||||
movie_paced = movie_clock ? movie_hz : 0;
|
||||
static int movie_was, movie_logs;
|
||||
if (!!movie_hz != movie_was) {
|
||||
movie_was = !!movie_hz;
|
||||
@@ -392,12 +400,33 @@ static void ocarina_step_reset(void) {
|
||||
os_owed = 0;
|
||||
}
|
||||
|
||||
// While a movie plays (frame_step_cap_ns paces the game at the movie's rate) the step is exactly one movie frame, whatever
|
||||
// the display intervals; NX2NAVI_MOVIE_CLOCK=0 leaves movies to the steady step (comparison runs). The game's movie
|
||||
// player (main+0x3b5ca60) adds the time manager's seconds times 60 to an accumulator at each update and advances the
|
||||
// movie by its whole pictures, at most the player's limit per update (+0x20, set at main+0x3b5d094: 1, or 2 in one of
|
||||
// its modes), keeping the rest. The Triforce movie showed one picture per update (600 pictures in 600 updates at 59.6
|
||||
// updates a second), so the time a late frame left owed, which the steady step pays back as steps over one frame, never
|
||||
// became pictures: the picture fell behind its sound, which plays by the clock, by each late frame for good. The
|
||||
// movie's event counts updates as 60 Hz frames too (frame_step_cap_ns). So the updates themselves keep the clock
|
||||
// (nvn_api_obj.c pace keeps the movie's slots through a late frame) and each counts as one movie frame, for the
|
||||
// picture, the event and the game's clock alike. The filter starts again at a movie's start and end, so neither rate's
|
||||
// intervals reach the other.
|
||||
static double ocarina_step(double dt) {
|
||||
static int steady = -1;
|
||||
static int steady = -1, movie_was;
|
||||
if (steady < 0) {
|
||||
const char *e = cfg_get("NX2NAVI_STEP_STEADY");
|
||||
steady = !(e && !strcmp(e, "0"));
|
||||
}
|
||||
if (movie_paced != movie_was) {
|
||||
movie_was = movie_paced;
|
||||
ocarina_step_reset();
|
||||
}
|
||||
if (movie_paced > 0) {
|
||||
double step = 1.0 / movie_paced;
|
||||
if (os_step_lo <= 0 || step < os_step_lo) os_step_lo = step;
|
||||
if (step > os_step_hi) os_step_hi = step;
|
||||
return step;
|
||||
}
|
||||
if (dt > STEP_MAX_S) dt = STEP_MAX_S;
|
||||
os_ring[os_next++ % OSTEP_WINDOW] = dt;
|
||||
if (os_count < OSTEP_WINDOW) os_count++;
|
||||
|
||||
Reference in New Issue
Block a user