cpc_ssa1: simplify sp0256 lrq/sby pin read,

sp0256: when callbacks are used, add bg timer like sp0250 does
This commit is contained in:
hap 2024-03-13 13:57:00 +01:00
parent a723b9003a
commit 50be02b53a
7 changed files with 18 additions and 63 deletions

View File

@ -30,10 +30,10 @@ uint8_t cpc_ssa1_device::ssa1_r()
{ {
uint8_t ret = 0xff; uint8_t ret = 0xff;
if(get_sby() == 0) if(!m_sp0256_device->sby_r())
ret &= ~0x80; ret &= ~0x80;
if(get_lrq() != 0) if(m_sp0256_device->lrq_r())
ret &= ~0x40; ret &= ~0x40;
return ret; return ret;
@ -50,7 +50,7 @@ uint8_t cpc_dkspeech_device::dkspeech_r()
// SBY is not connected // SBY is not connected
if(get_lrq() != 0) if(m_sp0256_device->lrq_r())
ret &= ~0x80; ret &= ~0x80;
return ret; return ret;
@ -61,26 +61,6 @@ void cpc_dkspeech_device::dkspeech_w(uint8_t data)
m_sp0256_device->ald_w(data & 0x3f); 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 // Device ROM definition
//------------------------------------------------- //-------------------------------------------------
@ -119,8 +99,6 @@ void cpc_ssa1_device::device_add_mconfig(machine_config &config)
{ {
SPEAKER(config, "mono").front_center(); SPEAKER(config, "mono").front_center();
SP0256(config, m_sp0256_device, XTAL(3'120'000)); 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); m_sp0256_device->add_route(ALL_OUTPUTS, "mono", 1.00);
// pass-through // pass-through
@ -134,8 +112,6 @@ void cpc_dkspeech_device::device_add_mconfig(machine_config &config)
{ {
SPEAKER(config, "mono").front_center(); 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 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); m_sp0256_device->add_route(ALL_OUTPUTS, "mono", 1.00);
// pass-through // 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) : 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_t(mconfig, CPC_SSA1, tag, owner, clock),
device_cpc_expansion_card_interface(mconfig, *this), m_slot(nullptr), m_rom(nullptr), device_cpc_expansion_card_interface(mconfig, *this), m_slot(nullptr), m_rom(nullptr),
m_lrq(1), m_sby(0),
m_sp0256_device(*this,"sp0256") 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) : 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_t(mconfig, CPC_DKSPEECH, tag, owner, clock),
device_cpc_expansion_card_interface(mconfig, *this), m_slot(nullptr), m_rom(nullptr), device_cpc_expansion_card_interface(mconfig, *this), m_slot(nullptr), m_rom(nullptr),
m_lrq(1), m_sby(0),
m_sp0256_device(*this,"sp0256") m_sp0256_device(*this,"sp0256")
{ {
} }

View File

@ -56,11 +56,6 @@ public:
// construction/destruction // construction/destruction
cpc_ssa1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 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(); uint8_t ssa1_r();
void ssa1_w(uint8_t data); void ssa1_w(uint8_t data);
@ -74,15 +69,8 @@ protected:
virtual void device_add_mconfig(machine_config &config) override; virtual void device_add_mconfig(machine_config &config) override;
private: private:
void lrq_cb(int state);
void sby_cb(int state);
cpc_expansion_slot_device *m_slot; cpc_expansion_slot_device *m_slot;
uint8_t *m_rom; uint8_t *m_rom;
uint8_t m_lrq;
uint8_t m_sby;
required_device<sp0256_device> m_sp0256_device; required_device<sp0256_device> m_sp0256_device;
}; };
@ -93,11 +81,6 @@ public:
// construction/destruction // construction/destruction
cpc_dkspeech_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 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(); uint8_t dkspeech_r();
void dkspeech_w(uint8_t data); void dkspeech_w(uint8_t data);
@ -111,15 +94,8 @@ protected:
virtual void device_add_mconfig(machine_config &config) override; virtual void device_add_mconfig(machine_config &config) override;
private: private:
void lrq_cb(int state);
void sby_cb(int state);
cpc_expansion_slot_device *m_slot; cpc_expansion_slot_device *m_slot;
uint8_t *m_rom; uint8_t *m_rom;
uint8_t m_lrq;
uint8_t m_sby;
required_device<sp0256_device> m_sp0256_device; required_device<sp0256_device> m_sp0256_device;
}; };

View File

@ -109,11 +109,6 @@ void sp0250_device::device_reset()
load_values(); load_values();
} }
TIMER_CALLBACK_MEMBER(sp0250_device::delayed_stream_update)
{
m_stream->update();
}
static uint16_t sp0250_ga(uint8_t v) static uint16_t sp0250_ga(uint8_t v)
{ {
return (v & 0x1f) << (v>>5); return (v & 0x1f) << (v>>5);

View File

@ -23,8 +23,7 @@ protected:
// sound stream update overrides // sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); }
TIMER_CALLBACK_MEMBER(delayed_stream_update);
private: private:
// internal helpers // internal helpers

View File

@ -55,6 +55,7 @@ sp0256_device::sp0256_device(const machine_config &mconfig, const char *tag, dev
, device_sound_interface(mconfig, *this) , device_sound_interface(mconfig, *this)
, m_rom(*this, DEVICE_SELF) , m_rom(*this, DEVICE_SELF)
, m_stream(nullptr) , m_stream(nullptr)
, m_stream_timer(nullptr)
, m_drq_cb(*this) , m_drq_cb(*this)
, m_sby_cb(*this) , m_sby_cb(*this)
, m_scratch() , m_scratch()
@ -71,7 +72,15 @@ void sp0256_device::device_start()
m_sby_cb(1); m_sby_cb(1);
m_sby_line = 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. */ /* Configure our internal variables. */

View File

@ -61,6 +61,7 @@ protected:
// sound stream update overrides // sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); }
private: private:
struct lpc12_t struct lpc12_t
@ -95,6 +96,7 @@ private:
required_region_ptr<uint8_t> m_rom; // 64K ROM. required_region_ptr<uint8_t> m_rom; // 64K ROM.
sound_stream *m_stream; // MAME core sound stream 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_drq_cb; // Data request callback
devcb_write_line m_sby_cb; // Standby callback devcb_write_line m_sby_cb; // Standby callback

View File

@ -385,7 +385,7 @@ void primo_state::primo(machine_config &config)
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_SVG)); screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_SVG));
screen.set_refresh_hz(60); screen.set_refresh_hz(60);
screen.set_size(1920/4, 606/4); screen.set_size(1920/5, 606/5);
screen.set_visarea_full(); screen.set_visarea_full();
PWM_DISPLAY(config, m_led_pwm).set_size(2, 8); PWM_DISPLAY(config, m_led_pwm).set_size(2, 8);