mirror of
https://github.com/holub/mame
synced 2025-05-30 09:33:05 +03:00
ym2151: Support dynamic changes to clock frequency
This commit is contained in:
parent
44c3a6b25b
commit
d1f6b7a719
@ -382,18 +382,6 @@ void ym2151_device::init_tables()
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate timers' deltas */
|
||||
for (int i=0; i<1024; i++)
|
||||
{
|
||||
/* ASG 980324: changed to compute both tim_A_tab and timer_A_time */
|
||||
timer_A_time[i] = attotime::from_hz(clock()) * (64 * (1024 - i));
|
||||
}
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
/* ASG 980324: changed to compute both tim_B_tab and timer_B_time */
|
||||
timer_B_time[i] = attotime::from_hz(clock()) * (1024 * (256 - i));
|
||||
}
|
||||
|
||||
/* calculate noise periods table */
|
||||
for (int i=0; i<32; i++)
|
||||
{
|
||||
@ -404,6 +392,21 @@ void ym2151_device::init_tables()
|
||||
}
|
||||
}
|
||||
|
||||
void ym2151_device::calculate_timers()
|
||||
{
|
||||
/* calculate timers' deltas */
|
||||
for (int i=0; i<1024; i++)
|
||||
{
|
||||
/* ASG 980324: changed to compute both tim_A_tab and timer_A_time */
|
||||
timer_A_time[i] = clocks_to_attotime(64 * (1024 - i));
|
||||
}
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
/* ASG 980324: changed to compute both tim_B_tab and timer_B_time */
|
||||
timer_B_time[i] = clocks_to_attotime(1024 * (256 - i));
|
||||
}
|
||||
}
|
||||
|
||||
void ym2151_device::YM2151Operator::key_on(uint32_t key_set, uint32_t eg_cnt)
|
||||
{
|
||||
if (!key)
|
||||
@ -1020,6 +1023,12 @@ void ym2151_device::device_start()
|
||||
save_item(NAME(connect));
|
||||
}
|
||||
|
||||
void ym2151_device::device_clock_changed()
|
||||
{
|
||||
m_stream->set_sample_rate(clock() / 64);
|
||||
calculate_timers();
|
||||
}
|
||||
|
||||
|
||||
int ym2151_device::op_calc(YM2151Operator * OP, unsigned int env, signed int pm)
|
||||
{
|
||||
|
@ -81,6 +81,7 @@ protected:
|
||||
virtual void device_reset() override;
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||
virtual void device_post_load() 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;
|
||||
@ -259,6 +260,7 @@ private:
|
||||
devcb_write8 m_portwritehandler;
|
||||
|
||||
void init_tables();
|
||||
void calculate_timers();
|
||||
void envelope_KONKOFF(YM2151Operator * op, int v);
|
||||
void set_connect(YM2151Operator *om1, int cha, int v);
|
||||
void advance();
|
||||
|
Loading…
Reference in New Issue
Block a user