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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
/***************************************************************************
toshiba 6721a chip approximation
(voice output)
not really working
communication with c364 works, no speech synthesis
includes c364 interface hardware
PeT mess@utanet.at
documentation
www.funet.fi
***************************************************************************/
/*
c364 speech
say 0 .. 10
rate 0 .. 15?
voc ?
rdy ? (only c64)
0 bit 0..3 ???
bit 456 0?
bit 7 writen 0 1
reset 9 9 b
set playback rate
rate 4: 2 a 4 5 4 6 0 7 a (default)
0 0
1 1
rate 2: 2 a 4 5 2 6 0 7 a
rate 3: 3
rate 9:
start: 1
1 bit 01 set to 1 for start ?
bit 6 polled until set (at $80ec)
7 set ready to transmit new byte?
2 0..7 sample data
seems to be a toshiba t6721a build in
(8 kHz 9bit output)
generates output for 20ms (or 10ms) out of 6 byte voice data!
(P?ARCOR voice synthesizing and analyzing method
Nippon Telegraph and Telephon Public Corporation)
End code also in voice data
technical info at www.funet.fi covers only the chip, not
the synthesizing method
magic voice in c64:
The internal electronics depicted in Danny's picture above are as follows, going from the MOS chip at top and then clockwise: MOS
6525B (4383), MOS 251476-01 (8A-06 4341) system ROM, General Instruments 8343SEA (LA05-123), Toshiba T6721A (3L)
sound generator (?), CD40105BE (RCA H 432) and a 74LS222A logic chip.
*/
#include "emu.h"
#include "audio/t6721.h"
typedef struct _t6721_state t6721_state;
struct _t6721_state
{
emu_timer *timer;
int busy, end_of_sample;
int playing;
int rate;
UINT8 command_data;
int command_state;
UINT8 sample_data[6], sample_index;
UINT8 state;
int sample_timeindex;
UINT8 readindex, writeindex;
UINT64 data[0x10];
};
/*****************************************************************************
LOGGING
*****************************************************************************/
#define VERBOSE_LEVEL 0
#define DBG_LOG(N,M,A) \
do { \
if(VERBOSE_LEVEL >= N) \
{ \
if( M ) \
logerror("%11.6f: %-24s", device->machine().time().as_double(), (char*) M ); \
logerror A; \
} \
} while(0)
/*****************************************************************************
INLINE FUNCTIONS
*****************************************************************************/
INLINE t6721_state *get_safe_token( device_t *device )
{
assert(device != NULL);
assert(device->type() == T6721);
return (t6721_state *)downcast<t6721_device *>(device)->token();
}
/*****************************************************************************
IMPLEMENTATION
*****************************************************************************/
static TIMER_CALLBACK( t6721_speech_timer )
{
t6721_state *t6721 = (t6721_state *)ptr;
if (!t6721->playing)
return;
if (t6721->sample_timeindex < 8000 / 50)
{
t6721->sample_timeindex++;
}
else
{
t6721->end_of_sample = (memcmp(t6721->sample_data, "\xff\xff\xff\xff\xff\xff", 6) == 0);
/*t6721->end_of_sample = 1; */
t6721->busy = 0;
}
}
WRITE8_DEVICE_HANDLER( t6721_speech_w )
{
t6721_state *t6721 = get_safe_token(device);
DBG_LOG(2, "364", ("port write %.2x %.2x\n", offset, data));
switch (offset)
{
case 0:
if (data & 0x80)
{
switch (t6721->command_state)
{
case 0:
switch (t6721->command_data)
{
case 9: case 0xb:
t6721->playing = 0;
break;
case 1: /* start */
t6721->timer->adjust(attotime::zero, 0, attotime::from_hz(8000));
t6721->playing = 1;
t6721->end_of_sample = 0;
t6721->sample_timeindex = 0;
break;
case 2:
t6721->end_of_sample = 0;
/*t6721->busy = 0; */
t6721->timer->reset();
t6721->playing = 0;
break;
case 5: /* set rate (in next nibble) */
t6721->command_state = 1;
break;
case 6: /* condition */
t6721->command_state = 2;
break;
}
break;
case 1:
t6721->command_state = 0;
t6721->rate = t6721->command_data;
break;
case 2:
t6721->command_state = 0;
break;
}
}
else
{
t6721->command_data = data;
}
break;
case 1:
t6721->state = (t6721->state & ~0x3f) | data;
break;
case 2:
t6721->sample_data[t6721->sample_index++] = data;
if (t6721->sample_index == sizeof(t6721->sample_data))
{
DBG_LOG(1,"t6721",("%.2x%.2x%.2x%.2x%.2x%.2x\n",
t6721->sample_data[0],
t6721->sample_data[1],
t6721->sample_data[2],
t6721->sample_data[3],
t6721->sample_data[4],
t6721->sample_data[5]));
t6721->sample_index = 0;
/*t6721->end_of_sample = false; */
t6721->busy = 1;
t6721->state = 0;
}
break;
}
}
READ8_DEVICE_HANDLER( t6721_speech_r )
{
t6721_state *t6721 = get_safe_token(device);
int data = 0xff;
switch (offset)
{
case 1:
data = t6721->state;
data = 1;
if (!t6721->end_of_sample)
{
data |= 0x41;
if (!t6721->busy)
data |= 0x81;
}
break;
}
DBG_LOG(2, "364", ("port read %.2x %.2x\n", offset, data));
return data;
}
/*****************************************************************************
DEVICE INTERFACE
*****************************************************************************/
static DEVICE_START( t6721 )
{
t6721_state *t6721 = get_safe_token(device);
t6721->timer = device->machine().scheduler().timer_alloc(FUNC(t6721_speech_timer), t6721);
device->save_item(NAME(t6721->sample_data));
device->save_item(NAME(t6721->data));
device->save_item(NAME(t6721->sample_index));
device->save_item(NAME(t6721->busy));
device->save_item(NAME(t6721->end_of_sample));
device->save_item(NAME(t6721->playing));
device->save_item(NAME(t6721->rate));
device->save_item(NAME(t6721->command_data));
device->save_item(NAME(t6721->command_state));
device->save_item(NAME(t6721->state));
device->save_item(NAME(t6721->sample_timeindex));
device->save_item(NAME(t6721->readindex));
device->save_item(NAME(t6721->writeindex));
}
static DEVICE_RESET( t6721 )
{
t6721_state *t6721 = get_safe_token(device);
memset(t6721->sample_data, 0, ARRAY_LENGTH(t6721->sample_data));
memset(t6721->data, 0, ARRAY_LENGTH(t6721->data));
t6721->sample_index = 0;
t6721->busy = 0;
t6721->end_of_sample = 0;
t6721->playing = 0;
t6721->rate = 0;
t6721->command_data = 0;
t6721->command_state = 0;
t6721->state = 0;
t6721->sample_timeindex = 0;
t6721->readindex = 0;
t6721->writeindex = 0;
}
const device_type T6721 = &device_creator<t6721_device>;
t6721_device::t6721_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, T6721, "Toshiba 6721A", tag, owner, clock)
{
m_token = global_alloc_array_clear(UINT8, sizeof(t6721_state));
}
//-------------------------------------------------
// device_config_complete - perform any
// operations now that the configuration is
// complete
//-------------------------------------------------
void t6721_device::device_config_complete()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void t6721_device::device_start()
{
DEVICE_START_NAME( t6721 )(this);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void t6721_device::device_reset()
{
DEVICE_RESET_NAME( t6721 )(this);
}
|