2013-05-23 13:10:39 +02:00
|
|
|
// Rough and ready CwCheats implementation, disabled by default.
|
|
|
|
// Will not enable by default until the TOOD:s have been addressed.
|
2013-05-16 15:42:25 -05:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
2013-05-23 13:10:39 +02:00
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "Core/MemMap.h"
|
2013-05-16 15:42:25 -05:00
|
|
|
|
2013-10-07 07:46:18 -07:00
|
|
|
class PointerWrap;
|
|
|
|
|
2013-05-17 23:49:44 -05:00
|
|
|
void __CheatInit();
|
|
|
|
void __CheatShutdown();
|
2013-10-07 07:46:18 -07:00
|
|
|
void __CheatDoState(PointerWrap &p);
|
|
|
|
|
2014-02-15 15:28:13 -08:00
|
|
|
// Return whether cheats are enabled and in effect.
|
|
|
|
bool CheatsInEffect();
|
2013-05-16 15:42:25 -05:00
|
|
|
|
2017-11-07 19:51:32 -08:00
|
|
|
struct CheatLine {
|
|
|
|
uint32_t part1;
|
|
|
|
uint32_t part2;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class CheatCodeFormat {
|
|
|
|
UNDEFINED,
|
|
|
|
CWCHEAT,
|
|
|
|
TEMPAR,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CheatCode {
|
|
|
|
CheatCodeFormat fmt;
|
|
|
|
std::vector<CheatLine> lines;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CheatOperation;
|
|
|
|
|
2013-05-18 17:04:01 -05:00
|
|
|
class CWCheatEngine {
|
2013-05-16 15:42:25 -05:00
|
|
|
public:
|
2013-05-18 17:04:01 -05:00
|
|
|
CWCheatEngine();
|
2016-06-21 06:29:26 +02:00
|
|
|
std::vector<std::string> GetCodesList();
|
2017-11-07 19:51:32 -08:00
|
|
|
void ParseCheats();
|
2016-06-20 00:18:35 +02:00
|
|
|
void CreateCheatFile();
|
2013-05-17 23:49:44 -05:00
|
|
|
void Run();
|
2014-02-15 15:28:13 -08:00
|
|
|
bool HasCheats();
|
2013-05-16 15:42:25 -05:00
|
|
|
|
2013-05-23 13:10:39 +02:00
|
|
|
private:
|
2015-02-02 23:26:25 +01:00
|
|
|
void InvalidateICache(u32 addr, int size);
|
2017-11-07 19:51:32 -08:00
|
|
|
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_;
|
2013-05-23 13:10:39 +02:00
|
|
|
};
|