1 | /*****************************************************************************\ |
2 | Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. |
3 | This file is licensed under the Snes9x License. |
4 | For further information, consult the LICENSE file in the root directory. |
5 | \*****************************************************************************/ |
6 | |
7 | #ifndef _CHEATS_H_ |
8 | #define _CHEATS_H_ |
9 | |
10 | #include "port.h" |
11 | #include <vector> |
12 | |
13 | struct SCheat |
14 | { |
15 | uint32 address; |
16 | uint8 byte; |
17 | uint8 saved_byte; |
18 | bool8 conditional; |
19 | bool8 cond_true; |
20 | uint8 cond_byte; |
21 | bool8 enabled; |
22 | }; |
23 | |
24 | struct SCheatGroup |
25 | { |
26 | char *name; |
27 | bool8 enabled; |
28 | std::vector<struct SCheat> c; |
29 | }; |
30 | |
31 | struct SCheatData |
32 | { |
33 | std::vector<struct SCheatGroup> g; |
34 | bool8 enabled; |
35 | uint8 CWRAM[0x20000]; |
36 | uint8 CSRAM[0x10000]; |
37 | uint8 CIRAM[0x2000]; |
38 | uint8 *RAM; |
39 | uint8 *FillRAM; |
40 | uint8 *SRAM; |
41 | uint32 ALL_BITS[0x32000 >> 5]; |
42 | uint8 CWatchRAM[0x32000]; |
43 | }; |
44 | |
45 | struct Watch |
46 | { |
47 | bool on; |
48 | int size; |
49 | int format; |
50 | uint32 address; |
51 | char buf[12]; |
52 | char desc[32]; |
53 | }; |
54 | |
55 | typedef enum |
56 | { |
57 | S9X_LESS_THAN, |
58 | S9X_GREATER_THAN, |
59 | S9X_LESS_THAN_OR_EQUAL, |
60 | S9X_GREATER_THAN_OR_EQUAL, |
61 | S9X_EQUAL, |
62 | S9X_NOT_EQUAL |
63 | } S9xCheatComparisonType; |
64 | |
65 | typedef enum |
66 | { |
67 | S9X_8_BITS, |
68 | S9X_16_BITS, |
69 | S9X_24_BITS, |
70 | S9X_32_BITS |
71 | } S9xCheatDataSize; |
72 | |
73 | extern SCheatData Cheat; |
74 | extern Watch watches[16]; |
75 | |
76 | int S9xAddCheatGroup (const char *name, const char *cheat); |
77 | int S9xModifyCheatGroup (uint32 index, const char *name, const char *cheat); |
78 | void S9xEnableCheatGroup (uint32 index); |
79 | void S9xDisableCheatGroup (uint32 index); |
80 | void S9xDeleteCheats (void); |
81 | char *S9xCheatGroupToText (uint32 index); |
82 | void S9xDeleteCheatGroup (uint32 index); |
83 | bool8 S9xLoadCheatFile (const char *filename); |
84 | bool8 S9xSaveCheatFile (const char *filename); |
85 | void S9xUpdateCheatsInMemory (void); |
86 | int S9xImportCheatsFromDatabase(const char *filename); |
87 | void S9xCheatsDisable (void); |
88 | void S9xCheatsEnable (void); |
89 | char *S9xCheatValidate (const char *cheat); |
90 | |
91 | void S9xInitCheatData (void); |
92 | void S9xInitWatchedAddress (void); |
93 | void S9xStartCheatSearch (SCheatData *); |
94 | void S9xSearchForChange (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, bool8, bool8); |
95 | void S9xSearchForValue (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8, bool8); |
96 | void S9xSearchForAddress (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8); |
97 | void S9xOutputCheatSearchResults (SCheatData *); |
98 | |
99 | const char * S9xGameGenieToRaw (const char *, uint32 &, uint8 &); |
100 | const char * S9xProActionReplayToRaw (const char *, uint32 &, uint8 &); |
101 | const char * S9xGoldFingerToRaw (const char *, uint32 &, bool8 &, uint8 &, uint8 bytes[3]); |
102 | |
103 | #endif |
104 | |