Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Needs Testing) Improve V-Sync and frame-rate synchronization #234

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion include/text_strings.h.in
Expand Up @@ -28,7 +28,6 @@
#define TEXT_OPT_LINEAR _("Linear")
#define TEXT_OPT_MVOLUME _("Master Volume")
#define TEXT_OPT_VSYNC _("Vertical Sync")
#define TEXT_OPT_DOUBLE _("Double")
#define TEXT_RESET_WINDOW _("Reset Window")
#define TEXT_OPT_HUD _("HUD")

Expand Down
23 changes: 6 additions & 17 deletions src/game/options_menu.c
Expand Up @@ -78,7 +78,6 @@ static const u8 optsVideoStr[][32] = {
{ TEXT_OPT_LINEAR },
{ TEXT_RESET_WINDOW },
{ TEXT_OPT_VSYNC },
{ TEXT_OPT_DOUBLE },
{ TEXT_OPT_HUD },
};

Expand Down Expand Up @@ -122,12 +121,6 @@ static const u8 *filterChoices[] = {
optsVideoStr[3],
};

static const u8 *vsyncChoices[] = {
toggleStr[0],
toggleStr[1],
optsVideoStr[6],
};

enum OptType {
OPT_INVALID = 0,
OPT_TOGGLE,
Expand Down Expand Up @@ -195,11 +188,7 @@ static void optmenu_act_exit(UNUSED struct Option *self, s32 arg) {
}

static void optvideo_reset_window(UNUSED struct Option *self, s32 arg) {
if (!arg) {
// Restrict reset to A press and not directions
configWindow.reset = true;
configWindow.settings_changed = true;
}
if (!arg) configWindow.reset = true; // Restrict reset to A press and not directions
}

/* submenu option lists */
Expand Down Expand Up @@ -237,10 +226,10 @@ static struct Option optsControls[] = {

static struct Option optsVideo[] = {
DEF_OPT_TOGGLE( optsVideoStr[0], &configWindow.fullscreen ),
DEF_OPT_CHOICE( optsVideoStr[5], &configWindow.vsync, vsyncChoices ),
DEF_OPT_TOGGLE( optsVideoStr[5], &configWindow.vsync ),
DEF_OPT_CHOICE( optsVideoStr[1], &configFiltering, filterChoices ),
DEF_OPT_BUTTON( optsVideoStr[4], optvideo_reset_window ),
DEF_OPT_TOGGLE( optsVideoStr[7], &configHUD ),
DEF_OPT_TOGGLE( optsVideoStr[6], &configHUD ),
};

static struct Option optsAudio[] = {
Expand Down Expand Up @@ -484,7 +473,7 @@ void optmenu_toggle(void) {

currentMenu = &menuMain;
optmenu_open = 1;

/* Resets l_counter to 0 every time the options menu is open */
l_counter = 0;
} else {
Expand Down Expand Up @@ -516,7 +505,7 @@ void optmenu_check_buttons(void) {

if (gPlayer1Controller->buttonPressed & R_TRIG)
optmenu_toggle();

/* Enables cheats if the user press the L trigger 3 times while in the options menu. Also plays a sound. */

if ((gPlayer1Controller->buttonPressed & L_TRIG) && !Cheats.EnableCheats) {
Expand All @@ -528,7 +517,7 @@ void optmenu_check_buttons(void) {
l_counter++;
}
}

if (!optmenu_open) return;

u8 allowInput = 0;
Expand Down
16 changes: 7 additions & 9 deletions src/pc/configfile.c
Expand Up @@ -36,15 +36,13 @@ struct ConfigOption {

// Video/audio stuff
ConfigWindow configWindow = {
.x = SDL_WINDOWPOS_CENTERED,
.y = SDL_WINDOWPOS_CENTERED,
.w = DESIRED_SCREEN_WIDTH,
.h = DESIRED_SCREEN_HEIGHT,
.vsync = 1,
.reset = false,
.x = SDL_WINDOWPOS_CENTERED,
.y = SDL_WINDOWPOS_CENTERED,
.w = DESIRED_SCREEN_WIDTH,
.h = DESIRED_SCREEN_HEIGHT,
.reset = false,
.vsync = true,
.fullscreen = false,
.exiting_fullscreen = false,
.settings_changed = false,
};
unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point
unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME
Expand Down Expand Up @@ -86,7 +84,7 @@ static const struct ConfigOption options[] = {
{.name = "window_y", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.y},
{.name = "window_w", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.w},
{.name = "window_h", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.h},
{.name = "vsync", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.vsync},
{.name = "vsync", .type = CONFIG_TYPE_UINT, .boolValue = &configWindow.vsync},
{.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering},
{.name = "master_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configMasterVolume},
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
Expand Down
8 changes: 3 additions & 5 deletions src/pc/configfile.h
Expand Up @@ -11,11 +11,9 @@

typedef struct {
unsigned int x, y, w, h;
unsigned int vsync;
bool reset;
bool fullscreen;
bool exiting_fullscreen;
bool settings_changed;
bool vsync;
bool reset;
bool fullscreen;
} ConfigWindow;

extern ConfigWindow configWindow;
Expand Down