Here's a kind of clunky but useful Gecko ASM code I just made and haven't tested (lol)
It uses r16, r17, r18, r19, and CTR (doesn't interfere with Zelda games at least)
C2JJJJJJ 00000008
7E0902A6 3E20LLLL
6231MMMM 82310000
3A40YYYY 7E719396
7E7391D6 7E738850
2C130000 40820014
3E20WWWW 6231ZZZZ
7E2903A6 4E800421
7E0903A6 00000000
JJJJJJ = The offset (relative to 0x80000000) to insert this code.
LLLL = Upper 16 bits of address to modulo the value of
MMMM = Lower 16 bits of address to modulo the value of
WWWW = Upper 16 bits (first half) of target function to execute if modulo result is 0
ZZZZ = Lower 16 bits (second half) of target function to execute if modulo result is 0
YYYY = The value to modulo the value at 0xLLLLMMMM by
So, to sum it all up:
1. Load the value at 0xLLLLMMMM
2. Mod that value by 0xYYYY (get the remainder after dividing it by 0xYYYY)
3. If there is no remainder (0xYYYY is a factor of the value at 0xLLLLMMMM), then put 0xWWWWZZZZ into the CTR and branch to the CTR (runs the function located at 0xWWWWZZZZ)
Anyways yeah I'm gonna use this code to run a few things every other frame (like updating the pause menu cursor)
Also don't ask how I decided on the letters for the code.
Oh and here's the ASM source of the code:
Edit 2: Forgot to make a change in the gecko code.
It uses r16, r17, r18, r19, and CTR (doesn't interfere with Zelda games at least)
C2JJJJJJ 00000008
7E0902A6 3E20LLLL
6231MMMM 82310000
3A40YYYY 7E719396
7E7391D6 7E738850
2C130000 40820014
3E20WWWW 6231ZZZZ
7E2903A6 4E800421
7E0903A6 00000000
JJJJJJ = The offset (relative to 0x80000000) to insert this code.
LLLL = Upper 16 bits of address to modulo the value of
MMMM = Lower 16 bits of address to modulo the value of
WWWW = Upper 16 bits (first half) of target function to execute if modulo result is 0
ZZZZ = Lower 16 bits (second half) of target function to execute if modulo result is 0
YYYY = The value to modulo the value at 0xLLLLMMMM by
So, to sum it all up:
1. Load the value at 0xLLLLMMMM
2. Mod that value by 0xYYYY (get the remainder after dividing it by 0xYYYY)
3. If there is no remainder (0xYYYY is a factor of the value at 0xLLLLMMMM), then put 0xWWWWZZZZ into the CTR and branch to the CTR (runs the function located at 0xWWWWZZZZ)
Anyways yeah I'm gonna use this code to run a few things every other frame (like updating the pause menu cursor)
Also don't ask how I decided on the letters for the code.
Oh and here's the ASM source of the code:
Spoiler: (Show Spoiler)
Edit 2: Forgot to make a change in the gecko code.

