Skip to content

Commit

Permalink
Memory reading CWCheat
Browse files Browse the repository at this point in the history
  • Loading branch information
iota97 committed May 16, 2020
1 parent 7cd6c82 commit 1d05444
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Core/CwCheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ enum class CheatOp {
Vibration,
VibrationFromMemory,
PostShader,
PostShaderFromMemory,
Delay,

Assert,
Expand Down Expand Up @@ -482,6 +483,7 @@ struct CheatOperation {
uint32_t i;
} value;
uint8_t uniform;
uint8_t format;
} PostShaderUniform;
};
};
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1d05444

Please sign in to comment.