mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 04:19:57 -04:00
Hold the game at 60 fps while a movie plays, so the intro's narration no longer doubles and the dream shows at high refresh rates.
The game's event script times the intro movie's narration and fades by counting updates as 60 Hz frames. At 144 fps everything ran 2.4 times early: each line started over the one before, and the closing fade hid the dream. frame_step_cap_ns caps the rate at the movie's 60 fps from the decoder's start to its end of stream (ov_movie_live); with fps_limit = unlimited the cap is the movie's rate. With RTSS limiting, the game's own limiter holds a new rate until RTSS has applied it. NX2NAVI_MOVIE_FPS sets the cap, 0 turns it off. From a tester's fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -185,6 +185,20 @@ static void frame_limit_live(void) {
|
||||
else rt_log("frame rate: limit at the monitor's refresh rate (60 until the window measures it)");
|
||||
}
|
||||
|
||||
// NX2NAVI_MOVIE_FPS (default 60; 0 = off): the game's frame rate while a movie plays (ov_movie2.c ov_movie_live). A
|
||||
// movie's event counts the game's updates as 60 Hz frames whatever the step: at 144 fps the intro's narration lines
|
||||
// started 2.4 times too early, each over the one before, and its closing fade to black came at 65 s of the movie's
|
||||
// 154, hiding the whole dream. The movies are 60 fps, so the cap shows the same pictures.
|
||||
static int movie_cap_hz(void) {
|
||||
static int hz = -1;
|
||||
if (hz < 0) {
|
||||
const char *e = cfg_get("NX2NAVI_MOVIE_FPS");
|
||||
hz = e && *e ? atoi(e) : 60;
|
||||
if (hz && hz < LIMIT_MIN_HZ) hz = 60;
|
||||
}
|
||||
return hz && ov_movie_live() ? hz : 0;
|
||||
}
|
||||
|
||||
// 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.
|
||||
uint64_t frame_step_cap_ns(void) {
|
||||
@@ -194,16 +208,28 @@ uint64_t frame_step_cap_ns(void) {
|
||||
const char *e = cfg_get("NX2NAVI_RTSS");
|
||||
rtss = !(e && !strcmp(e, "0")) && !vk_fg_wanted();
|
||||
}
|
||||
if (limit_hz == -2) { // unlimited: the pacer does not hold frames, and RTSS's limit is cleared
|
||||
int movie_hz = movie_cap_hz();
|
||||
static int movie_was, movie_logs;
|
||||
if (!!movie_hz != movie_was) {
|
||||
movie_was = !!movie_hz;
|
||||
if (movie_logs++ < 40) { // the first 20 movies
|
||||
if (movie_hz) rt_log("frame rate: a movie plays: at most %d fps until it ends (NX2NAVI_MOVIE_FPS)", movie_hz);
|
||||
else rt_log("frame rate: the movie ended: the frame limit again");
|
||||
}
|
||||
}
|
||||
if (limit_hz == -2 && !movie_hz) { // unlimited: the pacer does not hold frames, and RTSS's limit is cleared
|
||||
rtss_limit_want(rtss ? 0 : -1);
|
||||
return 0;
|
||||
}
|
||||
double hz = shown_hz(limit_hz ? limit_hz : gfx_window_refresh_hz());
|
||||
// unlimited during a movie: the movie's rate, doubled for frame generation's halving below
|
||||
double hz = limit_hz == -2 ? movie_hz * (vk_fg_generating() ? 2 : 1)
|
||||
: shown_hz(limit_hz ? limit_hz : gfx_window_refresh_hz());
|
||||
double max = frame_free_running() ? LIMIT_FREE_MAX_HZ : LIMIT_MAX_HZ;
|
||||
if (hz > max) hz = max;
|
||||
// Frame generation presents a generated frame between each two of the game's (vk_fg.cpp): the game is paced at
|
||||
// half the limit then, so the screen shows the limit
|
||||
if (vk_fg_generating()) hz /= 2;
|
||||
if (movie_hz && hz > movie_hz) hz = movie_hz;
|
||||
rtss_limit_want(rtss ? (int64_t)(hz * 1000 + 0.5) : -1);
|
||||
if (rtss_limit_active()) return 0;
|
||||
return (uint64_t)(1e9 / hz + 0.5);
|
||||
|
||||
Reference in New Issue
Block a user