mirror of
https://github.com/holub/mame
synced 2025-06-07 21:33:45 +03:00
Add ability for notifiers to add at front, fix for hiscore [Carl]
This commit is contained in:
parent
1d84a0c3aa
commit
699fa1462a
@ -127,7 +127,7 @@ function hiscore.startplugin()
|
|||||||
|
|
||||||
|
|
||||||
function write_scores ( posdata )
|
function write_scores ( posdata )
|
||||||
print("write_scores")
|
print("write_scores")
|
||||||
local output = io.open(get_file_name(), "wb");
|
local output = io.open(get_file_name(), "wb");
|
||||||
if not output then
|
if not output then
|
||||||
-- attempt to create the directory, and try again
|
-- attempt to create the directory, and try again
|
||||||
@ -242,9 +242,8 @@ function hiscore.startplugin()
|
|||||||
current_game = ""
|
current_game = ""
|
||||||
mem_check_passed = false
|
mem_check_passed = false
|
||||||
scores_have_been_read = false;
|
scores_have_been_read = false;
|
||||||
|
last_write_time = -10
|
||||||
print("Starting " .. emu.gamename())
|
print("Starting " .. emu.gamename())
|
||||||
-- check if we've just soft reset
|
|
||||||
-- reset() -- there's no way to reliably save scores after a soft reset currently
|
|
||||||
current_game = emu.romname()
|
current_game = emu.romname()
|
||||||
dat = read_hiscore_dat()
|
dat = read_hiscore_dat()
|
||||||
if dat and dat ~= "" then
|
if dat and dat ~= "" then
|
||||||
@ -254,14 +253,17 @@ function hiscore.startplugin()
|
|||||||
print("hiscore.dat parse error");
|
print("hiscore.dat parse error");
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
emu.sethook( tick, "frame" );
|
|
||||||
emu.register_stop(function()
|
|
||||||
reset()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
emu.sethook( tick, "frame" );
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
emu.register_stop(function()
|
||||||
|
reset()
|
||||||
|
end)
|
||||||
|
emu.register_prestart(function()
|
||||||
|
reset()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return exports
|
return exports
|
||||||
|
@ -1319,6 +1319,11 @@ int lua_engine::register_function(lua_State *L, const char *id)
|
|||||||
return 1;
|
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)
|
int lua_engine::l_emu_register_start(lua_State *L)
|
||||||
{
|
{
|
||||||
return register_function(L, "LUA_ON_START");
|
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");
|
return register_function(L, "LUA_ON_FRAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lua_engine::on_machine_prestart()
|
||||||
|
{
|
||||||
|
execute_function("LUA_ON_PRESTART");
|
||||||
|
}
|
||||||
|
|
||||||
void lua_engine::on_machine_start()
|
void lua_engine::on_machine_start()
|
||||||
{
|
{
|
||||||
execute_function("LUA_ON_START");
|
execute_function("LUA_ON_START");
|
||||||
@ -1393,6 +1403,7 @@ void lua_engine::update_machine()
|
|||||||
|
|
||||||
void lua_engine::attach_notifiers()
|
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_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_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));
|
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 ("start", l_emu_start )
|
||||||
.addCFunction ("pause", l_emu_pause )
|
.addCFunction ("pause", l_emu_pause )
|
||||||
.addCFunction ("unpause", l_emu_unpause )
|
.addCFunction ("unpause", l_emu_unpause )
|
||||||
|
.addCFunction ("register_prestart", l_emu_register_prestart )
|
||||||
.addCFunction ("register_start", l_emu_register_start )
|
.addCFunction ("register_start", l_emu_register_start )
|
||||||
.addCFunction ("register_stop", l_emu_register_stop )
|
.addCFunction ("register_stop", l_emu_register_stop )
|
||||||
.addCFunction ("register_pause", l_emu_register_pause )
|
.addCFunction ("register_pause", l_emu_register_pause )
|
||||||
|
@ -83,6 +83,7 @@ private:
|
|||||||
|
|
||||||
void update_machine();
|
void update_machine();
|
||||||
|
|
||||||
|
void on_machine_prestart();
|
||||||
void on_machine_start();
|
void on_machine_start();
|
||||||
void on_machine_stop();
|
void on_machine_stop();
|
||||||
void on_machine_pause();
|
void on_machine_pause();
|
||||||
@ -114,6 +115,7 @@ private:
|
|||||||
static int l_emu_pause(lua_State *L);
|
static int l_emu_pause(lua_State *L);
|
||||||
static int l_emu_unpause(lua_State *L);
|
static int l_emu_unpause(lua_State *L);
|
||||||
static int l_emu_set_hook(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_start(lua_State *L);
|
||||||
static int l_emu_register_stop(lua_State *L);
|
static int l_emu_register_stop(lua_State *L);
|
||||||
static int l_emu_register_pause(lua_State *L);
|
static int l_emu_register_pause(lua_State *L);
|
||||||
|
@ -739,12 +739,15 @@ void running_machine::toggle_pause()
|
|||||||
// given type
|
// 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!");
|
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
|
// 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));
|
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
|
// all other notifiers are added to the tail, and executed in the order registered
|
||||||
|
@ -214,7 +214,7 @@ public:
|
|||||||
void pause();
|
void pause();
|
||||||
void resume();
|
void resume();
|
||||||
void toggle_pause();
|
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 call_notifiers(machine_notification which);
|
||||||
void add_logerror_callback(logerror_callback callback);
|
void add_logerror_callback(logerror_callback callback);
|
||||||
void set_ui_active(bool active) { m_ui_active = active; }
|
void set_ui_active(bool active) { m_ui_active = active; }
|
||||||
|
Loading…
Reference in New Issue
Block a user