From 1921997a60dcef250d228322585198ac609a8a22 Mon Sep 17 00:00:00 2001 From: Elliptic Ellipsis Date: Sat, 25 Sep 2021 15:03:48 +0100 Subject: [PATCH 01/82] Add Tharo's documentation comments --- src/libultra/voice/voicecheckword.c | 1 + src/libultra/voice/voicecleardictionary.c | 1 + src/libultra/voice/voicecontrolgain.c | 1 + src/libultra/voice/voicegetreaddata.c | 1 + src/libultra/voice/voiceinit.c | 1 + src/libultra/voice/voicemaskdictionary.c | 1 + src/libultra/voice/voicesetword.c | 1 + src/libultra/voice/voicestartreaddata.c | 1 + src/libultra/voice/voicestopread.c | 1 + 9 files changed, 9 insertions(+) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 8b5ac0dfb..4da8d5a00 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -1,3 +1,4 @@ #include "global.h" +// Checks whether or not a word can be registered in the dictionary #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckword/osVoiceCheckWord.s") diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 29766bb2a..d6278d3fa 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -1,3 +1,4 @@ #include "global.h" +// Initializes Voice Recognition System word registration dictionary #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecleardictionary/osVoiceClearDictionary.s") diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index 9dc541cc5..d4020e605 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -1,3 +1,4 @@ #include "global.h" +// Adjusts the input gain of the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontrolgain/osVoiceControlGain.s") diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 5940a1f8b..c0987c151 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -1,3 +1,4 @@ #include "global.h" +// Gets voice recognition result from the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicegetreaddata/osVoiceGetReadData.s") diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 920bc4818..69fd1e36e 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -1,3 +1,4 @@ #include "global.h" +// Initializes Voice Recognition System control structure and hardware #pragma GLOBAL_ASM("asm/non_matchings/boot/voiceinit/osVoiceInit.s") diff --git a/src/libultra/voice/voicemaskdictionary.c b/src/libultra/voice/voicemaskdictionary.c index 3de841de3..e82a27b81 100644 --- a/src/libultra/voice/voicemaskdictionary.c +++ b/src/libultra/voice/voicemaskdictionary.c @@ -1,3 +1,4 @@ #include "global.h" +// Mask words registered in the voice recognition system #pragma GLOBAL_ASM("asm/non_matchings/boot/voicemaskdictionary/osVoiceMaskDictionary.s") diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index e50f26874..dbc1a6df6 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -1,3 +1,4 @@ #include "global.h" +// Registers words to the Voice Recognition System dictionary #pragma GLOBAL_ASM("asm/non_matchings/boot/voicesetword/osVoiceSetWord.s") diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index e7105a7d4..118cc3f60 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -1,3 +1,4 @@ #include "global.h" +// Start voice recognition by the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicestartreaddata/osVoiceStartReadData.s") diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index f032fc40e..16ecddef8 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -1,3 +1,4 @@ #include "global.h" +// Forcibly stops voice recognition processing by the Voice Recognition System #pragma GLOBAL_ASM("asm/non_matchings/boot/voicestopread/osVoiceStopReadData.s") From d70906fee7bcb51433bac4df78b660ee7559d974 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 16:29:33 +1100 Subject: [PATCH 02/82] Voice progress --- include/functions.h | 14 +++++----- include/os.h | 10 +++++++ src/libultra/voice/voicecheckresult.c | 20 +++++++++++++- src/libultra/voice/voicecleardictionary.c | 31 +++++++++++++++++++++- src/libultra/voice/voicecrc.c | 32 ++++++++++++++++++++++- 5 files changed, 97 insertions(+), 10 deletions(-) diff --git a/include/functions.h b/include/functions.h index 367d784ae..fab8136ba 100644 --- a/include/functions.h +++ b/include/functions.h @@ -355,11 +355,11 @@ void guLookAtHiliteF(float mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f void guLookAtHilite(Mtx* m, LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, f32 xl2, f32 yl2, f32 zl2, s32 twidth, s32 theight); s32 _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap); void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); -// void osVoiceClearDictionary(void); +s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words); void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -// void __osVoiceContRead2(void); -// void __osVoiceContDataCrc(void); +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, s32, u8 dst[2]); +u8 __osVoiceContDataCrc(u8* data, u32 arg1); const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); void* memcpy(void* __dest, const void* __src, size_t __n); @@ -388,7 +388,7 @@ OSTime osGetTime(void); void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); -// void osVoiceInit(void); +s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel); // void __osContChannelReset(void); // void __osVoiceSetADConverter(void); s32 osAiSetFrequency(u32 frequency); @@ -418,7 +418,7 @@ f32 __cosf(f32 __x); void osViSetSpecialFeatures(u32 func); s16 coss(u16 x); void osSetTime(OSTime ticks); -// void osVoiceStopReadData(void); +s32 osVoiceStopReadData(OSVoiceHandle* hd); void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount); s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern); // void __osPfsRequestData(void); @@ -473,11 +473,11 @@ float __ll_to_f(long long l); double __ull_to_d(unsigned long long l); float __ull_to_f(unsigned long long l); // void osVoiceCheckWord(void); -// void osVoiceControlGain(void); +s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital); // void osVoiceStartReadData(void); void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); -// void __osVoiceContWrite4(void); +// s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); // void __osSetHWIntrRoutine(void); u32 __osGetWatchLo(void); diff --git a/include/os.h b/include/os.h index 50f3b10c4..cdfa49c91 100644 --- a/include/os.h +++ b/include/os.h @@ -131,4 +131,14 @@ typedef struct { /* 0xC */ u8 status; } OSVoiceHandle; // size = 0x10 +typedef struct { + /* 0x00 */ u16 warning; /* Warning */ + /* 0x02 */ u16 answer_num; /* Candidate number (0~5) */ + /* 0x04 */ u16 voice_level; /* Voice input level */ + /* 0x06 */ u16 voice_sn; /* Relative voice level */ + /* 0x08 */ u16 voice_time; /* Voice input time */ + /* 0x0A */ u16 answer[5]; /* Candidate word number */ + /* 0x14 */ u16 distance[5]; /* Distance value */ +} OSVoiceData; // size = 0x20 + #endif diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index 44fb69be5..bd4060a37 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -1,3 +1,21 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckresult/__osVoiceCheckResult.s") +s32 __osVoiceCheckResult(OSVoiceHandle* handle, u8* status) { + s32 phi_v1; + u8 sp20[2]; + + if (phi_v1 = __osVoiceGetStatus(handle->mq, handle->port, status), phi_v1 == 0) { + if (*status & 1) { + phi_v1 = 0xF; + } else if (phi_v1 = __osVoiceContRead2(handle->mq, handle->port, 0, sp20), phi_v1 == 0) { + handle->status = sp20[0] & 7; + + if (sp20[0] & 0x40) { + phi_v1 = 0xF; + } else { + phi_v1 = sp20[1] << 8; + } + } + } + return phi_v1; +} diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index d6278d3fa..4de1eef59 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -1,4 +1,33 @@ #include "global.h" // Initializes Voice Recognition System word registration dictionary -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecleardictionary/osVoiceClearDictionary.s") +s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { + u8* registration_word; + u8 status; + s32 sp24; + s32 temp_v0; + + temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (temp_v0 != 0) { + return temp_v0; + } + + registration_word = &sp24; + if (status & 2) { + return 0xF; + } + + sp24 = 0x2000000; + registration_word[2] = words; + + temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); + if (temp_v0 != 0) { + return temp_v0; + } + + temp_v0 = __osVoiceCheckResult(hd, &status); + if ((temp_v0 & 0xFF00) != 0) { + temp_v0 = 5; + } + return temp_v0; +} diff --git a/src/libultra/voice/voicecrc.c b/src/libultra/voice/voicecrc.c index cc23e89dd..e1530fcb8 100644 --- a/src/libultra/voice/voicecrc.c +++ b/src/libultra/voice/voicecrc.c @@ -1,3 +1,33 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecrc/__osVoiceContDataCrc.s") +u8 __osVoiceContDataCrc(u8* data, u32 arg1) { + u32 bit; + u32 byte; + u32 ret = 0; + + for (byte = arg1; byte > 0; byte--) { + for (bit = 0x80; bit > 0; bit >>= 1) { + ret <<= 1; + if (*data & bit) { + if (ret & 0x100) { + ret ^= 0x84; + } else { + ret++; + } + } else if (ret & 0x100) { + ret ^= 0x85; + } + } + data++; + } + + do { + ret <<= 1; + if (ret & 0x100) { + ret ^= 0x85; + } + byte++; + } while (byte < 8); + + return ret; +} From 357ee948bb6f43f80ad988e2e306b71f47db673f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:32:28 +1100 Subject: [PATCH 03/82] Match osVoiceControlGain --- include/functions.h | 4 +-- src/libultra/voice/voicecontrolgain.c | 37 ++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index fab8136ba..431376e1e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -390,7 +390,7 @@ void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel); // void __osContChannelReset(void); -// void __osVoiceSetADConverter(void); +s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2, OSVoiceHandle* hd); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); // void __osVoiceContWrite20(void); @@ -477,7 +477,7 @@ s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital); // void osVoiceStartReadData(void); void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); -// s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); +s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); // void __osSetHWIntrRoutine(void); u32 __osGetWatchLo(void); diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index d4020e605..cfca63fbb 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -1,4 +1,39 @@ #include "global.h" +extern u8 D_80098180[]; + // Adjusts the input gain of the Voice Recognition System -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontrolgain/osVoiceControlGain.s") +s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { + s32 ret; + u8 phi_a2; + + + if (analog == 0) { + phi_a2 = 0x18; + } else { + phi_a2 = 0x98; + } + + ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (ret != 0) { + return ret; + } + + if (!((digital < 8) && (digital >= 0))){ + goto dummy; + } + + phi_a2 = D_80098180[digital] + 2; + + if (0) { + dummy: + return 5; + } + + ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (ret != 0) { + return ret; + } + + return ret; +} From 6cbf9734a7dbfb8997a79033fbca7565642d8117 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:43:53 +1100 Subject: [PATCH 04/82] Match osVoiceStartReadData --- include/functions.h | 6 ++--- src/libultra/voice/voicecheckresult.c | 8 +++--- src/libultra/voice/voicestartreaddata.c | 33 ++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/include/functions.h b/include/functions.h index 431376e1e..b0b68959d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -280,7 +280,7 @@ void __osDispatchThread(void); void __osCleanupThread(void); void __osDequeueThread(OSThread** param_1, OSThread* param_2); void osDestroyThread(OSThread* puParm1); -// void __osVoiceCheckResult(void); +s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status); void bzero(void* begin, s32 length); // void osSetRumble(void); // void osSetUpMempakWrite(void); @@ -473,8 +473,8 @@ float __ll_to_f(long long l); double __ull_to_d(unsigned long long l); float __ull_to_f(unsigned long long l); // void osVoiceCheckWord(void); -s32 osVoiceControlGain(OSVoiceHandle *hd, s32 analog, s32 digital); -// void osVoiceStartReadData(void); +s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); +s32 osVoiceStartReadData(OSVoiceHandle* hd); void* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* data); s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index bd4060a37..a20c88461 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -1,14 +1,14 @@ #include "global.h" -s32 __osVoiceCheckResult(OSVoiceHandle* handle, u8* status) { +s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { s32 phi_v1; u8 sp20[2]; - if (phi_v1 = __osVoiceGetStatus(handle->mq, handle->port, status), phi_v1 == 0) { + if (phi_v1 = __osVoiceGetStatus(hd->mq, hd->port, status), phi_v1 == 0) { if (*status & 1) { phi_v1 = 0xF; - } else if (phi_v1 = __osVoiceContRead2(handle->mq, handle->port, 0, sp20), phi_v1 == 0) { - handle->status = sp20[0] & 7; + } else if (phi_v1 = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), phi_v1 == 0) { + hd->status = sp20[0] & 7; if (sp20[0] & 0x40) { phi_v1 = 0xF; diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 118cc3f60..809ee805e 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -1,4 +1,35 @@ #include "global.h" // Start voice recognition by the Voice Recognition System -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicestartreaddata/osVoiceStartReadData.s") +s32 osVoiceStartReadData(OSVoiceHandle* hd) { + s32 temp_v0; + u8 sp2B; + s32 sp24; + + temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); + if (temp_v0 != 0) { + return temp_v0; + } + + if ((sp2B & 2) != 0) { + return 0xF; + } + + if (hd->mode != 0) { + return 5; + } + + sp24 = 0x5000000; + temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + + if (temp_v0 == 0) { + temp_v0 = __osVoiceCheckResult(hd, &sp2B); + if ((temp_v0 & 0xFF00) != 0) { + temp_v0 = 5; + } else { + hd->mode = 1; + } + } + + return temp_v0; +} From d1225a5634892d15e770e6aa1fc6c4852c1afdc0 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:45:24 +1100 Subject: [PATCH 05/82] Cleanup --- src/libultra/voice/voicestartreaddata.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 809ee805e..e0e696749 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -2,13 +2,13 @@ // Start voice recognition by the Voice Recognition System s32 osVoiceStartReadData(OSVoiceHandle* hd) { - s32 temp_v0; + s32 ret; u8 sp2B; s32 sp24; - temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); - if (temp_v0 != 0) { - return temp_v0; + ret = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); + if (ret != 0) { + return ret; } if ((sp2B & 2) != 0) { @@ -20,16 +20,17 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } sp24 = 0x5000000; - temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + ret = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); - if (temp_v0 == 0) { - temp_v0 = __osVoiceCheckResult(hd, &sp2B); - if ((temp_v0 & 0xFF00) != 0) { - temp_v0 = 5; + if (ret == 0) { + ret = __osVoiceCheckResult(hd, &sp2B); + + if ((ret & 0xFF00) != 0) { + ret = 5; } else { hd->mode = 1; } } - return temp_v0; + return ret; } From 3c76274078fb3226d8b2327f080eeceebf08f403 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 7 Nov 2021 21:24:58 +1100 Subject: [PATCH 06/82] Add docs from n64devkit --- include/functions.h | 8 ++++---- include/os.h | 17 ++++++++++++++++ src/libultra/voice/voicecheckresult.c | 14 ++++++------- src/libultra/voice/voicecleardictionary.c | 23 +++++++++++----------- src/libultra/voice/voicecontrolgain.c | 16 +++++++-------- src/libultra/voice/voicestartreaddata.c | 24 +++++++++++------------ 6 files changed, 60 insertions(+), 42 deletions(-) diff --git a/include/functions.h b/include/functions.h index d915a3e7d..23c537f0b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -245,7 +245,7 @@ void osStopThread(OSThread* t); s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags); OSIntMask osSetIntMask(OSIntMask im); // OSIntMask osGetIntMask(void); -// void osVoiceSetWord(void); +s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word); // void guScale(void); f32 __sinf(f32 __x); s16 sins(u16 x); @@ -287,7 +287,7 @@ void osCreateThread(OSThread* t, OSId id, void* entry, void* arg, void* sp, OSPr s32 osContStartReadData(OSMesgQueue* mq); void osContGetReadData(OSContPad* data); void __osPackReadData(void); -// void osVoiceGetReadData(void); +s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result); uintptr_t osVirtualToPhysical(void* vaddr); u32 __osGetSR(void); void __osSetSR(u32 value); @@ -452,7 +452,7 @@ void viMgrMain(OSDevMgr* iParm1); __OSViContext* __osViGetCurrentContext(void); void osWritebackDCacheAll(void); OSThread* __osGetCurrFaultedThread(void); -// void osVoiceMaskDictionary(void); +s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size); void guMtxF2L(float mf[4][4], Mtx* m); void osStartThread(OSThread* param_1); void osViSetYScale(f32 value); @@ -465,7 +465,7 @@ double __ll_to_d(long long l); float __ll_to_f(long long l); double __ull_to_d(unsigned long long l); float __ull_to_f(unsigned long long l); -// void osVoiceCheckWord(void); +s32 osVoiceCheckWord(u8* word); s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); s32 osVoiceStartReadData(OSVoiceHandle* hd); void* osViGetCurrentFramebuffer(void); diff --git a/include/os.h b/include/os.h index 47a419d6b..1a4712bff 100644 --- a/include/os.h +++ b/include/os.h @@ -122,6 +122,23 @@ typedef struct { /* 0xC */ u32* text_end; } OSProf; // size = 0x10 +#define VOICE_STATUS_READY 0 /* stop/end */ +#define VOICE_STATUS_START 1 /* Voice Undetected (no voice input) */ +#define VOICE_STATUS_CANCEL 3 /* Cancel (cancel extraneous noise) */ +#define VOICE_STATUS_BUSY 5 /* Detected/Detecting (voice being input, recognition processing under way) */ +#define VOICE_STATUS_END 7 /* End recognition processing (enable execution of Get Recognition Results command) */ + +#define VOICE_WARN_TOO_SMALL 0x400 /* Voice level is too low (100 < Voice Level < 150) */ +#define VOICE_WARN_TOO_LARGE 0x800 /* Voice level is too high (Voice Level > 3500) */ +#define VOICE_WARN_NOT_FIT 0x4000 /* No words match recognition word (No. 1 Candidate Distance Value > 1600) */ +#define VOICE_WARN_TOO_NOISY 0x8000 /* Too much ambient noise (Relative Voice Level =< 400) */ + +// #define CONT_ERR_NO_CONTROLLER +// #define CONT_ERR_DEVICE +// #define CONT_ERR_CONTRFAIL +// #define CONT_ERR_VOICE_NO_RESPONSE +// #define CONT_ERR_INVALID + typedef struct { /* 0x0 */ OSMesgQueue* mq; /* 0x4 */ s32 port; /* Controller port */ diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index a20c88461..97af48094 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -1,21 +1,21 @@ #include "global.h" s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { - s32 phi_v1; + s32 errorCode; u8 sp20[2]; - if (phi_v1 = __osVoiceGetStatus(hd->mq, hd->port, status), phi_v1 == 0) { + if (errorCode = __osVoiceGetStatus(hd->mq, hd->port, status), errorCode == 0) { if (*status & 1) { - phi_v1 = 0xF; - } else if (phi_v1 = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), phi_v1 == 0) { + errorCode = 0xF; + } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), errorCode == 0) { hd->status = sp20[0] & 7; if (sp20[0] & 0x40) { - phi_v1 = 0xF; + errorCode = 0xF; } else { - phi_v1 = sp20[1] << 8; + errorCode = sp20[1] << 8; } } } - return phi_v1; + return errorCode; } diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 4de1eef59..92114809d 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -5,11 +5,11 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { u8* registration_word; u8 status; s32 sp24; - s32 temp_v0; + s32 errorCode; - temp_v0 = __osVoiceGetStatus(hd->mq, hd->port, &status); - if (temp_v0 != 0) { - return temp_v0; + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (errorCode != 0) { + return errorCode; } registration_word = &sp24; @@ -20,14 +20,15 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { sp24 = 0x2000000; registration_word[2] = words; - temp_v0 = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); - if (temp_v0 != 0) { - return temp_v0; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); + if (errorCode != 0) { + return errorCode; } - temp_v0 = __osVoiceCheckResult(hd, &status); - if ((temp_v0 & 0xFF00) != 0) { - temp_v0 = 5; + errorCode = __osVoiceCheckResult(hd, &status); + if ((errorCode & 0xFF00) != 0) { + errorCode = 5; } - return temp_v0; + + return errorCode; } diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index cfca63fbb..b0a66284a 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -4,7 +4,7 @@ extern u8 D_80098180[]; // Adjusts the input gain of the Voice Recognition System s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { - s32 ret; + s32 errorCode; u8 phi_a2; @@ -14,9 +14,9 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { phi_a2 = 0x98; } - ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); - if (ret != 0) { - return ret; + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (errorCode != 0) { + return errorCode; } if (!((digital < 8) && (digital >= 0))){ @@ -30,10 +30,10 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { return 5; } - ret = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); - if (ret != 0) { - return ret; + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + if (errorCode != 0) { + return errorCode; } - return ret; + return errorCode; } diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index e0e696749..88c77dc2c 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -2,16 +2,16 @@ // Start voice recognition by the Voice Recognition System s32 osVoiceStartReadData(OSVoiceHandle* hd) { - s32 ret; - u8 sp2B; + s32 errorCode; + u8 status; s32 sp24; - ret = __osVoiceGetStatus(hd->mq, hd->port, &sp2B); - if (ret != 0) { - return ret; + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (errorCode != 0) { + return errorCode; } - if ((sp2B & 2) != 0) { + if (status & 2) { return 0xF; } @@ -20,17 +20,17 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } sp24 = 0x5000000; - ret = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); - if (ret == 0) { - ret = __osVoiceCheckResult(hd, &sp2B); + if (errorCode == 0) { + errorCode = __osVoiceCheckResult(hd, &status); - if ((ret & 0xFF00) != 0) { - ret = 5; + if (errorCode & 0xFF00) { + errorCode = 5; } else { hd->mode = 1; } } - return ret; + return errorCode; } From 11a86e2246aa4ca9161f0bc5fad5beffb341d187 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 7 Nov 2021 23:04:02 +1100 Subject: [PATCH 07/82] WIP on osVoiceGetReadData --- include/functions.h | 2 +- include/os.h | 5 +- include/variables.h | 2 +- src/libultra/voice/voicegetreaddata.c | 117 ++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 23c537f0b..0fff4f8f4 100644 --- a/include/functions.h +++ b/include/functions.h @@ -363,7 +363,7 @@ void __osTimerServicesInit(void); void __osTimerInterrupt(void); void __osSetTimerIntr(OSTime tim); OSTime __osInsertTimer(OSTimer* t); -// void __osVoiceContRead36(void); +s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, s32, u8*); s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); // void guMtxIdent(void); diff --git a/include/os.h b/include/os.h index 1a4712bff..d168d352e 100644 --- a/include/os.h +++ b/include/os.h @@ -135,9 +135,12 @@ typedef struct { // #define CONT_ERR_NO_CONTROLLER // #define CONT_ERR_DEVICE +// #define CONT_ERR_NOT_READY // #define CONT_ERR_CONTRFAIL // #define CONT_ERR_VOICE_NO_RESPONSE -// #define CONT_ERR_INVALID +// #define CONT_ERR_INVALID +// #define CONT_ERR_VOICE_WORD +// #define CONT_ERR_VOICE_MEMORY typedef struct { /* 0x0 */ OSMesgQueue* mq; diff --git a/include/variables.h b/include/variables.h index 6b5fbe620..55fe64c49 100644 --- a/include/variables.h +++ b/include/variables.h @@ -329,7 +329,7 @@ extern OSTask tmp_task; extern OSMesg siAccessBuf[1]; extern OSMesgQueue __osSiAccessQueue; -extern UNK_TYPE1 D_8009CF60; +extern u8 D_8009CF60; // extern UNK_TYPE4 D_8009CF70; extern OSThread __osThreadSave; extern OSPiHandle D_8009D130; diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index c0987c151..0bba3bac0 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -1,4 +1,121 @@ #include "global.h" // Gets voice recognition result from the Voice Recognition System +#ifdef NON_EQUIVALENT +s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { + s32 errorCode; + u8 new_var; + u8 temp_t9; + u8 sp38[40]; + s32 i; + + switch (hd->mode) { + case 1: + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (sp38[39] & 1) { + return 0xC; + } + + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + temp_t9 = sp38[0] & 7; + hd->status = temp_t9; + D_8009CF60 = temp_t9; + if ((temp_t9 != 0) && (temp_t9 != 7)) { + return 0xC; + } + case 2: + hd->mode = 2; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (0) {} + if (sp38[39] & 2) { + return 0xF; + } + + sp38[1] = 0x600; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + case 3: + hd->mode = 3; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (sp38[39] & 1) { + return 0xF; + } + + errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + result->warning = (sp38[5] << 8) + sp38[4]; + result->answer_num = sp38[6]; + result->voice_level = (sp38[9] << 8) + sp38[8]; + result->voice_sn = (sp38[11] << 8) + sp38[10]; + result->voice_time = (sp38[13] << 8) + sp38[12]; + + new_var = 4; + for (i = 0; i < 5; i++) { + result->answer[i] = (sp38[15 + new_var*i] << 8) + sp38[14 + new_var*i]; + result->distance[i] = (sp38[17 + new_var*i] << 8) + sp38[16 + new_var*i]; + } + + if (result->answer[0] == 0x7FFF) { + result->answer_num = 0; + } + + hd->status = sp38[34] & 7; + if ((D_8009CF60 == 0) || (hd->status == 0)) { + break; + } + case 4: + hd->mode = 4; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + if (errorCode != 0) { + return errorCode; + } + + if (sp38[39] & 1) { + return 0xF; + } + + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + if (errorCode != 0) { + return errorCode; + } + + hd->status = sp38[0] & 7; + if ((sp38[0] & 7) != 0) { + return 0xF; + } + + break; + default: + return 5; + } + hd->mode = 0; + return errorCode; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/boot/voicegetreaddata/osVoiceGetReadData.s") +#endif From 09a43268561c3206fd6e7929704d3825481a3fdb Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 7 Nov 2021 23:05:47 +1100 Subject: [PATCH 08/82] Add comment --- src/libultra/voice/voicegetreaddata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 0bba3bac0..c202ad27d 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -44,7 +44,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { return 0xF; } - sp38[1] = 0x600; + sp38[0] = 0x600; // Not reading in correctly since 0x600 is out-of-range for u8 errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, sp38); if (errorCode != 0) { return errorCode; From 5aa43d1c2985a6dec47672024c67a4cc9d14d621 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 00:27:05 +1100 Subject: [PATCH 09/82] Match voiceinit.c --- include/functions.h | 4 +- src/libultra/voice/voicecontrolgain.c | 4 +- src/libultra/voice/voiceinit.c | 57 ++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0fff4f8f4..5bfe48049 100644 --- a/include/functions.h +++ b/include/functions.h @@ -382,8 +382,8 @@ void guRotateF(float mf[4][4], f32 a, f32 x, f32 y, f32 z); void guRotate(Mtx* m, f32 a, f32 x, f32 y, f32 z); void __osSetGlobalIntMask(u32 mask); s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel); -// void __osContChannelReset(void); -s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2, OSVoiceHandle* hd); +s32 __osContChannelReset(OSMesgQueue* mq, s32 count); +s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); // void __osVoiceContWrite20(void); diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index b0a66284a..251dc1144 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -14,7 +14,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { phi_a2 = 0x98; } - errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); if (errorCode != 0) { return errorCode; } @@ -30,7 +30,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { return 5; } - errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2, hd); + errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 69fd1e36e..50dab4fdc 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -1,4 +1,59 @@ #include "global.h" +extern u8 D_80097FA0; +extern u8 D_80097FA5; + // Initializes Voice Recognition System control structure and hardware -#pragma GLOBAL_ASM("asm/non_matchings/boot/voiceinit/osVoiceInit.s") +s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { + s32 errorCode; + u8* phi_s0; + u8 sp37 = 0; + s32 sp30; + s32 pad; + + hd->port = channel; + hd->mq = siMessageQ; + hd->mode = 0; + + errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + if (errorCode != 0) { + return errorCode; + } + + if (__osContChannelReset(siMessageQ, channel) != 0) { + return 4; + } + + for (phi_s0 = &D_80097FA0;;) { + errorCode = __osVoiceSetADConverter(siMessageQ, channel, *phi_s0); + + phi_s0++; + if (errorCode != 0) { + return errorCode; + } + + if (phi_s0 == &D_80097FA5) { + errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + if (errorCode != 0) { + return errorCode; + } + if ((sp37 & 2) != 0) { + return 0xF; + } + + sp30 = 0x100; + errorCode = __osVoiceContWrite4(siMessageQ, channel, 0, &sp30); + if (errorCode != 0) { + return errorCode; + } + + errorCode = __osVoiceCheckResult(hd, &sp37); + if (errorCode & 0xFF00) { + errorCode = 5; + } + + return errorCode; + } + } +} + From 23d3f1980eab2f755e887826be61224525f360da Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 00:31:03 +1100 Subject: [PATCH 10/82] Remove CONT_ERR, already present in controller.h --- include/os.h | 9 --------- src/libultra/voice/voiceinit.c | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/include/os.h b/include/os.h index d168d352e..82e1ac013 100644 --- a/include/os.h +++ b/include/os.h @@ -133,15 +133,6 @@ typedef struct { #define VOICE_WARN_NOT_FIT 0x4000 /* No words match recognition word (No. 1 Candidate Distance Value > 1600) */ #define VOICE_WARN_TOO_NOISY 0x8000 /* Too much ambient noise (Relative Voice Level =< 400) */ -// #define CONT_ERR_NO_CONTROLLER -// #define CONT_ERR_DEVICE -// #define CONT_ERR_NOT_READY -// #define CONT_ERR_CONTRFAIL -// #define CONT_ERR_VOICE_NO_RESPONSE -// #define CONT_ERR_INVALID -// #define CONT_ERR_VOICE_WORD -// #define CONT_ERR_VOICE_MEMORY - typedef struct { /* 0x0 */ OSMesgQueue* mq; /* 0x4 */ s32 port; /* Controller port */ diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 50dab4fdc..54e13fa4c 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -37,7 +37,7 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { if (errorCode != 0) { return errorCode; } - if ((sp37 & 2) != 0) { + if (sp37 & 2) { return 0xF; } From b0c4073267b8a97b8fdf09a44287c64ad6e71fb9 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 01:03:04 +1100 Subject: [PATCH 11/82] Really close to matching osVoiceStopReadData --- src/libultra/voice/voicestopread.c | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 16ecddef8..d7dad3291 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -1,4 +1,52 @@ #include "global.h" // Forcibly stops voice recognition processing by the Voice Recognition System +#ifdef NON_EQUIVALENT +s32 osVoiceStopReadData(OSVoiceHandle* hd) { + s32 i; + s32 errorCode; + u8 sp3F; + s32 sp38; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp3F); + if (errorCode != 0) { + return errorCode; + } + + if (sp3F & 2) { + return 0xF; + } + + if (hd->mode == 0) { + return 5; + } + + sp38 = 0x700; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp38); + + if (errorCode == 0) { + for (i = 0; i < 20; i++) { + errorCode = __osVoiceCheckResult(hd, &sp3F); + if (errorCode & 0xFF00) { + if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) { + if (hd) {} + errorCode = 0; + hd->mode = 0; + } else { + errorCode = 5; + } + } else { + hd->mode = 0; + } + + if (errorCode != 0xF) { + break; + } + } + } + + return errorCode; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/boot/voicestopread/osVoiceStopReadData.s") +#endif From 1647f42c3dc36cf2eef2cd1f75dcd678a306c025 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 8 Nov 2021 19:13:20 +1100 Subject: [PATCH 12/82] Progress on voicecheckword --- src/libultra/voice/voicecheckword.c | 101 ++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 4da8d5a00..78b835579 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -1,4 +1,105 @@ #include "global.h" // Checks whether or not a word can be registered in the dictionary +#ifdef NON_EQUIVALENT +s32 osVoiceCheckWord(u8* word) { + s32 i; + s32 errorCode = 0; + u16 currentWord; // currentLetter? currentSyllable? + u16 new_var; + + for (i = 0; word[i] != 0; i += 2) { + new_var = word[i]; // Fake? But helps? + currentWord = word[i + 1] + (new_var << 8); + if (((currentWord != 0x815B) && (currentWord < 0x829F)) || + ((currentWord >= 0x82F2) && (currentWord < 0x8340)) || (currentWord == 0x837F) || (currentWord >= 0x8397)) { + errorCode = 0xE; + } else if ((i == 0) && ((currentWord == 0x815B) || (currentWord == 0x82F1) || (currentWord == 0x82C1) || + (currentWord == 0x82EC) || (currentWord == 0x8393) || (currentWord == 0x8362) || + (currentWord == 0x838E) || (currentWord == 0x8395) || (currentWord == 0x8396))) { + errorCode = 0xE; + } else if (((currentWord == 0x829F) || (currentWord == 0x8340)) && (currentWord != 0x82D3) && + (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A1) || (currentWord == 0x8342)) && (currentWord != 0x82A4) && + (currentWord != 0x82C4) && (currentWord != 0x82C5) && (currentWord != 0x82D3) && + (currentWord != 0x8345) && (currentWord != 0x8365) && (currentWord != 0x8366) && + (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A3) || (currentWord == 0x8344)) && (currentWord != 0x82C6) && + (currentWord != 0x82C7) && (currentWord != 0x82D3) && (currentWord != 0x8367) && + (currentWord != 0x8368) && (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A5) || (currentWord == 0x8346)) && (currentWord != 0x82A4) && + (currentWord != 0x82B5) && (currentWord != 0x82B6) && (currentWord != 0x82BF) && + (currentWord != 0x82C0) && (currentWord != 0x82C2) && (currentWord != 0x82D3) && + (currentWord != 0x8345) && (currentWord != 0x8356) && (currentWord != 0x8357) && + (currentWord != 0x8360) && (currentWord != 0x8361) && (currentWord != 0x8363) && + (currentWord != 0x8374) && (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82A7) || (currentWord == 0x8348)) && (currentWord != 0x82A4) && + (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8374) && + (currentWord != 0x8394)) { + errorCode = 0xE; + } else if (((currentWord == 0x82E1) || (currentWord == 0x82E3) || (currentWord == 0x82E5) || + (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387)) && + (currentWord != 0x82AB) && (currentWord != 0x82B5) && (currentWord != 0x82BF) && + (currentWord != 0x82C9) && (currentWord != 0x82D0) && (currentWord != 0x82DD) && + (currentWord != 0x82E8) && (currentWord != 0x82AC) && (currentWord != 0x82B6) && + (currentWord != 0x82C0) && (currentWord != 0x82D1) && (currentWord != 0x82D2) && + (currentWord != 0x834C) && (currentWord != 0x8356) && (currentWord != 0x8360) && + (currentWord != 0x836A) && (currentWord != 0x8371) && (currentWord != 0x837E) && + (currentWord != 0x838A) && (currentWord != 0x834D) && (currentWord != 0x8357) && + (currentWord != 0x8361) && (currentWord != 0x8372) && (currentWord != 0x8373) && + (currentWord != 0x8394)) { + errorCode = 0xE; + } else if ((currentWord == 0x815B) && ((currentWord == 0x82F1) || (currentWord == 0x82C1) || + (currentWord == 0x8393) || (currentWord == 0x8362))) { + errorCode = 0xE; + } else if (((currentWord == 0x82F1) || (currentWord == 0x8393)) && + ((currentWord == 0x82F1) || (currentWord == 0x8393))) { + errorCode = 0xE; + } else if (((currentWord == 0x82C1) || (currentWord == 0x8362)) && + ((currentWord == 0x815B) || (currentWord == 0x82A0) || (currentWord == 0x82A2) || + (currentWord == 0x82A4) || (currentWord == 0x82A6) || (currentWord == 0x82A8) || + (currentWord == 0x82C8) || (currentWord == 0x82C9) || (currentWord == 0x82CA) || + (currentWord == 0x82CB) || (currentWord == 0x82CC) || (currentWord == 0x82DC) || + (currentWord == 0x82DD) || (currentWord == 0x82DE) || (currentWord == 0x82DF) || + (currentWord == 0x82E0) || (currentWord == 0x82E2) || (currentWord == 0x82E4) || + (currentWord == 0x82E6) || (currentWord == 0x82E7) || (currentWord == 0x82E8) || + (currentWord == 0x82E9) || (currentWord == 0x82EA) || (currentWord == 0x82EB) || + (currentWord == 0x82ED) || (currentWord == 0x82EE) || (currentWord == 0x82EF) || + (currentWord == 0x82F0) || (currentWord == 0x82F1) || (currentWord == 0x829F) || + (currentWord == 0x82A1) || (currentWord == 0x82A3) || (currentWord == 0x82A5) || + (currentWord == 0x82A7) || (currentWord == 0x82E1) || (currentWord == 0x82E3) || + (currentWord == 0x82E5) || (currentWord == 0x82C1) || (currentWord == 0x82EC) || + (currentWord == 0x8341) || (currentWord == 0x8343) || (currentWord == 0x8345) || + (currentWord == 0x8347) || (currentWord == 0x8349) || (currentWord == 0x8369) || + (currentWord == 0x836A) || (currentWord == 0x836B) || (currentWord == 0x836C) || + (currentWord == 0x836D) || (currentWord == 0x837D) || (currentWord == 0x837E) || + (currentWord == 0x8380) || (currentWord == 0x8381) || (currentWord == 0x8382) || + (currentWord == 0x8384) || (currentWord == 0x8386) || (currentWord == 0x8388) || + (currentWord == 0x8389) || (currentWord == 0x838A) || (currentWord == 0x838B) || + (currentWord == 0x838C) || (currentWord == 0x838D) || (currentWord == 0x838F) || + (currentWord == 0x8390) || (currentWord == 0x8391) || (currentWord == 0x8392) || + (currentWord == 0x8393) || (currentWord == 0x8340) || (currentWord == 0x8342) || + (currentWord == 0x8344) || (currentWord == 0x8346) || (currentWord == 0x8348) || + (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387) || + (currentWord == 0x8362) || (currentWord == 0x838E))) { + errorCode = 0xE; + } + + if (errorCode != 0) { + return errorCode; + } + } + + if ((currentWord == 0x82C1) || (currentWord == 0x8362)) { + errorCode = 0xE; + } + + return errorCode; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckword/osVoiceCheckWord.s") +#endif From 5459a9e781791eea6138ac79a22ff3a49b5aa62a Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 00:06:50 +1100 Subject: [PATCH 13/82] Match osVoiceSetWord --- include/functions.h | 2 +- src/libultra/voice/voicesetword.c | 58 ++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index 5bfe48049..f05849d92 100644 --- a/include/functions.h +++ b/include/functions.h @@ -386,7 +386,7 @@ s32 __osContChannelReset(OSMesgQueue* mq, s32 count); s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); -// void __osVoiceContWrite20(void); +s32 __osVoiceContWrite20(OSMesgQueue*, s32, u8, u8*); u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); OSThread* __osGetActiveQueue(void); diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index dbc1a6df6..83cf97516 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -1,4 +1,60 @@ #include "global.h" // Registers words to the Voice Recognition System dictionary -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicesetword/osVoiceSetWord.s") +s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { + s32 i; + s32 sp50; + s32 errorCode; + u8 sp4B; + u8 sp20[0x28]; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp4B); + if (errorCode != 0) { + return errorCode; + } + + if (sp4B & 2) { + return 0xF; + } + + sp50 = 0; + + while (word[sp50] != 0) { + sp50 += 2; + } + + bzero(&sp20, 0x28); + + for (i = 0; i < sp50; i += 2) { + sp20[0x27 - sp50 + i] = word[i]; + sp20[0x27 - sp50 + i - 1] = word[i + 1]; + } + + sp20[0x27 - i - 5] = 3; + + if (sp50 >= 0xF) { + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20); + if (errorCode != 0) { + return errorCode; + } + } + + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20[0x14]); + if (errorCode != 0) { + return errorCode; + } + + errorCode = __osVoiceCheckResult(hd, &sp4B); + + if (errorCode != 0) { + if (errorCode & 0x100) { + errorCode = 0xD; + } else if (errorCode & 0x200) { + errorCode = 0xE; + } else if (errorCode & 0xFF00) { + errorCode = 5; + } + } + + return errorCode; +} From 6775824c4d71e407dcf98d4a096711a30db32cb9 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 10:50:33 +1100 Subject: [PATCH 14/82] Add error codes --- src/libultra/voice/voicecheckresult.c | 4 ++-- src/libultra/voice/voicecheckword.c | 24 ++++++++++---------- src/libultra/voice/voicecleardictionary.c | 6 ++--- src/libultra/voice/voicecontrolgain.c | 2 +- src/libultra/voice/voicegetreaddata.c | 14 ++++++------ src/libultra/voice/voicegetstatus.c | 27 ++++++++++++----------- src/libultra/voice/voiceinit.c | 16 +++++++------- src/libultra/voice/voicesetword.c | 16 +++++++------- src/libultra/voice/voicestartreaddata.c | 6 ++--- src/libultra/voice/voicestopread.c | 8 +++---- 10 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index 97af48094..907376734 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -6,12 +6,12 @@ s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { if (errorCode = __osVoiceGetStatus(hd->mq, hd->port, status), errorCode == 0) { if (*status & 1) { - errorCode = 0xF; + errorCode = CONT_ERR_VOICE_NO_RESPONSE; } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), errorCode == 0) { hd->status = sp20[0] & 7; if (sp20[0] & 0x40) { - errorCode = 0xF; + errorCode = CONT_ERR_VOICE_NO_RESPONSE; } else { errorCode = sp20[1] << 8; } diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 78b835579..f7c640760 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -13,34 +13,34 @@ s32 osVoiceCheckWord(u8* word) { currentWord = word[i + 1] + (new_var << 8); if (((currentWord != 0x815B) && (currentWord < 0x829F)) || ((currentWord >= 0x82F2) && (currentWord < 0x8340)) || (currentWord == 0x837F) || (currentWord >= 0x8397)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if ((i == 0) && ((currentWord == 0x815B) || (currentWord == 0x82F1) || (currentWord == 0x82C1) || (currentWord == 0x82EC) || (currentWord == 0x8393) || (currentWord == 0x8362) || (currentWord == 0x838E) || (currentWord == 0x8395) || (currentWord == 0x8396))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x829F) || (currentWord == 0x8340)) && (currentWord != 0x82D3) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A1) || (currentWord == 0x8342)) && (currentWord != 0x82A4) && (currentWord != 0x82C4) && (currentWord != 0x82C5) && (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8365) && (currentWord != 0x8366) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A3) || (currentWord == 0x8344)) && (currentWord != 0x82C6) && (currentWord != 0x82C7) && (currentWord != 0x82D3) && (currentWord != 0x8367) && (currentWord != 0x8368) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A5) || (currentWord == 0x8346)) && (currentWord != 0x82A4) && (currentWord != 0x82B5) && (currentWord != 0x82B6) && (currentWord != 0x82BF) && (currentWord != 0x82C0) && (currentWord != 0x82C2) && (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8356) && (currentWord != 0x8357) && (currentWord != 0x8360) && (currentWord != 0x8361) && (currentWord != 0x8363) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82A7) || (currentWord == 0x8348)) && (currentWord != 0x82A4) && (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8374) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82E1) || (currentWord == 0x82E3) || (currentWord == 0x82E5) || (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387)) && (currentWord != 0x82AB) && (currentWord != 0x82B5) && (currentWord != 0x82BF) && @@ -52,13 +52,13 @@ s32 osVoiceCheckWord(u8* word) { (currentWord != 0x838A) && (currentWord != 0x834D) && (currentWord != 0x8357) && (currentWord != 0x8361) && (currentWord != 0x8372) && (currentWord != 0x8373) && (currentWord != 0x8394)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if ((currentWord == 0x815B) && ((currentWord == 0x82F1) || (currentWord == 0x82C1) || (currentWord == 0x8393) || (currentWord == 0x8362))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82F1) || (currentWord == 0x8393)) && ((currentWord == 0x82F1) || (currentWord == 0x8393))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (((currentWord == 0x82C1) || (currentWord == 0x8362)) && ((currentWord == 0x815B) || (currentWord == 0x82A0) || (currentWord == 0x82A2) || (currentWord == 0x82A4) || (currentWord == 0x82A6) || (currentWord == 0x82A8) || @@ -86,7 +86,7 @@ s32 osVoiceCheckWord(u8* word) { (currentWord == 0x8344) || (currentWord == 0x8346) || (currentWord == 0x8348) || (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387) || (currentWord == 0x8362) || (currentWord == 0x838E))) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } if (errorCode != 0) { @@ -95,7 +95,7 @@ s32 osVoiceCheckWord(u8* word) { } if ((currentWord == 0x82C1) || (currentWord == 0x8362)) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } return errorCode; diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 92114809d..9bb490a97 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -14,7 +14,7 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { registration_word = &sp24; if (status & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } sp24 = 0x2000000; @@ -26,8 +26,8 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { } errorCode = __osVoiceCheckResult(hd, &status); - if ((errorCode & 0xFF00) != 0) { - errorCode = 5; + if (errorCode & 0xFF00) { + errorCode = CONT_ERR_INVALID; } return errorCode; diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index 251dc1144..eb896bb72 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -27,7 +27,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { if (0) { dummy: - return 5; + return CONT_ERR_INVALID; } errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index c202ad27d..e94202aca 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -17,7 +17,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (sp38[39] & 1) { - return 0xC; + return CONT_ERR_NOT_READY; } errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); @@ -29,7 +29,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { hd->status = temp_t9; D_8009CF60 = temp_t9; if ((temp_t9 != 0) && (temp_t9 != 7)) { - return 0xC; + return CONT_ERR_NOT_READY; } case 2: hd->mode = 2; @@ -41,7 +41,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { if (0) {} if (sp38[39] & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } sp38[0] = 0x600; // Not reading in correctly since 0x600 is out-of-range for u8 @@ -59,7 +59,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (sp38[39] & 1) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, sp38); @@ -96,7 +96,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (sp38[39] & 1) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); @@ -106,12 +106,12 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { hd->status = sp38[0] & 7; if ((sp38[0] & 7) != 0) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } break; default: - return 5; + return CONT_ERR_INVALID; } hd->mode = 0; return errorCode; diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index 1711eb56d..7946b4904 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -3,7 +3,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { __OSContRequestHeaderAligned header; - s32 ret = 0; + s32 errorCode = 0; s32 i; u8* ptr = (u8*)&__osContPifRam; s32 var = 2; @@ -11,7 +11,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { __osSiGetAccess(); do { - if (ret != CONT_ERR_CONTRFAIL) { + if (errorCode != CONT_ERR_CONTRFAIL) { __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; for (i = 0; i < port; i++, *ptr++ = 0) { @@ -25,34 +25,35 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { *ptr = CONT_CMD_END; __osContLastCmd = CONT_CMD_END; - ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam); + errorCode = __osSiRawStartDma(OS_WRITE, &__osContPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - ret = __osSiRawStartDma(OS_READ, &__osContPifRam); + errorCode = __osSiRawStartDma(OS_READ, &__osContPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); ptr = (u8*)&__osContPifRam + port; header = *((__OSContRequestHeaderAligned*)ptr); - ret = (u8)((header.rxsize & 0xC0) >> 4); + errorCode = (u8)((header.rxsize & 0xC0) >> 4); *status = header.status; - if (ret == 0) { + if (errorCode == 0) { if (header.typeh == 0 && header.typel == 1) { if (header.status & 4) { - ret = CONT_ERR_CONTRFAIL; + errorCode = CONT_ERR_CONTRFAIL; } } else { - ret = CONT_ERR_DEVICE; + errorCode = CONT_ERR_DEVICE; } - } else if (ret & CONT_NO_RESPONSE_ERROR) { - ret = CONT_ERR_NO_CONTROLLER; + } else if (errorCode & CONT_NO_RESPONSE_ERROR) { + errorCode = CONT_ERR_NO_CONTROLLER; } else { - ret = CONT_ERR_CONTRFAIL; + errorCode = CONT_ERR_CONTRFAIL; } - } while ((ret == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); __osSiRelAccess(); - return (ret); + + return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 54e13fa4c..7cc4f817a 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -7,7 +7,7 @@ extern u8 D_80097FA5; s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { s32 errorCode; u8* phi_s0; - u8 sp37 = 0; + u8 status = 0; s32 sp30; s32 pad; @@ -15,13 +15,13 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { hd->mq = siMessageQ; hd->mode = 0; - errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + errorCode = __osVoiceGetStatus(siMessageQ, channel, &status); if (errorCode != 0) { return errorCode; } if (__osContChannelReset(siMessageQ, channel) != 0) { - return 4; + return CONT_ERR_CONTRFAIL; } for (phi_s0 = &D_80097FA0;;) { @@ -33,12 +33,12 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { } if (phi_s0 == &D_80097FA5) { - errorCode = __osVoiceGetStatus(siMessageQ, channel, &sp37); + errorCode = __osVoiceGetStatus(siMessageQ, channel, &status); if (errorCode != 0) { return errorCode; } - if (sp37 & 2) { - return 0xF; + if (status & 2) { + return CONT_ERR_VOICE_NO_RESPONSE; } sp30 = 0x100; @@ -47,9 +47,9 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { return errorCode; } - errorCode = __osVoiceCheckResult(hd, &sp37); + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } return errorCode; diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index 83cf97516..3c927740c 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -5,16 +5,16 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { s32 i; s32 sp50; s32 errorCode; - u8 sp4B; + u8 status; u8 sp20[0x28]; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp4B); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { return errorCode; } - if (sp4B & 2) { - return 0xF; + if (status & 2) { + return CONT_ERR_VOICE_NO_RESPONSE; } sp50 = 0; @@ -44,15 +44,15 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { return errorCode; } - errorCode = __osVoiceCheckResult(hd, &sp4B); + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode != 0) { if (errorCode & 0x100) { - errorCode = 0xD; + errorCode = CONT_ERR_VOICE_MEMORY; } else if (errorCode & 0x200) { - errorCode = 0xE; + errorCode = CONT_ERR_VOICE_WORD; } else if (errorCode & 0xFF00) { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } } diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 88c77dc2c..5e65d3ce4 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -12,11 +12,11 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { } if (status & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } if (hd->mode != 0) { - return 5; + return CONT_ERR_INVALID; } sp24 = 0x5000000; @@ -26,7 +26,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } else { hd->mode = 1; } diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index d7dad3291..4c9a1dc88 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -14,11 +14,11 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { } if (sp3F & 2) { - return 0xF; + return CONT_ERR_VOICE_NO_RESPONSE; } if (hd->mode == 0) { - return 5; + return CONT_ERR_INVALID; } sp38 = 0x700; @@ -33,13 +33,13 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { errorCode = 0; hd->mode = 0; } else { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } } else { hd->mode = 0; } - if (errorCode != 0xF) { + if (errorCode != CONT_ERR_VOICE_NO_RESPONSE) { break; } } From e8deb9eb8e4a5ff14e03d7cca1b9cf04de050dfe Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 23:28:03 +1100 Subject: [PATCH 15/82] Matched __osVoiceContRead2... Somehow... --- include/functions.h | 2 +- src/libultra/voice/voicecontread2.c | 68 ++++++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/include/functions.h b/include/functions.h index a2a42e6d3..ab8384a06 100644 --- a/include/functions.h +++ b/include/functions.h @@ -351,7 +351,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words); void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, s32, u8 dst[2]); +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16, u8 dst[2]); u8 __osVoiceContDataCrc(u8* data, u32 arg1); const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index 38350ee5f..8e70d4dee 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -1,3 +1,69 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontread2/__osVoiceContRead2.s") +extern s32 D_80097FB0; + +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { + u8* ptr; + u8 sp63; + s32 errorCode; + s32 var = 2; + s32 i; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xB) || (port != D_80097FB0)) { + __osContLastCmd = 0xB; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = 1; + + ptr[0] = 0xFF; + ptr[1] = 3; + ptr[2] = 3; + ptr[3] = 0xB; + ptr[8] = 0xFF; + ptr[9] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[8] != __osVoiceContDataCrc(&ptr[6], 2)) { + errorCode = __osVoiceGetStatus(mq, port, &sp63); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } else { + bcopy(&ptr[6], dst, 2); + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} + From 7b95bd11d14025d1a420e1cdcb7184b4b93b9ae7 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 23:34:44 +1100 Subject: [PATCH 16/82] Add small amount of docs --- src/libultra/io/contreaddata.c | 4 ++-- src/libultra/io/controller.c | 4 ++-- src/libultra/io/motor.c | 2 +- src/libultra/voice/voicecontread2.c | 10 +++++----- src/libultra/voice/voicegetstatus.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 035663486..8fb925876 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -43,11 +43,11 @@ void __osPackReadData() { int i; ptr = (u8*)__osContPifRam.ramarray; - for (i = 0; i < 0xF; i++) { + for (i = 0; i < ARRAY_COUNT(__osContPifRam.ramarray); i++) { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; readformat.dummy = 255; readformat.txsize = 1; readformat.rxsize = 4; diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index 21e376d58..548d3e257 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -74,11 +74,11 @@ void __osPackRequestData(u8 cmd) { __OSContRequesFormat requestformat; int i; - for (i = 0; i < 0xF; i++) { + for (i = 0; i < ARRAY_COUNT(__osContPifRam.ramarray); i++) { __osContPifRam.ramarray[i] = 0; } - __osContPifRam.pifstatus = 1; + __osContPifRam.pifstatus = CONT_CMD_READ_BUTTON; ptr = (u8*)__osContPifRam.ramarray; requestformat.dummy = 255; requestformat.txsize = 1; diff --git a/src/libultra/io/motor.c b/src/libultra/io/motor.c index 4c0bfb67a..9db4bdb4c 100644 --- a/src/libultra/io/motor.c +++ b/src/libultra/io/motor.c @@ -20,7 +20,7 @@ s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) { } __osSiGetAccess(); - osPifBuffers[pfs->channel].pifstatus = 1; + osPifBuffers[pfs->channel].pifstatus = CONT_CMD_READ_BUTTON; buf += pfs->channel; for (i = 0; i < BLOCKSIZE; i++) { ((__OSContRamReadFormat*)buf)->data[i] = vibrate; diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index 8e70d4dee..e1d260372 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -4,9 +4,9 @@ extern s32 D_80097FB0; s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { u8* ptr; - u8 sp63; + u8 status; s32 errorCode; - s32 var = 2; + s32 retryCount = 2; s32 i; __osSiGetAccess(); @@ -23,7 +23,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { ; } - __osPfsPifRam.pifstatus = 1; + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; ptr[0] = 0xFF; ptr[1] = 3; @@ -47,7 +47,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { if (errorCode == 0) { if (ptr[8] != __osVoiceContDataCrc(&ptr[6], 2)) { - errorCode = __osVoiceGetStatus(mq, port, &sp63); + errorCode = __osVoiceGetStatus(mq, port, &status); if (errorCode != 0) { break; } @@ -60,7 +60,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { errorCode = CONT_ERR_NO_CONTROLLER; } - } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); __osSiRelAccess(); diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index 7946b4904..e11dcb954 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -6,7 +6,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { s32 errorCode = 0; s32 i; u8* ptr = (u8*)&__osContPifRam; - s32 var = 2; + s32 retryCount = 2; __osSiGetAccess(); @@ -51,7 +51,7 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { } else { errorCode = CONT_ERR_CONTRFAIL; } - } while ((errorCode == CONT_ERR_CONTRFAIL) && (var-- >= 0)); + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); __osSiRelAccess(); From 905584f8430bb57e3f026fad294d58f6cd82d554 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 9 Nov 2021 23:47:36 +1100 Subject: [PATCH 17/82] __osVoiceContRead36 was basically identical from __osVoiceContRead2 --- include/functions.h | 4 +- src/libultra/voice/voicecontread2.c | 2 +- src/libultra/voice/voicecontread36.c | 67 +++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/include/functions.h b/include/functions.h index ab8384a06..0043a3544 100644 --- a/include/functions.h +++ b/include/functions.h @@ -351,7 +351,7 @@ void _Putfld(_Pft* px, va_list* pap, u8 code, u8* ac); s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words); void osUnmapTLBAll(void); s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction); -s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16, u8 dst[2]); +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]); u8 __osVoiceContDataCrc(u8* data, u32 arg1); const char* strchr(const char* __s, s32 __c); size_t strlen(const char* __s); @@ -363,7 +363,7 @@ void __osTimerServicesInit(void); void __osTimerInterrupt(void); void __osSetTimerIntr(OSTime tim); OSTime __osInsertTimer(OSTimer* t); -s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, s32, u8*); +s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]); s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); // void guMtxIdent(void); diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index e1d260372..64ac40605 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -2,7 +2,7 @@ extern s32 D_80097FB0; -s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst) { +s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { u8* ptr; u8 status; s32 errorCode; diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index 38f3fe2f0..081b9a534 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -1,3 +1,68 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontread36/__osVoiceContRead36.s") +extern s32 D_80097FB0; + +s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { + u8* ptr; + u8 status; + s32 errorCode; + s32 retryCount = 2; + s32 i; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 9) || (port != D_80097FB0)) { + __osContLastCmd = 9; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 0xFF; + ptr[1] = 3; + ptr[2] = 0x25; + ptr[3] = 9; + ptr[0x2A] = 0xFF; + ptr[0x2B] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[0x2A] != __osVoiceContDataCrc(&ptr[6], 36)) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } else { + bcopy(&ptr[6], dst, 36); + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} From 1329f3aeaa71452c56ea222e26f32c0899d6188e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 00:03:48 +1100 Subject: [PATCH 18/82] docs, but maybe a little carried away --- include/variables.h | 2 +- src/boot_O2_g3/fault.c | 2 +- src/boot_O2_g3/idle.c | 2 +- src/boot_O2_g3/irqmgr.c | 10 +++++----- src/boot_O2_g3/z_std_dma.c | 4 ++-- src/code/z_vr_box.c | 6 +++--- src/libultra/io/contquery.c | 4 ++-- src/libultra/io/contreaddata.c | 6 +++--- src/libultra/io/controller.c | 8 ++++---- src/libultra/io/contsetch.c | 2 +- src/libultra/io/epidma.c | 4 ++-- src/libultra/io/piacs.c | 2 +- src/libultra/io/siacs.c | 6 +++--- src/libultra/os/seteventmesg.c | 2 +- src/libultra/os/timerintr.c | 2 +- src/libultra/voice/voicecontread2.c | 2 -- src/libultra/voice/voicecontread36.c | 2 -- 17 files changed, 31 insertions(+), 35 deletions(-) diff --git a/include/variables.h b/include/variables.h index 55fe64c49..d3ecb8bb1 100644 --- a/include/variables.h +++ b/include/variables.h @@ -78,7 +78,7 @@ extern float D_80097F90; // extern UNK_TYPE1 D_80097FA0; // extern UNK_TYPE1 D_80097FA4; // extern UNK_TYPE1 D_80097FA5; -// extern UNK_TYPE4 D_80097FB0; +extern s32 D_80097FB0; extern OSViMode osViModeNtscLan1; extern OSViMode osViModeMpalLan1; extern __OSViContext D_80098060[2]; diff --git a/src/boot_O2_g3/fault.c b/src/boot_O2_g3/fault.c index b32b5aa98..175fbbef7 100644 --- a/src/boot_O2_g3/fault.c +++ b/src/boot_O2_g3/fault.c @@ -802,7 +802,7 @@ void Fault_ThreadEntry(void* arg) { osSetEventMesg(12, &sFaultContext->queue, (OSMesg)2); while (1) { do { - osRecvMesg(&sFaultContext->queue, &msg, 1); + osRecvMesg(&sFaultContext->queue, &msg, OS_MESG_BLOCK); if (msg == (OSMesg)1) { sFaultContext->msgId = 1; diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 4be8a1094..4f9146530 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -62,7 +62,7 @@ void Idle_InitCodeAndMemory(void) { SEGMENT_ROM_END(code) - SEGMENT_ROM_START(code), 0, &queue, 0); Idle_InitScreen(); Idle_InitMemory(); - osRecvMesg(&queue, NULL, 1); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); sDmaMgrDmaBuffSize = oldSize; diff --git a/src/boot_O2_g3/irqmgr.c b/src/boot_O2_g3/irqmgr.c index 3f4ca04ae..696d114c4 100644 --- a/src/boot_O2_g3/irqmgr.c +++ b/src/boot_O2_g3/irqmgr.c @@ -17,10 +17,10 @@ void IrqMgr_AddClient(IrqMgr* irqmgr, IrqMgrClient* param_2, OSMesgQueue* param_ osSetIntMask(saveMask); if (irqmgr->prenmiStage > 0) { - osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, 0); + osSendMesg(param_2->queue, &irqmgr->prenmiMsg.type, OS_MESG_NOBLOCK); } if (irqmgr->prenmiStage > 1) { - osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, 0); + osSendMesg(param_2->queue, &irqmgr->nmiMsg.type, OS_MESG_NOBLOCK); } } @@ -54,7 +54,7 @@ void IrqMgr_SendMesgForClient(IrqMgr* irqmgr, OSMesg msg) { IrqMgrClient* iter = irqmgr->callbacks; while (iter != NULL) { - osSendMesg(iter->queue, msg, 0); + osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK); iter = iter->next; } } @@ -64,7 +64,7 @@ void IrqMgr_JamMesgForClient(IrqMgr* irqmgr, OSMesg msg) { while (iter != NULL) { if (iter->queue->validCount < iter->queue->msgCount) { - osSendMesg(iter->queue, msg, 0); + osSendMesg(iter->queue, msg, OS_MESG_NOBLOCK); } iter = iter->next; } @@ -130,7 +130,7 @@ void IrqMgr_ThreadEntry(IrqMgr* irqmgr) { ; } - osRecvMesg(&irqmgr->irqQueue, (OSMesg*)&interrupt, 1); + osRecvMesg(&irqmgr->irqQueue, (OSMesg*)&interrupt, OS_MESG_BLOCK); switch (interrupt) { case 0x29A: IrqMgr_HandleRetrace(irqmgr); diff --git a/src/boot_O2_g3/z_std_dma.c b/src/boot_O2_g3/z_std_dma.c index 2903b488f..55fdbce7a 100644 --- a/src/boot_O2_g3/z_std_dma.c +++ b/src/boot_O2_g3/z_std_dma.c @@ -31,7 +31,7 @@ s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { goto END; } - osRecvMesg(&queue, NULL, 1); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); size -= buffSize; rom = rom + buffSize; ram = (u8*)ram + buffSize; @@ -47,7 +47,7 @@ s32 DmaMgr_DMARomToRam(u32 rom, void* ram, size_t size) { goto END; } - osRecvMesg(&queue, NULL, 1); + osRecvMesg(&queue, NULL, OS_MESG_BLOCK); osInvalDCache(ram, size); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 9e949beac..724bc5971 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -103,7 +103,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); } - osRecvMesg(&skyboxCtx->loadQueue, NULL, 1); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); if (globalCtx->envCtx.unk_11 == 0) { @@ -120,7 +120,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy SEGMENT_ROM_START(d2_cloud_static), size, 0, &skyboxCtx->loadQueue, NULL); } - osRecvMesg(&skyboxCtx->loadQueue, NULL, 1); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1); size = SEGMENT_ROM_SIZE(d2_fine_pal_static); @@ -129,7 +129,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy DmaMgr_SendRequestImpl(&skyboxCtx->unk1C8, skyboxCtx->skyboxPaletteStaticSegment, SEGMENT_ROM_START(d2_fine_pal_static), size, 0, &skyboxCtx->loadQueue, NULL); - osRecvMesg(&skyboxCtx->loadQueue, NULL, 1); + osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK); } } diff --git a/src/libultra/io/contquery.c b/src/libultra/io/contquery.c index 5c351241a..cfdf9449f 100644 --- a/src/libultra/io/contquery.c +++ b/src/libultra/io/contquery.c @@ -7,11 +7,11 @@ s32 osContStartQuery(OSMesgQueue* mq) { if (__osContLastCmd != 0) { __osPackRequestData(0); - __osSiRawStartDma(1, &__osContPifRam); + __osSiRawStartDma(OS_WRITE, &__osContPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - ret = __osSiRawStartDma(0, &__osContPifRam); + ret = __osSiRawStartDma(OS_READ, &__osContPifRam); __osContLastCmd = 0; diff --git a/src/libultra/io/contreaddata.c b/src/libultra/io/contreaddata.c index 8fb925876..d2a5762f9 100644 --- a/src/libultra/io/contreaddata.c +++ b/src/libultra/io/contreaddata.c @@ -8,11 +8,11 @@ s32 osContStartReadData(OSMesgQueue* mq) { if (__osContLastCmd != 1) { __osPackReadData(); - __osSiRawStartDma(1, &__osContPifRam); - osRecvMesg(mq, NULL, 1); + __osSiRawStartDma(OS_WRITE, &__osContPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); } - ret = __osSiRawStartDma(0, &__osContPifRam); + ret = __osSiRawStartDma(OS_READ, &__osContPifRam); __osContLastCmd = 1; __osSiRelAccess(); diff --git a/src/libultra/io/controller.c b/src/libultra/io/controller.c index 548d3e257..e3064718f 100644 --- a/src/libultra/io/controller.c +++ b/src/libultra/io/controller.c @@ -34,11 +34,11 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) { __osPackRequestData(0); - ret = __osSiRawStartDma(1, &__osContPifRam); - osRecvMesg(mq, &dummy, 1); + ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam); + osRecvMesg(mq, &dummy, OS_MESG_BLOCK); - ret = __osSiRawStartDma(0, &__osContPifRam); - osRecvMesg(mq, &dummy, 1); + ret = __osSiRawStartDma(OS_READ, &__osContPifRam); + osRecvMesg(mq, &dummy, OS_MESG_BLOCK); __osContGetInitData(bitpattern, data); __osContLastCmd = 0; diff --git a/src/libultra/io/contsetch.c b/src/libultra/io/contsetch.c index bd1c96698..654d78e2a 100644 --- a/src/libultra/io/contsetch.c +++ b/src/libultra/io/contsetch.c @@ -8,7 +8,7 @@ s32 osContSetCh(u8 ch) { } else { __osMaxControllers = ch; } - __osContLastCmd = -2; + __osContLastCmd = CONT_CMD_END; __osSiRelAccess(); return 0; diff --git a/src/libultra/io/epidma.c b/src/libultra/io/epidma.c index d3e0e36d2..0b8c847d6 100644 --- a/src/libultra/io/epidma.c +++ b/src/libultra/io/epidma.c @@ -16,9 +16,9 @@ s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) { } if (mb->hdr.pri == 1) { - result = osJamMesg(osPiGetCmdQueue(), mb, 0); + result = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); } else { - result = osSendMesg(osPiGetCmdQueue(), mb, 0); + result = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK); } return result; } diff --git a/src/libultra/io/piacs.c b/src/libultra/io/piacs.c index 8e6f830c0..9689aaf67 100644 --- a/src/libultra/io/piacs.c +++ b/src/libultra/io/piacs.c @@ -8,7 +8,7 @@ OSMesgQueue __osPiAccessQueue; void __osPiCreateAccessQueue(void) { __osPiAccessQueueEnabled = 1; osCreateMesgQueue(&__osPiAccessQueue, D_8009E3F0, 1); - osSendMesg(&__osPiAccessQueue, NULL, 0); + osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osPiGetAccess(void) { diff --git a/src/libultra/io/siacs.c b/src/libultra/io/siacs.c index 590f048ad..5bddc63c8 100644 --- a/src/libultra/io/siacs.c +++ b/src/libultra/io/siacs.c @@ -8,7 +8,7 @@ OSMesgQueue __osSiAccessQueue; void __osSiCreateAccessQueue() { __osSiAccessQueueEnabled = 1; osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, 1); - osSendMesg(&__osSiAccessQueue, NULL, 0); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } void __osSiGetAccess(void) { @@ -16,9 +16,9 @@ void __osSiGetAccess(void) { if (!__osSiAccessQueueEnabled) { __osSiCreateAccessQueue(); } - osRecvMesg(&__osSiAccessQueue, &dummyMesg, 1); + osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK); } void __osSiRelAccess(void) { - osSendMesg(&__osSiAccessQueue, NULL, 0); + osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK); } diff --git a/src/libultra/os/seteventmesg.c b/src/libultra/os/seteventmesg.c index 723d1dafc..8be2ff9e2 100644 --- a/src/libultra/os/seteventmesg.c +++ b/src/libultra/os/seteventmesg.c @@ -17,7 +17,7 @@ void osSetEventMesg(OSEvent e, OSMesgQueue* mq, OSMesg m) { if (e == 14) { if (__osShutdown != 0 && D_80097F10 == 0) { - osSendMesg(mq, m, 0); + osSendMesg(mq, m, OS_MESG_NOBLOCK); } D_80097F10 = 1; } diff --git a/src/libultra/os/timerintr.c b/src/libultra/os/timerintr.c index 4c0083139..87f7129df 100644 --- a/src/libultra/os/timerintr.c +++ b/src/libultra/os/timerintr.c @@ -49,7 +49,7 @@ void __osTimerInterrupt(void) { t->next = NULL; t->prev = NULL; if (t->mq != NULL) { - osSendMesg(t->mq, t->msg, 0); + osSendMesg(t->mq, t->msg, OS_MESG_NOBLOCK); } if (t->interval != 0) { t->value = t->interval; diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index 64ac40605..b3a3a7fbc 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -1,7 +1,5 @@ #include "global.h" -extern s32 D_80097FB0; - s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { u8* ptr; u8 status; diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index 081b9a534..a3b330428 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -1,7 +1,5 @@ #include "global.h" -extern s32 D_80097FB0; - s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { u8* ptr; u8 status; From 83453f6cd31172185714e7cd5b2f09b3a81d5f6f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 00:21:29 +1100 Subject: [PATCH 19/82] Match __osVoiceContWrite4, Write is very similar to Read --- include/functions.h | 2 +- src/libultra/voice/voicecontread2.c | 4 +- src/libultra/voice/voicecontread36.c | 4 +- src/libultra/voice/voicecontwrite4.c | 67 +++++++++++++++++++++++++++- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/functions.h b/include/functions.h index 0043a3544..87e3ba2be 100644 --- a/include/functions.h +++ b/include/functions.h @@ -470,7 +470,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); s32 osVoiceStartReadData(OSVoiceHandle* hd); u32* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* pc); -s32 __osVoiceContWrite4(OSMesgQueue* hd, s32 arg1, s32 arg2, OSVoiceData* voiceData); +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); u32 __osGetWatchLo(void); diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index b3a3a7fbc..ce52e2be0 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -1,9 +1,9 @@ #include "global.h" s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { - u8* ptr; - u8 status; s32 errorCode; + u8 status; + u8* ptr; s32 retryCount = 2; s32 i; diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index a3b330428..66067d239 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -1,9 +1,9 @@ #include "global.h" s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { - u8* ptr; - u8 status; s32 errorCode; + u8 status; + u8* ptr; s32 retryCount = 2; s32 i; diff --git a/src/libultra/voice/voicecontwrite4.c b/src/libultra/voice/voicecontwrite4.c index c28e2d762..09158c043 100644 --- a/src/libultra/voice/voicecontwrite4.c +++ b/src/libultra/voice/voicecontwrite4.c @@ -1,3 +1,68 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontwrite4/__osVoiceContWrite4.s") +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]) { + s32 errorCode; + u8 status; + u8* ptr; + s32 retryCount = 2; + s32 i; + u8 temp_s2; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xC) || (port != D_80097FB0)) { + __osContLastCmd = 0xC; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 0xFF; + ptr[1] = 7; + ptr[2] = 1; + ptr[3] = 0xC; + ptr[0xA] = 0xFF; + ptr[0xB] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + bcopy(dst, &ptr[6], 4); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + temp_s2 = __osVoiceContDataCrc(dst, 4); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[0xA] != (0, temp_s2)) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} From d9f034bc0e6f2e3fc499497bd39a2e21659f4395 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 00:27:16 +1100 Subject: [PATCH 20/82] Match __osVoiceContWrite20 from __osVoiceContWrite4, ez --- include/functions.h | 4 +- src/libultra/voice/voicecontwrite20.c | 67 ++++++++++++++++++++++++++- src/libultra/voice/voicecontwrite4.c | 4 +- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/include/functions.h b/include/functions.h index 87e3ba2be..2ed3bf63c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -386,7 +386,7 @@ s32 __osContChannelReset(OSMesgQueue* mq, s32 count); s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2); s32 osAiSetFrequency(u32 frequency); s32 __osContRamRead(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer); -s32 __osVoiceContWrite20(OSMesgQueue*, s32, u8, u8*); +s32 __osVoiceContWrite20(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[20]); u8 __osContAddressCrc(u16 addr); u8 __osContDataCrc(u8* data); OSThread* __osGetActiveQueue(void); @@ -470,7 +470,7 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital); s32 osVoiceStartReadData(OSVoiceHandle* hd); u32* osViGetCurrentFramebuffer(void); s32 __osSpSetPc(void* pc); -s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]); +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[4]); void __osGetHWIntrRoutine(s32 idx, OSMesgQueue** outQueue, OSMesg* outMsg); void __osSetHWIntrRoutine(s32 idx, OSMesgQueue* queue, OSMesg msg); u32 __osGetWatchLo(void); diff --git a/src/libultra/voice/voicecontwrite20.c b/src/libultra/voice/voicecontwrite20.c index 5ca3560ed..9eba371c6 100644 --- a/src/libultra/voice/voicecontwrite20.c +++ b/src/libultra/voice/voicecontwrite20.c @@ -1,3 +1,68 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecontwrite20/__osVoiceContWrite20.s") +s32 __osVoiceContWrite20(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[20]) { + s32 errorCode; + u8 status; + u8* ptr; + s32 retryCount = 2; + s32 i; + u8 temp_s2; + + __osSiGetAccess(); + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xA) || (port != D_80097FB0)) { + __osContLastCmd = 0xA; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 0xFF; + ptr[1] = 0x17; + ptr[2] = 1; + ptr[3] = 0xA; + ptr[0x1A] = 0xFF; + ptr[0x1B] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[4] = arg2 >> 3; + ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); + + bcopy(dst, &ptr[6], 20); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + temp_s2 = __osVoiceContDataCrc(dst, 20); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[2] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[0x1A] != ((void)0, temp_s2)) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} diff --git a/src/libultra/voice/voicecontwrite4.c b/src/libultra/voice/voicecontwrite4.c index 09158c043..8e1af6bd8 100644 --- a/src/libultra/voice/voicecontwrite4.c +++ b/src/libultra/voice/voicecontwrite4.c @@ -1,6 +1,6 @@ #include "global.h" -s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]) { +s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[4]) { s32 errorCode; u8 status; u8* ptr; @@ -48,7 +48,7 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8* dst[4]) { errorCode = (ptr[2] & 0xC0) >> 4; if (errorCode == 0) { - if (ptr[0xA] != (0, temp_s2)) { + if (ptr[0xA] != ((void)0, temp_s2)) { errorCode = __osVoiceGetStatus(mq, port, &status); if (errorCode != 0) { break; From 16d91f5b710f2ba1507730d4974727d2e36bb9e2 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 11:56:25 +1100 Subject: [PATCH 21/82] Some docs --- src/libultra/voice/voicecheckresult.c | 10 ++++---- src/libultra/voice/voicecleardictionary.c | 31 +++++++++++++++++------ src/libultra/voice/voiceinit.c | 15 ++++++++--- src/libultra/voice/voicesetword.c | 14 +++++----- src/libultra/voice/voicestartreaddata.c | 15 ++++++++--- 5 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/libultra/voice/voicecheckresult.c b/src/libultra/voice/voicecheckresult.c index 907376734..0d306884d 100644 --- a/src/libultra/voice/voicecheckresult.c +++ b/src/libultra/voice/voicecheckresult.c @@ -2,18 +2,18 @@ s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) { s32 errorCode; - u8 sp20[2]; + u8 data[2]; if (errorCode = __osVoiceGetStatus(hd->mq, hd->port, status), errorCode == 0) { if (*status & 1) { errorCode = CONT_ERR_VOICE_NO_RESPONSE; - } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp20), errorCode == 0) { - hd->status = sp20[0] & 7; + } else if (errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, data), errorCode == 0) { + hd->status = data[0] & 7; - if (sp20[0] & 0x40) { + if (data[0] & 0x40) { errorCode = CONT_ERR_VOICE_NO_RESPONSE; } else { - errorCode = sp20[1] << 8; + errorCode = data[1] << 8; } } } diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 9bb490a97..719c7f0dc 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -1,10 +1,18 @@ #include "global.h" -// Initializes Voice Recognition System word registration dictionary -s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { - u8* registration_word; +/** + * Initializes Voice Recognition System word registration dictionary. + * + * The dictionary is initialized so that the specified "numWords" can be + * registered in the dictionary. 1-255 words can be registered in the dictionary. + * + * Words cannot be registered with the osVoiceSetWord before the dictionary + * is initialized with the osVoiceClearDictionary function + */ +s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords) { + u8* data; // u8 data[4]; u8 status; - s32 sp24; + u32 data32; // data[4] as u32 s32 errorCode; errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); @@ -12,15 +20,22 @@ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 words) { return errorCode; } - registration_word = &sp24; + data = (u8*)&data32; + if (status & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } - sp24 = 0x2000000; - registration_word[2] = words; + /** + * data[0] = 2 + * data[1] = 0 + * data[2] = numWords + * data[3] = 0 + */ + data32 = 0x2000000; + data[2] = numWords; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, registration_word); + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, data); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 7cc4f817a..8a1aeac11 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -8,7 +8,10 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { s32 errorCode; u8* phi_s0; u8 status = 0; - s32 sp30; + union { + s32 data32; + u8 data[4]; + } u; s32 pad; hd->port = channel; @@ -41,8 +44,14 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { return CONT_ERR_VOICE_NO_RESPONSE; } - sp30 = 0x100; - errorCode = __osVoiceContWrite4(siMessageQ, channel, 0, &sp30); + /** + * data[0] = 0 + * data[1] = 0 + * data[2] = 1 + * data[3] = 0 + */ + u.data32 = 0x100; + errorCode = __osVoiceContWrite4(siMessageQ, channel, 0, u.data); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index 3c927740c..a5ef50348 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -6,7 +6,7 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { s32 sp50; s32 errorCode; u8 status; - u8 sp20[0x28]; + u8 data[40]; errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { @@ -23,23 +23,23 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { sp50 += 2; } - bzero(&sp20, 0x28); + bzero(&data, 40); for (i = 0; i < sp50; i += 2) { - sp20[0x27 - sp50 + i] = word[i]; - sp20[0x27 - sp50 + i - 1] = word[i + 1]; + data[39 - sp50 + i] = word[i]; + data[39 - sp50 + i - 1] = word[i + 1]; } - sp20[0x27 - i - 5] = 3; + data[39 - i - 5] = 3; if (sp50 >= 0xF) { - errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20); + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data[0]); if (errorCode != 0) { return errorCode; } } - errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &sp20[0x14]); + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data[20]); if (errorCode != 0) { return errorCode; } diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 5e65d3ce4..07032ba67 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -4,7 +4,10 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { s32 errorCode; u8 status; - s32 sp24; + union { + s32 data32; + u8 data[4]; + } u; errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { @@ -19,8 +22,14 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { return CONT_ERR_INVALID; } - sp24 = 0x5000000; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp24); + /** + * data[0] = 5 + * data[1] = 0 + * data[2] = 0 + * data[3] = 0 + */ + u.data32 = 0x5000000; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); if (errorCode == 0) { errorCode = __osVoiceCheckResult(hd, &status); From be44a62f0a0bbf8efa14024de859d064cae98f05 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 13:22:01 +1100 Subject: [PATCH 22/82] Improve osVoiceGetReadData --- src/libultra/voice/voicegetreaddata.c | 67 ++++++++++++++++----------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index e94202aca..03f21e506 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -6,26 +6,29 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { s32 errorCode; u8 new_var; u8 temp_t9; - u8 sp38[40]; + union { + u8 sp38[40]; + u32 sp38_32[10]; + } u; s32 i; switch (hd->mode) { case 1: - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (sp38[39] & 1) { + if (u.sp38[39] & 1) { return CONT_ERR_NOT_READY; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } - temp_t9 = sp38[0] & 7; + temp_t9 = u.sp38[0] & 7; hd->status = temp_t9; D_8009CF60 = temp_t9; if ((temp_t9 != 0) && (temp_t9 != 7)) { @@ -34,18 +37,17 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 2: hd->mode = 2; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (0) {} - if (sp38[39] & 2) { + if (u.sp38[39] & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } - sp38[0] = 0x600; // Not reading in correctly since 0x600 is out-of-range for u8 - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, sp38); + u.sp38_32[0] = 0x600; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } @@ -53,59 +55,72 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 3: hd->mode = 3; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (sp38[39] & 1) { + if (u.sp38[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, sp38); + errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } - result->warning = (sp38[5] << 8) + sp38[4]; - result->answer_num = sp38[6]; - result->voice_level = (sp38[9] << 8) + sp38[8]; - result->voice_sn = (sp38[11] << 8) + sp38[10]; - result->voice_time = (sp38[13] << 8) + sp38[12]; + result->warning = u.sp38[4] + (u.sp38[5] << 8); + result->answer_num = u.sp38[6]; + result->voice_level = u.sp38[8] + (u.sp38[9] << 8); + result->voice_sn = u.sp38[10] + (u.sp38[11] << 8); + result->voice_time = u.sp38[12] + (u.sp38[13] << 8); + // Issue here with for-loop unrolling new_var = 4; for (i = 0; i < 5; i++) { - result->answer[i] = (sp38[15 + new_var*i] << 8) + sp38[14 + new_var*i]; - result->distance[i] = (sp38[17 + new_var*i] << 8) + sp38[16 + new_var*i]; + result->answer[i] = u.sp38[14 + new_var*i] + (u.sp38[15 + new_var*i] << 8); + result->distance[i] = u.sp38[16 + new_var*i] + (u.sp38[17 + new_var*i] << 8); } + + // result->answer[0] = u.sp38[14] + (u.sp38[15] << 8); + // result->distance[0] = u.sp38[16] + (u.sp38[17] << 8); + // result->answer[1] = u.sp38[18] + (u.sp38[19] << 8); + // result->distance[1] = u.sp38[20] + (u.sp38[21] << 8); + // result->answer[2] = u.sp38[22] + (u.sp38[23] << 8); + // result->distance[2] = u.sp38[24] + (u.sp38[25] << 8); + // result->answer[3] = u.sp38[26] + (u.sp38[27] << 8); + // result->distance[3] = u.sp38[28] + (u.sp38[29] << 8); + // result->answer[4] = u.sp38[30] + (u.sp38[31] << 8); + // result->distance[4] = u.sp38[32] + (u.sp38[33] << 8); if (result->answer[0] == 0x7FFF) { result->answer_num = 0; } - hd->status = sp38[34] & 7; + // Issue here with regalloc + hd->status = u.sp38[34] & 7; if ((D_8009CF60 == 0) || (hd->status == 0)) { break; } case 4: hd->mode = 4; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); if (errorCode != 0) { return errorCode; } - if (sp38[39] & 1) { + if (u.sp38[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); if (errorCode != 0) { return errorCode; } - hd->status = sp38[0] & 7; - if ((sp38[0] & 7) != 0) { + hd->status = u.sp38[0] & 7; + if (u.sp38[0] & 7) { return CONT_ERR_VOICE_NO_RESPONSE; } From 26cd8f9387d401a652d032fac4543e020a644722 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 14:01:29 +1100 Subject: [PATCH 23/82] Match osVoiceCheckWord --- src/libultra/voice/voicecheckword.c | 147 ++++++++++++++-------------- 1 file changed, 73 insertions(+), 74 deletions(-) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index f7c640760..84f8985ab 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -1,105 +1,104 @@ #include "global.h" // Checks whether or not a word can be registered in the dictionary -#ifdef NON_EQUIVALENT s32 osVoiceCheckWord(u8* word) { s32 i; s32 errorCode = 0; - u16 currentWord; // currentLetter? currentSyllable? - u16 new_var; + u16 currentSyllable; + u16 prevSyllable = 0; for (i = 0; word[i] != 0; i += 2) { - new_var = word[i]; // Fake? But helps? - currentWord = word[i + 1] + (new_var << 8); - if (((currentWord != 0x815B) && (currentWord < 0x829F)) || - ((currentWord >= 0x82F2) && (currentWord < 0x8340)) || (currentWord == 0x837F) || (currentWord >= 0x8397)) { + currentSyllable = (word[i] << 8) + word[i + 1]; + if (((currentSyllable != 0x815B) && (currentSyllable < 0x829F)) || + ((currentSyllable >= 0x82F2) && (currentSyllable < 0x8340)) || (currentSyllable == 0x837F) || + (currentSyllable >= 0x8397)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((i == 0) && ((currentWord == 0x815B) || (currentWord == 0x82F1) || (currentWord == 0x82C1) || - (currentWord == 0x82EC) || (currentWord == 0x8393) || (currentWord == 0x8362) || - (currentWord == 0x838E) || (currentWord == 0x8395) || (currentWord == 0x8396))) { + } else if ((i == 0) && + ((currentSyllable == 0x815B) || (currentSyllable == 0x82F1) || (currentSyllable == 0x82C1) || + (currentSyllable == 0x82EC) || (currentSyllable == 0x8393) || (currentSyllable == 0x8362) || + (currentSyllable == 0x838E) || (currentSyllable == 0x8395) || (currentSyllable == 0x8396))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x829F) || (currentWord == 0x8340)) && (currentWord != 0x82D3) && - (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x829F) || (currentSyllable == 0x8340)) && (prevSyllable != 0x82D3) && + (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A1) || (currentWord == 0x8342)) && (currentWord != 0x82A4) && - (currentWord != 0x82C4) && (currentWord != 0x82C5) && (currentWord != 0x82D3) && - (currentWord != 0x8345) && (currentWord != 0x8365) && (currentWord != 0x8366) && - (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A1) || (currentSyllable == 0x8342)) && (prevSyllable != 0x82A4) && + (prevSyllable != 0x82C4) && (prevSyllable != 0x82C5) && (prevSyllable != 0x82D3) && + (prevSyllable != 0x8345) && (prevSyllable != 0x8365) && (prevSyllable != 0x8366) && + (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A3) || (currentWord == 0x8344)) && (currentWord != 0x82C6) && - (currentWord != 0x82C7) && (currentWord != 0x82D3) && (currentWord != 0x8367) && - (currentWord != 0x8368) && (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A3) || (currentSyllable == 0x8344)) && (prevSyllable != 0x82C6) && + (prevSyllable != 0x82C7) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8367) && + (prevSyllable != 0x8368) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A5) || (currentWord == 0x8346)) && (currentWord != 0x82A4) && - (currentWord != 0x82B5) && (currentWord != 0x82B6) && (currentWord != 0x82BF) && - (currentWord != 0x82C0) && (currentWord != 0x82C2) && (currentWord != 0x82D3) && - (currentWord != 0x8345) && (currentWord != 0x8356) && (currentWord != 0x8357) && - (currentWord != 0x8360) && (currentWord != 0x8361) && (currentWord != 0x8363) && - (currentWord != 0x8374) && (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A5) || (currentSyllable == 0x8346)) && (prevSyllable != 0x82A4) && + (prevSyllable != 0x82B5) && (prevSyllable != 0x82B6) && (prevSyllable != 0x82BF) && + (prevSyllable != 0x82C0) && (prevSyllable != 0x82C2) && (prevSyllable != 0x82D3) && + (prevSyllable != 0x8345) && (prevSyllable != 0x8356) && (prevSyllable != 0x8357) && + (prevSyllable != 0x8360) && (prevSyllable != 0x8361) && (prevSyllable != 0x8363) && + (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82A7) || (currentWord == 0x8348)) && (currentWord != 0x82A4) && - (currentWord != 0x82D3) && (currentWord != 0x8345) && (currentWord != 0x8374) && - (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82A7) || (currentSyllable == 0x8348)) && (prevSyllable != 0x82A4) && + (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8374) && + (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82E1) || (currentWord == 0x82E3) || (currentWord == 0x82E5) || - (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387)) && - (currentWord != 0x82AB) && (currentWord != 0x82B5) && (currentWord != 0x82BF) && - (currentWord != 0x82C9) && (currentWord != 0x82D0) && (currentWord != 0x82DD) && - (currentWord != 0x82E8) && (currentWord != 0x82AC) && (currentWord != 0x82B6) && - (currentWord != 0x82C0) && (currentWord != 0x82D1) && (currentWord != 0x82D2) && - (currentWord != 0x834C) && (currentWord != 0x8356) && (currentWord != 0x8360) && - (currentWord != 0x836A) && (currentWord != 0x8371) && (currentWord != 0x837E) && - (currentWord != 0x838A) && (currentWord != 0x834D) && (currentWord != 0x8357) && - (currentWord != 0x8361) && (currentWord != 0x8372) && (currentWord != 0x8373) && - (currentWord != 0x8394)) { + } else if (((currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || (currentSyllable == 0x82E5) || + (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387)) && + (prevSyllable != 0x82AB) && (prevSyllable != 0x82B5) && (prevSyllable != 0x82BF) && + (prevSyllable != 0x82C9) && (prevSyllable != 0x82D0) && (prevSyllable != 0x82DD) && + (prevSyllable != 0x82E8) && (prevSyllable != 0x82AC) && (prevSyllable != 0x82B6) && + (prevSyllable != 0x82C0) && (prevSyllable != 0x82D1) && (prevSyllable != 0x82D2) && + (prevSyllable != 0x834C) && (prevSyllable != 0x8356) && (prevSyllable != 0x8360) && + (prevSyllable != 0x836A) && (prevSyllable != 0x8371) && (prevSyllable != 0x837E) && + (prevSyllable != 0x838A) && (prevSyllable != 0x834D) && (prevSyllable != 0x8357) && + (prevSyllable != 0x8361) && (prevSyllable != 0x8372) && (prevSyllable != 0x8373) && + (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((currentWord == 0x815B) && ((currentWord == 0x82F1) || (currentWord == 0x82C1) || - (currentWord == 0x8393) || (currentWord == 0x8362))) { + } else if ((currentSyllable == 0x815B) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x82C1) || + (prevSyllable == 0x8393) || (prevSyllable == 0x8362))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82F1) || (currentWord == 0x8393)) && - ((currentWord == 0x82F1) || (currentWord == 0x8393))) { + } else if (((currentSyllable == 0x82F1) || (currentSyllable == 0x8393)) && + ((prevSyllable == 0x82F1) || (prevSyllable == 0x8393))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentWord == 0x82C1) || (currentWord == 0x8362)) && - ((currentWord == 0x815B) || (currentWord == 0x82A0) || (currentWord == 0x82A2) || - (currentWord == 0x82A4) || (currentWord == 0x82A6) || (currentWord == 0x82A8) || - (currentWord == 0x82C8) || (currentWord == 0x82C9) || (currentWord == 0x82CA) || - (currentWord == 0x82CB) || (currentWord == 0x82CC) || (currentWord == 0x82DC) || - (currentWord == 0x82DD) || (currentWord == 0x82DE) || (currentWord == 0x82DF) || - (currentWord == 0x82E0) || (currentWord == 0x82E2) || (currentWord == 0x82E4) || - (currentWord == 0x82E6) || (currentWord == 0x82E7) || (currentWord == 0x82E8) || - (currentWord == 0x82E9) || (currentWord == 0x82EA) || (currentWord == 0x82EB) || - (currentWord == 0x82ED) || (currentWord == 0x82EE) || (currentWord == 0x82EF) || - (currentWord == 0x82F0) || (currentWord == 0x82F1) || (currentWord == 0x829F) || - (currentWord == 0x82A1) || (currentWord == 0x82A3) || (currentWord == 0x82A5) || - (currentWord == 0x82A7) || (currentWord == 0x82E1) || (currentWord == 0x82E3) || - (currentWord == 0x82E5) || (currentWord == 0x82C1) || (currentWord == 0x82EC) || - (currentWord == 0x8341) || (currentWord == 0x8343) || (currentWord == 0x8345) || - (currentWord == 0x8347) || (currentWord == 0x8349) || (currentWord == 0x8369) || - (currentWord == 0x836A) || (currentWord == 0x836B) || (currentWord == 0x836C) || - (currentWord == 0x836D) || (currentWord == 0x837D) || (currentWord == 0x837E) || - (currentWord == 0x8380) || (currentWord == 0x8381) || (currentWord == 0x8382) || - (currentWord == 0x8384) || (currentWord == 0x8386) || (currentWord == 0x8388) || - (currentWord == 0x8389) || (currentWord == 0x838A) || (currentWord == 0x838B) || - (currentWord == 0x838C) || (currentWord == 0x838D) || (currentWord == 0x838F) || - (currentWord == 0x8390) || (currentWord == 0x8391) || (currentWord == 0x8392) || - (currentWord == 0x8393) || (currentWord == 0x8340) || (currentWord == 0x8342) || - (currentWord == 0x8344) || (currentWord == 0x8346) || (currentWord == 0x8348) || - (currentWord == 0x8383) || (currentWord == 0x8385) || (currentWord == 0x8387) || - (currentWord == 0x8362) || (currentWord == 0x838E))) { + } else if (((prevSyllable == 0x82C1) || (prevSyllable == 0x8362)) && + ((currentSyllable == 0x815B) || (currentSyllable == 0x82A0) || (currentSyllable == 0x82A2) || + (currentSyllable == 0x82A4) || (currentSyllable == 0x82A6) || (currentSyllable == 0x82A8) || + (currentSyllable == 0x82C8) || (currentSyllable == 0x82C9) || (currentSyllable == 0x82CA) || + (currentSyllable == 0x82CB) || (currentSyllable == 0x82CC) || (currentSyllable == 0x82DC) || + (currentSyllable == 0x82DD) || (currentSyllable == 0x82DE) || (currentSyllable == 0x82DF) || + (currentSyllable == 0x82E0) || (currentSyllable == 0x82E2) || (currentSyllable == 0x82E4) || + (currentSyllable == 0x82E6) || (currentSyllable == 0x82E7) || (currentSyllable == 0x82E8) || + (currentSyllable == 0x82E9) || (currentSyllable == 0x82EA) || (currentSyllable == 0x82EB) || + (currentSyllable == 0x82ED) || (currentSyllable == 0x82EE) || (currentSyllable == 0x82EF) || + (currentSyllable == 0x82F0) || (currentSyllable == 0x82F1) || (currentSyllable == 0x829F) || + (currentSyllable == 0x82A1) || (currentSyllable == 0x82A3) || (currentSyllable == 0x82A5) || + (currentSyllable == 0x82A7) || (currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || + (currentSyllable == 0x82E5) || (currentSyllable == 0x82C1) || (currentSyllable == 0x82EC) || + (currentSyllable == 0x8341) || (currentSyllable == 0x8343) || (currentSyllable == 0x8345) || + (currentSyllable == 0x8347) || (currentSyllable == 0x8349) || (currentSyllable == 0x8369) || + (currentSyllable == 0x836A) || (currentSyllable == 0x836B) || (currentSyllable == 0x836C) || + (currentSyllable == 0x836D) || (currentSyllable == 0x837D) || (currentSyllable == 0x837E) || + (currentSyllable == 0x8380) || (currentSyllable == 0x8381) || (currentSyllable == 0x8382) || + (currentSyllable == 0x8384) || (currentSyllable == 0x8386) || (currentSyllable == 0x8388) || + (currentSyllable == 0x8389) || (currentSyllable == 0x838A) || (currentSyllable == 0x838B) || + (currentSyllable == 0x838C) || (currentSyllable == 0x838D) || (currentSyllable == 0x838F) || + (currentSyllable == 0x8390) || (currentSyllable == 0x8391) || (currentSyllable == 0x8392) || + (currentSyllable == 0x8393) || (currentSyllable == 0x8340) || (currentSyllable == 0x8342) || + (currentSyllable == 0x8344) || (currentSyllable == 0x8346) || (currentSyllable == 0x8348) || + (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387) || + (currentSyllable == 0x8362) || (currentSyllable == 0x838E))) { errorCode = CONT_ERR_VOICE_WORD; } if (errorCode != 0) { return errorCode; } + + prevSyllable = currentSyllable; } - if ((currentWord == 0x82C1) || (currentWord == 0x8362)) { + if ((currentSyllable == 0x82C1) || (currentSyllable == 0x8362)) { errorCode = CONT_ERR_VOICE_WORD; } return errorCode; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicecheckword/osVoiceCheckWord.s") -#endif From 6bfbbddb1a3624226e4e7230bf2406b5603020f9 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 14:04:48 +1100 Subject: [PATCH 24/82] currentSyllable -> currSyllable --- src/libultra/voice/voicecheckword.c | 93 ++++++++++++++--------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/src/libultra/voice/voicecheckword.c b/src/libultra/voice/voicecheckword.c index 84f8985ab..b6694ac7f 100644 --- a/src/libultra/voice/voicecheckword.c +++ b/src/libultra/voice/voicecheckword.c @@ -4,45 +4,44 @@ s32 osVoiceCheckWord(u8* word) { s32 i; s32 errorCode = 0; - u16 currentSyllable; + u16 currSyllable; u16 prevSyllable = 0; for (i = 0; word[i] != 0; i += 2) { - currentSyllable = (word[i] << 8) + word[i + 1]; - if (((currentSyllable != 0x815B) && (currentSyllable < 0x829F)) || - ((currentSyllable >= 0x82F2) && (currentSyllable < 0x8340)) || (currentSyllable == 0x837F) || - (currentSyllable >= 0x8397)) { + currSyllable = (word[i] << 8) + word[i + 1]; + if (((currSyllable != 0x815B) && (currSyllable < 0x829F)) || + ((currSyllable >= 0x82F2) && (currSyllable < 0x8340)) || (currSyllable == 0x837F) || + (currSyllable >= 0x8397)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((i == 0) && - ((currentSyllable == 0x815B) || (currentSyllable == 0x82F1) || (currentSyllable == 0x82C1) || - (currentSyllable == 0x82EC) || (currentSyllable == 0x8393) || (currentSyllable == 0x8362) || - (currentSyllable == 0x838E) || (currentSyllable == 0x8395) || (currentSyllable == 0x8396))) { + } else if ((i == 0) && ((currSyllable == 0x815B) || (currSyllable == 0x82F1) || (currSyllable == 0x82C1) || + (currSyllable == 0x82EC) || (currSyllable == 0x8393) || (currSyllable == 0x8362) || + (currSyllable == 0x838E) || (currSyllable == 0x8395) || (currSyllable == 0x8396))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x829F) || (currentSyllable == 0x8340)) && (prevSyllable != 0x82D3) && + } else if (((currSyllable == 0x829F) || (currSyllable == 0x8340)) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A1) || (currentSyllable == 0x8342)) && (prevSyllable != 0x82A4) && + } else if (((currSyllable == 0x82A1) || (currSyllable == 0x8342)) && (prevSyllable != 0x82A4) && (prevSyllable != 0x82C4) && (prevSyllable != 0x82C5) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8365) && (prevSyllable != 0x8366) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A3) || (currentSyllable == 0x8344)) && (prevSyllable != 0x82C6) && + } else if (((currSyllable == 0x82A3) || (currSyllable == 0x8344)) && (prevSyllable != 0x82C6) && (prevSyllable != 0x82C7) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8367) && (prevSyllable != 0x8368) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A5) || (currentSyllable == 0x8346)) && (prevSyllable != 0x82A4) && + } else if (((currSyllable == 0x82A5) || (currSyllable == 0x8346)) && (prevSyllable != 0x82A4) && (prevSyllable != 0x82B5) && (prevSyllable != 0x82B6) && (prevSyllable != 0x82BF) && (prevSyllable != 0x82C0) && (prevSyllable != 0x82C2) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8356) && (prevSyllable != 0x8357) && (prevSyllable != 0x8360) && (prevSyllable != 0x8361) && (prevSyllable != 0x8363) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82A7) || (currentSyllable == 0x8348)) && (prevSyllable != 0x82A4) && + } else if (((currSyllable == 0x82A7) || (currSyllable == 0x8348)) && (prevSyllable != 0x82A4) && (prevSyllable != 0x82D3) && (prevSyllable != 0x8345) && (prevSyllable != 0x8374) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || (currentSyllable == 0x82E5) || - (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387)) && + } else if (((currSyllable == 0x82E1) || (currSyllable == 0x82E3) || (currSyllable == 0x82E5) || + (currSyllable == 0x8383) || (currSyllable == 0x8385) || (currSyllable == 0x8387)) && (prevSyllable != 0x82AB) && (prevSyllable != 0x82B5) && (prevSyllable != 0x82BF) && (prevSyllable != 0x82C9) && (prevSyllable != 0x82D0) && (prevSyllable != 0x82DD) && (prevSyllable != 0x82E8) && (prevSyllable != 0x82AC) && (prevSyllable != 0x82B6) && @@ -53,39 +52,39 @@ s32 osVoiceCheckWord(u8* word) { (prevSyllable != 0x8361) && (prevSyllable != 0x8372) && (prevSyllable != 0x8373) && (prevSyllable != 0x8394)) { errorCode = CONT_ERR_VOICE_WORD; - } else if ((currentSyllable == 0x815B) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x82C1) || - (prevSyllable == 0x8393) || (prevSyllable == 0x8362))) { + } else if ((currSyllable == 0x815B) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x82C1) || + (prevSyllable == 0x8393) || (prevSyllable == 0x8362))) { errorCode = CONT_ERR_VOICE_WORD; - } else if (((currentSyllable == 0x82F1) || (currentSyllable == 0x8393)) && + } else if (((currSyllable == 0x82F1) || (currSyllable == 0x8393)) && ((prevSyllable == 0x82F1) || (prevSyllable == 0x8393))) { errorCode = CONT_ERR_VOICE_WORD; } else if (((prevSyllable == 0x82C1) || (prevSyllable == 0x8362)) && - ((currentSyllable == 0x815B) || (currentSyllable == 0x82A0) || (currentSyllable == 0x82A2) || - (currentSyllable == 0x82A4) || (currentSyllable == 0x82A6) || (currentSyllable == 0x82A8) || - (currentSyllable == 0x82C8) || (currentSyllable == 0x82C9) || (currentSyllable == 0x82CA) || - (currentSyllable == 0x82CB) || (currentSyllable == 0x82CC) || (currentSyllable == 0x82DC) || - (currentSyllable == 0x82DD) || (currentSyllable == 0x82DE) || (currentSyllable == 0x82DF) || - (currentSyllable == 0x82E0) || (currentSyllable == 0x82E2) || (currentSyllable == 0x82E4) || - (currentSyllable == 0x82E6) || (currentSyllable == 0x82E7) || (currentSyllable == 0x82E8) || - (currentSyllable == 0x82E9) || (currentSyllable == 0x82EA) || (currentSyllable == 0x82EB) || - (currentSyllable == 0x82ED) || (currentSyllable == 0x82EE) || (currentSyllable == 0x82EF) || - (currentSyllable == 0x82F0) || (currentSyllable == 0x82F1) || (currentSyllable == 0x829F) || - (currentSyllable == 0x82A1) || (currentSyllable == 0x82A3) || (currentSyllable == 0x82A5) || - (currentSyllable == 0x82A7) || (currentSyllable == 0x82E1) || (currentSyllable == 0x82E3) || - (currentSyllable == 0x82E5) || (currentSyllable == 0x82C1) || (currentSyllable == 0x82EC) || - (currentSyllable == 0x8341) || (currentSyllable == 0x8343) || (currentSyllable == 0x8345) || - (currentSyllable == 0x8347) || (currentSyllable == 0x8349) || (currentSyllable == 0x8369) || - (currentSyllable == 0x836A) || (currentSyllable == 0x836B) || (currentSyllable == 0x836C) || - (currentSyllable == 0x836D) || (currentSyllable == 0x837D) || (currentSyllable == 0x837E) || - (currentSyllable == 0x8380) || (currentSyllable == 0x8381) || (currentSyllable == 0x8382) || - (currentSyllable == 0x8384) || (currentSyllable == 0x8386) || (currentSyllable == 0x8388) || - (currentSyllable == 0x8389) || (currentSyllable == 0x838A) || (currentSyllable == 0x838B) || - (currentSyllable == 0x838C) || (currentSyllable == 0x838D) || (currentSyllable == 0x838F) || - (currentSyllable == 0x8390) || (currentSyllable == 0x8391) || (currentSyllable == 0x8392) || - (currentSyllable == 0x8393) || (currentSyllable == 0x8340) || (currentSyllable == 0x8342) || - (currentSyllable == 0x8344) || (currentSyllable == 0x8346) || (currentSyllable == 0x8348) || - (currentSyllable == 0x8383) || (currentSyllable == 0x8385) || (currentSyllable == 0x8387) || - (currentSyllable == 0x8362) || (currentSyllable == 0x838E))) { + ((currSyllable == 0x815B) || (currSyllable == 0x82A0) || (currSyllable == 0x82A2) || + (currSyllable == 0x82A4) || (currSyllable == 0x82A6) || (currSyllable == 0x82A8) || + (currSyllable == 0x82C8) || (currSyllable == 0x82C9) || (currSyllable == 0x82CA) || + (currSyllable == 0x82CB) || (currSyllable == 0x82CC) || (currSyllable == 0x82DC) || + (currSyllable == 0x82DD) || (currSyllable == 0x82DE) || (currSyllable == 0x82DF) || + (currSyllable == 0x82E0) || (currSyllable == 0x82E2) || (currSyllable == 0x82E4) || + (currSyllable == 0x82E6) || (currSyllable == 0x82E7) || (currSyllable == 0x82E8) || + (currSyllable == 0x82E9) || (currSyllable == 0x82EA) || (currSyllable == 0x82EB) || + (currSyllable == 0x82ED) || (currSyllable == 0x82EE) || (currSyllable == 0x82EF) || + (currSyllable == 0x82F0) || (currSyllable == 0x82F1) || (currSyllable == 0x829F) || + (currSyllable == 0x82A1) || (currSyllable == 0x82A3) || (currSyllable == 0x82A5) || + (currSyllable == 0x82A7) || (currSyllable == 0x82E1) || (currSyllable == 0x82E3) || + (currSyllable == 0x82E5) || (currSyllable == 0x82C1) || (currSyllable == 0x82EC) || + (currSyllable == 0x8341) || (currSyllable == 0x8343) || (currSyllable == 0x8345) || + (currSyllable == 0x8347) || (currSyllable == 0x8349) || (currSyllable == 0x8369) || + (currSyllable == 0x836A) || (currSyllable == 0x836B) || (currSyllable == 0x836C) || + (currSyllable == 0x836D) || (currSyllable == 0x837D) || (currSyllable == 0x837E) || + (currSyllable == 0x8380) || (currSyllable == 0x8381) || (currSyllable == 0x8382) || + (currSyllable == 0x8384) || (currSyllable == 0x8386) || (currSyllable == 0x8388) || + (currSyllable == 0x8389) || (currSyllable == 0x838A) || (currSyllable == 0x838B) || + (currSyllable == 0x838C) || (currSyllable == 0x838D) || (currSyllable == 0x838F) || + (currSyllable == 0x8390) || (currSyllable == 0x8391) || (currSyllable == 0x8392) || + (currSyllable == 0x8393) || (currSyllable == 0x8340) || (currSyllable == 0x8342) || + (currSyllable == 0x8344) || (currSyllable == 0x8346) || (currSyllable == 0x8348) || + (currSyllable == 0x8383) || (currSyllable == 0x8385) || (currSyllable == 0x8387) || + (currSyllable == 0x8362) || (currSyllable == 0x838E))) { errorCode = CONT_ERR_VOICE_WORD; } @@ -93,10 +92,10 @@ s32 osVoiceCheckWord(u8* word) { return errorCode; } - prevSyllable = currentSyllable; + prevSyllable = currSyllable; } - if ((currentSyllable == 0x82C1) || (currentSyllable == 0x8362)) { + if ((currSyllable == 0x82C1) || (currSyllable == 0x8362)) { errorCode = CONT_ERR_VOICE_WORD; } From 46c5a5a141532634631f8fc72d0cb5b2e832e3bb Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 19:42:39 +1100 Subject: [PATCH 25/82] Match osVoiceMaskDictionary --- src/libultra/voice/voicemaskdictionary.c | 47 +++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/libultra/voice/voicemaskdictionary.c b/src/libultra/voice/voicemaskdictionary.c index e82a27b81..21c01b8a5 100644 --- a/src/libultra/voice/voicemaskdictionary.c +++ b/src/libultra/voice/voicemaskdictionary.c @@ -1,4 +1,49 @@ #include "global.h" // Mask words registered in the voice recognition system -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicemaskdictionary/osVoiceMaskDictionary.s") +s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size) { + s32 errorCode; + s32 i; + s32 sp3C; + u8 status; + u8 data[20]; + + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); + if (errorCode != 0) { + return errorCode; + } + + if (status & 2) { + return CONT_ERR_VOICE_NO_RESPONSE; + } + + if (size & 1) { + sp3C = size + 1; + } else { + sp3C = size; + } + + bzero(&data, 20); + + data[18 - sp3C] = 4; + + for (i = 0; i < sp3C; i += 2) { + data[i + 20 - sp3C] = maskPattern[i]; + data[i + 21 - sp3C] = maskPattern[i+1]; + } + + if (size & 1) { + data[19] = 0; + } + + errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data); + if (errorCode == 0) { + errorCode = __osVoiceCheckResult(hd, &status); + if (errorCode & 0xFF00) { + errorCode = CONT_ERR_INVALID; + } + } + + return errorCode; +} + From a74c2605e656b4b00128463572e2efc0b5c399dd Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 19:55:32 +1100 Subject: [PATCH 26/82] Match __osVoiceSetADConverter --- src/libultra/voice/voicesetadconverter.c | 65 +++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/libultra/voice/voicesetadconverter.c b/src/libultra/voice/voicesetadconverter.c index c1b8fa002..fdfe49ecf 100644 --- a/src/libultra/voice/voicesetadconverter.c +++ b/src/libultra/voice/voicesetadconverter.c @@ -1,3 +1,66 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicesetadconverter/__osVoiceSetADConverter.s") +s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2) { + s32 errorCode; + u8* ptr; + s32 retryCount = 2; + u8 status; + u16 sp48; + s32 i; + + __osSiGetAccess(); + + sp48 = arg2 * 8; + + do { + + ptr = (u8*)&__osPfsPifRam; + + if ((__osContLastCmd != 0xD) || (port != D_80097FB0)) { + __osContLastCmd = 0xD; + D_80097FB0 = port; + + for (i = 0; i < port; i++, *ptr++ = 0) { + ; + } + + __osPfsPifRam.pifstatus = CONT_CMD_READ_BUTTON; + + ptr[0] = 3; + ptr[1] = 1; + ptr[2] = 0xD; + ptr[5] = 0; + ptr[6] = 0xFE; + } else { + ptr = (u8*)&__osPfsPifRam + port; + } + + ptr[3] = arg2; + ptr[4] = __osContAddressCrc(sp48); + + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + __osSiRawStartDma(OS_READ, &__osPfsPifRam); + osRecvMesg(mq, NULL, OS_MESG_BLOCK); + + errorCode = (ptr[1] & 0xC0) >> 4; + + if (errorCode == 0) { + if (ptr[5] & 1) { + errorCode = __osVoiceGetStatus(mq, port, &status); + if (errorCode != 0) { + break; + } + + errorCode = CONT_ERR_CONTRFAIL; + } + } else { + errorCode = CONT_ERR_NO_CONTROLLER; + } + + } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); + + __osSiRelAccess(); + + return errorCode; +} From b7858effd5c4f1e729f6bd08ade1b2b536fbaddc Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 22:09:52 +1100 Subject: [PATCH 27/82] Meme matched osVoiceStopReadData --- src/libultra/voice/voicestopread.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 4c9a1dc88..a5d9456e1 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -1,10 +1,9 @@ #include "global.h" // Forcibly stops voice recognition processing by the Voice Recognition System -#ifdef NON_EQUIVALENT s32 osVoiceStopReadData(OSVoiceHandle* hd) { - s32 i; s32 errorCode; + s32 i; u8 sp3F; s32 sp38; @@ -25,28 +24,24 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp38); if (errorCode == 0) { - for (i = 0; i < 20; i++) { + i = 0; + do { errorCode = __osVoiceCheckResult(hd, &sp3F); if (errorCode & 0xFF00) { if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) { - if (hd) {} errorCode = 0; hd->mode = 0; } else { - errorCode = CONT_ERR_INVALID; + errorCode = 5; } } else { hd->mode = 0; } - - if (errorCode != CONT_ERR_VOICE_NO_RESPONSE) { - break; - } - } + i++; + } while ((errorCode == 15) && (i < 20)); } + if (i) {} + return errorCode; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicestopread/osVoiceStopReadData.s") -#endif From 5ca6f07f1898662af69a3b1dcc304b4ca3b04ffc Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 22:12:45 +1100 Subject: [PATCH 28/82] small cleanup --- src/libultra/voice/voiceinit.c | 2 +- src/libultra/voice/voicestartreaddata.c | 2 +- src/libultra/voice/voicestopread.c | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 8a1aeac11..0cd5aba2b 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -9,7 +9,7 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { u8* phi_s0; u8 status = 0; union { - s32 data32; + u32 data32; u8 data[4]; } u; s32 pad; diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index 07032ba67..e3f6854bf 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -5,7 +5,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { s32 errorCode; u8 status; union { - s32 data32; + u32 data32; u8 data[4]; } u; diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index a5d9456e1..85fc02130 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -4,15 +4,18 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { s32 errorCode; s32 i; - u8 sp3F; - s32 sp38; + u8 status; + union { + u32 data32; + u8 data[4]; + } u; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &sp3F); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &status); if (errorCode != 0) { return errorCode; } - if (sp3F & 2) { + if (status & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } @@ -20,13 +23,19 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { return CONT_ERR_INVALID; } - sp38 = 0x700; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, &sp38); + /** + * data[0] = 0 + * data[1] = 0 + * data[2] = 7 + * data[3] = 0 + */ + u.data32 = 0x700; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); if (errorCode == 0) { i = 0; do { - errorCode = __osVoiceCheckResult(hd, &sp3F); + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { if (((errorCode & 7) == 0) || ((errorCode & 7) == 7)) { errorCode = 0; From 9b94fe096456459d6d84e187b04f63ed907ae39c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 10 Nov 2021 22:14:26 +1100 Subject: [PATCH 29/82] Missed macros --- src/libultra/voice/voicestopread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 85fc02130..8254c0083 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -41,13 +41,13 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { errorCode = 0; hd->mode = 0; } else { - errorCode = 5; + errorCode = CONT_ERR_INVALID; } } else { hd->mode = 0; } i++; - } while ((errorCode == 15) && (i < 20)); + } while ((errorCode == CONT_ERR_VOICE_NO_RESPONSE) && (i < 20)); } if (i) {} From d9cdd69205239e6b5c2d42a85a0fb7ff2cce105c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 00:46:58 +1100 Subject: [PATCH 30/82] osVoiceGetReadData Meme Match --- src/libultra/voice/voicegetreaddata.c | 30 +++++++-------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 03f21e506..25a7f3026 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -1,11 +1,10 @@ #include "global.h" // Gets voice recognition result from the Voice Recognition System -#ifdef NON_EQUIVALENT s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { s32 errorCode; - u8 new_var; u8 temp_t9; + u8 new_var2; union { u8 sp38[40]; u32 sp38_32[10]; @@ -75,31 +74,19 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { result->voice_sn = u.sp38[10] + (u.sp38[11] << 8); result->voice_time = u.sp38[12] + (u.sp38[13] << 8); - // Issue here with for-loop unrolling - new_var = 4; for (i = 0; i < 5; i++) { - result->answer[i] = u.sp38[14 + new_var*i] + (u.sp38[15 + new_var*i] << 8); - result->distance[i] = u.sp38[16 + new_var*i] + (u.sp38[17 + new_var*i] << 8); + result->answer[i] = u.sp38[14 + 4 * (i ^ 0)] + (u.sp38[15 + 4 * (i ^ 0)] << 8); + result->distance[i] = u.sp38[16 + 4 * (i ^ 0)] + (u.sp38[17 + 4 * (i ^ 0)] << 8); } - - // result->answer[0] = u.sp38[14] + (u.sp38[15] << 8); - // result->distance[0] = u.sp38[16] + (u.sp38[17] << 8); - // result->answer[1] = u.sp38[18] + (u.sp38[19] << 8); - // result->distance[1] = u.sp38[20] + (u.sp38[21] << 8); - // result->answer[2] = u.sp38[22] + (u.sp38[23] << 8); - // result->distance[2] = u.sp38[24] + (u.sp38[25] << 8); - // result->answer[3] = u.sp38[26] + (u.sp38[27] << 8); - // result->distance[3] = u.sp38[28] + (u.sp38[29] << 8); - // result->answer[4] = u.sp38[30] + (u.sp38[31] << 8); - // result->distance[4] = u.sp38[32] + (u.sp38[33] << 8); if (result->answer[0] == 0x7FFF) { result->answer_num = 0; } - // Issue here with regalloc - hd->status = u.sp38[34] & 7; - if ((D_8009CF60 == 0) || (hd->status == 0)) { + new_var2 = D_8009CF60; + temp_t9 = u.sp38[34] ^ 0; + hd->status = temp_t9 & 7; + if ((new_var2 == 0) || (hd->status == 0)) { break; } case 4: @@ -131,6 +118,3 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { hd->mode = 0; return errorCode; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/boot/voicegetreaddata/osVoiceGetReadData.s") -#endif From 28ba1090fff4ea43df30a7768e793015eb3fab9e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 00:53:08 +1100 Subject: [PATCH 31/82] Small clean-up --- src/libultra/voice/voicegetreaddata.c | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 25a7f3026..40d7b5b0b 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -6,28 +6,28 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { u8 temp_t9; u8 new_var2; union { - u8 sp38[40]; - u32 sp38_32[10]; + u8 data[40]; + u32 data32[10]; } u; s32 i; switch (hd->mode) { case 1: - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 1) { + if (u.data[39] & 1) { return CONT_ERR_NOT_READY; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } - temp_t9 = u.sp38[0] & 7; + temp_t9 = u.data[0] & 7; hd->status = temp_t9; D_8009CF60 = temp_t9; if ((temp_t9 != 0) && (temp_t9 != 7)) { @@ -36,17 +36,17 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 2: hd->mode = 2; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 2) { + if (u.data[39] & 2) { return CONT_ERR_VOICE_NO_RESPONSE; } - u.sp38_32[0] = 0x600; - errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.sp38); + u.data32[0] = 0x600; + errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } @@ -54,29 +54,29 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 3: hd->mode = 3; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 1) { + if (u.data[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, u.sp38); + errorCode = __osVoiceContRead36(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } - result->warning = u.sp38[4] + (u.sp38[5] << 8); - result->answer_num = u.sp38[6]; - result->voice_level = u.sp38[8] + (u.sp38[9] << 8); - result->voice_sn = u.sp38[10] + (u.sp38[11] << 8); - result->voice_time = u.sp38[12] + (u.sp38[13] << 8); + result->warning = u.data[4] + (u.data[5] << 8); + result->answer_num = u.data[6]; + result->voice_level = u.data[8] + (u.data[9] << 8); + result->voice_sn = u.data[10] + (u.data[11] << 8); + result->voice_time = u.data[12] + (u.data[13] << 8); for (i = 0; i < 5; i++) { - result->answer[i] = u.sp38[14 + 4 * (i ^ 0)] + (u.sp38[15 + 4 * (i ^ 0)] << 8); - result->distance[i] = u.sp38[16 + 4 * (i ^ 0)] + (u.sp38[17 + 4 * (i ^ 0)] << 8); + result->answer[i] = u.data[14 + 4 * (i ^ 0)] + (u.data[15 + 4 * (i ^ 0)] << 8); + result->distance[i] = u.data[16 + 4 * (i ^ 0)] + (u.data[17 + 4 * (i ^ 0)] << 8); } if (result->answer[0] == 0x7FFF) { @@ -84,7 +84,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } new_var2 = D_8009CF60; - temp_t9 = u.sp38[34] ^ 0; + temp_t9 = u.data[34] ^ 0; hd->status = temp_t9 & 7; if ((new_var2 == 0) || (hd->status == 0)) { break; @@ -92,22 +92,22 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { case 4: hd->mode = 4; - errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.sp38[39]); + errorCode = __osVoiceGetStatus(hd->mq, hd->port, &u.data[39]); if (errorCode != 0) { return errorCode; } - if (u.sp38[39] & 1) { + if (u.data[39] & 1) { return CONT_ERR_VOICE_NO_RESPONSE; } - errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.sp38); + errorCode = __osVoiceContRead2(hd->mq, hd->port, 0, u.data); if (errorCode != 0) { return errorCode; } - hd->status = u.sp38[0] & 7; - if (u.sp38[0] & 7) { + hd->status = u.data[0] & 7; + if (u.data[0] & 7) { return CONT_ERR_VOICE_NO_RESPONSE; } From d5958dd7d8d51c25c74c8859e3e3391f893bab64 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 00:59:13 +1100 Subject: [PATCH 32/82] format --- src/libultra/voice/voicecleardictionary.c | 6 +++--- src/libultra/voice/voicecontread2.c | 3 +-- src/libultra/voice/voicecontread36.c | 2 +- src/libultra/voice/voicecontrolgain.c | 9 ++++----- src/libultra/voice/voicecontwrite20.c | 2 +- src/libultra/voice/voicecontwrite4.c | 2 +- src/libultra/voice/voicegetstatus.c | 2 +- src/libultra/voice/voiceinit.c | 7 +++---- src/libultra/voice/voicemaskdictionary.c | 3 +-- src/libultra/voice/voicesetadconverter.c | 2 +- src/libultra/voice/voicesetword.c | 2 +- src/libultra/voice/voicestartreaddata.c | 2 +- src/libultra/voice/voicestopread.c | 2 +- 13 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/libultra/voice/voicecleardictionary.c b/src/libultra/voice/voicecleardictionary.c index 719c7f0dc..bb93a2302 100644 --- a/src/libultra/voice/voicecleardictionary.c +++ b/src/libultra/voice/voicecleardictionary.c @@ -2,11 +2,11 @@ /** * Initializes Voice Recognition System word registration dictionary. - * + * * The dictionary is initialized so that the specified "numWords" can be * registered in the dictionary. 1-255 words can be registered in the dictionary. - * - * Words cannot be registered with the osVoiceSetWord before the dictionary + * + * Words cannot be registered with the osVoiceSetWord before the dictionary * is initialized with the osVoiceClearDictionary function */ s32 osVoiceClearDictionary(OSVoiceHandle* hd, u8 numWords) { diff --git a/src/libultra/voice/voicecontread2.c b/src/libultra/voice/voicecontread2.c index ce52e2be0..d0056a0ab 100644 --- a/src/libultra/voice/voicecontread2.c +++ b/src/libultra/voice/voicecontread2.c @@ -35,7 +35,7 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { ptr[4] = arg2 >> 3; ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); __osSiRawStartDma(OS_READ, &__osPfsPifRam); @@ -64,4 +64,3 @@ s32 __osVoiceContRead2(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[2]) { return errorCode; } - diff --git a/src/libultra/voice/voicecontread36.c b/src/libultra/voice/voicecontread36.c index 66067d239..f11e20d26 100644 --- a/src/libultra/voice/voicecontread36.c +++ b/src/libultra/voice/voicecontread36.c @@ -35,7 +35,7 @@ s32 __osVoiceContRead36(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[36]) { ptr[4] = arg2 >> 3; ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); __osSiRawStartDma(OS_READ, &__osPfsPifRam); diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index eb896bb72..1f2e73aac 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -7,7 +7,6 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { s32 errorCode; u8 phi_a2; - if (analog == 0) { phi_a2 = 0x18; } else { @@ -18,22 +17,22 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { if (errorCode != 0) { return errorCode; } - - if (!((digital < 8) && (digital >= 0))){ + + if (!((digital < 8) && (digital >= 0))) { goto dummy; } phi_a2 = D_80098180[digital] + 2; if (0) { - dummy: + dummy: return CONT_ERR_INVALID; } errorCode = __osVoiceSetADConverter(hd->mq, hd->port, phi_a2); if (errorCode != 0) { return errorCode; - } + } return errorCode; } diff --git a/src/libultra/voice/voicecontwrite20.c b/src/libultra/voice/voicecontwrite20.c index 9eba371c6..2d43c9f26 100644 --- a/src/libultra/voice/voicecontwrite20.c +++ b/src/libultra/voice/voicecontwrite20.c @@ -38,7 +38,7 @@ s32 __osVoiceContWrite20(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[20]) { ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); bcopy(dst, &ptr[6], 20); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); temp_s2 = __osVoiceContDataCrc(dst, 20); osRecvMesg(mq, NULL, OS_MESG_BLOCK); diff --git a/src/libultra/voice/voicecontwrite4.c b/src/libultra/voice/voicecontwrite4.c index 8e1af6bd8..eac29d27c 100644 --- a/src/libultra/voice/voicecontwrite4.c +++ b/src/libultra/voice/voicecontwrite4.c @@ -38,7 +38,7 @@ s32 __osVoiceContWrite4(OSMesgQueue* mq, s32 port, u16 arg2, u8 dst[4]) { ptr[5] = __osContAddressCrc(arg2) | (arg2 << 5); bcopy(dst, &ptr[6], 4); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); temp_s2 = __osVoiceContDataCrc(dst, 4); osRecvMesg(mq, NULL, OS_MESG_BLOCK); diff --git a/src/libultra/voice/voicegetstatus.c b/src/libultra/voice/voicegetstatus.c index e11dcb954..b305cad19 100644 --- a/src/libultra/voice/voicegetstatus.c +++ b/src/libultra/voice/voicegetstatus.c @@ -54,6 +54,6 @@ s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) { } while ((errorCode == CONT_ERR_CONTRFAIL) && (retryCount-- >= 0)); __osSiRelAccess(); - + return errorCode; } diff --git a/src/libultra/voice/voiceinit.c b/src/libultra/voice/voiceinit.c index 0cd5aba2b..6936070d5 100644 --- a/src/libultra/voice/voiceinit.c +++ b/src/libultra/voice/voiceinit.c @@ -17,7 +17,7 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { hd->port = channel; hd->mq = siMessageQ; hd->mode = 0; - + errorCode = __osVoiceGetStatus(siMessageQ, channel, &status); if (errorCode != 0) { return errorCode; @@ -55,14 +55,13 @@ s32 osVoiceInit(OSMesgQueue* siMessageQ, OSVoiceHandle* hd, s32 channel) { if (errorCode != 0) { return errorCode; } - + errorCode = __osVoiceCheckResult(hd, &status); if (errorCode & 0xFF00) { errorCode = CONT_ERR_INVALID; } - + return errorCode; } } } - diff --git a/src/libultra/voice/voicemaskdictionary.c b/src/libultra/voice/voicemaskdictionary.c index 21c01b8a5..e0e67c792 100644 --- a/src/libultra/voice/voicemaskdictionary.c +++ b/src/libultra/voice/voicemaskdictionary.c @@ -29,7 +29,7 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size) { for (i = 0; i < sp3C; i += 2) { data[i + 20 - sp3C] = maskPattern[i]; - data[i + 21 - sp3C] = maskPattern[i+1]; + data[i + 21 - sp3C] = maskPattern[i + 1]; } if (size & 1) { @@ -46,4 +46,3 @@ s32 osVoiceMaskDictionary(OSVoiceHandle* hd, u8* maskPattern, s32 size) { return errorCode; } - diff --git a/src/libultra/voice/voicesetadconverter.c b/src/libultra/voice/voicesetadconverter.c index fdfe49ecf..4dccec20f 100644 --- a/src/libultra/voice/voicesetadconverter.c +++ b/src/libultra/voice/voicesetadconverter.c @@ -37,7 +37,7 @@ s32 __osVoiceSetADConverter(OSMesgQueue* mq, s32 port, u8 arg2) { ptr[3] = arg2; ptr[4] = __osContAddressCrc(sp48); - + __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(mq, NULL, OS_MESG_BLOCK); __osSiRawStartDma(OS_READ, &__osPfsPifRam); diff --git a/src/libultra/voice/voicesetword.c b/src/libultra/voice/voicesetword.c index a5ef50348..377d80a47 100644 --- a/src/libultra/voice/voicesetword.c +++ b/src/libultra/voice/voicesetword.c @@ -37,7 +37,7 @@ s32 osVoiceSetWord(OSVoiceHandle* hd, u8* word) { if (errorCode != 0) { return errorCode; } - } + } errorCode = __osVoiceContWrite20(hd->mq, hd->port, 0, &data[20]); if (errorCode != 0) { diff --git a/src/libultra/voice/voicestartreaddata.c b/src/libultra/voice/voicestartreaddata.c index e3f6854bf..927edf223 100644 --- a/src/libultra/voice/voicestartreaddata.c +++ b/src/libultra/voice/voicestartreaddata.c @@ -33,7 +33,7 @@ s32 osVoiceStartReadData(OSVoiceHandle* hd) { if (errorCode == 0) { errorCode = __osVoiceCheckResult(hd, &status); - + if (errorCode & 0xFF00) { errorCode = CONT_ERR_INVALID; } else { diff --git a/src/libultra/voice/voicestopread.c b/src/libultra/voice/voicestopread.c index 8254c0083..0b126622c 100644 --- a/src/libultra/voice/voicestopread.c +++ b/src/libultra/voice/voicestopread.c @@ -31,7 +31,7 @@ s32 osVoiceStopReadData(OSVoiceHandle* hd) { */ u.data32 = 0x700; errorCode = __osVoiceContWrite4(hd->mq, hd->port, 0, u.data); - + if (errorCode == 0) { i = 0; do { From 158dede3f68891fcf1643af65a9e77b242931432 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 13:47:50 +1100 Subject: [PATCH 33/82] Properly split voice files from code --- spec | 1 + src/code/code_8019AF00.c | 16 ---------------- src/code/code_801A4EB0.c | 17 +++++++++++++++++ tools/disasm/files.txt | 1 + 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 src/code/code_801A4EB0.c diff --git a/spec b/spec index f3cd6c8ba..c54036abb 100644 --- a/spec +++ b/spec @@ -658,6 +658,7 @@ beginseg include "build/src/code/code_8019AF00.o" include "build/data/code/code_8019AF00.bss.o" include "build/data/code/code_801D55B0.data.o" + include "build/src/code/code_801A4EB0.o" include "build/src/code/code_801A51F0.o" include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" diff --git a/src/code/code_8019AF00.c b/src/code/code_8019AF00.c index 8f0d129ad..227384d0a 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/code_8019AF00.c @@ -411,19 +411,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DF4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4E64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4FD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A50C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5100.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A510C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5118.s") diff --git a/src/code/code_801A4EB0.c b/src/code/code_801A4EB0.c new file mode 100644 index 000000000..d3461c8f5 --- /dev/null +++ b/src/code/code_801A4EB0.c @@ -0,0 +1,17 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index b9a7a0dfd..15debf9f5 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -488,6 +488,7 @@ 0x8019AEB0 : "[PADDING]", 0x8019AEC0 : "code_8019AEC0", 0x8019AF00 : "code_8019AF00", + 0x801A4EB0 : "code_801A4EB0", 0x801A51F0 : "code_801A51F0", 0x801A5BC0 : "[PADDING]", 0x801A5BD0 : "code_801A5BD0", From 98ea63ce9fc3e15ae1376fb28df76360baee4267 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 13:54:59 +1100 Subject: [PATCH 34/82] Use proper flags for voice files --- Makefile | 3 +++ spec | 4 ++-- src/code/{ => audio}/code_801A4EB0.c | 0 src/code/{ => audio}/code_801A51F0.c | 0 4 files changed, 5 insertions(+), 2 deletions(-) rename src/code/{ => audio}/code_801A4EB0.c (100%) rename src/code/{ => audio}/code_801A51F0.c (100%) diff --git a/Makefile b/Makefile index b202b95c0..470d835d4 100644 --- a/Makefile +++ b/Makefile @@ -156,6 +156,8 @@ build/src/libultra/rmon/%.o: OPTFLAGS := -O2 build/src/libultra/flash/%.o: OPTFLAGS := -g build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 +build/src/code/audio/%.o: OPTFLAGS := -O2 + # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv build/src/boot_O2_g3/fault_drawer.o: CFLAGS += -trapuv @@ -172,6 +174,7 @@ build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $( build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- diff --git a/spec b/spec index c54036abb..36da46954 100644 --- a/spec +++ b/spec @@ -658,8 +658,8 @@ beginseg include "build/src/code/code_8019AF00.o" include "build/data/code/code_8019AF00.bss.o" include "build/data/code/code_801D55B0.data.o" - include "build/src/code/code_801A4EB0.o" - include "build/src/code/code_801A51F0.o" + include "build/src/code/audio/code_801A4EB0.o" + include "build/src/code/audio/code_801A51F0.o" include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" pad_text diff --git a/src/code/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c similarity index 100% rename from src/code/code_801A4EB0.c rename to src/code/audio/code_801A4EB0.c diff --git a/src/code/code_801A51F0.c b/src/code/audio/code_801A51F0.c similarity index 100% rename from src/code/code_801A51F0.c rename to src/code/audio/code_801A51F0.c From b640bac998439d58fcaf55e1480efbfbf24c208b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:01:05 +1100 Subject: [PATCH 35/82] Add basic docs for func_801A5AF0 --- include/functions.h | 2 +- src/code/audio/code_801A51F0.c | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2ed3bf63c..4b9982a63 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3980,7 +3980,7 @@ void func_801A4D00(void); // void func_801A5080(void); // void func_801A5100(void); // void func_801A5118(void); -UNK_TYPE func_801A51F0(UNK_TYPE arg0); +s32 func_801A51F0(s32 errorCode); // void func_801A5228(void); // void func_801A5390(void); // void func_801A53E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 6a40bf23a..10c47ffa7 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,16 +1,26 @@ #include "global.h" +/* +char D_801E0EC0[] = "Error %d\n" +char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n" +char D_801E0EF0[] = "NAI_VRS:dict error! (%d-%d %s)\n" +char D_801E0F10[] = "NAI_VRS:Ina_SetVruGain Error!\n" +char D_801E0F30[] = "NAI_VRS:mask on %d\n" +char D_801E0F48[] = "NAI_VRS:mask off %d\n" +char D_801E0F60[] = "NAI_VRS:answer No.:%d Dist:%d Warn:%04X Level:%5d SN:%5d (Num:%d)\n" +char D_801E0FA4[] = "NAI_VRS:error !! (ANS_MAX:%d DIST:%d WARNING:%04X LEVEL:%5d SN:%5d)\n" +*/ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/D_801E0EC0.s") -UNK_TYPE func_801A51F0(UNK_TYPE arg0) { - switch (arg0) { - case 1: - case 4: - case 5: - case 11: - case 13: - case 14: - case 15: +s32 func_801A51F0(s32 errorCode) { + switch (errorCode) { + case CONT_ERR_NO_CONTROLLER: + case CONT_ERR_CONTRFAIL: + case CONT_ERR_INVALID: + case CONT_ERR_DEVICE: + case CONT_ERR_VOICE_MEMORY: + case CONT_ERR_VOICE_WORD: + case CONT_ERR_VOICE_NO_RESPONSE: return -1; default: return 0; From 133cb7a74c17bc3c709d7ace464ad397f0afb39e Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:11:58 +1100 Subject: [PATCH 36/82] Import Voice Data --- spec | 1 - src/code/audio/code_801A51F0.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spec b/spec index 36da46954..8ba7c36ea 100644 --- a/spec +++ b/spec @@ -660,7 +660,6 @@ beginseg include "build/data/code/code_801D55B0.data.o" include "build/src/code/audio/code_801A4EB0.o" include "build/src/code/audio/code_801A51F0.o" - include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" pad_text include "build/src/code/code_801A5BD0.o" diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 10c47ffa7..76200ac90 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,5 +1,17 @@ #include "global.h" +char D_801D8E50[] = + "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" + "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" + "PE\0HO\0BO\0PO\0MA\0MI\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + +char D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" + "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" + "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " + "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + /* char D_801E0EC0[] = "Error %d\n" char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n" From e42e0c607c9697e4ecce53205b9b60e3b0db8482 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:26:20 +1100 Subject: [PATCH 37/82] Update matching functions in code_801A51F0 from audio WIP --- include/variables.h | 6 +-- src/code/audio/code_801A51F0.c | 75 ++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/include/variables.h b/include/variables.h index d3ecb8bb1..ea39ac82d 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1821,9 +1821,9 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8BD0; // extern UNK_TYPE4 D_801D8BD4; // extern UNK_TYPE1 D_801D8BE0; -// extern UNK_TYPE1 D_801D8E3C; +extern u8 D_801D8E3C; // extern UNK_TYPE4 D_801D8E40; -// extern UNK_TYPE2 D_801D8E44; +extern u16 D_801D8E44; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; @@ -3625,7 +3625,7 @@ extern OSMesg D_801FD034; // extern UNK_TYPE1 D_801FD5C4; // extern UNK_TYPE1 D_801FD5C8; // extern UNK_TYPE1 D_801FD5E8; -// extern UNK_TYPE1 D_801FD608; +extern u8 D_801FD608[]; // extern UNK_TYPE1 D_801FD610; // extern UNK_TYPE1 D_801FD710; // extern UNK_TYPE1 D_801FD8C0; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 76200ac90..20ae5b8e3 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,5 +1,23 @@ #include "global.h" +// padmgr functions +s32 func_80175008(); +void func_8017506C(s32); + +typedef struct { + /* 0x00 */ u8* unk_00; + /* 0x04 */ u8 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ u16 unk_0C; + /* 0x0E */ u16 unk_0E; + /* 0x10 */ u16 unk_10; + /* 0x12 */ u16 unk_12; + /* 0x14 */ u16 unk_14; +} OSVoiceUnk; // size = 0x18 + +extern OSVoiceUnk D_801FD5A0; +extern OSVoiceHandle D_801FD5B8; + char D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" @@ -41,17 +59,58 @@ s32 func_801A51F0(s32 errorCode) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5228.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5390.s") +s32 func_801A5390(void) { + s32 temp_t6; + s32 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A53DC.s") + temp_t6 = D_801FD5A0.unk_08; + D_801FD5A0.unk_08 = 0; + sp18 = func_80175008(); + osVoiceStartReadData(&D_801FD5B8); + func_8017506C(sp18); + return temp_t6; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A53E8.s") +s32 func_801A53DC(void) { + return D_801FD5A0.unk_00; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A541C.s") +void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { + D_801FD5A0.unk_0C = arg0; + D_801FD5A0.unk_0E = arg1; + D_801FD5A0.unk_10 = arg2; + D_801FD5A0.unk_12 = arg3; + D_801FD5A0.unk_14 = arg4; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5488.s") +void func_801A541C(s32 analog, s32 digital) { + s32 sp1C; + s32 sp18; -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54C4.s") + if (D_801FD5A0.unk_00 != 0) { + sp18 = func_80175008(); + sp1C = osVoiceControlGain(&D_801FD5B8, analog, digital); + func_8017506C(sp18); + if (sp1C != 0) { + func_801A51F0(sp1C); + } + } +} + +s32 func_801A5488(u8* word) { + s32 sp1C; + s32 sp18; + s32 temp_v0; + + sp18 = func_80175008(); + sp1C = osVoiceCheckWord(word); + func_8017506C(sp18); + return sp1C; +} + +UNK_PTR func_801A54C4(void) { + return &D_801FD608; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54D0.s") @@ -59,6 +118,8 @@ s32 func_801A51F0(s32 errorCode) { #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A10.s") +void func_801A5A10(void) { + D_801FD5A0.unk_00 = 0; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A1C.s") From d8bc20f1097ace6dc12f90dde65de00f48c3693b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 14:29:32 +1100 Subject: [PATCH 38/82] Update matching functions in code_801A4EB0 from audio WIP --- src/code/audio/code_801A4EB0.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index d3461c8f5..441a70472 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,17 +1,33 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") +void func_801A5680(u16 arg0); +void func_801A54D0(u16 arg0); + +void func_801A4EB0(void) { +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") +void func_801A5080(u16 arg0) { + if ((D_801D8E3C != 0) && (arg0 < 6)) { + func_801A5680(arg0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") +void func_801A50C0(u16 arg0) { + if ((D_801D8E3C != 0) && (arg0 < 6)) { + func_801A54D0(arg0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") +u16 func_801A5100(void) { + return D_801D8E44; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") +u8 func_801A510C(void) { + return D_801D8E3C; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") From eecc39d5c723a10f6695eee2c18cb849e36b2361 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 16:07:59 +1100 Subject: [PATCH 39/82] Match func_801A5A1C --- src/code/audio/code_801A51F0.c | 44 +++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 20ae5b8e3..91a827bfa 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -17,14 +17,15 @@ typedef struct { extern OSVoiceUnk D_801FD5A0; extern OSVoiceHandle D_801FD5B8; +extern u8 D_801FD610[]; -char D_801D8E50[] = +s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" "PE\0HO\0BO\0PO\0MA\0MI\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; -char D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" +s8 D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" @@ -122,4 +123,41 @@ void func_801A5A10(void) { D_801FD5A0.unk_00 = 0; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5A1C.s") +u8* func_801A5A1C(s8* arg0) { + u8* new_var1; + u8 i; + u8 j; + u8 temp_t6; + u8 temp_t8; + u8* new_var2; + u8 len = strlen(arg0); + + for (j = 0, i = 0; i < len; i += 2) { + + temp_t8 = arg0[i]; + temp_t6 = arg0[i + 1]; + + new_var1 = &temp_t8; + new_var2 = &temp_t6; + + if (temp_t8 == 0x83) { + D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40)]; + D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40) + 1]; + } else if (temp_t8 == 0x82) { + D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F)]; + D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F) + 1]; + } else if (temp_t8 == 0x81 && temp_t6 == 0x5B) { + D_801FD610[j++] = 0x2D; + D_801FD610[j++] = 0x2D; + } else { + D_801FD610[j++] = 0x20; + D_801FD610[j++] = 0x20; + } + } + + D_801FD610[i] = 0; + + return D_801FD610; + +} + From 8a9e49a8896dc120447765ad9527cc270f02a80c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 16:26:50 +1100 Subject: [PATCH 40/82] Match func_801A5228 --- src/code/audio/code_801A51F0.c | 55 ++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 91a827bfa..7dd3a523a 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -4,6 +4,9 @@ s32 func_80175008(); void func_8017506C(s32); +// internal voice functions +u8* func_801A5A1C(s8* arg0); + typedef struct { /* 0x00 */ u8* unk_00; /* 0x04 */ u8 unk_04; @@ -58,7 +61,49 @@ s32 func_801A51F0(s32 errorCode) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5228.s") +s32 func_801A5228(u8* arg0) { + s32 temp_s2; + s32 errorCode; + u8 temp_s1; + u8 i; + u32 indexTemp; + s32 index; + + D_801FD5A0.unk_04 = 0; + D_801FD5A0.unk_08 = 0; + D_801FD5A0.unk_0C = 1000; + D_801FD5A0.unk_0E = 5; + D_801FD5A0.unk_10 = 0; + D_801FD5A0.unk_00 = arg0; + + temp_s1 = arg0[600]; + temp_s2 = func_80175008(); + errorCode = osVoiceClearDictionary(&D_801FD5B8, temp_s1); + func_8017506C(temp_s2); + + if (errorCode != 0) { + return errorCode; + } + + for (i = 0; i < (((temp_s1 - 1) / 8) + 1); i++) { + D_801FD608[i] = 0; + + } + + for (i = 0; i < temp_s1; i++) { + temp_s2 = func_80175008(); + indexTemp = i; + index = indexTemp * 30; + errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); + func_8017506C(temp_s2); + + if (func_801A51F0(errorCode) != 0) { + func_801A5A1C(&arg0[index]); + } + } + + return errorCode; +} s32 func_801A5390(void) { s32 temp_t6; @@ -124,12 +169,12 @@ void func_801A5A10(void) { } u8* func_801A5A1C(s8* arg0) { - u8* new_var1; + u8* indexTemp1; u8 i; u8 j; u8 temp_t6; u8 temp_t8; - u8* new_var2; + u8* index; u8 len = strlen(arg0); for (j = 0, i = 0; i < len; i += 2) { @@ -137,8 +182,8 @@ u8* func_801A5A1C(s8* arg0) { temp_t8 = arg0[i]; temp_t6 = arg0[i + 1]; - new_var1 = &temp_t8; - new_var2 = &temp_t6; + indexTemp1 = &temp_t8; + index = &temp_t6; if (temp_t8 == 0x83) { D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40)]; From aafe1b4e153972568c68ae0e0e8158e6c9c2367d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 17:02:28 +1100 Subject: [PATCH 41/82] Match func_801A54D0 --- src/code/audio/code_801A51F0.c | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 7dd3a523a..23a3e03e8 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -21,6 +21,7 @@ typedef struct { extern OSVoiceUnk D_801FD5A0; extern OSVoiceHandle D_801FD5B8; extern u8 D_801FD610[]; +extern s8 D_801FD5A4; s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" @@ -158,7 +159,51 @@ UNK_PTR func_801A54C4(void) { return &D_801FD608; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A54D0.s") +s32 func_801A54D0(u16 arg0) { + s32 errorCode; + u8 phi_t0; + u8 sp22; + u8 i; + s32 sp1C; + + phi_t0 = true; + if (D_801FD5A0.unk_00 != 0) { + sp22 = D_801FD5A0.unk_00[0x258]; + } else { + sp22 = 0x14; + phi_t0 = false; + } + + if (arg0 == 0xFFFF) { + for (i = 0; i < sp22; i++) { + D_801FD608[i / 8] |= 1 << (i % 8); + } + } else { + if (D_801FD608[arg0 / 8] & (1 << (arg0 % 8))) { + phi_t0 = false; + } else { + D_801FD608[arg0 / 8] |= (1 << (arg0 % 8)); + } + } + + if (phi_t0) { + sp1C = func_80175008(); + errorCode = osVoiceStopReadData(&D_801FD5B8); + func_8017506C(sp1C); + + if ((errorCode == 0) || (D_801FD5A4 == 0)) { + sp1C = func_80175008(); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + func_8017506C(sp1C); + } + + D_801FD5A4 = 0; + } + + return errorCode; +} + + #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5680.s") From b1cfaaff8b914101b0b52a9e14f4eeb937c9a971 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 17:13:14 +1100 Subject: [PATCH 42/82] Doc padmgr functions used --- include/functions.h | 4 +-- src/code/audio/code_801A51F0.c | 52 ++++++++++++++++++---------------- src/code/padmgr.c | 4 +-- tools/disasm/functions.txt | 4 +-- tools/sizes/code_functions.csv | 4 +-- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/include/functions.h b/include/functions.h index 4b9982a63..72b802e34 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3191,9 +3191,9 @@ u32 Padmgr_GetControllerBitmask(void); // void func_80174F7C(void); // void func_80174F9C(void); // OSMesgQueue* Padmgr_GetEventCallback(void); -// void func_80175008(void); +OSMesgQueue* PadMgr_LockSerialMesgQueue(); void Padmgr_SetEventCallback(OSMesg pvParm1); -// void func_8017506C(void); +void PadMgr_UnlockSerialMesgQueue(OSMesgQueue* msgQ); // void Padmgr_Lock(void); // void Padmgr_Unlock(void); // void func_801750FC(void); diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 23a3e03e8..bcbf50bd7 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,9 +1,5 @@ #include "global.h" -// padmgr functions -s32 func_80175008(); -void func_8017506C(s32); - // internal voice functions u8* func_801A5A1C(s8* arg0); @@ -63,7 +59,7 @@ s32 func_801A51F0(s32 errorCode) { } s32 func_801A5228(u8* arg0) { - s32 temp_s2; + OSMesgQueue* msgQ; s32 errorCode; u8 temp_s1; u8 i; @@ -78,9 +74,10 @@ s32 func_801A5228(u8* arg0) { D_801FD5A0.unk_00 = arg0; temp_s1 = arg0[600]; - temp_s2 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceClearDictionary(&D_801FD5B8, temp_s1); - func_8017506C(temp_s2); + PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { return errorCode; @@ -92,11 +89,12 @@ s32 func_801A5228(u8* arg0) { } for (i = 0; i < temp_s1; i++) { - temp_s2 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); indexTemp = i; index = indexTemp * 30; errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); - func_8017506C(temp_s2); + PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) != 0) { func_801A5A1C(&arg0[index]); @@ -108,13 +106,15 @@ s32 func_801A5228(u8* arg0) { s32 func_801A5390(void) { s32 temp_t6; - s32 sp18; + OSMesgQueue* msgQ; temp_t6 = D_801FD5A0.unk_08; D_801FD5A0.unk_08 = 0; - sp18 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStartReadData(&D_801FD5B8); - func_8017506C(sp18); + PadMgr_UnlockSerialMesgQueue(msgQ); + return temp_t6; } @@ -132,12 +132,14 @@ void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { void func_801A541C(s32 analog, s32 digital) { s32 sp1C; - s32 sp18; + OSMesgQueue* msgQ; if (D_801FD5A0.unk_00 != 0) { - sp18 = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); sp1C = osVoiceControlGain(&D_801FD5B8, analog, digital); - func_8017506C(sp18); + PadMgr_UnlockSerialMesgQueue(msgQ); + if (sp1C != 0) { func_801A51F0(sp1C); } @@ -146,12 +148,13 @@ void func_801A541C(s32 analog, s32 digital) { s32 func_801A5488(u8* word) { s32 sp1C; - s32 sp18; + OSMesgQueue* msgQ; s32 temp_v0; - sp18 = func_80175008(); + msgQ = PadMgr_LockSerialMesgQueue(); sp1C = osVoiceCheckWord(word); - func_8017506C(sp18); + PadMgr_UnlockSerialMesgQueue(msgQ); + return sp1C; } @@ -164,7 +167,7 @@ s32 func_801A54D0(u16 arg0) { u8 phi_t0; u8 sp22; u8 i; - s32 sp1C; + OSMesgQueue* msgQ; phi_t0 = true; if (D_801FD5A0.unk_00 != 0) { @@ -187,16 +190,17 @@ s32 func_801A54D0(u16 arg0) { } if (phi_t0) { - sp1C = func_80175008(); + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStopReadData(&D_801FD5B8); - func_8017506C(sp1C); + PadMgr_UnlockSerialMesgQueue(msgQ); if ((errorCode == 0) || (D_801FD5A4 == 0)) { - sp1C = func_80175008(); + + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); - func_8017506C(sp1C); + PadMgr_UnlockSerialMesgQueue(msgQ); } - + D_801FD5A4 = 0; } diff --git a/src/code/padmgr.c b/src/code/padmgr.c index 0d539126a..dbe85053c 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -13,11 +13,11 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_GetEventCallback.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175008.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_LockSerialMesgQueue.s") #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_SetEventCallback.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017506C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_UnlockSerialMesgQueue.s") #pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Lock.s") diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b6ec70b65..548615ba9 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3170,9 +3170,9 @@ 0x80174F7C:("func_80174F7C",), 0x80174F9C:("func_80174F9C",), 0x80174FD4:("Padmgr_GetEventCallback",), - 0x80175008:("func_80175008",), + 0x80175008:("PadMgr_LockSerialMesgQueue",), 0x8017503C:("Padmgr_SetEventCallback",), - 0x8017506C:("func_8017506C",), + 0x8017506C:("PadMgr_UnlockSerialMesgQueue",), 0x8017509C:("Padmgr_Lock",), 0x801750CC:("Padmgr_Unlock",), 0x801750FC:("func_801750FC",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9737ede4d..f6020f817 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2684,9 +2684,9 @@ asm/non_matchings/code/padmgr/func_80174F44.s,func_80174F44,0x80174F44,0xE asm/non_matchings/code/padmgr/func_80174F7C.s,func_80174F7C,0x80174F7C,0x8 asm/non_matchings/code/padmgr/func_80174F9C.s,func_80174F9C,0x80174F9C,0xE asm/non_matchings/code/padmgr/Padmgr_GetEventCallback.s,Padmgr_GetEventCallback,0x80174FD4,0xD -asm/non_matchings/code/padmgr/func_80175008.s,func_80175008,0x80175008,0xD +asm/non_matchings/code/padmgr/PadMgr_LockSerialMesgQueue.s,PadMgr_LockSerialMesgQueue,0x80175008,0xD asm/non_matchings/code/padmgr/Padmgr_SetEventCallback.s,Padmgr_SetEventCallback,0x8017503C,0xC -asm/non_matchings/code/padmgr/func_8017506C.s,func_8017506C,0x8017506C,0xC +asm/non_matchings/code/padmgr/PadMgr_UnlockSerialMesgQueue.s,PadMgr_UnlockSerialMesgQueue,0x8017506C,0xC asm/non_matchings/code/padmgr/Padmgr_Lock.s,Padmgr_Lock,0x8017509C,0xC asm/non_matchings/code/padmgr/Padmgr_Unlock.s,Padmgr_Unlock,0x801750CC,0xC asm/non_matchings/code/padmgr/func_801750FC.s,func_801750FC,0x801750FC,0x9A From 1d30e8ba6b2afa82ef703f9f4e5121caf02106e1 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 18:07:32 +1100 Subject: [PATCH 43/82] Match func_801A5680, it's near identical to func_801A54D0 --- src/code/audio/code_801A51F0.c | 43 ++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index bcbf50bd7..bb2fd4dc1 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -195,7 +195,6 @@ s32 func_801A54D0(u16 arg0) { PadMgr_UnlockSerialMesgQueue(msgQ); if ((errorCode == 0) || (D_801FD5A4 == 0)) { - msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); @@ -207,9 +206,49 @@ s32 func_801A54D0(u16 arg0) { return errorCode; } +s32 func_801A5680(u16 arg0) { + s32 errorCode; + u8 phi_a3; + u8 sp22; + u8 i; + OSMesgQueue* msgQ; + + phi_a3 = true; + if (D_801FD5A0.unk_00 != 0) { + sp22 = D_801FD5A0.unk_00[0x258]; + } else { + sp22 = 0x14; + phi_a3 = false; + } + if (arg0 == 0xFFFF) { + for (i = 0; i < (((sp22 - 1) / 8) + 1); i++) { + D_801FD608[i] = 0; + } + } else { + if (!(D_801FD608[arg0 / 8] & (1 << (arg0 % 8)))) { + phi_a3 = false; + } else { + D_801FD608[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; + } + } + + if (phi_a3) { + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5680.s") + if ((errorCode == 0) || (D_801FD5A4 == 0)) { + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + PadMgr_UnlockSerialMesgQueue(msgQ); + } + + D_801FD5A4 = 0; + } + + return errorCode; +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") From 7ac4c334eb7cac1b38fe47db5022c35d4296c180 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 18:41:16 +1100 Subject: [PATCH 44/82] code_801A51F0 OK --- src/code/audio/code_801A51F0.c | 80 +++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index bb2fd4dc1..2bc4a9950 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -5,8 +5,8 @@ u8* func_801A5A1C(s8* arg0); typedef struct { /* 0x00 */ u8* unk_00; - /* 0x04 */ u8 unk_04; - /* 0x08 */ s32 unk_08; + /* 0x04 */ s8 unk_04; + /* 0x08 */ OSVoiceData* unk_08; /* 0x0C */ u16 unk_0C; /* 0x0E */ u16 unk_0E; /* 0x10 */ u16 unk_10; @@ -16,8 +16,11 @@ typedef struct { extern OSVoiceUnk D_801FD5A0; extern OSVoiceHandle D_801FD5B8; +extern OSVoiceData D_801FD5C8; +extern OSVoiceData D_801FD5E8; extern u8 D_801FD610[]; extern s8 D_801FD5A4; +extern u8 D_801FD5C4; s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" @@ -67,7 +70,7 @@ s32 func_801A5228(u8* arg0) { s32 index; D_801FD5A0.unk_04 = 0; - D_801FD5A0.unk_08 = 0; + D_801FD5A0.unk_08 = NULL; D_801FD5A0.unk_0C = 1000; D_801FD5A0.unk_0E = 5; D_801FD5A0.unk_10 = 0; @@ -104,12 +107,12 @@ s32 func_801A5228(u8* arg0) { return errorCode; } -s32 func_801A5390(void) { - s32 temp_t6; +OSVoiceData* func_801A5390(void) { + OSVoiceData* temp_t6; OSMesgQueue* msgQ; temp_t6 = D_801FD5A0.unk_08; - D_801FD5A0.unk_08 = 0; + D_801FD5A0.unk_08 = NULL; msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStartReadData(&D_801FD5B8); @@ -171,9 +174,9 @@ s32 func_801A54D0(u16 arg0) { phi_t0 = true; if (D_801FD5A0.unk_00 != 0) { - sp22 = D_801FD5A0.unk_00[0x258]; + sp22 = D_801FD5A0.unk_00[600]; } else { - sp22 = 0x14; + sp22 = 20; phi_t0 = false; } @@ -215,9 +218,9 @@ s32 func_801A5680(u16 arg0) { phi_a3 = true; if (D_801FD5A0.unk_00 != 0) { - sp22 = D_801FD5A0.unk_00[0x258]; + sp22 = D_801FD5A0.unk_00[600]; } else { - sp22 = 0x14; + sp22 = 20; phi_a3 = false; } @@ -250,7 +253,62 @@ s32 func_801A5680(u16 arg0) { return errorCode; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") +void func_801A5808(void) { + s32 errorCode = 0; + s32 pad; + OSMesgQueue* msgQ; + + switch (D_801FD5A0.unk_04) { + case 0: + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceStartReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + D_801FD5A4 = 1; + break; + case 1: + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceGetReadData(&D_801FD5B8, &D_801FD5C8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + if (func_801A51F0(errorCode) == 0) { + switch (D_801FD5C4) { + case 0: + D_801FD5A4 = 2; + break; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + break; + case 7: + D_801FD5A4 = 2; + break; + } + } + break; + case 2: + if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { + D_801FD5E8 = D_801FD5C8; + D_801FD5A0.unk_08 = &D_801FD5E8; + } + + msgQ = PadMgr_LockSerialMesgQueue(); + osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + msgQ = PadMgr_LockSerialMesgQueue(); + errorCode = osVoiceStartReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + D_801FD5A4 = 1; + break; + } + + func_801A51F0(errorCode); +} void func_801A5A10(void) { D_801FD5A0.unk_00 = 0; From 11275cf1b48cefc5d432ff9e5e74ea53d66efe8b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:10:21 +1100 Subject: [PATCH 45/82] Match func_801A4EB8 --- src/code/audio/code_801A4EB0.c | 40 +++++++++++++++++++++++++++++++++- src/code/audio/code_801A51F0.c | 4 ++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 441a70472..03d71c4b9 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,12 +1,50 @@ #include "global.h" +s32 func_801A5228(u8* arg0); +void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); + void func_801A5680(u16 arg0); void func_801A54D0(u16 arg0); +u8* func_801A54C4(void); + +extern u8 D_801D8BE0; +extern OSVoiceHandle D_801FD5B8; void func_801A4EB0(void) { } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") +void func_801A4EB8(void) { + u8* new_var; + OSMesgQueue* msgQ; + s32 index; + u8 sp38[1]; + u8 i; + + if (D_801D8E3C != 0) { + msgQ = PadMgr_LockSerialMesgQueue(); + osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + } + + new_var = func_801A54C4(); + + for (i = 0; i < 1; i++) { + sp38[i] = new_var[i]; + } + + if (func_801A5228(&D_801D8BE0) == 0) { + for (i = 0; i < 6; i++) { + index = i / 8; + if (((sp38[index] >> (i % 8)) & 1) == 1) { + func_801A54D0(i); + } + + } + + func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + D_801D8E3C = 1; + } +} #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 2bc4a9950..03e186283 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -161,8 +161,8 @@ s32 func_801A5488(u8* word) { return sp1C; } -UNK_PTR func_801A54C4(void) { - return &D_801FD608; +u8* func_801A54C4(void) { + return D_801FD608; } s32 func_801A54D0(u16 arg0) { From 716de8820ef3b9006013e6ce45bbaeede3a58934 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:13:53 +1100 Subject: [PATCH 46/82] Match func_801A4FD8 (mips2c got it matching directly) --- src/code/audio/code_801A4EB0.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 03d71c4b9..ee4c9f4e6 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,8 +1,11 @@ #include "global.h" +void func_801A5080(u16 arg0); + s32 func_801A5228(u8* arg0); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); + void func_801A5680(u16 arg0); void func_801A54D0(u16 arg0); u8* func_801A54C4(void); @@ -46,7 +49,26 @@ void func_801A4EB8(void) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") +void func_801A4FD8(void) { + s32 sp24; + OSMesgQueue* msgQ; + + func_801A54D0(0xFFFF); + if (D_801D8E3C != 0) { + msgQ = PadMgr_LockSerialMesgQueue(); + osVoiceStopReadData(&D_801FD5B8); + PadMgr_UnlockSerialMesgQueue(msgQ); + + sp24 = func_801A5228(&D_801D8BE0); + func_801A54D0(0xFFFF); + if (sp24 == 0) { + func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + D_801D8E3C = 1; + } + func_801A5080(5); + func_801A5080(1); + } +} void func_801A5080(u16 arg0) { if ((D_801D8E3C != 0) && (arg0 < 6)) { From 957bc0b65f7e4f6010610058660065f05ded310b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:23:33 +1100 Subject: [PATCH 47/82] code_801A4EB0 & all of voice, OK --- src/code/audio/code_801A4EB0.c | 33 ++++++++++++++++++++++++++++++--- src/code/audio/code_801A51F0.c | 6 +++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index ee4c9f4e6..bb496ad5c 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -4,14 +4,16 @@ void func_801A5080(u16 arg0); s32 func_801A5228(u8* arg0); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); - - +s32 func_801A5808(void); +OSVoiceData* func_801A5390(void); void func_801A5680(u16 arg0); void func_801A54D0(u16 arg0); u8* func_801A54C4(void); extern u8 D_801D8BE0; extern OSVoiceHandle D_801FD5B8; +extern OSVoiceData* D_801D8E40; +extern u8 D_801D8E48; void func_801A4EB0(void) { } @@ -90,4 +92,29 @@ u8 func_801A510C(void) { return D_801D8E3C; } -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") +void func_801A5118(void) { + if (D_801D8E3C & 2) { + D_801D8E3C &= 1; + func_801A4EB8(); + } + + if (D_801D8E3C != 0) { + if (func_801A5808() != 0) { + D_801D8E48++; + if (D_801D8E48 == 0xA) { + D_801D8E3C = 0; + D_801D8E44 = 0xFFFF; + return; + } + } else { + D_801D8E48 = 0; + } + + D_801D8E40 = func_801A5390(); + if (D_801D8E40 != 0) { + D_801D8E44 = D_801D8E40->answer[0]; + } else { + D_801D8E44 = 0xFFFF; + } + } +} diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 03e186283..acff8dba6 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -253,9 +253,9 @@ s32 func_801A5680(u16 arg0) { return errorCode; } -void func_801A5808(void) { +s32 func_801A5808(void) { s32 errorCode = 0; - s32 pad; + s32 ret; OSMesgQueue* msgQ; switch (D_801FD5A0.unk_04) { @@ -307,7 +307,7 @@ void func_801A5808(void) { break; } - func_801A51F0(errorCode); + return func_801A51F0(errorCode); } void func_801A5A10(void) { From 1ede43f7ac6c4eaaab4a1590f77a9c8f714808aa Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 19:55:04 +1100 Subject: [PATCH 48/82] Import bss --- include/os.h | 11 +++++++ spec | 1 - src/boot_O2_g3/idle.c | 1 + src/code/audio/code_801A51F0.c | 59 ++++++++++++++++++---------------- src/libultra/flash/osFlash.c | 1 + tools/disasm/variables.txt | 3 +- 6 files changed, 46 insertions(+), 30 deletions(-) diff --git a/include/os.h b/include/os.h index 82e1ac013..f894c2077 100644 --- a/include/os.h +++ b/include/os.h @@ -150,4 +150,15 @@ typedef struct { /* 0x14 */ u16 distance[5]; /* Distance value */ } OSVoiceData; // size = 0x20 +typedef struct { + /* 0x00 */ u8* unk_00; + /* 0x04 */ s8 unk_04; + /* 0x08 */ OSVoiceData* unk_08; + /* 0x0C */ u16 unk_0C; + /* 0x0E */ u16 unk_0E; + /* 0x10 */ u16 unk_10; + /* 0x12 */ u16 unk_12; + /* 0x14 */ u16 unk_14; +} OSVoiceUnk; // size = 0x18 + #endif diff --git a/spec b/spec index 8ba7c36ea..a1c57f47f 100644 --- a/spec +++ b/spec @@ -660,7 +660,6 @@ beginseg include "build/data/code/code_801D55B0.data.o" include "build/src/code/audio/code_801A4EB0.o" include "build/src/code/audio/code_801A51F0.o" - include "build/data/code/code_801A51F0.bss.o" pad_text include "build/src/code/code_801A5BD0.o" include "build/data/code/code_801A5BD0.bss.o" diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 4f9146530..4fe22534c 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index acff8dba6..cd89ba4df 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -3,25 +3,25 @@ // internal voice functions u8* func_801A5A1C(s8* arg0); -typedef struct { - /* 0x00 */ u8* unk_00; - /* 0x04 */ s8 unk_04; - /* 0x08 */ OSVoiceData* unk_08; - /* 0x0C */ u16 unk_0C; - /* 0x0E */ u16 unk_0E; - /* 0x10 */ u16 unk_10; - /* 0x12 */ u16 unk_12; - /* 0x14 */ u16 unk_14; -} OSVoiceUnk; // size = 0x18 +// BSS +OSVoiceUnk D_801FD5A0; +OSVoiceHandle D_801FD5B8; +OSVoiceData D_801FD5C8; +OSVoiceData D_801FD5E8; +u8 D_801FD608[8]; -extern OSVoiceUnk D_801FD5A0; -extern OSVoiceHandle D_801FD5B8; -extern OSVoiceData D_801FD5C8; -extern OSVoiceData D_801FD5E8; -extern u8 D_801FD610[]; -extern s8 D_801FD5A4; -extern u8 D_801FD5C4; +// Maybe all the same? +// u8 D_801FD610[0x11B0]; +u8 D_801FD610[0x100]; +u8 D_801FD710[0x1B0]; +u8 D_801FD8C0[0x240]; +u8 D_801FDB00[0x600]; +u8 D_801FE100[0x3C0]; +u8 D_801FE4C0[0x180]; +u8 D_801FE640[0x90]; +u8 D_801FE6D0[0xF0]; +// Data s8 D_801D8E50[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" @@ -197,13 +197,13 @@ s32 func_801A54D0(u16 arg0) { errorCode = osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A4 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A4 = 0; + D_801FD5A0.unk_04 = 0; } return errorCode; @@ -241,30 +241,33 @@ s32 func_801A5680(u16 arg0) { errorCode = osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A4 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A4 = 0; + D_801FD5A0.unk_04 = 0; } return errorCode; } +// #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") s32 func_801A5808(void) { s32 errorCode = 0; s32 ret; OSMesgQueue* msgQ; + if (1) {} + switch (D_801FD5A0.unk_04) { case 0: msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStartReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A4 = 1; + D_801FD5A0.unk_04 = 1; break; case 1: msgQ = PadMgr_LockSerialMesgQueue(); @@ -272,9 +275,9 @@ s32 func_801A5808(void) { PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) == 0) { - switch (D_801FD5C4) { + switch (D_801FD5B8.status) { case 0: - D_801FD5A4 = 2; + D_801FD5A0.unk_04 = 2; break; case 1: case 2: @@ -284,7 +287,7 @@ s32 func_801A5808(void) { case 6: break; case 7: - D_801FD5A4 = 2; + D_801FD5A0.unk_04 = 2; break; } } @@ -303,11 +306,13 @@ s32 func_801A5808(void) { errorCode = osVoiceStartReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A4 = 1; + D_801FD5A0.unk_04 = 1; break; } - return func_801A51F0(errorCode); + ret = func_801A51F0(errorCode); + + return ret; } void func_801A5A10(void) { diff --git a/src/libultra/flash/osFlash.c b/src/libultra/flash/osFlash.c index bf3044029..cf90bc75b 100644 --- a/src/libultra/flash/osFlash.c +++ b/src/libultra/flash/osFlash.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "ultra64.h" #include "global.h" diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index b320e233f..4a4937eb7 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4419,8 +4419,7 @@ 0x801FD533:("D_801FD533","UNK_TYPE1","",0x1), 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), - 0x801FD5A0:("D_801FD5A0","UNK_TYPE1","",0x1), - 0x801FD5A4:("D_801FD5A4","UNK_TYPE1","",0x1), + 0x801FD5A0:("D_801FD5A0","u8","0x18",0x1), 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), 0x801FD5C4:("D_801FD5C4","UNK_TYPE1","",0x1), 0x801FD5C8:("D_801FD5C8","UNK_TYPE1","",0x1), From 35297dfa170ba9c8c5cf549bc30777a97f7f5518 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 20:03:00 +1100 Subject: [PATCH 49/82] Better match for func_801A5A1C --- src/code/audio/code_801A51F0.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index cd89ba4df..cdb443307 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -253,7 +253,6 @@ s32 func_801A5680(u16 arg0) { return errorCode; } -// #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/func_801A5808.s") s32 func_801A5808(void) { s32 errorCode = 0; s32 ret; @@ -320,29 +319,22 @@ void func_801A5A10(void) { } u8* func_801A5A1C(s8* arg0) { - u8* indexTemp1; u8 i; u8 j; - u8 temp_t6; - u8 temp_t8; - u8* index; u8 len = strlen(arg0); + u8 temp_t8[2]; for (j = 0, i = 0; i < len; i += 2) { + temp_t8[0] = arg0[i]; + temp_t8[1] = arg0[i + 1]; - temp_t8 = arg0[i]; - temp_t6 = arg0[i + 1]; - - indexTemp1 = &temp_t8; - index = &temp_t6; - - if (temp_t8 == 0x83) { - D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40)]; - D_801FD610[j++] = D_801D8F70[3 * (temp_t6 - 0x40) + 1]; - } else if (temp_t8 == 0x82) { - D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F)]; - D_801FD610[j++] = D_801D8E50[3 * (temp_t6 - 0x9F) + 1]; - } else if (temp_t8 == 0x81 && temp_t6 == 0x5B) { + if (temp_t8[0] == 0x83) { + D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40)]; + D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40) + 1]; + } else if (temp_t8[0] == 0x82) { + D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F)]; + D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F) + 1]; + } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { D_801FD610[j++] = 0x2D; D_801FD610[j++] = 0x2D; } else { From 97d720e788a3c762c09cb6a337629662bcdd4a36 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 20:05:29 +1100 Subject: [PATCH 50/82] format --- src/code/audio/code_801A4EB0.c | 3 +-- src/code/audio/code_801A51F0.c | 39 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index bb496ad5c..4863a68a5 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -43,7 +43,6 @@ void func_801A4EB8(void) { if (((sp38[index] >> (i % 8)) & 1) == 1) { func_801A54D0(i); } - } func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); @@ -97,7 +96,7 @@ void func_801A5118(void) { D_801D8E3C &= 1; func_801A4EB8(); } - + if (D_801D8E3C != 0) { if (func_801A5808() != 0) { D_801D8E48++; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index cdb443307..18bf8bcb7 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -12,7 +12,7 @@ u8 D_801FD608[8]; // Maybe all the same? // u8 D_801FD610[0x11B0]; -u8 D_801FD610[0x100]; +u8 D_801FD610[0x100]; u8 D_801FD710[0x1B0]; u8 D_801FD8C0[0x240]; u8 D_801FDB00[0x600]; @@ -29,10 +29,10 @@ s8 D_801D8E50[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; s8 D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" - "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" - "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " - "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; + "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" + "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " + "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; /* char D_801E0EC0[] = "Error %d\n" @@ -75,7 +75,7 @@ s32 func_801A5228(u8* arg0) { D_801FD5A0.unk_0E = 5; D_801FD5A0.unk_10 = 0; D_801FD5A0.unk_00 = arg0; - + temp_s1 = arg0[600]; msgQ = PadMgr_LockSerialMesgQueue(); @@ -84,11 +84,10 @@ s32 func_801A5228(u8* arg0) { if (errorCode != 0) { return errorCode; - } + } for (i = 0; i < (((temp_s1 - 1) / 8) + 1); i++) { D_801FD608[i] = 0; - } for (i = 0; i < temp_s1; i++) { @@ -98,7 +97,7 @@ s32 func_801A5228(u8* arg0) { index = indexTemp * 30; errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); PadMgr_UnlockSerialMesgQueue(msgQ); - + if (func_801A51F0(errorCode) != 0) { func_801A5A1C(&arg0[index]); } @@ -171,7 +170,7 @@ s32 func_801A54D0(u16 arg0) { u8 sp22; u8 i; OSMesgQueue* msgQ; - + phi_t0 = true; if (D_801FD5A0.unk_00 != 0) { sp22 = D_801FD5A0.unk_00[600]; @@ -191,7 +190,7 @@ s32 func_801A54D0(u16 arg0) { D_801FD608[arg0 / 8] |= (1 << (arg0 % 8)); } } - + if (phi_t0) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStopReadData(&D_801FD5B8); @@ -205,7 +204,7 @@ s32 func_801A54D0(u16 arg0) { D_801FD5A0.unk_04 = 0; } - + return errorCode; } @@ -215,7 +214,7 @@ s32 func_801A5680(u16 arg0) { u8 sp22; u8 i; OSMesgQueue* msgQ; - + phi_a3 = true; if (D_801FD5A0.unk_00 != 0) { sp22 = D_801FD5A0.unk_00[600]; @@ -235,7 +234,7 @@ s32 func_801A5680(u16 arg0) { D_801FD608[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; } } - + if (phi_a3) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStopReadData(&D_801FD5B8); @@ -249,7 +248,7 @@ s32 func_801A5680(u16 arg0) { D_801FD5A0.unk_04 = 0; } - + return errorCode; } @@ -292,7 +291,9 @@ s32 func_801A5808(void) { } break; case 2: - if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { + if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && + (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && + (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { D_801FD5E8 = D_801FD5C8; D_801FD5A0.unk_08 = &D_801FD5E8; } @@ -300,7 +301,7 @@ s32 func_801A5808(void) { msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - + msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceStartReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); @@ -342,10 +343,8 @@ u8* func_801A5A1C(s8* arg0) { D_801FD610[j++] = 0x20; } } - + D_801FD610[i] = 0; return D_801FD610; - } - From e488020b458779d8ece659451a696f19ae1949fc Mon Sep 17 00:00:00 2001 From: engineer124 Date: Thu, 11 Nov 2021 22:18:44 +1100 Subject: [PATCH 51/82] Cleanup --- src/code/audio/code_801A4EB0.c | 22 +++++--- src/code/audio/code_801A51F0.c | 99 ++++++++++++++++++++++------------ 2 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 4863a68a5..62b88449b 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -6,8 +6,8 @@ s32 func_801A5228(u8* arg0); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); -void func_801A5680(u16 arg0); -void func_801A54D0(u16 arg0); +s32 func_801A5680(u16 arg0); +s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); extern u8 D_801D8BE0; @@ -45,13 +45,14 @@ void func_801A4EB8(void) { } } - func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; } } +// Used externally in code_8019AF00 void func_801A4FD8(void) { - s32 sp24; + s32 errorCode; OSMesgQueue* msgQ; func_801A54D0(0xFFFF); @@ -60,12 +61,13 @@ void func_801A4FD8(void) { osVoiceStopReadData(&D_801FD5B8); PadMgr_UnlockSerialMesgQueue(msgQ); - sp24 = func_801A5228(&D_801D8BE0); + errorCode = func_801A5228(&D_801D8BE0); func_801A54D0(0xFFFF); - if (sp24 == 0) { - func_801A53E8(0x320, 2, 0x400, 0x1F4, 0x7D0); + if (errorCode == 0) { + func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; } + func_801A5080(5); func_801A5080(1); } @@ -77,20 +79,24 @@ void func_801A5080(u16 arg0) { } } +// Unused void func_801A50C0(u16 arg0) { if ((D_801D8E3C != 0) && (arg0 < 6)) { func_801A54D0(arg0); } } +// Used externally in many files u16 func_801A5100(void) { return D_801D8E44; } +// Unused u8 func_801A510C(void) { return D_801D8E3C; } +// Used externally in Audio_Update (code_8019AF00) void func_801A5118(void) { if (D_801D8E3C & 2) { D_801D8E3C &= 1; @@ -100,7 +106,7 @@ void func_801A5118(void) { if (D_801D8E3C != 0) { if (func_801A5808() != 0) { D_801D8E48++; - if (D_801D8E48 == 0xA) { + if (D_801D8E48 == 10) { D_801D8E3C = 0; D_801D8E44 = 0xFFFF; return; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 18bf8bcb7..8227f6b4a 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -12,7 +12,7 @@ u8 D_801FD608[8]; // Maybe all the same? // u8 D_801FD610[0x11B0]; -u8 D_801FD610[0x100]; +char D_801FD610[0x100]; u8 D_801FD710[0x1B0]; u8 D_801FD8C0[0x240]; u8 D_801FDB00[0x600]; @@ -22,17 +22,43 @@ u8 D_801FE640[0x90]; u8 D_801FE6D0[0xF0]; // Data -s8 D_801D8E50[] = - "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU\0ZU\0SE\0ZE\0SO" - "\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0" - "PE\0HO\0BO\0PO\0MA\0MI\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +s8 D_801D8E50[] = { + 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', + 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', + 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', + 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', + 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', + 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', + 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', + 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', + 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', + 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', + 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', 'M', 'U', '\0', 'M', 'E', '\0', 'M', 'O', '\0', + 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', 'Y', 'O', '\0', + 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', 'w', 'a', '\0', + 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', 'V', 'U', '\0', + 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +}; -s8 D_801D8F70[] = "aa\0AA\0ii\0II\0uu\0UU\0ee\0EE\0oo\0OO\0KA\0GA\0KI\0GI\0KU\0GU\0KE\0GE\0KO\0GO\0SA\0ZA\0SI\0ZI\0SU" - "\0ZU\0SE\0ZE\0SO\0ZO\0TA\0DA\0TI\0DI\0tu\0TU\0DU\0TE\0DE\0TO\0DO\0NA\0NI\0NU\0NE\0NO\0HA\0BA\0PA\0" - "HI\0BI\0PI\0HU\0BU\0PU\0HE\0BE\0PE\0HO\0BO\0PO\0MA\0MI\0 " - "\0MU\0ME\0MO\0ya\0YA\0yu\0YU\0yo\0YO\0RA\0RI\0RU\0RE\0RO\0wa\0WA\0WI\0WE\0WO\0NN\0VU\0ka\0ke\0\0\0" - "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +s8 D_801D8F70[] = { + 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', + 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', + 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', + 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', + 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', + 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', + 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', + 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', + 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', + 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', + 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', ' ', ' ', '\0', 'M', 'U', '\0', 'M', 'E', '\0', + 'M', 'O', '\0', 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', + 'Y', 'O', '\0', 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', + 'w', 'a', '\0', 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', + 'V', 'U', '\0', 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', + '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +}; /* char D_801E0EC0[] = "Error %d\n" @@ -120,6 +146,7 @@ OSVoiceData* func_801A5390(void) { return temp_t6; } +// Unused s32 func_801A53DC(void) { return D_801FD5A0.unk_00; } @@ -132,32 +159,33 @@ void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { D_801FD5A0.unk_14 = arg4; } -void func_801A541C(s32 analog, s32 digital) { - s32 sp1C; +// Unused +// Could have a return? or be void return? +s32 func_801A541C(s32 analog, s32 digital) { + s32 errorCode; OSMesgQueue* msgQ; - if (D_801FD5A0.unk_00 != 0) { - + if (D_801FD5A0.unk_00 != NULL) { msgQ = PadMgr_LockSerialMesgQueue(); - sp1C = osVoiceControlGain(&D_801FD5B8, analog, digital); + errorCode = osVoiceControlGain(&D_801FD5B8, analog, digital); PadMgr_UnlockSerialMesgQueue(msgQ); - if (sp1C != 0) { - func_801A51F0(sp1C); + if (errorCode != 0) { + func_801A51F0(errorCode); } } } +// Unused s32 func_801A5488(u8* word) { - s32 sp1C; + s32 errorCode; OSMesgQueue* msgQ; - s32 temp_v0; msgQ = PadMgr_LockSerialMesgQueue(); - sp1C = osVoiceCheckWord(word); + errorCode = osVoiceCheckWord(word); PadMgr_UnlockSerialMesgQueue(msgQ); - return sp1C; + return errorCode; } u8* func_801A54C4(void) { @@ -172,7 +200,7 @@ s32 func_801A54D0(u16 arg0) { OSMesgQueue* msgQ; phi_t0 = true; - if (D_801FD5A0.unk_00 != 0) { + if (D_801FD5A0.unk_00 != NULL) { sp22 = D_801FD5A0.unk_00[600]; } else { sp22 = 20; @@ -216,7 +244,7 @@ s32 func_801A5680(u16 arg0) { OSMesgQueue* msgQ; phi_a3 = true; - if (D_801FD5A0.unk_00 != 0) { + if (D_801FD5A0.unk_00 != NULL) { sp22 = D_801FD5A0.unk_00[600]; } else { sp22 = 20; @@ -274,17 +302,17 @@ s32 func_801A5808(void) { if (func_801A51F0(errorCode) == 0) { switch (D_801FD5B8.status) { - case 0: + case VOICE_STATUS_READY: D_801FD5A0.unk_04 = 2; break; - case 1: + case VOICE_STATUS_START: case 2: - case 3: + case VOICE_STATUS_CANCEL: case 4: - case 5: + case VOICE_STATUS_BUSY: case 6: break; - case 7: + case VOICE_STATUS_END: D_801FD5A0.unk_04 = 2; break; } @@ -315,8 +343,9 @@ s32 func_801A5808(void) { return ret; } +// Unused void func_801A5A10(void) { - D_801FD5A0.unk_00 = 0; + D_801FD5A0.unk_00 = NULL; } u8* func_801A5A1C(s8* arg0) { @@ -336,15 +365,15 @@ u8* func_801A5A1C(s8* arg0) { D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F)]; D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F) + 1]; } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { - D_801FD610[j++] = 0x2D; - D_801FD610[j++] = 0x2D; + D_801FD610[j++] = '-'; + D_801FD610[j++] = '-'; } else { - D_801FD610[j++] = 0x20; - D_801FD610[j++] = 0x20; + D_801FD610[j++] = ' '; + D_801FD610[j++] = ' '; } } - D_801FD610[i] = 0; + D_801FD610[i] = '\0'; return D_801FD610; } From 12164233fa5db4fbd0ac5d62a4542720ea53d814 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 01:49:17 +1100 Subject: [PATCH 52/82] Clean up dictionary --- src/code/audio/code_801A51F0.c | 56 +++++++++++----------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 8227f6b4a..1d519758d 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -22,42 +22,22 @@ u8 D_801FE640[0x90]; u8 D_801FE6D0[0xF0]; // Data -s8 D_801D8E50[] = { - 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', - 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', - 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', - 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', - 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', - 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', - 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', - 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', - 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', - 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', - 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', 'M', 'U', '\0', 'M', 'E', '\0', 'M', 'O', '\0', - 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', 'Y', 'O', '\0', - 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', 'w', 'a', '\0', - 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', 'V', 'U', '\0', - 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +s8 D_801D8E50[96][3] = { + "aa", "AA", "ii", "II", "uu", "UU", "ee", "EE", "oo", "OO", "KA", "GA", "KI", "GI", "KU", "GU", + "KE", "GE", "KO", "GO", "SA", "ZA", "SI", "ZI", "SU", "ZU", "SE", "ZE", "SO", "ZO", "TA", "DA", + "TI", "DI", "tu", "TU", "DU", "TE", "DE", "TO", "DO", "NA", "NI", "NU", "NE", "NO", "HA", "BA", + "PA", "HI", "BI", "PI", "HU", "BU", "PU", "HE", "BE", "PE", "HO", "BO", "PO", "MA", "MI", "MU", + "ME", "MO", "ya", "YA", "yu", "YU", "yo", "YO", "RA", "RI", "RU", "RE", "RO", "wa", "WA", "WI", + "WE", "WO", "NN", "VU", "ka", "ke", "", "", "", "", "", "", "", "", "", "", }; -s8 D_801D8F70[] = { - 'a', 'a', '\0', 'A', 'A', '\0', 'i', 'i', '\0', 'I', 'I', '\0', 'u', 'u', '\0', 'U', 'U', '\0', - 'e', 'e', '\0', 'E', 'E', '\0', 'o', 'o', '\0', 'O', 'O', '\0', 'K', 'A', '\0', 'G', 'A', '\0', - 'K', 'I', '\0', 'G', 'I', '\0', 'K', 'U', '\0', 'G', 'U', '\0', 'K', 'E', '\0', 'G', 'E', '\0', - 'K', 'O', '\0', 'G', 'O', '\0', 'S', 'A', '\0', 'Z', 'A', '\0', 'S', 'I', '\0', 'Z', 'I', '\0', - 'S', 'U', '\0', 'Z', 'U', '\0', 'S', 'E', '\0', 'Z', 'E', '\0', 'S', 'O', '\0', 'Z', 'O', '\0', - 'T', 'A', '\0', 'D', 'A', '\0', 'T', 'I', '\0', 'D', 'I', '\0', 't', 'u', '\0', 'T', 'U', '\0', - 'D', 'U', '\0', 'T', 'E', '\0', 'D', 'E', '\0', 'T', 'O', '\0', 'D', 'O', '\0', 'N', 'A', '\0', - 'N', 'I', '\0', 'N', 'U', '\0', 'N', 'E', '\0', 'N', 'O', '\0', 'H', 'A', '\0', 'B', 'A', '\0', - 'P', 'A', '\0', 'H', 'I', '\0', 'B', 'I', '\0', 'P', 'I', '\0', 'H', 'U', '\0', 'B', 'U', '\0', - 'P', 'U', '\0', 'H', 'E', '\0', 'B', 'E', '\0', 'P', 'E', '\0', 'H', 'O', '\0', 'B', 'O', '\0', - 'P', 'O', '\0', 'M', 'A', '\0', 'M', 'I', '\0', ' ', ' ', '\0', 'M', 'U', '\0', 'M', 'E', '\0', - 'M', 'O', '\0', 'y', 'a', '\0', 'Y', 'A', '\0', 'y', 'u', '\0', 'Y', 'U', '\0', 'y', 'o', '\0', - 'Y', 'O', '\0', 'R', 'A', '\0', 'R', 'I', '\0', 'R', 'U', '\0', 'R', 'E', '\0', 'R', 'O', '\0', - 'w', 'a', '\0', 'W', 'A', '\0', 'W', 'I', '\0', 'W', 'E', '\0', 'W', 'O', '\0', 'N', 'N', '\0', - 'V', 'U', '\0', 'k', 'a', '\0', 'k', 'e', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', - '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', +s8 D_801D8F70[96][3] = { + "aa", "AA", "ii", "II", "uu", "UU", "ee", "EE", "oo", "OO", "KA", "GA", "KI", "GI", "KU", "GU", + "KE", "GE", "KO", "GO", "SA", "ZA", "SI", "ZI", "SU", "ZU", "SE", "ZE", "SO", "ZO", "TA", "DA", + "TI", "DI", "tu", "TU", "DU", "TE", "DE", "TO", "DO", "NA", "NI", "NU", "NE", "NO", "HA", "BA", + "PA", "HI", "BI", "PI", "HU", "BU", "PU", "HE", "BE", "PE", "HO", "BO", "PO", "MA", "MI", " ", + "MU", "ME", "MO", "ya", "YA", "yu", "YU", "yo", "YO", "RA", "RI", "RU", "RE", "RO", "wa", "WA", + "WI", "WE", "WO", "NN", "VU", "ka", "ke", "", "", "", "", "", "", "", "", "", }; /* @@ -359,11 +339,11 @@ u8* func_801A5A1C(s8* arg0) { temp_t8[1] = arg0[i + 1]; if (temp_t8[0] == 0x83) { - D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40)]; - D_801FD610[j++] = D_801D8F70[3 * (temp_t8[1] - 0x40) + 1]; + D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][0]; + D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][1]; } else if (temp_t8[0] == 0x82) { - D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F)]; - D_801FD610[j++] = D_801D8E50[3 * (temp_t8[1] - 0x9F) + 1]; + D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][0]; + D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][1]; } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { D_801FD610[j++] = '-'; D_801FD610[j++] = '-'; From cb5d51579bdd289d980ace13500d17b13cfcd38f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 12:33:06 +1100 Subject: [PATCH 53/82] Introduce OSVoiceDictionary --- include/os.h | 9 +++- src/code/audio/code_801A4EB0.c | 4 +- src/code/audio/code_801A51F0.c | 89 ++++++++++++++++------------------ 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/include/os.h b/include/os.h index f894c2077..614b6c99a 100644 --- a/include/os.h +++ b/include/os.h @@ -151,9 +151,14 @@ typedef struct { } OSVoiceData; // size = 0x20 typedef struct { - /* 0x00 */ u8* unk_00; + /* 0x000 */ u8 words[20][30]; // 20 words, each with up to 15 syllables + /* 0x258 */ u8 numWords; +} OSVoiceDictionary; // size = 0x25C + +typedef struct { + /* 0x00 */ OSVoiceDictionary* dict; /* 0x04 */ s8 unk_04; - /* 0x08 */ OSVoiceData* unk_08; + /* 0x08 */ OSVoiceData* data; /* 0x0C */ u16 unk_0C; /* 0x0E */ u16 unk_0E; /* 0x10 */ u16 unk_10; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 62b88449b..bc08e9f77 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -2,7 +2,7 @@ void func_801A5080(u16 arg0); -s32 func_801A5228(u8* arg0); +s32 func_801A5228(OSVoiceDictionary* dict); void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); @@ -10,7 +10,7 @@ s32 func_801A5680(u16 arg0); s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); -extern u8 D_801D8BE0; +extern OSVoiceDictionary D_801D8BE0; extern OSVoiceHandle D_801FD5B8; extern OSVoiceData* D_801D8E40; extern u8 D_801D8E48; diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 1d519758d..ff0e2b6da 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -67,45 +67,40 @@ s32 func_801A51F0(s32 errorCode) { } } -s32 func_801A5228(u8* arg0) { +s32 func_801A5228(OSVoiceDictionary* dict) { OSMesgQueue* msgQ; s32 errorCode; - u8 temp_s1; + u8 numWords; u8 i; - u32 indexTemp; - s32 index; D_801FD5A0.unk_04 = 0; - D_801FD5A0.unk_08 = NULL; + D_801FD5A0.data = NULL; D_801FD5A0.unk_0C = 1000; D_801FD5A0.unk_0E = 5; D_801FD5A0.unk_10 = 0; - D_801FD5A0.unk_00 = arg0; + D_801FD5A0.dict = dict; - temp_s1 = arg0[600]; + numWords = dict->numWords; msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceClearDictionary(&D_801FD5B8, temp_s1); + errorCode = osVoiceClearDictionary(&D_801FD5B8, numWords); PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { return errorCode; } - for (i = 0; i < (((temp_s1 - 1) / 8) + 1); i++) { + for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { D_801FD608[i] = 0; } - for (i = 0; i < temp_s1; i++) { - + for (i = 0; i < numWords; i++) { msgQ = PadMgr_LockSerialMesgQueue(); - indexTemp = i; - index = indexTemp * 30; - errorCode = osVoiceSetWord(&D_801FD5B8, &arg0[index]); + errorCode = osVoiceSetWord(&D_801FD5B8, &dict->words[i]); PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) != 0) { - func_801A5A1C(&arg0[index]); + func_801A5A1C(&dict->words[i]); } } @@ -116,8 +111,8 @@ OSVoiceData* func_801A5390(void) { OSVoiceData* temp_t6; OSMesgQueue* msgQ; - temp_t6 = D_801FD5A0.unk_08; - D_801FD5A0.unk_08 = NULL; + temp_t6 = D_801FD5A0.data; + D_801FD5A0.data = NULL; msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStartReadData(&D_801FD5B8); @@ -127,8 +122,8 @@ OSVoiceData* func_801A5390(void) { } // Unused -s32 func_801A53DC(void) { - return D_801FD5A0.unk_00; +OSVoiceDictionary* func_801A53DC(void) { + return D_801FD5A0.dict; } void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { @@ -145,7 +140,7 @@ s32 func_801A541C(s32 analog, s32 digital) { s32 errorCode; OSMesgQueue* msgQ; - if (D_801FD5A0.unk_00 != NULL) { + if (D_801FD5A0.dict != NULL) { msgQ = PadMgr_LockSerialMesgQueue(); errorCode = osVoiceControlGain(&D_801FD5B8, analog, digital); PadMgr_UnlockSerialMesgQueue(msgQ); @@ -175,20 +170,20 @@ u8* func_801A54C4(void) { s32 func_801A54D0(u16 arg0) { s32 errorCode; u8 phi_t0; - u8 sp22; + u8 numWords; u8 i; OSMesgQueue* msgQ; phi_t0 = true; - if (D_801FD5A0.unk_00 != NULL) { - sp22 = D_801FD5A0.unk_00[600]; + if (D_801FD5A0.dict != NULL) { + numWords = D_801FD5A0.dict->numWords; } else { - sp22 = 20; + numWords = 20; phi_t0 = false; } if (arg0 == 0xFFFF) { - for (i = 0; i < sp22; i++) { + for (i = 0; i < numWords; i++) { D_801FD608[i / 8] |= 1 << (i % 8); } } else { @@ -206,7 +201,7 @@ s32 func_801A54D0(u16 arg0) { if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } @@ -219,20 +214,20 @@ s32 func_801A54D0(u16 arg0) { s32 func_801A5680(u16 arg0) { s32 errorCode; u8 phi_a3; - u8 sp22; + u8 numWords; u8 i; OSMesgQueue* msgQ; phi_a3 = true; - if (D_801FD5A0.unk_00 != NULL) { - sp22 = D_801FD5A0.unk_00[600]; + if (D_801FD5A0.dict != NULL) { + numWords = D_801FD5A0.dict->numWords; } else { - sp22 = 20; + numWords = 20; phi_a3 = false; } if (arg0 == 0xFFFF) { - for (i = 0; i < (((sp22 - 1) / 8) + 1); i++) { + for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { D_801FD608[i] = 0; } } else { @@ -250,7 +245,7 @@ s32 func_801A5680(u16 arg0) { if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((sp22 - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } @@ -303,7 +298,7 @@ s32 func_801A5808(void) { (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { D_801FD5E8 = D_801FD5C8; - D_801FD5A0.unk_08 = &D_801FD5E8; + D_801FD5A0.data = &D_801FD5E8; } msgQ = PadMgr_LockSerialMesgQueue(); @@ -325,26 +320,26 @@ s32 func_801A5808(void) { // Unused void func_801A5A10(void) { - D_801FD5A0.unk_00 = NULL; + D_801FD5A0.dict = NULL; } -u8* func_801A5A1C(s8* arg0) { +u8* func_801A5A1C(s8* word) { u8 i; u8 j; - u8 len = strlen(arg0); - u8 temp_t8[2]; + u8 numSyllables = strlen(word); // technically twice the num of syllables + u8 syllable[2]; - for (j = 0, i = 0; i < len; i += 2) { - temp_t8[0] = arg0[i]; - temp_t8[1] = arg0[i + 1]; + for (j = 0, i = 0; i < numSyllables; i += 2) { + syllable[0] = word[i]; + syllable[1] = word[i + 1]; - if (temp_t8[0] == 0x83) { - D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][0]; - D_801FD610[j++] = D_801D8F70[temp_t8[1] - 0x40][1]; - } else if (temp_t8[0] == 0x82) { - D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][0]; - D_801FD610[j++] = D_801D8E50[temp_t8[1] - 0x9F][1]; - } else if (temp_t8[0] == 0x81 && temp_t8[1] == 0x5B) { + if (syllable[0] == 0x83) { + D_801FD610[j++] = D_801D8F70[syllable[1] - 0x40][0]; + D_801FD610[j++] = D_801D8F70[syllable[1] - 0x40][1]; + } else if (syllable[0] == 0x82) { + D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][0]; + D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][1]; + } else if (syllable[0] == 0x81 && syllable[1] == 0x5B) { D_801FD610[j++] = '-'; D_801FD610[j++] = '-'; } else { From 418b4718b88d30c94c129243067e366de3dbe8ca Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 13:25:34 +1100 Subject: [PATCH 54/82] More voice docs --- include/os.h | 20 ++--- include/variables.h | 4 +- src/code/audio/code_801A4EB0.c | 8 +- src/code/audio/code_801A51F0.c | 108 +++++++++++++------------- src/libultra/voice/voicegetreaddata.c | 10 +-- tools/disasm/variables.txt | 4 +- 6 files changed, 76 insertions(+), 78 deletions(-) diff --git a/include/os.h b/include/os.h index ee5ec86f4..379f18746 100644 --- a/include/os.h +++ b/include/os.h @@ -161,10 +161,10 @@ typedef struct { typedef struct { /* 0x00 */ u16 warning; /* Warning */ - /* 0x02 */ u16 answer_num; /* Candidate number (0~5) */ - /* 0x04 */ u16 voice_level; /* Voice input level */ - /* 0x06 */ u16 voice_sn; /* Relative voice level */ - /* 0x08 */ u16 voice_time; /* Voice input time */ + /* 0x02 */ u16 answerNum; /* Candidate number (0~5) */ + /* 0x04 */ u16 voiceLevel; /* Voice input level */ + /* 0x06 */ u16 voiceRelLevel; /* Relative voice level "voice_sn" */ + /* 0x08 */ u16 voiceTime; /* Voice input time */ /* 0x0A */ u16 answer[5]; /* Candidate word number */ /* 0x14 */ u16 distance[5]; /* Distance value */ } OSVoiceData; // size = 0x20 @@ -176,13 +176,13 @@ typedef struct { typedef struct { /* 0x00 */ OSVoiceDictionary* dict; - /* 0x04 */ s8 unk_04; + /* 0x04 */ s8 mode; /* 0x08 */ OSVoiceData* data; - /* 0x0C */ u16 unk_0C; - /* 0x0E */ u16 unk_0E; - /* 0x10 */ u16 unk_10; - /* 0x12 */ u16 unk_12; - /* 0x14 */ u16 unk_14; + /* 0x0C */ u16 distance; + /* 0x0E */ u16 answerNum; + /* 0x10 */ u16 warning; + /* 0x12 */ u16 voiceLevel; + /* 0x14 */ u16 voiceRelLevel; } OSVoiceUnk; // size = 0x18 #endif diff --git a/include/variables.h b/include/variables.h index be7cb79cf..a5adc2d93 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3621,11 +3621,11 @@ extern OSMesg D_801FD034; // extern UNK_TYPE1 D_801FD598; // extern UNK_TYPE1 D_801FD5A0; // extern UNK_TYPE1 D_801FD5A4; -// extern UNK_TYPE1 D_801FD5B8; +// extern UNK_TYPE1 sVoiceHandle; // extern UNK_TYPE1 D_801FD5C4; // extern UNK_TYPE1 D_801FD5C8; // extern UNK_TYPE1 D_801FD5E8; -extern u8 D_801FD608[]; +extern u8 sVoiceMaskPattern[]; // extern UNK_TYPE1 D_801FD610; // extern UNK_TYPE1 D_801FD710; // extern UNK_TYPE1 D_801FD8C0; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index bc08e9f77..cdc5be6fb 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -3,7 +3,7 @@ void func_801A5080(u16 arg0); s32 func_801A5228(OSVoiceDictionary* dict); -void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4); +void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); s32 func_801A5680(u16 arg0); @@ -11,7 +11,7 @@ s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); extern OSVoiceDictionary D_801D8BE0; -extern OSVoiceHandle D_801FD5B8; +extern OSVoiceHandle sVoiceHandle; extern OSVoiceData* D_801D8E40; extern u8 D_801D8E48; @@ -27,7 +27,7 @@ void func_801A4EB8(void) { if (D_801D8E3C != 0) { msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStopReadData(&D_801FD5B8); + osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); } @@ -58,7 +58,7 @@ void func_801A4FD8(void) { func_801A54D0(0xFFFF); if (D_801D8E3C != 0) { msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStopReadData(&D_801FD5B8); + osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); errorCode = func_801A5228(&D_801D8BE0); diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index ff0e2b6da..325a28399 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -1,14 +1,14 @@ #include "global.h" // internal voice functions -u8* func_801A5A1C(s8* arg0); +u8* func_801A5A1C(s8* word); // BSS OSVoiceUnk D_801FD5A0; -OSVoiceHandle D_801FD5B8; -OSVoiceData D_801FD5C8; -OSVoiceData D_801FD5E8; -u8 D_801FD608[8]; +OSVoiceHandle sVoiceHandle; +OSVoiceData D_801FD5C8; // Intermediate Voice Data during processsing? +OSVoiceData D_801FD5E8; // Best Match Voice Data? +u8 sVoiceMaskPattern[8]; // Maybe all the same? // u8 D_801FD610[0x11B0]; @@ -73,17 +73,17 @@ s32 func_801A5228(OSVoiceDictionary* dict) { u8 numWords; u8 i; - D_801FD5A0.unk_04 = 0; + D_801FD5A0.mode = 0; D_801FD5A0.data = NULL; - D_801FD5A0.unk_0C = 1000; - D_801FD5A0.unk_0E = 5; - D_801FD5A0.unk_10 = 0; + D_801FD5A0.distance = 1000; + D_801FD5A0.answerNum = 5; + D_801FD5A0.warning = 0; D_801FD5A0.dict = dict; numWords = dict->numWords; msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceClearDictionary(&D_801FD5B8, numWords); + errorCode = osVoiceClearDictionary(&sVoiceHandle, numWords); PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { @@ -91,12 +91,12 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { - D_801FD608[i] = 0; + sVoiceMaskPattern[i] = 0; } for (i = 0; i < numWords; i++) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceSetWord(&D_801FD5B8, &dict->words[i]); + errorCode = osVoiceSetWord(&sVoiceHandle, &dict->words[i]); PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) != 0) { @@ -108,17 +108,17 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } OSVoiceData* func_801A5390(void) { - OSVoiceData* temp_t6; + OSVoiceData* voiceData; OSMesgQueue* msgQ; - temp_t6 = D_801FD5A0.data; + voiceData = D_801FD5A0.data; D_801FD5A0.data = NULL; msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStartReadData(&D_801FD5B8); + osVoiceStartReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - return temp_t6; + return voiceData; } // Unused @@ -126,12 +126,12 @@ OSVoiceDictionary* func_801A53DC(void) { return D_801FD5A0.dict; } -void func_801A53E8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { - D_801FD5A0.unk_0C = arg0; - D_801FD5A0.unk_0E = arg1; - D_801FD5A0.unk_10 = arg2; - D_801FD5A0.unk_12 = arg3; - D_801FD5A0.unk_14 = arg4; +void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel) { + D_801FD5A0.distance = distance; + D_801FD5A0.answerNum = answerNum; + D_801FD5A0.warning = warning; + D_801FD5A0.voiceLevel = voiceLevel; + D_801FD5A0.voiceRelLevel = voiceRelLevel; } // Unused @@ -142,7 +142,7 @@ s32 func_801A541C(s32 analog, s32 digital) { if (D_801FD5A0.dict != NULL) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceControlGain(&D_801FD5B8, analog, digital); + errorCode = osVoiceControlGain(&sVoiceHandle, analog, digital); PadMgr_UnlockSerialMesgQueue(msgQ); if (errorCode != 0) { @@ -164,17 +164,16 @@ s32 func_801A5488(u8* word) { } u8* func_801A54C4(void) { - return D_801FD608; + return sVoiceMaskPattern; } s32 func_801A54D0(u16 arg0) { s32 errorCode; - u8 phi_t0; + u8 phi_t0 = true; u8 numWords; u8 i; OSMesgQueue* msgQ; - phi_t0 = true; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; } else { @@ -184,28 +183,28 @@ s32 func_801A54D0(u16 arg0) { if (arg0 == 0xFFFF) { for (i = 0; i < numWords; i++) { - D_801FD608[i / 8] |= 1 << (i % 8); + sVoiceMaskPattern[i / 8] |= 1 << (i % 8); } } else { - if (D_801FD608[arg0 / 8] & (1 << (arg0 % 8))) { + if (sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8))) { phi_t0 = false; } else { - D_801FD608[arg0 / 8] |= (1 << (arg0 % 8)); + sVoiceMaskPattern[arg0 / 8] |= (1 << (arg0 % 8)); } } if (phi_t0) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStopReadData(&D_801FD5B8); + errorCode = osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&sVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A0.unk_04 = 0; + D_801FD5A0.mode = 0; } return errorCode; @@ -213,12 +212,11 @@ s32 func_801A54D0(u16 arg0) { s32 func_801A5680(u16 arg0) { s32 errorCode; - u8 phi_a3; + u8 phi_a3 = true; u8 numWords; u8 i; OSMesgQueue* msgQ; - phi_a3 = true; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; } else { @@ -228,28 +226,28 @@ s32 func_801A5680(u16 arg0) { if (arg0 == 0xFFFF) { for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { - D_801FD608[i] = 0; + sVoiceMaskPattern[i] = 0; } } else { - if (!(D_801FD608[arg0 / 8] & (1 << (arg0 % 8)))) { + if (!(sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8)))) { phi_a3 = false; } else { - D_801FD608[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; + sVoiceMaskPattern[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; } } if (phi_a3) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStopReadData(&D_801FD5B8); + errorCode = osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - if ((errorCode == 0) || (D_801FD5A0.unk_04 == 0)) { + if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceMaskDictionary(&D_801FD5B8, D_801FD608, ((numWords - 1) / 8) + 1); + errorCode = osVoiceMaskDictionary(&sVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); PadMgr_UnlockSerialMesgQueue(msgQ); } - D_801FD5A0.unk_04 = 0; + D_801FD5A0.mode = 0; } return errorCode; @@ -262,23 +260,23 @@ s32 func_801A5808(void) { if (1) {} - switch (D_801FD5A0.unk_04) { + switch (D_801FD5A0.mode) { case 0: msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStartReadData(&D_801FD5B8); + errorCode = osVoiceStartReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A0.unk_04 = 1; + D_801FD5A0.mode = 1; break; case 1: msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceGetReadData(&D_801FD5B8, &D_801FD5C8); + errorCode = osVoiceGetReadData(&sVoiceHandle, &D_801FD5C8); PadMgr_UnlockSerialMesgQueue(msgQ); if (func_801A51F0(errorCode) == 0) { - switch (D_801FD5B8.status) { + switch (sVoiceHandle.status) { case VOICE_STATUS_READY: - D_801FD5A0.unk_04 = 2; + D_801FD5A0.mode = 2; break; case VOICE_STATUS_START: case 2: @@ -288,28 +286,28 @@ s32 func_801A5808(void) { case 6: break; case VOICE_STATUS_END: - D_801FD5A0.unk_04 = 2; + D_801FD5A0.mode = 2; break; } } break; case 2: - if (((D_801FD5C8.warning & D_801FD5A0.unk_10) == 0) && (D_801FD5A0.unk_0E >= D_801FD5C8.answer_num) && - (D_801FD5A0.unk_0C >= D_801FD5C8.distance[0]) && (D_801FD5C8.voice_level >= D_801FD5A0.unk_12) && - (D_801FD5C8.voice_sn >= D_801FD5A0.unk_14)) { + if (((D_801FD5C8.warning & D_801FD5A0.warning) == 0) && (D_801FD5A0.answerNum >= D_801FD5C8.answerNum) && + (D_801FD5A0.distance >= D_801FD5C8.distance[0]) && (D_801FD5C8.voiceLevel >= D_801FD5A0.voiceLevel) && + (D_801FD5C8.voiceRelLevel >= D_801FD5A0.voiceRelLevel)) { D_801FD5E8 = D_801FD5C8; D_801FD5A0.data = &D_801FD5E8; } msgQ = PadMgr_LockSerialMesgQueue(); - osVoiceStopReadData(&D_801FD5B8); + osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); msgQ = PadMgr_LockSerialMesgQueue(); - errorCode = osVoiceStartReadData(&D_801FD5B8); + errorCode = osVoiceStartReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); - D_801FD5A0.unk_04 = 1; + D_801FD5A0.mode = 1; break; } diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index 40d7b5b0b..1338a61a8 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -69,10 +69,10 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } result->warning = u.data[4] + (u.data[5] << 8); - result->answer_num = u.data[6]; - result->voice_level = u.data[8] + (u.data[9] << 8); - result->voice_sn = u.data[10] + (u.data[11] << 8); - result->voice_time = u.data[12] + (u.data[13] << 8); + result->answerNum = u.data[6]; + result->voiceLevel = u.data[8] + (u.data[9] << 8); + result->voiceRelLevel = u.data[10] + (u.data[11] << 8); + result->voiceTime = u.data[12] + (u.data[13] << 8); for (i = 0; i < 5; i++) { result->answer[i] = u.data[14 + 4 * (i ^ 0)] + (u.data[15 + 4 * (i ^ 0)] << 8); @@ -80,7 +80,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } if (result->answer[0] == 0x7FFF) { - result->answer_num = 0; + result->answerNum = 0; } new_var2 = D_8009CF60; diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 3e2508212..1779d6a3a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4420,11 +4420,11 @@ 0x801FD590:("D_801FD590","UNK_TYPE1","",0x1), 0x801FD598:("D_801FD598","UNK_TYPE1","",0x1), 0x801FD5A0:("D_801FD5A0","u8","0x18",0x1), - 0x801FD5B8:("D_801FD5B8","UNK_TYPE1","",0x1), + 0x801FD5B8:("sVoiceHandle","UNK_TYPE1","",0x1), 0x801FD5C4:("D_801FD5C4","UNK_TYPE1","",0x1), 0x801FD5C8:("D_801FD5C8","UNK_TYPE1","",0x1), 0x801FD5E8:("D_801FD5E8","UNK_TYPE1","",0x1), - 0x801FD608:("D_801FD608","UNK_TYPE1","",0x1), + 0x801FD608:("sVoiceMaskPattern","UNK_TYPE1","",0x1), 0x801FD610:("D_801FD610","UNK_TYPE1","",0x1), 0x801FD710:("D_801FD710","UNK_TYPE1","",0x1), 0x801FD8C0:("D_801FD8C0","UNK_TYPE1","",0x1), From 3ab4bf67bd0becf1466b2cc2a63afbd19babeed1 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 17:02:01 +1100 Subject: [PATCH 55/82] Fix bss --- src/code/audio/code_801A51F0.c | 12 +----------- src/code/code_801A5BD0.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 325a28399..41ef0f98e 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -9,17 +9,7 @@ OSVoiceHandle sVoiceHandle; OSVoiceData D_801FD5C8; // Intermediate Voice Data during processsing? OSVoiceData D_801FD5E8; // Best Match Voice Data? u8 sVoiceMaskPattern[8]; - -// Maybe all the same? -// u8 D_801FD610[0x11B0]; -char D_801FD610[0x100]; -u8 D_801FD710[0x1B0]; -u8 D_801FD8C0[0x240]; -u8 D_801FDB00[0x600]; -u8 D_801FE100[0x3C0]; -u8 D_801FE4C0[0x180]; -u8 D_801FE640[0x90]; -u8 D_801FE6D0[0xF0]; +char D_801FD610[256]; // Data s8 D_801D8E50[96][3] = { diff --git a/src/code/code_801A5BD0.c b/src/code/code_801A5BD0.c index 32889dcb8..8e9eafe64 100644 --- a/src/code/code_801A5BD0.c +++ b/src/code/code_801A5BD0.c @@ -1,5 +1,36 @@ #include "global.h" +typedef struct { + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxUnk01; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIdx; + /* 0x2B */ u8 unk_2F; + /* 0x2C */ u8 token; +} SoundBankEntry; // size = 0x30 + +// gSoundBank +SoundBankEntry D_801FD710[9]; +SoundBankEntry D_801FD8C0[12]; +SoundBankEntry D_801FDB00[32]; +SoundBankEntry D_801FE100[20]; +SoundBankEntry D_801FE4C0[8]; +SoundBankEntry D_801FE640[3]; +SoundBankEntry D_801FE6D0[5]; + #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C28.s") From c527da691689f1f7b0b900cdcef3333e03b84ee0 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 22:10:26 +1100 Subject: [PATCH 56/82] Import code_801A4EB0 data --- include/variables.h | 4 ++-- src/code/audio/code_801A4EB0.c | 33 +++++++++++++++++++++++++---- src/code/code_801A5BD0.c | 38 +++++++++++++++++----------------- tools/disasm/files.txt | 1 + 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/include/variables.h b/include/variables.h index a5adc2d93..06546f440 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1821,9 +1821,9 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE2 D_801D8BD0; // extern UNK_TYPE4 D_801D8BD4; // extern UNK_TYPE1 D_801D8BE0; -extern u8 D_801D8E3C; +// extern u8 D_801D8E3C; // extern UNK_TYPE4 D_801D8E40; -extern u16 D_801D8E44; +// extern u16 D_801D8E44; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index cdc5be6fb..9136477c1 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -1,7 +1,6 @@ #include "global.h" void func_801A5080(u16 arg0); - s32 func_801A5228(OSVoiceDictionary* dict); void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); s32 func_801A5808(void); @@ -10,10 +9,36 @@ s32 func_801A5680(u16 arg0); s32 func_801A54D0(u16 arg0); u8* func_801A54C4(void); -extern OSVoiceDictionary D_801D8BE0; extern OSVoiceHandle sVoiceHandle; -extern OSVoiceData* D_801D8E40; -extern u8 D_801D8E48; + +OSVoiceDictionary D_801D8BE0 = { + { + // "アトナンジカン" - "atonanjikan" - "How many hours" + { 0x83, 0x41, 0x83, 0x67, 0x83, 0x69, 0x83, 0x93, 0x83, 0x57, 0x83, 0x4A, 0x83, 0x93 }, + + // "ハイチーズ" - "haichīzu" - "say cheese" + { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x60, 0x81, 0x5B, 0x83, 0x59 }, + + // "オキロー" - "okirō" - "wake up" + { 0x83, 0x49, 0x83, 0x4C, 0x83, 0x8D, 0x81, 0x5B }, + + // "オスワリ" - "osuwari" - "sit" + { 0x83, 0x49, 0x83, 0x58, 0x83, 0x8F, 0x83, 0x8A }, + + // "ミルク" - "miruku" - "milk" + { 0x83, 0x7E, 0x83, 0x8B, 0x83, 0x4E }, + + // "ハイヤー" - "haiyā" - "hiya!" + { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x84, 0x81, 0x5B }, + }, + + 6, // number of words +}; + +u8 D_801D8E3C = 0; +OSVoiceData* D_801D8E40 = NULL; +u16 D_801D8E44 = 0xFFFF; +u8 D_801D8E48 = 0; void func_801A4EB0(void) { } diff --git a/src/code/code_801A5BD0.c b/src/code/code_801A5BD0.c index 8e9eafe64..0cafa50b1 100644 --- a/src/code/code_801A5BD0.c +++ b/src/code/code_801A5BD0.c @@ -1,25 +1,25 @@ #include "global.h" typedef struct { - /* 0x00 */ f32* posX; - /* 0x04 */ f32* posY; - /* 0x08 */ f32* posZ; - /* 0x0C */ f32* freqScale; - /* 0x10 */ f32* vol; - /* 0x14 */ s8* reverbAdd; - /* 0x18 */ f32 dist; - /* 0x1C */ u32 priority; // lower is more prioritized - /* 0x20 */ u16 sfxParams; - /* 0x22 */ u16 sfxId; - /* 0x25 */ u8 sfxUnk01; - /* 0x24 */ u8 sfxImportance; - /* 0x26 */ u8 state; // uses SfxState enum - /* 0x27 */ u8 freshness; - /* 0x28 */ u8 prev; - /* 0x29 */ u8 next; - /* 0x2A */ u8 channelIdx; - /* 0x2B */ u8 unk_2F; - /* 0x2C */ u8 token; + /* 0x00 */ f32* posX; + /* 0x04 */ f32* posY; + /* 0x08 */ f32* posZ; + /* 0x0C */ f32* freqScale; + /* 0x10 */ f32* vol; + /* 0x14 */ s8* reverbAdd; + /* 0x18 */ f32 dist; + /* 0x1C */ u32 priority; // lower is more prioritized + /* 0x20 */ u16 sfxParams; + /* 0x22 */ u16 sfxId; + /* 0x25 */ u8 sfxUnk01; + /* 0x24 */ u8 sfxImportance; + /* 0x26 */ u8 state; // uses SfxState enum + /* 0x27 */ u8 freshness; + /* 0x28 */ u8 prev; + /* 0x29 */ u8 next; + /* 0x2A */ u8 channelIdx; + /* 0x2B */ u8 unk_2F; + /* 0x2C */ u8 token; } SoundBankEntry; // size = 0x30 // gSoundBank diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index e4bd66da0..625946f4c 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -578,6 +578,7 @@ 0x801D2E80 : "", # audio_heap? 0x801D3D90 : "", 0x801D55B0 : "", + 0x801D8BE0 : "code_801A4EB0", 0x801D8E50 : "code_801A51F0", 0x801D9090 : "", From e84fd1d1393ef755e4b3bfb8377021b2d5eae117 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 22:39:59 +1100 Subject: [PATCH 57/82] Introduce Word Id enum --- include/os.h | 11 +++++++++++ include/variables.h | 2 +- src/code/audio/code_801A4EB0.c | 34 +++++++++++++++++----------------- src/code/audio/code_801A51F0.c | 16 ++++++++-------- tools/disasm/variables.txt | 2 +- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/include/os.h b/include/os.h index 379f18746..c3d76dd3b 100644 --- a/include/os.h +++ b/include/os.h @@ -141,6 +141,17 @@ typedef struct { /* 0xC */ u32* text_end; } OSProf; // size = 0x10 +typedef enum { + /* 0 */ VOICE_WORD_ID_HOURS, + /* 1 */ VOICE_WORD_ID_CHEESE, + /* 2 */ VOICE_WORD_ID_WAKE_UP, + /* 3 */ VOICE_WORD_ID_SIT, + /* 4 */ VOICE_WORD_ID_MILK, + /* 5 */ VOICE_WORD_ID_HIYA, + /* 6 */ VOICE_WORD_ID_MAX, + /* -1 */ VOICE_WORD_ID_NONE = 0xFFFF +} OSVoiceWordId; + #define VOICE_STATUS_READY 0 /* stop/end */ #define VOICE_STATUS_START 1 /* Voice Undetected (no voice input) */ #define VOICE_STATUS_CANCEL 3 /* Cancel (cancel extraneous noise) */ diff --git a/include/variables.h b/include/variables.h index 06546f440..45e31a527 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1823,7 +1823,7 @@ extern UNK_PTR D_801D8B24; // extern UNK_TYPE1 D_801D8BE0; // extern u8 D_801D8E3C; // extern UNK_TYPE4 D_801D8E40; -// extern u16 D_801D8E44; +// extern u16 sTopScoreWordId; // extern UNK_TYPE1 D_801D8E48; // extern UNK_TYPE1 D_801D8E50; // extern UNK_TYPE1 D_801D8F70; diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 9136477c1..32b1dbc6c 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -5,8 +5,8 @@ s32 func_801A5228(OSVoiceDictionary* dict); void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); s32 func_801A5808(void); OSVoiceData* func_801A5390(void); -s32 func_801A5680(u16 arg0); -s32 func_801A54D0(u16 arg0); +s32 func_801A5680(u16 wordId); +s32 func_801A54D0(u16 wordId); u8* func_801A54C4(void); extern OSVoiceHandle sVoiceHandle; @@ -32,12 +32,12 @@ OSVoiceDictionary D_801D8BE0 = { { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x84, 0x81, 0x5B }, }, - 6, // number of words + VOICE_WORD_ID_MAX, // number of words }; u8 D_801D8E3C = 0; OSVoiceData* D_801D8E40 = NULL; -u16 D_801D8E44 = 0xFFFF; +u16 sTopScoreWordId = VOICE_WORD_ID_NONE; u8 D_801D8E48 = 0; void func_801A4EB0(void) { @@ -63,7 +63,7 @@ void func_801A4EB8(void) { } if (func_801A5228(&D_801D8BE0) == 0) { - for (i = 0; i < 6; i++) { + for (i = 0; i < VOICE_WORD_ID_MAX; i++) { index = i / 8; if (((sp38[index] >> (i % 8)) & 1) == 1) { func_801A54D0(i); @@ -80,14 +80,14 @@ void func_801A4FD8(void) { s32 errorCode; OSMesgQueue* msgQ; - func_801A54D0(0xFFFF); + func_801A54D0(VOICE_WORD_ID_NONE); if (D_801D8E3C != 0) { msgQ = PadMgr_LockSerialMesgQueue(); osVoiceStopReadData(&sVoiceHandle); PadMgr_UnlockSerialMesgQueue(msgQ); errorCode = func_801A5228(&D_801D8BE0); - func_801A54D0(0xFFFF); + func_801A54D0(VOICE_WORD_ID_NONE); if (errorCode == 0) { func_801A53E8(800, 2, VOICE_WARN_TOO_SMALL, 500, 2000); D_801D8E3C = 1; @@ -98,22 +98,22 @@ void func_801A4FD8(void) { } } -void func_801A5080(u16 arg0) { - if ((D_801D8E3C != 0) && (arg0 < 6)) { - func_801A5680(arg0); +void func_801A5080(u16 wordId) { + if ((D_801D8E3C != 0) && (wordId < VOICE_WORD_ID_MAX)) { + func_801A5680(wordId); } } // Unused -void func_801A50C0(u16 arg0) { - if ((D_801D8E3C != 0) && (arg0 < 6)) { - func_801A54D0(arg0); +void func_801A50C0(u16 wordId) { + if ((D_801D8E3C != 0) && (wordId < VOICE_WORD_ID_MAX)) { + func_801A54D0(wordId); } } // Used externally in many files u16 func_801A5100(void) { - return D_801D8E44; + return sTopScoreWordId; } // Unused @@ -133,7 +133,7 @@ void func_801A5118(void) { D_801D8E48++; if (D_801D8E48 == 10) { D_801D8E3C = 0; - D_801D8E44 = 0xFFFF; + sTopScoreWordId = VOICE_WORD_ID_NONE; return; } } else { @@ -142,9 +142,9 @@ void func_801A5118(void) { D_801D8E40 = func_801A5390(); if (D_801D8E40 != 0) { - D_801D8E44 = D_801D8E40->answer[0]; + sTopScoreWordId = D_801D8E40->answer[0]; } else { - D_801D8E44 = 0xFFFF; + sTopScoreWordId = VOICE_WORD_ID_NONE; } } } diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index 41ef0f98e..c5d7bafb4 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -157,7 +157,7 @@ u8* func_801A54C4(void) { return sVoiceMaskPattern; } -s32 func_801A54D0(u16 arg0) { +s32 func_801A54D0(u16 wordId) { s32 errorCode; u8 phi_t0 = true; u8 numWords; @@ -171,15 +171,15 @@ s32 func_801A54D0(u16 arg0) { phi_t0 = false; } - if (arg0 == 0xFFFF) { + if (wordId == VOICE_WORD_ID_NONE) { for (i = 0; i < numWords; i++) { sVoiceMaskPattern[i / 8] |= 1 << (i % 8); } } else { - if (sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8))) { + if (sVoiceMaskPattern[wordId / 8] & (1 << (wordId % 8))) { phi_t0 = false; } else { - sVoiceMaskPattern[arg0 / 8] |= (1 << (arg0 % 8)); + sVoiceMaskPattern[wordId / 8] |= (1 << (wordId % 8)); } } @@ -200,7 +200,7 @@ s32 func_801A54D0(u16 arg0) { return errorCode; } -s32 func_801A5680(u16 arg0) { +s32 func_801A5680(u16 wordId) { s32 errorCode; u8 phi_a3 = true; u8 numWords; @@ -214,15 +214,15 @@ s32 func_801A5680(u16 arg0) { phi_a3 = false; } - if (arg0 == 0xFFFF) { + if (wordId == VOICE_WORD_ID_NONE) { for (i = 0; i < (((numWords - 1) / 8) + 1); i++) { sVoiceMaskPattern[i] = 0; } } else { - if (!(sVoiceMaskPattern[arg0 / 8] & (1 << (arg0 % 8)))) { + if (!(sVoiceMaskPattern[wordId / 8] & (1 << (wordId % 8)))) { phi_a3 = false; } else { - sVoiceMaskPattern[arg0 / 8] &= (1 << (arg0 % 8)) ^ 0xFF; + sVoiceMaskPattern[wordId / 8] &= (1 << (wordId % 8)) ^ 0xFF; } } diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1779d6a3a..98ae20bd9 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2438,7 +2438,7 @@ 0x801D8BE0:("D_801D8BE0","UNK_TYPE1","",0x1), 0x801D8E3C:("D_801D8E3C","UNK_TYPE1","",0x1), 0x801D8E40:("D_801D8E40","UNK_TYPE4","",0x4), - 0x801D8E44:("D_801D8E44","UNK_TYPE2","",0x2), + 0x801D8E44:("sTopScoreWordId","UNK_TYPE2","",0x2), 0x801D8E48:("D_801D8E48","UNK_TYPE1","",0x1), 0x801D8E50:("D_801D8E50","UNK_TYPE1","",0x1), 0x801D8F70:("D_801D8F70","UNK_TYPE1","",0x1), From 0ca2818b8f5a17bc12b7376ae283f2736874cc80 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 12 Nov 2021 23:45:01 +1100 Subject: [PATCH 58/82] Dictionary: u8 -> u16 --- include/os.h | 2 +- src/code/audio/code_801A4EB0.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/os.h b/include/os.h index c3d76dd3b..198c06935 100644 --- a/include/os.h +++ b/include/os.h @@ -181,7 +181,7 @@ typedef struct { } OSVoiceData; // size = 0x20 typedef struct { - /* 0x000 */ u8 words[20][30]; // 20 words, each with up to 15 syllables + /* 0x000 */ u16 words[20][15]; // 20 words, each with up to 15 syllables /* 0x258 */ u8 numWords; } OSVoiceDictionary; // size = 0x25C diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c index 32b1dbc6c..0712d4761 100644 --- a/src/code/audio/code_801A4EB0.c +++ b/src/code/audio/code_801A4EB0.c @@ -14,22 +14,22 @@ extern OSVoiceHandle sVoiceHandle; OSVoiceDictionary D_801D8BE0 = { { // "アトナンジカン" - "atonanjikan" - "How many hours" - { 0x83, 0x41, 0x83, 0x67, 0x83, 0x69, 0x83, 0x93, 0x83, 0x57, 0x83, 0x4A, 0x83, 0x93 }, + { 0x8341, 0x8367, 0x8369, 0x8393, 0x8357, 0x834A, 0x8393 }, // "ハイチーズ" - "haichīzu" - "say cheese" - { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x60, 0x81, 0x5B, 0x83, 0x59 }, + { 0x836E, 0x8343, 0x8360, 0x815B, 0x8359 }, // "オキロー" - "okirō" - "wake up" - { 0x83, 0x49, 0x83, 0x4C, 0x83, 0x8D, 0x81, 0x5B }, + { 0x8349, 0x834C, 0x838D, 0x815B }, // "オスワリ" - "osuwari" - "sit" - { 0x83, 0x49, 0x83, 0x58, 0x83, 0x8F, 0x83, 0x8A }, + { 0x8349, 0x8358, 0x838F, 0x838A }, // "ミルク" - "miruku" - "milk" - { 0x83, 0x7E, 0x83, 0x8B, 0x83, 0x4E }, + { 0x837E, 0x838B, 0x834E }, // "ハイヤー" - "haiyā" - "hiya!" - { 0x83, 0x6E, 0x83, 0x43, 0x83, 0x84, 0x81, 0x5B }, + { 0x836E, 0x8343, 0x8384, 0x815B }, }, VOICE_WORD_ID_MAX, // number of words From a9311e94c9280cf9c61e45fe41bbaa93975b778b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 14:49:57 +1100 Subject: [PATCH 59/82] Introduce bgms --- include/bgm.h | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/include/bgm.h b/include/bgm.h index 4cd19c957..1dc9acdc3 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,4 +3,133 @@ #define NA_BGM_STOP 0x100000FF +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 +#define NA_BGM_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_STALKID 0x04 // Majora's Theme +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_RUIN_DUNGEON_FRONT 0x06 // Stone Tower Temple +#define NA_BGM_RUIN_DUNGEON_REVERSE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_OMENYA 0x0A // Mask Salesman +#define NA_BGM_DEMO_CURE 0x0B // Song of Healing +#define NA_BGM_DAMP_AREA 0x0C // Southern Swamp +#define NA_BGM_UFO 0x0D // Ghost Attack +#define NA_BGM_JUNGLE_CREWS 0x0E // Mini Game +#define NA_BGM_SHARP 0x0F // Sharp's Curse +#define NA_BGM_SEA_AREA 0x10 // Great Bay Coast +#define NA_BGM_IKANA_AREA 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_SNOW_AREA 0x13 // Mountain Village +#define NA_BGM_PIRATE_AREA 0x14 // Pirates' Fortress +#define NA_BGM_DUMMY_21 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D +#define NA_BGM_DUMMY_22 0x16 // Clock Town Day 2 This song's filename is dummied out in MM3D +#define NA_BGM_DUMMY_23 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_EVENT_CLEAR 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_JUNGLE_DUNGEON 0x1C // Woodfall Temple +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_LINK_HOUSE 0x1F // House +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear +#define NA_BGM_ITEM_GET 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_HEART_GET 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_ORGEL_HOUSE 0x27 // Music Box House +#define NA_BGM_GODESS 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_HIME 0x29 // Zelda's Lullaby +#define NA_BGM_SISTER_DANCER 0x2A // Rosa Sisters' Dance +#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Chest +#define NA_BGM_DRUGSTORE 0x2C // Marine Research Laboratory +#define NA_BGM_KYOJIN_ROOM 0x2D // The Four Giants +#define NA_BGM_FUSHA 0x2E // Guru-Guru's Song +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON 0x30 // Goron Village +#define NA_BGM_MEETING 0x31 // Mayor Dotour +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUN 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME_NORMAL 0x34 // Ocarina Song of Time +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA 0x36 // Zora Hall +#define NA_BGM_MASK_GET 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_S_ITEM_GET 0x39 // Small Item Catch +#define NA_BGM_TENMONDAI 0x3A // Astral Observatory +#define NA_BGM_NORMAL_DUNGEON 0x3B // Clock Town Cavern +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_MAYOIMORI 0x3E // Woods of Mystery +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. +#define NA_BGM_KOTAKE_KOUME 0x43 // Kotake's Potion Shop +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_BIGWING 0x47 // Ocarina Song of Soaring +#define NA_BGM_OCA_CURE 0x48 // Ocarina Song of Healing +#define NA_BGM_TIME_SPEED 0x49 // Inverted Song of Time +#define NA_BGM_TIME_JUMP 0x4A // Song of Double Time +#define NA_BGM_DEMO_AWAKING 0x4B // Sonata of Awakening +#define NA_BGM_DEMO_LULLABY 0x4C // Goron Lullaby +#define NA_BGM_DEMO_TIDE 0x4D // New Wave Bossa Nova +#define NA_BGM_DEMO_SHELL 0x4E // Elegy of Emptiness +#define NA_BGM_DEMO_PLEDGE 0x4F // Oath to Order +#define NA_BGM_EXERCISE_HALL 0x50 // Sword Training +#define NA_BGM_DEMO_LULLABY_HALF 0x51 // Ocarina Goron Lullaby Intro +#define NA_BGM_OCA_YOUSEI 0x52 // New Song +#define NA_BGM_FACEMASK 0x53 // Bremen March +#define NA_BGM_QUARTET 0x54 // Ballad of the Wind Fish +#define NA_BGM_WING_WARP 0x55 // Song of Soaring +#define NA_BGM_MILK_BAR_DUMMY 0x56 // Milk Bar Latte Duplicate. +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_LIFF 0x58 // Mikau's Tale +#define NA_BGM_MIKAU_FIN 0x59 // A single guitar chord. +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_AWAKING 0x5B // Ocarina Sonata of Awakening +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby +#define NA_BGM_OCA_TIDE 0x5D // Ocarina New Wave Bossa Nova +#define NA_BGM_OCA_SHELL 0x5E // Ocarina Elegy of Emptiness +#define NA_BGM_OCA_PLEDGE 0x5F // Ocarina Oath to Order +#define NA_BGM_LAST_DUNGEON 0x60 // +#define NA_BGM_OCA_LULLABY_HALF 0x61 // +#define NA_BGM_OCA_SESSION 0x62 // Bass and Guitar Session +#define NA_BGM_DEMO_SESSION 0x63 // Piano Solo +#define NA_BGM_ALLPART_SESSION 0x64 // The Indigo-Go's Rehearsal +#define NA_BGM_SILVER_DUNGEON 0x65 // Snowhead Temple +#define NA_BGM_DEEPBLUE_DUNGEON 0x66 // Great Bay Temple +#define NA_BGM_DEMO_TIDE_SAX 0x67 // +#define NA_BGM_DEMO_TIDE_VOCAL 0x68 // +#define NA_BGM_MUJURA_1 0x69 // Majora's Wrath +#define NA_BGM_MUJURA_2 0x6A // Majora's Incarnation +#define NA_BGM_MUJURA_3 0x6B // Majora's Mask Battle +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING 0x70 // Calling the Four Giants +#define NA_BGM_CAMARO_DANCE 0x71 // Kamaro's Dance +#define NA_BGM_DONKEY_CART 0x72 // Cremia's Carriage +#define NA_BGM_QUIZ 0x73 // Keaton +#define NA_BGM_END_DEMO 0x74 // The End/Credits I +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_PURIFICATION_0 0x78 // Woodfall Clear +#define NA_BGM_PURIFICATION_1 0x79 // Snowhead Clear +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_CHAT 0x7D // Tatl and Tael +#define NA_BGM_MOON_VANISH 0x7E // Moon's Destruction +#define NA_BGM_STAFFROLL2 0x7F // The End/Credits II +#define NA_BGM_DISABLED 0xFFFF + #endif From 85b280f68aacfcd8d5ec3f269eaf4fc0c2131c08 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 15:03:26 +1100 Subject: [PATCH 60/82] Fill in bgm enums --- include/functions.h | 12 ++++++------ src/code/code_8019AF00.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_scene.c | 2 +- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 4 ++-- src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c | 4 ++-- src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c | 4 ++-- src/overlays/actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c | 4 ++-- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 6 +++--- src/overlays/actors/ovl_En_Ma4/z_en_ma4.c | 2 +- src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c | 2 +- src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c | 2 +- src/overlays/actors/ovl_En_Owl/z_en_owl.c | 8 ++++---- .../actors/ovl_En_Pametfrog/z_en_pametfrog.c | 4 ++-- src/overlays/actors/ovl_En_Suttari/z_en_suttari.c | 2 +- .../actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 6 +++--- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 21 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/functions.h b/include/functions.h index 1102363d5..039303645 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3895,10 +3895,10 @@ void func_801A0204(UNK_TYPE); // void func_801A1904(void); // void func_801A1A10(void); // void func_801A1A8C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_801A1D44(Vec3f* vec, UNK_TYPE arg1, f32 arg2); -void func_801A1DB8(Vec3f* vec, UNK_TYPE arg1, f32 arg2); +void func_801A1D44(Vec3f* vec, u8 seqId, f32 arg2); +void func_801A1DB8(Vec3f* vec, u8 seqId, f32 arg2); // void func_801A1E0C(void); -void func_801A1F00(s32 arg0, s32 arg1); +void func_801A1F00(u8 arg0, u16 seqId); void func_801A1F88(void); // void func_801A1FB4(void); // void func_801A2090(void); @@ -3916,15 +3916,15 @@ void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); // void func_801A2D54(void); -s32 func_801A2DE0(UNK_TYPE4 arg1); +s32 Audio_IsSequencePlaying(u8 seqId); void func_801A2E54(s32 param_1); void func_801A2ED8(void); // void func_801A2F88(void); // void func_801A3000(void); // void func_801A3038(void); -void func_801A3098(u16 arg0); +void func_801A3098(u16 seqId); // void func_801A312C(void); -void func_801A31EC(UNK_TYPE1 arg1, UNK_TYPE4 arg2, u8 arg3); +void func_801A31EC(u16 seqId, s8 arg1, u8 arg2); // void func_801A3238(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5); // void func_801A32CC(void); // void func_801A3590(void); diff --git a/src/code/code_8019AF00.c b/src/code/code_8019AF00.c index 8f0d129ad..32934a82c 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/code_8019AF00.c @@ -296,7 +296,7 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2D54.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2DE0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A2E54.s") diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index c510c1974..edbf79ed7 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -66,7 +66,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND; break; case GAMEOVER_DEATH_FADE_OUT: - if (func_801A8A50(1) != 32) { + if (func_801A8A50(1) != NA_BGM_GAME_OVER) { func_80169F78(globalCtx); if (gSaveContext.respawnFlag != -7) { gSaveContext.respawnFlag = -6; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index dd158ac07..406685f85 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == 0x57) { + if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 6b3c944f4..dc7f3639a 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(0x8021); + Audio_QueueSeqCmd(NA_BGM_BOSS_CLEAR | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); @@ -1342,7 +1342,7 @@ void func_809DC78C(Actor* thisx, GlobalContext* globalCtx) { if (D_809E0430 != 0) { D_809E0430--; if (D_809E0430 == 0) { - Audio_QueueSeqCmd(0x801B); + Audio_QueueSeqCmd(NA_BGM_BOSS | 0x8000); } } } diff --git a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c index 42ac8d510..b11647ddf 100644 --- a/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c +++ b/src/overlays/actors/ovl_En_Bigpo/z_en_bigpo.c @@ -449,7 +449,7 @@ void EnBigpo_SpawnCutsceneStage6(EnBigpo* this, GlobalContext* globalCtx) { void EnBigpo_SpawnCutsceneStage7(EnBigpo* this) { this->idleTimer = 15; if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } this->actionFunc = EnBigpo_SpawnCutsceneStage8; @@ -535,7 +535,7 @@ void EnBigpo_WarpingIn(EnBigpo* this, GlobalContext* globalCtx) { if (this->idleTimer == 32) { this->mainColor.a = 255; // fully visible if (this->unkBool204 == false) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unkBool204 = true; } EnBigpo_SetupIdleFlying(this); diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index a73f5423f..bf0f977b7 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -528,7 +528,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { Math_Vec3f_StepTo(&camera->eye, &this->unk_2BC, 10.0f); this->unk_290++; if (this->unk_290 == 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } sp28.x = this->actor.world.pos.x; @@ -547,7 +547,7 @@ void func_8089B3D4(EnDinofos* this, GlobalContext* globalCtx) { void func_8089B4A4(EnDinofos* this) { if (this->unk_290 < 10) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); } Animation_PlayOnce(&this->skelAnime, &D_0600C974); this->unk_2BC.x = (Math_SinS(this->actor.shape.rot.y + 0x200) * 123.0f) + this->actor.world.pos.x; diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index 644f2fedb..e1b71acb2 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); } } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 550a54f62..7a0386183 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -804,7 +804,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 71e0c8cd0..252b1e973 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, 0x2E, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 42b9a6c91..15eed7e02 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(0x800D); + Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(0x19); + func_801A3098(NA_BGM_EVENT_CLEAR); } this->actionTimer--; if (this->actionTimer <= 0) { diff --git a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c index eca46a8e8..92908ac6d 100644 --- a/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c +++ b/src/overlays/actors/ovl_En_Ma4/z_en_ma4.c @@ -751,7 +751,7 @@ void EnMa4_SetupHorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { gSaveContext.weekEventReg[0x8] &= (u8)~0x01; this->actionFunc = EnMa4_HorsebackGameEnd; Audio_QueueSeqCmd(NA_BGM_STOP); - Audio_QueueSeqCmd(0x8041); + Audio_QueueSeqCmd(NA_BGM_HORSE_GOAL | 0x8000); } void EnMa4_HorsebackGameEnd(EnMa4* this, GlobalContext* globalCtx) { diff --git a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c index 4c955f83f..d89ed4582 100644 --- a/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c +++ b/src/overlays/actors/ovl_En_Ma_Yto/z_en_ma_yto.c @@ -903,7 +903,7 @@ void EnMaYto_SetupAfterMilkRunInit(EnMaYto* this) { if (gSaveContext.weekEventReg[0x34] & 1) { // if (ProtectedCremia) EnMaYto_SetFaceExpression(this, 3, 1); } else { - func_801A3098(9); + func_801A3098(NA_BGM_FAILURE_1); EnMaYto_SetFaceExpression(this, 5, 2); } this->actionFunc = EnMaYto_AfterMilkRunInit; diff --git a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c index 67c1d8659..9095d702b 100644 --- a/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c +++ b/src/overlays/actors/ovl_En_Minifrog/z_en_minifrog.c @@ -462,7 +462,7 @@ void EnMinifrog_BeginChoirCutscene(EnMinifrog* this, GlobalContext* globalCtx) { ActorCutscene_Start(this->actor.cutscene, &this->actor); this->actionFunc = EnMinifrog_SetupNextFrogChoir; this->timer = 5; - func_801A1F00(3, 0x5A); + func_801A1F00(3, NA_BGM_FROG_SONG); this->flags |= 0x100; globalCtx->setPlayerTalkAnim(globalCtx, &D_0400E2A8, 0); } else { diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index 446b4c100..514245a32 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -367,7 +367,7 @@ void func_8095AE60(EnOwl* this, GlobalContext* globalCtx) { void func_8095AEC0(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0x7D0, 360.0f, 200.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AE60; } } @@ -396,7 +396,7 @@ void func_8095AF2C(EnOwl* this, GlobalContext* globalCtx) { void func_8095AFEC(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_8095A978(this, globalCtx, 0xBF6, 200.0f, 100.0f)) { - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFunc = func_8095AF2C; this->unk_406 = 0; this->actionFlags |= 0x40; @@ -511,7 +511,7 @@ void func_8095B574(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->actionFlags |= 0x40; this->unk_406 = 2; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -721,7 +721,7 @@ void func_8095BE0C(EnOwl* this, GlobalContext* globalCtx) { func_8095A920(this, globalCtx); if (func_800B84D0(&this->actor, globalCtx)) { this->actionFunc = func_8095BA84; - func_801A3098(0x45); + func_801A3098(NA_BGM_OWL); this->unk_406 = 1; this->actionFlags |= 0x40; } else if (this->actor.textId == 0xBF0) { diff --git a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c index 12e234991..8acba6f8a 100644 --- a/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c +++ b/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c @@ -1054,7 +1054,7 @@ void EnPametfrog_LookAround(EnPametfrog* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.world.rot.y; if (SkelAnime_Update(&this->skelAnime) && (func_801690CC(globalCtx) == 0)) { if (!this->unk_2AE) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); this->unk_2AE = true; } EnPametfrog_SetupJumpToLink(this); @@ -1274,7 +1274,7 @@ void EnPametfrog_SetupTransitionGekkoSnapper(EnPametfrog* this, GlobalContext* g void EnPametfrog_TransitionGekkoSnapper(EnPametfrog* this, GlobalContext* globalCtx) { if (this->actor.params == GEKKO_INIT_SNAPPER) { - func_801A2E54(0x38); + func_801A2E54(NA_BGM_MINI_BOSS); EnPametfrog_SetupRunToSnapper(this); } } diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 3a8db7839..546f029ff 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -1142,7 +1142,7 @@ void func_80BAD230(EnSuttari* this, GlobalContext* globalCtx) { this->textId = 0x2A31; func_801518B0(globalCtx, this->textId, &this->actor); this->flags1 |= 0x4000; - Audio_QueueSeqCmd(0x8003); + Audio_QueueSeqCmd(NA_BGM_CHASE | 0x8000); this->actionFunc = func_80BAD380; } else { ActorCutscene_SetIntentToPlay(this->cutscenes[1]); diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 5018c640f..bd961b7ad 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(0x922); + func_801A3098(NA_BGM_ITEM_GET | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index ef3fdf7dc..f846a2399 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(0x54, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_QUARTET, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,8 +621,8 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!func_801A2DE0(0x54)) { - actor = (Actor*)GET_PLAYER(globalCtx); // Needed for regalloc, possible FAKE MATCH + if (!Audio_IsSequencePlaying(NA_BGM_QUARTET)) { + actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { Actor_MarkForDeath(actor); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index b6ec70b65..c2c4b7b3f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -3951,7 +3951,7 @@ 0x801A2C44:("func_801A2C44",), 0x801A2C88:("func_801A2C88",), 0x801A2D54:("func_801A2D54",), - 0x801A2DE0:("func_801A2DE0",), + 0x801A2DE0:("Audio_IsSequencePlaying",), 0x801A2E54:("func_801A2E54",), 0x801A2ED8:("func_801A2ED8",), 0x801A2F88:("func_801A2F88",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 9737ede4d..3a14ddbc3 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3469,7 +3469,7 @@ asm/non_matchings/code/code_8019AF00/func_801A2C20.s,func_801A2C20,0x801A2C20,0x asm/non_matchings/code/code_8019AF00/func_801A2C44.s,func_801A2C44,0x801A2C44,0x11 asm/non_matchings/code/code_8019AF00/func_801A2C88.s,func_801A2C88,0x801A2C88,0x33 asm/non_matchings/code/code_8019AF00/func_801A2D54.s,func_801A2D54,0x801A2D54,0x23 -asm/non_matchings/code/code_8019AF00/func_801A2DE0.s,func_801A2DE0,0x801A2DE0,0x1D +asm/non_matchings/code/code_8019AF00/Audio_IsSequencePlaying.s,Audio_IsSequencePlaying,0x801A2DE0,0x1D asm/non_matchings/code/code_8019AF00/func_801A2E54.s,func_801A2E54,0x801A2E54,0x21 asm/non_matchings/code/code_8019AF00/func_801A2ED8.s,func_801A2ED8,0x801A2ED8,0x2C asm/non_matchings/code/code_8019AF00/func_801A2F88.s,func_801A2F88,0x801A2F88,0xF From ea906f4280afacbf6f278bdca28c0cbd54f34041 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 16:04:58 +1100 Subject: [PATCH 61/82] Rename bgm to clearer names --- include/bgm.h | 254 +++++++++--------- src/overlays/actors/ovl_Boss_02/z_boss_02.c | 2 +- .../actors/ovl_En_Elforg/z_en_elforg.c | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 4 +- .../actors/ovl_En_Invadepoh/z_en_invadepoh.c | 6 +- .../ovl_En_Syateki_Man/z_en_syateki_man.c | 2 +- src/overlays/actors/ovl_En_Toto/z_en_toto.c | 4 +- 8 files changed, 138 insertions(+), 138 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 1dc9acdc3..5038f66e0 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,133 +3,133 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_AMBIENCE 0x01 -#define NA_BGM_FIELD 0x02 // Termina Field -#define NA_BGM_CHASE 0x03 // Forest Chase -#define NA_BGM_STALKID 0x04 // Majora's Theme -#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower -#define NA_BGM_RUIN_DUNGEON_FRONT 0x06 // Stone Tower Temple -#define NA_BGM_RUIN_DUNGEON_REVERSE 0x07 // Stone Tower Temple Inverted -#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 -#define NA_BGM_FAILURE_1 0x09 // Title -#define NA_BGM_OMENYA 0x0A // Mask Salesman -#define NA_BGM_DEMO_CURE 0x0B // Song of Healing -#define NA_BGM_DAMP_AREA 0x0C // Southern Swamp -#define NA_BGM_UFO 0x0D // Ghost Attack -#define NA_BGM_JUNGLE_CREWS 0x0E // Mini Game -#define NA_BGM_SHARP 0x0F // Sharp's Curse -#define NA_BGM_SEA_AREA 0x10 // Great Bay Coast -#define NA_BGM_IKANA_AREA 0x11 // Ikana Valley -#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King -#define NA_BGM_SNOW_AREA 0x13 // Mountain Village -#define NA_BGM_PIRATE_AREA 0x14 // Pirates' Fortress -#define NA_BGM_DUMMY_21 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D -#define NA_BGM_DUMMY_22 0x16 // Clock Town Day 2 This song's filename is dummied out in MM3D -#define NA_BGM_DUMMY_23 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D -#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain -#define NA_BGM_EVENT_CLEAR 0x19 // Event Clear -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle -#define NA_BGM_JUNGLE_DUNGEON 0x1C // Woodfall Temple -#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ -#define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_LINK_HOUSE 0x1F // House -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_BOSS_CLEAR 0x21 // Boss Clear -#define NA_BGM_ITEM_GET 0x22 // Item Catch -#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_HEART_GET 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame -#define NA_BGM_GORON_RACE 0x26 // Goron Race -#define NA_BGM_ORGEL_HOUSE 0x27 // Music Box House -#define NA_BGM_GODESS 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_HIME 0x29 // Zelda's Lullaby -#define NA_BGM_SISTER_DANCER 0x2A // Rosa Sisters' Dance -#define NA_BGM_OPEN_TRE_BOX 0x2B // Open Chest -#define NA_BGM_DRUGSTORE 0x2C // Marine Research Laboratory -#define NA_BGM_KYOJIN_ROOM 0x2D // The Four Giants -#define NA_BGM_FUSHA 0x2E // Guru-Guru's Song -#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" -#define NA_BGM_GORON 0x30 // Goron Village -#define NA_BGM_MEETING 0x31 // Mayor Dotour -#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song -#define NA_BGM_OCA_SUN 0x33 // Ocarina Sun's Song -#define NA_BGM_OCA_TIME_NORMAL 0x34 // Ocarina Song of Time -#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms -#define NA_BGM_ZORA 0x36 // Zora Hall -#define NA_BGM_MASK_GET 0x37 // A New Mask -#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" -#define NA_BGM_S_ITEM_GET 0x39 // Small Item Catch -#define NA_BGM_TENMONDAI 0x3A // Astral Observatory -#define NA_BGM_NORMAL_DUNGEON 0x3B // Clock Town Cavern -#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte -#define NA_BGM_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_MAYOIMORI 0x3E // Woods of Mystery -#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal -#define NA_BGM_HORSE 0x40 // Gorman Race -#define NA_BGM_HORSE_GOAL 0x41 // Race Finish -#define NA_BGM_INGO 0x42 // Gorman Bros. -#define NA_BGM_KOTAKE_KOUME 0x43 // Kotake's Potion Shop -#define NA_BGM_SHOP 0x44 // Store -#define NA_BGM_OWL 0x45 // Gaebora's Theme -#define NA_BGM_MINI_GAME 0x46 // Target Practice -#define NA_BGM_OCA_BIGWING 0x47 // Ocarina Song of Soaring -#define NA_BGM_OCA_CURE 0x48 // Ocarina Song of Healing -#define NA_BGM_TIME_SPEED 0x49 // Inverted Song of Time -#define NA_BGM_TIME_JUMP 0x4A // Song of Double Time -#define NA_BGM_DEMO_AWAKING 0x4B // Sonata of Awakening -#define NA_BGM_DEMO_LULLABY 0x4C // Goron Lullaby -#define NA_BGM_DEMO_TIDE 0x4D // New Wave Bossa Nova -#define NA_BGM_DEMO_SHELL 0x4E // Elegy of Emptiness -#define NA_BGM_DEMO_PLEDGE 0x4F // Oath to Order -#define NA_BGM_EXERCISE_HALL 0x50 // Sword Training -#define NA_BGM_DEMO_LULLABY_HALF 0x51 // Ocarina Goron Lullaby Intro -#define NA_BGM_OCA_YOUSEI 0x52 // New Song -#define NA_BGM_FACEMASK 0x53 // Bremen March -#define NA_BGM_QUARTET 0x54 // Ballad of the Wind Fish -#define NA_BGM_WING_WARP 0x55 // Song of Soaring -#define NA_BGM_MILK_BAR_DUMMY 0x56 // Milk Bar Latte Duplicate. -#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" -#define NA_BGM_MIKAU_LIFF 0x58 // Mikau's Tale -#define NA_BGM_MIKAU_FIN 0x59 // A single guitar chord. -#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song -#define NA_BGM_OCA_AWAKING 0x5B // Ocarina Sonata of Awakening -#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby -#define NA_BGM_OCA_TIDE 0x5D // Ocarina New Wave Bossa Nova -#define NA_BGM_OCA_SHELL 0x5E // Ocarina Elegy of Emptiness -#define NA_BGM_OCA_PLEDGE 0x5F // Ocarina Oath to Order -#define NA_BGM_LAST_DUNGEON 0x60 // -#define NA_BGM_OCA_LULLABY_HALF 0x61 // -#define NA_BGM_OCA_SESSION 0x62 // Bass and Guitar Session -#define NA_BGM_DEMO_SESSION 0x63 // Piano Solo -#define NA_BGM_ALLPART_SESSION 0x64 // The Indigo-Go's Rehearsal -#define NA_BGM_SILVER_DUNGEON 0x65 // Snowhead Temple -#define NA_BGM_DEEPBLUE_DUNGEON 0x66 // Great Bay Temple -#define NA_BGM_DEMO_TIDE_SAX 0x67 // -#define NA_BGM_DEMO_TIDE_VOCAL 0x68 // -#define NA_BGM_MUJURA_1 0x69 // Majora's Wrath -#define NA_BGM_MUJURA_2 0x6A // Majora's Incarnation -#define NA_BGM_MUJURA_3 0x6B // Majora's Mask Battle -#define NA_BGM_BASS_PLAY 0x6C // Bass Practice -#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice -#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice -#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle -#define NA_BGM_GATHERING 0x70 // Calling the Four Giants -#define NA_BGM_CAMARO_DANCE 0x71 // Kamaro's Dance -#define NA_BGM_DONKEY_CART 0x72 // Cremia's Carriage -#define NA_BGM_QUIZ 0x73 // Keaton -#define NA_BGM_END_DEMO 0x74 // The End/Credits I -#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. -#define NA_BGM_TITLE 0x76 // Title Screen -#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall -#define NA_BGM_PURIFICATION_0 0x78 // Woodfall Clear -#define NA_BGM_PURIFICATION_1 0x79 // Snowhead Clear -#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon -#define NA_BGM_GOODBYE_GIANT 0x7C // -#define NA_BGM_CHAT 0x7D // Tatl and Tael -#define NA_BGM_MOON_VANISH 0x7E // Moon's Destruction -#define NA_BGM_STAFFROLL2 0x7F // The End/Credits II +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" +#define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" +#define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_GOODBYE_GIANT 0x7C // +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index dc7f3639a..498455011 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1005,7 +1005,7 @@ void func_809DAB78(Boss02* this, GlobalContext* globalCtx) { } if (spB0->unk_0144 >= 10) { - Audio_QueueSeqCmd(NA_BGM_BOSS_CLEAR | 0x8000); + Audio_QueueSeqCmd(NA_BGM_CLEAR_BOSS | 0x8000); } Audio_PlayActorSound2(&this->actor, NA_SE_EN_INBOSS_DEAD_OLD); diff --git a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c index e1b71acb2..1efecd257 100644 --- a/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c +++ b/src/overlays/actors/ovl_En_Elforg/z_en_elforg.c @@ -464,7 +464,7 @@ void EnElforg_FreeFloating(EnElforg* this, GlobalContext* globalCtx) { gSaveContext.inventory.strayFairies[gSaveContext.unk_48C8]++; func_801518B0(globalCtx, 0x11, NULL); if (gSaveContext.inventory.strayFairies[(void)0, gSaveContext.unk_48C8] >= 15) { - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); } } } diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 7a0386183..a278711b5 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -804,7 +804,7 @@ void func_80962F4C(EnFu* this, GlobalContext* globalCtx) { func_801A2C20(); gSaveContext.unk_3DE0[4] = 0; gSaveContext.unk_3DD0[4] = 5; - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); this->unk_54A = 3; func_809632D0(this); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 252b1e973..edc0135a8 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, NA_BGM_FUSHA, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 15eed7e02..b10894b16 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -1699,7 +1699,7 @@ void func_80B4627C(EnInvadepoh* this, GlobalContext* globalCtx) { } else { func_80B454BC(this, globalCtx); func_80B452EC(this, globalCtx); - Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } else if (D_80B4E940 == 3) { @@ -1987,7 +1987,7 @@ void func_80B46EE8(EnInvadepoh* this, GlobalContext* globalCtx) { this->actionTimer--; if (this->actionTimer <= 0) { ActorCutscene_Stop(D_80B50404[0]); - Audio_QueueSeqCmd(NA_BGM_UFO | 0x8000); + Audio_QueueSeqCmd(NA_BGM_ALIEN_INVASION | 0x8000); func_80B46F88(this); } } @@ -2036,7 +2036,7 @@ void func_80B470E0(EnInvadepoh* this) { void func_80B47108(EnInvadepoh* this, GlobalContext* globalCtx) { if (this->actionTimer == 100) { - func_801A3098(NA_BGM_EVENT_CLEAR); + func_801A3098(NA_BGM_CLEAR_EVENT); } this->actionTimer--; if (this->actionTimer <= 0) { diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index bd961b7ad..1a038f5a7 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -1160,7 +1160,7 @@ void func_809C898C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_801A2C20(); this->actionFunc = func_809C8BF0; if (this->unk_280 == 50) { - func_801A3098(NA_BGM_ITEM_GET | 0x900); + func_801A3098(NA_BGM_GET_ITEM | 0x900); func_8011B4E0(globalCtx, 1); } } diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index f846a2399..0acdc0485 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -612,7 +612,7 @@ s32 func_80BA47E0(EnToto* this, GlobalContext* globalCtx) { s32 func_80BA49A4(EnToto* this, GlobalContext* globalCtx) { func_800B7298(globalCtx, NULL, 0x44); - func_801A31EC(NA_BGM_QUARTET, 4, this->unk2B3 ^ 0xF); + func_801A31EC(NA_BGM_BALLAD_OF_THE_WIND_FISH, 4, this->unk2B3 ^ 0xF); this->unk2B1 = 4; return 0; } @@ -621,7 +621,7 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor* actor; if (DECR(this->unk2B1) == 0) { - if (!Audio_IsSequencePlaying(NA_BGM_QUARTET)) { + if (!Audio_IsSequencePlaying(NA_BGM_BALLAD_OF_THE_WIND_FISH)) { actor = &GET_PLAYER(globalCtx)->actor; actor = actor->next; while (actor != NULL) { From 0499934d02e1e6a34607236f635fe62ac85a5734 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 13 Nov 2021 16:07:55 +1100 Subject: [PATCH 62/82] Fix spacing --- include/bgm.h | 244 +++++++++++++++++++++++++------------------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 5038f66e0..391881221 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,133 +3,133 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises -#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field -#define NA_BGM_CHASE 0x03 // Forest Chase -#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" -#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower -#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple -#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted -#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 -#define NA_BGM_FAILURE_1 0x09 // Title -#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" -#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" -#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" -#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" -#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" -#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse -#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" -#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley -#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King -#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" -#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" -#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" -#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" -#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" -#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain -#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear -#define NA_BGM_ENEMY 0x1A // Battle -#define NA_BGM_BOSS 0x1B // Boss Battle -#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" -#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ -#define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" -#define NA_BGM_GAME_OVER 0x20 // Game Over -#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear -#define NA_BGM_GET_ITEM 0x22 // Item Catch -#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT -#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece -#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame -#define NA_BGM_GORON_RACE 0x26 // Goron Race -#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" -#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" -#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" -#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" -#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" -#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" -#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" -#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" -#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" -#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village -#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" -#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song -#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song -#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" -#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms -#define NA_BGM_ZORA_HALL 0x36 // Zora Hall -#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask -#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" -#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" -#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" -#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" -#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte -#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" -#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal -#define NA_BGM_HORSE 0x40 // Gorman Race -#define NA_BGM_HORSE_GOAL 0x41 // Race Finish -#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" -#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" -#define NA_BGM_SHOP 0x44 // Store -#define NA_BGM_OWL 0x45 // Gaebora's Theme -#define NA_BGM_MINI_GAME 0x46 // Target Practice -#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" -#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" -#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" -#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" -#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" -#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" -#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" -#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" -#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" -#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" -#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" -#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" -#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" -#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" -#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" -#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" -#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" -#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" -#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" -#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song -#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" -#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" -#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" -#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" -#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" +#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects +#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_TERMINA_FIELD 0x02 // Termina Field +#define NA_BGM_CHASE 0x03 // Forest Chase +#define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" +#define NA_BGM_CLOCK_TOWER 0x05 // The Clock Tower +#define NA_BGM_STONE_TOWER_TEMPLE 0x06 // Stone Tower Temple +#define NA_BGM_INV_STONE_TOWER_TEMPLE 0x07 // Stone Tower Temple Inverted +#define NA_BGM_FAILURE_0 0x08 // Missed Event 1 +#define NA_BGM_FAILURE_1 0x09 // Title +#define NA_BGM_HAPPY_MASK_SALESMAN 0x0A // Mask Salesman "OMENYA" +#define NA_BGM_SONG_OF_HEALING 0x0B // Song of Healing "DEMO_CURE" +#define NA_BGM_SWAMP_REGION 0x0C // Southern Swamp and Woodfall "DAMP_AREA" +#define NA_BGM_ALIEN_INVASION 0x0D // Ghost Attack "UFO" +#define NA_BGM_SWAMP_CRUISE 0x0E // Mini Game "JUNGLE_CREWS" +#define NA_BGM_SHARPS_CURSE 0x0F // Sharp's Curse +#define NA_BGM_GREAT_BAY_REGION 0x10 // Great Bay Coast "SEA_AREA" +#define NA_BGM_IKANA_REGION 0x11 // Ikana Valley +#define NA_BGM_DEKU_KING 0x12 // Court of the Deku King +#define NA_BGM_MOUNTAIN_REGION 0x13 // Mountain Village "SNOW_AREA" +#define NA_BGM_PIRATES_FORTRESS 0x14 // Pirates' Fortress "PIRATE_AREA" +#define NA_BGM_CLOCK_TOWN_DAY_1 0x15 // Clock Town Day 1 This song's filename is dummied out in MM3D "DUMMY_21" +#define NA_BGM_CLOCK_TOWN_DAY_2 0x16 // Clock Town Day 2 his song's filename is dummied out in MM3D "DUMMY_22" +#define NA_BGM_CLOCK_TOWN_DAY_3 0x17 // Clock Town Day 3 This song's filename is dummied out in MM3D "DUMMY_23" +#define NA_BGM_FILE_SELECT 0x18 // This song has no track name, as it's a duplicate of the Fairy's Fountain +#define NA_BGM_CLEAR_EVENT 0x19 // Event Clear +#define NA_BGM_ENEMY 0x1A // Battle +#define NA_BGM_BOSS 0x1B // Boss Battle +#define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" +#define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ +#define NA_BGM_OPENING 0x1E // Forest Ambush +#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_GAME_OVER 0x20 // Game Over +#define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear +#define NA_BGM_GET_ITEM 0x22 // Item Catch +#define NA_BGM_GATE_OPEN 0x23 // Clock Town Day 2 Duplicate of #16. In MM3D, it shares its filename with the Door of Time song from OoT +#define NA_BGM_GET_HEART 0x24 // Complete a Heart Piece +#define NA_BGM_MINI_GAME_2 0x25 // Playing Minigame +#define NA_BGM_GORON_RACE 0x26 // Goron Race +#define NA_BGM_MUSIC_BOX_HOUSE 0x27 // Music Box House "ORGEL_HOUSE" +#define NA_BGM_FAIRY_FOUNTAIN 0x28 // Fairy's Fountain In MM3D, it shares its filename with the Door of Time song from OoT "GODESS" +#define NA_BGM_ZELDAS_LULLABY 0x29 // Zelda's Lullaby "HIME" +#define NA_BGM_ROSA_SISTERS 0x2A // Rosa Sisters' Dance "SISTER_DANCER" +#define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" +#define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" +#define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" +#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" +#define NA_BGM_GORON_VILLAGE 0x30 // Goron Village +#define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" +#define NA_BGM_OCA_EPONA 0x32 // Ocarina Epona's Song +#define NA_BGM_OCA_SUNS 0x33 // Ocarina Sun's Song +#define NA_BGM_OCA_TIME 0x34 // Ocarina Song of Time "TIME_NORMAL" +#define NA_BGM_OCA_STORM 0x35 // Ocarina Song of Storms +#define NA_BGM_ZORA_HALL 0x36 // Zora Hall +#define NA_BGM_GET_NEW_MASK 0x37 // A New Mask +#define NA_BGM_MINI_BOSS 0x38 // Mini Boss "MIDDLE_BOSS" +#define NA_BGM_GET_SMALL_ITEM 0x39 // Small Item Catch "S_ITEM_GET" +#define NA_BGM_ASTRAL_OBSERVATORY 0x3A // Astral Observatory "TENMONDAI" +#define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" +#define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte +#define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) +#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal +#define NA_BGM_HORSE 0x40 // Gorman Race +#define NA_BGM_HORSE_GOAL 0x41 // Race Finish +#define NA_BGM_INGO 0x42 // Gorman Bros. "INGO" +#define NA_BGM_KOTAKE_POTION_SHOP 0x43 // Kotake's Potion Shop "KOTAKE_KOUME" +#define NA_BGM_SHOP 0x44 // Store +#define NA_BGM_OWL 0x45 // Gaebora's Theme +#define NA_BGM_MINI_GAME 0x46 // Target Practice +#define NA_BGM_OCA_SOARING 0x47 // Ocarina Song of Soaring "OCA_BIGWING" +#define NA_BGM_OCA_HEALING 0x48 // Ocarina Song of Healing "OCA_CURE" +#define NA_BGM_INVERTED_SONG_OF_TIME 0x49 // Inverted Song of Time "_SPEED" +#define NA_BGM_SONG_OF_DOUBLE_TIME 0x4A // Song of Double Time "TIME_JUMP" +#define NA_BGM_SONATA_OF_AWAKENING 0x4B // Sonata of Awakening "DEMO_AWAKING" +#define NA_BGM_GORON_LULLABY 0x4C // Goron Lullaby "DEMO_LULLABY" +#define NA_BGM_NEW_WAVE_BOSSA_NOVA 0x4D // New Wave Bossa Nova "DEMO_TIDE" +#define NA_BGM_ELEGY_OF_EMPTINESS 0x4E // Elegy of Emptiness "DEMO_SHELL" +#define NA_BGM_OATH_TO_ORDER 0x4F // Oath to Order "DEMO_PLEDGE" +#define NA_BGM_SWORD_TRAINING_HALL 0x50 // Sword Training "EXERCISE_HALL" +#define NA_BGM_GORON_LULLABY_INTRO 0x51 // Ocarina Goron Lullaby Intro "DEMO_LULLABY_HALF" +#define NA_BGM_OCA_FAIRY 0x52 // New Song "OCA_YOUSEI" +#define NA_BGM_BREMEN_MARCH 0x53 // Bremen March "FACEMASK" +#define NA_BGM_BALLAD_OF_THE_WIND_FISH 0x54 // Quartet performed in on the milk bar stage "QUARTET" +#define NA_BGM_SONG_OF_SOARING 0x55 // Song of Soaring "WING_WARP" +#define NA_BGM_MILK_BAR_DUPLICATE 0x56 // Milk Bar Latte Duplicate. "MILK_BAR_DUMMY" +#define NA_BGM_FINAL_HOURS 0x57 // Final Hours "TIME_LIMIT" +#define NA_BGM_MIKAU_RIFF 0x58 // Mikau's Tale "MIKAU_LIFF" +#define NA_BGM_MIKAU_FINALE 0x59 // A single guitar chord. "MIKAU_FIN" +#define NA_BGM_FROG_SONG 0x5A // Don Gero's Song +#define NA_BGM_OCA_SONATA 0x5B // Ocarina Sonata of Awakening "OCA_AWAKING" +#define NA_BGM_OCA_LULLABY 0x5C // Ocarina Goron Lullaby "OCA_LULLABY" +#define NA_BGM_OCA_NEW_WAVE 0x5D // Ocarina New Wave Bossa Nova "OCA_TIDE" +#define NA_BGM_OCA_ELEGY 0x5E // Ocarina Elegy of Emptiness "OCA_SHELL" +#define NA_BGM_OCA_OATH 0x5F // Ocarina Oath to Order "OCA_PLEDGE" #define NA_BGM_MAJORAS_LAIR 0x60 // "LAST_DUNGEON" #define NA_BGM_OCA_LULLABY_INTRO 0x61 // "OCA_LULLABY_HALF" -#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" -#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" -#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" -#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" -#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" +#define NA_BGM_OCA_GUITAR_BASS_SESSION 0x62 // Bass and Guitar Session "OCA_SESSION" +#define NA_BGM_PIANO_SESSION 0x63 // Piano Solo "DEMO_SESSION" +#define NA_BGM_INDIGO_GO_SESSION 0x64 // The Indigo-Go's Rehearsal "ALLPART_SESSION" +#define NA_BGM_SNOWHEAD_TEMPLE 0x65 // Snowhead Temple "SILVER_DUNGEON" +#define NA_BGM_GREAT_BAY_TEMPLE 0x66 // Great Bay Temple "DEEPBLUE_DUNGEON" #define NA_BGM_NEW_WAVE_SAXOPHONE 0x67 // "DEMO_TIDE_SAX" #define NA_BGM_NEW_WAVE_VOCAL 0x68 // "DEMO_TIDE_VOCAL" -#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" -#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" -#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" -#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" -#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" -#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" -#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle -#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants -#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" -#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" -#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" -#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" -#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. -#define NA_BGM_TITLE_THEME 0x76 // Title Screen -#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall -#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" -#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" -#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon +#define NA_BGM_MAJORAS_WRATH 0x69 // Majora's Wrath "MUJURA_1" +#define NA_BGM_MAJORAS_INCARNATION 0x6A // Majora's Incarnation "MUJURA_2" +#define NA_BGM_MAJORAS_MASK 0x6B // Majora's Mask Battle "MUJURA_3" +#define NA_BGM_BASS_PLAY 0x6C // Bass Practice "BASS_PLAY" +#define NA_BGM_DRUMS_PLAY 0x6D // Drums Practice "DRUMS_PLAY" +#define NA_BGM_PIANO_PLAY 0x6E // Piano Practice "PIANO_PLAY" +#define NA_BGM_IKANA_CASTLE 0x6F // Ikana Castle +#define NA_BGM_GATHERING_GIANTS 0x70 // Calling the Four Giants +#define NA_BGM_KAMARO_DANCE 0x71 // Kamaro's Dance "CAMARO_DANCE" +#define NA_BGM_CREMIA_CARRIAGE 0x72 // Cremia's Carriage "DONKEY_CART" +#define NA_BGM_KEATON_QUIZ 0x73 // Keaton "QUIZ" +#define NA_BGM_END_CREDITS_1 0x74 // The End/Credits I "END_DEMO" +#define NA_BGM_OPENING_LOOP 0x75 // Forest Ambush (?) Duplicate. +#define NA_BGM_TITLE_THEME 0x76 // Title Screen +#define NA_BGM_DUNGEON_APPEAR 0x77 // Surfacing of Woodfall +#define NA_BGM_WOODFALL_CLEAR 0x78 // Woodfall Clear "PURIFICATION_0" +#define NA_BGM_SNOWHEAD_CLEAR 0x79 // Snowhead Clear "PURIFICATION_1" +#define NA_BGM_INTO_THE_MOON 0x7B // To the Moon #define NA_BGM_GOODBYE_GIANT 0x7C // -#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" -#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" +#define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" +#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif From e85ef78e859e75967e56831544c4585370e6ce3b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 14:30:32 +1100 Subject: [PATCH 63/82] Fix "No_Music" define --- include/bgm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index 391881221..430be896e 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -129,7 +129,8 @@ #define NA_BGM_GOODBYE_GIANT 0x7C // #define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" #define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_END_CREDITS_2 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_NO_MUSIC 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF #endif From f5f52dbaf0006e57b371ca77b87b4caa2863a549 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 14:35:51 +1100 Subject: [PATCH 64/82] remove comment --- include/bgm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index 430be896e..a8ed3a5d8 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -129,7 +129,7 @@ #define NA_BGM_GOODBYE_GIANT 0x7C // #define NA_BGM_TATL_AND_TAEL 0x7D // Tatl and Tael "CHAT" #define NA_BGM_MOONS_DESTRUCTION 0x7E // Moon's Destruction "MOON_VANISH" -#define NA_BGM_NO_MUSIC 0x7F // The End/Credits II "STAFFROLL2" +#define NA_BGM_NO_MUSIC 0x7F // #define NA_BGM_END_CREDITS_2 0x82 // The End/Credits II "STAFFROLL2" #define NA_BGM_DISABLED 0xFFFF From b7160a2efc3c08cccffb7e99c2e9b1f5c6410e03 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Mon, 15 Nov 2021 16:25:05 +1100 Subject: [PATCH 65/82] import rodata --- src/code/audio/code_801A51F0.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/code/audio/code_801A51F0.c b/src/code/audio/code_801A51F0.c index c5d7bafb4..d5afc3858 100644 --- a/src/code/audio/code_801A51F0.c +++ b/src/code/audio/code_801A51F0.c @@ -30,17 +30,14 @@ s8 D_801D8F70[96][3] = { "WI", "WE", "WO", "NN", "VU", "ka", "ke", "", "", "", "", "", "", "", "", "", }; -/* -char D_801E0EC0[] = "Error %d\n" -char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n" -char D_801E0EF0[] = "NAI_VRS:dict error! (%d-%d %s)\n" -char D_801E0F10[] = "NAI_VRS:Ina_SetVruGain Error!\n" -char D_801E0F30[] = "NAI_VRS:mask on %d\n" -char D_801E0F48[] = "NAI_VRS:mask off %d\n" -char D_801E0F60[] = "NAI_VRS:answer No.:%d Dist:%d Warn:%04X Level:%5d SN:%5d (Num:%d)\n" -char D_801E0FA4[] = "NAI_VRS:error !! (ANS_MAX:%d DIST:%d WARNING:%04X LEVEL:%5d SN:%5d)\n" -*/ -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A51F0/D_801E0EC0.s") +const char D_801E0EC0[] = "Error %d\n"; +const char D_801E0ECC[] = "NAI_VRS:osVoiceClearDictionary %d\n"; +const char D_801E0EF0[] = "NAI_VRS:dict error! (%d-%d %s)\n"; +const char D_801E0F10[] = "NAI_VRS:Ina_SetVruGain Error!\n"; +const char D_801E0F30[] = "NAI_VRS:mask on %d\n"; +const char D_801E0F48[] = "NAI_VRS:mask off %d\n"; +const char D_801E0F60[] = "NAI_VRS:answer No.:%d Dist:%d Warn:%04X Level:%5d SN:%5d (Num:%d)\n"; +const char D_801E0FA4[] = "NAI_VRS:error !! (ANS_MAX:%d DIST:%d WARNING:%04X LEVEL:%5d SN:%5d)\n"; s32 func_801A51F0(s32 errorCode) { switch (errorCode) { From f0ddf5a017c24540ca0923beb2c9584d0a58c325 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 02:58:40 +1100 Subject: [PATCH 66/82] Improve bgm names, found another seqId function --- include/bgm.h | 6 +++--- include/functions.h | 2 +- src/overlays/actors/ovl_En_Fu/z_en_fu.c | 2 +- src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c | 4 ++-- src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index a8ed3a5d8..9a5f547f3 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -3,8 +3,8 @@ #define NA_BGM_STOP 0x100000FF -#define NA_BGM_GENERAL_SFX 0x0 // General Sound Effects -#define NA_BGM_NATURE_BACKGROUND 0x01 // Ambient background noises +#define NA_BGM_GENERAL_SFX 0x00 // General Sound Effects +#define NA_BGM_NATURE_AMBIENCE 0x01 // Ambient background noises #define NA_BGM_TERMINA_FIELD 0x02 // Termina Field #define NA_BGM_CHASE 0x03 // Forest Chase #define NA_BGM_MAJORAS_THEME 0x04 // Majora's Theme "STALKID" @@ -49,7 +49,7 @@ #define NA_BGM_OPEN_CHEST 0x2B // Open Chest "OPEN_TRE_BOX" #define NA_BGM_MARINE_RESEARCH_LAB 0x2C // Marine Research Laboratory "DRUGSTORE" #define NA_BGM_GIANTS_THEME 0x2D // The Four Giants "KYOJIN_ROOM" -#define NA_BGM_GURU_GURU 0x2E // Guru-Guru's Song "FUSHA" +#define NA_BGM_SONG_OF_STORMS 0x2E // Guru-Guru's Song "FUSHA" #define NA_BGM_ROMANI_RANCH 0x2F // Romani Ranch "RONRON" #define NA_BGM_GORON_VILLAGE 0x30 // Goron Village #define NA_BGM_MAYORS_OFFICE 0x31 // Mayor Dotour "MEETING" diff --git a/include/functions.h b/include/functions.h index 578d0c1ec..254c050c0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3911,7 +3911,7 @@ void func_801A246C(u8 param_1, u8 param_2); // void func_801A27E8(void); // void func_801A281C(void); void func_801A29D4(UNK_TYPE arg0, f32 arg1, UNK_TYPE arg2); -void func_801A2BB8(s32 arg0); +void func_801A2BB8(s32 seqId); void func_801A2C20(void); // void func_801A2C44(void); // void func_801A2C88(void); diff --git a/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/src/overlays/actors/ovl_En_Fu/z_en_fu.c index c34f5cb82..a898ea7cc 100644 --- a/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -543,7 +543,7 @@ void func_80962660(EnFu* this, GlobalContext* globalCtx) { player->stateFlags1 |= 0x20; this->unk_53C = 0; func_800BDC5C(&this->skelAnime, sAnimations, 3); - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); if (this->unk_542 == 0) { if (this->unk_546 == 1) { func_80961EC8(globalCtx); diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index edc0135a8..14a2ac839 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -339,12 +339,12 @@ void EnGuruguru_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.params == 2) { if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 100.0f) { - func_801A1DB8(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); + func_801A1DB8(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } return; } if (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 200.0f) { - func_801A1D44(&this->actor.projectedPos, NA_BGM_GURU_GURU, 540.0f); + func_801A1D44(&this->actor.projectedPos, NA_BGM_SONG_OF_STORMS, 540.0f); } if (this->unusedTimer != 0) { this->unusedTimer--; diff --git a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index 1a038f5a7..513762805 100644 --- a/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -337,7 +337,7 @@ void func_809C6C2C(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80123F2C(globalCtx, 80); this->unk_26A = 1; this->actionFunc = func_809C80C0; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); break; case 0xA32: @@ -657,7 +657,7 @@ void func_809C7620(EnSyatekiMan* this, GlobalContext* globalCtx) { func_80112AFC(globalCtx); func_80123F2C(globalCtx, 0x63); this->unk_26A = 1; - func_801A2BB8(0x25); + func_801A2BB8(NA_BGM_MINI_GAME_2); this->actionFunc = func_809C8808; break; From 43d5adebf656e251e84e5fd5f84ba8db8ca94ebe Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 03:16:22 +1100 Subject: [PATCH 67/82] Another seqId function --- include/functions.h | 2 +- src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/functions.h b/include/functions.h index 254c050c0..e6c387cc0 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3874,7 +3874,7 @@ void func_8019FDC8(UNK_PTR arg0, u16 sfxId, UNK_TYPE arg2); void func_801A0124(Vec3f* pos, u8 arg1); // void func_801A0184(void); // void func_801A01C4(void); -void func_801A0204(UNK_TYPE); +void func_801A0204(s8 seqId); // void func_801A0238(void); // void func_801A026C(void); // void func_801A0318(void); diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index db3f66030..467b5493a 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -590,9 +590,9 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { func_80BD9904(this); } if (gSaveContext.weekEventReg[14] & 4) { - func_801A0204(0x27); + func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(0x1F); + func_801A0204(NA_BGM_HOUSE); } } From 7c51f64320545383e4cbe751efad1df48ce2f66d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 03:39:21 +1100 Subject: [PATCH 68/82] Another name change --- include/bgm.h | 2 +- src/overlays/actors/ovl_En_Pamera/z_en_pamera.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/bgm.h b/include/bgm.h index 9a5f547f3..fd6b98e58 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -34,7 +34,7 @@ #define NA_BGM_WOODFALL_TEMPLE 0x1C // Woodfall Temple "JUNGLE_DUNGEON" #define NA_BGM_MARKET 0x1D // Clock Town Day 1 Duplicate of #15. Interesting filename in MM3D. ✘ #define NA_BGM_OPENING 0x1E // Forest Ambush -#define NA_BGM_HOUSE 0x1F // House "LINK_HOUSE" +#define NA_BGM_INSIDE_A_HOUSE 0x1F // House "LINK_HOUSE" #define NA_BGM_GAME_OVER 0x20 // Game Over #define NA_BGM_CLEAR_BOSS 0x21 // Boss Clear #define NA_BGM_GET_ITEM 0x22 // Item Catch diff --git a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c index 467b5493a..129b1c94d 100644 --- a/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c +++ b/src/overlays/actors/ovl_En_Pamera/z_en_pamera.c @@ -592,7 +592,7 @@ void func_80BD9840(EnPamera* this, GlobalContext* globalCtx) { if (gSaveContext.weekEventReg[14] & 4) { func_801A0204(NA_BGM_MUSIC_BOX_HOUSE); } else { - func_801A0204(NA_BGM_HOUSE); + func_801A0204(NA_BGM_INSIDE_A_HOUSE); } } From a2056da3b286edfa66f986c323bce1fc7195b512 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 16 Nov 2021 17:20:34 +1100 Subject: [PATCH 69/82] Woods of Mystery -> Sarias Song --- include/bgm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bgm.h b/include/bgm.h index fd6b98e58..c3ac3b1d1 100644 --- a/include/bgm.h +++ b/include/bgm.h @@ -65,7 +65,7 @@ #define NA_BGM_CAVERN 0x3B // Clock Town Cavern "NORMAL_DUNGEON" #define NA_BGM_MILK_BAR 0x3C // Milk Bar Latte #define NA_BGM_ZELDA_APPEAR 0x3D // Meet Zelda (OoT) -#define NA_BGM_WOODS_OF_MYSTERY 0x3E // Saria's Song from OoT "MAYOIMORI" +#define NA_BGM_SARIAS_SONG 0x3E // Saria's Theme Song from OoT "MAYOIMORI" #define NA_BGM_GORON_GOAL 0x3F // Goron Race Goal #define NA_BGM_HORSE 0x40 // Gorman Race #define NA_BGM_HORSE_GOAL 0x41 // Race Finish From cf7009b45c591d64926efc71240b1324c973385d Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 17 Nov 2021 16:21:46 +1100 Subject: [PATCH 70/82] Fix match in osVoiceControlGain --- src/libultra/voice/voicecontrolgain.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libultra/voice/voicecontrolgain.c b/src/libultra/voice/voicecontrolgain.c index be4d75973..b96ae510c 100644 --- a/src/libultra/voice/voicecontrolgain.c +++ b/src/libultra/voice/voicecontrolgain.c @@ -18,14 +18,9 @@ s32 osVoiceControlGain(OSVoiceHandle* hd, s32 analog, s32 digital) { return errorCode; } - if (!((digital < 8) && (digital >= 0))) { - goto dummy; - } - - phi_a2 = D_80098180[digital] + 2; - - if (0) { - dummy: + if (((digital < 8) && (digital >= 0))) { + phi_a2 = D_80098180[digital] + 2; + } else { return CONT_ERR_INVALID; } From 597907c50a26fde27e5d1fdd08898312a1e0082f Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 17 Nov 2021 16:25:34 +1100 Subject: [PATCH 71/82] Fix bss reordering --- src/boot_O2_g3/yaz0.c | 1 + src/code/sched.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/boot_O2_g3/yaz0.c b/src/boot_O2_g3/yaz0.c index 094c0bb38..5fb32b8ea 100644 --- a/src/boot_O2_g3/yaz0.c +++ b/src/boot_O2_g3/yaz0.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 sYaz0DataBuffer[0x400]; diff --git a/src/code/sched.c b/src/code/sched.c index 927a48f66..5f9cdf236 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #define RSP_DONE_MSG 667 From 4e0ce6c70a07a7cca0c41367f02de6ed2bf3f186 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Wed, 17 Nov 2021 16:28:15 +1100 Subject: [PATCH 72/82] Fix bss file split --- src/code/code_801A5BD0.c | 31 ------------------------------- tools/disasm/files.txt | 2 +- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/code/code_801A5BD0.c b/src/code/code_801A5BD0.c index 0cafa50b1..32889dcb8 100644 --- a/src/code/code_801A5BD0.c +++ b/src/code/code_801A5BD0.c @@ -1,36 +1,5 @@ #include "global.h" -typedef struct { - /* 0x00 */ f32* posX; - /* 0x04 */ f32* posY; - /* 0x08 */ f32* posZ; - /* 0x0C */ f32* freqScale; - /* 0x10 */ f32* vol; - /* 0x14 */ s8* reverbAdd; - /* 0x18 */ f32 dist; - /* 0x1C */ u32 priority; // lower is more prioritized - /* 0x20 */ u16 sfxParams; - /* 0x22 */ u16 sfxId; - /* 0x25 */ u8 sfxUnk01; - /* 0x24 */ u8 sfxImportance; - /* 0x26 */ u8 state; // uses SfxState enum - /* 0x27 */ u8 freshness; - /* 0x28 */ u8 prev; - /* 0x29 */ u8 next; - /* 0x2A */ u8 channelIdx; - /* 0x2B */ u8 unk_2F; - /* 0x2C */ u8 token; -} SoundBankEntry; // size = 0x30 - -// gSoundBank -SoundBankEntry D_801FD710[9]; -SoundBankEntry D_801FD8C0[12]; -SoundBankEntry D_801FDB00[32]; -SoundBankEntry D_801FE100[20]; -SoundBankEntry D_801FE4C0[8]; -SoundBankEntry D_801FE640[3]; -SoundBankEntry D_801FE6D0[5]; - #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5BD0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A5BD0/func_801A5C28.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index 8de402900..2ad71313b 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -716,7 +716,7 @@ 0x801FD140 : "audio_load", 0x801FD1F0 : "code_8019AF00", 0x801FD5A0 : "code_801A51F0", - 0x801FE7C0 : "code_801A5BD0", + 0x801FD710 : "code_801A5BD0", 0x801FFD00 : "code_801A7B10", 0x80208E90 : "code_801AA020", 0x80208EA0 : "gfxbuffers", From e84d8bc3f5b707baced6b7fd05ca81303483ba92 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 18:53:37 +1100 Subject: [PATCH 73/82] add saria's song bgm to pierre --- src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 436386af9..631fc26e5 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -811,7 +811,7 @@ void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { if (currentDay == 3 && gSaveContext.isNight) { EnKakasi_SetupDigAway(this); } else { - func_801A2BB8(0x3E); + func_801A2BB8(NA_BGM_SARIAS_SONG); EnKakasi_SetupDanceNightAway(this); } } From a0882f3fd3c05dcc920629007ad63ffc391798b6 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 22:36:18 +1100 Subject: [PATCH 74/82] Another bgm function found! --- include/functions.h | 2 +- src/code/z_common_data.c | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/functions.h b/include/functions.h index 39bfe916e..4b21e3d0f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1761,7 +1761,7 @@ void func_800FD654(GlobalContext* globalCtx, Color_RGB8* pzParm2, f32 fParm3); // u32 get_days_elapsed(void); // void reset_days_elapsed(void); // u32 get_current_day(void); -void func_800FD750(UNK_TYPE arg0); +void func_800FD750(u16 seqId); // void func_800FD768(void); void func_800FD78C(GlobalContext* globalCtx); void func_800FD858(GlobalContext* globalCtx); diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 88fa3e103..89a161b45 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -7,7 +7,7 @@ void SaveContext_Init(void) { gSaveContext.playerForm = 0; gSaveContext.seqIndex = 0xFF; gSaveContext.nightSeqIndex = 0xFF; - gSaveContext.unk_3F46 = 0; + gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; gSaveContext.unk_3F4D = 0; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 381dd693f..95fd85c5a 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -860,7 +860,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; @@ -1107,7 +1107,7 @@ s32 func_808F4414(GlobalContext* globalCtx, EnIn* this, s32 arg2) { break; case 0x3475: SET_FLAGS_START_RACE; - func_800FD750(0x40); + func_800FD750(NA_BGM_HORSE); globalCtx->nextEntranceIndex = 0xCE50; globalCtx->unk_1887F = 5; globalCtx->sceneLoadFlag = 0x14; From 5cc0ff2d6413e56b3f4825c903c2b5a1a7b4e937 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Fri, 19 Nov 2021 22:45:36 +1100 Subject: [PATCH 75/82] Add bgm's to `gSaveContext.seqIndex` --- src/code/z_common_data.c | 2 +- src/code/z_game_over.c | 2 +- src/code/z_scene.c | 2 +- src/overlays/gamestates/ovl_select/z_select.c | 2 +- src/overlays/gamestates/ovl_title/z_title.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 89a161b45..26fd324a7 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -5,7 +5,7 @@ SaveContext gSaveContext; void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(gSaveContext)); gSaveContext.playerForm = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.unk_3F46 = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c index edbf79ed7..979b28cba 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -45,7 +45,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.unk_3DC0 = 2000; gSaveContext.naviTimer = 0; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 406685f85..293a9762d 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -449,7 +449,7 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq; globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX; - if (gSaveContext.seqIndex == 0xFF || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { + if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) { audio_setBGM(cmd->soundSettings.bgmId); } } diff --git a/src/overlays/gamestates/ovl_select/z_select.c b/src/overlays/gamestates/ovl_select/z_select.c index 550bbbc8e..1cae35a85 100644 --- a/src/overlays/gamestates/ovl_select/z_select.c +++ b/src/overlays/gamestates/ovl_select/z_select.c @@ -45,7 +45,7 @@ void Select_LoadGame(SelectContext* this, u32 entranceIndex, s32 opt) { } gSaveContext.respawn[0].entranceIndex = 0xFFFF; - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.showTitleCard = true; gSaveContext.respawnFlag = 0; diff --git a/src/overlays/gamestates/ovl_title/z_title.c b/src/overlays/gamestates/ovl_title/z_title.c index ed732fc3d..62a85c863 100644 --- a/src/overlays/gamestates/ovl_title/z_title.c +++ b/src/overlays/gamestates/ovl_title/z_title.c @@ -127,7 +127,7 @@ void Title_Main(GameState* thisx) { Title_UpdateCounters(this); Title_Draw(&this->gameState); if (this->exit) { - gSaveContext.seqIndex = 0xFF; + gSaveContext.seqIndex = (u8)NA_BGM_DISABLED; gSaveContext.nightSeqIndex = 0xFF; gSaveContext.gameMode = 1; From 6b79b958b7fe771c9c5eb6b01ba1de270aee9560 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 5 Feb 2022 12:59:27 +1100 Subject: [PATCH 76/82] Fix BSS --- include/variables.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/variables.h b/include/variables.h index cd30f42d1..68a58f72f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3343,6 +3343,7 @@ extern FaultAddrConvClient sGraphFaultAddrConvClient; extern FaultClient sGraphFaultClient; extern GfxMasterList* gGfxMasterDL; extern CfbInfo sGraphCfbInfos[3]; +extern OSTime sGraphTaskStartTime; extern OSMesgQueue sSiIntMsgQ; extern OSMesg sSiIntMsgBuf[1]; extern u32 gSegments[NUM_SEGMENTS]; From dc950a93ea010835af504aec327560e9e1c57214 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sat, 23 Jul 2022 00:52:17 +1000 Subject: [PATCH 77/82] fix bss --- src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c index 99d5c5a85..555f92798 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Balance/z_bg_dblue_balance.c @@ -4,6 +4,7 @@ * Description: Great Bay Temple - See-Saw */ +#include "prevent_bss_reordering.h" #include "z_bg_dblue_balance.h" #include "objects/object_dblue_object/object_dblue_object.h" From 58d545c4237c3d583772e326a6e4713ac875a53c Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 24 Jul 2022 09:45:43 +1000 Subject: [PATCH 78/82] Fix bss --- src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c index 73c5e32c6..b699cd9af 100644 --- a/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c +++ b/src/overlays/actors/ovl_Obj_Flowerpot/z_obj_flowerpot.c @@ -4,7 +4,6 @@ * Description: Breakable Pot With Grass */ -#include "prevent_bss_reordering.h" #include "z_obj_flowerpot.h" #include "objects/object_flowerpot/object_flowerpot.h" From 5194d2be8bf1c2c97446f67710f0ea2a992871e6 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 11:32:00 +1000 Subject: [PATCH 79/82] cleanup --- include/functions.h | 19 ----------- include/ultra64/os_voice.h | 12 ------- include/z64voice.h | 34 +++++++++++++++++++ src/audio/voice_external.c | 16 +++------ src/audio/voice_internal.c | 3 ++ src/code/padmgr.c | 1 + src/code/z_parameter.c | 15 ++++---- src/libultra/voice/voicegetreaddata.c | 4 +-- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 9 +++-- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 5 +-- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 5 +-- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 7 ++-- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 14 files changed, 71 insertions(+), 63 deletions(-) create mode 100644 include/z64voice.h diff --git a/include/functions.h b/include/functions.h index 6a9ebcf60..39342e094 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2338,25 +2338,6 @@ void Audio_ResetForAudioHeapStep3(void); void Audio_ResetForAudioHeapStep2(void); void Audio_ResetForAudioHeapStep1(s32 specId); -void func_801A4EB0(void); -// void func_801A4EB8(void); -void func_801A4FD8(void); -void func_801A5080(u16 arg0); -u16 func_801A5100(void); -void func_801A5118(void); -UNK_TYPE func_801A51F0(UNK_TYPE arg0); -// void func_801A5228(void); -// void func_801A5390(void); -// void func_801A53E8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void func_801A541C(void); -// void func_801A5488(void); -// void func_801A54C4(void); -// void func_801A54D0(void); -// void func_801A5680(void); -// void func_801A5808(void); -void AudioVoice_ResetData(void); -// void func_801A5A1C(void); - void AudioSfx_MuteBanks(u16 muteMask); void AudioSfx_LowerBgmVolume(u8 channelIndex); void AudioSfx_RestoreBgmVolume(u8 channelIndex); diff --git a/include/ultra64/os_voice.h b/include/ultra64/os_voice.h index 2f7827ed5..fd08d3bf9 100644 --- a/include/ultra64/os_voice.h +++ b/include/ultra64/os_voice.h @@ -29,18 +29,6 @@ typedef struct { /* 0x14 */ u16 distance[5]; // Distance value } OSVoiceData; // size = 0x20 - -typedef enum { - /* 0 */ VOICE_WORD_ID_HOURS, - /* 1 */ VOICE_WORD_ID_CHEESE, - /* 2 */ VOICE_WORD_ID_WAKE_UP, - /* 3 */ VOICE_WORD_ID_SIT, - /* 4 */ VOICE_WORD_ID_MILK, - /* 5 */ VOICE_WORD_ID_HIYA, - /* 6 */ VOICE_WORD_ID_MAX, - /* -1 */ VOICE_WORD_ID_NONE = 0xFFFF -} OSVoiceWordId; - #define VOICE_STATUS_READY 0 /* stop/end */ #define VOICE_STATUS_START 1 /* Voice Undetected (no voice input) */ #define VOICE_STATUS_CANCEL 3 /* Cancel (cancel extraneous noise) */ diff --git a/include/z64voice.h b/include/z64voice.h new file mode 100644 index 000000000..e456c0a12 --- /dev/null +++ b/include/z64voice.h @@ -0,0 +1,34 @@ +#ifndef Z64VOICE_H +#define Z64VOICE_H + +#include "PR/ultratypes.h" +#include "unk.h" +#include "ultra64/os_voice.h" + +typedef enum { + /* 0 */ VOICE_WORD_ID_HOURS, + /* 1 */ VOICE_WORD_ID_CHEESE, + /* 2 */ VOICE_WORD_ID_WAKE_UP, + /* 3 */ VOICE_WORD_ID_SIT, + /* 4 */ VOICE_WORD_ID_MILK, + /* 5 */ VOICE_WORD_ID_HIYA, + /* 6 */ VOICE_WORD_ID_MAX, + /* -1 */ VOICE_WORD_ID_NONE = 0xFFFF +} OSVoiceWordId; + +void func_801A4EB0(void); +void func_801A4FD8(void); +void func_801A5080(u16 wordId); +u16 AudioVoice_GetWord(void); +void func_801A5118(void); +s32 func_801A51F0(s32 errorCode); +s32 func_801A5228(OSVoiceDictionary* dict); +OSVoiceData* func_801A5390(void); +void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); +u8* func_801A54C4(void); +s32 func_801A54D0(u16 wordId); +s32 func_801A5680(u16 wordId); +s32 func_801A5808(void); +void AudioVoice_ResetData(void); + +#endif diff --git a/src/audio/voice_external.c b/src/audio/voice_external.c index b585a2716..69b465e9b 100644 --- a/src/audio/voice_external.c +++ b/src/audio/voice_external.c @@ -1,13 +1,5 @@ #include "global.h" - -void func_801A5080(u16 arg0); -s32 func_801A5228(OSVoiceDictionary* dict); -void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 voiceRelLevel); -s32 func_801A5808(void); -OSVoiceData* func_801A5390(void); -s32 func_801A5680(u16 wordId); -s32 func_801A54D0(u16 wordId); -u8* func_801A54C4(void); +#include "z64voice.h" extern OSVoiceHandle gVoiceHandle; @@ -93,8 +85,8 @@ void func_801A4FD8(void) { D_801D8E3C = 1; } - func_801A5080(5); - func_801A5080(1); + func_801A5080(VOICE_WORD_ID_HIYA); + func_801A5080(VOICE_WORD_ID_CHEESE); } } @@ -112,7 +104,7 @@ void func_801A50C0(u16 wordId) { } // Used externally in many files -u16 func_801A5100(void) { +u16 AudioVoice_GetWord(void) { return sTopScoreWordId; } diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c index 6ad766f91..2367887d5 100644 --- a/src/audio/voice_internal.c +++ b/src/audio/voice_internal.c @@ -1,4 +1,5 @@ #include "global.h" +#include "z64voice.h" // internal voice functions u8* func_801A5A1C(s8* word); @@ -265,6 +266,7 @@ s32 func_801A5808(void) { case VOICE_STATUS_READY: D_801FD5A0.mode = 2; break; + case VOICE_STATUS_START: case 2: case VOICE_STATUS_CANCEL: @@ -272,6 +274,7 @@ s32 func_801A5808(void) { case VOICE_STATUS_BUSY: case 6: break; + case VOICE_STATUS_END: D_801FD5A0.mode = 2; break; diff --git a/src/code/padmgr.c b/src/code/padmgr.c index a04a14f57..f8e164c39 100644 --- a/src/code/padmgr.c +++ b/src/code/padmgr.c @@ -31,6 +31,7 @@ * done while waiting for this operation to complete. */ #include "global.h" +#include "z64voice.h" #include "io/controller.h" #include "ultra64/motor.h" diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index e63c9d8e5..d3718d55d 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -1,6 +1,7 @@ #include "global.h" #include "z64snap.h" #include "z64view.h" +#include "z64voice.h" #include "interface/parameter_static/parameter_static.h" #include "interface/do_action_static/do_action_static.h" #include "misc/story_static/story_static.h" @@ -2166,7 +2167,7 @@ void Interface_UpdateButtonsPart1(PlayState* play) { if (gSaveContext.save.cutsceneIndex < 0xFFF0) { gSaveContext.hudVisibilityForceButtonAlphasByStatus = false; if ((player->stateFlags1 & PLAYER_STATE1_800000) || CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) || - (!(CHECK_EVENTINF(EVENTINF_41)) && (play->unk_1887C >= 2))) { + (!CHECK_EVENTINF(EVENTINF_41) && (play->unk_1887C >= 2))) { // Riding Epona OR Honey & Darling minigame OR Horseback balloon minigame OR related to swamp boat // (non-minigame?) if ((player->stateFlags1 & PLAYER_STATE1_800000) && (player->currentMask == PLAYER_MASK_BLAST) && @@ -2239,8 +2240,7 @@ void Interface_UpdateButtonsPart1(PlayState* play) { (gSaveContext.save.entrance == ENTRANCE(ROMANI_RANCH, 0)) && (Cutscene_GetSceneLayer(play) != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { Interface_SetHudVisibility(HUD_VISIBILITY_A_B_MINIMAP); - } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && - (CHECK_EVENTINF(EVENTINF_35))) { + } else if ((gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) && CHECK_EVENTINF(EVENTINF_35)) { Interface_SetHudVisibility(HUD_VISIBILITY_B_MINIMAP); } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_82_08) && (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE)) { @@ -2328,9 +2328,10 @@ void Interface_UpdateButtonsPart1(PlayState* play) { interfaceCtx->unk_222 = interfaceCtx->unk_224 = 0; restoreHudVisibility = true; sPictoState = PICTO_BOX_STATE_OFF; - } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || (func_801A5100() == 1)) { - if (!(CHECK_EVENTINF(EVENTINF_41)) || - ((CHECK_EVENTINF(EVENTINF_41)) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { + } else if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, BTN_A) || + (AudioVoice_GetWord() == VOICE_WORD_ID_CHEESE)) { + if (!CHECK_EVENTINF(EVENTINF_41) || + (CHECK_EVENTINF(EVENTINF_41) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { play_sound(NA_SE_SY_CAMERA_SHUTTER); SREG(89) = 1; play->haltAllActors = true; @@ -4078,7 +4079,7 @@ void Interface_DrawBButtonIcons(PlayState* play) { (play->sceneId != SCENE_BOWLING) && ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || (gSaveContext.save.entrance != ENTRANCE(ROMANI_RANCH, 0))) && - ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || !(CHECK_EVENTINF(EVENTINF_35))) && + ((gSaveContext.minigameStatus != MINIGAME_STATUS_ACTIVE) || !CHECK_EVENTINF(EVENTINF_35)) && (!CHECK_WEEKEVENTREG(WEEKEVENTREG_31_80) || (play->unk_1887C != 100))) { Interface_DrawAmmoCount(play, EQUIP_SLOT_B, interfaceCtx->bAlpha); } diff --git a/src/libultra/voice/voicegetreaddata.c b/src/libultra/voice/voicegetreaddata.c index d271f71c7..7f5f1e87b 100644 --- a/src/libultra/voice/voicegetreaddata.c +++ b/src/libultra/voice/voicegetreaddata.c @@ -33,7 +33,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { sHandleStatus = data[0] & 7; hd->status = sHandleStatus; - if ((sHandleStatus != 0) && (sHandleStatus != 7)) { + if ((sHandleStatus != VOICE_STATUS_READY) && (sHandleStatus != VOICE_STATUS_END)) { return CONT_ERR_NOT_READY; } // fallthrough @@ -88,7 +88,7 @@ s32 osVoiceGetReadData(OSVoiceHandle* hd, OSVoiceData* result) { } hd->status = data[34] & 7; - if ((sHandleStatus == 0) || (hd->status == 0)) { + if ((sHandleStatus == VOICE_STATUS_READY) || (hd->status == VOICE_STATUS_READY)) { break; } // fallthrough diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index aa74c5007..27fd87bbc 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -6,6 +6,7 @@ #include "z_en_cow.h" #include "z64horse.h" +#include "z64voice.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -132,8 +133,9 @@ void EnCow_Init(Actor* thisx, PlayState* play) { this->actor.targetMode = 6; gHorsePlayedEponasSong = false; - func_801A5080(4); + func_801A5080(VOICE_WORD_ID_MILK); break; + case EN_COW_TYPE_TAIL: SkelAnime_InitFlex(play, &this->skelAnime, &gCowTailSkel, NULL, this->jointTable, this->morphTable, COW_TAIL_LIMB_MAX); @@ -148,6 +150,9 @@ void EnCow_Init(Actor* thisx, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_1; this->animationTimer = Rand_ZeroFloat(1000.0f) + 40.0f; break; + + default: + break; } this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -289,7 +294,7 @@ void EnCow_Idle(EnCow* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { - if (func_801A5100() == 4) { + if (AudioVoice_GetWord() == VOICE_WORD_ID_MILK) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_87_01)) { SET_WEEKEVENTREG(WEEKEVENTREG_87_01); if (Inventory_HasEmptyBottle()) { diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 6f6f2cad9..125f92ad3 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -5,6 +5,7 @@ */ #include "z_en_gs.h" +#include "z64voice.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_gs/object_gs.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -158,7 +159,7 @@ void EnGs_Init(Actor* thisx, PlayState* play) { Math_Vec3f_Copy(&this->unk_1B0[0], &gOneVec3f); Math_Vec3f_Copy(&this->unk_1B0[1], &gOneVec3f); SubS_FillCutscenesList(&this->actor, this->csIdList, ARRAY_COUNT(this->csIdList)); - func_801A5080(0); + func_801A5080(VOICE_WORD_ID_HOURS); if (this->actor.params == ENGS_1) { Actor_SetScale(&this->actor, 0.15f); this->collider.dim.radius *= 1.5f; @@ -924,7 +925,7 @@ void func_80999BC8(Actor* thisx, PlayState* play2) { EnGs* this = THIS; s32 pad; - if (this->actor.isTargeted && !func_801A5100()) { + if (this->actor.isTargeted && AudioVoice_GetWord() == VOICE_WORD_ID_HOURS) { this->unk_19D = 0; this->unk_19A |= 1; func_80999AC0(this); diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index 8ad694a11..5115a5ef9 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -5,6 +5,7 @@ */ #include "z_en_hidden_nuts.h" +#include "z64voice.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" #include "objects/object_hintnuts/object_hintnuts.h" @@ -106,7 +107,7 @@ void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { this->path = SubS_GetPathByIndex(play, this->pathIndex, ENHIDDENNUTS_PATH_INDEX_NONE_ALT); this->csId = this->actor.csId; - func_801A5080(2); + func_801A5080(VOICE_WORD_ID_WAKE_UP); func_80BDB268(this); } @@ -186,7 +187,7 @@ void func_80BDB2B8(EnHiddenNuts* this, PlayState* play) { if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_SONATA)) { play->msgCtx.ocarinaMode = 4; func_80BDB788(this); - } else if (func_801A5100() == 2) { + } else if (AudioVoice_GetWord() == VOICE_WORD_ID_WAKE_UP) { func_80BDB788(this); } else { func_800B8614(&this->actor, play, BREG(13) + 100.0f); diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 787a40da7..05fbf25cb 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -7,6 +7,7 @@ #include "z_en_horse.h" #include "z64horse.h" #include "z64rumble.h" +#include "z64voice.h" #include "overlays/actors/ovl_En_In/z_en_in.h" #include "overlays/actors/ovl_Obj_Um/z_obj_um.h" #include "overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.h" @@ -3987,9 +3988,9 @@ void func_80886C00(EnHorse* this, PlayState* play) { if (((this->action == ENHORSE_ACTION_MOUNTED_WALK) || (this->action == ENHORSE_ACTION_MOUNTED_TROT) || (this->action == ENHORSE_ACTION_MOUNTED_GALLOP)) && - (CHECK_BTN_ALL(input->press.button, BTN_A) || (func_801A5100() == 5)) && (play->interfaceCtx.unk_212 == 8) && - !(this->stateFlags & ENHORSE_BOOST) && !(this->stateFlags & ENHORSE_FLAG_8) && - !(this->stateFlags & ENHORSE_FLAG_9)) { + (CHECK_BTN_ALL(input->press.button, BTN_A) || (AudioVoice_GetWord() == VOICE_WORD_ID_HIYA)) && + (play->interfaceCtx.unk_212 == 8) && !(this->stateFlags & ENHORSE_BOOST) && + !(this->stateFlags & ENHORSE_FLAG_8) && !(this->stateFlags & ENHORSE_FLAG_9)) { if (this->numBoosts > 0) { Rumble_Request(0.0f, 180, 20, 100); this->stateFlags |= ENHORSE_BOOST; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4fc8f07c1..3a66be7ab 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4014,7 +4014,7 @@ 0x801A4FD8:("func_801A4FD8",), 0x801A5080:("func_801A5080",), 0x801A50C0:("func_801A50C0",), - 0x801A5100:("func_801A5100",), + 0x801A5100:("AudioVoice_GetWord",), 0x801A510C:("func_801A510C",), 0x801A5118:("func_801A5118",), 0x801A51F0:("func_801A51F0",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 80d36de95..a72b9e4b1 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -3531,7 +3531,7 @@ asm/non_matchings/code/voice_external/func_801A4EB8.s,func_801A4EB8,0x801A4EB8,0 asm/non_matchings/code/voice_external/func_801A4FD8.s,func_801A4FD8,0x801A4FD8,0x2A asm/non_matchings/code/voice_external/func_801A5080.s,func_801A5080,0x801A5080,0x10 asm/non_matchings/code/voice_external/func_801A50C0.s,func_801A50C0,0x801A50C0,0x10 -asm/non_matchings/code/voice_external/func_801A5100.s,func_801A5100,0x801A5100,0x3 +asm/non_matchings/code/voice_external/AudioVoice_GetWord.s,AudioVoice_GetWord,0x801A5100,0x3 asm/non_matchings/code/voice_external/func_801A510C.s,func_801A510C,0x801A510C,0x3 asm/non_matchings/code/voice_external/func_801A5118.s,func_801A5118,0x801A5118,0x36 asm/non_matchings/code/voice_internal/func_801A51F0.s,func_801A51F0,0x801A51F0,0xE From 721d097c101c37683896c726c8086fd16b98da8b Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 11:44:07 +1000 Subject: [PATCH 80/82] more cleanup --- src/audio/voice_external.c | 12 ++--- src/audio/voice_internal.c | 89 ++++++++++++++++++++------------------ 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/audio/voice_external.c b/src/audio/voice_external.c index 69b465e9b..00d5f24a0 100644 --- a/src/audio/voice_external.c +++ b/src/audio/voice_external.c @@ -37,15 +37,15 @@ void func_801A4EB0(void) { void func_801A4EB8(void) { u8* new_var; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; s32 index; u8 sp38[1]; u8 i; if (D_801D8E3C != 0) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); } new_var = func_801A54C4(); @@ -70,13 +70,13 @@ void func_801A4EB8(void) { // Used externally in code_8019AF00 void func_801A4FD8(void) { s32 errorCode; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; func_801A54D0(VOICE_WORD_ID_NONE); if (D_801D8E3C != 0) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); errorCode = func_801A5228(&D_801D8BE0); func_801A54D0(VOICE_WORD_ID_NONE); diff --git a/src/audio/voice_internal.c b/src/audio/voice_internal.c index 2367887d5..a8a19d228 100644 --- a/src/audio/voice_internal.c +++ b/src/audio/voice_internal.c @@ -2,7 +2,7 @@ #include "z64voice.h" // internal voice functions -u8* func_801A5A1C(s8* word); +u8* func_801A5A1C(s8* words); // BSS OSVoiceUnk D_801FD5A0; @@ -50,13 +50,14 @@ s32 func_801A51F0(s32 errorCode) { case CONT_ERR_VOICE_WORD: case CONT_ERR_VOICE_NO_RESPONSE: return -1; + default: return 0; } } s32 func_801A5228(OSVoiceDictionary* dict) { - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; s32 errorCode; u8 numWords; u8 i; @@ -70,9 +71,9 @@ s32 func_801A5228(OSVoiceDictionary* dict) { numWords = dict->numWords; - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceClearDictionary(&gVoiceHandle, numWords); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (errorCode != 0) { return errorCode; @@ -83,9 +84,9 @@ s32 func_801A5228(OSVoiceDictionary* dict) { } for (i = 0; i < numWords; i++) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceSetWord(&gVoiceHandle, &dict->words[i]); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (func_801A51F0(errorCode) != 0) { func_801A5A1C(&dict->words[i]); @@ -97,14 +98,14 @@ s32 func_801A5228(OSVoiceDictionary* dict) { OSVoiceData* func_801A5390(void) { OSVoiceData* voiceData; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; voiceData = D_801FD5A0.data; D_801FD5A0.data = NULL; - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStartReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); return voiceData; } @@ -126,12 +127,12 @@ void func_801A53E8(u16 distance, u16 answerNum, u16 warning, u16 voiceLevel, u16 // Could have a return? or be void return? s32 func_801A541C(s32 analog, s32 digital) { s32 errorCode; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; if (D_801FD5A0.dict != NULL) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceControlGain(&gVoiceHandle, analog, digital); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (errorCode != 0) { func_801A51F0(errorCode); @@ -142,11 +143,11 @@ s32 func_801A541C(s32 analog, s32 digital) { // Unused s32 func_801A5488(u8* word) { s32 errorCode; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceCheckWord(word); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); return errorCode; } @@ -160,7 +161,7 @@ s32 func_801A54D0(u16 wordId) { u8 phi_t0 = true; u8 numWords; u8 i; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; @@ -182,14 +183,14 @@ s32 func_801A54D0(u16 wordId) { } if (phi_t0) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceMaskDictionary(&gVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); } D_801FD5A0.mode = 0; @@ -203,7 +204,7 @@ s32 func_801A5680(u16 wordId) { u8 phi_a3 = true; u8 numWords; u8 i; - OSMesgQueue* msgQ; + OSMesgQueue* serialEventQueue; if (D_801FD5A0.dict != NULL) { numWords = D_801FD5A0.dict->numWords; @@ -225,14 +226,14 @@ s32 func_801A5680(u16 wordId) { } if (phi_a3) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if ((errorCode == 0) || (D_801FD5A0.mode == 0)) { - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceMaskDictionary(&gVoiceHandle, sVoiceMaskPattern, ((numWords - 1) / 8) + 1); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); } D_801FD5A0.mode = 0; @@ -244,22 +245,21 @@ s32 func_801A5680(u16 wordId) { s32 func_801A5808(void) { s32 errorCode = 0; s32 ret; - OSMesgQueue* msgQ; - - if (1) {} + OSMesgQueue* serialEventQueue; switch (D_801FD5A0.mode) { case 0: - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStartReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); D_801FD5A0.mode = 1; break; + case 1: - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceGetReadData(&gVoiceHandle, &D_801FD5C8); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); if (func_801A51F0(errorCode) == 0) { switch (gVoiceHandle.status) { @@ -278,9 +278,13 @@ s32 func_801A5808(void) { case VOICE_STATUS_END: D_801FD5A0.mode = 2; break; + + default: + break; } } break; + case 2: if (((D_801FD5C8.warning & D_801FD5A0.warning) == 0) && (D_801FD5A0.answerNum >= D_801FD5C8.answerNum) && (D_801FD5A0.distance >= D_801FD5C8.distance[0]) && (D_801FD5C8.voiceLevel >= D_801FD5A0.voiceLevel) && @@ -289,16 +293,19 @@ s32 func_801A5808(void) { D_801FD5A0.data = &D_801FD5E8; } - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); osVoiceStopReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); - msgQ = PadMgr_VoiceAcquireSerialEventQueue(); + serialEventQueue = PadMgr_VoiceAcquireSerialEventQueue(); errorCode = osVoiceStartReadData(&gVoiceHandle); - PadMgr_VoiceReleaseSerialEventQueue(msgQ); + PadMgr_VoiceReleaseSerialEventQueue(serialEventQueue); D_801FD5A0.mode = 1; break; + + default: + break; } ret = func_801A51F0(errorCode); @@ -311,15 +318,15 @@ void AudioVoice_ResetData(void) { D_801FD5A0.dict = NULL; } -u8* func_801A5A1C(s8* word) { +u8* func_801A5A1C(s8* words) { u8 i; u8 j; - u8 numSyllables = strlen(word); // technically twice the num of syllables + u8 numSyllables = strlen(words); // technically twice the num of syllables u8 syllable[2]; for (j = 0, i = 0; i < numSyllables; i += 2) { - syllable[0] = word[i]; - syllable[1] = word[i + 1]; + syllable[0] = words[i]; + syllable[1] = words[i + 1]; if (syllable[0] == 0x83) { D_801FD610[j++] = D_801D8F70[syllable[1] - 0x40][0]; @@ -327,7 +334,7 @@ u8* func_801A5A1C(s8* word) { } else if (syllable[0] == 0x82) { D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][0]; D_801FD610[j++] = D_801D8E50[syllable[1] - 0x9F][1]; - } else if (syllable[0] == 0x81 && syllable[1] == 0x5B) { + } else if ((syllable[0] == 0x81) && (syllable[1] == 0x5B)) { D_801FD610[j++] = '-'; D_801FD610[j++] = '-'; } else { From db5335c42a7c98b2d2178217b918f66b42576223 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 11:58:13 +1000 Subject: [PATCH 81/82] cow voice weekeventflag --- include/z64save.h | 3 ++- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 8 ++++---- tools/weekeventregconvert.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 69b9e7ad8..0960185ef 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -1299,7 +1299,8 @@ typedef enum { #define WEEKEVENTREG_86_20 PACK_WEEKEVENTREG_FLAG(86, 0x20) #define WEEKEVENTREG_86_40 PACK_WEEKEVENTREG_FLAG(86, 0x40) #define WEEKEVENTREG_86_80 PACK_WEEKEVENTREG_FLAG(86, 0x80) -#define WEEKEVENTREG_87_01 PACK_WEEKEVENTREG_FLAG(87, 0x01) +// Currently talking to a cow using the voice recognition unit +#define WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE PACK_WEEKEVENTREG_FLAG(87, 0x01) #define WEEKEVENTREG_87_02 PACK_WEEKEVENTREG_FLAG(87, 0x02) #define WEEKEVENTREG_87_04 PACK_WEEKEVENTREG_FLAG(87, 0x04) #define WEEKEVENTREG_87_08 PACK_WEEKEVENTREG_FLAG(87, 0x08) diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index 27fd87bbc..c9621e420 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -159,7 +159,7 @@ void EnCow_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); this->flags = 0; - CLEAR_WEEKEVENTREG(WEEKEVENTREG_87_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); } void EnCow_Destroy(Actor* thisx, PlayState* play) { @@ -295,8 +295,8 @@ void EnCow_Idle(EnCow* this, PlayState* play) { if (this->actor.xzDistToPlayer < 150.0f && ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { if (AudioVoice_GetWord() == VOICE_WORD_ID_MILK) { - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_87_01)) { - SET_WEEKEVENTREG(WEEKEVENTREG_87_01); + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE)) { + SET_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); if (Inventory_HasEmptyBottle()) { this->actor.textId = 0x32C9; // Text to give milk. } else { @@ -307,7 +307,7 @@ void EnCow_Idle(EnCow* this, PlayState* play) { this->actionFunc = EnCow_Talk; } } else { - CLEAR_WEEKEVENTREG(WEEKEVENTREG_87_01); + CLEAR_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); } } diff --git a/tools/weekeventregconvert.py b/tools/weekeventregconvert.py index 591671ab8..8415b02f8 100755 --- a/tools/weekeventregconvert.py +++ b/tools/weekeventregconvert.py @@ -700,7 +700,7 @@ weekEventReg = { (86 << 8) | 0x20: "WEEKEVENTREG_86_20", (86 << 8) | 0x40: "WEEKEVENTREG_86_40", (86 << 8) | 0x80: "WEEKEVENTREG_86_80", - (87 << 8) | 0x01: "WEEKEVENTREG_87_01", + (87 << 8) | 0x01: "WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE", (87 << 8) | 0x02: "WEEKEVENTREG_87_02", (87 << 8) | 0x04: "WEEKEVENTREG_87_04", (87 << 8) | 0x08: "WEEKEVENTREG_87_08", From 6ef3cefb9f1dbad08d7ec1cfacf17e12fed041f4 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Tue, 13 Jun 2023 12:02:48 +1000 Subject: [PATCH 82/82] small cleanup --- src/overlays/actors/ovl_En_Cow/z_en_cow.c | 12 ++++++------ src/overlays/actors/ovl_En_Gs/z_en_gs.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/overlays/actors/ovl_En_Cow/z_en_cow.c b/src/overlays/actors/ovl_En_Cow/z_en_cow.c index c9621e420..28f37897f 100644 --- a/src/overlays/actors/ovl_En_Cow/z_en_cow.c +++ b/src/overlays/actors/ovl_En_Cow/z_en_cow.c @@ -292,8 +292,8 @@ void EnCow_Idle(EnCow* this, PlayState* play) { } } - if (this->actor.xzDistToPlayer < 150.0f && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 25000) { + if ((this->actor.xzDistToPlayer < 150.0f) && + (ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) < 0x61A8)) { if (AudioVoice_GetWord() == VOICE_WORD_ID_MILK) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE)) { SET_WEEKEVENTREG(WEEKEVENTREG_TALKING_TO_COW_WITH_VOICE); @@ -323,8 +323,8 @@ void EnCow_DoTail(EnCow* this, PlayState* play) { Animation_GetLastFrame(&gCowTailIdleAnim), ANIMMODE_ONCE, 1.0f); } - if (this->actor.xzDistToPlayer < 150.0f && - ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 25000) { + if ((this->actor.xzDistToPlayer < 150.0f) && + (ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y)) > 0x61A8)) { if (!(this->flags & EN_COW_FLAG_PLAYER_HAS_APPROACHED)) { this->flags |= EN_COW_FLAG_PLAYER_HAS_APPROACHED; if (this->skelAnime.animation == &gCowTailIdleAnim) { @@ -361,8 +361,8 @@ void EnCow_Update(Actor* thisx, PlayState* play2) { this->actionFunc(this, play); - if (this->actor.xzDistToPlayer < 150.0f && - ABS_ALT(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000) { + if ((this->actor.xzDistToPlayer < 150.0f) && + (ABS_ALT(Math_Vec3f_Yaw(&thisx->world.pos, &player->actor.world.pos)) < 0xC000)) { targetX = Math_Vec3f_Pitch(&thisx->focus.pos, &player->actor.focus.pos); targetY = Math_Vec3f_Yaw(&thisx->focus.pos, &player->actor.focus.pos) - this->actor.shape.rot.y; diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 125f92ad3..846b90a2f 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -925,7 +925,7 @@ void func_80999BC8(Actor* thisx, PlayState* play2) { EnGs* this = THIS; s32 pad; - if (this->actor.isTargeted && AudioVoice_GetWord() == VOICE_WORD_ID_HOURS) { + if (this->actor.isTargeted && (AudioVoice_GetWord() == VOICE_WORD_ID_HOURS)) { this->unk_19D = 0; this->unk_19A |= 1; func_80999AC0(this);