Add error codes

This commit is contained in:
engineer124
2021-11-09 10:50:33 +11:00
parent 5459a9e781
commit 6775824c4d
10 changed files with 62 additions and 61 deletions
+2 -2
View File
@@ -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;
}
+12 -12
View File
@@ -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;
+3 -3
View File
@@ -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;
+1 -1
View File
@@ -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);
+7 -7
View File
@@ -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;
+14 -13
View File
@@ -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;
}
+8 -8
View File
@@ -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;
+8 -8
View File
@@ -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;
}
}
+3 -3
View File
@@ -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;
}
+4 -4
View File
@@ -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;
}
}