diff options
author | 2024-12-13 15:11:31 +0100 | |
---|---|---|
committer | 2024-12-13 18:40:45 +0100 | |
commit | 8e5b54e6500afa2ccbbaa31102944b259181a612 (patch) | |
tree | e57afdb5561afc3587b92e8c0b966eb635c86cdb | |
parent | d62e3a328aee8ddb0ed53c47265f8f88c603072c (diff) |
ad1848: Add support for auto-calibration
-rw-r--r-- | src/devices/sound/ad1848.cpp | 22 | ||||
-rw-r--r-- | src/devices/sound/ad1848.h | 1 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/devices/sound/ad1848.cpp b/src/devices/sound/ad1848.cpp index b47e3c4a683..ac37b4cd05f 100644 --- a/src/devices/sound/ad1848.cpp +++ b/src/devices/sound/ad1848.cpp @@ -38,6 +38,7 @@ void ad1848_device::device_start() save_item(NAME(m_addr)); save_item(NAME(m_stat)); save_item(NAME(m_sam_cnt)); + save_item(NAME(m_calibration_cycles)); save_item(NAME(m_samples)); save_item(NAME(m_count)); save_item(NAME(m_play)); @@ -52,6 +53,7 @@ void ad1848_device::device_reset() m_addr = 0; m_stat = 0; m_sam_cnt = 0; + m_calibration_cycles = 0; m_samples = 0; m_play = false; m_irq = false; @@ -96,9 +98,17 @@ void ad1848_device::write(offs_t offset, uint8_t data) break; case 9: { + // auto-calibration + if (m_mce && BIT(data, 3)) + { + logerror("set auto-calibration\n"); + m_regs.init |= 0x20; + m_calibration_cycles = 384; + } + m_play = (data & 1) ? true : false; // FIXME: provide external configuration for XTAL1 (24.576 MHz) and XTAL2 (16.9344 MHz) inputs - attotime rate = m_play ? attotime::from_hz(((m_regs.dform & 1) ? 16.9344_MHz_XTAL : 24.576_MHz_XTAL) + attotime rate = (m_play || BIT(m_regs.init, 5)) ? attotime::from_hz(((m_regs.dform & 1) ? 16.9344_MHz_XTAL : 24.576_MHz_XTAL) / div_factor[(m_regs.dform >> 1) & 7]) : attotime::never; m_timer->adjust(rate, 0 , rate); m_drq_cb(m_play ? ASSERT_LINE : CLEAR_LINE); @@ -157,6 +167,16 @@ void ad1848_device::dack_w(uint8_t data) TIMER_CALLBACK_MEMBER(ad1848_device::update_tick) { + // auto-calibration + if (BIT(m_regs.init, 5)) + { + if (--m_calibration_cycles == 0) + { + logerror("calibration finished\n"); + m_regs.init &= ~0x20; + } + } + if(!m_play) return; switch(m_regs.dform >> 4) diff --git a/src/devices/sound/ad1848.h b/src/devices/sound/ad1848.h index d3ea876f0c6..934854b09dc 100644 --- a/src/devices/sound/ad1848.h +++ b/src/devices/sound/ad1848.h @@ -55,6 +55,7 @@ private: uint16_t m_count; uint32_t m_samples; uint8_t m_sam_cnt; + uint16_t m_calibration_cycles; bool m_play, m_mce, m_trd, m_irq; devcb_write_line m_irq_cb; devcb_write_line m_drq_cb; |