CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/CwCheat.h
Views: 1401
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::vector<CheatLine> lines;
36
};
37
38
struct CheatFileInfo {
39
int lineNum;
40
std::string name;
41
bool enabled;
42
};
43
44
struct CheatOperation;
45
46
class CWCheatEngine {
47
public:
48
CWCheatEngine(const std::string &gameID);
49
std::vector<CheatFileInfo> FileInfo();
50
void ParseCheats();
51
void CreateCheatFile();
52
Path CheatFilename();
53
void Run();
54
bool HasCheats();
55
void InvalidateICache(u32 addr, int size);
56
private:
57
u32 GetAddress(u32 value);
58
59
CheatOperation InterpretNextOp(const CheatCode &cheat, size_t &i);
60
CheatOperation InterpretNextCwCheat(const CheatCode &cheat, size_t &i);
61
CheatOperation InterpretNextTempAR(const CheatCode &cheat, size_t &i);
62
63
void ExecuteOp(const CheatOperation &op, const CheatCode &cheat, size_t &i);
64
void ApplyMemoryOperator(const CheatOperation &op, uint32_t(*oper)(uint32_t, uint32_t));
65
bool TestIf(const CheatOperation &op, bool(*oper)(int a, int b));
66
bool TestIfAddr(const CheatOperation &op, bool(*oper)(int a, int b));
67
68
std::vector<CheatCode> cheats_;
69
std::string gameID_;
70
Path filename_;
71
};
72
73