diff options
Diffstat (limited to 'src/devices/sound/bsmt2000.cpp')
-rw-r--r-- | src/devices/sound/bsmt2000.cpp | 77 |
1 files changed, 44 insertions, 33 deletions
diff --git a/src/devices/sound/bsmt2000.cpp b/src/devices/sound/bsmt2000.cpp index 09392661079..428009b1fc2 100644 --- a/src/devices/sound/bsmt2000.cpp +++ b/src/devices/sound/bsmt2000.cpp @@ -110,7 +110,7 @@ void bsmt2000_device::device_add_mconfig(machine_config &config) void bsmt2000_device::device_start() { - m_ready_callback.resolve(); + m_ready_callback.resolve_safe(); // create the stream; BSMT typically runs at 24MHz and writes to a DAC, so // in theory we should generate a 24MHz stream, but that's certainly overkill @@ -126,6 +126,11 @@ void bsmt2000_device::device_start() save_item(NAME(m_left_data)); save_item(NAME(m_right_data)); save_item(NAME(m_write_pending)); + + // allocate timers + m_deferred_reset = timer_alloc(FUNC(bsmt2000_device::deferred_reset), this); + m_deferred_reg_write = timer_alloc(FUNC(bsmt2000_device::deferred_reg_write), this); + m_deferred_data_write = timer_alloc(FUNC(bsmt2000_device::deferred_data_write), this); } @@ -135,41 +140,47 @@ void bsmt2000_device::device_start() void bsmt2000_device::device_reset() { - synchronize(TIMER_ID_RESET); + m_deferred_reset->adjust(attotime::zero); +} + + + +//------------------------------------------------- +// deferred_reset - +//------------------------------------------------- + +TIMER_CALLBACK_MEMBER(bsmt2000_device::deferred_reset) +{ + m_stream->update(); + m_cpu->reset(); } //------------------------------------------------- -// device_timer - handle deferred writes and -// resets as a timer callback +// deferred_reg_write - //------------------------------------------------- -void bsmt2000_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(bsmt2000_device::deferred_reg_write) { - switch (id) - { - // deferred reset - case TIMER_ID_RESET: - m_stream->update(); - m_cpu->reset(); - break; - - // deferred register write - case TIMER_ID_REG_WRITE: - m_register_select = param & 0xffff; - break; - - // deferred data write - case TIMER_ID_DATA_WRITE: - m_write_data = param & 0xffff; - if (m_write_pending) logerror("BSMT2000: Missed data\n"); - m_write_pending = true; - break; - } + m_register_select = param & 0xffff; } + +//------------------------------------------------- +// deferred_data_write - +//------------------------------------------------- + +TIMER_CALLBACK_MEMBER(bsmt2000_device::deferred_data_write) +{ + m_write_data = param & 0xffff; + if (m_write_pending) logerror("BSMT2000: Missed data\n"); + m_write_pending = true; +} + + + //------------------------------------------------- // sound_stream_update - handle update requests // for our sound stream @@ -185,10 +196,11 @@ void bsmt2000_device::sound_stream_update(sound_stream &stream, std::vector<read //------------------------------------------------- -// rom_bank_updated - the rom bank has changed +// rom_bank_pre_change - refresh the stream if the +// ROM banking changes //------------------------------------------------- -void bsmt2000_device::rom_bank_updated() +void bsmt2000_device::rom_bank_pre_change() { m_stream->update(); } @@ -211,7 +223,7 @@ uint16_t bsmt2000_device::read_status() void bsmt2000_device::write_reg(uint16_t data) { - synchronize(TIMER_ID_REG_WRITE, data); + m_deferred_reg_write->adjust(attotime::zero, data); } @@ -222,10 +234,10 @@ void bsmt2000_device::write_reg(uint16_t data) void bsmt2000_device::write_data(uint16_t data) { - synchronize(TIMER_ID_DATA_WRITE, data); + m_deferred_data_write->adjust(attotime::zero, data); // boost the interleave on a write so that the caller detects the status more accurately - machine().scheduler().boost_interleave(attotime::from_usec(1), attotime::from_usec(10)); + machine().scheduler().add_quantum(attotime::from_usec(1), attotime::from_usec(10)); } @@ -249,8 +261,7 @@ uint16_t bsmt2000_device::tms_data_r() { // also implicitly clear the write pending flag m_write_pending = false; - if (!m_ready_callback.isnull()) - m_ready_callback(); + m_ready_callback(); return m_write_data; } @@ -319,7 +330,7 @@ void bsmt2000_device::tms_right_w(uint16_t data) // on the TMS32015 //------------------------------------------------- -READ_LINE_MEMBER( bsmt2000_device::tms_write_pending_r ) +int bsmt2000_device::tms_write_pending_r() { return m_write_pending ? 1 : 0; } |