Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/CwCheat.h
3185 views
1
// Rough and ready CwCheats implementation, disabled by default.
2
3
#pragma once
4
5
#include <string>
6
#include <vector>
7
#include <iostream>
8
#include <sstream>
9
10
#include "Common/File/Path.h"
11
#include "Core/MemMap.h"
12
13
class PointerWrap;
14
15
void __CheatInit();
16
void __CheatShutdown();
17
void __CheatDoState(PointerWrap &p);
18
19
// Return whether cheats are enabled and in effect.
20
bool CheatsInEffect();
21
22
struct CheatLine {
23
uint32_t part1;
24
uint32_t part2;
25
};
26
27
enum class CheatCodeFormat {
28
UNDEFINED,
29
CWCHEAT,
30
TEMPAR,
31
};
32
33
struct CheatCode {
34
CheatCodeFormat fmt;
35
std::string name;
36
std::vector<CheatLine> lines;
37
};
38
39
struct CheatFileInfo {
40
int lineNum;
41
std::string name;
42
bool enabled;
43
};
44
45
struct CheatOperation;
46
47
class CWCheatEngine {
48
public:
49
CWCheatEngine(const std::string &gameID);
50
std::vector<CheatFileInfo> FileInfo();
51
void ParseCheats();
52
void CreateCheatFile();
53
Path CheatFilename();
54
void Run();
55
bool HasCheats();
56
private:
57
void InvalidateICache(u32 addr, int size) const;
58
u32 GetAddress(u32 value);
59
60
CheatOperation InterpretNextOp(const CheatCode &cheat, size_t &i);
61
CheatOperation InterpretNextCwCheat(const CheatCode &cheat, size_t &i);
62
CheatOperation InterpretNextTempAR(const CheatCode &cheat, size_t &i);
63
64
void ExecuteOp(const CheatOperation &op, const CheatCode &cheat, size_t &i);
65
inline void ApplyMemoryOperator(const CheatOperation &op, uint32_t(*oper)(uint32_t, uint32_t));
66
inline bool TestIf(const CheatOperation &op, bool(*oper)(int a, int b)) const;
67
inline bool TestIfAddr(const CheatOperation &op, bool(*oper)(int a, int b)) const;
68
69
std::vector<CheatCode> cheats_;
70
std::string gameID_;
71
Path filename_;
72
};
73
74