diff --git a/include/PICA/regs.hpp b/include/PICA/regs.hpp index 968dae44..be807e0d 100644 --- a/include/PICA/regs.hpp +++ b/include/PICA/regs.hpp @@ -59,6 +59,7 @@ namespace PICAInternalRegs { VertexIntUniform2 = 0x2B3, VertexIntUniform3 = 0x2B4, + VertexShaderEntrypoint = 0x2BA, VertexShaderTransferEnd = 0x2BF, VertexFloatUniformIndex = 0x2C0, VertexFloatUniformData0 = 0x2C1, diff --git a/include/PICA/shader.hpp b/include/PICA/shader.hpp index 868b807d..df30d117 100644 --- a/include/PICA/shader.hpp +++ b/include/PICA/shader.hpp @@ -150,7 +150,8 @@ class PICAShader { public: std::array loadedShader; // Currently loaded & active shader std::array bufferedShader; // Shader to be transferred when the SH_CODETRANSFER_END reg gets written to - + + u32 entrypoint = 0; // Initial shader PC u32 boolUniform; std::array, 4> intUniforms; std::array floatUniforms; diff --git a/src/core/PICA/regs.cpp b/src/core/PICA/regs.cpp index 6a033541..7a2c15c4 100644 --- a/src/core/PICA/regs.cpp +++ b/src/core/PICA/regs.cpp @@ -113,6 +113,10 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) { shaderUnit.vs.uploadWord(value); break; + case VertexShaderEntrypoint: + shaderUnit.vs.entrypoint = value & 0xffff; + break; + case VertexShaderTransferEnd: if (value != 0) shaderUnit.vs.finalize(); break; diff --git a/src/core/PICA/shader_interpreter.cpp b/src/core/PICA/shader_interpreter.cpp index b23ef192..f8071a4a 100644 --- a/src/core/PICA/shader_interpreter.cpp +++ b/src/core/PICA/shader_interpreter.cpp @@ -2,7 +2,7 @@ #include void PICAShader::run() { - pc = 0; + pc = entrypoint; loopIndex = 0; ifIndex = 0; callIndex = 0; @@ -63,7 +63,7 @@ void PICAShader::run() { // Handle calls if (callIndex != 0) { auto& info = callInfo[callIndex - 1]; - if (pc == info.endingPC) { // Check if the IF block ended + if (pc == info.endingPC) { // Check if the CALL block ended pc = info.returnPC; callIndex -= 1; } @@ -121,7 +121,7 @@ bool PICAShader::isCondTrue(u32 instruction) { return cmpRegister[0] == refX && cmpRegister[1] == refY; case 2: // At least cmp.x matches return cmpRegister[0] == refX; - case 3: // At least cmp.y matches + default: // At least cmp.y matches return cmpRegister[1] == refY; } }