From 50be02b53ac01f64924f4aecfc5372a6d669f869 Mon Sep 17 00:00:00 2001 From: hap Date: Wed, 13 Mar 2024 13:57:00 +0100 Subject: cpc_ssa1: simplify sp0256 lrq/sby pin read, sp0256: when callbacks are used, add bg timer like sp0250 does --- src/devices/bus/cpc/cpc_ssa1.cpp | 32 +++----------------------------- src/devices/bus/cpc/cpc_ssa1.h | 24 ------------------------ src/devices/sound/sp0250.cpp | 5 ----- src/devices/sound/sp0250.h | 3 +-- src/devices/sound/sp0256.cpp | 13 +++++++++++-- src/devices/sound/sp0256.h | 2 ++ src/mame/novag/primo.cpp | 2 +- 7 files changed, 18 insertions(+), 63 deletions(-) diff --git a/src/devices/bus/cpc/cpc_ssa1.cpp b/src/devices/bus/cpc/cpc_ssa1.cpp index cfe5c88d29d..eab90d6831d 100644 --- a/src/devices/bus/cpc/cpc_ssa1.cpp +++ b/src/devices/bus/cpc/cpc_ssa1.cpp @@ -30,10 +30,10 @@ uint8_t cpc_ssa1_device::ssa1_r() { uint8_t ret = 0xff; - if(get_sby() == 0) + if(!m_sp0256_device->sby_r()) ret &= ~0x80; - if(get_lrq() != 0) + if(m_sp0256_device->lrq_r()) ret &= ~0x40; return ret; @@ -50,7 +50,7 @@ uint8_t cpc_dkspeech_device::dkspeech_r() // SBY is not connected - if(get_lrq() != 0) + if(m_sp0256_device->lrq_r()) ret &= ~0x80; return ret; @@ -61,26 +61,6 @@ void cpc_dkspeech_device::dkspeech_w(uint8_t data) m_sp0256_device->ald_w(data & 0x3f); } -void cpc_ssa1_device::lrq_cb(int state) -{ - set_lrq(state); -} - -void cpc_ssa1_device::sby_cb(int state) -{ - set_sby(state); -} - -void cpc_dkspeech_device::lrq_cb(int state) -{ - set_lrq(state); -} - -void cpc_dkspeech_device::sby_cb(int state) -{ - set_sby(state); -} - //------------------------------------------------- // Device ROM definition //------------------------------------------------- @@ -119,8 +99,6 @@ void cpc_ssa1_device::device_add_mconfig(machine_config &config) { SPEAKER(config, "mono").front_center(); SP0256(config, m_sp0256_device, XTAL(3'120'000)); - m_sp0256_device->data_request_callback().set(FUNC(cpc_ssa1_device::lrq_cb)); - m_sp0256_device->standby_callback().set(FUNC(cpc_ssa1_device::sby_cb)); m_sp0256_device->add_route(ALL_OUTPUTS, "mono", 1.00); // pass-through @@ -134,8 +112,6 @@ void cpc_dkspeech_device::device_add_mconfig(machine_config &config) { SPEAKER(config, "mono").front_center(); SP0256(config, m_sp0256_device, DERIVED_CLOCK(1, 1)); // uses the CPC's clock from pin 50 of the expansion port - m_sp0256_device->data_request_callback().set(FUNC(cpc_dkspeech_device::lrq_cb)); - m_sp0256_device->standby_callback().set(FUNC(cpc_dkspeech_device::sby_cb)); m_sp0256_device->add_route(ALL_OUTPUTS, "mono", 1.00); // pass-through @@ -153,7 +129,6 @@ void cpc_dkspeech_device::device_add_mconfig(machine_config &config) cpc_ssa1_device::cpc_ssa1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CPC_SSA1, tag, owner, clock), device_cpc_expansion_card_interface(mconfig, *this), m_slot(nullptr), m_rom(nullptr), - m_lrq(1), m_sby(0), m_sp0256_device(*this,"sp0256") { } @@ -161,7 +136,6 @@ cpc_ssa1_device::cpc_ssa1_device(const machine_config &mconfig, const char *tag, cpc_dkspeech_device::cpc_dkspeech_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CPC_DKSPEECH, tag, owner, clock), device_cpc_expansion_card_interface(mconfig, *this), m_slot(nullptr), m_rom(nullptr), - m_lrq(1), m_sby(0), m_sp0256_device(*this,"sp0256") { } diff --git a/src/devices/bus/cpc/cpc_ssa1.h b/src/devices/bus/cpc/cpc_ssa1.h index b0ebc35d9cf..9c89be6067d 100644 --- a/src/devices/bus/cpc/cpc_ssa1.h +++ b/src/devices/bus/cpc/cpc_ssa1.h @@ -56,11 +56,6 @@ public: // construction/destruction cpc_ssa1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void set_lrq(uint8_t state) { m_lrq = state; } - uint8_t get_lrq() { return m_lrq; } - void set_sby(uint8_t state) { m_sby = state; } - uint8_t get_sby() { return m_sby; } - uint8_t ssa1_r(); void ssa1_w(uint8_t data); @@ -74,15 +69,8 @@ protected: virtual void device_add_mconfig(machine_config &config) override; private: - void lrq_cb(int state); - void sby_cb(int state); - cpc_expansion_slot_device *m_slot; - uint8_t *m_rom; - uint8_t m_lrq; - uint8_t m_sby; - required_device m_sp0256_device; }; @@ -93,11 +81,6 @@ public: // construction/destruction cpc_dkspeech_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void set_lrq(uint8_t state) { m_lrq = state; } - uint8_t get_lrq() { return m_lrq; } - void set_sby(uint8_t state) { m_sby = state; } - uint8_t get_sby() { return m_sby; } - uint8_t dkspeech_r(); void dkspeech_w(uint8_t data); @@ -111,15 +94,8 @@ protected: virtual void device_add_mconfig(machine_config &config) override; private: - void lrq_cb(int state); - void sby_cb(int state); - cpc_expansion_slot_device *m_slot; - uint8_t *m_rom; - uint8_t m_lrq; - uint8_t m_sby; - required_device m_sp0256_device; }; diff --git a/src/devices/sound/sp0250.cpp b/src/devices/sound/sp0250.cpp index 73e0e6cacff..2c4384888e9 100644 --- a/src/devices/sound/sp0250.cpp +++ b/src/devices/sound/sp0250.cpp @@ -109,11 +109,6 @@ void sp0250_device::device_reset() load_values(); } -TIMER_CALLBACK_MEMBER(sp0250_device::delayed_stream_update) -{ - m_stream->update(); -} - static uint16_t sp0250_ga(uint8_t v) { return (v & 0x1f) << (v>>5); diff --git a/src/devices/sound/sp0250.h b/src/devices/sound/sp0250.h index fb463e25d5b..5dfd3742e52 100644 --- a/src/devices/sound/sp0250.h +++ b/src/devices/sound/sp0250.h @@ -23,8 +23,7 @@ protected: // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; - - TIMER_CALLBACK_MEMBER(delayed_stream_update); + TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); } private: // internal helpers diff --git a/src/devices/sound/sp0256.cpp b/src/devices/sound/sp0256.cpp index b142c3b57a7..3486f710be3 100644 --- a/src/devices/sound/sp0256.cpp +++ b/src/devices/sound/sp0256.cpp @@ -55,6 +55,7 @@ sp0256_device::sp0256_device(const machine_config &mconfig, const char *tag, dev , device_sound_interface(mconfig, *this) , m_rom(*this, DEVICE_SELF) , m_stream(nullptr) + , m_stream_timer(nullptr) , m_drq_cb(*this) , m_sby_cb(*this) , m_scratch() @@ -71,7 +72,15 @@ void sp0256_device::device_start() m_sby_cb(1); m_sby_line = 1; - m_stream = stream_alloc(0, 1, clock() / CLOCK_DIVIDER); + int sample_rate = clock() / CLOCK_DIVIDER; + m_stream = stream_alloc(0, 1, sample_rate); + + // if callbacks are used, update the stream at sample rate frequency to ensure they get picked up in a timely matter + if (!m_drq_cb.isunset() || !m_sby_cb.isunset()) + { + m_stream_timer = timer_alloc(FUNC(sp0256_device::delayed_stream_update), this); + m_stream_timer->adjust(attotime::from_hz(sample_rate), 0, attotime::from_hz(sample_rate)); + } /* -------------------------------------------------------------------- */ /* Configure our internal variables. */ @@ -79,7 +88,7 @@ void sp0256_device::device_start() m_filt.rng = 1; /* -------------------------------------------------------------------- */ - /* Allocate a scratch buffer for generating ~10kHz samples. */ + /* Allocate a scratch buffer for generating ~10kHz samples. */ /* -------------------------------------------------------------------- */ m_scratch = std::make_unique(SCBUF_SIZE); save_pointer(NAME(m_scratch), SCBUF_SIZE); diff --git a/src/devices/sound/sp0256.h b/src/devices/sound/sp0256.h index 9afc5aa2141..d1c6d7ab687 100644 --- a/src/devices/sound/sp0256.h +++ b/src/devices/sound/sp0256.h @@ -61,6 +61,7 @@ protected: // sound stream update overrides virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; + TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); } private: struct lpc12_t @@ -95,6 +96,7 @@ private: required_region_ptr m_rom; // 64K ROM. sound_stream *m_stream; // MAME core sound stream + emu_timer *m_stream_timer; // For forcing stream update when callbacks are used devcb_write_line m_drq_cb; // Data request callback devcb_write_line m_sby_cb; // Standby callback diff --git a/src/mame/novag/primo.cpp b/src/mame/novag/primo.cpp index d45e51989da..66144978c0e 100644 --- a/src/mame/novag/primo.cpp +++ b/src/mame/novag/primo.cpp @@ -385,7 +385,7 @@ void primo_state::primo(machine_config &config) screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_SVG)); screen.set_refresh_hz(60); - screen.set_size(1920/4, 606/4); + screen.set_size(1920/5, 606/5); screen.set_visarea_full(); PWM_DISPLAY(config, m_led_pwm).set_size(2, 8); -- cgit v1.2.3