Commits

wahrhaft committed 4d3507a

Better descriptions for config options,and use boolean config options instead of int where appropriate

Comments (0)

Files changed (4)

 *
 * You should have received a copy of the GNU General Public
 * Licence along with this program; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
 #include "Config.h"
     ConfigSetDefaultBool(video_general_section, "Fullscreen", false, "Use fullscreen mode if True, or windowed mode if False");
     ConfigSetDefaultInt(video_general_section, "ScreenWidth", 640, "Width of output window or fullscreen width");
     ConfigSetDefaultInt(video_general_section, "ScreenHeight", 480, "Height of output window or fullscreen height");
+
     return TRUE;
 }
 
     packedResolution.width = ConfigGetParamInt(video_general_section, "ScreenWidth");
     packedResolution.height = ConfigGetParamInt(video_general_section, "ScreenHeight");
     packedResolution.fullscreen = ConfigGetParamBool(video_general_section, "Fullscreen");
-    
+
     return packedResolution;
 }
 
-int Config_ReadInt(const char *itemname, int def_value, BOOL create)
+int Config_ReadInt(const char *itemname, const char *desc, int def_value, BOOL create, BOOL isBoolean)
 {
     WriteLog(M64MSG_VERBOSE, "Getting value %s", itemname);
-    ConfigSetDefaultInt(video_glide64_section, itemname, def_value, itemname);
-    return ConfigGetParamInt(video_glide64_section, itemname);
+    if (isBoolean)
+    {
+        ConfigSetDefaultBool(video_glide64_section, itemname, def_value, desc);
+        return ConfigGetParamBool(video_glide64_section, itemname);
+    }
+    else
+    {
+        ConfigSetDefaultInt(video_glide64_section, itemname, def_value, desc);
+        return ConfigGetParamInt(video_glide64_section, itemname);
+    }
+
 }
 *
 * You should have received a copy of the GNU General Public
 * Licence along with this program; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
 
 
 BOOL Config_Open();
 PackedScreenResolution Config_ReadScreenSettings();
-int Config_ReadInt(const char *itemname, int def_value, BOOL create=TRUE);
+int Config_ReadInt(const char *itemname, const char *desc, int def_value, BOOL create=TRUE, BOOL isBoolean=TRUE);
 
 
 #endif /* CONFIG_H */
 *
 *   You should have received a copy of the GNU General Public
 *   Licence along with this program; if not, write to the Free
-*   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+*   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *   Boston, MA  02110-1301, USA
 */
 
 
 #ifdef ALTTAB_FIX
 HHOOK hhkLowLevelKybd = NULL;
-LRESULT CALLBACK LowLevelKeyboardProc(int nCode, 
+LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
                                       WPARAM wParam, LPARAM lParam);
 #endif
 
   { 1280, 1024 },
   { 1600, 1200 },
   { 400, 300 },
-  
+
   // 0x10
   { 1152, 864 },
   { 1280, 960 },
 {
   float res_scl_x = (float)settings.res_x / 320.0f;
   float res_scl_y = (float)settings.res_y / 240.0f;
-  
+
   DWORD scale_x = *gfx.VI_X_SCALE_REG & 0xFFF;
   if (!scale_x) return;
   DWORD scale_y = *gfx.VI_Y_SCALE_REG & 0xFFF;
   if (!scale_y) return;
-  
+
   float fscale_x = (float)scale_x / 1024.0f;
   float fscale_y = (float)scale_y / 1024.0f;
-  
+
   DWORD dwHStartReg = *gfx.VI_H_START_REG;
   DWORD dwVStartReg = *gfx.VI_V_START_REG;
-  
+
   DWORD hstart = dwHStartReg >> 16;
   DWORD hend = dwHStartReg & 0xFFFF;
-  
+
   // dunno... but sometimes this happens
   if (hend == hstart) hend = (int)(*gfx.VI_WIDTH_REG / fscale_x);
-  
+
   DWORD vstart = dwVStartReg >> 16;
   DWORD vend = dwVStartReg & 0xFFFF;
-  
+
   sprintf (out_buf, "hstart: %d, hend: %d, vstart: %d, vend: %d\n", hstart, hend, vstart, vend);
   LOG (out_buf);
-  
+
   rdp.vi_width = (hend - hstart) * fscale_x;
   rdp.vi_height = (vend - vstart)/2 * fscale_y;
-  
+
   sprintf (out_buf, "size: %d x %d\n", (int)rdp.vi_width, (int)rdp.vi_height);
   LOG (out_buf);
-  
+
   if (region == 0)
   {
     if (*gfx.VI_WIDTH_REG == 0x500) // 1280x960 is different... needs height * 2
       //rdp.scale_y = res_scl_y * (230.0f / rdp.vi_height);
     }
   }
-  
+
   rdp.offset_x = settings.offset_x * res_scl_x;
   rdp.offset_y = settings.offset_y * res_scl_y;
   if (settings.scale_x != 0)
     rdp.scale_x *= (settings.scale_x / 100000.0f);
   if (settings.scale_y != 0)
     rdp.scale_y *= (settings.scale_y / 100000.0f);
-  
+
   rdp.scale_1024 = settings.scr_res_x / 1024.0f;
   rdp.scale_768 = settings.scr_res_y / 768.0f;
-  
+
   rdp.scissor_o.ul_x = 0;
   rdp.scissor_o.ul_y = 0;
   rdp.scissor_o.lr_x = (DWORD)rdp.vi_width;
   rdp.scissor_o.lr_y = (DWORD)rdp.vi_height;
-  
+
   rdp.update |= UPDATE_VIEWPORT | UPDATE_SCISSOR;
 }
 
     WriteLog(M64MSG_ERROR, "Could not open configuration!");
     return;
   }
-  settings.card_id = (BYTE)Config_ReadInt ("card_id", 0);
-  
-  settings.depth_bias = -Config_ReadInt ("depth_bias", 0);
+  settings.card_id = (BYTE)Config_ReadInt ("card_id", "Card ID", 0, TRUE, FALSE);
+
+  settings.depth_bias = -Config_ReadInt ("depth_bias", "Depth bias level", 0, TRUE, FALSE);
   PackedScreenResolution packedResolution = Config_ReadScreenSettings();
   settings.res_data = (DWORD) packedResolution.resolution;
   settings.scr_res_x = settings.res_x = packedResolution.width;
   settings.scr_res_y = settings.res_y = packedResolution.height;
-  settings.autodetect_ucode = (BOOL)Config_ReadInt ("autodetect_ucode", 1);
-  settings.ucode = (DWORD)Config_ReadInt ("ucode", 2);
-  
-  settings.wireframe = (BOOL)Config_ReadInt ("wireframe", 0);
-  settings.wfmode = (int)Config_ReadInt ("wfmode", 1);
-  settings.filtering = (BYTE)Config_ReadInt ("filtering", 1);
-  settings.fog = (BOOL)Config_ReadInt ("fog", 1);
-  settings.buff_clear = (BOOL)Config_ReadInt ("buff_clear", 1);
-  settings.vsync = (BOOL)Config_ReadInt ("vsync", 0);
-  settings.fast_crc = (BOOL)Config_ReadInt ("fast_crc", 0);
-  settings.swapmode = (BYTE)Config_ReadInt ("swapmode", 1);
-  settings.lodmode = (BYTE)Config_ReadInt ("lodmode", 0);
-  
-  settings.logging = (BOOL)Config_ReadInt ("logging", 0);
-  settings.log_clear = (BOOL)Config_ReadInt ("log_clear", 0);
-  settings.elogging = (BOOL)Config_ReadInt ("elogging", 0);
-  settings.filter_cache = (BOOL)Config_ReadInt ("filter_cache", 0);
-  settings.cpu_write_hack = (BOOL)Config_ReadInt ("detect_cpu_write", 0);
-  settings.unk_as_red = (BOOL)Config_ReadInt ("unk_as_red", 0);
-  settings.log_unk = (BOOL)Config_ReadInt ("log_unk", 0);
-  settings.unk_clear = (BOOL)Config_ReadInt ("unk_clear", 0);
-  
-  settings.wrap_big_tex = (BOOL)Config_ReadInt ("wrap_big_tex", 0);
-  settings.flame_corona = (BOOL)Config_ReadInt ("flame_corona", 0);
+  settings.autodetect_ucode = (BOOL)Config_ReadInt ("autodetect_ucode", "Auto-detect microcode", 1);
+  settings.ucode = (DWORD)Config_ReadInt ("ucode", "Force microcode", 2, TRUE, FALSE);
+
+  settings.wireframe = (BOOL)Config_ReadInt ("wireframe", "Wireframe display", 0);
+  settings.wfmode = (int)Config_ReadInt ("wfmode", "Wireframe mode", 1, TRUE, FALSE);
+  settings.filtering = (BYTE)Config_ReadInt ("filtering", "Texture filter", 1, TRUE, FALSE);
+  settings.fog = (BOOL)Config_ReadInt ("fog", "Fog enabled", 1);
+  settings.buff_clear = (BOOL)Config_ReadInt ("buff_clear", "Buffer clear on every frame", 1);
+  settings.vsync = (BOOL)Config_ReadInt ("vsync", "Vertical sync", 0);
+  settings.fast_crc = (BOOL)Config_ReadInt ("fast_crc", "Fast CRC", 0);
+  settings.swapmode = (BYTE)Config_ReadInt ("swapmode", "Swap mode", 1, TRUE, FALSE);
+  settings.lodmode = (BYTE)Config_ReadInt ("lodmode", "LOD mode", 0, TRUE, FALSE);
+
+  settings.logging = (BOOL)Config_ReadInt ("logging", "Logging", 0);
+  settings.log_clear = (BOOL)Config_ReadInt ("log_clear", "", 0);
+  settings.elogging = (BOOL)Config_ReadInt ("elogging", "", 0);
+  settings.filter_cache = (BOOL)Config_ReadInt ("filter_cache", "Filter cache", 0);
+  settings.cpu_write_hack = (BOOL)Config_ReadInt ("detect_cpu_write", "Detect CPU writes", 0);
+  settings.unk_as_red = (BOOL)Config_ReadInt ("unk_as_red", "Display unknown combines as red", 0);
+  settings.log_unk = (BOOL)Config_ReadInt ("log_unk", "Log unknown combines", 0);
+  settings.unk_clear = (BOOL)Config_ReadInt ("unk_clear", "", 0);
+
+  settings.wrap_big_tex = (BOOL)Config_ReadInt ("wrap_big_tex", "Wrap textures too big for tmem", 0);
+  settings.flame_corona = (BOOL)Config_ReadInt ("flame_corona", "Zelda corona fix", 0);
   //  settings.RE2_native_video = (BOOL)INI_ReadInt ("RE2_native_video", 0);
