What’s the best way to go about calling game specific functions?
#1
Hiya.

So I’ve just started looking into making ASM based hacks today. I’ve found many of the tutorials on this forum very helpful. I’ve so far managed to make a couple of simple codes for the sake of learning what to do (although I’ve had experience with modding, NDS Action Replay codes and programming in the past, so it’s not completely new to me). I made a code to never increment the lap counter and a code to always force a specific item from a box.

Anyway, I started looking into what happens when the player runs into an item box, and I believe I’ve found various functions that get called when a box is run into. However, whenever I try to call any of the functions from my ASM (I’m using the CTR method specified in the “calling functions” tutorial), Dolphin throws some errors and either the game or dolphin itself crashes. I used my lap counter code as a base, so the idea is that whenever the start line is passed, the player should receive an item as if they had hit a box. The crash happens right as I go to pass the start line.

I understand that part of the reason for the crash is because certain registers need to be set properly, as they are used as function arguments. But some of the functions I found look as though they use registers that aren’t predictable (I can’t just set them to the same value each time). So how can I reliably call one of these functions? Or is it just not possible through these means, or am I horribly misunderstanding something? I also tried calling functions that appeared to have consistent arguments but still ran into crashes. I guess at this stage I’m probably punching above my weight and I should probably stick to simpler stuff, but I thought I’d ask anyway.

Thanks in advance.
Reply
#2
Hey there! First off, welcome to the forums!

Many functions are very very complex. Especially if something such as the r3 arg is pointing to an area of dynamic memory. For the item box functions, I took a quick look at them before.

Essentially there's a parent function that is ran every frame constantly checking if you hit a box. The exact check for the box is near the end of this function. If a certain value is met, a branch route is taken thus calling a set of ~removed~ functions, and the whole process starts. There's a lot of other elements involved which caused me to give up on it.

Check out this code http://mkwii.com/showthread.php?tid=1390 and set an Instruction BP on the address.

In the Code View, there is a thing named "Call stack" Which shows the hierarchy of functions. The lower functions on the list are like the 'parent functions'. You can go further down the list (such as setting Instruction BPs on them) and see how/when the parent functions get called.

If you are really good at C++/C and disassembly work, I recommend getting Ghidra. http://mkwii.com/showthread.php?tid=1193

You have probably already looked at the symbol map thread. Unfortunately nobody (that is willing to share their work) has provided any StaticR.rel mapping. Ghidra can get you started on that. Once you have that setup, you can take your function addresses and analyze them on Ghidra.

If you don't want to use Ghidra, you can use IDA pro, or get your hands on a cracked version of the original Metrowerks Codewarrior for the Gamecube/Wii.

~Over 100 MKWii Cheat Codes created
~Main Time Updater for the MKWii Player's Page

Reply
#3
Thank you for the reply. I’ll definitely look into using Ghidra, it looks like it could be useful for better understanding how some functions work.

I was using the call stack to try to get a list of functions related to item boxes. After setting breakpoints on the ones near the bottom, I noticed they were being called every frame so I assumed that maybe they were more generic functions that handled more than just item boxes.

It looks like the drive through item boxes code removes the branch instruction, to stop the function from being called at all. Maybe I can do something with that to trigger the item roulette when crossing the start line. I’ll try experimenting with it.

Thanks again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)