Purpose of r13?
#2
r13 is used as a small data area global pointer. It's set at the very early stages of the booting process of the Game. This address will vary per game. Do NOT modify this value at any time. If for whatever reason you wanted to, be sure interrupts are off and you restore its original value at the end of your code.

Wii games will use r13 as a pointer when it needs to reference important or common constants. Like for Super Smash Bros, r13 minus 32400 points to the ascii byte of "r" which is used for SD file writing and r13 minus 32384 points to ascii byte of "w" for SD file reading. Knowing this can cut down on code size because you won't need to write out "w" or "r" in a custom table.

Example code using r13 - https://mariokartwii.com/nonmkwcodes/bra...ritesd.txt

For actual technical explanations, this document does a good job - http://refspecs.linux-foundation.org/elf...ec_ppc.pdf
Reply


Messages In This Thread
Purpose of r13? - by jawa - 05-08-2023, 04:59 PM
RE: Purpose of r13? - by Vega - 05-08-2023, 09:23 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)