Revert "Merge branch 'nightly' into master"

This reverts commit 2e8a821fa3, reversing
changes made to d499f55402.
This commit is contained in:
fgsfds 2020-05-19 02:38:59 +03:00
parent 2e8a821fa3
commit c18e70f44e
6 changed files with 42 additions and 40 deletions

View file

@ -2107,7 +2107,7 @@ const Gfx dl_hud_img_load_tex_block[] = {
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD),
gsDPLoadSync(), gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 16 * 16 - 1, CALC_DXT(16, G_IM_SIZ_16b_BYTES)), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 16 * 16 - 1, CALC_DXT(16, G_IM_SIZ_16b_BYTES)),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 4, G_TX_NOLOD, G_TX_CLAMP, 4, G_TX_NOLOD), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD),
gsDPSetTileSize(0, 0, 0, (16 - 1) << G_TEXTURE_IMAGE_FRAC, (16 - 1) << G_TEXTURE_IMAGE_FRAC), gsDPSetTileSize(0, 0, 0, (16 - 1) << G_TEXTURE_IMAGE_FRAC, (16 - 1) << G_TEXTURE_IMAGE_FRAC),
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
@ -2144,7 +2144,7 @@ const Gfx dl_rgba16_load_tex_block[] = {
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD),
gsDPLoadSync(), gsDPLoadSync(),
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 16 * 16 - 1, CALC_DXT(16, G_IM_SIZ_16b_BYTES)), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 16 * 16 - 1, CALC_DXT(16, G_IM_SIZ_16b_BYTES)),
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 4, G_TX_NOLOD, G_TX_CLAMP, 4, G_TX_NOLOD), gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD),
gsDPSetTileSize(0, 0, 0, (16 - 1) << G_TEXTURE_IMAGE_FRAC, (16 - 1) << G_TEXTURE_IMAGE_FRAC), gsDPSetTileSize(0, 0, 0, (16 - 1) << G_TEXTURE_IMAGE_FRAC, (16 - 1) << G_TEXTURE_IMAGE_FRAC),
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };

View file

@ -27,6 +27,8 @@
#define TEXT_OPT_NEAREST _("Nearest") #define TEXT_OPT_NEAREST _("Nearest")
#define TEXT_OPT_LINEAR _("Linear") #define TEXT_OPT_LINEAR _("Linear")
#define TEXT_OPT_MVOLUME _("Master Volume") #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_RESET_WINDOW _("Reset Window")
#define TEXT_OPT_UNBOUND _("NONE") #define TEXT_OPT_UNBOUND _("NONE")

View file