-  
-  settings.show_fps = (BYTE)Config_ReadInt ("show_fps", 9);
-  
-  settings.clock = (BOOL)Config_ReadInt ("clock", 0);
-  settings.clock_24_hr = (BOOL)Config_ReadInt ("clock_24_hr", 0);
-  
-  settings.fb_read_always = (BOOL)Config_ReadInt ("fb_read_always", 0);
-  settings.fb_read_alpha = (BOOL)Config_ReadInt ("fb_read_alpha", 0);
-  settings.fb_smart = (BOOL)Config_ReadInt ("fb_smart", 0);
-  settings.fb_motionblur = (BOOL)Config_ReadInt ("motionblur", 0);
-  settings.fb_hires = (BOOL)Config_ReadInt ("fb_hires", 1);
-  settings.fb_get_info = (BOOL)Config_ReadInt ("fb_get_info", 0);
-  settings.fb_depth_clear = (BOOL)Config_ReadInt ("fb_clear", 0);
-  settings.fb_depth_render = (BOOL)Config_ReadInt ("fb_render", 0);
+
+  settings.show_fps = (BYTE)Config_ReadInt ("show_fps", "FPS counter", 0, TRUE, FALSE);
+
+  settings.clock = (BOOL)Config_ReadInt ("clock", "Clock enabled", 0);
+  settings.clock_24_hr = (BOOL)Config_ReadInt ("clock_24_hr", "Clock is 24-hour", 0);
+
+  settings.fb_read_always = (BOOL)Config_ReadInt ("fb_read_always", "Framebuffer read every frame", 0);
+  settings.fb_read_alpha = (BOOL)Config_ReadInt ("fb_read_alpha", "Framebuffer read alpha", 0);
+  settings.fb_smart = (BOOL)Config_ReadInt ("fb_smart", "Smart framebuffer", 0);
+  settings.fb_motionblur = (BOOL)Config_ReadInt ("motionblur", "Motion blur", 0);
+  settings.fb_hires = (BOOL)Config_ReadInt ("fb_hires", "Hi-res framebuffer", 1);
+  settings.fb_get_info = (BOOL)Config_ReadInt ("fb_get_info", "Get framebuffer info", 0);
+  settings.fb_depth_clear = (BOOL)Config_ReadInt ("fb_clear", "Clear framebuffer", 0);
+  settings.fb_depth_render = (BOOL)Config_ReadInt ("fb_render", "Depth buffer render", 0);
   if (settings.fb_depth_render)
     settings.fb_depth_clear = TRUE;
-  
-  settings.custom_ini = (BOOL)Config_ReadInt ("custom_ini", 1);
-  settings.hotkeys = (BOOL)Config_ReadInt ("hotkeys", 1);
 
-  settings.full_res = (BOOL)Config_ReadInt ("full_res", 7);
-  settings.tex_filter = (BOOL)Config_ReadInt ("tex_filter", 0);
-  settings.noditheredalpha = (BOOL)Config_ReadInt ("noditheredalpha", 1);
-  settings.noglsl = (BOOL)Config_ReadInt ("noglsl", 1);
-  settings.FBO = (BOOL)Config_ReadInt ("fbo", 0);
-  settings.disable_auxbuf = (BOOL)Config_ReadInt ("disable_auxbuf", 0);
+  settings.custom_ini = (BOOL)Config_ReadInt ("custom_ini", "Use custom INI settings", 0);
+  settings.hotkeys = 0;
+
+  settings.full_res = 0;
+  settings.tex_filter = (BOOL)Config_ReadInt ("tex_filter", "Texture filtering", 0);
+  settings.noditheredalpha = (BOOL)Config_ReadInt ("noditheredalpha", "Disable dithered alpha", 1);
+  settings.noglsl = (BOOL)Config_ReadInt ("noglsl", "Disable GLSL combiners", 1);
+  settings.FBO = (BOOL)Config_ReadInt ("fbo", "Use framebuffer objects", 0);
+  settings.disable_auxbuf = (BOOL)Config_ReadInt ("disable_auxbuf", "Disable aux buffer", 0);
 
 }
 
   int force_microcheck = INI_ReadInt ("force_microcheck", -1, 0);
   int info_disable = INI_ReadInt ("fb_info_disable", -1, 0);
   int hires_disable = INI_ReadInt ("fb_hires_disable", -1, 0);
-  
+
   if (offset_x != -1) settings.offset_x = offset_x;
   if (offset_y != -1) settings.offset_y = offset_y;
   if (scale_x != -1) settings.scale_x = scale_x;
     //FIXME unused int depth_render = INI_ReadInt ("fb_render", -1, 0);
     //int resolution = (INT)INI_ReadInt ("resolution", -1, 0);
     int cpu_write_hack = (INT)INI_ReadInt ("detect_cpu_write", -1, 0);
