pwm: fix savestate problem (nw)

This commit is contained in:
hap 2019-07-05 19:48:19 +02:00
parent abb0842eca
commit 10f0425b9e
2 changed files with 30 additions and 4 deletions

View File

@ -68,8 +68,6 @@ pwm_display_device::pwm_display_device(const machine_config &mconfig, const char
// device_start/reset
//-------------------------------------------------
ALLOW_SAVE_TYPE(attotime); // m_acc
void pwm_display_device::device_start()
{
// resolve handlers
@ -113,8 +111,9 @@ void pwm_display_device::device_start()
save_item(NAME(m_rowdata_prev));
save_item(NAME(m_bri));
save_item(NAME(m_acc));
save_item(NAME(m_update_time));
save_item(NAME(m_acc_attos));
save_item(NAME(m_acc_secs));
}
void pwm_display_device::device_reset()
@ -128,6 +127,29 @@ void pwm_display_device::device_reset()
//-------------------------------------------------
// custom savestate handling (MAME doesn't save array of attotime)
//-------------------------------------------------
void pwm_display_device::device_pre_save()
{
for (int y = 0; y < ARRAY_LENGTH(m_acc); y++)
for (int x = 0; x < ARRAY_LENGTH(m_acc[0]); x++)
{
m_acc_attos[y][x] = m_acc[y][x].attoseconds();
m_acc_secs[y][x] = m_acc[y][x].seconds();
}
}
void pwm_display_device::device_post_load()
{
for (int y = 0; y < ARRAY_LENGTH(m_acc); y++)
for (int x = 0; x < ARRAY_LENGTH(m_acc[0]); x++)
m_acc[y][x] = attotime(m_acc_secs[y][x], m_acc_attos[y][x]);
}
//-------------------------------------------------
// public handlers (most of the interface is in the .h file)
//-------------------------------------------------

View File

@ -59,6 +59,8 @@ protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_pre_save() override;
virtual void device_post_load() override;
private:
output_finder<0x40, 0x40> m_out_x;
@ -86,8 +88,10 @@ private:
u64 m_rowdata_prev[0x40];
double m_bri[0x40][0x41];
attotime m_acc[0x40][0x41];
attotime m_update_time;
attotime m_acc[0x40][0x41];
attoseconds_t m_acc_attos[0x40][0x41];
seconds_t m_acc_secs[0x40][0x41];
emu_timer *m_frame_timer;
TIMER_CALLBACK_MEMBER(frame_tick);