CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/CwCheat.h
Views: 1401
// Rough and ready CwCheats implementation, disabled by default.12#pragma once34#include <string>5#include <vector>6#include <iostream>7#include <sstream>89#include "Common/File/Path.h"10#include "Core/MemMap.h"1112class PointerWrap;1314void __CheatInit();15void __CheatShutdown();16void __CheatDoState(PointerWrap &p);1718// Return whether cheats are enabled and in effect.19bool CheatsInEffect();2021struct CheatLine {22uint32_t part1;23uint32_t part2;24};2526enum class CheatCodeFormat {27UNDEFINED,28CWCHEAT,29TEMPAR,30};3132struct CheatCode {33CheatCodeFormat fmt;34std::vector<CheatLine> lines;35};3637struct CheatFileInfo {38int lineNum;39std::string name;40bool enabled;41};4243struct CheatOperation;4445class CWCheatEngine {46public:47CWCheatEngine(const std::string &gameID);48std::vector<CheatFileInfo> FileInfo();49void ParseCheats();50void CreateCheatFile();51Path CheatFilename();52void Run();53bool HasCheats();54void InvalidateICache(u32 addr, int size);55private:56u32 GetAddress(u32 value);5758CheatOperation InterpretNextOp(const CheatCode &cheat, size_t &i);59CheatOperation InterpretNextCwCheat(const CheatCode &cheat, size_t &i);60CheatOperation InterpretNextTempAR(const CheatCode &cheat, size_t &i);6162void ExecuteOp(const CheatOperation &op, const CheatCode &cheat, size_t &i);63void ApplyMemoryOperator(const CheatOperation &op, uint32_t(*oper)(uint32_t, uint32_t));64bool TestIf(const CheatOperation &op, bool(*oper)(int a, int b));65bool TestIfAddr(const CheatOperation &op, bool(*oper)(int a, int b));6667std::vector<CheatCode> cheats_;68std::string gameID_;69Path filename_;70};717273