-    
+
     if (filtering != -1) settings.filtering = filtering;
     if (fog != -1) settings.fog = fog;
     if (buff_clear != -1) settings.buff_clear = buff_clear;
   if (grTextureBufferExt)
   {
     int tbuf_size = 0;
-    if (max_tex_size <= 256) 
+    if (max_tex_size <= 256)
     {
-      grTextureBufferExt(  GR_TMU1, grTexMinAddress(GR_TMU1), GR_LOD_LOG2_256, GR_LOD_LOG2_256, 
-                    GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH ); 
-      tbuf_size = 8 * grTexCalcMemRequired(GR_LOD_LOG2_256, GR_LOD_LOG2_256, 
+      grTextureBufferExt(  GR_TMU1, grTexMinAddress(GR_TMU1), GR_LOD_LOG2_256, GR_LOD_LOG2_256,
+                    GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH );
+      tbuf_size = 8 * grTexCalcMemRequired(GR_LOD_LOG2_256, GR_LOD_LOG2_256,
                                          GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565);
     }
     else if (settings.scr_res_x <= 1024)
     {
-      grTextureBufferExt(  GR_TMU1, grTexMinAddress(GR_TMU1), GR_LOD_LOG2_1024, GR_LOD_LOG2_1024, 
-                    GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH ); 
-      tbuf_size = grTexCalcMemRequired(GR_LOD_LOG2_1024, GR_LOD_LOG2_1024, 
+      grTextureBufferExt(  GR_TMU1, grTexMinAddress(GR_TMU1), GR_LOD_LOG2_1024, GR_LOD_LOG2_1024,
+                    GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH );
+      tbuf_size = grTexCalcMemRequired(GR_LOD_LOG2_1024, GR_LOD_LOG2_1024,
                                          GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565);
     }
     else
     {
-      grTextureBufferExt(  GR_TMU1, grTexMinAddress(GR_TMU1), GR_LOD_LOG2_2048, GR_LOD_LOG2_2048, 
-                    GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH ); 
-      tbuf_size = grTexCalcMemRequired(GR_LOD_LOG2_2048, GR_LOD_LOG2_2048, 
+      grTextureBufferExt(  GR_TMU1, grTexMinAddress(GR_TMU1), GR_LOD_LOG2_2048, GR_LOD_LOG2_2048,
+                    GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH );
+      tbuf_size = grTexCalcMemRequired(GR_LOD_LOG2_2048, GR_LOD_LOG2_2048,
                                          GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565);
     }
-    
+
     //tbuf_size *= 2;
     WriteLog(M64MSG_INFO, "tbuf_size %gMb\n", tbuf_size/1024.0f/1024);
     rdp.texbufs[0].tmu = GR_TMU0;
 
    DWORD *data = (DWORD*)font;
    DWORD cur;
-  
+
   // ** Font texture **
   BYTE *tex8 = (BYTE*)malloc(256*64);
-  
+
   fontTex.smallLodLog2 = fontTex.largeLodLog2 = GR_LOD_LOG2_256;
   fontTex.aspectRatioLog2 = GR_ASPECT_LOG2_4x1;
   fontTex.format = GR_TEXFMT_ALPHA_8;
   fontTex.data = tex8;
-  
+
   // Decompression: [1-bit inverse alpha --> 8-bit alpha]
   DWORD i,b;
   for (i=0; i<0x200; i++)
            : "[cur]"(~*(data++))
            );
 #endif
-    
+
     for (b=0x80000000; b!=0; b>>=1)
     {
       if (cur&b) *tex8 = 0xFF;
       tex8 ++;
     }
   }
-  
+
   grTexDownloadMipMap (GR_TMU0,
     grTexMinAddress(GR_TMU0) + offset_font,
     GR_MIPMAPLEVELMASK_BOTH,
     &fontTex);
-  
+
   offset_cursor = offset_font + grTexTextureMemRequired (GR_MIPMAPLEVELMASK_BOTH, &fontTex);
-  
+
   free (fontTex.data);
-  
+
   // ** Cursor texture **
   data = (DWORD*)cursor;
-  
+
   WORD *tex16 = (WORD*)malloc(32*32*2);
-  
+
   cursorTex.smallLodLog2 = cursorTex.largeLodLog2 = GR_LOD_LOG2_32;
   cursorTex.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
   cursorTex.format = GR_TEXFMT_ARGB_1555;
   cursorTex.data = tex16;
-  
+
   // Conversion: [16-bit 1555 (swapped) --> 16-bit 1555]
   for (i=0; i<0x200; i++)
   {
     *(tex16++) = (WORD)(((cur&0x000000FF)<<8)|((cur&0x0000FF00)>>8));
     *(tex16++) = (WORD)(((cur&0x00FF0000)>>8)|((cur&0xFF000000)>>24));
   }
-  
+
   grTexDownloadMipMap (GR_TMU0,
     grTexMinAddress(GR_TMU0) + offset_cursor,
     GR_MIPMAPLEVELMASK_BOTH,
     &cursorTex);
-  
+
   // Round to higher 16
     offset_textures = ((offset_cursor + grTexTextureMemRequired (GR_MIPMAPLEVELMASK_BOTH, &cursorTex))
       & 0xFFFFFFF0) + 16;
   {
     ReleaseGfx ();
   }
-  
+
   OPEN_RDP_LOG ();  // doesn't matter if opens again; it will check for it
   OPEN_RDP_E_LOG ();
   LOG ("InitGfx ()\n");
-  
+
   debugging = FALSE;
-  
+
   // Initialize Glide
   grGlideInit ();
-  
+
   // Select the Glide device
   grSstSelect (settings.card_id);
-  
+
   gfx_context = 0;
   // Select the window
 
     grGlideShutdown ();
     return FALSE;
   }
-  
+
   // get the # of TMUs available
   grGet (GR_NUM_TMU, 4, (FxI32 *) &num_tmu);
   WriteLog(M64MSG_INFO, "num_tmu %d\n", num_tmu);
   // get maximal texture size
   grGet (GR_MAX_TEXTURE_SIZE, 4, (FxI32 *) &max_tex_size);
   //num_tmu = 1;
-  
+
   // Is mirroring allowed?
   const char *extensions = grGetString (GR_EXTENSION);
-  
+
   if (strstr (extensions, "TEXMIRROR"))
     sup_mirroring = 1;
   else
     sup_32bit_tex = TRUE;
   else
     sup_32bit_tex = FALSE;
-  
+
   if (settings.fb_hires)
   {
     const char * extstr = strstr(extensions, "TEXTUREBUFFER");
     if (extstr)
     {
-      if (!strncmp(extstr, "TEXTUREBUFFER", 13)) 
+      if (!strncmp(extstr, "TEXTUREBUFFER", 13))
       {
         grTextureBufferExt = (GRTEXBUFFEREXT) grGetProcAddress("grTextureBufferExt");
         grTextureAuxBufferExt = (GRTEXBUFFEREXT) grGetProcAddress("grTextureAuxBufferExt");
         grAuxBufferExt = (GRAUXBUFFEREXT) grGetProcAddress("grAuxBufferExt");
       }
     }
-    else 
+    else
       settings.fb_hires = 0;
   }
   else
 
   grFramebufferCopyExt = (GRFRAMEBUFFERCOPYEXT) grGetProcAddress("grFramebufferCopyExt");
   grStippleModeExt = (GRSTIPPLE) grStippleMode;
-  grStipplePatternExt = (GRSTIPPLE) grStipplePattern; 
+  grStipplePatternExt = (GRSTIPPLE) grStipplePattern;
   if (grStipplePatternExt)
     grStipplePatternExt(settings.stipple_pattern);
 
   num_tmu = 1;
   sup_mirroring = 0;
 #endif
-  
+
 #ifdef SIMULATE_BANSHEE
   num_tmu = 1;
   sup_mirroring = 1;
 #endif
-  
+
   fullscreen = TRUE;
-  
+
   if (evoodoo_using_window)
     ev_fullscreen = FALSE;
   else
   grVertexLayout (GR_PARAM_ST0, offsetof(VERTEX,coord[0]), GR_PARAM_ENABLE);
   grVertexLayout (GR_PARAM_ST1, offsetof(VERTEX,coord[2]), GR_PARAM_ENABLE);
   grVertexLayout (GR_PARAM_PARGB, offsetof(VERTEX,b), GR_PARAM_ENABLE);
-  
+
   grCullMode(GR_CULL_NEGATIVE);
-  
-  if (settings.fog) //"FOGCOORD" extension 
+
+  if (settings.fog) //"FOGCOORD" extension
   {
     if (strstr (extensions, "FOGCOORD"))
     {
       GrFog_t fog_t[64];
       guFogGenerateLinear (fog_t, 0.0f, 255.0f);//(float)rdp.fog_multiplier + (float)rdp.fog_offset);//256.0f);
-      
+
       for (int i = 63; i > 0; i--)
       {
         if (fog_t[i] - fog_t[i-1] > 63)
     else //not supported
       settings.fog = FALSE;
   }
-  
+
   //grDepthBufferMode (GR_DEPTHBUFFER_WBUFFER);
   grDepthBufferMode (GR_DEPTHBUFFER_ZBUFFER);
   grDepthBufferFunction(GR_CMP_LESS);
   grDepthMask(FXTRUE);
-  
+
   settings.res_x = settings.scr_res_x;
   settings.res_y = settings.scr_res_y;
   ChangeSize ();
-  
+
   guLoadTextures ();
   grRenderBuffer(GR_BUFFER_BACKBUFFER);
-  
+
   rdp_reset ();
   ClearCache ();
-  
+
   rdp.update |= UPDATE_SCISSOR;
-  
+
   return TRUE;
 }
 
 {
   // Release graphics
   grSstWinClose (gfx_context);
-  
+
   // Shutdown glide
   grGlideShutdown();
-  
+
   fullscreen = FALSE;
   rdp.window_changed = TRUE;
 }
       WriteLog(M64MSG_WARNING, "[Glide64] Cannot save screenshot in windowed mode?\n");
       return;
     }
-    
+
     GrLfbInfo_t info;
     info.size = sizeof(GrLfbInfo_t);
     if (grLfbLock(GR_LFB_READ_ONLY, GR_BUFFER_FRONTBUFFER, GR_LFBWRITEMODE_888, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info))
         }
         line += settings.res_x * 3;
       }
-      
+
       // Unlock the frontbuffer
       grLfbUnlock (GR_LFB_READ_ONLY, GR_BUFFER_FRONTBUFFER);
     }
 
     if (APIVersion != NULL)
         *APIVersion = PLUGIN_API_VERSION;
-    
+
     if (PluginNamePtr != NULL)
         *PluginNamePtr = "Glide64";
 
     {
         *Capabilities = 0;
     }
