From 428a8181e53dc9ff7da68ab715cca6194f59de27 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 00:38:52 -0700 Subject: [PATCH] Format stencil and alpha tests differently. One is the stored value on the right, the other is the vertex value on the left. --- GPU/GeDisasm.cpp | 4 ++-- Windows/GEDebugger/TabState.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/GPU/GeDisasm.cpp b/GPU/GeDisasm.cpp index ef582cebc8..4520a1676c 100644 --- a/GPU/GeDisasm.cpp +++ b/GPU/GeDisasm.cpp @@ -807,8 +807,8 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer) { case GE_CMD_ALPHATEST: { - const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", " == ", " != ", " < ", " <= ", " > ", " >= " }; - sprintf(buffer, "Alpha test settings: %06x (%02x%s(c & %02x))", data, (data >> 8) & 0xFF, alphaTestFuncs[data & 7], (data >> 16) & 0xFF); + const char *alphaTestFuncs[] = { " NEVER ", " ALWAYS ", " == ", " != ", " < ", " <= ", " > ", " >= " }; + sprintf(buffer, "Alpha test settings: %06x ((c & %02x)%s%02x)", data, (data >> 16) & 0xFF, (data >> 8) & 0xFF, alphaTestFuncs[data & 7]); } break; diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index baca3a3e39..6681874283 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -49,6 +49,7 @@ enum CmdFormatType { CMD_FMT_TEXFMT, CMD_FMT_COLORTEST, CMD_FMT_ALPHATEST, + CMD_FMT_STENCILTEST, CMD_FMT_ZTEST, CMD_FMT_OFFSETADDR, CMD_FMT_VADDR, @@ -208,7 +209,7 @@ static const TabStateRow stateSettingsRows[] = { { L"Cull mode", GE_CMD_CULL, CMD_FMT_NUM, GE_CMD_CULLFACEENABLE }, { L"Color test", GE_CMD_COLORTEST, CMD_FMT_COLORTEST, GE_CMD_COLORTESTENABLE, GE_CMD_COLORREF, GE_CMD_COLORTESTMASK }, { L"Alpha test", GE_CMD_ALPHATEST, CMD_FMT_ALPHATEST, GE_CMD_ALPHATESTENABLE }, - { L"Stencil test", GE_CMD_STENCILTEST, CMD_FMT_ALPHATEST, GE_CMD_STENCILTESTENABLE }, + { L"Stencil test", GE_CMD_STENCILTEST, CMD_FMT_STENCILTEST, GE_CMD_STENCILTESTENABLE }, { L"Stencil test op", GE_CMD_STENCILOP, CMD_FMT_STENCILOP, GE_CMD_STENCILTESTENABLE }, { L"Depth test", GE_CMD_ZTEST, CMD_FMT_ZTEST, GE_CMD_ZTESTENABLE }, { L"Alpha blend mode", GE_CMD_BLENDMODE, CMD_FMT_BLENDMODE, GE_CMD_ALPHABLENDENABLE }, @@ -368,13 +369,19 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab break; case CMD_FMT_ALPHATEST: + case CMD_FMT_STENCILTEST: { - static const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", " == ", " != ", " < ", " <= ", " > ", " >= " }; + static const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; const u8 mask = (value >> 16) & 0xff; const u8 ref = (value >> 8) & 0xff; const u8 func = (value >> 0) & 0xff; if (func < (u8)ARRAY_SIZE(alphaTestFuncs)) { - swprintf(dest, L"pass if (a & %02x) %S (%02x & %02x)", mask, alphaTestFuncs[func], ref, mask); + if (info.fmt == CMD_FMT_ALPHATEST) { + swprintf(dest, L"pass if (a & %02x) %S (%02x & %02x)", mask, alphaTestFuncs[func], ref, mask); + } else if (info.fmt == CMD_FMT_STENCILTEST) { + // Stencil test is the other way around. + swprintf(dest, L"pass if (%02x & %02x) %S (a & %02x)", ref, mask, alphaTestFuncs[func], mask); + } } else { swprintf(dest, L"%06x", value); } @@ -383,7 +390,7 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab case CMD_FMT_ZTEST: { - static const char *zTestFuncs[] = { "NEVER", "ALWAYS", " == ", " != ", " < ", " <= ", " > ", " >= " }; + static const char *zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; if (value < (u32)ARRAY_SIZE(zTestFuncs)) { swprintf(dest, L"pass if src %S dst", zTestFuncs[value]); } else {