Skip to content

Commit

Permalink
port: net: allow up to 120fps in netgames
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfdsfgs committed Jan 14, 2024
1 parent 4cb9950 commit fbfe4b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions port/include/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion port/src/pdsched.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ void schedStartFrame(OSSched *sc)
{
videoStartFrame();
if (g_Vars.diffframe60) {
netStartFrame();
if (g_NetMode) {
videoCapFramerate(120);
netStartFrame();
} else {
videoCapFramerate(0);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions port/src/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/game/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fbfe4b4

Please sign in to comment.