asm cpu works, added sync()s
[fceu.git] / Documentation / cheat.txt
1 FCE Ultra Cheat Guide
2  version .4
3 ---------------------------
4
5 Table of Contents:
6
7  1:  Introduction
8   1.0) Introduction
9   1.1) Cheat Files
10
11  2:  The Windows Interface
12   2.0) The Main Cheat Window
13   2.1) The Add Cheat Window
14    2.1.1) The Cheat Search Interface
15
16  3:  The DOS/Linux Interface - UNFINISHED(read "The Windows Interface" for now)
17   3.0) The Main Cheat Menu
18    3.0.1) The Cheat List
19   3.1) The Add Cheat Menu
20    3.1.1) The Cheat Search Interface
21
22  4:  Finding Cheats
23   4.0) "Mega Man 3" Windows Example
24   4.1) "Over Horizon" DOS/Linux Example
25   4.2) Hints
26
27 /******** Section 1.0:   */
28
29  FCE Ultra allows cheating by the periodic "patching" of arbitrary addresses
30  in the 6502's memory space with arbitrary values.  Currently, only RAM
31  patching is allowed(trying to patch an address where ROM is will silently
32  fail).
33
34  The patches are all applied a short time before the emulated
35  vertical blanking period.  This detail shouldn't concern most people, though.
36  However, this does mean that cheating with games that use
37  bank-switched RAM may be problematic.  Fortunately, such games are not very
38  common(in relation to the total number of NES and Famicom games).
39
40 /******** Section 1.1:   */
41
42  Cheats are stored in the "cheats" subdirectory under the base FCE Ultra
43  directory.  The files are in a simple plain-text format.  Each line represents
44  a one-byte memory patch.  The format is:
45
46         Address(hex):Value(hex):Description
47         
48   Example:
49
50         040e:05:Infinite super power.
51
52  A colon(:) can be prefixed to the beginning of a line to disable that cheat.
53         
54
55 /******** Section 2.0   */
56
57  All addresses listed in the Cheats and Add Cheat windows are in a
58  16-bit hexadecimal format and all values in these windows are in an
59  unsigned 8-bit decimal format(the range for values is 0 through 255).
60
61
62  The main Cheats window contains the list of cheats for the currently
63  loaded game, places to view and edit the attributes of the selected cheat,
64  a button to delete the selected cheat, a button to open the Add Cheat
65  window, and a button to close the Cheats window.
66
67 /******** Section 2.1   */
68
69  To the left in the Add Cheat window are text edit boxes for inputting
70  attributes of a cheat and a button to add that cheat.  To the right is
71  the cheat searching interface.
72
73  /******* Section 2.1.1 */
74  
75  The cheat search interface consists of several components:  a list of
76  addresses and associated data for a search, several command buttons,
77  and the search paramters.
78
79  The list of addresses is in the format of:
80   "Address:Original Value:Current Value".
81
82  The address is the location in the 6502's address space, the original
83  value is the value that was stored at this address when the search was
84  reset, and the current value is the value that is currently stored at
85  that address.  Selecting an item in this list will automatically cause
86  the "Address" field in the "Add Cheat" box to be updated with the
87  selected address.
88
89  The "Reset Search" button resets the search process; all valid addresses
90  are displayed in the cheat list and the data values at those addresses noted.
91
92  The "Do Search" buttons performs a search based on the search parameters
93  and removes any non-matching addresses from the address list.
94
95  The "Set Original to Current" button sets the remembered original values
96  to the current values.  It is like the "Reset Search" button, but it does
97  not affect which addresses are shown in the address list.  This command is
98  especially useful when used in conjunction with the "O!=C" search filter.
99
100  The "Unhide Excluded" button shows all addresses that are excluded as a
101  result of any previous searches.  It is like the "Reset Search" button
102  except that it does not affect the remembered original values.
103
104  The numbers assigned the names "V1" and "V2" have different meanings based
105  on which filter is selected.  A list of the names of the filters and detailed
106  information on what they do follows("original value" corresponds to the value
107  remembered for a given addres and "current value" is the value currently
108  at that address. Also, if a value is not explicitly said to be shown
109  under a certain condition, then it is obviously excluded.):
110
111   "O==V1 && C==V2":
112                  Show the address if the original value is equal to "V1" AND
113                  the current value is equal to "V2".
114
115   "O==V1 && |O-C|==V2":
116                  Show the address if the original value is equal to "V1" AND
117                  the difference between the current value and the original
118                  value is equal to "V2".
119
120   "|O-C|==V2":
121                  Show the address if the difference between the current value
122                  and the original value is equal to "V2".
123   "O!=C":
124                  Show the address if the original value does not equal the
125                  current value.
126
127  
128 /******** Section 4.0   */
129
130  This example will give Mega Man unlimited energy.
131  Immediately after entering the Top Man stage, make your way to the
132  "Add Cheat" window.  Push "Reset Search".
133  Go back to playing and move right until the first enemy appears.  Allow
134  yourself to be hit twice.  Each hit does "2" damage, so you've lost 4 energy
135  bars.  Go to the "Add Cheat" window again and select the third filter
136  ("|O-C|==V2") and enter the value 4 next to "V2".  Then push "Do Search".
137
138  Several addresses will appear in the address list.  You can try to find
139  the address you want through trial and error, or you can narrow the results
140  down further.  We will do the latter.
141
142  Go back to playing MM3 and get hit one more time and make your way back
143  to the "Add Cheat" window.  Your damage is now "6".  You can probably
144  see which address that contains your life(it is 00A2).  If now, change
145  V2 to 6 and push "Do Search" again.  This should leave only 00A2.
146
147  Select that entry in the address list.  Shift your attention to the "Add
148  Cheat" box to the left.  Type in a meaningful name and the desired value(156;
149  it was the value when you had no damage, so it's safe to assume it's the
150  maximum value you can use).  Push the "Add" button and a confirmation box
151  will come up.  The cheat has been added.
152
153
154 /******** Section 4.1   */
155
156  This example will give you infinite lives in the NTSC(Japanese) version
157  of "Over Horizon".
158
159  Start a new game.  Notice that when you press "Start" during gameplay,
160  the number of lives you have left is indicated.  With no cheating, you
161  start with 3 lives(2 lives left).
162
163  Activate the cheat interface immediately after starting a new game.
164  Select the "New Cheats" menu and "Reset Search".
165
166  I'll assume that the number of lives left shown in the game is the same number
167  that's stored in RAM.  Now, "Do Search".  You're going to use the first search
168  filter.  For V1, enter the value 2.  For V2, enter the same value.  This, 
169  coupled with the fact that you just reset the search, will allow you to search 
170  for a value "absolutely"(as opposed to changes in the value).  
171
172  Now, "Show Results".  When I did it, I received 11 results:
173
174          1) $0000:002:002
175          2) $001c:002:002
176          3) $001e:002:002
177          4) $009d:002:002
178          5) $00b9:002:002
179          6) $00e3:002:002
180          7) $0405:002:002
181          8) $0406:002:002
182          9) $0695:002:002
183         10) $07d5:002:002       
184         11) $07f8:002:002
185
186  You really can't do much yet(unless you want to spend time doing trial
187  and error cheat additions).  Return to the game.
188
189  After losing a life, go back to the cheat interface, to the "New Cheats"
190  menu, and "Show Results".  Here are my results:
191
192          1) $0000:002:002
193          2) $001c:002:002
194          3) $001e:002:002
195          4) $009d:002:002
196          5) $00b9:002:041
197          6) $00e3:002:002
198          7) $0405:002:001
199          8) $0406:002:002
200          9) $0695:002:002
201         10) $07d5:002:001
202         11) $07f8:002:002
203
204  Notice that two addresses seem to hold the number of lives($0405 and
205  $07d5).  You can lose another life and go "Show Results" again, and you
206  should see that $07d5 is the address that holds the number of lives.
207
208  Now that you know the address that holds the number of lives, you can
209  add a cheat.  You can either type in the number from the cheat results list
210  corresponding to the address you want to add a cheat for, or you can
211  remember the address and select "Add Cheat" from the "New Cheats" menu.
212  Do the former.
213
214  Now you will need to enter a name for the cheat.  I suggest something short,
215  but descriptive.  "Infinite lives" will work fine.  Next, a prompt for
216  the address will show up.  Since you selected an item from the list, you
217  can press enter to use the associated address($07d5).  Next, you will
218  need to enter a value.  It doesn't need to be large(in fact, it probably
219  shouldn't be; abnormally high numbers can cause some games to misbehave).
220  I suggest a value of 2.  After this, you should get a prompt that looks like
221  this:
222
223    Add cheat "Infinite lives" for address $07d5 with value 002?(Y/N)[N]:
224
225  Answer "Y".  You now have infinite lives.
226
227 /******** Section 4.2   */
228
229  Games store player information in many different ways.  For example,
230  if you have "3" lives in Super Wacky Dodgeball 1989, the game might store
231  it in memory as 2, 3, or 4, or perhaps a different number all together.
232  Also, say that you have 69 life points out of 200 in Mole Mashers.  The
233  game might store how many life points you have, or how much damage you have
234  taken. Relative value searches are very valuable because you probably 
235  don't know the way that the game stores its player data.
236
237  Some games, especially RPGs, deal with individual numbers greater than
238  8-bits in size.  Most that I've seen seem to store the multiple-byte data
239  least significant byte(lower byte of number) first in memory, though 
240  conceivably, it could be stored most significant byte first, or the component 
241  bytes of the number could be non-contiguous, though the latter is very unlikely.
242  For example, say I have 5304 experience points in Boring Quest for the 
243  Overused Plot Device.  To split the number into two eight bit decimal numbers,
244  take 5304 %(modulus) 256.  This will give a number that is the lower 8 bits.
245  Next, take 5304 / 256.  The integral component of your answer will be the 
246  upper 8 bits(or the next 8 bits, if the number is or can be larger than 16 
247  bits) of 5304.  Now you will need to search for these numbers.  Fortunately, 
248  most(all?) RPGs seem to store large numbers exactly as they are shown in the
249  game.