diff --git a/Source/Glide64/Config.cpp b/Source/Glide64/Config.cpp index 0a8865830..ab9345e22 100644 --- a/Source/Glide64/Config.cpp +++ b/Source/Glide64/Config.cpp @@ -476,7 +476,7 @@ public: tooltip = "Fog enabled:\n\nSets fog emulation on//off.\n\n[Recommended: on]"; TTSetTxt(IDC_CHK_FOG, tooltip.c_str()); m_cbxFog.Attach(GetDlgItem(IDC_CHK_FOG)); - m_cbxFog.SetCheck(g_settings->fog > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFog.SetCheck(g_settings->fog() > 0 ? BST_CHECKED : BST_UNCHECKED); tooltip = "Buffer clear on every frame:\n\nForces the frame buffer to be cleared every frame drawn.\nUsually frame buffer clear is controlled by the game.\nHowever, in some cases it is not well emulated, and some garbage may be left on the screen.\nIn such cases, this option must be set on.\n\n[Recommended: on]"; TTSetTxt(IDC_CHK_BUFFER_CLEAR, tooltip.c_str()); @@ -520,7 +520,7 @@ public: g_settings->SetFiltering((CSettings::Filtering_t)m_cmbFiltering.GetItemData(m_cmbFiltering.GetCurSel())); g_settings->SetAspectmode((CSettings::AspectMode_t)m_cmbAspect.GetItemData(m_cmbAspect.GetCurSel())); g_settings->SetSwapMode((CSettings::SwapMode_t)m_cmbBufferSwap.GetItemData(m_cmbBufferSwap.GetCurSel())); - g_settings->fog = m_cbxFog.GetCheck() == BST_CHECKED; + g_settings->SetFog(m_cbxFog.GetCheck() == BST_CHECKED); g_settings->buff_clear = m_cbxBuffer.GetCheck() == BST_CHECKED; g_settings->SetLODmode((CSettings::PixelLevelOfDetail_t)m_cmbLOD.GetItemData(m_cmbLOD.GetCurSel())); diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 4ba5a688e..74dc6c2ac 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -599,7 +599,7 @@ int InitGfx() grCullMode(GR_CULL_NEGATIVE); - if (g_settings->fog) //"FOGCOORD" extension + if (g_settings->fog()) //"FOGCOORD" extension { if (strstr(extensions, "FOGCOORD")) { @@ -622,7 +622,9 @@ int InitGfx() grVertexLayout(GR_PARAM_FOG_EXT, offsetof(VERTEX, f), GR_PARAM_ENABLE); } else //not supported - g_settings->fog = FALSE; + { + g_settings->SetFog(FALSE); + } } grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); diff --git a/Source/Glide64/Settings.cpp b/Source/Glide64/Settings.cpp index a8a383544..91e5efa23 100644 --- a/Source/Glide64/Settings.cpp +++ b/Source/Glide64/Settings.cpp @@ -26,8 +26,7 @@ CSettings::CSettings() : m_vsync(false), m_rotate(Rotate_None), m_filtering(Filter_Automatic), - -fog(0), + m_fog(false), buff_clear(0), m_swapmode(SwapMode_Old), m_lodmode(LOD_Off), @@ -157,7 +156,7 @@ void CSettings::RegisterSettings(void) general_setting(Set_optimize_texrect_default, "optimize_texrect", true); general_setting(Set_filtering_default, "filtering", CSettings::Filter_Automatic); general_setting(Set_lodmode_default, "lodmode", CSettings::LOD_Off); - general_setting(Set_fog_default, "fog", 1); + general_setting(Set_fog_default, "fog", true); general_setting(Set_buff_clear_default, "buff_clear", 1); general_setting(Set_swapmode_default, "swapmode", SwapMode_New); general_setting(Set_aspect_default, "aspect", Aspect_4x3); @@ -308,6 +307,15 @@ void CSettings::SetSwapMode(SwapMode_t value) } } +void CSettings::SetFog(bool value) +{ + if (value != m_fog) + { + m_fog = value; + m_dirty = true; + } +} + void CSettings::SetGhqFltr(TextureFilter_t value) { if (value != m_ghq_fltr) @@ -609,7 +617,6 @@ void CSettings::ReadGameSettings(const char * name) g_settings->old_style_adither = GetSetting(Set_old_style_adither); g_settings->n64_z_scale = GetSetting(Set_n64_z_scale); - g_settings->fog = GetSetting(g_romopen ? Set_fog : Set_fog_default); g_settings->buff_clear = GetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default); m_ScreenRes = GetSetting(Set_Resolution); if (m_ScreenRes >= GetScreenResolutionCount()) { m_ScreenRes = GetDefaultScreenRes(); } @@ -668,6 +675,7 @@ void CSettings::ReadGameSettings(const char * name) m_fb_crc_mode = (FBCRCMODE_t)GetSetting(Set_fb_crc_mode); SetFiltering((Filtering_t)GetSetting(g_romopen ? Set_filtering : Set_filtering_default)); + SetFog(GetSetting(g_romopen ? Set_fog : Set_fog_default) != 0); SetSwapMode((SwapMode_t)GetSetting(g_romopen ? Set_swapmode : Set_swapmode_default)); SetAspectmode((AspectMode_t)GetSetting(g_romopen ? Set_aspect : Set_aspect_default)); SetLODmode((PixelLevelOfDetail_t)GetSetting(g_romopen ? Set_lodmode : Set_lodmode_default)); @@ -716,7 +724,7 @@ void CSettings::WriteSettings(void) SetSetting(Set_ghq_hirs_dump, g_settings->ghq_hirs_dump); SetSetting(g_romopen ? Set_filtering : Set_filtering_default, filtering()); - SetSetting(g_romopen ? Set_fog : Set_fog_default, g_settings->fog); + SetSetting(g_romopen ? Set_fog : Set_fog_default, m_fog); SetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default, g_settings->buff_clear); SetSetting(g_romopen ? Set_swapmode : Set_swapmode_default, g_settings->swapmode()); SetSetting(g_romopen ? Set_lodmode : Set_lodmode_default, lodmode()); diff --git a/Source/Glide64/Settings.h b/Source/Glide64/Settings.h index 2fdf30ba4..435290f42 100644 --- a/Source/Glide64/Settings.h +++ b/Source/Glide64/Settings.h @@ -145,8 +145,6 @@ public: ucode_Turbo3d = 21, }; - - int fog; int buff_clear; @@ -185,6 +183,7 @@ public: inline ScreenRotate_t rotate(void) const { return m_rotate; } inline Filtering_t filtering(void) const { return m_filtering; } + inline bool fog (void) const { return m_fog; } inline SwapMode_t swapmode(void) const { return m_swapmode; } inline PixelLevelOfDetail_t lodmode(void) const { return m_lodmode; } inline AspectMode_t aspectmode(void) const { return m_aspectmode; } @@ -261,6 +260,7 @@ public: void SetVsync(bool value); void SetFiltering(Filtering_t value); void SetSwapMode(SwapMode_t value); + void SetFog(bool value); void SetGhqFltr(TextureFilter_t value); void SetGhqEnht(TextureEnhancement_t value); void UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove); @@ -293,6 +293,7 @@ private: FBCRCMODE_t m_fb_crc_mode; ScreenRotate_t m_rotate; Filtering_t m_filtering; + bool m_fog; SwapMode_t m_swapmode; PixelLevelOfDetail_t m_lodmode; bool m_advanced_options; diff --git a/Source/Glide64/TexBuffer.cpp b/Source/Glide64/TexBuffer.cpp index 26c1003d4..af44e9bb3 100644 --- a/Source/Glide64/TexBuffer.cpp +++ b/Source/Glide64/TexBuffer.cpp @@ -461,7 +461,7 @@ int CloseTextureBuffer(int draw) grDrawTriangle(&v[0], &v[2], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]); rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } @@ -526,7 +526,7 @@ int CopyTextureBuffer(COLOR_IMAGE & fb_from, COLOR_IMAGE & fb_to) rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; rdp.update |= UPDATE_VIEWPORT | UPDATE_SCISSOR; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); WriteTrace(TraceRDP, TraceDebug, "CopyTextureBuffer draw, OK"); rdp.tbuff_tex = 0; @@ -580,7 +580,7 @@ int CopyDepthBuffer() grAuxBufferExt(GR_BUFFER_TEXTUREAUXBUFFER_EXT); rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); WriteTrace(TraceRDP, TraceDebug, "CopyDepthBuffer draw, OK"); rdp.tbuff_tex = 0; @@ -654,7 +654,7 @@ int SwapTextureBuffer() rdp.update |= UPDATE_VIEWPORT | UPDATE_SCISSOR; } rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } diff --git a/Source/Glide64/Util.cpp b/Source/Glide64/Util.cpp index 37b682317..9cca4cf63 100644 --- a/Source/Glide64/Util.cpp +++ b/Source/Glide64/Util.cpp @@ -1919,7 +1919,7 @@ void update() } //Added by Gonetz. - if (g_settings->fog && (rdp.update & UPDATE_FOG_ENABLED)) + if (g_settings->fog() && (rdp.update & UPDATE_FOG_ENABLED)) { rdp.update ^= UPDATE_FOG_ENABLED; diff --git a/Source/Glide64/rdp.cpp b/Source/Glide64/rdp.cpp index 44cc4e152..91206b854 100644 --- a/Source/Glide64/rdp.cpp +++ b/Source/Glide64/rdp.cpp @@ -965,11 +965,14 @@ static void rdp_texrect() if ((rdp.othermode_l >> 16) == 0x3c18 && rdp.cycle1 == 0x03ffffff && rdp.cycle2 == 0x01ff1fff) //depth image based fog { - if (!depth_buffer_fog) - return; - if (g_settings->fog) - DrawDepthBufferFog(); - depth_buffer_fog = FALSE; + if (depth_buffer_fog) + { + if (g_settings->fog()) + { + DrawDepthBufferFog(); + } + depth_buffer_fog = false; + } return; } diff --git a/Source/Glide64/ucode06.h b/Source/Glide64/ucode06.h index f446cd543..050b7e999 100644 --- a/Source/Glide64/ucode06.h +++ b/Source/Glide64/ucode06.h @@ -950,7 +950,7 @@ static void uc6_draw_polygons(VERTEX v[4]) } rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_VIEWPORT; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } @@ -1659,7 +1659,7 @@ void uc6_sprite2d() } rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_VIEWPORT; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); }