mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-10-18 19:22:41 +00:00
Added 30 or 60 FPS toggle
This commit is contained in:
parent
d7d26639a8
commit
f18007cd34
7 changed files with 31 additions and 17 deletions
|
@ -45,7 +45,7 @@ ConfigWindow configWindow = {
|
|||
.y = WAPI_WIN_CENTERPOS,
|
||||
.w = DESIRED_SCREEN_WIDTH,
|
||||
.h = DESIRED_SCREEN_HEIGHT,
|
||||
.vsync = 1,
|
||||
.vsync = 0,
|
||||
.reset = false,
|
||||
.fullscreen = false,
|
||||
.exiting_fullscreen = false,
|
||||
|
@ -110,6 +110,7 @@ unsigned int configNetworkSystem = 0;
|
|||
char configPlayerName[MAX_PLAYER_STRING] = "";
|
||||
unsigned int configPlayerModel = 0;
|
||||
unsigned int configPlayerPalette = 0;
|
||||
unsigned int config60Fps = 1;
|
||||
|
||||
static const struct ConfigOption options[] = {
|
||||
{.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen},
|
||||
|
@ -173,6 +174,7 @@ static const struct ConfigOption options[] = {
|
|||
{.name = "coop_player_name", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configPlayerName},
|
||||
{.name = "coop_player_model", .type = CONFIG_TYPE_UINT , .uintValue = &configPlayerModel},
|
||||
{.name = "coop_player_palette", .type = CONFIG_TYPE_UINT , .uintValue = &configPlayerPalette},
|
||||
{.name = "coop_60fps", .type = CONFIG_TYPE_UINT , .uintValue = &config60Fps},
|
||||
};
|
||||
|
||||
// Reads an entire line from a file (excluding the newline character) and returns an allocated string
|
||||
|
|
|
@ -77,6 +77,7 @@ extern unsigned int configNetworkSystem;
|
|||
extern char configPlayerName[];
|
||||
extern unsigned int configPlayerModel;
|
||||
extern unsigned int configPlayerPalette;
|
||||
extern unsigned int config60Fps;
|
||||
|
||||
void configfile_load(const char *filename);
|
||||
void configfile_save(const char *filename);
|
||||
|
|
|
@ -114,7 +114,7 @@ void djui_panel_update(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
sMoveAmount += moveMax / 10.0f;
|
||||
sMoveAmount += (config60Fps ? 1.0f : 2.0f) * (moveMax / 10.0f);
|
||||
if (sMoveAmount >= moveMax) {
|
||||
sMoveAmount = moveMax;
|
||||
if (parentBase != NULL) {
|
||||
|
|
|
@ -7,7 +7,7 @@ static void djui_panel_display_apply(UNUSED struct DjuiBase* caller) {
|
|||
}
|
||||
|
||||
void djui_panel_display_create(struct DjuiBase* caller) {
|
||||
f32 bodyHeight = 32 * 5 + 64 * 1 + 16 * 4;
|
||||
f32 bodyHeight = 32 * 6 + 64 * 1 + 16 * 5;
|
||||
|
||||
struct DjuiBase* defaultBase = NULL;
|
||||
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\D\\#1be700\\I\\#00b3ff\\S\\#ffef00\\P\\#ff0800\\L\\#1be700\\A\\#00b3ff\\Y");
|
||||
|
@ -29,11 +29,16 @@ void djui_panel_display_create(struct DjuiBase* caller) {
|
|||
djui_base_set_size_type(&checkbox4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&checkbox4->base, 1.0f, 32);
|
||||
|
||||
char* choices[3] = { "Nearest", "Linear", "Tripoint" };
|
||||
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Filtering", choices, 3, &configFiltering);
|
||||
char* filterChoices[3] = { "Nearest", "Linear", "Tripoint" };
|
||||
struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Filtering", filterChoices, 3, &configFiltering);
|
||||
djui_base_set_size_type(&selectionbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&selectionbox1->base, 1.0f, 32);
|
||||
|
||||
char* fpsChoices[3] = { "30", "60" };
|
||||
struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "FPS", fpsChoices, 2, &config60Fps);
|
||||
djui_base_set_size_type(&selectionbox2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&selectionbox2->base, 1.0f, 32);
|
||||
|
||||
struct DjuiButton* button6 = djui_button_create(&body->base, "Back");
|
||||
djui_base_set_size_type(&button6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
|
||||
djui_base_set_size(&button6->base, 1.0f, 64);
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
# define FRAMERATE 30
|
||||
#endif
|
||||
// time between consequtive game frames
|
||||
static const f64 sFrameTime = 1.0 / (2.0 * FRAMERATE);
|
||||
static const f64 sFrameTime = 1.0 / ((double)FRAMERATE);
|
||||
static f64 sFrameTargetTime = 0;
|
||||
extern "C" f64 clock_elapsed_f64(void);
|
||||
|
||||
|
@ -523,9 +523,10 @@ static bool gfx_dxgi_start_frame(void) {
|
|||
|
||||
dxgi.length_in_vsync_frames = configWindow.vsync;
|
||||
f64 curTime = clock_elapsed_f64();
|
||||
f64 frameTime = config60Fps ? (sFrameTime / 2.0) : sFrameTime;
|
||||
if (curTime > sFrameTargetTime) {
|
||||
sFrameTargetTime += sFrameTime;
|
||||
if (curTime > sFrameTargetTime + sFrameTime * 3) {
|
||||
sFrameTargetTime += frameTime;
|
||||
if (curTime > sFrameTargetTime + frameTime * 3) {
|
||||
sFrameTargetTime = curTime;
|
||||
}
|
||||
dxgi.dropped_frame = true;
|
||||
|
@ -544,7 +545,8 @@ static inline void sync_framerate_with_timer(void) {
|
|||
Sleep(delayMs);
|
||||
}
|
||||
}
|
||||
sFrameTargetTime += sFrameTime;
|
||||
f64 frameTime = config60Fps ? (sFrameTime / 2.0) : sFrameTime;
|
||||
sFrameTargetTime += frameTime;
|
||||
}
|
||||
|
||||
static void gfx_dxgi_swap_buffers_begin(void) {
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
# define FRAMERATE 30
|
||||
#endif
|
||||
// time between consequtive game frames
|
||||
static const f64 sFrameTime = 1.0 / (2.0 * FRAMERATE);
|
||||
static const f64 sFrameTime = 1.0 / ((double)FRAMERATE);
|
||||
static f64 sFrameTargetTime = 0;
|
||||
|
||||
static SDL_Window *wnd;
|
||||
|
@ -316,9 +316,10 @@ static void gfx_sdl_set_keyboard_callbacks(kb_callback_t on_key_down, kb_callbac
|
|||
|
||||
static bool gfx_sdl_start_frame(void) {
|
||||
f64 curTime = clock_elapsed_f64();
|
||||
f64 frameTime = config60Fps ? (sFrameTime / 2.0) : sFrameTime;
|
||||
if (curTime > sFrameTargetTime) {
|
||||
sFrameTargetTime += sFrameTime;
|
||||
if (curTime > sFrameTargetTime + sFrameTime * 3) {
|
||||
sFrameTargetTime += frameTime;
|
||||
if (curTime > sFrameTargetTime + frameTime * 3) {
|
||||
sFrameTargetTime = curTime;
|
||||
}
|
||||
return false;
|
||||
|
@ -334,7 +335,8 @@ static inline void sync_framerate_with_timer(void) {
|
|||
SDL_Delay(delayMs);
|
||||
}
|
||||
}
|
||||
sFrameTargetTime += sFrameTime;
|
||||
f64 frameTime = config60Fps ? (sFrameTime / 2.0) : sFrameTime;
|
||||
sFrameTargetTime += frameTime;
|
||||
}
|
||||
|
||||
static void gfx_sdl_swap_buffers_begin(void) {
|
||||
|
|
|
@ -139,11 +139,13 @@ void produce_one_frame(void) {
|
|||
|
||||
gfx_end_frame();
|
||||
|
||||
if (config60Fps) {
|
||||
gfx_start_frame();
|
||||
patch_interpolations();
|
||||
send_display_list(gGfxSPTask);
|
||||
gfx_end_frame();
|
||||
}
|
||||
}
|
||||
|
||||
void audio_shutdown(void) {
|
||||
if (audio_api) {
|
||||
|
|
Loading…
Reference in a new issue