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);