From fbfe4b4564d492d66943aa755e770c1e255f6950 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 14 Jan 2024 20:48:22 +0100 Subject: [PATCH] port: net: allow up to 120fps in netgames --- port/include/video.h | 1 + port/src/pdsched.c | 7 ++++++- port/src/video.c | 8 ++++++++ src/game/timing.c | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/port/include/video.h b/port/include/video.h index 105f78699..2b39cf46c 100644 --- a/port/include/video.h +++ b/port/include/video.h @@ -36,6 +36,7 @@ void videoSetWindowOffset(s32 x, s32 y); void videoSetFullscreen(s32 fs); void videoSetTextureFilter(u32 filter); void videoSetTextureFilter2D(u32 filter); +void videoCapFramerate(s32 limit); s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize); void videoSetFramebuffer(s32 target); diff --git a/port/src/pdsched.c b/port/src/pdsched.c index 02c4f4240..234c43154 100644 --- a/port/src/pdsched.c +++ b/port/src/pdsched.c @@ -243,7 +243,12 @@ void schedStartFrame(OSSched *sc) { videoStartFrame(); if (g_Vars.diffframe60) { - netStartFrame(); + if (g_NetMode) { + videoCapFramerate(120); + netStartFrame(); + } else { + videoCapFramerate(0); + } } } diff --git a/port/src/video.c b/port/src/video.c index 18da94fc0..4e9244234 100644 --- a/port/src/video.c +++ b/port/src/video.c @@ -202,6 +202,14 @@ void videoSetTextureFilter2D(u32 filter) texFilter2D = !!filter; } +void videoCapFramerate(s32 limit) +{ + if (vidFramerateLimit > 0 && vidFramerateLimit < limit) { + limit = vidFramerateLimit; + } + wmAPI->set_target_fps(limit ? limit : vidFramerateLimit); +} + s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize) { return gfx_create_framebuffer(w, h, upscale, autoresize); diff --git a/src/game/timing.c b/src/game/timing.c index aabeec728..9a7c8e380 100644 --- a/src/game/timing.c +++ b/src/game/timing.c @@ -49,7 +49,7 @@ void frametimeCalculate(void) #ifdef PLATFORM_N64 g_Vars.mininc60 = 1; #else - g_Vars.mininc60 = g_NetMode ? 1 : g_TickRateDiv; + g_Vars.mininc60 = g_TickRateDiv; #endif frametimeApply(diffframe60, diffframe240, count);