So if you have ever done your own custom ASM code, then you are very familiar with the JAL command that allows you to call functions. You would have to go searching for the specific address every time you forgot about it, unless you just write everything yourself.
As a small side project I'm creating a file that you can include into your ASM source code, so you only have to remember the names of each function. So instead of remembering that 0x802D66C0 is the function that prints text, you can just put down @PrintXY instead.
.include "SM64Functions.txt"
// Later in the code...
LUI A2, 0x802C
ORI A2, A2, 0xB23C // Pointer to ASCII string
ORI A0, R0, 0x0028 // X position
JAL @PrintXY
ORI A1, R0, 0x0050 // Y position
Inside the file itself includes documentation on every function along with the define; so if you don't know how many arguments a function needs, or what the function returns, then you can just look it up in the file.
Spoiler :
I am hosting the file over on github, so you can add to the project if you want to. There is not a lot of functions at the moment, but I will continuously add more over time. There are hundreds of functions in SM64, so I want to only add the ones that ASM coders will find useful in multiple situations.
I added 2 more functions: @ConfigureTimer and @PlayTransition. In this post there are 2 example projects that show how to use both of these functions in-game.
The @ConfigureTimer function allows you to enable, disable, start, or stop the HUD timer.
Spoiler: Definition
/*
ConfigureTimer (0x802495E0 / 0x45E0)
Enables, disables, starts, or stops the HUD timer
Arguments:
A0 = option
- 0 = Shows timer and resets time value to zero
- 1 = Starts timer
- 2 = Stops timer
- 3 = Stops showing timer and resets time value to zero
Returns:
V0 = time value (value / 30 = time in seconds)
*/
[ConfigureTimer]: 0x002495E0
Use the D-Pad to configure the timer
D-pad Up = Enables Timer
D-pad Down = Disables Timer
D-pad Left = Starts Timer
D-pad Right = Stops Timer
*/ .org0x3D00000 ADDIUSP, SP, $FFE8 SWRA, $0014(SP)
The @PlayTransition function is used by the game's warp system to play a transition animation when mario goes to another level/area. The arguments of this function change which image is used and what RGB color to use for the background. Now this function has nothing to do with warps, but instead the transition animation that goes with warping. After the transition animation is completed, you will need to set the byte at 0x8033BAB3 to 0 to clear the screen.
Spoiler: Definition
/*
PlayTransition (0x8027B1A0 / 0x0361A0)
Plays a transition on the screen.
Arguments:
A0 = Image
- 0x01 = No image (fade to color)
- 0x09 = Star image
- 0x0B = Circle image
- 0x11 = Mario face image
- 0x13 = Bowser image
A1 = amount of time for transition to complete
A2 = red color amount (0x00 to 0xFF)
A3 = green color amount (0x00 to 0xFF)
SP + 0x10 = blue color amount (0x00 to 0xFF)
Note:
After the transition has been played, the screen will be filled up
with whatever color you chose. To fix this, detect if the byte at
0x8033BAB3 is equal to 1. If it is 1, then set that value to zero.
*/
[PlayTransition]: 0x0027B1A0
ADDIUT9, R0, 0xFF// Blue color amount SWT9, 0x10(SP) ADDIUA0, R0, 0x11// Fade image type /*
0x01 = No image (fade to color)
0x09 = Star image
0x0B = Circle image
0x11 = Mario face image
0x13 = Bowser image
*/ ADDIUA1, R0, 0x40// Timer (How long the effect will last) ADDIUA2, R0, 0x7F// Red color amount JAL@PlayTransition ADDIUA3, R0, 0x00// Green color amount
807F0000_PATH2: LUIT1, 0x8034 SBR0, 0xBAB3(T1)// When the effect is done, clear the screen.