@ -72,7 +72,9 @@ static const u8 optsVideoStr[][32] = {
{ TEXT_OPT_TEXFILTER }, { TEXT_OPT_TEXFILTER },
{ TEXT_OPT_NEAREST }, { TEXT_OPT_NEAREST },
{ TEXT_OPT_LINEAR }, { TEXT_OPT_LINEAR },
{ TEXT_RESET_WINDOW } { TEXT_RESET_WINDOW },
{ TEXT_OPT_VSYNC },
{ TEXT_OPT_DOUBLE },
}; };
static const u8 optsAudioStr[][32] = { static const u8 optsAudioStr[][32] = {
@ -112,6 +114,12 @@ static const u8 *filterChoices[] = {
optsVideoStr[3], optsVideoStr[3],
}; };
static const u8 *vsyncChoices[] = {
toggleStr[0],
toggleStr[1],
optsVideoStr[6],
};
enum OptType { enum OptType {
OPT_INVALID = 0, OPT_INVALID = 0,
OPT_TOGGLE, OPT_TOGGLE,
@ -178,8 +186,12 @@ static void optmenu_act_exit(UNUSED struct Option *self, s32 arg) {
if (!arg) game_exit(); // only exit on A press and not directions if (!arg) game_exit(); // only exit on A press and not directions
} }
static void optvide_reset_window(UNUSED struct Option *self, s32 arg) { static void optvideo_reset_window(UNUSED struct Option *self, s32 arg) {
if (!arg) configWindow.reset = true;; // Restrict reset to A press and not directions if (!arg) {
// Restrict reset to A press and not directions
configWindow.reset = true;
configWindow.settings_changed = true;
}
} }
/* submenu option lists */ /* submenu option lists */
@ -217,8 +229,9 @@ static struct Option optsControls[] = {
static struct Option optsVideo[] = { static struct Option optsVideo[] = {
DEF_OPT_TOGGLE( optsVideoStr[0], &configWindow.fullscreen ), DEF_OPT_TOGGLE( optsVideoStr[0], &configWindow.fullscreen ),
DEF_OPT_CHOICE( optsVideoStr[5], &configWindow.vsync, vsyncChoices ),
DEF_OPT_CHOICE( optsVideoStr[1], &configFiltering, filterChoices ), DEF_OPT_CHOICE( optsVideoStr[1], &configFiltering, filterChoices ),
DEF_OPT_BUTTON( optsVideoStr[4], optvide_reset_window ), DEF_OPT_BUTTON( optsVideoStr[4], optvideo_reset_window ),
}; };
static struct Option optsAudio[] = { static struct Option optsAudio[] = {

View file

@ -40,10 +40,11 @@ ConfigWindow configWindow = {
.y = SDL_WINDOWPOS_CENTERED, .y = SDL_WINDOWPOS_CENTERED,
.w = DESIRED_SCREEN_WIDTH, .w = DESIRED_SCREEN_WIDTH,
.h = DESIRED_SCREEN_HEIGHT, .h = DESIRED_SCREEN_HEIGHT,
.vsync = 1,
.reset = false, .reset = false,
.vsync = false,
.fullscreen = false, .fullscreen = false,
.exiting_fullscreen = false, .exiting_fullscreen = false,
.settings_changed = false,
}; };
unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point
unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME
@ -84,6 +85,7 @@ static const struct ConfigOption options[] = {
{.name = "window_y", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.y}, {.name = "window_y", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.y},
{.name = "window_w", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.w}, {.name = "window_w", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.w},
{.name = "window_h", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.h}, {.name = "window_h", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.h},
{.name = "vsync", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.vsync},
{.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering}, {.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering},
{.name = "master_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configMasterVolume}, {.name = "master_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configMasterVolume},
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA}, {.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},

View file

@ -11,10 +11,11 @@
typedef struct { typedef struct {
unsigned int x, y, w, h; unsigned int x, y, w, h;
unsigned int vsync;
bool reset; bool reset;
bool vsync;
bool fullscreen; bool fullscreen;
bool exiting_fullscreen; bool exiting_fullscreen;
bool settings_changed;
} ConfigWindow; } ConfigWindow;
extern ConfigWindow configWindow; extern ConfigWindow configWindow;

View file

@ -39,9 +39,12 @@
# define FRAMERATE 30 # define FRAMERATE 30
#endif #endif
static const Uint32 FRAME_TIME = 1000 / FRAMERATE;
static SDL_Window *wnd; static SDL_Window *wnd;
static SDL_GLContext ctx = NULL; static SDL_GLContext ctx = NULL;
static int inverted_scancode_table[512]; static int inverted_scancode_table[512];
static Uint32 frame_start = 0;
const SDL_Scancode windows_scancode_table[] = const SDL_Scancode windows_scancode_table[] =
{ {
@ -110,9 +113,9 @@ static void gfx_sdl_set_fullscreen() {
} }
static void gfx_sdl_reset_dimension_and_pos() { static void gfx_sdl_reset_dimension_and_pos() {
if (configWindow.exiting_fullscreen) if (configWindow.exiting_fullscreen) {
configWindow.exiting_fullscreen = false; configWindow.exiting_fullscreen = false;
else if (configWindow.reset) { } else if (configWindow.reset) {
configWindow.x = SDL_WINDOWPOS_CENTERED; configWindow.x = SDL_WINDOWPOS_CENTERED;
configWindow.y = SDL_WINDOWPOS_CENTERED; configWindow.y = SDL_WINDOWPOS_CENTERED;
configWindow.w = DESIRED_SCREEN_WIDTH; configWindow.w = DESIRED_SCREEN_WIDTH;
@ -123,29 +126,14 @@ static void gfx_sdl_reset_dimension_and_pos() {
configWindow.fullscreen = false; configWindow.fullscreen = false;
return; return;
} }
} else } else if (!configWindow.settings_changed) {
return; return;
SDL_SetWindowSize(wnd, configWindow.w, configWindow.h);
SDL_SetWindowPosition(wnd, configWindow.x, configWindow.y);
} }
static bool test_vsync(void) { configWindow.settings_changed = false;
// Even if SDL_GL_SetSwapInterval succeeds, it doesn't mean that VSync actually works. SDL_SetWindowSize(wnd, configWindow.w, configWindow.h);
// A 60 Hz monitor should have a swap interval of 16.67 milliseconds. SDL_SetWindowPosition(wnd, configWindow.x, configWindow.y);
// If it takes less than 12 milliseconds, assume that VSync is not working. SDL_GL_SetSwapInterval(configWindow.vsync); // in case vsync changed
// SDL_GetTicks() probably does not offer enough precision for this kind of shit.
Uint32 start, end;
// do an extra swap, sometimes the first one takes longer (maybe creates buffers?)
SDL_GL_SwapWindow(wnd);
SDL_GL_SwapWindow(wnd);
start = SDL_GetTicks();
SDL_GL_SwapWindow(wnd);
end = SDL_GetTicks();
return (end - start >= 12);
} }
static void gfx_sdl_init(void) { static void gfx_sdl_init(void) {
@ -165,11 +153,9 @@ static void gfx_sdl_init(void) {
if (gCLIOpts.FullScreen == 1) if (gCLIOpts.FullScreen == 1)
configWindow.fullscreen = true; configWindow.fullscreen = true;
else if (gCLIOpts.FullScreen == 2)
if (gCLIOpts.FullScreen == 2)
configWindow.fullscreen = false; configWindow.fullscreen = false;
const char* window_title = const char* window_title =
#ifndef USE_GLES #ifndef USE_GLES
"Super Mario 64 PC port (OpenGL)"; "Super Mario 64 PC port (OpenGL)";
@ -183,14 +169,11 @@ static void gfx_sdl_init(void) {
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE
); );
ctx = SDL_GL_CreateContext(wnd); ctx = SDL_GL_CreateContext(wnd);
SDL_GL_SetSwapInterval(2);
SDL_GL_SetSwapInterval(configWindow.vsync);
gfx_sdl_set_fullscreen(); gfx_sdl_set_fullscreen();
configWindow.vsync = test_vsync();
if (!configWindow.vsync)
printf("Warning: VSync is not enabled or not working. Falling back to timer for synchronization\n");
for (size_t i = 0; i < sizeof(windows_scancode_table) / sizeof(SDL_Scancode); i++) { for (size_t i = 0; i < sizeof(windows_scancode_table) / sizeof(SDL_Scancode); i++) {
inverted_scancode_table[windows_scancode_table[i]] = i; inverted_scancode_table[windows_scancode_table[i]] = i;
} }
@ -281,6 +264,7 @@ static void gfx_sdl_handle_events(void) {
} }
static bool gfx_sdl_start_frame(void) { static bool gfx_sdl_start_frame(void) {
frame_start = SDL_GetTicks();
return true; return true;
} }