From de121b141dde5f87a7af748dab9c931a675bd933 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 28 Nov 2019 22:10:29 +1000 Subject: [PATCH] Attempt to decompile aiSpeak --- src/game/chr/chraicommands.c | 41 +++++++++++++++++++++++++++- src/include/game/chr/chraicommands.h | 2 +- src/include/game/game_16cfa0.h | 2 +- src/setup/setup_000000.c | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 90965f595..4580c8d70 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -6359,7 +6359,7 @@ bool aiShowText2(void) * @cmd 00cd */ GLOBAL_ASM( -glabel ai00cd +glabel aiSpeak /* f056040: 27bdffb8 */ addiu $sp,$sp,-72 /* f056044: afb10020 */ sw $s1,0x20($sp) /* f056048: 3c11800a */ lui $s1,%hi(g_Vars) @@ -6479,6 +6479,45 @@ glabel ai00cd /* f0561f4: 00001025 */ or $v0,$zero,$zero ); +// Mismatch due to different registers +//bool aiSpeak(void) +//{ +// u8 *cmd = g_Vars.ailist + g_Vars.aioffset; +// struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); +// s16 audio_id = cmd[6] | (cmd[5] << 8); +// s16 text_id = cmd[4] | (cmd[3] << 8); +// s32 prevplayernum = g_Vars.currentplayernum; +// s32 playernum = g_Vars.currentplayernum; +// u32 audioref; +// char *text = text_id >= 0 ? textGet(text_id) : NULL; +// +// if (chr && chr->pos && chr->pos->type == POSITIONTYPE_PLAYER) { +// playernum = posGetPlayerNum(chr->pos); +// } +// +// setCurrentPlayerNum(playernum); +// +// if (text && cmd[2] != CHR_P1P2) { +// func0f0926bc(g_Vars.chrdata->pos, 9, 0xffff); +// } +// +// if (cmd[2] == CHR_P1P2) { +// audioref = audioPlayFromWorldPosition(cmd[7], audio_id, 0, g_Vars.chrdata->pos, 0, 512); +// } else { +// audioref = audioPlayFromWorldPosition(cmd[7], audio_id, 0, g_Vars.chrdata->pos, 9, 512); +// } +// +// if (text && !audioIsFiltered(audio_id)) { +// func0f0de160(text, 6, cmd[8], audioref); +// } +// +// setCurrentPlayerNum(prevplayernum); +// +// g_Vars.aioffset += 9; +// +// return false; +//} + /** * @cmd 00ce */ diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index f5d3fd8a6..206becddd 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -207,7 +207,7 @@ /*0x00ca*/ bool aiDuplicateChr(void); /*0x00cb*/ bool aiMessage(void); /*0x00cc*/ bool aiShowText2(void); -/*0x00cd*/ bool ai00cd(void); +/*0x00cd*/ bool aiSpeak(void); /*0x00ce*/ bool aiPlaySound(void); /*0x00cf*/ bool ai00cf(void); /*0x00d0*/ bool ai00d0(void); diff --git a/src/include/game/game_16cfa0.h b/src/include/game/game_16cfa0.h index 1388a7c89..1f57fead7 100644 --- a/src/include/game/game_16cfa0.h +++ b/src/include/game/game_16cfa0.h @@ -47,6 +47,6 @@ s32 textGetFileId(s32 bank); void textSetBankSimple(s32 bank); void textSetBank(s32 bank, s32 arg1, s32 arg2); void textClearBank(s32 bank); -char *textGet(u32 textid); +char *textGet(s32 textid); #endif diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index dd1940490..77cdc5fd5 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14337,7 +14337,7 @@ bool (*g_CommandPointers[])(void) = { /*0x00ca*/ aiDuplicateChr, /*0x00cb*/ aiMessage, /*0x00cc*/ aiShowText2, - /*0x00cd*/ ai00cd, + /*0x00cd*/ aiSpeak, /*0x00ce*/ aiPlaySound, /*0x00cf*/ ai00cf, /*0x00d0*/ ai00d0,