// handle pre-saving by filling the blob protected override void device_pre_save() { // remember the original blob size var orig_size = m_save_blob.size(); // save the state ymfm.ymfm_saved_state state = new ymfm.ymfm_saved_state(m_save_blob, true); m_chip.save_restore(state); // ensure that the size didn't change since we first allocated if (m_save_blob.size() != orig_size) { throw new emu_fatalerror("State size changed for ymfm chip"); } }
// handle device start protected override void device_start() { // let our parent do its startup base.device_start(); // allocate our stream m_stream = m_disound.stream_alloc(0, OUTPUTS, m_chip.sample_rate(clock())); // compute the size of the save buffer by doing an initial save ymfm.ymfm_saved_state state = new ymfm.ymfm_saved_state(m_save_blob, true); m_chip.save_restore(state); // now register the blob for save, on the assumption the size won't change save_item(NAME(new { m_save_blob })); }
// save/restore public void save_restore(ymfm_saved_state state) { throw new emu_unimplemented(); }
// handle post-loading by restoring from the blob protected override void device_post_load() { // populate the state from the blob ymfm.ymfm_saved_state state = new ymfm.ymfm_saved_state(m_save_blob, false); m_chip.save_restore(state); }