1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
.. _debugger-cheats-list:
Cheat Debugger Commands
=======================
:ref:`debugger-command-cheatinit`
initialize the cheat search to the selected memory area
:ref:`debugger-command-cheatrange`
add selected memory area to cheat search
:ref:`debugger-command-cheatnext`
filter cheat candidates by comparing to previous values
:ref:`debugger-command-cheatnextf`
filter cheat candidates by comparing to initial value
:ref:`debugger-command-cheatlist`
show the list of cheat search matches or save them to a file
:ref:`debugger-command-cheatundo`
undo the last cheat search (state only)
The debugger includes basic cheat search functionality, which works
by saving the contents of memory, and then filtering locations according
to how the values change.
We’ll demonstrate use of the cheat search functionality to make an
infinite lives cheat for Raiden (``raiden``):
* Start the game with the debugger active. Allow the game to run,
insert a coin, and start a game, then break into the debugger.
* Ensure the main CPU is visible, and start a search for 8-bit unsigned
values using the
:ref:`cheatinit command <debugger-command-cheatinit>`::
>cheatinit ub
36928 cheat locations initialized for NEC V30 ':maincpu' program space
* Allow the game to run, lose a life and break into the debugger.
* Use the :ref:`cheatnext command <debugger-command-cheatnext>` to
filter locations that have decreased by 1::
>cheatnext -,1
12 cheats found
* Allow the game to run, lose another life, break into the
debugger, and filter locations that have decreased by 1 again::
>cheatnext -,1
Address=0B85 Start=03 Current=01
1 cheats found
* Use the :ref:`cheatlist command <debugger-command-cheatlist>` to save
the cheat candidate to a file::
>cheatlist raiden-p1-lives.xml
* The file now contains an XML fragment with cheat to set the candidate
location to the initial value:
.. code-block:: XML
<cheat desc="Possibility 1: 00B85 (01)">
<script state="run">
<action>:maincpu.pb@0x00B85=0x03</action>
</script>
</cheat>
.. _debugger-command-cheatinit:
cheatinit
---------
**cheatinit [[<sign>[<width>[<swap>]]],[<address>,<length>[,<space>]]]**
Initialize the cheat search to writable RAM areas in the specified
address space. May be abbreviated to ``ci``.
The first argument specifies the data format to search for. The
**<sign>** may be **u** for unsigned or **s** for signed, the
**<width>** may be **b** for 8-bit (byte), **w** for 16-bit (word),
**d** for 32-bit (double word), or **q** for 64-bit (quadruple word);
**<swap>** may be **s** for reversed byte order. If the first argument
is omitted or empty, the data format from the previous cheat search is
used, or unsigned 8-bit format if this is the first cheat search.
The **<address>** specifies the address to start searching from, and the
**<length>** specifies how much memory to search. If specified,
writable RAM in the range **<address>** through
**<address>+<length>-1**, inclusive, will be searched; otherwise, all
writable RAM in the address space will be searched.
See :ref:`debugger-devicespec` for details on specifying address spaces.
If the address space is not specified, it defaults to the first address
space exposed by the visible CPU.
Examples:
``cheatinit ub,0x1000,0x10``
Initialize the cheat search for unsigned 8-bit values in addresses
0x1000-0x100f in the program space of the visible CPU.
``cheatinit sw,0x2000,0x1000,1``
Initialize the cheat search for signed 16-bit values in addresses
0x2000-0x2fff in the program space of the second CPU in the system
(zero-based index).
``cheatinit uds,0x0000,0x1000``
Initialize the cheat search for unsigned 64-bit values with reverse
byte order in addresses 0x0000-0x0fff in the program space of the
visible CPU.
Back to :ref:`debugger-cheats-list`
.. _debugger-command-cheatrange:
cheatrange
----------
**cheatrange <address>,<length>**
Add writable RAM areas to the cheat search. May be abbreviated to
``cr``. Before using this command, the
:ref:`cheatinit command <debugger-command-cheatinit>` must be used to
initialize the cheat search and set the address space and data format.
The **<address>** specifies the address to start searching from, and the
**<length>** specifies how much memory to search. Writable RAM in the
range **<address>** through **<address>+<length>-1**, inclusive, will be
added to the areas to search.
Examples:
``cheatrange 0x1000,0x10``
Add addresses 0x1000-0x100f to the areas to search for cheats.
Back to :ref:`debugger-cheats-list`
.. _debugger-command-cheatnext:
cheatnext
---------
**cheatnext <condition>[,<comparisonvalue>]**
Filter candidates by comparing to the previous search values. If five
or fewer candidates remain, they will be shown in the debugger console.
May be abbreviated to ``cn``.
Possible **<condition>** arguments:
``all``
Use to update the last value without changing the current matches
(the **<comparisonvalue>** is not used).
``equal`` (``eq``)
Without **<comparisonvalue>**, search for values that are equal to
the previous search; with **<comparisonvalue>**, search for values
that are equal to the **<comparisonvalue>**.
``notequal`` (``ne``)
Without **<comparisonvalue>**, search for values that are not equal
to the previous search; with **<comparisonvalue>**, search for
values that are not equal to the **<comparisonvalue>**.
``decrease`` (``de``, ``-``)
Without **<comparisonvalue>**, search for values that have decreased
since the previous search; with **<comparisonvalue>**, search for
values that have decreased by the **<comparisonvalue>** since the
previous search.
``increase`` (``in``, ``+``)
Without **<comparisonvalue>**, search for values that have increased
since the previous search; with **<comparisonvalue>**, search for
values that have increased by the **<comparisonvalue>** since the
previous search.
``decreaseorequal`` (``deeq``)
Search for values that have decreased or are unchanged since the
previous search (the **<comparisonvalue>** is not used).
``increaseorequal`` (``ineq``)
Search for values that have increased or are unchanged since the
previous search (the **<comparisonvalue>** is not used).
``smallerof`` (``lt``, ``<``)
Search for values that are less than the **<comparisonvalue>** (the
**<comparisonvalue>** is required).
``greaterof`` (``gt``, ``>``)
Search for values that are greater than the **<comparisonvalue>**
(the **<comparisonvalue>** is required).
``changedby`` (``ch``, ``~``)
Search for values that have changed by the **<comparisonvalue>**
since the previous search (the **<comparisonvalue>** is required).
Examples:
``cheatnext increase``
Search for all values that have increased since the previous search.
``cheatnext decrease,1``
Search for all values that have decreased by 1 since the previous
search.
Back to :ref:`debugger-cheats-list`
.. _debugger-command-cheatnextf:
cheatnextf
----------
**cheatnextf <condition>[,<comparisonvalue>]**
Filter candidates by comparing to the initial search values. If five or
fewer candidates remain, they will be shown in the debugger console.
May be abbreviated to ``cn``.
Possible **<condition>** arguments:
``all``
Use to update the last value without changing the current matches
(the **<comparisonvalue>** is not used).
``equal`` (``eq``)
Without **<comparisonvalue>**, search for values that are equal to
the initial search; with **<comparisonvalue>**, search for values
that are equal to the **<comparisonvalue>**.
``notequal`` (``ne``)
Without **<comparisonvalue>**, search for values that are not equal
to the initial search; with **<comparisonvalue>**, search for values
that are not equal to the **<comparisonvalue>**.
``decrease`` (``de``, ``-``)
Without **<comparisonvalue>**, search for values that have decreased
since the initial search; with **<comparisonvalue>**, search for
values that have decreased by the **<comparisonvalue>** since the
initial search.
``increase`` (``in``, ``+``)
Without **<comparisonvalue>**, search for values that have increased
since the initial search; with **<comparisonvalue>**, search for
values that have increased by the **<comparisonvalue>** since the
initial search.
``decreaseorequal`` (``deeq``)
Search for values that have decreased or are unchanged since the
initial search (the **<comparisonvalue>** is not used).
``increaseorequal`` (``ineq``)
Search for values that have increased or are unchanged since the
initial search (the **<comparisonvalue>** is not used).
``smallerof`` (``lt``, ``<``)
Search for values that are less than the **<comparisonvalue>** (the
**<comparisonvalue>** is required).
``greaterof`` (``gt``, ``>``)
Search for values that are greater than the **<comparisonvalue>**
(the **<comparisonvalue>** is required).
``changedby`` (``ch``, ``~``)
Search for values that have changed by the **<comparisonvalue>**
since the initial search (the **<comparisonvalue>** is required).
Examples:
``cheatnextf increase``
Search for all values that have increased since the initial search.
``cheatnextf decrease,1``
Search for all values that have decreased by 1 since the initial
search.
Back to :ref:`debugger-cheats-list`
.. _debugger-command-cheatlist:
cheatlist
---------
**cheatlist [<filename>]**
Without **<filename>**, show the current cheat matches in the debugger
console; with **<filename>**, save the current cheat matches in basic
XML format to the specified file. May be abbreviated to ``cl``.
Examples:
``cheatlist``
Show the current matches in the console.
``cheatlist cheat.xml``
Save the current matches to the file **cheat.xml** in XML format.
Back to :ref:`debugger-cheats-list`
.. _debugger-command-cheatundo:
cheatundo
---------
**cheatundo**
Undo filtering of cheat candidates by the most recent
:ref:`cheatnext <debugger-command-cheatnext>` or
:ref:`cheatnextf <debugger-command-cheatnextf>` command. Note that the
previous values *are not* rolled back. May be abbreviated to ``cu``.
Examples:
``cheatundo``
Restore cheat candidates filtered out by the most recent
:ref:`cheatnext <debugger-command-cheatnext>` or
:ref:`cheatnextf <debugger-command-cheatnextf>` command.
Back to :ref:`debugger-cheats-list`
|