Coding Questions and other Quandaries
I'll try to keep this as concise and to the point as possible.

1. Instead of posting entire functions, its better to post their names with their args and return values.

2. Some functions depend on a return value from a previous function. Let's say we have three Functions. A, B, and C. You call A with an initial argument to ask it perform a certain task. If the task completes successfully, function A returns a value that you need to use as an argument for function B. You Call B with that value. Function B then returns you a new value. That new value is needed for Function C. You then call Function C with value. This can get pretty complicated especially if Functions have their own child/sub functions that need their own values that must be derived beforehand.

3. When to call a Function in within a code? Use C2 or C0? This depends greatly. Like in MKWii, some functions are only meant to be called during a Race. Thus a C2 code using a hook address that only occurs during a race would suffice. Trying to write a Code to call it outside a race will end up in an Exception ofc.

4. If you are able to call a Function in C0 (usually it's a generic function like a file handling thing), you may need to disable interrupts.

5. blr/bctr is to have the function NOT return back. This is usually only suitable for functions like Shutting Down the Console. Other functions need to be called with blrl/bctrl. The return address will get saved in the Link Register. Function can return back.

6. Have a better understanding of C/C++ to understand how the game operates on a higher level. This will also give you a better understanding of how functions work on a lower level (Assembly)

7. Conclusion: Read the following two threads completely. If you have already read them, read them again. Another idea is to search on this forum for Codes that include Function Calls. Read over their source(s), that can give you some pointers/tips

https://mariokartwii.com/showthread.php?tid=1052
https://mariokartwii.com/showthread.php?tid=1156
Reply


Messages In This Thread
RE: Coding Questions and other Quandaries - by Vega - 12-29-2022, 04:05 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)