Match osVoiceSetWord

This commit is contained in:
engineer124
2021-11-09 00:06:50 +11:00
parent 1647f42c3d
commit 5459a9e781
2 changed files with 58 additions and 2 deletions
+1 -1
View File
@@ -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);
+57 -1
View File
@@ -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;
}