ai2asm: Store current chr in s0 instead of repeatedly loading it from g_Vars.chrdata

This commit is contained in:
Ryan Dwyer 2023-05-11 17:20:15 +10:00
parent 6edc8681da
commit c24afbddb8
5 changed files with 1158 additions and 1265 deletions

View File

@ -51,7 +51,7 @@
#include "lib/snd.h"
#include "types.h"
u8 *aiTick(u8 *ptr);
u8 *aiTick(u8 *ptr, struct chrdata *chr);
void chraiExecute(void *entity, s32 proptype)
{
@ -136,7 +136,7 @@ void chraiExecute(void *entity, s32 proptype)
}
// Execute the ailist
cmd = aiTick(cmd);
cmd = aiTick(cmd, g_Vars.chrdata);
if (g_Vars.chrdata) {
g_Vars.chrdata->aioffset = cmd;
@ -146,19 +146,19 @@ void chraiExecute(void *entity, s32 proptype)
}
}
void aiTerminateCleanup(void)
void aiTerminateCleanup(struct chrdata *chr)
{
if (g_Vars.chrdata) {
g_Vars.chrdata->ailist = NULL;
if (chr) {
chr->ailist = NULL;
if (g_Vars.chrdata->model == NULL) {
if (chr->model == NULL) {
// It's a BG chr (1xxx script).
// Remove ourselves from the BG chrs array and shift the later ones back.
s32 myindex = -1;
s32 i;
for (i = 0; i < g_NumBgChrs; i++) {
if (g_Vars.chrdata == &g_BgChrs[i]) {
if (chr == &g_BgChrs[i]) {
myindex = i;
break;
}

View File

@ -17,25 +17,30 @@
* the next AI tick for this chr, while aiTerminate returns NULL.
*
* Stack usage:
* 0x20 = saved $ra
* 0x00 through 0x1c = function arguments used in AI code
* 0x28 = saved $s0
* 0x24 = saved $ra
* 0x00 through 0x20 = function arguments used in AI code
*/
glabel aiTick
addiu $sp, $sp, -0x28
addiu $sp, $sp, -0x30
sw $s0, 0x28($sp)
move $s0, $a1
jr $a0
sw $ra, 0x20($sp)
sw $ra, 0x24($sp)
glabel aiYield
move $v0, $ra
lw $ra, 0x20($sp)
lw $s0, 0x28($sp)
lw $ra, 0x24($sp)
jr $ra
addiu $sp, $sp, 0x28
addiu $sp, $sp, 0x30
glabel aiTerminate
jal aiTerminateCleanup
nop
move $a0, $s0
move $v0, $zero
lw $ra, 0x20($sp)
lw $s0, 0x28($sp)
lw $ra, 0x24($sp)
jr $ra
addiu $sp, $sp, 0x28
addiu $sp, $sp, 0x30

File diff suppressed because it is too large Load Diff

View File

@ -3249,8 +3249,8 @@
*/
#define set_chr_dodge_rating(value, whichprop) \
mkshort(0x01c6), \
value, \
whichprop,
whichprop, \
value,
/**
* This doesn't appear to be used.

File diff suppressed because it is too large Load Diff