diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 3fdfeee9a642..2a648960fdbb 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -422,6 +422,7 @@ enum class CheatOp { Vibration, VibrationFromMemory, PostShader, + PostShaderFromMemory, Delay, Assert, @@ -482,6 +483,7 @@ struct CheatOperation { uint32_t i; } value; uint8_t uniform; + uint8_t format; } PostShaderUniform; }; }; @@ -635,6 +637,14 @@ CheatOperation CWCheatEngine::InterpretNextCwCheat(const CheatCode &cheat, size_ op.PostShaderUniform.value.i = line1.part2; return op; } + case 0x3: // 0x3 sets postprocessing shader uniform from memory + { + addr = line1.part2; + CheatOperation op = { CheatOp::PostShaderFromMemory, addr }; + op.PostShaderUniform.uniform = line1.part1 & 0x000000FF; + op.PostShaderUniform.format = (line1.part1 >> 8) & 0x000000FF; + return op; + } // Place for other PPSSPP specific cheats default: return { CheatOp::Invalid }; @@ -939,6 +949,30 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat, g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", g_Config.sPostShaderName.c_str(), op.PostShaderUniform.uniform + 1)] = op.PostShaderUniform.value.f; break; + case CheatOp::PostShaderFromMemory: + if (Memory::IsValidAddress(op.addr) && op.PostShaderUniform.uniform >= 0 && op.PostShaderUniform.uniform < 4) { + union { + float f; + uint32_t u; + } value; + value.u = Memory::Read_U32(op.addr); + switch (op.PostShaderUniform.format) { + case (0): + g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", g_Config.sPostShaderName.c_str(), op.PostShaderUniform.uniform + 1)] = value.u & 0x000000FF; + break; + case (1): + g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", g_Config.sPostShaderName.c_str(), op.PostShaderUniform.uniform + 1)] = value.u & 0x0000FFFF; + break; + case (2): + g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", g_Config.sPostShaderName.c_str(), op.PostShaderUniform.uniform + 1)] = value.u; + break; + case (3): + g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", g_Config.sPostShaderName.c_str(), op.PostShaderUniform.uniform + 1)] = value.f; + break; + } + } + break; + case CheatOp::Delay: // TODO: Not supported. break;