voicecheckword.c
4.99 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*---------------------------------------------------------------------
Copyright (C) 1998 Nintendo.
File voicecheckword.c
Coded by Koji Mitsunari. May 26, 1998.
Modified by Koji Mitsunari. Jul 1, 1998.
Comments Voice Recognition System
$Id: voicecheckword.c,v 1.1.1.1 2002/05/02 03:28:44 blythe Exp $
---------------------------------------------------------------------*/
/**************************************************************************
*
* $Revision: 1.1.1.1 $
* $Date: 2002/05/02 03:28:44 $
* $Source:
*
**************************************************************************/
#include "osint.h"
#include "controller.h"
#include "siint.h"
s32
osVoiceCheckWord(u8 *data) {
s32 k, ret = 0;
u16 sjis, old = 0;
for ( k = 0 ; data[k] ; k += 2) {
sjis = (data[k]<<8)+data[k+1];
if ( (sjis != 0x815b && sjis < 0x829f) ||
(sjis > 0x82f1 && sjis < 0x8340) ||
sjis == 0x837f ||
sjis > 0x8396 ) {
ret = CONT_ERR_VOICE_WORD;
} else if ( k == 0 && /* 先頭の文字の場合 */
(sjis == 0x815b || sjis == 0x82f1 || sjis == 0x82c1 ||
sjis == 0x82ec || sjis == 0x8393 || sjis == 0x8362 ||
sjis == 0x838e || sjis == 0x8395 || sjis == 0x8396)) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x829f || sjis == 0x8340) &&
(old != 0x82d3 && old != 0x8374 && old != 0x8394)) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x82a1 || sjis == 0x8342) &&
(old != 0x82a4 && old != 0x82c4 && old != 0x82c5 &&
old != 0x82d3 && old != 0x8345 && old != 0x8365 &&
old != 0x8366 && old != 0x8374 && old != 0x8394 )) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x82a3 || sjis == 0x8344) &&
(old != 0x82c6 && old != 0x82c7 && old != 0x82d3 &&
old != 0x8367 && old != 0x8368 && old != 0x8374 &&
old != 0x8394 )) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x82a5 || sjis == 0x8346) &&
(old != 0x82a4 && old != 0x82b5 && old != 0x82b6 &&
old != 0x82bf && old != 0x82c0 && old != 0x82c2 &&
old != 0x82d3 && old != 0x8345 && old != 0x8356 &&
old != 0x8357 && old != 0x8360 && old != 0x8361 &&
old != 0x8363 && old != 0x8374 && old != 0x8394 )) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x82a7 || sjis == 0x8348) &&
(old != 0x82a4 && old != 0x82d3 && old != 0x8345 &&
old != 0x8374 && old != 0x8394 )) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x82e1 || sjis == 0x82e3 || sjis == 0x82e5 ||
sjis == 0x8383 || sjis == 0x8385 || sjis == 0x8387 ) &&
(old != 0x82ab && old != 0x82b5 && old != 0x82bf &&
old != 0x82c9 && old != 0x82d0 && old != 0x82dd &&
old != 0x82e8 && old != 0x82ac && old != 0x82b6 &&
old != 0x82c0 && old != 0x82d1 && old != 0x82d2 &&
old != 0x834c && old != 0x8356 && old != 0x8360 &&
old != 0x836a && old != 0x8371 && old != 0x837e &&
old != 0x838a && old != 0x834d && old != 0x8357 &&
old != 0x8361 && old != 0x8372 && old != 0x8373 &&
old != 0x8394 )) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x815b) && /* 「ー」の前では使用不可 */
(old == 0x82f1 || old == 0x82c1 ||
old == 0x8393 || old == 0x8362)) {
ret = CONT_ERR_VOICE_WORD;
} else if ((sjis == 0x82f1 || sjis == 0x8393) && /* 「んん」 */
(old == 0x82f1 || old == 0x8393)) {
ret = CONT_ERR_VOICE_WORD;
} else if ((old == 0x82c1 || old == 0x8362) && /* 「っ」のあと */
(sjis == 0x815b || sjis == 0x82a0 || sjis == 0x82a2 ||
sjis == 0x82a4 || sjis == 0x82a6 || sjis == 0x82a8 ||
sjis == 0x82c8 || sjis == 0x82c9 || sjis == 0x82ca ||
sjis == 0x82cb || sjis == 0x82cc || sjis == 0x82dc ||
sjis == 0x82dd || sjis == 0x82de || sjis == 0x82df ||
sjis == 0x82e0 || sjis == 0x82e2 || sjis == 0x82e4 ||
sjis == 0x82e6 || sjis == 0x82e7 || sjis == 0x82e8 ||
sjis == 0x82e9 || sjis == 0x82ea || sjis == 0x82eb ||
sjis == 0x82ed || sjis == 0x82ee || sjis == 0x82ef ||
sjis == 0x82f0 || sjis == 0x82f1 || sjis == 0x829f ||
sjis == 0x82a1 || sjis == 0x82a3 || sjis == 0x82a5 ||
sjis == 0x82a7 || sjis == 0x82e1 || sjis == 0x82e3 ||
sjis == 0x82e5 || sjis == 0x82c1 || sjis == 0x82ec ||
sjis == 0x8341 || sjis == 0x8343 || sjis == 0x8345 ||
sjis == 0x8347 || sjis == 0x8349 || sjis == 0x8369 ||
sjis == 0x836a || sjis == 0x836b || sjis == 0x836c ||
sjis == 0x836d || sjis == 0x837d || sjis == 0x837e ||
sjis == 0x8380 || sjis == 0x8381 || sjis == 0x8382 ||
sjis == 0x8384 || sjis == 0x8386 || sjis == 0x8388 ||
sjis == 0x8389 || sjis == 0x838a || sjis == 0x838b ||
sjis == 0x838c || sjis == 0x838d || sjis == 0x838f ||
sjis == 0x8390 || sjis == 0x8391 || sjis == 0x8392 ||
sjis == 0x8393 || sjis == 0x8340 || sjis == 0x8342 ||
sjis == 0x8344 || sjis == 0x8346 || sjis == 0x8348 ||
sjis == 0x8383 || sjis == 0x8385 || sjis == 0x8387 ||
sjis == 0x8362 || sjis == 0x838e)) {
ret = CONT_ERR_VOICE_WORD;
}
if (ret != 0) {
return(ret);
} else {
old = sjis;
}
}
if (sjis == 0x82c1 || sjis == 0x8362) { /* 単語の末尾 */
ret = CONT_ERR_VOICE_WORD;
}
return(ret);
}