From 4009a37692d9b9e5fa42b97ce4c9ed67da282a09 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 1 May 2013 00:55:30 -0700 Subject: [PATCH] Improve blending with two fixed colors. It's not right, but it's less bad. Maybe there's a better way? Improves Popolocrois and Lunar (battle) blending issues. --- GPU/GLES/StateMapping.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 5a0df2f9123b..c01da70082a5 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -178,8 +178,19 @@ void TransformDrawEngine::ApplyDrawState(int prim) { didReportBlend = true; DEBUG_LOG(HLE, "ERROR INVALID blendcolorstate: FixA=%06x FixB=%06x FuncA=%i FuncB=%i", gstate.getFixA(), gstate.getFixB(), gstate.getBlendFuncA(), gstate.getBlendFuncB()); - glBlendFuncA = GL_ONE; - glBlendFuncB = GL_ONE; + // Let's approximate, at least. + int blendSumA = (fixA & 0xFF) + ((fixA >> 8) & 0xFF) + ((fixA >> 16) & 0xFF); + int blendSumB = (fixB & 0xFF) + ((fixB >> 8) & 0xFF) + ((fixB >> 16) & 0xFF); + if (blendSumA < 64 * 3 && blendSumB > 192 * 3) { + glBlendFuncA = GL_ZERO; + glBlendFuncB = GL_ONE; + } else if (blendSumA > 192 * 3 && blendSumB < 64 * 3) { + glBlendFuncA = GL_ONE; + glBlendFuncB = GL_ZERO; + } else { + glBlendFuncA = GL_ONE; + glBlendFuncB = GL_ONE; + } } } // At this point, through all paths above, glBlendFuncA and glBlendFuncB will be set somehow.