add --syncframes to override vblank count detection

This commit is contained in:
fgsfds 2020-09-07 15:48:19 +03:00
parent 544f2e74aa
commit fb22013eab
3 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include "cheats.h"
#include "pc_main.h"
#include "platform.h"
#include "macros.h"
#include <strings.h>
#include <stdlib.h>
@ -34,7 +35,7 @@ static inline int arg_string(const char *name, const char *value, char *target)
return 1;
}
static inline int arg_uint(const char *name, const char *value, unsigned int *target) {
static inline int arg_uint(UNUSED const char *name, const char *value, unsigned int *target) {
const unsigned long int v = strtoul(value, NULL, 0);
*target = v;
return 1;
@ -60,6 +61,9 @@ void parse_cli_opts(int argc, char* argv[]) {
else if (strcmp(argv[i], "--poolsize") == 0) // Main pool size
arg_uint("--poolsize", argv[++i], &gCLIOpts.PoolSize);
else if (strcmp(argv[i], "--syncframes") == 0) // VBlanks to wait
arg_uint("--syncframes", argv[++i], &gCLIOpts.SyncFrames);
else if (strcmp(argv[i], "--configfile") == 0 && (i + 1) < argc)
arg_string("--configfile", argv[++i], gCLIOpts.ConfigFile);

View File

@ -7,6 +7,7 @@ struct PCCLIOptions {
unsigned int SkipIntro;
unsigned int FullScreen;
unsigned int PoolSize;
unsigned int SyncFrames;
char ConfigFile[SYS_MAX_PATH];
char SavePath[SYS_MAX_PATH];
char GameDir[SYS_MAX_PATH];

View File

@ -142,7 +142,7 @@ static inline void gfx_sdl_set_vsync(const bool enabled) {
if (enabled) {
// try to detect refresh rate
SDL_GL_SetSwapInterval(1);
const int vblanks = test_vsync();
const int vblanks = gCLIOpts.SyncFrames ? (int)gCLIOpts.SyncFrames : test_vsync();
if (vblanks) {
printf("determined swap interval: %d\n", vblanks);
SDL_GL_SetSwapInterval(vblanks);