Seeing as the cheat functions appear to be working correctly as of 0.9.2, and people being confused as to how to use it, here's a quick and dirty guide to using internal DeSmuMe cheats.
It is impossible yet to use "commercial" codes, such as Action Replay and Codebreaker, so what we'll have to do is manually run a search for, and alter the memory positions to our advantage. We'll have a quick rundown of the cheat searching menu and functions, followed by a pair of examples.
The cheat searching menu can be found under Emulation -> Cheats -> Search;
Select Size - Choose the smallest range applicable to the value you're trying to change. If you're trying to change an energy value which maxes out at 100, choose 1 byte (range of 0 to 255). If you're trying to change HP and it maxes out in the game at 9999, choose 2 bytes (range 1 to 65536), etc. It usually is inadvisable to use larger memory sizes than required, as it may have undesirable effects on your game.
Sign - A signed memory refers to a memory that can include both positive or negative numbers. So if the value you're searching for can be less than zero, it is likely to be a signed memory. Do note that when choosing a memory as signed, the range is halved in both directions. 1 byte, rather than covering a range of 0 to 255, will cover a range of -128 to +127 (not -255 to +255). This option does not work in 0.9.2
Select Search Type - In some cases, you don't know the exact value you're searching for, when it's hidden or not numerical for example. Exact searches allow you to enter a known value (say, 100 for energy), and then continue with known values. A comparative search allows you to search for an unknown value by comparison - You run an initial search, and in following searches you narrow the possible values down by choosing wether the value increased, decreased, changed in any direction, or remained the same.
The three buttons allow you to restart a search, view the found memory addresses, and run a search respectively.
Example 1: Modifying a known value
Let's assume you are playing a game in which your character currently has 100 health points. What we'll try to do is freeze his health at that value.
1) First thing one needs to do is figure out the size of the type of memory address we're dealing with. Our character has 100 health points, and we know that that is the highest value it can reach through the game. We'll choose 1 byte, unsigned, exact search. One byte because we need to use the smallest possible memory size which fits our value, unsigned because the hero's health points can not be less than zero, and exact search because we can clearly see his health points at any given time.
2) Click "search", and enter the health points value in the next window. In our case, it's 100. Click "search again".
3) Close the cheat searching window down, and keep playing until you get hurt, and your health points are no longer at 100. Let's assume they are now at 90.
4) I go back into the search menu, and this time run a search for 90. What actually happened is that in the above search the emulator found all of the addresses that at the time of the search were equal to 100 and saved them. This second search is called a FILTER search - it goes through the previous found addresses, and finds the ones that changed to 90. We're essentially weeding out addresses that matched our searches by coincidence, to find the one we actually want.
5) After the second search, the number of results shown should be considerably lower. At this time there are two options: either there is only 1 result left, or there are more. If there are more I'll repeat filter searches with new value until I get the results down to 1. If it's 1 we're ready to set the value to what we want.
6) Click "view", and a window with the address and the value will appear. Click the line that holds our current health's value, and click "Add".
7) Change the value in the new window to 100, add a description if you want, and choose wether you want the value to be frozen or not. If it's frozen, the value will be frozen at 100. If not, it will simply be set once to the value you chose, but will not be frozen and will be free to change later. Click "Add", and the value should now be frozen at 100.
Example 2: Modifying an unknown value via comparative searches
Let's assume you're playing a game in which after your character is hit, he flashes for three seconds during which he is invulnerable (like megaman games). What happens behind the scenes of the game is that when you get hit, SOME address is set to SOME value (usually 1, but not always) that tells the game that right now, you're invulnerable. What we want to do is make that value ALWAYS be on the "invulnerable" state.
1) First thing we do is get hit, to have the invulnerability flashing on.
2) We begin a search. Choosing a memory size for unknown values is trickier because they're, well, unknown. However, in situations such as these (on/off functions, or boolean functions as they are called), memories are usually saved as booleans (1 or 0), or as flags (1,2,4,8,16...). Both of those are 1 byte memory addresses, so we'll first attempt the comparative search with a 1 byte size and if it fails - we'll try with increasing sizes.
2) After clicking "search", we won't be asked to enter a value of course. Don't be alarmed by seeing that we have 0 results. What actually happened is that the emulator just saved ALL of the addresses of our specified memory size. At this time we'll return to the game and wait for the invulnerability to wear off. When it does, we go back to the search menu where we'll be presented with a couple of options. As we don't know how the game saves the invulnerability state, we can't actually know if the value is now higher or lower, so the first two options are irrelevant to us. What we do now is that the value has changed. We choose "new value is != old value" -- ! in programming means NOT, so != means "not equal". We click search, and go back to the game.
3) In these kinds of searches we'll usually need to do quite a couple of filtering searches. Do note that you can also use the "new value is = old value" searches. For example, when you're not invulnerable you run the first search, then seconds later when you're still not invulnerable, you run the "new value is = old value" search. This will usually have very little effect on the amount of values remaining, though.
4) After finally weeding the amount of values down to 1, I'm going to get hit again to get the invulnerability status, so the value will be set at invulnerable. I'll then go to the search menu, hit "view", click the value we found, click add, NOT CHANGE THE VALUE (the current value is the state for invulnerability after all), make sure 'frozen' is checked, and click add. My character is now invulnerable for as long as the cheat is on.
Last edited by Manivo (2009-04-12 15:55:09)
Ive taken the liberty of adding this great guide to the wiki. Currently it;s located at "http://wiki.desmume.org/index.php?title=Using Cheats in DeSmuMe". It's a nice addition to the wiki FAQ and wiki manuals. Please feel free to alter the wiki version as you see fit..
Last edited by lbalbalba (2009-04-12 19:13:13)
Thanks for contributing. It's sincerely appreciated.
Last edited by lbalbalba (2009-04-12 20:31:53)