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:
@@ -28,7 +28,8 @@ void rt_patch_switch(int set, int on) { (void)set, (void)on; }
|
||||
void *rt_patch_page(void) { return page; }
|
||||
void rt_log(const char *fmt, ...) { (void)fmt; }
|
||||
double gfx_window_refresh_hz(void) { return 144; }
|
||||
int ov_movie_live(void) { return 0; }
|
||||
static int movie; // a movie plays (frame_rate.c movie_cap_hz)
|
||||
int ov_movie_live(void) { return movie; }
|
||||
int vk_fg_generating(void) { return 0; }
|
||||
float dbg_speed_factor(void) { return 1.0f; } // the debug menu's game speed: normal
|
||||
int vk_fg_active(void) { return 0; }
|
||||
@@ -128,6 +129,21 @@ int main(int argc, char **argv) {
|
||||
for (int i = 0; i < 12; i++) f = present(2 * p240);
|
||||
CHECK(f > 0.49f, "240 -> 120 fps: %.4f frames after 12", f);
|
||||
|
||||
// A movie started at 240 fps: exactly one frame from its first update, late and short frames included, as the game
|
||||
// shows one picture per update; at its end the step follows the frame limit again within 12 frames.
|
||||
set_limit("unlimited");
|
||||
for (int i = 0; i < 300; i++) present(p240);
|
||||
movie = 1;
|
||||
for (int i = 0; i < 600; i++) {
|
||||
float g = present(i % 120 == 7 ? 0.070 : i % 120 == 8 ? 0.004 : p60);
|
||||
CHECK(g == 1.0f, "movie, frame %d: %.6f frames", i, g);
|
||||
}
|
||||
CHECK(frame_step_movie_hz() == 60, "the movie's rate: %d", frame_step_movie_hz());
|
||||
movie = 0;
|
||||
float after = 0;
|
||||
for (int i = 0; i < 12; i++) after = present(p240);
|
||||
CHECK(fabsf(after - 0.25f) < 0.002f, "after the movie: %.4f frames", after);
|
||||
|
||||
// A frame longer than 1/15 s slows the game down; the step never leaves 1/480..1/15 s.
|
||||
set_limit("unlimited");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
||||
Reference in New Issue
Block a user