Merge pull request #6302 from cam900/ics2115_sample

Calculated actual ICS2115 sample rate
This commit is contained in:
R. Belmont 2020-02-13 10:22:52 -05:00 committed by GitHub
commit 920b161665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}