diff --git a/MacGLide/Mac/GlideSettings_FSp.cpp b/MacGLide/Mac/GlideSettings_FSp.cpp index b6a2266..e7174d5 100644 --- a/MacGLide/Mac/GlideSettings_FSp.cpp +++ b/MacGLide/Mac/GlideSettings_FSp.cpp @@ -47,7 +47,7 @@ GlideSettings::IOErr GlideSettingsFSp::makeSettingsFolderFileSpec(const char* pa /** * Find/Create settings folder - * @return fnfErr means the CLassic environment wasn't found + * @return fnfErr means the Classic environment wasn't found */ GlideSettings::IOErr GlideSettingsFSp::init(const char* applicationname) { @@ -71,6 +71,7 @@ GlideSettings::IOErr GlideSettingsFSp::init(const char* applicationname) } } // Make references to various files + m_fsSettingsFile.vRefNum = 0; if (err == noErr) { err = makeSettingsFolderFileSpec(&s_SettingsFolderName[1], s_LogFileName, &m_fsLogFile); @@ -79,7 +80,6 @@ GlideSettings::IOErr GlideSettingsFSp::init(const char* applicationname) err = makeSettingsFolderFileSpec(&s_SettingsFolderName[1], s_DefaultSettingsFileName, &m_fsDefaultSettingsFile); if (err == noErr) { - m_fsSettingsFile.vRefNum = 0; if (applicationname) { err = makeSettingsFolderFileSpec(&s_SettingsFolderName[1], applicationname, &m_fsSettingsFile); @@ -143,7 +143,7 @@ GlideSettings::IOErr GlideSettingsFSp::read_settings_from_file(FSSpec* file, Gli err = save(); if (err == noErr) { - // Now we have o load the file into memory to make the settings reader happy + // Now we have to load the file into memory to make the settings reader happy err = read_file(file, &m_FileBuffer, &m_FileBufferSize, &m_SettingsFileRefnum); } } diff --git a/MacGLide/Mac/GlideSettings_FSp.h b/MacGLide/Mac/GlideSettings_FSp.h index 669c573..c6e1acd 100755 --- a/MacGLide/Mac/GlideSettings_FSp.h +++ b/MacGLide/Mac/GlideSettings_FSp.h @@ -26,7 +26,6 @@ protected: IOErr create(); IOErr read_defaults(); IOErr read(); - inline bool isApplicationSpecific() {return m_fsSettingsFile.vRefNum != 0;}; IOErr put_raw(const char* string); IOErr close(); const unsigned char* PascalString(char* string); diff --git a/MacGLide/OpenGLide/GlideSettings.cpp b/MacGLide/OpenGLide/GlideSettings.cpp index 0b6e784..4f8b6fc 100644 --- a/MacGLide/OpenGLide/GlideSettings.cpp +++ b/MacGLide/OpenGLide/GlideSettings.cpp @@ -63,6 +63,11 @@ bool GlideSettings::get(const char* setting, const char** value) sscanf(v, "%255s", buffer); found = true; } + else + { + // Wrong match, maybe a comment + v++; + } } } *value = buffer; @@ -127,6 +132,7 @@ void GlideSettings::defaults() // OpenGL extensions that can be disabled via the config file must be set to // true in order to become enabled in ValidateUserConfig() Resolution = 1; + ResolutionCap = 0; MonitorRefreshRate = 0; DepthBufferBits = 0; FullSceneAntiAliasing = 0; @@ -140,29 +146,29 @@ void GlideSettings::defaults() #endif ColorAlphaRenderMode = OpenGLideColorAlphaRenderMode_Automatic; PrecisionFix = 1; + /* // Not bad - GapFix = static_cast(OpenGLideGapFixFlag_Enabled | - OpenGLideGapFixFlag_IncircleOr | + GapFix = static_cast(OpenGLideGapFixFlag_IncircleOr | OpenGLideGapFixFlag_DepthFactor); GapFixParam1 = 3.0f; GapFixParam2 = 10.0f; GapFixParam3 = 3.0f; GapFixDepthFactor = 3.3f; */ + /* // But this one is better - GapFix = static_cast(OpenGLideGapFixFlag_Enabled | - OpenGLideGapFixFlag_VertexLengthSecondRadius | + GapFix = static_cast(OpenGLideGapFixFlag_VertexLengthSecondRadius | OpenGLideGapFixFlag_DepthFactor); GapFixParam1 = 3.0f; GapFixParam2 = 25.0f; GapFixParam3 = 0.9f; GapFixDepthFactor = 3.3f; */ - // @todo: Let's make this even more better - GapFix = static_cast(/*OpenGLideGapFixFlag_Enabled |*/ - OpenGLideGapFixFlag_VertexLengthSecondRadius | + + // @todo: Let's improve these default values even more + GapFix = static_cast(OpenGLideGapFixFlag_VertexLengthSecondRadius | OpenGLideGapFixFlag_DepthFactor); GapFixParam1 = 3.0f; GapFixParam2 = 25.0f; @@ -215,11 +221,11 @@ GlideSettings::IOErr GlideSettings::read_settings() #ifdef OGL_DEBUG GlideMsg("Reading values...\n"); #endif - GlideSettings::IOErr err = noErr; unsigned long value; get("DisplayMode", &value); DisplayMode = static_cast(value); get("Resolution", &Resolution); + get("ResolutionCap", &ResolutionCap); get("MonitorRefreshRate", &MonitorRefreshRate); get("DepthBufferBits", &DepthBufferBits); get("Mipmapping", &Mipmapping); @@ -257,7 +263,7 @@ GlideSettings::IOErr GlideSettings::read_settings() get("ShamelessPlug", &ShamelessPlug); get("UseApplicationSpecificSettings", &UseApplicationSpecificSettings); get("AutoEnableGameSpecificSettings", &AutoEnableGameSpecificSettings); - return err; + return noErr; } GlideSettings::IOErr GlideSettings::load() @@ -279,29 +285,35 @@ GlideSettings::IOErr GlideSettings::load() } if (success && strcmp(version, prefs_version) == 0) { + // Version match err = read_settings(); } else if (!success) { - GlideMsg(version_complaint, "default"); + // Unable to read settings file version information - somethings seriously wrong + GlideError(version_complaint, "default"); } else { + // Write new settings file after settings file version change GlideMsg("Configuration outdated - Creating new default settings %s...\n", prefs_version); defaults(); err = create_defaults(); if (err == noErr) { - err = saveSettings(); + err = save(); } } if (err == noErr) { - if (isApplicationSpecific() && UseApplicationSpecificSettings) + // Default or application specific config? + if (UseApplicationSpecificSettings) { + // Read application specific config err = read(); if (err == noErr) { + // Version check success = get("Version", &version); if (success && strcmp(version, prefs_version) == 0) { @@ -314,16 +326,18 @@ GlideSettings::IOErr GlideSettings::load() } else if (!success) { - GlideMsg(version_complaint, "application specific"); + // Unable to read settings file version information - somethings seriously wrong + GlideError(version_complaint, "application specific"); } else { + // Write new settings file after settings file version change GlideMsg("Configuration outdated - Creating new application specific settings %s...\n", prefs_version); defaults(); err = create(); if (err == noErr) { - err = saveSettings(); + err = save(); } } } @@ -338,171 +352,182 @@ GlideSettings::IOErr GlideSettings::saveSettings() #ifdef OGL_DEBUG GlideMsg("Saving...\n"); #endif - put("Configuration File for MacGLide"); - put(); - put(); - put("Current version number of the settings file:" ); - put("Version", OpenGLidePreferencesVersion); - put(); - put("Enable to apply application specific settings:"); - put("UseApplicationSpecificSettings", UseApplicationSpecificSettings); - put(); - put("Video settings"); - put(); - put("Fullscreen display:"); - put("0 for windowed mode, 1 for fullscreen display"); - put("DisplayMode", static_cast(DisplayMode)); - put(); - put("Display resolution:"); - put("1-8: Multiplier for Glide resolution as requested by the"); - put("game/application. Any value equal or greater than 512:"); - put("fixed x resolution (y is computed for a 4/3 aspect ratio)"); - put("Resolution", Resolution); - put(); - put("Refresh rate of the monitor:"); - put("0 to use the Glide refresh rate as requested by the game/"); - put("application. Any other value equal or greater than 60(Hz):"); - put("Use fixed refresh rate"); - put("MonitorRefreshRate", MonitorRefreshRate); - put(); - put("Gamma bias value for the Glide display:"); - put("Most games adjust the gamma correction of the display."); - put("For certain monitors and LCD display the resulting gamma"); - put("correction might be too bright (probably because the"); - put("3Dfx-Hardware was never supposed to work with LCD displays)."); - put("Although most games provide a way to adjust the gamma"); - put("correction via their configuration dialog, it might be"); - put("necessary to set a reasonable default bias value."); - put("Reasonable bias values are -1.0 to 1.0."); - put("GammaBias", GammaBias); - put(); - put("Mip-Mapping: 0 to disable, 1 to enable mipmapped textures"); - put("Mipmapping", Mipmapping); - put(); - put("Anisotropic filtering:"); - put("0 or 1 to disable, 2, 4, 8, 16 to specify the quality"); - put("level of anisotropic filtering"); - put("AnisotropylLevel", AnisotropylLevel); - put(); - put("Fullscene antialiasing:"); - put("0 to disable, any other value to set number of samples to use"); - put("for antialiasing (currently this works with ATI cards only)"); - put("FullSceneAntiAliasing", FullSceneAntiAliasing); - put(); - put(); - put("Game specific settings (usually set automatically per application"); - put(); - put("Enable game specific settings automatically:"); - put("0 to disable, 1 to automatically certain enable game specific settings"); - put("The settings in this section don't work with all games. To avoid"); - put("problems, these settings are usually set individually for each game."); - put("AutoEnableGameSpecificSettings", AutoEnableGameSpecificSettings); - put(); - put("Texture smoothing:"); - put("0 to disable, 1 to enable texture filtering. Overrides Glide"); - put("texture filter settings in order to suppress blocky pixels."); - put("Some games don't like these filter settings to be changed, for"); - put("instance horizontal and vertical gaps may appear in texture-based"); - put("menu screens"); - put("TextureSmoothing", TextureSmoothing); - put(); - put("Texture artefact optimisation for Tomb Raider 1 & 2:"); - put("Tomb Raider joins a number of texture images within a"); - put("larger texture object. In conjunction with ansisotropic"); - put("filtering and mipmapping this cause artefacts at the"); - put("edges of single tiles/triangles."); - put("0 to disable, n (power of 2) to place each texture image"); - put("into a seperate OpenGL texture object. The value determines"); - put("the grid points and the minimal size of the generated"); - put("OpenGL textures."); - put("GenerateSubTextures", GenerateSubTextures); - put(); - put("Vertex gapfix optimisation for Tomb Raider 1 & 2:"); - put("Reduces gaps between tiles in the tomb raider series"); - put("(best observed in TR1, but TR2 is also affected)"); - put("A combination of the following values:"); - put("1=Enable, 2=Debug, 4=DepthFactor, 16=IncircleOr,"); - put("32=IncircleAnd, 64=IncircleSecondRadius,"); - put("128=VertexLengthSecondRadius"); - put("GapFix", static_cast(GapFix)); - put(); - put("Minimum pixel incircle of a triangle for applying the gapfix"); - put("GapFixParam1", GapFixParam1); - put(); - put("Minimum value of the isoscelesness or the maximum vertex"); - put("length of a triangle for applying the gapfix"); - put("(an isosceles triangle has a value of 10)"); - put("GapFixParam2", GapFixParam2); - put(); - put("Second minimum incircle of a triangle for applying the gapfix,"); - put(" this one is independent from the isoscelesness/vertex length"); - put("GapFixParam3", GapFixParam3); - put(); - put("Multiplies the incircles/isoscelesness with the vertex depth to"); - put("allow applying the gapfix to smaller triangles in the background"); - put("GapFixDepthFactor", GapFixDepthFactor); - put(); - put(); - put("Various settings that affect the rendering quality."); - put(); - put("Fog emulation method:"); - put("0 to disable, 1 for simple, 2 for complete fog emulation"); - put("FogMode", static_cast(FogMode)); - put(); - put("The renderer to be used to emulate the Glide color and alpha"); - put("combine unit. 0 for automatic selection, 1 for simple (0.10),"); - put("2 for enhanced, and 3 for enhanced ATI optimised emulation"); - put("ColorAlphaRenderMode", static_cast(ColorAlphaRenderMode)); - put(); - put("Number of bits to use for the depth buffer:"); - put("0: automatic (attempts to use the largest possible value)"); - put("16, 24, 32: use the specified number of bits for the depth buffer"); - put("DepthBufferBits", DepthBufferBits); - put(); - put("Depth precision fix: attempts to avoid depth precision"); - put("problems on graphic cards with only 16bit-zbuffer depth"); - put("0 = always off, 1 = automatic, 2 = always on"); - put("EnablePrecisionFix", PrecisionFix); - put(); - put(); - put("Various debug settings"); - put(); - put("IgnorePaletteChange", IgnorePaletteChange); - put("EnableFrameBufferOverlays", EnableFrameBufferOverlays); - put("EnableFrameBufferUnderlays", EnableFrameBufferUnderlays); - put("FramebufferIgnoreUnlock", FramebufferIgnoreUnlock); - put("PedanticFrameBufferEmulation", PedanticFrameBufferEmulation); - put("CompiledVertexArray", EXT_compiled_vertex_array); - put("EnableMultiTextureEXT", ARB_multitexture); - put("EnablePaletteEXT", EXT_paletted_texture); - put("EXT_clip_volume_hint", EXT_clip_volume_hint); - put(); - put(); - put("Glide hardware settings"); - put(); - putv("Texture Memory goes from %d to %d", OGL_MIN_TEXTURE_BUFFER, OGL_MAX_TEXTURE_BUFFER); - put("TextureMemorySize", TextureMemorySize); - put(); - putv("Frame Buffer Memory goes from %d to %d", OGL_MIN_FRAME_BUFFER, OGL_MAX_FRAME_BUFFER); - put("FrameBufferMemorySize", FrameBufferMemorySize); - put(); - put("The hardware we're pretending to be emulating"); - put("(This has no effect on the emulation, but games may change"); - put("their behaviour/features depending on this setting)"); - put("0 = Voodoo, 1 = SST-96, 2 = AT3D, 3 = Voodoo 2"); - put("BoardType", static_cast(BoardType)); - put(); - put("The number of emulated Glide texture units (TMUs)"); - put("0 = as many as possible, 1-3 number of emulated TMUs"); - put("GlideTextureUnits", GlideTextureUnits); - put(); - put("0 to display the cool splash animation on startup,"); - put("or 1 to supress the annoying splash animation"); - put("NoSplash", NoSplash); - put(); - put("Shows the 3Dfx logo in the lower right corner of the screen"); - put("ShamelessPlug", ShamelessPlug); - GlideSettings::IOErr err = close(); + IOErr err = put("Configuration File for MacGLide"); + if (err == noErr) + { + put(); + put(); + put("Current version number of the settings file:" ); + put("Version", OpenGLidePreferencesVersion); + put(); + put("Enable to apply application specific settings:"); + put("UseApplicationSpecificSettings", UseApplicationSpecificSettings); + put(); + put("Video settings"); + put(); + put("Fullscreen display:"); + put("0 for windowed mode, 1 for fullscreen display"); + put("DisplayMode", static_cast(DisplayMode)); + put(); + put("Display resolution:"); + put("0: Always use the resolution denoted by the ResolutionCap settings"); + put("1-8: Multiplier for Glide resolution as requested by the"); + put("game/application. Any value equal or greater than 512:"); + put("fixed x resolution (y is computed for a 4/3 aspect ratio)"); + put("Resolution", Resolution); + put(); + put("Display resolution cap:"); + put("0 to disable, otherwise the maximum"); + put("x resolution to use for the Glide display"); + put("(y is computed for a 4/3 aspect ratio)"); + put("ResolutionCap", ResolutionCap); + put(); + put("Refresh rate of the monitor:"); + put("0 to use the Glide refresh rate as requested by the game/"); + put("application. Any other value equal or greater than 60(Hz):"); + put("Use fixed refresh rate"); + put("MonitorRefreshRate", MonitorRefreshRate); + put(); + put("Gamma bias value for the Glide display:"); + put("Most games adjust the gamma correction of the display."); + put("For certain monitors and LCD display the resulting gamma"); + put("correction might be too bright (probably because the"); + put("3Dfx-Hardware was never supposed to work with LCD displays)."); + put("Although most games provide a way to adjust the gamma"); + put("correction via their configuration dialog, it might be"); + put("necessary to set a reasonable default bias value."); + put("Reasonable bias values are -1.0 to 1.0."); + put("GammaBias", GammaBias); + put(); + put("Mip-Mapping: 0 to disable, 1 to enable mipmapped textures"); + put("Mipmapping", Mipmapping); + put(); + put("Anisotropic filtering:"); + put("0 or 1 to disable, 2, 4, 8, 16 to specify the quality"); + put("level of anisotropic filtering"); + put("AnisotropylLevel", AnisotropylLevel); + put(); + put("Fullscene antialiasing:"); + put("0 to disable, any other value to set number of samples to use"); + put("for antialiasing (currently this works with ATI cards only)"); + put("FullSceneAntiAliasing", FullSceneAntiAliasing); + put(); + put(); + put("Game specific settings (usually set automatically per application"); + put(); + put("Enable game specific settings automatically:"); + put("0 to disable, 1 to automatically certain enable game specific settings"); + put("The settings in this section don't work with all games. To avoid"); + put("problems, these settings are usually set individually for each game."); + put("AutoEnableGameSpecificSettings", AutoEnableGameSpecificSettings); + put(); + put("Texture smoothing:"); + put("0 to disable, 1 to enable texture filtering. Overrides Glide"); + put("texture filter settings in order to suppress blocky pixels."); + put("Some games don't like these filter settings to be changed, for"); + put("instance horizontal and vertical gaps may appear in texture-based"); + put("menu screens"); + put("TextureSmoothing", TextureSmoothing); + put(); + put("Texture artefact optimisation for Tomb Raider 1 & 2:"); + put("Tomb Raider joins a number of texture images within a"); + put("larger texture object. In conjunction with ansisotropic"); + put("filtering and mipmapping this cause artefacts at the"); + put("edges of single tiles/triangles."); + put("0 to disable, n (power of 2) to place each texture image"); + put("into a seperate OpenGL texture object. The value determines"); + put("the grid points and the minimal size of the generated"); + put("OpenGL textures."); + put("GenerateSubTextures", GenerateSubTextures); + put(); + put("Vertex gapfix optimisation for Tomb Raider 1 & 2:"); + put("Reduces gaps between tiles in the tomb raider series"); + put("(best observed in TR1, but TR2 is also affected)"); + put("A combination of the following values:"); + put("1=Enable, 2=Debug, 4=DepthFactor, 16=IncircleOr,"); + put("32=IncircleAnd, 64=IncircleSecondRadius,"); + put("128=VertexLengthSecondRadius"); + put("GapFix", static_cast(GapFix)); + put(); + put("Minimum pixel incircle of a triangle for applying the gapfix"); + put("GapFixParam1", GapFixParam1); + put(); + put("Minimum value of the isoscelesness or the maximum vertex"); + put("length of a triangle for applying the gapfix"); + put("(an isosceles triangle has a value of 10)"); + put("GapFixParam2", GapFixParam2); + put(); + put("Second minimum incircle of a triangle for applying the gapfix,"); + put(" this one is independent from the isoscelesness/vertex length"); + put("GapFixParam3", GapFixParam3); + put(); + put("Multiplies the incircles/isoscelesness with the vertex depth to"); + put("allow applying the gapfix to smaller triangles in the background"); + put("GapFixDepthFactor", GapFixDepthFactor); + put(); + put(); + put("Various settings that affect the rendering quality."); + put(); + put("Fog emulation method:"); + put("0 to disable, 1 for simple, 2 for complete fog emulation"); + put("FogMode", static_cast(FogMode)); + put(); + put("The renderer to be used to emulate the Glide color and alpha"); + put("combine unit. 0 for automatic selection, 1 for simple (0.10),"); + put("2 for enhanced, and 3 for enhanced ATI optimised emulation"); + put("ColorAlphaRenderMode", static_cast(ColorAlphaRenderMode)); + put(); + put("Number of bits to use for the depth buffer:"); + put("0: automatic (attempts to use the largest possible value)"); + put("16, 24, 32: use the specified number of bits for the depth buffer"); + put("DepthBufferBits", DepthBufferBits); + put(); + put("Depth precision fix: attempts to avoid depth precision"); + put("problems on graphic cards with only 16bit-zbuffer depth"); + put("0 = always off, 1 = automatic, 2 = always on"); + put("EnablePrecisionFix", PrecisionFix); + put(); + put(); + put("Various debug settings"); + put(); + put("IgnorePaletteChange", IgnorePaletteChange); + put("EnableFrameBufferOverlays", EnableFrameBufferOverlays); + put("EnableFrameBufferUnderlays", EnableFrameBufferUnderlays); + put("FramebufferIgnoreUnlock", FramebufferIgnoreUnlock); + put("PedanticFrameBufferEmulation", PedanticFrameBufferEmulation); + put("CompiledVertexArray", EXT_compiled_vertex_array); + put("EnableMultiTextureEXT", ARB_multitexture); + put("EnablePaletteEXT", EXT_paletted_texture); + put("EXT_clip_volume_hint", EXT_clip_volume_hint); + put(); + put(); + put("Glide hardware settings"); + put(); + putv("Texture Memory goes from %d to %d", OGL_MIN_TEXTURE_BUFFER, OGL_MAX_TEXTURE_BUFFER); + put("TextureMemorySize", TextureMemorySize); + put(); + putv("Frame Buffer Memory goes from %d to %d", OGL_MIN_FRAME_BUFFER, OGL_MAX_FRAME_BUFFER); + put("FrameBufferMemorySize", FrameBufferMemorySize); + put(); + put("The hardware we're pretending to be emulating"); + put("(This has no effect on the emulation, but games may change"); + put("their behaviour/features depending on this setting)"); + put("0 = Voodoo, 1 = SST-96, 2 = AT3D, 3 = Voodoo 2"); + put("BoardType", static_cast(BoardType)); + put(); + put("The number of emulated Glide texture units (TMUs)"); + put("0 = as many as possible, 1-3 number of emulated TMUs"); + put("GlideTextureUnits", GlideTextureUnits); + put(); + put("0 to display the cool splash animation on startup,"); + put("or 1 to supress the annoying splash animation"); + put("NoSplash", NoSplash); + put(); + put("Shows the 3Dfx logo in the lower right corner of the screen"); + put("ShamelessPlug", ShamelessPlug); + // Get the error code of the last write in order to catch errors like "Disk full" etc. + err = put(); + } return err; } @@ -616,19 +641,14 @@ GlideSettings::IOErr GlideSettings::put(const char* setting, bool value) GlideSettings::IOErr GlideSettings::save() { - IOErr err = noErr; - if (isApplicationSpecific()) + IOErr err = saveSettings(); + if (err == noErr) { - err = create(); + err = close(); } else { - err = create_defaults(); + close(); } - if (err == noErr) - { - err = saveSettings(); - } - close(); - return noErr; -} \ No newline at end of file + return err; +} diff --git a/MacGLide/OpenGLide/GlideSettings.h b/MacGLide/OpenGLide/GlideSettings.h index dd2b9c4..847eccf 100644 --- a/MacGLide/OpenGLide/GlideSettings.h +++ b/MacGLide/OpenGLide/GlideSettings.h @@ -69,6 +69,7 @@ struct ConfigStruct { OpenGLideDisplayMode DisplayMode; unsigned long Resolution; + unsigned long ResolutionCap; unsigned long MonitorRefreshRate; unsigned long DepthBufferBits; unsigned long FullSceneAntiAliasing; @@ -143,7 +144,6 @@ protected: void defaults(); virtual IOErr read_defaults()=0; virtual IOErr read()=0; - virtual bool isApplicationSpecific()=0; IOErr read_settings(); IOErr saveSettings(); bool get(const char* setting, const char** value); diff --git a/MacGLide/OpenGLide/grguSstGlide.cpp b/MacGLide/OpenGLide/grguSstGlide.cpp index d655c2a..a3365b9 100644 --- a/MacGLide/OpenGLide/grguSstGlide.cpp +++ b/MacGLide/OpenGLide/grguSstGlide.cpp @@ -225,13 +225,13 @@ grSstWinOpen(FxU32 hwnd, } #endif - Glide.WindowWidth = windowDimensions[ Glide.Resolution ].width; - Glide.WindowHeight = windowDimensions[ Glide.Resolution ].height; + Glide.WindowWidth = windowDimensions[Glide.Resolution].width; + Glide.WindowHeight = windowDimensions[Glide.Resolution].height; // Set the size of the opengl window (might be different from Glide window size) if (UserConfig.Resolution == 0) { // Does only work if the library is loaded at startup, before the game changes the screen resolution - if (DisplayManager_GetDesktopDisplayResolution(OpenGL.WindowWidth, OpenGL.WindowHeight) != noErr) + if (!DisplayManager_GetDesktopDisplayResolution(OpenGL.WindowWidth, OpenGL.WindowHeight)) { // Use the resuolution requested by the game OpenGL.WindowWidth = Glide.WindowWidth; @@ -244,18 +244,20 @@ grSstWinOpen(FxU32 hwnd, OpenGL.WindowWidth = Glide.WindowWidth * UserConfig.Resolution; OpenGL.WindowHeight = Glide.WindowHeight * UserConfig.Resolution; } - else if (UserConfig.Resolution >= 512) + else { // override the resolution OpenGL.WindowWidth = UserConfig.Resolution; // Glide games have a fixed 4/3 aspect ratio OpenGL.WindowHeight = UserConfig.Resolution * 3 / 4; } - else + // Limit the display size to the max allowed screen resolution + if (UserConfig.ResolutionCap) { - // Use the resuolution requested by the game - OpenGL.WindowWidth = Glide.WindowWidth; - OpenGL.WindowHeight = Glide.WindowHeight; + OpenGL.WindowWidth = min(OpenGL.WindowWidth, + UserConfig.ResolutionCap); + OpenGL.WindowHeight = min(OpenGL.WindowHeight, + UserConfig.ResolutionCap * 3 / 4); } Glide.WindowTotalPixels = Glide.WindowWidth * Glide.WindowHeight; Glide.Refresh = ref;