-                    
+
     return M64ERR_SUCCESS;
 }
 
 Purpose:  This function dumps the current frame to a file
 input:    pointer to the directory to save the file to
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL CaptureScreen ( char * Directory )
 {
   capture_screen = 1;
 
 /******************************************************************
 Function: ChangeWindow
-Purpose:  to change the window between fullscreen and window 
-mode. If the window was in fullscreen this should 
+Purpose:  to change the window between fullscreen and window
+mode. If the window was in fullscreen this should
 change the screen to window mode and vice vesa.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL ChangeWindow (void)
 {
   LOG ("ChangeWindow()\n");
     if (!ev_fullscreen)
     {
       to_fullscreen = TRUE;
-      GRWRAPPERFULLSCREENRESOLUTIONEXT grWrapperFullScreenResolutionExt = 
+      GRWRAPPERFULLSCREENRESOLUTIONEXT grWrapperFullScreenResolutionExt =
          (GRWRAPPERFULLSCREENRESOLUTIONEXT)grGetProcAddress("grWrapperFullScreenResolutionExt");
       if (grWrapperFullScreenResolutionExt != NULL)
       {
     else
     {
       ReleaseGfx ();
-      GRWRAPPERFULLSCREENRESOLUTIONEXT grWrapperFullScreenResolutionExt = 
+      GRWRAPPERFULLSCREENRESOLUTIONEXT grWrapperFullScreenResolutionExt =
          (GRWRAPPERFULLSCREENRESOLUTIONEXT)grGetProcAddress("grWrapperFullScreenResolutionExt");
       if (grWrapperFullScreenResolutionExt != NULL)
       {
 down allowing the dll to de-initialise.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL CloseDLL (void)
 {
   LOG ("CloseDLL ()\n");
-  
+
   // re-set the old window proc
 #ifdef WINPROC_OVERRIDE
   SetWindowLong (gfx.hWnd, GWL_WNDPROC, (long)oldWndProc);
 #endif
-  
+
 #ifdef ALTTAB_FIX
   if (hhkLowLevelKybd)
   {
     hhkLowLevelKybd = 0;
   }
 #endif
-  
+
   //CLOSELOG ();
-  
+
   if (fullscreen)
     ReleaseGfx ();
   ZLUT_release();
 to give further information about the DLL.
 input:    a handle to the window that calls this function
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL DllAbout ( HWND hParent )
 {
    messagebox("Glide64 v"G64_VERSION, MB_OK,
-          "Glide64 "G64_VERSION"\nRelease: " RELTIME "\n" 
+          "Glide64 "G64_VERSION"\nRelease: " RELTIME "\n"
           "by GuentherB, Richard42, Gonetz, Dave2001, Gugaman, and others\n\n"
           "Beta testers: Raziel64, Federelli, Flash\n\n"
           "Special thanks to:\n"
 to allow the user to test the dll
 input:    a handle to the window that calls this function
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL DllTest ( HWND hParent )
 {
 }
 it is being used in the desktop.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL DrawScreen (void)
 {
   LOG ("DrawScreen ()\n");
 input:    a pointer to a PLUGIN_INFO stucture that needs to be
 filled by the function. (see def above)
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo )
 {
   PluginInfo->Version = 0x0103;     // Set to 0x0103
   PluginInfo->Type  = PLUGIN_TYPE_GFX;  // Set to PLUGIN_TYPE_GFX
   sprintf (PluginInfo->Name, "Glide64 "G64_VERSION);  // Name of the DLL
-  
+
   // If DLL supports memory these memory options then set them to TRUE or FALSE
   //  if it does not support it
   PluginInfo->NormalMemory = TRUE;  // a normal BYTE array
 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
 {
    struct timeval tv;
-   
+
    /* generic routine */
    gettimeofday( &tv, NULL );
    counter->QuadPart = (LONGLONG)tv.tv_usec + (LONGLONG)tv.tv_sec * 1000000;
   To generate an interrupt set the appropriate bit in MI_INTR_REG
   and then call the function CheckInterrupts to tell the emulator
   that there is a waiting interrupt.
-*******************************************************************/ 
+*******************************************************************/
 
 EXPORT BOOL CALL InitiateGFX (GFX_INFO Gfx_Info)
 {
   LOG ("InitiateGFX (*)\n");
   // Do *NOT* put this in rdp_reset or it could be set after the screen is initialized
   num_tmu = 2;
-  
+
   // Assume scale of 1 for debug purposes
   rdp.scale_x = 1.0f;
   rdp.scale_y = 1.0f;
-  
+
   memset (&settings, 0, sizeof(SETTINGS));
   ReadSettings ();
-  
+
 #ifdef FPS
   QueryPerformanceFrequency (&perf_freq);
   QueryPerformanceCounter (&fps_last);
 #endif
-  
+
   debug_init ();    // Initialize debugger
-  
+
   gfx = Gfx_Info;
-  /*  
+  /*
   char name[21];
   // get the name of the ROM
   for (int i=0; i<20; i++)
     name[i] = gfx.HEADER[(32+i)^3];
   name[20] = 0;
-  
+
   // remove all trailing spaces
   while (name[strlen(name)-1] == ' ')
     name[strlen(name)-1] = 0;
-  
+
   ReadSpecialSettings (name);
-  */  
+  */
 #ifdef WINPROC_OVERRIDE
   if (!oldWndProc)
   {
     oldWndProc = (WNDPROC)SetWindowLong (gfx.hWnd, GWL_WNDPROC, (long)myWndProc);
   }
 #endif
-  
+
   util_init ();
   math_init ();
   TexCacheInit ();
   CountCombine();
   if (settings.fb_depth_render)
     ZLUT_init();
-  
+
   return TRUE;
 }
 
 input:    xpos - the x-coordinate of the upper-left corner of the
 client area of the window.
 ypos - y-coordinate of the upper-left corner of the
-client area of the window. 
+client area of the window.
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL MoveScreen (int xpos, int ypos)
 {
   LOG ("MoveScreen");
 Purpose:  This function is called when a rom is closed.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL RomClosed (void)
 {
   LOG ("RomClosed ()\n");
-  
+
   CLOSE_RDP_LOG ();
   CLOSE_RDP_E_LOG ();
   rdp.window_changed = TRUE;
 
 /******************************************************************
 Function: RomOpen
-Purpose:  This function is called when a rom is open. (from the 
+Purpose:  This function is called when a rom is open. (from the
 emulation thread)
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT int CALL RomOpen (void)
 {
   LOG ("RomOpen ()\n");
   no_dlist = TRUE;
   romopen = TRUE;
   ucode_error_report = TRUE;    // allowed to report ucode errors
-  
+
   // Get the country code & translate to NTSC(0) or PAL(1)
   WORD code = ((WORD*)gfx.HEADER)[0x1F^1];
-  
+
   if (code == 0x4400) region = 1; // Germany (PAL)
   if (code == 0x4500) region = 0; // USA (NTSC)
   if (code == 0x4A00) region = 0; // Japan (NTSC)
   if (code == 0x5000) region = 1; // Europe (PAL)
   if (code == 0x5500) region = 0; // Australia (NTSC)
-  
+
   char name[21] = "DEFAULT";
   ReadSpecialSettings (name);
-  
+
   // get the name of the ROM
   for (int i=0; i<20; i++)
     name[i] = gfx.HEADER[(32+i)^3];
   name[20] = 0;
-  
+
   // remove all trailing spaces
   while (name[strlen(name)-1] == ' ')
     name[strlen(name)-1] = 0;
-  
+
   ReadSpecialSettings (name);
 
 
   WriteLog(M64MSG_INFO, "fb_clear %d fb_smart %d\n", settings.fb_depth_clear, settings.fb_smart);
 
-  
+
   rdp_reset ();
   ClearCache ();
 
   OPEN_RDP_LOG ();
   OPEN_RDP_E_LOG ();
-  
+
   // ** EVOODOO EXTENSIONS **
   if (!fullscreen)
   {
   if (!fullscreen)
   {
     grGlideShutdown ();
-    
+
     if (strstr (extensions, "EVOODOO"))
       evoodoo = 1;
     else
       evoodoo = 0;
-    
+
     if (evoodoo)
       InitGfx (TRUE);
   }
-  
+
   if (strstr (extensions, "ROMNAME"))
   {
     void (__stdcall *grSetRomName)(char*);
 them again.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL ShowCFB (void)
 {
   no_dlist = TRUE;
 set
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 DWORD update_screen_count = 0;
 EXPORT void CALL UpdateScreen (void)
 {
   sprintf (out_buf, "UpdateScreen (). distance: %d\n", (int)(*gfx.VI_ORIGIN_REG) - (int)((*gfx.VI_WIDTH_REG) << 2));
   LOG (out_buf);
   //  LOG ("UpdateScreen ()\n");
-  
+
   DWORD width = (*gfx.VI_WIDTH_REG) << 1;
   if (fullscreen && (*gfx.VI_ORIGIN_REG  > width))
     update_screen_count++;
-  
+
   // vertical interrupt has occured, increment counter
   vi_count ++;
-  
+
 #ifdef FPS
   // Check frames per second
   LARGE_INTEGER difference;
     vi_count = 0;
   }
 #endif
-  //*  
+  //*
   DWORD limit = settings.lego ? 15 : 50;
-  if (settings.cpu_write_hack && (update_screen_count > limit) && (rdp.last_bg == 0)) 
+  if (settings.cpu_write_hack && (update_screen_count > limit) && (rdp.last_bg == 0))
   {
     RDP("DirectCPUWrite hack!\n");
     update_screen_count = 0;
     }
     return;
   }
-  //*/  
+  //*/
   if (settings.swapmode == 0)
   {
     newSwapBuffers ();
 ViStatus registers value has been changed.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL ViStatusChanged (void)
 {
 }
 ViWidth registers value has been changed.
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 EXPORT void CALL ViWidthChanged (void)
 {
 }
     if (to_fullscreen)
     {
       to_fullscreen = FALSE;
-      
+
       if (!InitGfx (FALSE))
       {
         LOG ("FAILED!!!\n");
       }
       fullscreen = TRUE;
     }
-    
+
     if (fullscreen)
     {
       grDepthMask (FXTRUE);
   if (rdp.updatescreen)
   {
     rdp.updatescreen = 0;
-    
+
     RDP ("swapped\n");
- 
+
     // Allow access to the whole screen
     if (fullscreen)
     {
       grClipWindow (0, 0, settings.scr_res_x, settings.scr_res_y);
       grDepthBufferFunction (GR_CMP_ALWAYS);
       grDepthMask (FXFALSE);
-      
+
       grCullMode (GR_CULL_DISABLE);
 
       if ((settings.show_fps & 0xF) || settings.clock)
           output (0, y, 0, "FPS: %.02f ", fps);
       }
 #endif
-      
+
       if (settings.clock)
       {
         if (settings.clock_24_hr)
           time_t ltime;
           time (&ltime);
           tm *cur_time = localtime (&ltime);
-          
+
           sprintf (out_buf, "%.2d:%.2d:%.2d", cur_time->tm_hour, cur_time->tm_min, cur_time->tm_sec);
         }
         else
         {
           char ampm[] = "AM";
           time_t ltime;
-          
+
           time (&ltime);
           tm *cur_time = localtime (&ltime);
-          
+
           if (cur_time->tm_hour >= 12)
           {
             strcpy (ampm, "PM");
           }
           if (cur_time->tm_hour == 0)
             cur_time->tm_hour = 12;
-          
+
           if (cur_time->tm_hour >= 10)
             sprintf (out_buf, "%.5s %s", asctime(cur_time) + 11, ampm);
           else
     {
       // Allocate the screen
       debug.screen = new BYTE [(settings.res_x*settings.res_y) << 1];
-      
+
       // Lock the backbuffer (already rendered)
       GrLfbInfo_t info;
       info.size = sizeof(GrLfbInfo_t);
         GR_ORIGIN_UPPER_LEFT,
         FXFALSE,
         &info));
-      
+
       DWORD offset_src=0/*(settings.scr_res_y-settings.res_y)*info.strideInBytes*/, offset_dst=0;
-      
+
       // Copy the screen
       for (DWORD y=0; y<settings.res_y; y++)
       {
         offset_dst += settings.res_x << 1;
         offset_src += info.strideInBytes;
       }
-      
+
       // Unlock the backbuffer
       grLfbUnlock (GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER);
     }
 
     if (fullscreen)
     {
-      LOG ("BUFFER SWAPPED\n"); 
-      grBufferSwap (settings.vsync);    
+      LOG ("BUFFER SWAPPED\n");
+      grBufferSwap (settings.vsync);
       fps_count ++;
     }
-    
+
     if (fullscreen && (debugging || settings.wireframe || settings.buff_clear))
     {
       if (settings.RE2 && settings.fb_depth_render)
         grDepthMask (FXTRUE);
       grBufferClear (0, 0, 0xFFFF);
     }
-    
+
     frame_count ++;
   }
 }
   case WM_ACTIVATE:
     rdp.window_changed = TRUE;
     break;
-    
+
     /*    case WM_DESTROY:
     SetWindowLong (gfx.hWnd, GWL_WNDPROC, (long)oldWndProc);
     break;*/
   }
-  
+
   return CallWindowProc(oldWndProc, hwnd, msg, wParam, lParam);
 }
 #endif
 BOOL k_ctl=0, k_alt=0, k_del=0;
 
 #ifdef ALTTAB_FIX
-LRESULT CALLBACK LowLevelKeyboardProc(int nCode, 
+LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
                                       WPARAM wParam, LPARAM lParam) {
   if (!fullscreen) return CallNextHookEx(NULL, nCode, wParam, lParam);
-  
+
   BOOL TabKey = FALSE;
-  
+
   PKBDLLHOOKSTRUCT p;
-  
-  if (nCode == HC_ACTION) 
+
+  if (nCode == HC_ACTION)
   {
     switch (wParam) {
     case WM_KEYUP:    case WM_SYSKEYUP:
       if (p->vkCode == 164) k_alt = 0;
       if (p->vkCode == 46) k_del = 0;
       goto do_it;
-      
+
     case WM_KEYDOWN:  case WM_SYSKEYDOWN:
       p = (PKBDLLHOOKSTRUCT) lParam;
       if (p->vkCode == 162) k_ctl = 1;
       if (p->vkCode == 164) k_alt = 1;
       if (p->vkCode == 46) k_del = 1;
       goto do_it;
-      
-do_it:    
+
+do_it:
       TabKey =
         ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
         ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
         ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0)) ||
         (k_ctl && k_alt && k_del);
-      
+
       break;
     }
   }
