diff --git a/Source/Project64-video/FBtoScreen.cpp b/Source/Project64-video/FBtoScreen.cpp index e6f80cd4a..16feb4820 100644 --- a/Source/Project64-video/FBtoScreen.cpp +++ b/Source/Project64-video/FBtoScreen.cpp @@ -65,7 +65,7 @@ static gfxChipID_t SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaqu FXFALSE); if (opaque) { - gfxAlphaTestFunction(GR_CMP_ALWAYS); + gfxAlphaTestFunction(GFX_CMP_ALWAYS); gfxAlphaBlendFunction(GFX_BLEND_ONE, GFX_BLEND_ZERO, GFX_BLEND_ONE, @@ -78,7 +78,7 @@ static gfxChipID_t SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaqu GFX_BLEND_ONE, GFX_BLEND_ZERO); } - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxCullMode(GR_CULL_DISABLE); gfxDepthMask(FXFALSE); rdp.update |= UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; @@ -481,7 +481,7 @@ static void DrawHiresDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) GFX_BLEND_ONE_MINUS_SRC_ALPHA, GFX_BLEND_ONE, GFX_BLEND_ZERO); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxDepthMask(FXFALSE); gfxCullMode(GR_CULL_DISABLE); gfxTexCombine(GFX_TMU1, diff --git a/Source/Project64-video/Main.cpp b/Source/Project64-video/Main.cpp index db1c36744..11cbbdf49 100644 --- a/Source/Project64-video/Main.cpp +++ b/Source/Project64-video/Main.cpp @@ -530,7 +530,7 @@ int InitGfx() } gfxDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); - gfxDepthBufferFunction(GR_CMP_LESS); + gfxDepthBufferFunction(GFX_CMP_LESS); gfxDepthMask(FXTRUE); ChangeSize(); @@ -540,7 +540,7 @@ int InitGfx() gfxCullMode(GR_CULL_DISABLE); gfxDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxRenderBuffer(GFX_BUFFER_BACKBUFFER); gfxColorMask(FXTRUE, FXTRUE); gfxDepthMask(FXTRUE); @@ -1308,7 +1308,7 @@ void newSwapBuffers() rdp.update |= UPDATE_SCISSOR | UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; gfxClipWindow(0, 0, g_scr_res_x, g_scr_res_y); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxDepthMask(FXFALSE); gfxCullMode(GR_CULL_DISABLE); diff --git a/Source/Project64-video/Renderer/OGLEScombiner.cpp b/Source/Project64-video/Renderer/OGLEScombiner.cpp index f005460c8..755050bbd 100644 --- a/Source/Project64-video/Renderer/OGLEScombiner.cpp +++ b/Source/Project64-video/Renderer/OGLEScombiner.cpp @@ -1539,19 +1539,19 @@ void gfxAlphaTestReferenceValue(gfxAlpha_t value) gfxAlphaTestFunction(g_alpha_func); } -void gfxAlphaTestFunction(GrCmpFnc_t function) +void gfxAlphaTestFunction(gfxCmpFnc_t function) { WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); g_alpha_func = function; switch (function) { - case GR_CMP_GREATER: + case GFX_CMP_GREATER: //glAlphaFunc(GL_GREATER, g_alpha_ref/255.0f); break; - case GR_CMP_GEQUAL: + case GFX_CMP_GEQUAL: //glAlphaFunc(GL_GEQUAL, g_alpha_ref/255.0f); break; - case GR_CMP_ALWAYS: + case GFX_CMP_ALWAYS: //glAlphaFunc(GL_ALWAYS, g_alpha_ref/255.0f); //glDisable(GL_ALPHA_TEST); g_alpha_test = false; diff --git a/Source/Project64-video/Renderer/OGLESgeometry.cpp b/Source/Project64-video/Renderer/OGLESgeometry.cpp index 3fd790bd9..62743e90b 100644 --- a/Source/Project64-video/Renderer/OGLESgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLESgeometry.cpp @@ -240,45 +240,45 @@ void gfxDepthBufferMode(GrDepthBufferMode_t mode) } } -void gfxDepthBufferFunction(GrCmpFnc_t function) +void gfxDepthBufferFunction(gfxCmpFnc_t function) { WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); switch (function) { - case GR_CMP_GEQUAL: + case GFX_CMP_GEQUAL: if (w_buffer_mode) glDepthFunc(GL_LEQUAL); else glDepthFunc(GL_GEQUAL); break; - case GR_CMP_LEQUAL: + case GFX_CMP_LEQUAL: if (w_buffer_mode) glDepthFunc(GL_GEQUAL); else glDepthFunc(GL_LEQUAL); break; - case GR_CMP_LESS: + case GFX_CMP_LESS: if (w_buffer_mode) glDepthFunc(GL_GREATER); else glDepthFunc(GL_LESS); break; - case GR_CMP_ALWAYS: + case GFX_CMP_ALWAYS: glDepthFunc(GL_ALWAYS); break; - case GR_CMP_EQUAL: + case GFX_CMP_EQUAL: glDepthFunc(GL_EQUAL); break; - case GR_CMP_GREATER: + case GFX_CMP_GREATER: if (w_buffer_mode) glDepthFunc(GL_LESS); else glDepthFunc(GL_GREATER); break; - case GR_CMP_NEVER: + case GFX_CMP_NEVER: glDepthFunc(GL_NEVER); break; - case GR_CMP_NOTEQUAL: + case GFX_CMP_NOTEQUAL: glDepthFunc(GL_NOTEQUAL); break; diff --git a/Source/Project64-video/Renderer/OGLcombiner.cpp b/Source/Project64-video/Renderer/OGLcombiner.cpp index 6a2bbe404..29c93fb36 100644 --- a/Source/Project64-video/Renderer/OGLcombiner.cpp +++ b/Source/Project64-video/Renderer/OGLcombiner.cpp @@ -28,7 +28,8 @@ static int fct[4], source0[4], operand0[4], source1[4], operand1[4], source2[4], operand2[4]; static int fcta[4], sourcea0[4], operanda0[4], sourcea1[4], operanda1[4], sourcea2[4], operanda2[4]; -static int alpha_ref, alpha_func; +static int alpha_ref; +static gfxCmpFnc_t alpha_func; float texture_env_color[4]; float ccolor0[4]; @@ -1481,22 +1482,22 @@ void gfxAlphaTestReferenceValue(gfxAlpha_t value) gfxAlphaTestFunction(alpha_func); } -void gfxAlphaTestFunction(GrCmpFnc_t function) +void gfxAlphaTestFunction(gfxCmpFnc_t function) { WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); alpha_func = function; switch (function) { - case GR_CMP_GREATER: + case GFX_CMP_GREATER: glAlphaFunc(GL_GREATER, alpha_ref / 255.0f); break; - case GR_CMP_GEQUAL: + case GFX_CMP_GEQUAL: glAlphaFunc(GL_GEQUAL, alpha_ref / 255.0f); break; - case GR_CMP_ALWAYS: + case GFX_CMP_ALWAYS: glAlphaFunc(GL_ALWAYS, alpha_ref / 255.0f); glDisable(GL_ALPHA_TEST); - grDisplayGLError("gfxAlphaTestFunction :: GR_CMP_ALWAYS"); + grDisplayGLError("gfxAlphaTestFunction :: GFX_CMP_ALWAYS"); return; break; default: diff --git a/Source/Project64-video/Renderer/OGLgeometry.cpp b/Source/Project64-video/Renderer/OGLgeometry.cpp index 1bd2640a3..3cca6f2b8 100644 --- a/Source/Project64-video/Renderer/OGLgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLgeometry.cpp @@ -171,45 +171,45 @@ void gfxDepthBufferMode(GrDepthBufferMode_t mode) grDisplayGLError("gfxDepthBufferMode"); } -void gfxDepthBufferFunction(GrCmpFnc_t function) +void gfxDepthBufferFunction(gfxCmpFnc_t function) { WriteTrace(TraceGlitch, TraceDebug, "function: %d", function); switch (function) { - case GR_CMP_GEQUAL: + case GFX_CMP_GEQUAL: if (w_buffer_mode) glDepthFunc(GL_LEQUAL); else glDepthFunc(GL_GEQUAL); break; - case GR_CMP_LEQUAL: + case GFX_CMP_LEQUAL: if (w_buffer_mode) glDepthFunc(GL_GEQUAL); else glDepthFunc(GL_LEQUAL); break; - case GR_CMP_LESS: + case GFX_CMP_LESS: if (w_buffer_mode) glDepthFunc(GL_GREATER); else glDepthFunc(GL_LESS); break; - case GR_CMP_ALWAYS: + case GFX_CMP_ALWAYS: glDepthFunc(GL_ALWAYS); break; - case GR_CMP_EQUAL: + case GFX_CMP_EQUAL: glDepthFunc(GL_EQUAL); break; - case GR_CMP_GREATER: + case GFX_CMP_GREATER: if (w_buffer_mode) glDepthFunc(GL_LESS); else glDepthFunc(GL_GREATER); break; - case GR_CMP_NEVER: + case GFX_CMP_NEVER: glDepthFunc(GL_NEVER); break; - case GR_CMP_NOTEQUAL: + case GFX_CMP_NOTEQUAL: glDepthFunc(GL_NOTEQUAL); break; diff --git a/Source/Project64-video/Renderer/Renderer.h b/Source/Project64-video/Renderer/Renderer.h index e6a3a065c..5c895ee7f 100644 --- a/Source/Project64-video/Renderer/Renderer.h +++ b/Source/Project64-video/Renderer/Renderer.h @@ -28,7 +28,7 @@ void gfxAlphaCombine(gfxCombineFunction_t function, gfxCombineFactor_t factor, g void gfxTexCombine(gfxChipID_t tmu, gfxCombineFunction_t rgb_function, gfxCombineFactor_t rgb_factor, gfxCombineFunction_t alpha_function, gfxCombineFactor_t alpha_factor, bool rgb_invert, bool alpha_invert); void gfxAlphaBlendFunction(gfxAlphaBlendFnc_t rgb_sf, gfxAlphaBlendFnc_t rgb_df, gfxAlphaBlendFnc_t alpha_sf, gfxAlphaBlendFnc_t alpha_df); void gfxAlphaTestReferenceValue(gfxAlpha_t value); -void gfxAlphaTestFunction(GrCmpFnc_t function); +void gfxAlphaTestFunction(gfxCmpFnc_t function); void gfxFogMode(GrFogMode_t mode); void gfxFogGenerateLinear(float nearZ, float farZ); void gfxFogColorValue(gfxColor_t fogcolor); @@ -43,7 +43,7 @@ void gfxConstantColorValueExt(gfxChipID_t tmu, gfxColor_t value); void gfxVertexLayout(uint32_t param, FxI32 offset, uint32_t mode); void gfxCullMode(GrCullMode_t mode); void gfxDepthBufferMode(GrDepthBufferMode_t mode); -void gfxDepthBufferFunction(GrCmpFnc_t function); +void gfxDepthBufferFunction(gfxCmpFnc_t function); void gfxDepthMask(bool mask); void gfxDrawTriangle(const void *a, const void *b, const void *c); void gfxDepthBiasLevel(FxI32 level); diff --git a/Source/Project64-video/Renderer/types.h b/Source/Project64-video/Renderer/types.h index 9aabc9ded..6d6492270 100644 --- a/Source/Project64-video/Renderer/types.h +++ b/Source/Project64-video/Renderer/types.h @@ -185,6 +185,18 @@ enum gfxAlphaBlendFnc_t GFX_BLEND_PREFOG_COLOR = GFX_BLEND_ALPHA_SATURATE, }; +enum gfxCmpFnc_t +{ + GFX_CMP_NEVER = 0x0, + GFX_CMP_LESS = 0x1, + GFX_CMP_EQUAL = 0x2, + GFX_CMP_LEQUAL = 0x3, + GFX_CMP_GREATER = 0x4, + GFX_CMP_NOTEQUAL = 0x5, + GFX_CMP_GEQUAL = 0x6, + GFX_CMP_ALWAYS = 0x7, +}; + enum GFX_CMBX { GFX_CMBX_ZERO = 0x00, diff --git a/Source/Project64-video/Settings.cpp b/Source/Project64-video/Settings.cpp index f1eb20a62..23a5519e1 100644 --- a/Source/Project64-video/Settings.cpp +++ b/Source/Project64-video/Settings.cpp @@ -80,7 +80,7 @@ CSettings::CSettings() : m_force_calc_sphere(false), //use spheric mapping only, Ridge Racer 64 m_pal230(false), //set special scale for PAL games m_correct_viewport(false), //correct viewport values - m_zmode_compare_less(false), //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) + m_zmode_compare_less(false), //force GFX_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) m_old_style_adither(false), //apply alpha dither regardless of alpha_dither_mode m_n64_z_scale(false), //scale vertex z value before writing to depth buffer, as N64 does. diff --git a/Source/Project64-video/Settings.h b/Source/Project64-video/Settings.h index bf9abe195..7daa78eb7 100644 --- a/Source/Project64-video/Settings.h +++ b/Source/Project64-video/Settings.h @@ -260,7 +260,7 @@ public: inline bool force_calc_sphere(void) const { return m_force_calc_sphere; } //use spheric mapping only, Ridge Racer 64 inline bool pal230(void) const { return m_pal230; } //use spheric mapping only, Ridge Racer 64 inline bool correct_viewport(void) const { return m_correct_viewport; } //correct viewport values - inline bool zmode_compare_less(void) const { return m_zmode_compare_less; } //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) + inline bool zmode_compare_less(void) const { return m_zmode_compare_less; } //force GFX_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) inline bool old_style_adither(void) const { return m_old_style_adither; } //apply alpha dither regardless of alpha_dither_mode inline bool n64_z_scale(void) const { return m_n64_z_scale; } //scale vertex z value before writing to depth buffer, as N64 does. diff --git a/Source/Project64-video/TexBuffer.cpp b/Source/Project64-video/TexBuffer.cpp index 040ecf163..709b87cf3 100644 --- a/Source/Project64-video/TexBuffer.cpp +++ b/Source/Project64-video/TexBuffer.cpp @@ -340,7 +340,7 @@ static gfxTextureFormat_t TexBufSetupCombiner(int force_rgb = FALSE) GFX_BLEND_ONE, GFX_BLEND_ZERO); gfxClipWindow(0, 0, g_scr_res_x, g_scr_res_y); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxDepthMask(FXFALSE); gfxCullMode(GR_CULL_DISABLE); gfxFogMode(GR_FOG_DISABLE); diff --git a/Source/Project64-video/Util.cpp b/Source/Project64-video/Util.cpp index d1f7df71e..8e7f35591 100644 --- a/Source/Project64-video/Util.cpp +++ b/Source/Project64-video/Util.cpp @@ -1752,27 +1752,27 @@ void update() switch ((rdp.rm & 0xC00) >> 10) { case 0: gfxDepthBiasLevel(0); - gfxDepthBufferFunction(g_settings->zmode_compare_less() ? GR_CMP_LESS : GR_CMP_LEQUAL); + gfxDepthBufferFunction(g_settings->zmode_compare_less() ? GFX_CMP_LESS : GFX_CMP_LEQUAL); break; case 1: gfxDepthBiasLevel(-4); - gfxDepthBufferFunction(g_settings->zmode_compare_less() ? GR_CMP_LESS : GR_CMP_LEQUAL); + gfxDepthBufferFunction(g_settings->zmode_compare_less() ? GFX_CMP_LESS : GFX_CMP_LEQUAL); break; case 2: gfxDepthBiasLevel(g_settings->ucode() == CSettings::ucode_PerfectDark ? -4 : 0); - gfxDepthBufferFunction(GR_CMP_LESS); + gfxDepthBufferFunction(GFX_CMP_LESS); break; case 3: // will be set dynamically per polygon //gfxDepthBiasLevel(-deltaZ); - gfxDepthBufferFunction(GR_CMP_LEQUAL); + gfxDepthBufferFunction(GFX_CMP_LEQUAL); break; } } else { gfxDepthBiasLevel(0); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); } if (rdp.flags & ZBUF_UPDATE) @@ -1783,7 +1783,7 @@ void update() else { gfxDepthBiasLevel(0); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxDepthMask(FXFALSE); } } @@ -1799,7 +1799,7 @@ void update() if (rdp.acmp == 1 && !(rdp.othermode_l & 0x00002000) && (!(rdp.othermode_l & 0x00004000) || (rdp.blend_color & 0xFF))) { uint8_t reference = (uint8_t)(rdp.blend_color & 0xFF); - gfxAlphaTestFunction(reference ? GR_CMP_GEQUAL : GR_CMP_GREATER); + gfxAlphaTestFunction(reference ? GFX_CMP_GEQUAL : GFX_CMP_GREATER); gfxAlphaTestReferenceValue(reference); WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: blend: %02lx", reference); } @@ -1809,13 +1809,13 @@ void update() { if ((rdp.othermode_l & 0x5000) != 0x5000) { - gfxAlphaTestFunction(GR_CMP_GEQUAL); + gfxAlphaTestFunction(GFX_CMP_GEQUAL); gfxAlphaTestReferenceValue(0x20);//0xA0); WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: 0x20"); } else { - gfxAlphaTestFunction(GR_CMP_GREATER); + gfxAlphaTestFunction(GFX_CMP_GREATER); if (rdp.acmp == 3) { gfxAlphaTestReferenceValue((uint8_t)(rdp.blend_color & 0xFF)); @@ -1830,7 +1830,7 @@ void update() } else { - gfxAlphaTestFunction(GR_CMP_ALWAYS); + gfxAlphaTestFunction(GFX_CMP_ALWAYS); WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: none"); } } @@ -1966,7 +1966,7 @@ void set_message_combiner() GFX_BLEND_ZERO, GFX_BLEND_ZERO, GFX_BLEND_ZERO); - gfxAlphaTestFunction(GR_CMP_ALWAYS); + gfxAlphaTestFunction(GFX_CMP_ALWAYS); gfxStippleMode(GR_STIPPLE_DISABLE); gfxTexFilterMode(GFX_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); gfxTexCombine(GFX_TMU1, diff --git a/Source/Project64-video/rdp.cpp b/Source/Project64-video/rdp.cpp index 784744b3a..100131003 100644 --- a/Source/Project64-video/rdp.cpp +++ b/Source/Project64-video/rdp.cpp @@ -2516,12 +2516,12 @@ void rdp_fillrect() gfxAlphaBlendFunction(GFX_BLEND_ONE, GFX_BLEND_ZERO, GFX_BLEND_ONE, GFX_BLEND_ZERO); - gfxAlphaTestFunction(GR_CMP_ALWAYS); + gfxAlphaTestFunction(GFX_CMP_ALWAYS); gfxStippleMode(GR_STIPPLE_DISABLE); gfxCullMode(GR_CULL_DISABLE); gfxFogMode(GR_FOG_DISABLE); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxDepthMask(FXFALSE); rdp.update |= UPDATE_COMBINE | UPDATE_CULL_MODE | UPDATE_FOG_ENABLED | UPDATE_ZBUF_ENABLED; @@ -3176,7 +3176,7 @@ void SetWireframeCol() break; } - gfxAlphaTestFunction(GR_CMP_ALWAYS); + gfxAlphaTestFunction(GFX_CMP_ALWAYS); gfxCullMode(GR_CULL_DISABLE); rdp.update |= UPDATE_COMBINE | UPDATE_ALPHA_COMPARE; diff --git a/Source/Project64-video/ucode06.cpp b/Source/Project64-video/ucode06.cpp index 23dd2ee78..82bda5423 100644 --- a/Source/Project64-video/ucode06.cpp +++ b/Source/Project64-video/ucode06.cpp @@ -88,11 +88,11 @@ float set_sprite_combine_mode() GFX_BLEND_ZERO); if (rdp.othermode_l & 1) { - gfxAlphaTestFunction(GR_CMP_GEQUAL); + gfxAlphaTestFunction(GFX_CMP_GEQUAL); gfxAlphaTestReferenceValue(0x80); } else - gfxAlphaTestFunction(GR_CMP_ALWAYS); + gfxAlphaTestFunction(GFX_CMP_ALWAYS); rdp.update |= UPDATE_ALPHA_COMPARE | UPDATE_COMBINE; } return Z; @@ -172,7 +172,7 @@ void DrawHiresDepthImage(const DRAWIMAGE & d) GFX_BLEND_ZERO, GFX_BLEND_ONE, GFX_BLEND_ZERO); - gfxDepthBufferFunction(GR_CMP_ALWAYS); + gfxDepthBufferFunction(GFX_CMP_ALWAYS); gfxDepthMask(FXFALSE); gfxLOD_t LOD = g_scr_res_x > 1024 ? GFX_LOD_LOG2_2048 : GFX_LOD_LOG2_1024;