voicesetword.c
1.59 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*---------------------------------------------------------------------
Copyright (C) 1997,1998 Nintendo.
File voicesetword.c
Coded by Koji Mitsunari. Oct 6, 1997.
Modified by Koji Mitsunari. Jun 22, 1998.
Comments Voice Recognition System
$Id: voicesetword.c,v 1.2 2003/03/25 20:42:04 blythe Exp $
---------------------------------------------------------------------*/
#include "osint.h"
#include "controller.h"
#include "siint.h"
s32
osVoiceSetWord(OSVoiceHandle *hd, u8 *data) {
#ifdef BBPLAYER
return CONT_ERR_DEVICE;
#else
s32 j, k, ret;
u8 stat;
u8 buf[40];
if ((ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat)) != 0 ) {
return(ret);
} else if (stat & VOICE_WRITE_READY ) {
return(CONT_ERR_VOICE_NO_RESPONSE);
}
for ( k = 0 ; data[k] ; k += 2); /* NULLޤǥݥư */
#ifdef _DEBUG
if (k >= 34) {
return(CONT_ERR_VOICE_WORD);
}
#endif
bzero(buf, 40);
for ( j = 0 ; j < k ; j += 2 ) {
buf[39 - k + j] = data[j];
buf[39 - k + j-1] = data[j+1];
}
buf[39-j-5] = 3;
if (k > 14) {
ret = __osVoiceContWrite20(hd->__mq, hd->__channel, VOICE_RW_ADDR, buf);
if (ret != 0 ) {
return(ret);
}
}
ret = __osVoiceContWrite20(hd->__mq, hd->__channel, VOICE_RW_ADDR,
&buf[20]);
if (ret != 0 ) {
return(ret);
}
ret = __osVoiceCheckResult(hd, &stat);
if (ret != 0) {
if (ret & 0x0100) {
ret = CONT_ERR_VOICE_MEMORY;
} else if (ret & 0x0200) {
ret = CONT_ERR_VOICE_WORD;
} else if (ret & 0xff00) {
ret = CONT_ERR_INVALID;
}
}
return(ret);
#endif
}