-  
+
   if (TabKey)
   {
     k_ctl = 0;
     k_del = 0;
     ReleaseGfx ();
   }
-  
+
   return CallNextHookEx(NULL, nCode, wParam, lParam);
 }
 #endif
 *
 * You should have received a copy of the GNU General Public
 * Licence along with this program; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
 
 const char *str_tlut[4]   = { "TT_NONE", "TT_UNKNOWN", "TT_RGBA_16", "TT_IA_16" };
 
 const char *CIStatus[10] = { "ci_main", "ci_zimg", "ci_unknown",  "ci_useless",
-                           "ci_old_copy", "ci_copy", "ci_copy_self", 
+                           "ci_old_copy", "ci_copy", "ci_copy_self",
                            "ci_zcopy", "ci_aux", "ci_aux_copy" };
 
 
 void rdp_reset ()
 {
     reset = 1;
-    
+
     rdp.model_i = 0;
-    
+
     rdp.n_cached[0] = 0;
     rdp.n_cached[1] = 0;
     rdp.cur_cache[0] = NULL;
     rdp.c_Ab0 = 0;
     rdp.c_Ac0 = 0;
     rdp.c_Ad0 = 0;
-    
+
     rdp.c_a1  = 0;
     rdp.c_b1  = 0;
     rdp.c_c1  = 0;
     rdp.c_Ab1 = 0;
     rdp.c_Ac1 = 0;
     rdp.c_Ad1 = 0;
-    
+
     // Clear the palette CRC
     int i;
     for (i=0; i<16; i++)
         rdp.pal_8_crc[i] = 0;
-    
+
     // Clear the palettes
     for (i=0; i<256; i++)
         rdp.pal_8[i] = 0;
-    
+
     rdp.tlut_mode = 0;
-    
+
     // Clear all segments ** VERY IMPORTANT FOR ZELDA **
     for (i=0; i<16; i++)
         rdp.segment[i] = 0;
-    
+
     for (i=0; i<512; i++)
         rdp.addr[i] = 0;
-    
+
     // set all vertex numbers
     for (i=0; i<MAX_VTX; i++)
         rdp.vtx[i].number = i;
     rdp.render_mode_changed = 0;
     rdp.othermode_h = 0;
     rdp.othermode_l = 0;
-    
+
     rdp.tex_ctr = 0;
-    
+
     rdp.tex = 0;
-    
+
     rdp.cimg = 0;
     rdp.ocimg = 0;
     rdp.zimg = 0;
     rdp.ci_width = 0;
     rdp.cycle_mode = 2;
-    
+
     rdp.allow_combine = 1;
-    
+
   rdp.fog_coord_enabled = FALSE;
     rdp.skip_drawing = FALSE;
 
   rdp.maincimg[0].addr = rdp.maincimg[1].addr = rdp.last_drawn_ci_addr = 0x7FFFFFFF;
     rdp.read_previous_ci = FALSE;
     rdp.yuv_ul_x = rdp.yuv_ul_y = rdp.yuv_lr_x = rdp.yuv_lr_y = 0;
-    rdp.yuv_im_begin = 0x00FFFFFF; 
+    rdp.yuv_im_begin = 0x00FFFFFF;
     rdp.yuv_image = FALSE;
     rdp.cur_tex_buf = 0;
   rdp.acc_tex_buf = 0;
     rdp.cur_image = 0;
     rdp.hires_tex = 0;
 
-    hotkey_info.fb_always = 0; 
-    hotkey_info.fb_motionblur = (settings.buff_clear == 0)?0:60; 
-    hotkey_info.filtering = hotkey_info.fb_motionblur; 
-    hotkey_info.corona = hotkey_info.fb_motionblur; 
+    hotkey_info.fb_always = 0;
+    hotkey_info.fb_motionblur = (settings.buff_clear == 0)?0:60;
+    hotkey_info.filtering = hotkey_info.fb_motionblur;
+    hotkey_info.corona = hotkey_info.fb_motionblur;
 #ifdef _WIN32
     GetAsyncKeyState (VK_BACK);
     GetAsyncKeyState(0x42);
 {
     DWORD i;
     uc_crc = 0;
-    
+
     // Check first 3k of ucode, because the last 1k sometimes contains trash
     for (i=0; i<3072>>2; i++)
     {
         uc_crc += ((DWORD*)microcode)[i];
     }
-    
+
     FRDP_E ("crc: %08lx\n", uc_crc);
-    
+
 #ifdef LOG_UCODE
     std::ofstream ucf;
     ucf.open ("ucode.txt", ios::out | ios::binary);
     }
     ucf.close ();
 #endif
-    
+
     char str[9];
   sprintf (str, "%08lx", (unsigned long)uc_crc);
-    
+
     INI_Open ();
     INI_FindSection ("UCODE");
     FRDP("ucode = %s\n", str);
     if (uc == -2 && ucode_error_report)
     {
         Config_Open();
-        settings.ucode = Config_ReadInt ("ucode", 0);
-        
+        settings.ucode = Config_ReadInt ("ucode", "Force microcode", 0, FALSE, FALSE);
+
         ReleaseGfx ();
         WriteLog(M64MSG_ERROR, "Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", (unsigned long)uc_crc);
-        
+
         ucode_error_report = FALSE; // don't report any more ucode errors from this game
     }
     else if (uc == -1 && ucode_error_report)
     {
         Config_Open();
-        settings.ucode = Config_ReadInt ("ucode", 0);
-        
+        settings.ucode = Config_ReadInt ("ucode", "Force microcode", 0, FALSE, FALSE);
+
         ReleaseGfx ();
         WriteLog(M64MSG_ERROR, "Error: Unsupported uCode!\n\ncrc: %08lx", (unsigned long)uc_crc);
-        
+
         ucode_error_report = FALSE; // don't report any more ucode errors from this game
     }
     else
     if (r < 0) r = 0;
     if (g < 0) g = 0;
     if (b < 0) b = 0;
-    
+
     WORD c = (WORD)(((WORD)(r) << 11) |
               ((WORD)(g) << 6) |
               ((WORD)(b) << 1) | 1);
     GR_COMBINE_OTHER_TEXTURE,
     FXFALSE);
   grConstantColorValue (0xFFFFFFFF);
-  grAlphaBlendFunction( GR_BLEND_SRC_ALPHA, 
-    GR_BLEND_ONE_MINUS_SRC_ALPHA, 
-    GR_BLEND_ONE, 
-    GR_BLEND_ZERO); 
+  grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,
+    GR_BLEND_ONE_MINUS_SRC_ALPHA,
+    GR_BLEND_ONE,
+    GR_BLEND_ZERO);
   rdp.update |= UPDATE_COMBINE;
