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
13struct 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
24struct SCheatGroup
25{
26 char *name;
27 bool8 enabled;
28 std::vector<struct SCheat> c;
29};
30
31struct 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
45struct Watch
46{
47 bool on;
48 int size;
49 int format;
50 uint32 address;
51 char buf[12];
52 char desc[32];
53};
54
55typedef 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
65typedef enum
66{
67 S9X_8_BITS,
68 S9X_16_BITS,
69 S9X_24_BITS,
70 S9X_32_BITS
71} S9xCheatDataSize;
72
73extern SCheatData Cheat;
74extern Watch watches[16];
75
76int S9xAddCheatGroup (const char *name, const char *cheat);
77int S9xModifyCheatGroup (uint32 index, const char *name, const char *cheat);
78void S9xEnableCheatGroup (uint32 index);
79void S9xDisableCheatGroup (uint32 index);
80void S9xDeleteCheats (void);
81char *S9xCheatGroupToText (uint32 index);
82void S9xDeleteCheatGroup (uint32 index);
83bool8 S9xLoadCheatFile (const char *filename);
84bool8 S9xSaveCheatFile (const char *filename);
85void S9xUpdateCheatsInMemory (void);
86int S9xImportCheatsFromDatabase(const char *filename);
87void S9xCheatsDisable (void);
88void S9xCheatsEnable (void);
89char *S9xCheatValidate (const char *cheat);
90
91void S9xInitCheatData (void);
92void S9xInitWatchedAddress (void);
93void S9xStartCheatSearch (SCheatData *);
94void S9xSearchForChange (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, bool8, bool8);
95void S9xSearchForValue (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8, bool8);
96void S9xSearchForAddress (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8);
97void S9xOutputCheatSearchResults (SCheatData *);
98
99const char * S9xGameGenieToRaw (const char *, uint32 &, uint8 &);
100const char * S9xProActionReplayToRaw (const char *, uint32 &, uint8 &);
101const char * S9xGoldFingerToRaw (const char *, uint32 &, bool8 &, uint8 &, uint8 bytes[3]);
102
103#endif
104