summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/sound
diff options
context:
space:
mode:
author Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-02-02 19:25:25 +0000
committer Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-02-02 19:25:25 +0000
commitedf6aa3d8e2cafac5af8c52e0f3833c51e6a2658 (patch)
tree7b0dd6e90321f77e3a01af4ea7a838c5e19da10b /src/emu/sound
parent0ff47c0b8b135292116f83cf017a1085aebb3705 (diff)
Modernized digitalker, x1_010, tiaintf, and n63701x sound devices. [Andrew Gardner]
Diffstat (limited to 'src/emu/sound')
-rw-r--r--src/emu/sound/digitalk.c470
-rw-r--r--src/emu/sound/digitalk.h89
-rw-r--r--src/emu/sound/n63701x.c121
-rw-r--r--src/emu/sound/n63701x.h43
-rw-r--r--src/emu/sound/tiaintf.c82
-rw-r--r--src/emu/sound/tiaintf.h31
-rw-r--r--src/emu/sound/x1_010.c238
-rw-r--r--src/emu/sound/x1_010.h54
8 files changed, 543 insertions, 585 deletions
diff --git a/src/emu/sound/digitalk.c b/src/emu/sound/digitalk.c
index 13b8ad24d7f..4b57f56999d 100644
--- a/src/emu/sound/digitalk.c
+++ b/src/emu/sound/digitalk.c
@@ -236,30 +236,6 @@ complete set of waveforms is repeated R times.
*/
-
-struct digitalker {
- const UINT8 *rom;
- device_t *device;
- sound_stream *stream;
-
- // Port/lines state
- UINT8 data, cs, cms, wr, intr;
-
- // Current decoding state
- UINT16 bpos, apos;
- UINT8 mode, cur_segment, cur_repeat, segments, repeats;
- UINT8 prev_pitch, pitch, pitch_pos;
- UINT8 stop_after, cur_dac, cur_bits;
-
- // Zero-range size
- UINT32 zero_count; // 0 for done
-
- // Waveform and current index in it
- UINT8 dac_index; // 128 for done
- INT16 dac[128];
-
-};
-
// Quantized intensity values, first index is the volume, second the
// intensity (positive half only, real value goes -8..7)
static const short pcm_levels[8][8] = {
@@ -277,22 +253,44 @@ static const int delta1[16] = { -4, -4, -1, -1, -2, -2, 0, 0, 0, 0, 2, 2, 1, 1,
static const int delta2[16] = { 0, -1, -2, -3, 1, 0, -1, -2, 2, 1, 0, -1, 3, 2, 1, 0 };
// Frequency quantizations, values are in units of 128us.
-
static const int pitch_vals[32] = {
97, 95, 92, 89, 87, 84, 82, 80, 77, 75, 73, 71, 69, 67, 65, 63,
61, 60, 58, 56, 55, 53, 52, 50, 49, 48, 46, 45, 43, 42, 41, 40
};
-INLINE digitalker *get_safe_token(device_t *device)
+const device_type DIGITALKER = &device_creator<digitalker_device>;
+
+digitalker_device::digitalker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, DIGITALKER, "Digitalker", tag, owner, clock),
+ device_sound_interface(mconfig, *this),
+ m_rom(NULL),
+ m_stream(NULL),
+ m_data(0),
+ m_cs(0),
+ m_cms(0),
+ m_wr(0),
+ m_intr(0),
+ m_bpos(0),
+ m_apos(0),
+ m_mode(0),
+ m_cur_segment(0),
+ m_cur_repeat(0),
+ m_segments(0),
+ m_repeats(0),
+ m_prev_pitch(0),
+ m_pitch(0),
+ m_pitch_pos(0),
+ m_stop_after(0),
+ m_cur_dac(0),
+ m_cur_bits(0),
+ m_zero_count(0),
+ m_dac_index(0)
{
- assert(device != NULL);
- assert(device->type() == DIGITALKER);
- return (digitalker *)downcast<digitalker_device *>(device)->token();
}
-static void digitalker_write(digitalker *dg, UINT8 *adr, UINT8 vol, INT8 dac)
+void digitalker_device::digitalker_write(UINT8 *adr, UINT8 vol, INT8 dac)
{
INT16 v;
dac &= 15;
@@ -302,10 +300,10 @@ static void digitalker_write(digitalker *dg, UINT8 *adr, UINT8 vol, INT8 dac)
v = pcm_levels[vol][dac-1];
else
v = 0;
- dg->dac[(*adr)++] = v;
+ m_dac[(*adr)++] = v;
}
-static UINT8 digitalker_pitch_next(UINT8 val, UINT8 prev, int step)
+UINT8 digitalker_device::digitalker_pitch_next(UINT8 val, UINT8 prev, int step)
{
int delta, nv;
@@ -323,253 +321,257 @@ static UINT8 digitalker_pitch_next(UINT8 val, UINT8 prev, int step)
return nv;
}
-static void digitalker_set_intr(digitalker *dg, UINT8 intr)
+void digitalker_device::digitalker_set_intr(UINT8 intr)
{
- dg->intr = intr;
+ m_intr = intr;
}
-static void digitalker_start_command(digitalker *dg, UINT8 cmd)
+void digitalker_device::digitalker_start_command(UINT8 cmd)
{
- dg->bpos = ((dg->rom[cmd*2] << 8) | dg->rom[cmd*2+1]) & 0x3fff;
- dg->cur_segment = dg->segments = dg->cur_repeat = dg->repeats = 0;
- dg->dac_index = 128;
- dg->zero_count = 0;
- digitalker_set_intr(dg, 0);
+ m_bpos = ((m_rom[cmd*2] << 8) | m_rom[cmd*2+1]) & 0x3fff;
+ m_cur_segment = m_segments = m_cur_repeat = m_repeats = 0;
+ m_dac_index = 128;
+ m_zero_count = 0;
+ digitalker_set_intr(0);
}
-static void digitalker_step_mode_0(digitalker *dg)
+void digitalker_device::digitalker_step_mode_0()
{
INT8 dac = 0;
int i, k, l;
UINT8 wpos = 0;
- UINT8 h = dg->rom[dg->apos];
+ UINT8 h = m_rom[m_apos];
UINT16 bits = 0x80;
UINT8 vol = h >> 5;
- UINT8 pitch_id = dg->cur_segment ? digitalker_pitch_next(h, dg->prev_pitch, dg->cur_repeat) : h & 0x1f;
+ UINT8 pitch_id = m_cur_segment ? digitalker_pitch_next(h, m_prev_pitch, m_cur_repeat) : h & 0x1f;
- dg->pitch = pitch_vals[pitch_id];
+ m_pitch = pitch_vals[pitch_id];
for(i=0; i<32; i++)
- dg->dac[wpos++] = 0;
+ m_dac[wpos++] = 0;
for(k=1; k != 9; k++) {
- bits |= dg->rom[dg->apos+k] << 8;
+ bits |= m_rom[m_apos+k] << 8;
for(l=0; l<4; l++) {
dac += delta1[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
bits >>= 8;
}
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
for(k=7; k >= 0; k--) {
- bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
+ bits = (bits << 8) | (k ? m_rom[m_apos+k] : 0x80);
for(l=3; l>=0; l--) {
dac -= delta1[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
}
for(i=0; i<31; i++)
- dg->dac[wpos++] = 0;
-
- dg->cur_repeat++;
- if(dg->cur_repeat == dg->repeats) {
- dg->apos += 9;
- dg->prev_pitch = pitch_id;
- dg->cur_repeat = 0;
- dg->cur_segment++;
+ m_dac[wpos++] = 0;
+
+ m_cur_repeat++;
+ if(m_cur_repeat == m_repeats) {
+ m_apos += 9;
+ m_prev_pitch = pitch_id;
+ m_cur_repeat = 0;
+ m_cur_segment++;
}
}
-static void digitalker_step_mode_1(digitalker *dg)
+void digitalker_device::digitalker_step_mode_1()
{
logerror("Digitalker mode 1 unsupported");
- dg->zero_count = 1;
- dg->cur_segment = dg->segments;
+ m_zero_count = 1;
+ m_cur_segment = m_segments;
}
-static void digitalker_step_mode_2(digitalker *dg)
+void digitalker_device::digitalker_step_mode_2()
{
INT8 dac = 0;
int k, l;
UINT8 wpos=0;
- UINT8 h = dg->rom[dg->apos];
+ UINT8 h = m_rom[m_apos];
UINT16 bits = 0x80;
UINT8 vol = h >> 5;
- UINT8 pitch_id = dg->cur_segment ? digitalker_pitch_next(h, dg->prev_pitch, dg->cur_repeat) : h & 0x1f;
+ UINT8 pitch_id = m_cur_segment ? digitalker_pitch_next(h, m_prev_pitch, m_cur_repeat) : h & 0x1f;
- dg->pitch = pitch_vals[pitch_id];
+ m_pitch = pitch_vals[pitch_id];
for(k=1; k != 9; k++) {
- bits |= dg->rom[dg->apos+k] << 8;
+ bits |= m_rom[m_apos+k] << 8;
for(l=0; l<4; l++) {
dac += delta1[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
bits >>= 8;
}
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
for(k=7; k >= 0; k--) {
int limit = k ? 0 : 1;
- bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
+ bits = (bits << 8) | (k ? m_rom[m_apos+k] : 0x80);
for(l=3; l>=limit; l--) {
dac -= delta1[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
}
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
for(k=1; k != 9; k++) {
int start = k == 1 ? 1 : 0;
- bits |= dg->rom[dg->apos+k] << 8;
+ bits |= m_rom[m_apos+k] << 8;
for(l=start; l<4; l++) {
dac += delta1[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
bits >>= 8;
}
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
for(k=7; k >= 0; k--) {
int limit = k ? 0 : 1;
- bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
+ bits = (bits << 8) | (k ? m_rom[m_apos+k] : 0x80);
for(l=3; l>=limit; l--) {
dac -= delta1[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
}
- dg->cur_repeat++;
- if(dg->cur_repeat == dg->repeats) {
- dg->apos += 9;
- dg->prev_pitch = pitch_id;
- dg->cur_repeat = 0;
- dg->cur_segment++;
+ m_cur_repeat++;
+ if(m_cur_repeat == m_repeats) {
+ m_apos += 9;
+ m_prev_pitch = pitch_id;
+ m_cur_repeat = 0;
+ m_cur_segment++;
}
}
-static void digitalker_step_mode_3(digitalker *dg)
+void digitalker_device::digitalker_step_mode_3()
{
- UINT8 h = dg->rom[dg->apos];
+ UINT8 h = m_rom[m_apos];
UINT8 vol = h >> 5;
UINT16 bits;
UINT8 dac, apos, wpos;
int k, l;
- dg->pitch = pitch_vals[h & 0x1f];
- if(dg->cur_segment == 0 && dg->cur_repeat == 0) {
- dg->cur_bits = 0x40;
- dg->cur_dac = 0;
+ m_pitch = pitch_vals[h & 0x1f];
+ if(m_cur_segment == 0 && m_cur_repeat == 0) {
+ m_cur_bits = 0x40;
+ m_cur_dac = 0;
}
- bits = dg->cur_bits;
+ bits = m_cur_bits;
dac = 0;
- apos = dg->apos + 1 + 32*dg->cur_segment;
+ apos = m_apos + 1 + 32*m_cur_segment;
wpos = 0;
for(k=0; k != 32; k++) {
- bits |= dg->rom[apos++] << 8;
+ bits |= m_rom[apos++] << 8;
for(l=0; l<4; l++) {
dac += delta2[(bits >> (6+2*l)) & 15];
- digitalker_write(dg, &wpos, vol, dac);
+ digitalker_write(&wpos, vol, dac);
}
bits >>= 8;
}
- dg->cur_bits = bits;
- dg->cur_dac = dac;
+ m_cur_bits = bits;
+ m_cur_dac = dac;
- dg->cur_segment++;
- if(dg->cur_segment == dg->segments) {
- dg->cur_segment = 0;
- dg->cur_repeat++;
+ m_cur_segment++;
+ if(m_cur_segment == m_segments) {
+ m_cur_segment = 0;
+ m_cur_repeat++;
}
}
-static void digitalker_step(digitalker *dg)
+void digitalker_device::digitalker_step()
{
- if(dg->cur_segment == dg->segments || dg->cur_repeat == dg->repeats) {
- if(dg->stop_after == 0 && dg->bpos == 0xffff)
+ if(m_cur_segment == m_segments || m_cur_repeat == m_repeats) {
+ if(m_stop_after == 0 && m_bpos == 0xffff)
return;
- if(dg->stop_after == 0) {
- UINT8 v1 = dg->rom[dg->bpos++];
- UINT8 v2 = dg->rom[dg->bpos++];
- UINT8 v3 = dg->rom[dg->bpos++];
- dg->apos = v2 | ((v3 << 8) & 0x3f00);
- dg->segments = (v1 & 15) + 1;
- dg->repeats = ((v1 >> 4) & 7) + 1;
- dg->mode = (v3 >> 6) & 3;
- dg->stop_after = (v1 & 0x80) != 0;
-
- dg->cur_segment = 0;
- dg->cur_repeat = 0;
-
- if(!dg->apos) {
- dg->zero_count = 40*128*dg->segments*dg->repeats;
- dg->segments = 0;
- dg->repeats = 0;
+ if(m_stop_after == 0) {
+ UINT8 v1 = m_rom[m_bpos++];
+ UINT8 v2 = m_rom[m_bpos++];
+ UINT8 v3 = m_rom[m_bpos++];
+ m_apos = v2 | ((v3 << 8) & 0x3f00);
+ m_segments = (v1 & 15) + 1;
+ m_repeats = ((v1 >> 4) & 7) + 1;
+ m_mode = (v3 >> 6) & 3;
+ m_stop_after = (v1 & 0x80) != 0;
+
+ m_cur_segment = 0;
+ m_cur_repeat = 0;
+
+ if(!m_apos) {
+ m_zero_count = 40*128*m_segments*m_repeats;
+ m_segments = 0;
+ m_repeats = 0;
return;
}
- } else if(dg->stop_after == 1) {
- dg->bpos = 0xffff;
- dg->zero_count = 81920;
- dg->stop_after = 2;
- dg->cur_segment = 0;
- dg->cur_repeat = 0;
- dg->segments = 0;
- dg->repeats = 0;
+ } else if(m_stop_after == 1) {
+ m_bpos = 0xffff;
+ m_zero_count = 81920;
+ m_stop_after = 2;
+ m_cur_segment = 0;
+ m_cur_repeat = 0;
+ m_segments = 0;
+ m_repeats = 0;
} else {
- dg->stop_after = 0;
- digitalker_set_intr(dg, 1);
+ m_stop_after = 0;
+ digitalker_set_intr(1);
}
}
- switch(dg->mode) {
- case 0: digitalker_step_mode_0(dg); break;
- case 1: digitalker_step_mode_1(dg); break;
- case 2: digitalker_step_mode_2(dg); break;
- case 3: digitalker_step_mode_3(dg); break;
+ switch(m_mode) {
+ case 0: digitalker_step_mode_0(); break;
+ case 1: digitalker_step_mode_1(); break;
+ case 2: digitalker_step_mode_2(); break;
+ case 3: digitalker_step_mode_3(); break;
}
- if(!dg->zero_count)
- dg->dac_index = 0;
+ if(!m_zero_count)
+ m_dac_index = 0;
}
-static STREAM_UPDATE(digitalker_update)
+
+//-------------------------------------------------
+// sound_stream_update - handle a stream update
+//-------------------------------------------------
+
+void digitalker_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- digitalker *dg = (digitalker *)param;
stream_sample_t *sout = outputs[0];
int cpos = 0;
while(cpos != samples) {
- if(dg->zero_count == 0 && dg->dac_index == 128)
- digitalker_step(dg);
+ if(m_zero_count == 0 && m_dac_index == 128)
+ digitalker_step();
- if(dg->zero_count) {
+ if(m_zero_count) {
int n = samples - cpos;
int i;
- if(n > dg->zero_count)
- n = dg->zero_count;
+ if(n > m_zero_count)
+ n = m_zero_count;
for(i=0; i != n; i++)
sout[cpos++] = 0;
- dg->zero_count -= n;
+ m_zero_count -= n;
- } else if(dg->dac_index != 128) {
- while(cpos != samples && dg->dac_index != 128) {
- short v = dg->dac[dg->dac_index];
- int pp = dg->pitch_pos;
- while(cpos != samples && pp != dg->pitch) {
+ } else if(m_dac_index != 128) {
+ while(cpos != samples && m_dac_index != 128) {
+ short v = m_dac[m_dac_index];
+ int pp = m_pitch_pos;
+ while(cpos != samples && pp != m_pitch) {
sout[cpos++] = v;
pp++;
}
- if(pp == dg->pitch) {
+ if(pp == m_pitch) {
pp = 0;
- dg->dac_index++;
+ m_dac_index++;
}
- dg->pitch_pos = pp;
+ m_pitch_pos = pp;
}
} else {
@@ -579,151 +581,111 @@ static STREAM_UPDATE(digitalker_update)
}
}
-static void digitalker_cs_w(digitalker *dg, int line)
+void digitalker_device::digitalker_cs_w(int line)
{
UINT8 cs = line == ASSERT_LINE ? 1 : 0;
- if(cs == dg->cs)
+ if(cs == m_cs)
return;
- dg->cs = cs;
+ m_cs = cs;
if(cs)
return;
- if(!dg->wr) {
- if(dg->cms)
- digitalker_set_intr(dg, 1);
+ if(!m_wr) {
+ if(m_cms)
+ digitalker_set_intr(1);
else
- digitalker_start_command(dg, dg->data);
+ digitalker_start_command(m_data);
}
}
-static void digitalker_cms_w(digitalker *dg, int line)
+void digitalker_device::digitalker_cms_w(int line)
{
- dg->cms = line == ASSERT_LINE ? 1 : 0;
+ m_cms = line == ASSERT_LINE ? 1 : 0;
}
-static void digitalker_wr_w(digitalker *dg, int line)
+void digitalker_device::digitalker_wr_w(int line)
{
UINT8 wr = line == ASSERT_LINE ? 1 : 0;
- if(wr == dg->wr)
+ if(wr == m_wr)
return;
- dg->wr = wr;
- if(wr || dg->cs)
+ m_wr = wr;
+ if(wr || m_cs)
return;
- if(dg->cms)
- digitalker_set_intr(dg, 1);
+ if(m_cms)
+ digitalker_set_intr(1);
else
- digitalker_start_command(dg, dg->data);
+ digitalker_start_command(m_data);
}
-static int digitalker_intr_r(digitalker *dg)
+int digitalker_device::digitalker_intr_r()
{
- return dg->intr ? ASSERT_LINE : CLEAR_LINE;
+ return m_intr ? ASSERT_LINE : CLEAR_LINE;
}
-static void digitalker_register_for_save(digitalker *dg)
+void digitalker_device::digitalker_register_for_save()
{
- dg->device->save_item(NAME(dg->data));
- dg->device->save_item(NAME(dg->cs));
- dg->device->save_item(NAME(dg->cms));
- dg->device->save_item(NAME(dg->wr));
- dg->device->save_item(NAME(dg->intr));
- dg->device->save_item(NAME(dg->bpos));
- dg->device->save_item(NAME(dg->apos));
- dg->device->save_item(NAME(dg->mode));
- dg->device->save_item(NAME(dg->cur_segment));
- dg->device->save_item(NAME(dg->cur_repeat));
- dg->device->save_item(NAME(dg->segments));
- dg->device->save_item(NAME(dg->repeats));
- dg->device->save_item(NAME(dg->prev_pitch));
- dg->device->save_item(NAME(dg->pitch));
- dg->device->save_item(NAME(dg->pitch_pos));
- dg->device->save_item(NAME(dg->stop_after));
- dg->device->save_item(NAME(dg->cur_dac));
- dg->device->save_item(NAME(dg->cur_bits));
- dg->device->save_item(NAME(dg->zero_count));
- dg->device->save_item(NAME(dg->dac_index));
- dg->device->save_item(NAME(dg->dac));
+ save_item(NAME(m_data));
+ save_item(NAME(m_cs));
+ save_item(NAME(m_cms));
+ save_item(NAME(m_wr));
+ save_item(NAME(m_intr));
+ save_item(NAME(m_bpos));
+ save_item(NAME(m_apos));
+ save_item(NAME(m_mode));
+ save_item(NAME(m_cur_segment));
+ save_item(NAME(m_cur_repeat));
+ save_item(NAME(m_segments));
+ save_item(NAME(m_repeats));
+ save_item(NAME(m_prev_pitch));
+ save_item(NAME(m_pitch));
+ save_item(NAME(m_pitch_pos));
+ save_item(NAME(m_stop_after));
+ save_item(NAME(m_cur_dac));
+ save_item(NAME(m_cur_bits));
+ save_item(NAME(m_zero_count));
+ save_item(NAME(m_dac_index));
+ save_item(NAME(m_dac));
}
-static DEVICE_START(digitalker)
-{
- digitalker *dg = get_safe_token(device);
- dg->device = device;
- dg->rom = device->machine().root_device().memregion(device->tag())->base();
- dg->stream = device->machine().sound().stream_alloc(*device, 0, 1, device->clock()/4, dg, digitalker_update);
- dg->dac_index = 128;
- dg->data = 0xff;
- dg->cs = dg->cms = dg->wr = 1;
- dg->bpos = 0xffff;
- digitalker_set_intr(dg, 1);
-
- digitalker_register_for_save(dg);
-}
-
-void digitalker_0_cs_w(device_t *device, int line)
-{
- digitalker *dg = get_safe_token(device);
- digitalker_cs_w(dg, line);
-}
-void digitalker_0_cms_w(device_t *device, int line)
-{
- digitalker *dg = get_safe_token(device);
- digitalker_cms_w(dg, line);
-}
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
-void digitalker_0_wr_w(device_t *device, int line)
+void digitalker_device::device_start()
{
- digitalker *dg = get_safe_token(device);
- digitalker_wr_w(dg, line);
+ m_rom = machine().root_device().memregion(tag())->base();
+ m_stream = stream_alloc(0, 1, clock()/4);
+ m_dac_index = 128;
+ m_data = 0xff;
+ m_cs = m_cms = m_wr = 1;
+ m_bpos = 0xffff;
+ digitalker_set_intr(1);
+
+ digitalker_register_for_save();
}
-int digitalker_0_intr_r(device_t *device)
+void digitalker_device::digitalker_0_cs_w(int line)
{
- digitalker *dg = get_safe_token(device);
- return digitalker_intr_r(dg);
+ digitalker_cs_w(line);
}
-WRITE8_DEVICE_HANDLER( digitalker_data_w )
+void digitalker_device::digitalker_0_cms_w(int line)
{
- digitalker *dg = get_safe_token(device);
- dg->data = data;
+ digitalker_cms_w(line);
}
-
-const device_type DIGITALKER = &device_creator<digitalker_device>;
-
-digitalker_device::digitalker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, DIGITALKER, "Digitalker", tag, owner, clock),
- device_sound_interface(mconfig, *this)
+void digitalker_device::digitalker_0_wr_w(int line)
{
- m_token = global_alloc_clear(digitalker);
+ digitalker_wr_w(line);
}
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void digitalker_device::device_config_complete()
+int digitalker_device::digitalker_0_intr_r()
{
+ return digitalker_intr_r();
}
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void digitalker_device::device_start()
+WRITE8_MEMBER( digitalker_device::digitalker_data_w )
{
- DEVICE_START_NAME( digitalker )(this);
+ m_data = data;
}
-//-------------------------------------------------
-// sound_stream_update - handle a stream update
-//-------------------------------------------------
-
-void digitalker_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
-{
- // should never get here
- fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
-}
diff --git a/src/emu/sound/digitalk.h b/src/emu/sound/digitalk.h
index b8373355cb0..d293fabb9a9 100644
--- a/src/emu/sound/digitalk.h
+++ b/src/emu/sound/digitalk.h
@@ -1,33 +1,96 @@
#ifndef _DIGITALKER_H_
#define _DIGITALKER_H_
-#include "devlegcy.h"
-void digitalker_0_cs_w(device_t *device, int line);
-void digitalker_0_cms_w(device_t *device, int line);
-void digitalker_0_wr_w(device_t *device, int line);
-int digitalker_0_intr_r(device_t *device);
-DECLARE_WRITE8_DEVICE_HANDLER(digitalker_data_w);
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
+
+#define MCFG_DIGITALKER_ADD(_tag, _clock) \
+ MCFG_DEVICE_ADD(_tag, DIGITALKER, _clock)
+#define MCFG_DIGITALKER_REPLACE(_tag, _clock) \
+ MCFG_DEVICE_REPLACE(_tag, DIGITALKER, _clock)
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> digitalker_device
class digitalker_device : public device_t,
- public device_sound_interface
+ public device_sound_interface
{
public:
digitalker_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~digitalker_device() { global_free(m_token); }
+ ~digitalker_device() { }
+
+ void digitalker_0_cs_w(int line);
+ void digitalker_0_cms_w(int line);
+ void digitalker_0_wr_w(int line);
+ int digitalker_0_intr_r();
- // access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
- virtual void device_config_complete();
virtual void device_start();
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
+
+public:
+ DECLARE_WRITE8_MEMBER(digitalker_data_w);
+
private:
- // internal state
- void *m_token;
+ void digitalker_write(UINT8 *adr, UINT8 vol, INT8 dac);
+ UINT8 digitalker_pitch_next(UINT8 val, UINT8 prev, int step);
+ void digitalker_set_intr(UINT8 intr);
+ void digitalker_start_command(UINT8 cmd);
+ void digitalker_step_mode_0();
+ void digitalker_step_mode_1();
+ void digitalker_step_mode_2();
+ void digitalker_step_mode_3();
+ void digitalker_step();
+ void digitalker_cs_w(int line);
+ void digitalker_cms_w(int line);
+ void digitalker_wr_w(int line);
+ int digitalker_intr_r();
+ void digitalker_register_for_save();
+
+private:
+ const UINT8 *m_rom;
+ sound_stream *m_stream;
+
+ // Port/lines state
+ UINT8 m_data;
+ UINT8 m_cs;
+ UINT8 m_cms;
+ UINT8 m_wr;
+ UINT8 m_intr;
+
+ // Current decoding state
+ UINT16 m_bpos;
+ UINT16 m_apos;
+
+ UINT8 m_mode;
+ UINT8 m_cur_segment;
+ UINT8 m_cur_repeat;
+ UINT8 m_segments;
+ UINT8 m_repeats;
+
+ UINT8 m_prev_pitch;
+ UINT8 m_pitch;
+ UINT8 m_pitch_pos;
+
+ UINT8 m_stop_after;
+ UINT8 m_cur_dac;
+ UINT8 m_cur_bits;
+
+ // Zero-range size
+ UINT32 m_zero_count; // 0 for done
+
+ // Waveform and current index in it
+ UINT8 m_dac_index; // 128 for done
+ INT16 m_dac[128];
};
extern const device_type DIGITALKER;
diff --git a/src/emu/sound/n63701x.c b/src/emu/sound/n63701x.c
index 276c5907282..3b4acf8dc61 100644
--- a/src/emu/sound/n63701x.c
+++ b/src/emu/sound/n63701x.c
@@ -17,25 +17,6 @@ silence compression: '00 nn' must be replaced by nn+1 times '80'.
#include "n63701x.h"
-struct voice
-{
- int select;
- int playing;
- int base_addr;
- int position;
- int volume;
- int silence_counter;
-};
-
-
-struct namco_63701x
-{
- voice voices[2];
- sound_stream * stream; /* channel assigned by the mixer */
- UINT8 *rom; /* pointer to sample ROM */
-};
-
-
/* volume control has three resistors: 22000, 10000 and 3300 Ohm.
22000 is always enabled, the other two can be turned off.
Since 0x00 and 0xff samples have special meaning, the available range is
@@ -43,29 +24,47 @@ struct namco_63701x
inside 16 bits without overflowing.
*/
static const int vol_table[4] = { 26, 84, 200, 258 };
+
+// device type definition
+const device_type NAMCO_63701X = &device_creator<namco_63701x_device>;
-INLINE namco_63701x *get_safe_token(device_t *device)
+namco_63701x_device::namco_63701x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, NAMCO_63701X, "Namco 63701X", tag, owner, clock),
+ device_sound_interface(mconfig, *this),
+ m_stream(NULL),
+ m_rom(NULL)
{
- assert(device != NULL);
- assert(device->type() == NAMCO_63701X);
- return (namco_63701x *)downcast<namco_63701x_device *>(device)->token();
}
-static STREAM_UPDATE( namco_63701x_update )
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void namco_63701x_device::device_start()
+{
+ m_rom = *region();
+ m_stream = stream_alloc(0, 2, clock()/1000);
+}
+
+
+//-------------------------------------------------
+// sound_stream_update - handle a stream update
+//-------------------------------------------------
+
+void namco_63701x_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- namco_63701x *chip = (namco_63701x *)param;
int ch;
for (ch = 0;ch < 2;ch++)
{
stream_sample_t *buf = outputs[ch];
- voice *v = &chip->voices[ch];
+ voice_63701x *v = &m_voices[ch];
if (v->playing)
{
- UINT8 *base = chip->rom + v->base_addr;
+ UINT8 *base = m_rom + v->base_addr;
int pos = v->position;
int vol = vol_table[v->volume];
int p;
@@ -107,24 +106,13 @@ static STREAM_UPDATE( namco_63701x_update )
}
-static DEVICE_START( namco_63701x )
-{
- namco_63701x *chip = get_safe_token(device);
-
- chip->rom = *device->region();
-
- chip->stream = device->machine().sound().stream_alloc(*device, 0, 2, device->clock()/1000, chip, namco_63701x_update);
-}
-
-
-WRITE8_DEVICE_HANDLER( namco_63701x_w )
+WRITE8_MEMBER( namco_63701x_device::namco_63701x_w )
{
- namco_63701x *chip = get_safe_token(device);
int ch = offset / 2;
if (offset & 1)
- chip->voices[ch].select = data;
+ m_voices[ch].select = data;
else
{
/*
@@ -133,60 +121,23 @@ WRITE8_DEVICE_HANDLER( namco_63701x_w )
after the continue counter reaches 0. Either we shouldn't stop
the sample, or genpeitd is returning to the title screen too soon.
*/
- if (chip->voices[ch].select & 0x1f)
+ if (m_voices[ch].select & 0x1f)
{
int rom_offs;
/* update the streams */
- chip->stream->update();
+ m_stream->update();
- chip->voices[ch].playing = 1;
- chip->voices[ch].base_addr = 0x10000 * ((chip->voices[ch].select & 0xe0) >> 5);
- rom_offs = chip->voices[ch].base_addr + 2 * ((chip->voices[ch].select & 0x1f) - 1);
- chip->voices[ch].position = (chip->rom[rom_offs] << 8) + chip->rom[rom_offs+1];
+ m_voices[ch].playing = 1;
+ m_voices[ch].base_addr = 0x10000 * ((m_voices[ch].select & 0xe0) >> 5);
+ rom_offs = m_voices[ch].base_addr + 2 * ((m_voices[ch].select & 0x1f) - 1);
+ m_voices[ch].position = (m_rom[rom_offs] << 8) + m_rom[rom_offs+1];
/* bits 6-7 = volume */
- chip->voices[ch].volume = data >> 6;
+ m_voices[ch].volume = data >> 6;
/* bits 0-5 = counter to indicate new sample start? we don't use them */
- chip->voices[ch].silence_counter = 0;
+ m_voices[ch].silence_counter = 0;
}
}
}
-const device_type NAMCO_63701X = &device_creator<namco_63701x_device>;
-
-namco_63701x_device::namco_63701x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, NAMCO_63701X, "Namco 63701X", tag, owner, clock),
- device_sound_interface(mconfig, *this)
-{
- m_token = global_alloc_clear(namco_63701x);
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void namco_63701x_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void namco_63701x_device::device_start()
-{
- DEVICE_START_NAME( namco_63701x )(this);
-}
-
-//-------------------------------------------------
-// sound_stream_update - handle a stream update
-//-------------------------------------------------
-
-void namco_63701x_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
-{
- // should never get here
- fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
-}
diff --git a/src/emu/sound/n63701x.h b/src/emu/sound/n63701x.h
index 87bda1672f4..447ea946186 100644
--- a/src/emu/sound/n63701x.h
+++ b/src/emu/sound/n63701x.h
@@ -3,29 +3,54 @@
#ifndef __N63701X_H__
#define __N63701X_H__
-#include "devlegcy.h"
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
-DECLARE_WRITE8_DEVICE_HANDLER( namco_63701x_w );
+#define MCFG_NAMCO_63701X_ADD(_tag, _clock) \
+ MCFG_DEVICE_ADD(_tag, NAMCO_63701X, _clock)
+#define MCFG_NAMCO_63701X_REPLACE(_tag, _clock) \
+ MCFG_DEVICE_REPLACE(_tag, NAMCO_63701X, _clock)
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+struct voice_63701x
+{
+ int select;
+ int playing;
+ int base_addr;
+ int position;
+ int volume;
+ int silence_counter;
+};
+
+
+// ======================> namco_63701x_device
class namco_63701x_device : public device_t,
- public device_sound_interface
+ public device_sound_interface
{
public:
namco_63701x_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~namco_63701x_device() { global_free(m_token); }
+ ~namco_63701x_device() { }
- // access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
- virtual void device_config_complete();
virtual void device_start();
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
+
+public:
+ DECLARE_WRITE8_MEMBER(namco_63701x_w);
+
private:
- // internal state
- void *m_token;
+ voice_63701x m_voices[2];
+ sound_stream *m_stream; /* channel assigned by the mixer */
+ UINT8 *m_rom; /* pointer to sample ROM */
};
extern const device_type NAMCO_63701X;
diff --git a/src/emu/sound/tiaintf.c b/src/emu/sound/tiaintf.c
index a95d173c643..2b1fe9963a2 100644
--- a/src/emu/sound/tiaintf.c
+++ b/src/emu/sound/tiaintf.c
@@ -2,68 +2,26 @@
#include "tiaintf.h"
#include "tiasound.h"
-struct tia_state
-{
- sound_stream * channel;
- void *chip;
-};
-
-INLINE tia_state *get_safe_token(device_t *device)
-{
- assert(device != NULL);
- assert(device->type() == TIA);
- return (tia_state *)downcast<tia_device *>(device)->token();
-}
-
-
-static STREAM_UPDATE( tia_update )
-{
- tia_state *info = (tia_state *)param;
- tia_process(info->chip, outputs[0], samples);
-}
-
-
-static DEVICE_START( tia )
-{
- tia_state *info = get_safe_token(device);
-
- info->channel = device->machine().sound().stream_alloc(*device, 0, 1, device->clock(), info, tia_update);
+// device type definition
+const device_type TIA = &device_creator<tia_device>;
- info->chip = tia_sound_init(device->clock(), device->clock(), 16);
- assert_always(info->chip != NULL, "Error creating TIA chip");
-}
-static DEVICE_STOP( tia )
-{
- tia_state *info = get_safe_token(device);
- tia_sound_free(info->chip);
-}
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
-WRITE8_DEVICE_HANDLER( tia_sound_w )
-{
- tia_state *info = get_safe_token(device);
- info->channel->update();
- tia_write(info->chip, offset, data);
-}
-
-const device_type TIA = &device_creator<tia_device>;
+//-------------------------------------------------
+// tia_device - constructor
+//-------------------------------------------------
tia_device::tia_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, TIA, "TIA", tag, owner, clock),
- device_sound_interface(mconfig, *this)
+ device_sound_interface(mconfig, *this),
+ m_channel(NULL),
+ m_chip(NULL)
{
- m_token = global_alloc_clear(tia_state);
}
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void tia_device::device_config_complete()
-{
-}
//-------------------------------------------------
// device_start - device-specific startup
@@ -71,24 +29,34 @@ void tia_device::device_config_complete()
void tia_device::device_start()
{
- DEVICE_START_NAME( tia )(this);
+ m_channel = stream_alloc(0, 1, clock());
+ m_chip = tia_sound_init(clock(), clock(), 16);
+ assert_always(m_chip != NULL, "Error creating TIA chip");
}
+
//-------------------------------------------------
// device_stop - device-specific stop
//-------------------------------------------------
void tia_device::device_stop()
{
- DEVICE_STOP_NAME( tia )(this);
+ tia_sound_free(m_chip);
}
+
//-------------------------------------------------
// sound_stream_update - handle a stream update
//-------------------------------------------------
void tia_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- // should never get here
- fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
+ tia_process(m_chip, outputs[0], samples);
+}
+
+
+WRITE8_MEMBER( tia_device::tia_sound_w )
+{
+ m_channel->update();
+ tia_write(m_chip, offset, data);
}
diff --git a/src/emu/sound/tiaintf.h b/src/emu/sound/tiaintf.h
index 567ec6fa778..89ef8abe527 100644
--- a/src/emu/sound/tiaintf.h
+++ b/src/emu/sound/tiaintf.h
@@ -3,30 +3,43 @@
#ifndef __TIAINTF_H__
#define __TIAINTF_H__
-#include "devlegcy.h"
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
-DECLARE_WRITE8_DEVICE_HANDLER( tia_sound_w );
+#define MCFG_SOUND_TIA_ADD(_tag, _clock) \
+ MCFG_DEVICE_ADD(_tag, TIA, _clock)
+#define MCFG_SOUND_TIA_REPLACE(_tag, _clock) \
+ MCFG_DEVICE_REPLACE(_tag, TIA, _clock)
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> tia_device
class tia_device : public device_t,
- public device_sound_interface
+ public device_sound_interface
{
public:
tia_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~tia_device() { global_free(m_token); }
+ ~tia_device() { }
- // access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
- virtual void device_config_complete();
virtual void device_start();
virtual void device_stop();
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
+
+public:
+ DECLARE_WRITE8_MEMBER( tia_sound_w );
+
private:
- // internal state
- void *m_token;
+ sound_stream *m_channel;
+ void *m_chip;
};
extern const device_type TIA;
diff --git a/src/emu/sound/x1_010.c b/src/emu/sound/x1_010.c
index 29d6b27d26f..6d150da2b56 100644
--- a/src/emu/sound/x1_010.c
+++ b/src/emu/sound/x1_010.c
@@ -51,7 +51,6 @@ Registers:
#include "emu.h"
#include "x1_010.h"
-
#define VERBOSE_SOUND 0
#define VERBOSE_REGISTER_WRITE 0
#define VERBOSE_REGISTER_READ 0
@@ -60,11 +59,9 @@ Registers:
#define LOG_REGISTER_WRITE(x) do { if (VERBOSE_REGISTER_WRITE) logerror x; } while (0)
#define LOG_REGISTER_READ(x) do { if (VERBOSE_REGISTER_READ) logerror x; } while (0)
-#define SETA_NUM_CHANNELS 16
-
#define FREQ_BASE_BITS 8 // Frequency fixed decimal shift bits
#define ENV_BASE_BITS 16 // wave form envelope fixed decimal shift bits
-#define VOL_BASE (2*32*256/30) // Volume base
+#define VOL_BASE (2*32*256/30) // Volume base
/* this structure defines the parameters for a channel */
struct X1_010_CHANNEL {
@@ -77,54 +74,82 @@ struct X1_010_CHANNEL {
unsigned char reserve[2];
};
-struct x1_010_state
-{
- /* Variables only used here */
- int rate; // Output sampling rate (Hz)
- sound_stream * stream; // Stream handle
- int address; // address eor data
- const UINT8 *region; // region name
- int sound_enable; // sound output enable/disable
- UINT8 reg[0x2000]; // X1-010 Register & wave form area
- UINT8 HI_WORD_BUF[0x2000]; // X1-010 16bit access ram check avoidance work
- UINT32 smp_offset[SETA_NUM_CHANNELS];
- UINT32 env_offset[SETA_NUM_CHANNELS];
-
- UINT32 base_clock;
-};
-
/* mixer tables and internal buffers */
//static short *mixer_buffer = NULL;
-INLINE x1_010_state *get_safe_token(device_t *device)
+
+// device type definition
+const device_type X1_010 = &device_creator<x1_010_device>;
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// x1_010_device - constructor
+//-------------------------------------------------
+
+x1_010_device::x1_010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+ : device_t(mconfig, X1_010, "X1-010", tag, owner, clock),
+ device_sound_interface(mconfig, *this),
+ m_rate(0),
+ m_stream(NULL),
+ m_address(0),
+ m_region(NULL),
+ m_sound_enable(0),
+ m_base_clock(0)
{
- assert(device != NULL);
- assert(device->type() == X1_010);
- return (x1_010_state *)downcast<x1_010_device *>(device)->token();
}
-/*--------------------------------------------------------------
- generate sound to the mix buffer
---------------------------------------------------------------*/
-static STREAM_UPDATE( seta_update )
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void x1_010_device::device_start()
+{
+ int i;
+ const x1_010_interface *intf = (const x1_010_interface *)static_config();
+
+ m_region = *region();
+ m_base_clock = clock();
+ m_rate = clock() / 1024;
+ m_address = intf->adr;
+
+ for( i = 0; i < SETA_NUM_CHANNELS; i++ ) {
+ m_smp_offset[i] = 0;
+ m_env_offset[i] = 0;
+ }
+ /* Print some more debug info */
+ LOG_SOUND(("masterclock = %d rate = %d\n", clock(), m_rate ));
+
+ /* get stream channels */
+ m_stream = stream_alloc(0, 2, m_rate);
+}
+
+
+//-------------------------------------------------
+// sound_stream_update - handle a stream update
+//-------------------------------------------------
+
+void x1_010_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- x1_010_state *info = (x1_010_state *)param;
X1_010_CHANNEL *reg;
int ch, i, volL, volR, freq;
register INT8 *start, *end, data;
register UINT8 *env;
register UINT32 smp_offs, smp_step, env_offs, env_step, delta;
- const UINT8 *snd1 = info->region;
+ const UINT8 *snd1 = m_region;
// mixer buffer zero clear
memset( outputs[0], 0, samples*sizeof(*outputs[0]) );
memset( outputs[1], 0, samples*sizeof(*outputs[1]) );
-// if( info->sound_enable == 0 ) return;
+// if( m_sound_enable == 0 ) return;
for( ch = 0; ch < SETA_NUM_CHANNELS; ch++ ) {
- reg = (X1_010_CHANNEL *)&(info->reg[ch*sizeof(X1_010_CHANNEL)]);
+ reg = (X1_010_CHANNEL *)&(m_reg[ch*sizeof(X1_010_CHANNEL)]);
if( (reg->status&1) != 0 ) { // Key On
stream_sample_t *bufL = outputs[0];
stream_sample_t *bufR = outputs[1];
@@ -133,12 +158,12 @@ static STREAM_UPDATE( seta_update )
end = (INT8 *)((0x100-reg->end)*0x1000+snd1);
volL = ((reg->volume>>4)&0xf)*VOL_BASE;
volR = ((reg->volume>>0)&0xf)*VOL_BASE;
- smp_offs = info->smp_offset[ch];
+ smp_offs = m_smp_offset[ch];
freq = reg->frequency&0x1f;
// Meta Fox does not write the frequency register. Ever
if( freq == 0 ) freq = 4;
- smp_step = (UINT32)((float)info->base_clock/8192.0
- *freq*(1<<FREQ_BASE_BITS)/(float)info->rate);
+ smp_step = (UINT32)((float)m_base_clock/8192.0
+ *freq*(1<<FREQ_BASE_BITS)/(float)m_rate);
if( smp_offs == 0 ) {
LOG_SOUND(( "Play sample %p - %p, channel %X volume %d:%d freq %X step %X offset %X\n",
start, end, ch, volL, volR, freq, smp_step, smp_offs ));
@@ -155,16 +180,16 @@ static STREAM_UPDATE( seta_update )
*bufR++ += (data*volR/256);
smp_offs += smp_step;
}
- info->smp_offset[ch] = smp_offs;
+ m_smp_offset[ch] = smp_offs;
} else { // Wave form
- start = (INT8 *)&(info->reg[reg->volume*128+0x1000]);
- smp_offs = info->smp_offset[ch];
+ start = (INT8 *)&(m_reg[reg->volume*128+0x1000]);
+ smp_offs = m_smp_offset[ch];
freq = (reg->pitch_hi<<8)+reg->frequency;
- smp_step = (UINT32)((float)info->base_clock/128.0/1024.0/4.0*freq*(1<<FREQ_BASE_BITS)/(float)info->rate);
+ smp_step = (UINT32)((float)m_base_clock/128.0/1024.0/4.0*freq*(1<<FREQ_BASE_BITS)/(float)m_rate);
- env = (UINT8 *)&(info->reg[reg->end*128]);
- env_offs = info->env_offset[ch];
- env_step = (UINT32)((float)info->base_clock/128.0/1024.0/4.0*reg->start*(1<<ENV_BASE_BITS)/(float)info->rate);
+ env = (UINT8 *)&(m_reg[reg->end*128]);
+ env_offs = m_env_offset[ch];
+ env_step = (UINT32)((float)m_base_clock/128.0/1024.0/4.0*reg->start*(1<<ENV_BASE_BITS)/(float)m_rate);
/* Print some more debug info */
if( smp_offs == 0 ) {
LOG_SOUND(( "Play waveform %X, channel %X volume %X freq %4X step %X offset %X\n",
@@ -187,136 +212,63 @@ static STREAM_UPDATE( seta_update )
smp_offs += smp_step;
env_offs += env_step;
}
- info->smp_offset[ch] = smp_offs;
- info->env_offset[ch] = env_offs;
+ m_smp_offset[ch] = smp_offs;
+ m_env_offset[ch] = env_offs;
}
}
}
}
-
-static DEVICE_START( x1_010 )
+void x1_010_device::seta_sound_enable_w(int data)
{
- int i;
- const x1_010_interface *intf = (const x1_010_interface *)device->static_config();
- x1_010_state *info = get_safe_token(device);
-
- info->region = *device->region();
- info->base_clock = device->clock();
- info->rate = device->clock() / 1024;
- info->address = intf->adr;
-
- for( i = 0; i < SETA_NUM_CHANNELS; i++ ) {
- info->smp_offset[i] = 0;
- info->env_offset[i] = 0;
- }
- /* Print some more debug info */
- LOG_SOUND(("masterclock = %d rate = %d\n", device->clock(), info->rate ));
-
- /* get stream channels */
- info->stream = device->machine().sound().stream_alloc(*device,0,2,info->rate,info,seta_update);
+ m_sound_enable = data;
}
-void seta_sound_enable_w(device_t *device, int data)
+//
+// Use these for 8 bit CPUs
+//
+READ8_MEMBER( x1_010_device::seta_sound_r )
{
- x1_010_state *info = get_safe_token(device);
- info->sound_enable = data;
+ offset ^= m_address;
+ return m_reg[offset];
}
-
-/* Use these for 8 bit CPUs */
-
-
-READ8_DEVICE_HANDLER( seta_sound_r )
+WRITE8_MEMBER( x1_010_device::seta_sound_w )
{
- x1_010_state *info = get_safe_token(device);
- offset ^= info->address;
- return info->reg[offset];
-}
-
-
-
-
-WRITE8_DEVICE_HANDLER( seta_sound_w )
-{
- x1_010_state *info = get_safe_token(device);
int channel, reg;
- offset ^= info->address;
+ offset ^= m_address;
channel = offset/sizeof(X1_010_CHANNEL);
reg = offset%sizeof(X1_010_CHANNEL);
if( channel < SETA_NUM_CHANNELS && reg == 0
- && (info->reg[offset]&1) == 0 && (data&1) != 0 ) {
- info->smp_offset[channel] = 0;
- info->env_offset[channel] = 0;
+ && (m_reg[offset]&1) == 0 && (data&1) != 0 ) {
+ m_smp_offset[channel] = 0;
+ m_env_offset[channel] = 0;
}
- LOG_REGISTER_WRITE(("%s: offset %6X : data %2X\n", device->machine().describe_context(), offset, data ));
- info->reg[offset] = data;
+ LOG_REGISTER_WRITE(("%s: offset %6X : data %2X\n", machine().describe_context(), offset, data ));
+ m_reg[offset] = data;
}
-
-
-/* Use these for 16 bit CPUs */
-
-READ16_DEVICE_HANDLER( seta_sound_word_r )
+//
+// Use these for 16 bit CPUs
+//
+READ16_MEMBER( x1_010_device::seta_sound_word_r )
{
- x1_010_state *info = get_safe_token(device);
UINT16 ret;
-
- ret = info->HI_WORD_BUF[offset]<<8;
- ret += (seta_sound_r( device, space, offset )&0xff);
- LOG_REGISTER_READ(( "%s: Read X1-010 Offset:%04X Data:%04X\n", device->machine().describe_context(), offset, ret ));
+ ret = m_HI_WORD_BUF[offset]<<8;
+ ret += (seta_sound_r( space, offset )&0xff);
+ LOG_REGISTER_READ(( "%s: Read X1-010 Offset:%04X Data:%04X\n", machine().describe_context(), offset, ret ));
return ret;
}
-WRITE16_DEVICE_HANDLER( seta_sound_word_w )
-{
- x1_010_state *info = get_safe_token(device);
- info->HI_WORD_BUF[offset] = (data>>8)&0xff;
- seta_sound_w( device, space, offset, data&0xff );
- LOG_REGISTER_WRITE(( "%s: Write X1-010 Offset:%04X Data:%04X\n", device->machine().describe_context(), offset, data ));
-}
-
-
-const device_type X1_010 = &device_creator<x1_010_device>;
-
-x1_010_device::x1_010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
- : device_t(mconfig, X1_010, "X1-010", tag, owner, clock),
- device_sound_interface(mconfig, *this)
-{
- m_token = global_alloc_clear(x1_010_state);
-}
-
-//-------------------------------------------------
-// device_config_complete - perform any
-// operations now that the configuration is
-// complete
-//-------------------------------------------------
-
-void x1_010_device::device_config_complete()
-{
-}
-
-//-------------------------------------------------
-// device_start - device-specific startup
-//-------------------------------------------------
-
-void x1_010_device::device_start()
-{
- DEVICE_START_NAME( x1_010 )(this);
-}
-
-//-------------------------------------------------
-// sound_stream_update - handle a stream update
-//-------------------------------------------------
-
-void x1_010_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+WRITE16_MEMBER( x1_010_device::seta_sound_word_w )
{
- // should never get here
- fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
+ m_HI_WORD_BUF[offset] = (data>>8)&0xff;
+ seta_sound_w( space, offset, data&0xff );
+ LOG_REGISTER_WRITE(( "%s: Write X1-010 Offset:%04X Data:%04X\n", machine().describe_context(), offset, data ));
}
diff --git a/src/emu/sound/x1_010.h b/src/emu/sound/x1_010.h
index 0ebd53c318c..e33cdfd3e49 100644
--- a/src/emu/sound/x1_010.h
+++ b/src/emu/sound/x1_010.h
@@ -3,42 +3,66 @@
#ifndef __X1_010_H__
#define __X1_010_H__
-#include "devlegcy.h"
+#define SETA_NUM_CHANNELS 16
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
+
+#define MCFG_X1_010_ADD(_tag, _clock) \
+ MCFG_DEVICE_ADD(_tag, X1_010, _clock)
+#define MCFG_X1_010_REPLACE(_tag, _clock) \
+ MCFG_DEVICE_REPLACE(_tag, X1_010, _clock)
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
struct x1_010_interface
{
int adr; /* address */
};
-DECLARE_READ8_DEVICE_HANDLER ( seta_sound_r );
-DECLARE_WRITE8_DEVICE_HANDLER( seta_sound_w );
-
-DECLARE_READ16_DEVICE_HANDLER ( seta_sound_word_r );
-DECLARE_WRITE16_DEVICE_HANDLER( seta_sound_word_w );
-
-void seta_sound_enable_w(device_t *device, int data);
+// ======================> x1_010_device
class x1_010_device : public device_t,
- public device_sound_interface
+ public device_sound_interface
{
public:
x1_010_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
- ~x1_010_device() { global_free(m_token); }
+ ~x1_010_device() { }
+
+ void seta_sound_enable_w(int data);
- // access to legacy token
- void *token() const { assert(m_token != NULL); return m_token; }
protected:
// device-level overrides
- virtual void device_config_complete();
virtual void device_start();
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
+
+public:
+ DECLARE_READ8_MEMBER( seta_sound_r );
+ DECLARE_WRITE8_MEMBER( seta_sound_w );
+
+ DECLARE_READ16_MEMBER( seta_sound_word_r );
+ DECLARE_WRITE16_MEMBER( seta_sound_word_w );
+
private:
- // internal state
- void *m_token;
+ int m_rate; // Output sampling rate (Hz)
+ sound_stream *m_stream; // Stream handle
+ int m_address; // address eor data
+ const UINT8 *m_region; // region name
+ int m_sound_enable; // sound output enable/disable
+ UINT8 m_reg[0x2000]; // X1-010 Register & wave form area
+ UINT8 m_HI_WORD_BUF[0x2000]; // X1-010 16bit access ram check avoidance work
+ UINT32 m_smp_offset[SETA_NUM_CHANNELS];
+ UINT32 m_env_offset[SETA_NUM_CHANNELS];
+
+ UINT32 m_base_clock;
};
extern const device_type X1_010;