summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emu/luaengine.cpp12
-rw-r--r--src/emu/luaengine.h2
-rw-r--r--src/emu/machine.cpp7
-rw-r--r--src/emu/machine.h2
4 files changed, 20 insertions, 3 deletions
diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp
index cd392de3c89..18ae0172bf7 100644
--- a/src/emu/luaengine.cpp
+++ b/src/emu/luaengine.cpp
@@ -1319,6 +1319,11 @@ int lua_engine::register_function(lua_State *L, const char *id)
return 1;
}
+int lua_engine::l_emu_register_prestart(lua_State *L)
+{
+ return register_function(L, "LUA_ON_PRESTART");
+}
+
int lua_engine::l_emu_register_start(lua_State *L)
{
return register_function(L, "LUA_ON_START");
@@ -1344,6 +1349,11 @@ int lua_engine::l_emu_register_frame(lua_State *L)
return register_function(L, "LUA_ON_FRAME");
}
+void lua_engine::on_machine_prestart()
+{
+ execute_function("LUA_ON_PRESTART");
+}
+
void lua_engine::on_machine_start()
{
execute_function("LUA_ON_START");
@@ -1393,6 +1403,7 @@ void lua_engine::update_machine()
void lua_engine::attach_notifiers()
{
+ machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(lua_engine::on_machine_prestart), this), true);
machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(lua_engine::on_machine_start), this));
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(lua_engine::on_machine_stop), this));
machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(lua_engine::on_machine_pause), this));
@@ -1439,6 +1450,7 @@ void lua_engine::initialize()
.addCFunction ("start", l_emu_start )
.addCFunction ("pause", l_emu_pause )
.addCFunction ("unpause", l_emu_unpause )
+ .addCFunction ("register_prestart", l_emu_register_prestart )
.addCFunction ("register_start", l_emu_register_start )
.addCFunction ("register_stop", l_emu_register_stop )
.addCFunction ("register_pause", l_emu_register_pause )
diff --git a/src/emu/luaengine.h b/src/emu/luaengine.h
index 2f0f4ad7a34..b98b9597b56 100644
--- a/src/emu/luaengine.h
+++ b/src/emu/luaengine.h
@@ -83,6 +83,7 @@ private:
void update_machine();
+ void on_machine_prestart();
void on_machine_start();
void on_machine_stop();
void on_machine_pause();
@@ -114,6 +115,7 @@ private:
static int l_emu_pause(lua_State *L);
static int l_emu_unpause(lua_State *L);
static int l_emu_set_hook(lua_State *L);
+ static int l_emu_register_prestart(lua_State *L);
static int l_emu_register_start(lua_State *L);
static int l_emu_register_stop(lua_State *L);
static int l_emu_register_pause(lua_State *L);
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index d76ad49676d..70d1ccc411b 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -739,12 +739,15 @@ void running_machine::toggle_pause()
// given type
//-------------------------------------------------
-void running_machine::add_notifier(machine_notification event, machine_notify_delegate callback)
+void running_machine::add_notifier(machine_notification event, machine_notify_delegate callback, bool first)
{
assert_always(m_current_phase == MACHINE_PHASE_INIT, "Can only call add_notifier at init time!");
+ if(first)
+ m_notifier_list[event].push_front(std::make_unique<notifier_callback_item>(callback));
+
// exit notifiers are added to the head, and executed in reverse order
- if (event == MACHINE_NOTIFY_EXIT)
+ else if (event == MACHINE_NOTIFY_EXIT)
m_notifier_list[event].push_front(std::make_unique<notifier_callback_item>(callback));
// all other notifiers are added to the tail, and executed in the order registered
diff --git a/src/emu/machine.h b/src/emu/machine.h
index 1eaee4d6e4a..5e19aefb6c4 100644
--- a/src/emu/machine.h
+++ b/src/emu/machine.h
@@ -214,7 +214,7 @@ public:
void pause();
void resume();
void toggle_pause();
- void add_notifier(machine_notification event, machine_notify_delegate callback);
+ void add_notifier(machine_notification event, machine_notify_delegate callback, bool first = false);
void call_notifiers(machine_notification which);
void add_logerror_callback(logerror_callback callback);
void set_ui_active(bool active) { m_ui_active = active; }