summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/autofire/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/autofire/init.lua')
-rw-r--r--plugins/autofire/init.lua33
1 files changed, 29 insertions, 4 deletions
diff --git a/plugins/autofire/init.lua b/plugins/autofire/init.lua
index fd268b65ca3..5b52e47d350 100644
--- a/plugins/autofire/init.lua
+++ b/plugins/autofire/init.lua
@@ -2,13 +2,20 @@
-- copyright-holders:Jack Li
local exports = {}
exports.name = 'autofire'
-exports.version = '0.0.1'
+exports.version = '0.0.2'
exports.description = 'Autofire plugin'
exports.license = 'The BSD 3-Clause License'
exports.author = { name = 'Jack Li' }
local autofire = exports
+function autofire.set_folder(path)
+ local loader = require('autofire/autofire_save')
+ if loader then
+ loader:set_plugin_path(path)
+ end
+end
+
function autofire.startplugin()
-- List of autofire buttons, each being a table with keys:
@@ -21,6 +28,8 @@ function autofire.startplugin()
-- 'counter' - position in autofire cycle
local buttons = {}
+ local current_rom = nil
+
local function process_button(button)
local pressed = manager:machine():input():code_pressed(button.key)
if pressed then
@@ -54,10 +63,26 @@ function autofire.startplugin()
end
end
+ local function reinit_buttons()
+ for i, button in ipairs(buttons) do
+ button.counter = 0
+ button.button = manager:machine():ioport().ports[button.port].fields[button.field]
+ end
+ end
+
local function load_settings()
- local loader = require('autofire/autofire_save')
- if loader then
- buttons = loader:load_settings()
+ if current_rom == emu.romname() then
+ reinit_buttons()
+ else
+ local loader = require('autofire/autofire_save')
+ if loader then
+ buttons = loader:load_settings()
+ end
+ end
+ current_rom = emu.romname()
+ local menu_handler = require('autofire/autofire_menu')
+ if menu_handler then
+ menu_handler:init_menu(buttons)
end
end