Hi guys !!!
I'm trying to make a switch on/off code by pressing the same combination of buttons.
This is not so difficult if I need to modify some pointer or memory address.
The problems occurs when I need to enable/disable an ASM cheat because I need to enable/disable a branch with some cutoms instructions.
I would write something like:
if (buttons_pressed == C+1) {
if (one_time_pressed) {
one_time_pressed = false
apply a branch with some customs instructions
} else {
one_time_pressed = true
use the original program instruction
} // if-else
} // if
To do that I wrote something like this:
28yyyyyy BDFF4200 // button check (exclusive C+1)
CC000000 00000001 // if one time pressed
C2xxxxxx 00000002 // branch to new instructions
zzzzzzzz zzzzzzzz // do all it needs
E2100000 00000000 // endif - else
04xxxxxx zzzzzzzz // set the original program instruction
E0000000 80008000 // full terminator
yyyyyy -> input address of the game
xxxxxx -> same address location
zzzzzzzz -> various stuff
for sure there's something wrong because the game crashes when I enable the cheat from WiiRD (so not when I press the 2 buttons).
I need to say that if I don't use this activation technique the cheats (I mean the branch) work great (so there is not a problem of what I do in ASM) but they are not deactivable.
Can someone please explain me what is my fault?
THANKS !!! :)
If the C2 code is running constantly and you turn it off while its branched it might crash
I would just double check you are writing back the correct original instruction
Interesting idea though, i might try it with one of my C2 codes
In fact I suspected something like this: the original instruction will be replaced always also if you don't activate the cheat pressing the correct buttons combination because the C2 is not applicable to C0 for the code switching.
Perhaps a solution could be:
if (buttons_pressed == C+1) {
if (gecko_register == 0) {
gecko_register = 1
apply a branch with some customs instructions
} else {
gecko_register = 0
use the original program instruction
} // if-else
} // if
the only problem now is: what initialized value will have a gecko register? If it is different from 0 you need to press 2 times the activation buttons combinations to enable for the 1st time the cheat.
http://wiird.l0nk.org/forum/index.php/topic,5100.msg43934.html#msg43934
Gecko registers initialize to 0. Be careful with Gecko registers because they're off by 4 bytes between old and new versions of Gecko OS.
The 00000001 after the CC code is not doing what you think it's doing. 1 means switch is off and 0 means switch is on. So, the code that you posted, it started off by writing the original instruction (switch was set to 1), and then when you press the button, it "switches" to executing the C2 code (switch set to 0). Each time you press the button it will "switch" from 1 to 0, or 0 to 1, and execute one or the other path.
Turning off a C2 code shouldn't cause any damage. C2 codes end with a branch, so even if you shut the C2 code off while the game was in the middle of your injection, it will finish running that injected routine and branch back to where it should be.
Even if that wasn't so, the game isn't running when the code handler is doing its magic. If the processor is currently executing the code handler, patching your ASM with either the original instruction or your C2, then it can't be in two places at once, so by definition it is not in the middle of your injected ASM.
Finally, instead of turning the C2 code on and off with 28 and CC codes, you should use a single C2 code, with an asm button activator at the beginning that branches over your "some customs instructions" to the original instruction at the end.