psx_gpu: add a tool to generate asm offsets
[pcsx_rearmed.git] / libpcsxcore / cheat.h
CommitLineData
ef79bbde
P
1/* Cheat Support for PCSX-Reloaded
2 * Copyright (C) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
17 */
18
19#ifndef CHEAT_H
20#define CHEAT_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26typedef struct {
27 uint32_t Addr;
28 uint16_t Val;
2c843d96 29 uint16_t OldVal;
ef79bbde
P
30} CheatCode;
31
32typedef struct {
33 char *Descr;
34 int First; // index of the first cheat code
35 int n; // number of cheat codes for this cheat
36 int Enabled;
2c843d96 37 int WasEnabled;
ef79bbde
P
38} Cheat;
39
40void ClearAllCheats();
41
42void LoadCheats(const char *filename);
43void SaveCheats(const char *filename);
44
45void ApplyCheats();
46
47int AddCheat(const char *descr, char *code);
48void RemoveCheat(int index);
49int EditCheat(int index, const char *descr, char *code);
50
51void FreeCheatSearchResults();
52void FreeCheatSearchMem();
53void CheatSearchBackupMemory();
54
55void CheatSearchEqual8(u8 val);
56void CheatSearchEqual16(u16 val);
57void CheatSearchEqual32(u32 val);
58void CheatSearchNotEqual8(u8 val);
59void CheatSearchNotEqual16(u16 val);
60void CheatSearchNotEqual32(u32 val);
61void CheatSearchRange8(u8 min, u8 max);
62void CheatSearchRange16(u16 min, u16 max);
63void CheatSearchRange32(u32 min, u32 max);
64void CheatSearchIncreasedBy8(u8 val);
65void CheatSearchIncreasedBy16(u16 val);
66void CheatSearchIncreasedBy32(u32 val);
67void CheatSearchDecreasedBy8(u8 val);
68void CheatSearchDecreasedBy16(u16 val);
69void CheatSearchDecreasedBy32(u32 val);
70void CheatSearchIncreased8();
71void CheatSearchIncreased16();
72void CheatSearchIncreased32();
73void CheatSearchDecreased8();
74void CheatSearchDecreased16();
75void CheatSearchDecreased32();
76void CheatSearchDifferent8();
77void CheatSearchDifferent16();
78void CheatSearchDifferent32();
79void CheatSearchNoChange8();
80void CheatSearchNoChange16();
81void CheatSearchNoChange32();
82
83extern Cheat *Cheats;
84extern CheatCode *CheatCodes;
85extern int NumCheats;
86extern int NumCodes;
87
88extern s8 *prevM;
89extern u32 *SearchResults;
90extern int NumSearchResults;
91
9c27c205 92extern int NumCheatsAllocated;
93extern int NumCodesAllocated;
94
ef79bbde
P
95#define PREVM(mem) (&prevM[mem])
96#define PrevMu8(mem) (*(u8 *)PREVM(mem))
97#define PrevMu16(mem) (SWAP16(*(u16 *)PREVM(mem)))
98#define PrevMu32(mem) (SWAP32(*(u32 *)PREVM(mem)))
99
100// cheat types
101#define CHEAT_CONST8 0x30 /* 8-bit Constant Write */
102#define CHEAT_CONST16 0x80 /* 16-bit Constant Write */
103#define CHEAT_INC16 0x10 /* 16-bit Increment */
104#define CHEAT_DEC16 0x11 /* 16-bit Decrement */
105#define CHEAT_INC8 0x20 /* 8-bit Increment */
106#define CHEAT_DEC8 0x21 /* 8-bit Decrement */
107#define CHEAT_SLIDE 0x50 /* Slide Codes */
108#define CHEAT_MEMCPY 0xC2 /* Memory Copy */
109
110#define CHEAT_EQU8 0xE0 /* 8-bit Equal To */
111#define CHEAT_NOTEQU8 0xE1 /* 8-bit Not Equal To */
112#define CHEAT_LESSTHAN8 0xE2 /* 8-bit Less Than */
113#define CHEAT_GREATERTHAN8 0xE3 /* 8-bit Greater Than */
114#define CHEAT_EQU16 0xD0 /* 16-bit Equal To */
115#define CHEAT_NOTEQU16 0xD1 /* 16-bit Not Equal To */
116#define CHEAT_LESSTHAN16 0xD2 /* 16-bit Less Than */
117#define CHEAT_GREATERTHAN16 0xD3 /* 16-bit Greater Than */
118
119#ifdef __cplusplus
120}
121#endif
122#endif