-  
+
   float scale_x_dst = (float)settings.scr_res_x / rdp.vi_width;//(float)max(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
   float scale_y_dst = (float)settings.scr_res_y / rdp.vi_height;//(float)max(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
   float scale_x_src = (float)rdp.vi_width / (float)settings.scr_res_x;//(float)max(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
         cur_part = num_of_parts;
         num_of_parts++;
       }
-      else 
+      else
       {
         for (p = 0; p < num_of_parts; p++)
         {
         most_right = w;
         num_of_parts++;
       }
-      else 
+      else
       {
         if (parts[cur_part].lr_x < w) parts[cur_part].lr_x = w;
         if (most_right < w) most_right = w;
   if (!fullscreen)
     return;
   FRDP ("CopyFrameBuffer: %08lx... ", rdp.cimg);
-  
+
   // don't bother to write the stuff in asm... the slow part is the read from video card,
   //   not the copy.
-  
+
   int width = rdp.ci_width;//*gfx.VI_WIDTH_REG;
   int height;
   if (settings.fb_smart && !settings.PPL)
       height -= rdp.ci_upper_bound;
   }
   FRDP ("width: %d, height: %d...  ", width, height);
-  
+
   if (rdp.scale_x < 1.1f)
   {
     WORD * ptr_src = new WORD[width*height];
       WORD *ptr_dst = (WORD*)(gfx.RDRAM+rdp.cimg);
       DWORD *ptr_dst32 = (DWORD*)(gfx.RDRAM+rdp.cimg);
       WORD c;
-      
+
       for (int y=0; y<height; y++)
       {
         for (int x=0; x<width; x++)
       {
       BYTE *ptr_dst = (BYTE*)(gfx.RDRAM+rdp.cimg);
       WORD c;
-      
+
         for (int y=0; y<height; y++)
         {
         for (int x=0; x<width; x++)
     }
     delete[] ptr_src;
   }
-  else 
+  else
   {
     if (rdp.motionblur && settings.fb_hires)
     {
       return;
-    }   
+    }
     else
     {
       float scale_x = (float)settings.scr_res_x / rdp.vi_width;//(float)max(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
       float scale_y = (float)settings.scr_res_y / rdp.vi_height;//(float)max(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
-      
+
       FRDP("width: %d, height: %d, ul_y: %d, lr_y: %d, scale_x: %f, scale_y: %f, ci_width: %d, ci_height: %d\n",width, height, rdp.ci_upper_bound, rdp.ci_lower_bound, scale_x, scale_y, rdp.ci_width, rdp.ci_height);
       GrLfbInfo_t info;
       info.size = sizeof(GrLfbInfo_t);
-      
+
 
       // VP 888 disconnected for now
       if (1||rdp.ci_size <= 2) {
         DWORD *ptr_dst32 = (DWORD*)(gfx.RDRAM+rdp.cimg);
         WORD c;
         DWORD stride = info.strideInBytes>>1;
-        
+
         BOOL read_alpha = settings.fb_read_alpha;
         if (settings.PM && rdp.frame_buffers[rdp.ci_count-1].status != ci_aux)
           read_alpha = FALSE;
               ptr_dst32[x + y * width] = RGBA16TO32(c);
           }
           }
-        
+
         // Unlock the backbuffer
         grLfbUnlock (GR_LFB_READ_ONLY, buffer);
         RDP ("LfbLock.  Framebuffer copy complete.\n");
         DWORD *ptr_dst32 = (DWORD*)(gfx.RDRAM+rdp.cimg);
         DWORD c;
         DWORD stride = info.strideInBytes>>1;
-        
+
         BOOL read_alpha = settings.fb_read_alpha;
         if (settings.PM && rdp.frame_buffers[rdp.ci_count-1].status != ci_aux)
           read_alpha = FALSE;
             ptr_dst32[x + y * width] = c;
           }
           }
-        
+
         // Unlock the backbuffer
         grLfbUnlock (GR_LFB_READ_ONLY, buffer);
         RDP ("LfbLock.  Framebuffer copy complete.\n");
         RDP ("Framebuffer copy failed.\n");
       }
       }
-    }   
+    }
   }
 }
 
 processed. (High level GFX list)
 input:    none
 output:   none
-*******************************************************************/ 
+*******************************************************************/
 void DetectFrameBufferUsage ();
 DWORD fbreads_front = 0;
 DWORD fbreads_back = 0;
     no_dlist = FALSE;
   update_screen_count = 0;
     ChangeSize ();
-    
+
 #ifdef ALTTAB_FIX
     if (!hhkLowLevelKybd)
     {
-        hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, 
+        hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
             LowLevelKeyboardProc, hInstance, 0);
     }
 #endif
-    
+
     LOG ("ProcessDList ()\n");
-    
+
     if (!fullscreen)
   {
         drawNoFullscreenMessage();
     *gfx.MI_INTR_REG |= 0x20;
     gfx.CheckInterrupts();
   }
-    
+
     if (reset)
     {
         reset = 0;
-        
+
         memset (microcode, 0, 4096);
         if (settings.autodetect_ucode)
         {
             // Thanks to ZeZu for ucode autodetection!!!
-            
+
             DWORD startUcode = *(DWORD*)(gfx.DMEM+0xFD0);
             memcpy (microcode, gfx.RDRAM+startUcode, 4096);
             microcheck ();
-            
+
         }
     }
   else if ( ((old_ucode == 6) && (settings.ucode == 1)) || settings.force_microcheck)
         memcpy (microcode, gfx.RDRAM+startUcode, 4096);
         microcheck ();
     }
-    
+
     if (exception) return;
-    
+
     // Switch to fullscreen?
     if (to_fullscreen)
     {
         to_fullscreen = FALSE;
-        
+
         if (!InitGfx (FALSE))
         {
             LOG ("FAILED!!!\n");
         }
         fullscreen = TRUE;
     }
-    
+
     // Clear out the RDP log
 #ifdef RDP_LOGGING
     if (settings.logging && settings.log_clear)
         OPEN_RDP_LOG ();
     }
 #endif
-    
+
 #ifdef UNIMP_LOG
     if (settings.log_unk && settings.unk_clear)
     {
         unimp.close();
     }
 #endif
-  
+
   //* Set states *//
   if (settings.swapmode > 0)
     SwapOK = TRUE;
   rdp.updatescreen = 1;
-  
+
     rdp.tri_n = 0;  // 0 triangles so far this frame
     rdp.debug_n = 0;
-    
+
     rdp.model_i = 0; // 0 matrices so far in stack
     //stack_size can be less then 32! Important for Silicon Vally. Thanks Orkin!
     rdp.model_stack_size = min(32, (*(DWORD*)(gfx.DMEM+0x0FE4))>>6);
     if (rdp.model_stack_size == 0)
       rdp.model_stack_size = 32;
-  rdp.fb_drawn = rdp.fb_drawn_front = FALSE; 
+  rdp.fb_drawn = rdp.fb_drawn_front = FALSE;
     rdp.update = 0x7FFFFFFF;  // All but clear cache
     rdp.geom_mode = 0;
   rdp.acmp = 0;
   fbreads_front = fbreads_back = 0;
   rdp.fog_multiplier = rdp.fog_offset = 0;
   rdp.zsrc = 0;
-    
+
     if (cpu_fb_write == TRUE)
       DrawFrameBufferToScreen();
     cpu_fb_write = FALSE;
     d_ul_y = 0xffff;
     d_lr_x = 0;
     d_lr_y = 0;
-    
+
     //analize possible frame buffer usage
     if (settings.fb_smart)
         DetectFrameBufferUsage();
   if (!settings.lego || rdp.num_of_ci > 1)
     rdp.last_bg = 0;
   //* End of set states *//
-  
-    
+
+
     // Get the start of the display list and the length of it
     DWORD dlist_start = *(DWORD*)(gfx.DMEM+0xFF0);
     DWORD dlist_length = *(DWORD*)(gfx.DMEM+0xFF4);
   FRDP("--- NEW DLIST --- crc: %08lx, ucode: %d, fbuf: %08lx, fbuf_width: %d, dlist start: %08lx, dlist_lenght: %d\n", uc_crc, settings.ucode, *gfx.VI_ORIGIN_REG, *gfx.VI_WIDTH_REG, dlist_start, dlist_length);
     FRDP_E("--- NEW DLIST --- crc: %08lx, ucode: %d, fbuf: %08lx\n", uc_crc, settings.ucode, *gfx.VI_ORIGIN_REG);
-    
+
     if (settings.tonic && dlist_length < 16)
     {
     rdp_fullsync();
         FRDP_E("DLIST is too short!\n");
         return;
     }
-    
+
     // Start executing at the start of the display list
     rdp.pc_i = 0;
     rdp.pc[rdp.pc_i] = dlist_start;
     rdp.dl_count = -1;
     rdp.halt = 0;
   DWORD a;
