From 6cbf9734a7dbfb8997a79033fbca7565642d8117 Mon Sep 17 00:00:00 2001 From: engineer124 Date: Sun, 3 Oct 2021 17:43:53 +1100 Subject: [PATCH] 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; +}