Coding Questions and other Quandaries
The way you are structuring you C2 ASM Codes to include button activator instructions within th esource should not be needed in most cases and probably has something to do with why your codes fail on certain Hooktypes for the different Wii games you are working on.

If you ever run into a situation where you want the C2 Hook Address's Instruction to be executed  whenever the button activator is not pressed, structure the C2 code like so..

04xxxxxx oooooooo #xxxxxx = C2 Hook Address, #oooooooo = Default/Original Instruction
283XXXXX YYYYZZZZ #16-bit If-Equal statement (button activator line))
C2xxxxxx 000000XX
.. ..    .. ..    #Somewhere in source is default/original instruction ofc
E0000000 80008000 #End If Statement via Final Terminator


You can rewrite the source of your ASM code like this...

lis r12, 0x8066
ori r12, r12, 0x994C
cmpw r4, r12
bne- default_instruction

lis r12, 0x40F8
ori r12, r12, 0x1480
stw r12, 0 (r4)

default_instruction:
lfs f0, 0 (r4)


And thus the finished code is this..

04037858 C0040000
286254BA YYYYZZZZ
C2037858 00000005
3D808066 618C994C
7C046000 40820010
3D8040F8 618C1480
91840000 C0040000
60000000 00000000
E0000000 80008000


This compiled code is longer by 1 line than your version, but it allows the end user to choose whether or not the button activator is the condition of "only can be pressed" or the condition of "at least pressed". Not only that, formatting your C2 Button Activated codes in this way should reduce the Hooktype issues.

If you are running into scenarios where you are doing 'address checks' in your sources, based on my experience, the code is 'hacky', and needs a better Hook Address or try finding some pattern/correlation in the GVRs.

Off-topic tips:

if you ever need to set an FPR to 0, do this

fsubs fZ, fX, fX #use fsub if double precision

To set an FPR to 1, do this...

fdivs fZ, fX, fX #use fdiv if double precision. fX cannot be 0.

Another note is be on the lookout for some FPRs (during time of Hook address execution) that may always be 0 or 1. Therefore you don't even need the above instructions.
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Vega - 05-31-2022, 01:22 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)