-    
+
     // catches exceptions so that it doesn't freeze
 #ifdef CATCH_EXCEPTIONS
     try {
 #endif
-        
+
         // MAIN PROCESSING LOOP
         do {
-            
+
             // Get the address of the next command
             a = rdp.pc[rdp.pc_i] & BMASK;
-            
+
             // Load the next command and its input
             rdp.cmd0 = ((DWORD*)gfx.RDRAM)[a>>2];   // \ Current command, 64 bit
             rdp.cmd1 = ((DWORD*)gfx.RDRAM)[(a>>2)+1]; // /
             // cmd2 and cmd3 are filled only when needed, by the function that needs them
-            
+
             // Output the address before the command
 #ifdef LOG_COMMANDS
             FRDP ("%08lx (c0:%08lx, c1:%08lx): ", a, rdp.cmd0, rdp.cmd1);
 #else
             FRDP ("%08lx: ", a);
 #endif
-            
+
             // Go to the next instruction
             rdp.pc[rdp.pc_i] = (a+8) & BMASK;
-            
+
 #ifdef PERFORMANCE
             QueryPerformanceCounter ((LARGE_INTEGER*)&perf_cur);
 #endif
             // Process this instruction
             gfx_instruction[settings.ucode][rdp.cmd0>>24] ();
-            
+
             // check DL counter
             if (rdp.dl_count != -1)
             {
                 if (rdp.dl_count == 0)
                 {
                     rdp.dl_count = -1;
-                    
+
                     RDP ("End of DL\n");
                     rdp.pc_i --;
                 }
             }
-            
+
 #ifdef PERFORMANCE
             QueryPerformanceCounter ((LARGE_INTEGER*)&perf_next);
             __int64 t = perf_next-perf_cur;
             sprintf (out_buf, "perf %08lx: %016I64d\n", a-8, t);
             rdp_log << out_buf;
 #endif
-            
+
         } while (!rdp.halt);
 #ifdef CATCH_EXCEPTIONS
     } catch (...) {
-        
+
         if (fullscreen) ReleaseGfx ();
         WriteLog(M64MSG_ERROR, "The GFX plugin caused an exception and has been disabled.");
         exception = TRUE;
     }
 #endif
-    
+
     if (settings.fb_smart)
     {
         rdp.scale_x = rdp.scale_x_bak;
     {
       DrawYUVImageToFrameBuffer();
       rdp.yuv_image = FALSE;
-//        FRDP("yuv image draw. ul_x: %f, ul_y: %f, lr_x: %f, lr_y: %f, begin: %08lx\n", 
+//        FRDP("yuv image draw. ul_x: %f, ul_y: %f, lr_x: %f, lr_y: %f, begin: %08lx\n",
 //        rdp.yuv_ul_x, rdp.yuv_ul_y, rdp.yuv_lr_x, rdp.yuv_lr_y, rdp.yuv_im_begin);
       rdp.yuv_ul_x = rdp.yuv_ul_y = rdp.yuv_lr_x = rdp.yuv_lr_y = 0;
-      rdp.yuv_im_begin = 0x00FFFFFF; 
+      rdp.yuv_im_begin = 0x00FFFFFF;
     }
     if (rdp.cur_image)
     CloseTextureBuffer(rdp.read_whole_frame && (settings.PM || rdp.swap_ci_index >= 0));
   *gfx.MI_INTR_REG |= 0x20;
   gfx.CheckInterrupts();
     rdp.halt = 1;
-  #endif    
+  #endif
 }
 
 // spnoop - no operation, always ignore
 static void ys_memrect ()
 {
     DWORD tile = (WORD)((rdp.cmd1 & 0x07000000) >> 24);
-    
+
     DWORD lr_x = (WORD)((rdp.cmd0 & 0x00FFF000) >> 14);
     DWORD lr_y = (WORD)((rdp.cmd0 & 0x00000FFF) >> 2);
     DWORD ul_x = (WORD)((rdp.cmd1 & 0x00FFF000) >> 14);
     DWORD ul_y = (WORD)((rdp.cmd1 & 0x00000FFF) >> 2);
-    
+
     rdp.pc[rdp.pc_i] += 16; // texrect is 196-bit
-    
+
     if (lr_y > rdp.scissor_o.lr_y) lr_y = rdp.scissor_o.lr_y;
-    
+
     FRDP ("memrect (%d, %d, %d, %d), ci_width: %d\n", ul_x, ul_y, lr_x, lr_y, rdp.ci_width);
-    
+
     DWORD y, width = lr_x - ul_x;
     DWORD texaddr = rdp.addr[rdp.tiles[tile].t_mem];
     DWORD tex_width = rdp.tiles[tile].line << 3;
-    
+
     for (y = ul_y; y < lr_y; y++) {
         BYTE *src = gfx.RDRAM + texaddr + (y - ul_y) * tex_width;
         BYTE *dst = gfx.RDRAM + rdp.cimg + ul_x + y * rdp.ci_width;
         DWORD dwHalf1 = (((DWORD*)gfx.RDRAM)[(a>>2)+0]) >> 24;
         if ((dwHalf1 != 0xF1)  && (dwHalf1 != 0xb3))
         {
-            rdp.pc[rdp.pc_i] += 16; 
+            rdp.pc[rdp.pc_i] += 16;
         }
         else
         {
     lr_y ++;
   }
 
-  //*   
+  //*
   if (rdp.hires_tex && settings.fb_optimize_texrect)
     {
        if (!rdp.hires_tex->drawn)
     // framebuffer workaround for Zelda: MM LOT
     if ((rdp.othermode_l & 0xFFFF0000) == 0x0f5a0000)
         return;
-    
+
     /*Gonetz*/
     //hack for Zelda MM. it removes black texrects which cover all geometry in "Link meets Zelda" cut scene
     if (settings.zelda && rdp.timg.addr >= rdp.cimg && rdp.timg.addr < rdp.ci_end)
         rdp.tri_n += 2;
         return;
     }
-//* 
+//*
     //hack for Banjo2. it removes black texrects under Banjo
     if (!settings.fb_hires && ((rdp.cycle1 << 16) | (rdp.cycle2 & 0xFFFF)) == 0xFFFFFFFF && (rdp.othermode_l & 0xFFFF0000) == 0x00500000)
     {
         rdp.tri_n += 2;
         return;
     }
-//*/    
+//*/
   //*
   //remove motion blur in night vision
   if ((settings.ucode == 7) && (rdp.maincimg[1].addr != rdp.maincimg[0].addr) && (rdp.timg.addr >= rdp.maincimg[1].addr) && (rdp.timg.addr < (rdp.maincimg[1].addr+rdp.ci_width*rdp.ci_height*rdp.ci_size)))
             return;
           }
     }
-//*/    
+//*/
 
     int i;
-    
+
     DWORD tile = (WORD)((rdp.cmd1 & 0x07000000) >> 24);
-    
+
     // update MUST be at the beginning, b/c of update_scissor
     if (rdp.cycle_mode == 2)
     {
         rdp.tex = 1;
         rdp.allow_combine = 0;
-        
+
     cmb.tmu1_func = cmb.tmu0_func = GR_COMBINE_FUNCTION_LOCAL;
     cmb.tmu1_fac = cmb.tmu0_fac = GR_COMBINE_FACTOR_NONE;
     cmb.tmu1_a_func = cmb.tmu0_a_func = GR_COMBINE_FUNCTION_LOCAL;
     }
 
     rdp.texrecting = 1;
-    
+
     DWORD prev_tile = rdp.cur_tile;
     rdp.cur_tile = tile;
     rdp.update |= UPDATE_COMBINE;
     update ();
-    
+
     rdp.texrecting = 0;
     rdp.allow_combine = 1;
 
-    if (!rdp.cur_cache[0]) 
+    if (!rdp.cur_cache[0])
     {
         rdp.cur_tile = prev_tile;
         rdp.tri_n += 2;
     float dtdy = (float)((short)(rdp.cmd3 & 0x0000FFFF)) / 1024.0f;
 
     if (rdp.cycle_mode == 2) dsdx /= 4.0f;
-    
+
     float s_ul_x = ul_x * rdp.scale_x + rdp.offset_x;
     float s_lr_x = lr_x * rdp.scale_x + rdp.offset_x;
     float s_ul_y = ul_y * rdp.scale_y + rdp.offset_y;
     float s_lr_y = lr_y * rdp.scale_y + rdp.offset_y;
-    
+
     FRDP("texrect (%d, %d, %d, %d), tile: %d, #%d, #%d\n", ul_x, ul_y, lr_x, lr_y, tile, rdp.tri_n, rdp.tri_n+1);
     FRDP ("(%f, %f) -> (%f, %f), s: (%d, %d) -> (%d, %d)\n", s_ul_x, s_ul_y, s_lr_x, s_lr_y, rdp.scissor.ul_x, rdp.scissor.ul_y, rdp.scissor.lr_x, rdp.scissor.lr_y);
     FRDP("\toff_x: %f, off_y: %f, dsdx: %f, dtdy: %f\n", off_x, off_y, dsdx, dtdy);
-    
+
     float off_size_x;
     float off_size_y;
 
     }
 
     float lr_u0, lr_v0, ul_u0, ul_v0, lr_u1, lr_v1, ul_u1, ul_v1;
