diff options
-rw-r--r-- | apps/talk.c | 30 | ||||
-rwxr-xr-x | tools/genlang | 23 |
2 files changed, 42 insertions, 11 deletions
diff --git a/apps/talk.c b/apps/talk.c index f65b594b92..7ba858b47d 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -51,9 +51,10 @@ struct clip_entry /* one entry of the index table */ | |||
51 | struct voicefont /* file format of our "voicefont" */ | 51 | struct voicefont /* file format of our "voicefont" */ |
52 | { | 52 | { |
53 | int version; /* version of the voicefont */ | 53 | int version; /* version of the voicefont */ |
54 | int headersize; /* size of the header, =offset to index */ | 54 | int table; /* offset to index table, (=header size) */ |
55 | int id_max; /* number of clips contained */ | 55 | int id1_max; /* number of "normal" clips contained in above index */ |
56 | struct clip_entry index[]; /* followed by the index table */ | 56 | int id2_max; /* number of "voice only" clips contained in above index */ |
57 | struct clip_entry index[]; /* followed by the index tables */ | ||
57 | /* and finally the bitswapped mp3 clips, not visible here */ | 58 | /* and finally the bitswapped mp3 clips, not visible here */ |
58 | }; | 59 | }; |
59 | 60 | ||
@@ -104,7 +105,7 @@ static int load_voicefont(void) | |||
104 | 105 | ||
105 | size = read(fd, mp3buf, mp3end - mp3buf); | 106 | size = read(fd, mp3buf, mp3end - mp3buf); |
106 | if (size > 1000 | 107 | if (size > 1000 |
107 | && ((struct voicefont*)mp3buf)->headersize | 108 | && ((struct voicefont*)mp3buf)->table |
108 | == offsetof(struct voicefont, index)) | 109 | == offsetof(struct voicefont, index)) |
109 | { | 110 | { |
110 | p_voicefont = (struct voicefont*)mp3buf; | 111 | p_voicefont = (struct voicefont*)mp3buf; |
@@ -294,9 +295,12 @@ int talk_id(int id, bool enqueue) | |||
294 | if (p_voicefont == NULL) /* still no voices? */ | 295 | if (p_voicefont == NULL) /* still no voices? */ |
295 | return -1; | 296 | return -1; |
296 | 297 | ||
298 | if (id == -1) /* -1 is an indication for silence */ | ||
299 | return -1; | ||
300 | |||
297 | /* check if this is a special ID, with a value */ | 301 | /* check if this is a special ID, with a value */ |
298 | unit = ((unsigned)id) >> UNIT_SHIFT; | 302 | unit = ((unsigned)id) >> UNIT_SHIFT; |
299 | if (id != -1 && unit) | 303 | if (unit) |
300 | { /* sign-extend the value */ | 304 | { /* sign-extend the value */ |
301 | //splash(200, true,"unit=%d", unit); | 305 | //splash(200, true,"unit=%d", unit); |
302 | id = (unsigned)id << (32-UNIT_SHIFT); | 306 | id = (unsigned)id << (32-UNIT_SHIFT); |
@@ -305,9 +309,19 @@ int talk_id(int id, bool enqueue) | |||
305 | return 0; /* and stop, end of special case */ | 309 | return 0; /* and stop, end of special case */ |
306 | } | 310 | } |
307 | 311 | ||
308 | if (id < 0 || id >= p_voicefont->id_max) | 312 | if (id > VOICEONLY_DELIMITER) |
309 | return -1; | 313 | { /* voice-only entries use the second part of the table */ |
310 | 314 | id -= VOICEONLY_DELIMITER + 1; | |
315 | if (id >= p_voicefont->id2_max) | ||
316 | return -1; /* must be newer than we have */ | ||
317 | id += p_voicefont->id1_max; /* table 2 is behind table 1 */ | ||
318 | } | ||
319 | else | ||
320 | { /* normal use of the first table */ | ||
321 | if (id >= p_voicefont->id1_max) | ||
322 | return -1; /* must be newer than we have */ | ||
323 | } | ||
324 | |||
311 | clipsize = p_voicefont->index[id].size; | 325 | clipsize = p_voicefont->index[id].size; |
312 | if (clipsize == 0) /* clip not included in voicefont */ | 326 | if (clipsize == 0) /* clip not included in voicefont */ |
313 | return -1; | 327 | return -1; |
diff --git a/tools/genlang b/tools/genlang index de9dd43920..fd0b498813 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -62,6 +62,7 @@ while(<LANG>) { | |||
62 | $set{$var} = $value; | 62 | $set{$var} = $value; |
63 | 63 | ||
64 | if( (($var eq "new") && $value && ($value !~ /^\"(.*)\"\W*$/)) || | 64 | if( (($var eq "new") && $value && ($value !~ /^\"(.*)\"\W*$/)) || |
65 | (($var eq "voice") && $value && ($value !~ /^\"(.*)\"\W*$/)) || | ||
65 | (($var eq "eng") && ($value !~ /^\"(.*)\"\W*$/)) ) { | 66 | (($var eq "eng") && ($value !~ /^\"(.*)\"\W*$/)) ) { |
66 | print "$input:$line:missing quotes for ".$set{'id'}."\n"; | 67 | print "$input:$line:missing quotes for ".$set{'id'}."\n"; |
67 | $errors++; | 68 | $errors++; |
@@ -75,9 +76,15 @@ while(<LANG>) { | |||
75 | # if not set, get the english version | 76 | # if not set, get the english version |
76 | $value = $set{'eng'}; | 77 | $value = $set{'eng'}; |
77 | } | 78 | } |
78 | 79 | # print "VOICE: ".$set{'voice'}." VALUE: $value\n"; | |
79 | print HFILE " ".$set{'id'}.",\n"; | 80 | if(($value eq "\"\"") && $set{'voice'}) { |
80 | print CFILE " $value,\n"; | 81 | # voice-only |
82 | push @vfile, $set{'id'}; | ||
83 | } | ||
84 | else { | ||
85 | push @hfile, $set{'id'}; | ||
86 | print CFILE " $value,\n"; | ||
87 | } | ||
81 | 88 | ||
82 | undef %set; | 89 | undef %set; |
83 | } | 90 | } |
@@ -87,6 +94,16 @@ while(<LANG>) { | |||
87 | } | 94 | } |
88 | close(LANG); | 95 | close(LANG); |
89 | 96 | ||
97 | for(@hfile) { | ||
98 | print HFILE " $_,\n"; | ||
99 | } | ||
100 | |||
101 | print HFILE " /* --- below this follows voice-only strings --- */\n", | ||
102 | " VOICEONLY_DELIMITER = 0x8000,\n"; | ||
103 | |||
104 | for(@vfile) { | ||
105 | print HFILE " $_,\n"; | ||
106 | } | ||
90 | 107 | ||
91 | print HFILE <<MOO | 108 | print HFILE <<MOO |
92 | LANG_LAST_INDEX_IN_ARRAY /* this is not a string, this is a marker */ | 109 | LANG_LAST_INDEX_IN_ARRAY /* this is not a string, this is a marker */ |