For more complete decompile of Monster Hunter World shaders. diff --git a/BinaryDecompiler/decode.cpp b/BinaryDecompiler/decode.cpp index 89ac94f0..9356d27b 100644 --- a/BinaryDecompiler/decode.cpp +++ b/BinaryDecompiler/decode.cpp @@ -333,7 +333,7 @@ uint32_t DecodeOperand (const uint32_t *pui32Tokens, Operand* psOperand) } default: { - ASSERT(0); + //ASSERT(0); break; } } diff --git a/HLSLDecompiler/DecompileHLSL.cpp b/HLSLDecompiler/DecompileHLSL.cpp index 6175e733..24913e88 100644 --- a/HLSLDecompiler/DecompileHLSL.cpp +++ b/HLSLDecompiler/DecompileHLSL.cpp @@ -1493,7 +1493,7 @@ public: { int in[4] = { 0, 0, 0, 0 }; - numRead = sscanf_s(c + pos, "// = %i %i %i %i", in + 0, in + 1, in + 2, in + 3); + numRead = sscanf_s(c + pos, "// = %d %d %d %d", in + 0, in + 1, in + 2, in + 3); NextLine(c, pos, size); if (structLevel < 0) @@ -1510,10 +1510,37 @@ public: for (int i = 0; i < numRead - 1; ++i) { - sprintf(buffer, "%i,", in[i]); + sprintf(buffer, "%d,", in[i]); mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer)); } - sprintf(buffer, "%i};\n", in[numRead - 1]); + sprintf(buffer, "%d};\n", in[numRead - 1]); + mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer)); + } + else if (e.bt == DT_uint || e.bt == DT_uint2 || e.bt == DT_uint3 || e.bt == DT_uint4) + { + unsigned in[4] = { 0, 0, 0, 0 }; + + numRead = sscanf_s(c + pos, "// = %u %u %u %u", in + 0, in + 1, in + 2, in + 3); + NextLine(c, pos, size); + + if (structLevel < 0) + { + if (suboffset == 0) + sprintf(buffer, " %s%s %s : packoffset(c%u) = {", modifier.c_str(), type, name, packoffset); + else + sprintf(buffer, " %s%s %s : packoffset(c%u.%c) = {", modifier.c_str(), type, name, packoffset, INDEX_MASK[suboffset]); + } + else + sprintf(buffer, " %s%s%s %s = {", structSpacing.c_str(), modifier.c_str(), type, name); + + mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer)); + + for (int i = 0; i < numRead - 1; ++i) + { + sprintf(buffer, "%u,", in[i]); + mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer)); + } + sprintf(buffer, "%u};\n", in[numRead - 1]); mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer)); } else if (e.bt == DT_float || e.bt == DT_float2 || e.bt == DT_float3 || e.bt == DT_float4) @@ -2510,7 +2537,7 @@ public: else if (!strncmp(textype, "TextureCubeArray<", strlen("TextureCubeArray<"))) pos = 5; // float4 .xyzw else logDecompileError(" unknown texture type for truncation: " + string(textype)); cpos = strrchr(op, '.'); - cpos[pos] = 0; + if (cpos) cpos[pos] = 0; } }