diff options
Diffstat (limited to 'src/devices/sound/qs1000.cpp')
-rw-r--r-- | src/devices/sound/qs1000.cpp | 129 |
1 files changed, 46 insertions, 83 deletions
diff --git a/src/devices/sound/qs1000.cpp b/src/devices/sound/qs1000.cpp index 92943066296..b3e87b1515a 100644 --- a/src/devices/sound/qs1000.cpp +++ b/src/devices/sound/qs1000.cpp @@ -164,20 +164,19 @@ ROM_END //------------------------------------------------- // qs1000_device - constructor //------------------------------------------------- -qs1000_device::qs1000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, QS1000, tag, owner, clock), - device_sound_interface(mconfig, *this), - device_rom_interface(mconfig, *this, 24), - m_external_rom(false), - m_in_p1_cb(*this), - m_in_p2_cb(*this), - m_in_p3_cb(*this), - m_out_p1_cb(*this), - m_out_p2_cb(*this), - m_out_p3_cb(*this), - //m_serial_w_cb(*this), - m_stream(nullptr), - m_cpu(*this, "cpu") +qs1000_device::qs1000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, QS1000, tag, owner, clock), + device_sound_interface(mconfig, *this), + device_rom_interface(mconfig, *this), + m_external_rom(false), + m_in_p1_cb(*this, 0), + m_in_p2_cb(*this, 0), + m_in_p3_cb(*this, 0), + m_out_p1_cb(*this), + m_out_p2_cb(*this), + m_out_p3_cb(*this), + m_stream(nullptr), + m_cpu(*this, "cpu") { } @@ -207,15 +206,15 @@ void qs1000_device::device_add_mconfig(machine_config &config) m_cpu->port_out_cb<2>().set(FUNC(qs1000_device::p2_w)); m_cpu->port_in_cb<3>().set(FUNC(qs1000_device::p3_r)); m_cpu->port_out_cb<3>().set(FUNC(qs1000_device::p3_w)); - m_cpu->serial_rx_cb().set(FUNC(qs1000_device::data_to_i8052)); } //------------------------------------------------- -// rom_bank_updated - the rom bank has changed +// rom_bank_pre_change - refresh the stream if the +// ROM banking changes //------------------------------------------------- -void qs1000_device::rom_bank_updated() +void qs1000_device::rom_bank_pre_change() { m_stream->update(); } @@ -231,18 +230,6 @@ void qs1000_device::device_start() // gives reasonable results m_stream = stream_alloc(0, 2, clock() / 32); - // Resolve CPU port callbacks - m_in_p1_cb.resolve_safe(0); - m_in_p2_cb.resolve_safe(0); - m_in_p3_cb.resolve_safe(0); - - m_out_p1_cb.resolve_safe(); - m_out_p2_cb.resolve_safe(); - m_out_p3_cb.resolve_safe(); - - //m_serial_w_cb.resolve_safe(); - - save_item(NAME(m_serial_data_in)); save_item(NAME(m_wave_regs)); for (int i = 0; i < QS1000_CHANNELS; i++) @@ -259,27 +246,17 @@ void qs1000_device::device_start() save_item(NAME(m_channels[i].m_regs), i); save_item(NAME(m_channels[i].m_adpcm.m_signal), i); save_item(NAME(m_channels[i].m_adpcm.m_step), i); + save_item(NAME(m_channels[i].m_adpcm.m_loop_signal), i); + save_item(NAME(m_channels[i].m_adpcm.m_loop_step), i); + save_item(NAME(m_channels[i].m_adpcm.m_saved), i); } } //------------------------------------------------- -// serial_in - send data to the chip -//------------------------------------------------- -void qs1000_device::serial_in(uint8_t data) -{ - m_serial_data_in = data; - - // Signal to the CPU that data is available - m_cpu->set_input_line(MCS51_RX_LINE, ASSERT_LINE); - m_cpu->set_input_line(MCS51_RX_LINE, CLEAR_LINE); -} - - -//------------------------------------------------- // set_irq - interrupt the internal CPU //------------------------------------------------- -WRITE_LINE_MEMBER(qs1000_device::set_irq) +void qs1000_device::set_irq(int state) { // Signal to the CPU that data is available m_cpu->set_input_line(MCS51_INT1_LINE, state ? ASSERT_LINE : CLEAR_LINE); @@ -287,16 +264,6 @@ WRITE_LINE_MEMBER(qs1000_device::set_irq) //------------------------------------------------- -// data_to_i8052 - called by the 8052 core to -// receive serial data -//------------------------------------------------- -READ8_MEMBER(qs1000_device::data_to_i8052) -{ - return m_serial_data_in; -} - - -//------------------------------------------------- // device_reset - device-specific reset //------------------------------------------------- void qs1000_device::device_reset() @@ -309,18 +276,9 @@ void qs1000_device::device_reset() //------------------------------------------------- -// device_timer - handle deferred writes and -// resets as a timer callback -//------------------------------------------------- -void qs1000_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ -} - - -//------------------------------------------------- // p0_r //------------------------------------------------- -READ8_MEMBER( qs1000_device::p0_r ) +uint8_t qs1000_device::p0_r() { return 0xff; } @@ -329,7 +287,7 @@ READ8_MEMBER( qs1000_device::p0_r ) //------------------------------------------------- // p1_r //------------------------------------------------- -READ8_MEMBER( qs1000_device::p1_r ) +uint8_t qs1000_device::p1_r() { return m_in_p1_cb(0); } @@ -338,7 +296,7 @@ READ8_MEMBER( qs1000_device::p1_r ) //------------------------------------------------- // p2_r //------------------------------------------------- -READ8_MEMBER( qs1000_device::p2_r ) +uint8_t qs1000_device::p2_r() { return m_in_p2_cb(0); } @@ -347,7 +305,7 @@ READ8_MEMBER( qs1000_device::p2_r ) //------------------------------------------------- // p3_r //------------------------------------------------- -READ8_MEMBER( qs1000_device::p3_r ) +uint8_t qs1000_device::p3_r() { return m_in_p3_cb(0); } @@ -356,7 +314,7 @@ READ8_MEMBER( qs1000_device::p3_r ) //------------------------------------------------- // p0_w //------------------------------------------------- -WRITE8_MEMBER( qs1000_device::p0_w ) +void qs1000_device::p0_w(uint8_t data) { } @@ -365,7 +323,7 @@ WRITE8_MEMBER( qs1000_device::p0_w ) // p1_w //------------------------------------------------- -WRITE8_MEMBER( qs1000_device::p1_w ) +void qs1000_device::p1_w(uint8_t data) { m_out_p1_cb((offs_t)0, data); } @@ -375,7 +333,7 @@ WRITE8_MEMBER( qs1000_device::p1_w ) // p2_w //------------------------------------------------- -WRITE8_MEMBER( qs1000_device::p2_w ) +void qs1000_device::p2_w(uint8_t data) { m_out_p2_cb((offs_t)0, data); } @@ -385,7 +343,7 @@ WRITE8_MEMBER( qs1000_device::p2_w ) // p3_w //------------------------------------------------- -WRITE8_MEMBER( qs1000_device::p3_w ) +void qs1000_device::p3_w(uint8_t data) { m_out_p3_cb((offs_t)0, data); } @@ -395,7 +353,7 @@ WRITE8_MEMBER( qs1000_device::p3_w ) // wave_w - process writes to wavetable engine //------------------------------------------------- -WRITE8_MEMBER( qs1000_device::wave_w ) +void qs1000_device::wave_w(offs_t offset, uint8_t data) { m_stream->update(); @@ -465,12 +423,8 @@ WRITE8_MEMBER( qs1000_device::wave_w ) //------------------------------------------------- // sound_stream_update - //------------------------------------------------- -void qs1000_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) +void qs1000_device::sound_stream_update(sound_stream &stream) { - // Rset the output stream - memset(outputs[0], 0x0, samples * sizeof(*outputs[0])); - memset(outputs[1], 0x0, samples * sizeof(*outputs[1])); - // Iterate over voices and accumulate sample data for (auto & chan : m_channels) { @@ -482,7 +436,7 @@ void qs1000_device::sound_stream_update(sound_stream &stream, stream_sample_t ** { if (chan.m_flags & QS1000_ADPCM) { - for (int samp = 0; samp < samples; samp++) + for (int samp = 0; samp < stream.samples(); samp++) { if (chan.m_addr >= chan.m_loop_end) { @@ -504,8 +458,17 @@ void qs1000_device::sound_stream_update(sound_stream &stream, stream_sample_t ** { chan.m_adpcm_addr++; - if (chan.m_start + chan.m_adpcm_addr >= chan.m_loop_end) + if (chan.m_start + chan.m_adpcm_addr >= chan.m_loop_end) + { chan.m_adpcm_addr = chan.m_loop_start - chan.m_start; +#if 0 // Looping disabled until envelopes work + chan.m_adpcm.restore(); + } + if (chan.m_start + chan.m_adpcm_addr == chan.m_loop_start) + { + chan.m_adpcm.save(); +#endif + } uint8_t data = read_byte(chan.m_start + (chan.m_adpcm_addr >> 1)); uint8_t nibble = (chan.m_adpcm_addr & 1 ? data : data >> 4) & 0xf; @@ -517,13 +480,13 @@ void qs1000_device::sound_stream_update(sound_stream &stream, stream_sample_t ** chan.m_addr = (chan.m_addr + (chan.m_acc >> 18)) & QS1000_ADDRESS_MASK; chan.m_acc &= ((1 << 18) - 1); - outputs[0][samp] += (result * 4 * lvol * vol) >> 12; - outputs[1][samp] += (result * 4 * rvol * vol) >> 12; + stream.add_int(0, samp, result * 4 * lvol * vol, 32768 << 12); + stream.add_int(1, samp, result * 4 * rvol * vol, 32768 << 12); } } else { - for (int samp = 0; samp < samples; samp++) + for (int samp = 0; samp < stream.samples(); samp++) { if (chan.m_addr >= chan.m_loop_end) { @@ -546,8 +509,8 @@ void qs1000_device::sound_stream_update(sound_stream &stream, stream_sample_t ** chan.m_addr = (chan.m_addr + (chan.m_acc >> 18)) & QS1000_ADDRESS_MASK; chan.m_acc &= ((1 << 18) - 1); - outputs[0][samp] += (result * lvol * vol) >> 12; - outputs[1][samp] += (result * rvol * vol) >> 12; + stream.add_int(0, samp, result * lvol * vol, 32768 << 12); + stream.add_int(1, samp, result * rvol * vol, 32768 << 12); } } } |