In ye boring and basic RPG then "IF enemy health = 0 then goto battle victory ELSE do next round"
If it is a timer then that, if there is another means of doing a victory with stats then that too.
Many cheats will then set this health or timer or whatever to a value that corresponds to dead/won and then when the game next checks it goes "oh wow, must have won in the meantime, let's do the victory routine".
Alternatively rather than doing that other cheat codes will find the game's code (which is in memory, and the locations mentioned in the cheats are where I often can expect to find the code the DS puts in memory to run*) and change the "IF enemy health = 0 then goto battle victory ELSE do next round" thing from before to instead be "[do nothing] goto battle victory".
This means when the cheat is activated the game's code is overwritten until it is refreshed (does not normally happen other than for overlays) or you reboot the game without cheats on (do note savestates in emulators don't count here as they keep the memory as it was). If however you know what was supposed to be at the location the cheat cares about in the base game then you can make another cheat that restores that location. This restoration of original data.
What you appeared to be doing is replacing it with 0000. This would be fine if it was say an ammo counter you put to 9999 and want to put back to 0000 after you are done. For code it would be a different matter.
*you can easily find this out. NDSTS from
https://no-intro.org/tools.htm , open up the ROM and it will tell you where the ARM9 address is in RAM as well as the size. If the cheat is somewhere in that area then good chance it is the code altering type. Also check it is not in the overlay range (overlays are sections of code the game can swap out to free up some memory - the game's credits might only run once every 50 boots or hundred hours, no sense keeping that code in memory all the time when it could be used for something useful, repeat for other minigames and whatever else), though an overlay should be a check as well to make sure it is the overlay it wants.
Still I will run the general idea of things
Decoding cheats.
https://web.archive.org/web/20191123185758/https://doc.kodewerx.org/hacking_nds.html
If you need a guide to DS hardware
http://problemkaputt.de/gbatek.htm
The original cheat
5219A3EC FBE8F6BC
1219A41A 00002100
D2000000 00000000
Type 0x05
Equal To
5XXXXXXX YYYYYYYY Checks if YYYYYYYY == (word at [XXXXXXX]).
If not, the code(s) following this one are not executed (ie. execution status is set to false) until a code type D0 or D2 is encountered, or until the end of the code list is reached.
This presumably checks to see if some area of memory equals something else. Could be an overlay, could be something that only appears in that format in battle. I don't know which is what I was asking before.
Type 0x01
16-bit
1XXXXXXX 0000YYYY Writes halfword YYYY to [XXXXXXX+offset].
This is the actual cheat component that carries the thing the cheat does. What you would want to find out for this is what is originally at that location when in battle, or indeed any time the 5 code's conditions are met if that is different (can also be a thing to make sure you are far enough into the game -- many cheats work happily in the game but will crash if active during boot or something).
D2000000 00000000 is just end of check/loop function it started with the 5 code at the start.
Now onto your code.
First part is much the same as before.
Type 0x09
Equal To
9XXXXXXX ZZZZYYYY Checks if (YYYY) == (not (ZZZZ) & halfword at [XXXXXXX]).
If not, the code(s) following this one are not executed (ie. execution status is set to false) until a code type D0 or D2 is encountered, or until the end of the code list is reached.
4000130 FEFD0000
04000130 in the DS (and GBA) memory is the GBA buttons
http://problemkaputt.de/gbatek.htm#gbakeypadinput http://problemkaputt.de/gbatek.htm#dskeypad
gbatek said:
GBA Keypad Input
The built-in GBA gamepad has 4 direction keys, and 6 buttons.
4000130h - KEYINPUT - Key Status (R)
Bit Expl.
0 Button A (0=Pressed, 1=Released)
1 Button B (etc.)
2 Select (etc.)
3 Start (etc.)
4 Right (etc.)
5 Left (etc.)
6 Up (etc.)
7 Down (etc.)
8 Button R (etc.)
9 Button L (etc.)
10-15 Not used
It'd be usually recommended to read-out this register only once per frame, and to store the current state in memory. As a side effect, this method avoids problems caused by switch bounce when a key is newly released or pressed.
Seems we are being dirty rebels today and not using the debounced section, though cheats rarely do.
There are some button press calculators out there for those that don't fancy doing Boolean maths and fiddling with binary in their head. ARDS Button Activator Calculator by Demonic722 is the one I used to know but there are others I have seen.
Anyway
opening post said:
R + A to turn it on and want to use R + B to turn off
So that should correspond to R and A. Bit 8 and bit 0 then being 1 in the basic idea
0000 0000 0000 0000
means
0000 0001 0000 0001
Should be that in binary.
0101 in hex. As you are inverting it then FEFE should be it. Not sure where FEFD (which would be R+B) is involved here as going by the original code the write 2100 to the location is the skip turn thing comes in.
Looks however like you got the activators the wrong way around and put R and B's check as the do cheat, and R and A as something else which is what is up shortly.
Personally I would put the button activator before the memory check but no great deal either way.
One thing I am curious about is in the second part, and sorry I did not clock it first time around.
In the "undo" code
1219A41B 00000000
In the original code
1219A41A 00002100
A is not B. Why are you overwriting a different section? It is not impossible that you want to write somewhere else in memory to undo a cheat (if the game has two timers, one for actual time and another for time remaining as sometimes that is easier to deal with in code) but this is also one of the the things I want clarification as to what the memory area the cheats are messing with actually does in the context of this game.[/quote]