mirror of
https://github.com/holub/mame
synced 2025-05-11 16:48:52 +03:00
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>
This commit is contained in:
parent
39788873b0
commit
37cd9a2d98
@ -45,7 +45,6 @@ class device_state_entry
|
|||||||
{
|
{
|
||||||
friend class device_state_interface;
|
friend class device_state_interface;
|
||||||
friend class simple_list<device_state_entry>;
|
friend class simple_list<device_state_entry>;
|
||||||
friend class lua_engine;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// construction/destruction
|
// construction/destruction
|
||||||
|
@ -456,23 +456,33 @@ luabridge::LuaRef lua_engine::l_dev_get_states(const device_t *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// state_get_value - return value of a devices state
|
// state_get_value - return value of a device state entry
|
||||||
// -> manager:machine().devices[":maincpu"].state["PC"].value
|
// -> manager:machine().devices[":maincpu"].state["PC"].value
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
UINT64 lua_engine::l_state_get_value(const device_state_entry *d)
|
UINT64 lua_engine::l_state_get_value(const device_state_entry *d)
|
||||||
{
|
{
|
||||||
return d->value();
|
device_state_interface *state = d->parent_state();
|
||||||
|
if(state) {
|
||||||
|
luaThis->machine().save().dispatch_presave();
|
||||||
|
return state->state_int(d->index());
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// state_set_value - set value of a devices state
|
// state_set_value - set value of a device state entry
|
||||||
// -> manager:machine().devices[":maincpu"].state["D0"].value = 0x0c00
|
// -> manager:machine().devices[":maincpu"].state["D0"].value = 0x0c00
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
void lua_engine::l_state_set_value(device_state_entry *d, UINT64 val)
|
void lua_engine::l_state_set_value(device_state_entry *d, UINT64 val)
|
||||||
{
|
{
|
||||||
d->set_value(val);
|
device_state_interface *state = d->parent_state();
|
||||||
|
if(state) {
|
||||||
|
state->set_state_int(d->index(), val);
|
||||||
|
luaThis->machine().save().dispatch_presave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user