psxmem: set fixed flag on mappings that really need it
[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;
29} CheatCode;
30
31typedef struct {
32 char *Descr;
33 int First; // index of the first cheat code
34 int n; // number of cheat codes for this cheat
35 int Enabled;
36} Cheat;
37
38void ClearAllCheats();
39
40void LoadCheats(const char *filename);
41void SaveCheats(const char *filename);
42
43void ApplyCheats();
44
45int AddCheat(const char *descr, char *code);
46void RemoveCheat(int index);
47int EditCheat(int index, const char *descr, char *code);
48
49void FreeCheatSearchResults();
50void FreeCheatSearchMem();
51void CheatSearchBackupMemory();
52
53void CheatSearchEqual8(u8 val);
54void CheatSearchEqual16(u16 val);
55void CheatSearchEqual32(u32 val);
56void CheatSearchNotEqual8(u8 val);
57void CheatSearchNotEqual16(u16 val);
58void CheatSearchNotEqual32(u32 val);
59void CheatSearchRange8(u8 min, u8 max);
60void CheatSearchRange16(u16 min, u16 max);
61void CheatSearchRange32(u32 min, u32 max);
62void CheatSearchIncreasedBy8(u8 val);
63void CheatSearchIncreasedBy16(u16 val);
64void CheatSearchIncreasedBy32(u32 val);
65void CheatSearchDecreasedBy8(u8 val);
66void CheatSearchDecreasedBy16(u16 val);
67void CheatSearchDecreasedBy32(u32 val);
68void CheatSearchIncreased8();
69void CheatSearchIncreased16();
70void CheatSearchIncreased32();
71void CheatSearchDecreased8();
72void CheatSearchDecreased16();
73void CheatSearchDecreased32();
74void CheatSearchDifferent8();
75void CheatSearchDifferent16();
76void CheatSearchDifferent32();
77void CheatSearchNoChange8();
78void CheatSearchNoChange16();
79void CheatSearchNoChange32();
80
81extern Cheat *Cheats;
82extern CheatCode *CheatCodes;
83extern int NumCheats;
84extern int NumCodes;
85
86extern s8 *prevM;
87extern u32 *SearchResults;
88extern int NumSearchResults;
89
90#define PREVM(mem) (&prevM[mem])
91#define PrevMu8(mem) (*(u8 *)PREVM(mem))
92#define PrevMu16(mem) (SWAP16(*(u16 *)PREVM(mem)))
93#define PrevMu32(mem) (SWAP32(*(u32 *)PREVM(mem)))
94
95// cheat types
96#define CHEAT_CONST8 0x30 /* 8-bit Constant Write */
97#define CHEAT_CONST16 0x80 /* 16-bit Constant Write */
98#define CHEAT_INC16 0x10 /* 16-bit Increment */
99#define CHEAT_DEC16 0x11 /* 16-bit Decrement */
100#define CHEAT_INC8 0x20 /* 8-bit Increment */
101#define CHEAT_DEC8 0x21 /* 8-bit Decrement */
102#define CHEAT_SLIDE 0x50 /* Slide Codes */
103#define CHEAT_MEMCPY 0xC2 /* Memory Copy */
104
105#define CHEAT_EQU8 0xE0 /* 8-bit Equal To */
106#define CHEAT_NOTEQU8 0xE1 /* 8-bit Not Equal To */
107#define CHEAT_LESSTHAN8 0xE2 /* 8-bit Less Than */
108#define CHEAT_GREATERTHAN8 0xE3 /* 8-bit Greater Than */
109#define CHEAT_EQU16 0xD0 /* 16-bit Equal To */
110#define CHEAT_NOTEQU16 0xD1 /* 16-bit Not Equal To */
111#define CHEAT_LESSTHAN16 0xD2 /* 16-bit Less Than */
112#define CHEAT_GREATERTHAN16 0xD3 /* 16-bit Greater Than */
113
114#ifdef __cplusplus
115}
116#endif
117#endif