From 05d9616d07e1bd85ee99b777cfe26b07cf8b4a7b Mon Sep 17 00:00:00 2001 From: Shaun Inman Date: Fri, 10 Feb 2023 21:01:24 -0500 Subject: [PATCH] light cleanup before GFX refactor --- src/common/api.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/common/api.c b/src/common/api.c index cb79a43..910c48a 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -153,6 +153,7 @@ GFX_Fonts font; /////////////////////////////// +static int _; SDL_Surface* GFX_init(int mode) { SDL_Init(SDL_INIT_VIDEO); SDL_ShowCursor(0); @@ -240,8 +241,7 @@ void GFX_quit(void) { SDL_FreeSurface(gfx.assets); - int arg = 1; - ioctl(gfx.fb, OWLFB_WAITFORVSYNC, &arg); + ioctl(gfx.fb, OWLFB_WAITFORVSYNC, &_); GFX_clearAll(); munmap(gfx.map, gfx.map_size); @@ -266,14 +266,12 @@ void GFX_setVsync(int vsync) { gfx.vsync = vsync; } +#define FRAME_BUDGET 17 // 60fps static uint32_t frame_start = 0; void GFX_startFrame(void) { frame_start = SDL_GetTicks(); } void GFX_flip(SDL_Surface* screen) { - static int ticks = 0; - ticks += 1; - gfx.vinfo.yoffset = gfx.buffer * SCREEN_HEIGHT; ioctl(gfx.fb, FBIOPAN_DISPLAY, &gfx.vinfo); @@ -281,23 +279,18 @@ void GFX_flip(SDL_Surface* screen) { if (gfx.buffer>=GFX_BUFFER_COUNT) gfx.buffer -= GFX_BUFFER_COUNT; screen->pixels = gfx.map + (gfx.buffer * gfx.buffer_size); - // TODO: this doesn't make sense here but it's the only way to reduce flickering when changing volume/brightness... if (gfx.vsync!=VSYNC_OFF) { // this limiting condition helps SuperFX chip games - #define FRAME_BUDGET 17 // 60fps if (gfx.vsync==VSYNC_STRICT || frame_start==0 || SDL_GetTicks()-frame_start