mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
es5506.cpp, Sync sample rate with esqpump.cpp (#4582)
* es5506.cpp, Sync sample rate with esqpump.cpp esqpump.cpp : Use required_device for m_esp, Add device_clock_changed, Add notes, Change timer frequency related to sample rate(clock) * esqpump.cpp : Minor correction
This commit is contained in:
parent
e8afd930a5
commit
08259f27dd
@ -156,7 +156,8 @@ es550x_device::es550x_device(const machine_config &mconfig, device_type type, co
|
||||
m_region3(nullptr),
|
||||
m_channels(0),
|
||||
m_irq_cb(*this),
|
||||
m_read_port_cb(*this)
|
||||
m_read_port_cb(*this),
|
||||
m_sample_rate_changed_cb(*this)
|
||||
{
|
||||
for (auto & elem : m_region_base)
|
||||
{
|
||||
@ -230,6 +231,7 @@ void es5506_device::device_start()
|
||||
m_master_clock = clock();
|
||||
m_irq_cb.resolve();
|
||||
m_read_port_cb.resolve();
|
||||
m_sample_rate_changed_cb.resolve();
|
||||
m_irqv = 0x80;
|
||||
m_channels = channels;
|
||||
|
||||
@ -309,6 +311,8 @@ void es550x_device::device_clock_changed()
|
||||
m_master_clock = clock();
|
||||
m_sample_rate = m_master_clock / (16 * (m_active_voices + 1));
|
||||
m_stream->set_sample_rate(m_sample_rate);
|
||||
if (!m_sample_rate_changed_cb.isnull())
|
||||
m_sample_rate_changed_cb(m_sample_rate);
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -378,6 +382,7 @@ void es5505_device::device_start()
|
||||
m_master_clock = clock();
|
||||
m_irq_cb.resolve();
|
||||
m_read_port_cb.resolve();
|
||||
m_sample_rate_changed_cb.resolve();
|
||||
m_irqv = 0x80;
|
||||
m_channels = channels;
|
||||
|
||||
@ -1215,6 +1220,8 @@ inline void es5506_device::reg_write_low(es550x_voice *voice, offs_t offset, uin
|
||||
m_active_voices = data & 0x1f;
|
||||
m_sample_rate = m_master_clock / (16 * (m_active_voices + 1));
|
||||
m_stream->set_sample_rate(m_sample_rate);
|
||||
if (!m_sample_rate_changed_cb.isnull())
|
||||
m_sample_rate_changed_cb(m_sample_rate);
|
||||
|
||||
LOG("active voices=%d, sample_rate=%d\n", m_active_voices, m_sample_rate);
|
||||
break;
|
||||
@ -1749,6 +1756,8 @@ inline void es5505_device::reg_write_low(es550x_voice *voice, offs_t offset, uin
|
||||
m_active_voices = data & 0x1f;
|
||||
m_sample_rate = m_master_clock / (16 * (m_active_voices + 1));
|
||||
m_stream->set_sample_rate(m_sample_rate);
|
||||
if (!m_sample_rate_changed_cb.isnull())
|
||||
m_sample_rate_changed_cb(m_sample_rate);
|
||||
|
||||
LOG("active voices=%d, sample_rate=%d\n", m_active_voices, m_sample_rate);
|
||||
}
|
||||
@ -1847,6 +1856,8 @@ inline void es5505_device::reg_write_high(es550x_voice *voice, offs_t offset, ui
|
||||
m_active_voices = data & 0x1f;
|
||||
m_sample_rate = m_master_clock / (16 * (m_active_voices + 1));
|
||||
m_stream->set_sample_rate(m_sample_rate);
|
||||
if (!m_sample_rate_changed_cb.isnull())
|
||||
m_sample_rate_changed_cb(m_sample_rate);
|
||||
|
||||
LOG("active voices=%d, sample_rate=%d\n", m_active_voices, m_sample_rate);
|
||||
}
|
||||
@ -1890,6 +1901,8 @@ inline void es5505_device::reg_write_test(es550x_voice *voice, offs_t offset, ui
|
||||
m_active_voices = data & 0x1f;
|
||||
m_sample_rate = m_master_clock / (16 * (m_active_voices + 1));
|
||||
m_stream->set_sample_rate(m_sample_rate);
|
||||
if (!m_sample_rate_changed_cb.isnull())
|
||||
m_sample_rate_changed_cb(m_sample_rate);
|
||||
|
||||
LOG("active voices=%d, sample_rate=%d\n", m_active_voices, m_sample_rate);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ public:
|
||||
|
||||
auto irq_cb() { return m_irq_cb.bind(); }
|
||||
auto read_port_cb() { return m_read_port_cb.bind(); }
|
||||
auto sample_rate_changed() { return m_sample_rate_changed_cb.bind(); }
|
||||
|
||||
protected:
|
||||
// struct describing a single playing voice
|
||||
@ -114,6 +115,7 @@ protected:
|
||||
int m_channels; /* number of output channels: 1 .. 6 */
|
||||
devcb_write_line m_irq_cb; /* irq callback */
|
||||
devcb_read16 m_read_port_cb; /* input port read */
|
||||
devcb_write32 m_sample_rate_changed_cb; /* callback for when sample rate is changed */
|
||||
};
|
||||
|
||||
|
||||
|
@ -16,8 +16,12 @@ DEFINE_DEVICE_TYPE(ESQ_5505_5510_PUMP, esq_5505_5510_pump_device, "esq_5505_5510
|
||||
esq_5505_5510_pump_device::esq_5505_5510_pump_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: device_t(mconfig, ESQ_5505_5510_PUMP, tag, owner, clock)
|
||||
, device_sound_interface(mconfig, *this)
|
||||
, m_stream(nullptr), m_timer(nullptr), m_esp(nullptr)
|
||||
, m_esp_halted(true), ticks_spent_processing(0), samples_processed(0)
|
||||
, m_stream(nullptr)
|
||||
, m_timer(nullptr)
|
||||
, m_esp(*this, finder_base::DUMMY_TAG)
|
||||
, m_esp_halted(true)
|
||||
, ticks_spent_processing(0)
|
||||
, samples_processed(0)
|
||||
{
|
||||
#if !PUMP_FAKE_ESP_PROCESSING && PUMP_REPLACE_ESP_PROGRAM
|
||||
e = nullptr;
|
||||
@ -59,14 +63,16 @@ void esq_5505_5510_pump_device::device_stop()
|
||||
|
||||
void esq_5505_5510_pump_device::device_reset()
|
||||
{
|
||||
int64_t nsec_per_sample = 100 * 16 * 21;
|
||||
attotime sample_time(0, 1000000000 * nsec_per_sample);
|
||||
attotime initial_delay(0, 0);
|
||||
|
||||
m_timer->adjust(initial_delay, 0, sample_time);
|
||||
m_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
|
||||
m_timer->enable(true);
|
||||
}
|
||||
|
||||
void esq_5505_5510_pump_device::device_clock_changed()
|
||||
{
|
||||
m_stream->set_sample_rate(clock());
|
||||
m_timer->adjust(attotime::zero, 0, attotime::from_hz(clock()));
|
||||
}
|
||||
|
||||
void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
|
||||
{
|
||||
if (samples != 1) {
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
|
||||
esq_5505_5510_pump_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
void set_esp(es5510_device *esp) { m_esp = esp; }
|
||||
template <typename T> void set_esp(T &&tag) { m_esp.set_tag(std::forward<T>(tag)); }
|
||||
void set_esp_halted(bool esp_halted) {
|
||||
m_esp_halted = esp_halted;
|
||||
logerror("ESP-halted -> %d\n", m_esp_halted);
|
||||
@ -72,6 +72,7 @@ protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_stop() override;
|
||||
virtual void device_reset() override;
|
||||
virtual void device_clock_changed() override;
|
||||
|
||||
// sound stream update overrides
|
||||
virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
|
||||
@ -88,7 +89,7 @@ private:
|
||||
emu_timer *m_timer;
|
||||
|
||||
// ESP signal processor
|
||||
es5510_device *m_esp;
|
||||
required_device<es5510_device> m_esp;
|
||||
|
||||
// Is the ESP halted by the CPU?
|
||||
bool m_esp_halted;
|
||||
|
@ -43,7 +43,6 @@ taito_en_device::taito_en_device(const machine_config &mconfig, const char *tag,
|
||||
void taito_en_device::device_start()
|
||||
{
|
||||
// tell the pump about the ESP chips
|
||||
m_pump->set_esp(m_esp);
|
||||
uint8_t *ROM = m_osrom->base();
|
||||
uint32_t max = (m_osrom->bytes() - 0x100000) / 0x20000;
|
||||
for (int i = 0; i < 3; i++)
|
||||
@ -134,6 +133,18 @@ WRITE8_MEMBER(taito_en_device::mb87078_gain_changed)
|
||||
}
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* ES5510 callback
|
||||
*
|
||||
*************************************/
|
||||
|
||||
void taito_en_device::es5505_clock_changed(u32 data)
|
||||
{
|
||||
m_pump->set_unscaled_clock(data);
|
||||
}
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* M68681 callback
|
||||
@ -213,10 +224,12 @@ void taito_en_device::device_add_mconfig(machine_config &config)
|
||||
SPEAKER(config, "rspeaker").front_right();
|
||||
|
||||
ESQ_5505_5510_PUMP(config, m_pump, XTAL(30'476'100) / (2 * 16 * 32));
|
||||
m_pump->set_esp(m_esp);
|
||||
m_pump->add_route(0, "lspeaker", 1.0);
|
||||
m_pump->add_route(1, "rspeaker", 1.0);
|
||||
|
||||
ES5505(config, m_ensoniq, XTAL(30'476'100) / 2);
|
||||
m_ensoniq->sample_rate_changed().set(FUNC(taito_en_device::es5505_clock_changed));
|
||||
m_ensoniq->set_region0("ensoniq.0");
|
||||
m_ensoniq->set_region1("ensoniq.0");
|
||||
m_ensoniq->set_channels(4);
|
||||
|
@ -58,6 +58,7 @@ private:
|
||||
DECLARE_WRITE8_MEMBER(duart_output);
|
||||
|
||||
DECLARE_WRITE8_MEMBER(mb87078_gain_changed);
|
||||
void es5505_clock_changed(u32 data);
|
||||
};
|
||||
|
||||
DECLARE_DEVICE_TYPE(TAITO_EN, taito_en_device)
|
||||
|
@ -222,6 +222,8 @@ private:
|
||||
DECLARE_WRITE_LINE_MEMBER(duart_tx_b);
|
||||
DECLARE_WRITE8_MEMBER(duart_output);
|
||||
|
||||
void es5505_clock_changed(u32 data);
|
||||
|
||||
int m_system_type;
|
||||
uint8_t m_duart_io;
|
||||
uint8_t otis_irq_state;
|
||||
@ -270,8 +272,6 @@ IRQ_CALLBACK_MEMBER(esq5505_state::maincpu_irq_acknowledge_callback)
|
||||
void esq5505_state::machine_start()
|
||||
{
|
||||
driver_device::machine_start();
|
||||
// tell the pump about the ESP chips
|
||||
m_pump->set_esp(m_esp);
|
||||
|
||||
m_rom = (uint16_t *)(void *)memregion("osrom")->base();
|
||||
m_ram = (uint16_t *)(void *)memshare("osram")->ptr();
|
||||
@ -435,6 +435,11 @@ WRITE_LINE_MEMBER(esq5505_state::esq5505_otis_irq)
|
||||
update_irq_to_maincpu();
|
||||
}
|
||||
|
||||
void esq5505_state::es5505_clock_changed(u32 data)
|
||||
{
|
||||
m_pump->set_unscaled_clock(data);
|
||||
}
|
||||
|
||||
WRITE16_MEMBER(esq5505_state::analog_w)
|
||||
{
|
||||
offset &= 0x7;
|
||||
@ -644,10 +649,12 @@ void esq5505_state::vfx(machine_config &config)
|
||||
SPEAKER(config, "rspeaker").front_right();
|
||||
|
||||
ESQ_5505_5510_PUMP(config, m_pump, 10_MHz_XTAL / (16 * 21));
|
||||
m_pump->set_esp(m_esp);
|
||||
m_pump->add_route(0, "lspeaker", 1.0);
|
||||
m_pump->add_route(1, "rspeaker", 1.0);
|
||||
|
||||
auto &es5505(ES5505(config, "otis", 10_MHz_XTAL));
|
||||
es5505.sample_rate_changed().set(FUNC(esq5505_state::es5505_clock_changed));
|
||||
es5505.set_region0("waverom"); /* Bank 0 */
|
||||
es5505.set_region1("waverom2"); /* Bank 1 */
|
||||
es5505.set_channels(4); /* channels */
|
||||
@ -733,10 +740,12 @@ void esq5505_state::vfx32(machine_config &config)
|
||||
SPEAKER(config, "rspeaker").front_right();
|
||||
|
||||
ESQ_5505_5510_PUMP(config, m_pump, 30.4761_MHz_XTAL / (2 * 16 * 32));
|
||||
m_pump->set_esp(m_esp);
|
||||
m_pump->add_route(0, "lspeaker", 1.0);
|
||||
m_pump->add_route(1, "rspeaker", 1.0);
|
||||
|
||||
auto &es5505(ES5505(config, "otis", 30.4761_MHz_XTAL / 2));
|
||||
es5505.sample_rate_changed().set(FUNC(esq5505_state::es5505_clock_changed));
|
||||
es5505.set_region0("waverom"); /* Bank 0 */
|
||||
es5505.set_region1("waverom2"); /* Bank 1 */
|
||||
es5505.set_channels(4); /* channels */
|
||||
|
@ -76,18 +76,14 @@ private:
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER(esq5506_otto_irq);
|
||||
DECLARE_READ16_MEMBER(esq5506_read_adc);
|
||||
void es5506_clock_changed(u32 data);
|
||||
|
||||
void asr_map(address_map &map);
|
||||
void asrx_map(address_map &map);
|
||||
};
|
||||
|
||||
void esqasr_state::machine_start()
|
||||
{
|
||||
if (m_pump.found())
|
||||
{
|
||||
// tell the pump about the ESP chips
|
||||
if (m_esp.found())
|
||||
m_pump->set_esp(m_esp);
|
||||
}
|
||||
}
|
||||
|
||||
void esqasr_state::machine_reset()
|
||||
@ -116,6 +112,11 @@ READ16_MEMBER(esqasr_state::esq5506_read_adc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void esqasr_state::es5506_clock_changed(u32 data)
|
||||
{
|
||||
m_pump->set_unscaled_clock(data);
|
||||
}
|
||||
|
||||
void esqasr_state::asr(machine_config &config)
|
||||
{
|
||||
M68000(config, m_maincpu, XTAL(16'000'000)); // actually MC68302
|
||||
@ -130,10 +131,12 @@ void esqasr_state::asr(machine_config &config)
|
||||
SPEAKER(config, "rspeaker").front_right();
|
||||
|
||||
ESQ_5505_5510_PUMP(config, m_pump, XTAL(16'000'000) / (16 * 32));
|
||||
m_pump->set_esp(m_esp);
|
||||
m_pump->add_route(0, "lspeaker", 1.0);
|
||||
m_pump->add_route(1, "rspeaker", 1.0);
|
||||
|
||||
es5506_device &ensoniq(ES5506(config, "ensoniq", XTAL(16'000'000)));
|
||||
ensoniq.sample_rate_changed().set(FUNC(esqasr_state::es5506_clock_changed));
|
||||
ensoniq.set_region0("waverom"); /* Bank 0 */
|
||||
ensoniq.set_region1("waverom2"); /* Bank 1 */
|
||||
ensoniq.set_region2("waverom3"); /* Bank 0 */
|
||||
@ -165,10 +168,12 @@ void esqasr_state::asrx(machine_config &config)
|
||||
SPEAKER(config, "rspeaker").front_right();
|
||||
|
||||
ESQ_5505_5510_PUMP(config, m_pump, XTAL(16'000'000) / (16 * 32)); // Actually ES5511
|
||||
m_pump->set_esp(m_esp);
|
||||
m_pump->add_route(0, "lspeaker", 1.0);
|
||||
m_pump->add_route(1, "rspeaker", 1.0);
|
||||
|
||||
es5506_device &ensoniq(ES5506(config, "ensoniq", XTAL(16'000'000)));
|
||||
ensoniq.sample_rate_changed().set(FUNC(esqasr_state::es5506_clock_changed));
|
||||
ensoniq.set_region0("waverom"); /* Bank 0 */
|
||||
ensoniq.set_region1("waverom2"); /* Bank 1 */
|
||||
ensoniq.set_region2("waverom3"); /* Bank 0 */
|
||||
|
@ -139,13 +139,12 @@ private:
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER(esq5506_otto_irq);
|
||||
DECLARE_READ16_MEMBER(esq5506_read_adc);
|
||||
void es5506_clock_changed(u32 data);
|
||||
void kt_map(address_map &map);
|
||||
};
|
||||
|
||||
void esqkt_state::machine_start()
|
||||
{
|
||||
// tell the pump about the ESP chips
|
||||
m_pump->set_esp(m_esp);
|
||||
}
|
||||
|
||||
void esqkt_state::machine_reset()
|
||||
@ -194,6 +193,11 @@ READ16_MEMBER(esqkt_state::esq5506_read_adc)
|
||||
}
|
||||
}
|
||||
|
||||
void esqkt_state::es5506_clock_changed(u32 data)
|
||||
{
|
||||
m_pump->set_unscaled_clock(data);
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER(esqkt_state::duart_irq_handler)
|
||||
{
|
||||
m_maincpu->set_input_line(M68K_IRQ_3, state);
|
||||
@ -244,10 +248,12 @@ void esqkt_state::kt(machine_config &config)
|
||||
SPEAKER(config, "rspeaker").front_right();
|
||||
|
||||
ESQ_5505_5510_PUMP(config, m_pump, 16_MHz_XTAL / (16 * 32));
|
||||
m_pump->set_esp(m_esp);
|
||||
m_pump->add_route(0, "lspeaker", 1.0);
|
||||
m_pump->add_route(1, "rspeaker", 1.0);
|
||||
|
||||
auto &es5506a(ES5506(config, "ensoniq1", 16_MHz_XTAL));
|
||||
es5506a.sample_rate_changed().set(FUNC(esqkt_state::es5506_clock_changed)); // TODO : Sync with 2 chips?
|
||||
es5506a.set_region0("waverom"); /* Bank 0 */
|
||||
es5506a.set_region1("waverom2"); /* Bank 1 */
|
||||
es5506a.set_region2("waverom3"); /* Bank 0 */
|
||||
|
Loading…
Reference in New Issue
Block a user