summaryrefslogtreecommitdiff
path: root/src/libultra/voice/voicecheckresult.c
blob: e5e13c9260ea9d95cd2ede9145a2c3b04eae100b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * File: voicecheckresult.c
 */

#include "PR/controller_voice.h"
#include "PR/controller.h"
#include "PR/os_voice.h"

s32 __osVoiceCheckResult(OSVoiceHandle* hd, u8* status) {
    s32 errorCode = __osVoiceGetStatus(hd->__mq, hd->__channel, status);
    u8 data[2];

    if (errorCode == 0) {
        if (*status & 1) {
            errorCode = CONT_ERR_VOICE_NO_RESPONSE;
        } else {
            errorCode = __osVoiceContRead2(hd->__mq, hd->__channel, 0, data);
            if (errorCode == 0) {
                hd->cmd_status = data[0] & 7;

                if (data[0] & 0x40) {
                    errorCode = CONT_ERR_VOICE_NO_RESPONSE;
                } else {
                    errorCode = data[1] << 8;
                }
            }
        }
    }
    return errorCode;
}