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