From 1228a78ae52619fbcf2feb9062a180ab1e732362 Mon Sep 17 00:00:00 2001 From: cam900 Date: Thu, 13 Feb 2020 20:09:22 +0900 Subject: [PATCH] ics2115.cpp : Calculated sample rate related to clock, Activated osc numbers, Add notes --- src/devices/sound/ics2115.cpp | 12 +++++++++++- src/devices/sound/ics2115.h | 1 + src/mame/drivers/igs011.cpp | 2 +- src/mame/drivers/igs_fear.cpp | 2 +- src/mame/drivers/pgm.cpp | 6 +++--- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index 9ce19fe649f..040955a3064 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -29,7 +29,7 @@ void ics2115_device::device_start() { m_timer[0].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ics2115_device::timer_cb_0),this), this); m_timer[1].timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(ics2115_device::timer_cb_1),this), this); - m_stream = machine().sound().stream_alloc(*this, 0, 2, 33075); + m_stream = machine().sound().stream_alloc(*this, 0, 2, clock() / (32 * 32)); m_irq_cb.resolve_safe(); @@ -104,6 +104,7 @@ void ics2115_device::device_reset() m_irq_pending = 0; //possible re-suss m_active_osc = 31; + m_stream->set_sample_rate(clock() / ((m_active_osc + 1) * 32)); m_osc_select = 0; m_reg_select = 0; m_vmode = 0; @@ -136,6 +137,11 @@ void ics2115_device::device_reset() } } +void ics2115_device::device_clock_changed() +{ + m_stream->set_sample_rate(clock() / ((m_active_osc + 1) * 32)); +} + //TODO: improve using next-state logic from column 126 of patent 5809466 int ics2115_device::ics2115_voice::update_volume_envelope() { @@ -719,7 +725,10 @@ void ics2115_device::reg_write(u16 data, u16 mem_mask) case 0x0e: // Active Voices //Does this value get added to 1? Not sure. Could trace for writes of 32. if (ACCESSING_BITS_8_15) + { m_active_osc = (data >> 8) & 0x1f; // & 0x1f ? (Guessing) + m_stream->set_sample_rate(clock() / ((m_active_osc + 1) * 32)); + } break; //2X8 ? case 0x10: // [osc] Oscillator Control @@ -982,6 +991,7 @@ void ics2115_device::recalc_timer(int timer) //u64 period = m_timer[timer].preset * (m_timer[timer].scale << 16) / 60; //New formula based on O.Galibert's reverse engineering of ICS2115 card firmware + // TODO : Related to input clock? u64 period = ((m_timer[timer].scale & 0x1f) + 1) * (m_timer[timer].preset + 1); period = (period << (4 + (m_timer[timer].scale >> 5)))*78125/2646; diff --git a/src/devices/sound/ics2115.h b/src/devices/sound/ics2115.h index 58373daa5b2..78bc7e510c2 100644 --- a/src/devices/sound/ics2115.h +++ b/src/devices/sound/ics2115.h @@ -99,6 +99,7 @@ protected: // device-level overrides virtual void device_start() override; virtual void device_reset() override; + virtual void device_clock_changed() override; // internal callbacks virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override; diff --git a/src/mame/drivers/igs011.cpp b/src/mame/drivers/igs011.cpp index 9f516de60d6..a0758324434 100644 --- a/src/mame/drivers/igs011.cpp +++ b/src/mame/drivers/igs011.cpp @@ -4198,7 +4198,7 @@ void igs011_state::vbowl(machine_config &config) // GFXDECODE(config, "gfxdecode", m_palette, gfx_igs011_hi); config.device_remove("oki"); - ICS2115(config, m_ics, 0); + ICS2115(config, m_ics, 33.8688_MHz_XTAL); m_ics->irq().set(FUNC(igs011_state::sound_irq)); m_ics->add_route(ALL_OUTPUTS, "mono", 5.0); } diff --git a/src/mame/drivers/igs_fear.cpp b/src/mame/drivers/igs_fear.cpp index c88e8f40d7f..16929d0fd85 100644 --- a/src/mame/drivers/igs_fear.cpp +++ b/src/mame/drivers/igs_fear.cpp @@ -101,7 +101,7 @@ void igs_fear_state::igs_fear(machine_config &config) /* sound hardware */ SPEAKER(config, "mono").front_center(); - ics2115_device &ics(ICS2115(config, "ics", 0)); + ics2115_device &ics(ICS2115(config, "ics", 33.8688_MHz_XTAL)); // TODO : Correct? ics.irq().set(FUNC(igs_fear_state::sound_irq)); ics.add_route(ALL_OUTPUTS, "mono", 5.0); } diff --git a/src/mame/drivers/pgm.cpp b/src/mame/drivers/pgm.cpp index 2d57288ec19..e7ce0bce684 100644 --- a/src/mame/drivers/pgm.cpp +++ b/src/mame/drivers/pgm.cpp @@ -491,12 +491,12 @@ void pgm_state::machine_reset() void pgm_state::pgmbase(machine_config &config) { /* basic machine hardware */ - M68000(config, m_maincpu, 20000000); /* 20 mhz! verified on real board */ + M68000(config, m_maincpu, 20_MHz_XTAL); /* 20 mhz! verified on real board */ m_maincpu->set_addrmap(AS_PROGRAM, &pgm_state::pgm_basic_mem); m_maincpu->set_vblank_int("screen", FUNC(pgm_state::irq6_line_hold)); TIMER(config, "scantimer").configure_scanline(FUNC(pgm_state::interrupt), "screen", 0, 1); - Z80(config, m_soundcpu, 33868800/4); + Z80(config, m_soundcpu, 33.8688_MHz_XTAL/4); m_soundcpu->set_addrmap(AS_PROGRAM, &pgm_state::pgm_z80_mem); m_soundcpu->set_addrmap(AS_IO, &pgm_state::pgm_z80_io); @@ -524,7 +524,7 @@ void pgm_state::pgmbase(machine_config &config) GENERIC_LATCH_8(config, "soundlatch2"); GENERIC_LATCH_8(config, m_soundlatch3); - ICS2115(config, m_ics, 0); + ICS2115(config, m_ics, 33.8688_MHz_XTAL); m_ics->irq().set_inputline("soundcpu", 0); m_ics->add_route(ALL_OUTPUTS, "mono", 5.0); }