-    
+
     if (rdp.cur_cache[0] && (rdp.tex & 1))
     {
         float sx=1, sy=1;
       FRDP("hires_tex ul_s: %d, ul_t: %d, off_x: %f, off_y: %f\n", rdp.tiles[0].ul_s, rdp.tiles[0].ul_t, off_x, off_y);
         ul_u0 = off_x * sx;
         ul_v0 = off_y * sy;
-        
+
         lr_u0 = ul_u0 + off_size_x * sx;
         lr_v0 = ul_v0 + off_size_y * sy;
-        
+
         ul_u0 *= rdp.hires_tex->u_scale;
         ul_v0 *= rdp.hires_tex->v_scale;
         lr_u0 *= rdp.hires_tex->u_scale;
     {
             ul_u0 = off_x * sx;
         ul_v0 = off_y * sy;
-        
+
         ul_u0 -= rdp.tiles[rdp.cur_tile].f_ul_s;
         ul_v0 -= rdp.tiles[rdp.cur_tile].f_ul_t;
-        
+
         lr_u0 = ul_u0 + off_size_x * sx;
         lr_v0 = ul_v0 + off_size_y * sy;
-        
+
             ul_u0 = rdp.cur_cache[0]->c_off + rdp.cur_cache[0]->c_scl_x * ul_u0;
             lr_u0 = rdp.cur_cache[0]->c_off + rdp.cur_cache[0]->c_scl_x * lr_u0;
             ul_v0 = rdp.cur_cache[0]->c_off + rdp.cur_cache[0]->c_scl_y * ul_v0;
     if (rdp.cur_cache[1] && (rdp.tex & 2))
     {
         float sx=1, sy=1;
-        
+
         if (rdp.tiles[rdp.cur_tile+1].shift_s)
         {
             if (rdp.tiles[rdp.cur_tile+1].shift_s > 10)
             else
                 sy = (float)1.0f/(1 << rdp.tiles[rdp.cur_tile+1].shift_t);
         }
-        
+
     if (rdp.hires_tex && rdp.hires_tex->tile == 1)
     {
       off_x += rdp.hires_tex->u_shift;// + rdp.tiles[0].ul_s; //commented for Paper Mario motion blur
       FRDP("hires_tex ul_s: %d, ul_t: %d, off_x: %f, off_y: %f\n", rdp.tiles[0].ul_s, rdp.tiles[0].ul_t, off_x, off_y);
             ul_u1 = off_x * sx;
         ul_v1 = off_y * sy;
-        
+
         lr_u1 = ul_u1 + off_size_x * sx;
         lr_v1 = ul_v1 + off_size_y * sy;
-        
+
         ul_u1 *= rdp.hires_tex->u_scale;
         ul_v1 *= rdp.hires_tex->v_scale;
         lr_u1 *= rdp.hires_tex->u_scale;
         lr_v1 *= rdp.hires_tex->v_scale;
         FRDP("hires_tex ul_u1: %f, ul_v1: %f, lr_u1: %f, lr_v1: %f\n", ul_u0, ul_v0, lr_u0, lr_v0);
-        
+
     }
     else
     {
         ul_u1 = off_x * sx;
         ul_v1 = off_y * sy;
-        
+
         ul_u1 -= rdp.tiles[rdp.cur_tile+1].f_ul_s;
         ul_v1 -= rdp.tiles[rdp.cur_tile+1].f_ul_t;
-        
+
         lr_u1 = ul_u1 + off_size_x * sx;
         lr_v1 = ul_v1 + off_size_y * sy;
-        
+
         ul_u1 = rdp.cur_cache[1]->c_off + rdp.cur_cache[1]->c_scl_x * ul_u1;
         lr_u1 = rdp.cur_cache[1]->c_off + rdp.cur_cache[1]->c_scl_x * lr_u1;
         ul_v1 = rdp.cur_cache[1]->c_off + rdp.cur_cache[1]->c_scl_y * ul_v1;
     rdp.cur_tile = prev_tile;
 
     // ****
-    
+
     FRDP ("  scissor: (%d, %d) -> (%d, %d)\n", rdp.scissor.ul_x, rdp.scissor.ul_y, rdp.scissor.lr_x, rdp.scissor.lr_y);
-    
+
     CCLIP2 (s_ul_x, s_lr_x, ul_u0, lr_u0, ul_u1, lr_u1, (float)rdp.scissor.ul_x, (float)rdp.scissor.lr_x);
     CCLIP2 (s_ul_y, s_lr_y, ul_v0, lr_v0, ul_v1, lr_v1, (float)rdp.scissor.ul_y, (float)rdp.scissor.lr_y);
 //  CCLIP2 (s_lr_y, s_ul_y, lr_v0, ul_v0, lr_v1, ul_v1, (float)rdp.scissor.ul_y, (float)rdp.scissor.lr_y);
-    
+
     FRDP ("  draw at: (%f, %f) -> (%f, %f)\n", s_ul_x, s_ul_y, s_lr_x, s_lr_y);
-    
+
     // DO NOT SET CLAMP MODE HERE
-    
+
     float Z = 1.0f;
     if (rdp.zsrc == 1 && (rdp.othermode_l & 0x00000030))  // othermode check makes sure it
         // USES the z-buffer.  Otherwise it returns bad (unset) values for lot and telescope
     {
         RDP ("no prim_depth used, using 1.0\n");
     }
-    
+
     VERTEX vstd[4] = {
     { s_ul_x, s_ul_y, Z, 1.0f, ul_u0, ul_v0, ul_u1, ul_v1, { 0, 0, 0, 0}, 255 },
     { s_lr_x, s_ul_y, Z, 1.0f, lr_u0, ul_v0, lr_u1, ul_v1, { 0, 0, 0, 0}, 255 },
     { s_ul_x, s_lr_y, Z, 1.0f, ul_u0, lr_v0, ul_u1, lr_v1, { 0, 0, 0, 0}, 255 },
     { s_lr_x, s_lr_y, Z, 1.0f, lr_u0, lr_v0, lr_u1, lr_v1, { 0, 0, 0, 0}, 255 } };
-        
+
         if ( ((rdp.cmd0>>24)&0xFF) == 0xE5 ) //texrectflip
         {
             vstd[1].u0 = ul_u0;
             vstd[1].v0 = lr_v0;
             vstd[1].u1 = ul_u1;
             vstd[1].v1 = lr_v1;
-            
+
             vstd[2].u0 = lr_u0;
             vstd[2].v0 = ul_v0;
             vstd[2].u1 = lr_u1;
 
         VERTEX *vptr = vstd;
         int n_vertices = 4;
-        
+
     VERTEX *vnew = 0;
 //      for (int j =0; j < 4; j++)
 //        FRDP("v[%d]  u0: %f, v0: %f, u1: %f, v1: %f\n", j, vstd[j].u0, vstd[j].v0, vstd[j].u1, vstd[j].v1);
                 max_u = vstd[0].u0;
                 max_x = vstd[0].x;
             }
-            
+
             int start_u_256, end_u_256;
-        
+
             if (settings.ucode == 7)
             {
               start_u_256 = 0;
             //FRDP(" min_u: %f, max_u: %f start: %d, end: %d\n", min_u, max_u, start_u_256, end_u_256);
 
             int splitheight = rdp.cur_cache[0]->splitheight;
-            
+
             int num_verts_line = 2 + ((end_u_256-start_u_256)<<1);
             vnew = new VERTEX [num_verts_line << 1];
-            
+
             n_vertices = num_verts_line << 1;
             vptr = vnew;
-            
+
             vnew[0] = vstd[0];
             vnew[0].u0 -= 256.0f * start_u_256;
             vnew[0].v0 += splitheight * start_u_256;
             vnew[n_vertices-1].v0 += splitheight * end_u_256;
       vnew[n_vertices-1].u1 -= 256.0f * end_u_256;
       vnew[n_vertices-1].v1 += splitheight * end_u_256;
-            
+
             // find the equation of the line of u,x
             float m = (max_x - min_x) / (max_u - min_u);  // m = delta x / delta u
             float b = min_x - m * min_u;          // b = y - m * x
-            
+
             for (i=start_u_256; i<end_u_256; i++)
             {
                 // Find where x = current 256 multiple
                 float x = m * ((i<<8)+256) + b;
-                
+
                 int vn = 2 + ((i-start_u_256)<<2);
                 vnew[vn] = vnew[0];
                 vnew[vn].x = x;
                 vnew[vn].v0 += (float)splitheight * i;
         vnew[vn].u1 = 255.5f;
         vnew[vn].v1 += (float)splitheight * i;
-                
+
                 vn ++;
                 vnew[vn] = vnew[1];
                 vnew[vn].x = x;
                 vnew[vn].v0 += (float)splitheight * i;
         vnew[vn].u1 = 255.5f;
         vnew[vn].v1 += (float)splitheight * i;
-                
+
                 vn ++;
                 vnew[vn] = vnew[vn-2];
                 vnew[vn].u0 = 0.5f;
                 vnew[vn].v0 += (float)splitheight;
         vnew[vn].u1 = 0.5f;
         vnew[vn].v1 += (float)splitheight;
-                
+
                 vn ++;
                 vnew[vn] = vnew[vn-2];
                 vnew[vn].u0 = 0.5f;
         vnew[vn].v1 += (float)splitheight;
             }
         }
-        
+
     AllowShadeMods (vptr, n_vertices);
         for (i=0; i<n_vertices; i++)
         {
             VERTEX *z = &vptr[i];
-            
+
             z->u0 *= z->q;
             z->v0 *= z->q;
             z->u1 *= z->q;
             z->v1 *= z->q;
-            
+
             apply_shade_mods (z);
         }
-                               
+
         if (fullscreen)
         {
             grFogMode (GR_FOG_DISABLE);
-            
+
             grClipWindow (0, 0, settings.res_x, settings.res_y);
-            
+
             grCullMode (GR_CULL_DISABLE);
-            
+
             if (rdp.cycle_mode == 2)
             {
                 grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER,
                 }
                 else
                     grAlphaTestFunction (GR_CMP_ALWAYS);
-                
+
                 rdp.update |= UPDATE_ALPHA_COMPARE | UPDATE_COMBINE;
             }
-            
+
             ConvertCoordsConvert (vptr, n_vertices);
-            
+
             if (settings.wireframe)
             {
                 SetWireframeCol ();
             {
                 grDrawVertexArrayContiguous (GR_TRIANGLE_STRIP, n_vertices, vptr, sizeof(VERTEX));