Previous 199869 Revisions Next

r34473 Sunday 18th January, 2015 at 19:13:11 UTC by Luca Bruno
luaengine: rework state getter/setter for saves

Improve state_get_value and state_set_value by using the
parent device_state_interface and triggering callbacks for
updates.

While at it, also remove the hackish friend relationship.

Signed-off-by: Luca Bruno <lucab@debian.org>
[src/emu]distate.h luaengine.c

trunk/src/emu/distate.h
r242984r242985
4545{
4646   friend class device_state_interface;
4747   friend class simple_list<device_state_entry>;
48   friend class lua_engine;
4948
5049private:
5150   // construction/destruction
trunk/src/emu/luaengine.c
r242984r242985
456456}
457457
458458//-------------------------------------------------
459//  state_get_value - return value of a devices state
459//  state_get_value - return value of a device state entry
460460//  -> manager:machine().devices[":maincpu"].state["PC"].value
461461//-------------------------------------------------
462462
463463UINT64 lua_engine::l_state_get_value(const device_state_entry *d)
464464{
465   return d->value();
465   device_state_interface *state = d->parent_state();
466   if(state) {
467      luaThis->machine().save().dispatch_presave();
468      return state->state_int(d->index());
469   } else {
470      return 0;
471   }
466472}
467473
468474//-------------------------------------------------
469//  state_set_value - set value of a devices state
475//  state_set_value - set value of a device state entry
470476//  -> manager:machine().devices[":maincpu"].state["D0"].value = 0x0c00
471477//-------------------------------------------------
472478
473479void lua_engine::l_state_set_value(device_state_entry *d, UINT64 val)
474480{
475   d->set_value(val);
481   device_state_interface *state = d->parent_state();
482   if(state) {
483      state->set_state_int(d->index(), val);
484      luaThis->machine().save().dispatch_presave();
485   }
476486}
477487
478488//-------------------------------------------------


Previous 199869 Revisions Next


© 1997-2024 The MAME Team