From 80e8944d2f47afaf1fe8d3d397f8fce2d261018a Mon Sep 17 00:00:00 2001
From: zilmar <zilmae@pj64-emu.com>
Date: Mon, 13 Mar 2017 20:28:34 +1100
Subject: [PATCH] [Glide64] Change capture_screen to g_capture_screen

---
 Source/Glide64/Main.cpp     | 29 +++++++++--------------------
 Source/Glide64/Settings.cpp |  9 +++++++--
 Source/Glide64/rdp.cpp      |  4 ++--
 Source/Glide64/ucode06.h    |  5 +++--
 4 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp
index 51f4101ef..68d241dc2 100644
--- a/Source/Glide64/Main.cpp
+++ b/Source/Glide64/Main.cpp
@@ -41,7 +41,6 @@
 #include <Common/StdString.h>
 #include "Gfx_1.3.h"
 #include "Version.h"
-#include <Settings/Settings.h>
 #include <Common/CriticalSection.h>
 #include <Common/DateTimeClass.h>
 #include <Common/path.h>
@@ -116,8 +115,8 @@ uint32_t   offset_textures = 0;
 uint32_t   offset_texbuf1 = 0;
 
 bool g_ghq_use = false;
-int    capture_screen = 0;
-std::string capture_path;
+bool g_capture_screen = false;
+std::string g_capture_path;
 
 #ifdef _WIN32
 HWND g_hwnd_win = NULL;
@@ -841,8 +840,8 @@ output:   none
 *******************************************************************/
 EXPORT void CALL CaptureScreen(char * Directory)
 {
-    capture_screen = 1;
-    capture_path = Directory;
+    g_capture_screen = true;
+    g_capture_path = Directory;
 }
 
 /******************************************************************
@@ -1176,15 +1175,6 @@ void CALL RomOpen(void)
 
     if (evoodoo)
         InitGfx();
-
-    if (strstr(extensions, "ROMNAME"))
-    {
-        char strSetRomName[] = "grSetRomName";
-        void (FX_CALL *grSetRomName)(char*);
-        grSetRomName = (void (FX_CALL *)(char*))grGetProcAddress(strSetRomName);
-        grSetRomName(name);
-    }
-    // **
 }
 
 /******************************************************************
@@ -1205,9 +1195,8 @@ void CALL ShowCFB(void)
 void drawViRegBG()
 {
     WriteTrace(TraceGlide64, TraceDebug, "start");
-    const uint32_t VIwidth = *gfx.VI_WIDTH_REG;
     FB_TO_SCREEN_INFO fb_info;
-    fb_info.width = VIwidth;
+    fb_info.width = *gfx.VI_WIDTH_REG;
     fb_info.height = (uint32_t)rdp.vi_height;
     if (fb_info.height == 0)
     {
@@ -1216,7 +1205,7 @@ void drawViRegBG()
     }
     fb_info.ul_x = 0;
 
-    fb_info.lr_x = VIwidth - 1;
+    fb_info.lr_x = fb_info.width - 1;
     //  fb_info.lr_x = (uint32_t)rdp.vi_width - 1;
     fb_info.ul_y = 0;
     fb_info.lr_y = fb_info.height - 1;
@@ -1452,9 +1441,9 @@ void newSwapBuffers()
     grDepthMask(FXFALSE);
     grCullMode(GR_CULL_DISABLE);
 
-    if (capture_screen)
+    if (g_capture_screen)
     {
-        CPath path(capture_path);
+        CPath path(g_capture_path);
         if (!path.DirectoryExists())
         {
             path.DirectoryCreate();
@@ -1525,7 +1514,7 @@ void newSwapBuffers()
             // Unlock the backbuffer
             grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER);
             write_png_file(path, image_width, image_height, ssimg);
-            capture_screen = 0;
+            g_capture_screen = false;
         }
     }
 
diff --git a/Source/Glide64/Settings.cpp b/Source/Glide64/Settings.cpp
index 10e9c0dd3..8e216bc4f 100644
--- a/Source/Glide64/Settings.cpp
+++ b/Source/Glide64/Settings.cpp
@@ -573,7 +573,6 @@ void CSettings::ReadSettings()
     m_wrpAnisotropic = GetSetting(Set_wrpAnisotropic) != 0;
 
     m_autodetect_ucode = GetSetting(Set_autodetect_ucode) != 0;
-    m_unk_as_red = GetSetting(Set_unk_as_red) != 0;
     m_wireframe = GetSetting(Set_wireframe) != 0;
     m_wfmode = (wfmode_t)GetSetting(Set_wfmode);
     m_ucode = ucode_F3DEX2;
@@ -845,7 +844,6 @@ void CSettings::WriteSettings(void)
 
     SetSetting(Set_wireframe, m_wireframe);
     SetSetting(Set_wfmode, m_wfmode);
-    SetSetting(Set_unk_as_red, m_unk_as_red);
     SetSetting(Set_ucode, (int)m_ucode);
 
     SetSetting(Set_ghq_fltr, m_ghq_fltr);
@@ -914,3 +912,10 @@ void CSettings::SettingsChanged(void)
 {
     m_ScreenRes = GetSetting(Set_Resolution);
 }
+
+void UseUnregisteredSetting(int /*SettingID*/)
+{
+#ifdef _WIN32
+    DebugBreak();
+#endif
+}
diff --git a/Source/Glide64/rdp.cpp b/Source/Glide64/rdp.cpp
index fb241369d..b4457d2d3 100644
--- a/Source/Glide64/rdp.cpp
+++ b/Source/Glide64/rdp.cpp
@@ -737,10 +737,10 @@ EXPORT void CALL ProcessDList(void)
         {
             ReleaseGfx ();
             rdp_reset();
-            if (g_settings->ghq_use)
+            if (g_ghq_use)
             {
                 ext_ghq_shutdown();
-                g_settings->ghq_use = 0;
+                g_ghq_use = false;
             }
         }
         if (MessageBox(gfx.hWnd, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?","Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION) == MB_NO)
diff --git a/Source/Glide64/ucode06.h b/Source/Glide64/ucode06.h
index 050b7e999..a421f9c57 100644
--- a/Source/Glide64/ucode06.h
+++ b/Source/Glide64/ucode06.h
@@ -231,7 +231,6 @@ void DrawHiresDepthImage(const DRAWIMAGE & d)
         GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH);
     grRenderBuffer(GR_BUFFER_TEXTUREBUFFER_EXT);
     grAuxBufferExt(GR_BUFFER_AUXBUFFER);
-    grSstOrigin(GR_ORIGIN_UPPER_LEFT);
     grBufferClear(0, 0, 0xFFFF);
     grDrawTriangle(&v[0], &v[2], &v[1]);
     grDrawTriangle(&v[2], &v[3], &v[1]);
@@ -287,7 +286,9 @@ void DrawImage(DRAWIMAGE & d)
 {
     if (d.imageW == 0 || d.imageH == 0 || d.frameH == 0)   return;
 
-    int x_size, y_size, x_shift, y_shift, line;
+    int x_shift, y_shift;
+    uint16_t x_size, y_size, line;
+
     // choose optimum size for the format/size
     switch (d.imageSiz)
     {