summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/cheat/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/cheat/init.lua')
-rw-r--r--plugins/cheat/init.lua88
1 files changed, 44 insertions, 44 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index 83dbdc7bfb1..46a086f8ac2 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -94,12 +94,12 @@ function cheat.startplugin()
local function load_cheats()
local filename = emu.romname()
local newcheats = {}
- local file = emu.file(manager:machine():options().entries.cheatpath:value():gsub("([^;]+)", "%1;%1/cheat") , 1)
+ local file = emu.file(manager.machine.options.entries.cheatpath:value():gsub("([^;]+)", "%1;%1/cheat") , 1)
if emu.softname() ~= "" then
if emu.softname():find(":") then
filename = emu.softname():gsub(":", "/")
else
- for name, image in pairs(manager:machine().images) do
+ for name, image in pairs(manager.machine.images) do
if image:exists() and image:software_list_name() ~= "" then
filename = image:software_list_name() .. "/" .. emu.softname()
end
@@ -134,7 +134,7 @@ function cheat.startplugin()
local function load_hotkeys()
local json = require("json")
- local file = io.open(emu.subst_env(manager:machine():options().entries.cheatpath:value():match("([^;]+)")) .. "/" .. cheatname .. "_hotkeys.json", "r")
+ local file = io.open(emu.subst_env(manager.machine.options.entries.cheatpath:value():match("([^;]+)")) .. "/" .. cheatname .. "_hotkeys.json", "r")
if not file then
return
end
@@ -142,7 +142,7 @@ function cheat.startplugin()
for num, val in ipairs(hotkeys) do
for num, cheat in pairs(cheats) do
if val.desc == cheat.desc then
- cheat.hotkeys = {pressed = false, keys = manager:machine():input():seq_from_tokens(val.keys)}
+ cheat.hotkeys = {pressed = false, keys = manager.machine.input:seq_from_tokens(val.keys)}
end
end
end
@@ -152,7 +152,7 @@ function cheat.startplugin()
local hotkeys = {}
for num, cheat in ipairs(cheats) do
if cheat.hotkeys then
- local hotkey = {desc = cheat.desc, keys = manager:machine():input():seq_to_tokens(cheat.hotkeys.keys)}
+ local hotkey = {desc = cheat.desc, keys = manager.machine.input:seq_to_tokens(cheat.hotkeys.keys)}
if hotkey.keys ~= "" then
hotkeys[#hotkeys + 1] = hotkey
end
@@ -160,7 +160,7 @@ function cheat.startplugin()
end
if #hotkeys > 0 then
local json = require("json")
- local path = emu.subst_env(manager:machine():options().entries.cheatpath:value():match("([^;]+)"))
+ local path = emu.subst_env(manager.machine.options.entries.cheatpath:value():match("([^;]+)"))
local attr = lfs.attributes(path)
if not attr then
lfs.mkdir(path)
@@ -215,7 +215,7 @@ function cheat.startplugin()
return
end
if type(x) == "string" then
- y = y * mame_manager:ui():get_line_height()
+ y = y * mame_manager.ui.line_height
end
output[#output + 1] = { type = "text", scr = screen, x = x, y = y, str = str, color = color }
end
@@ -278,13 +278,13 @@ function cheat.startplugin()
run_if(wp.cheat, wp.func)
-- go in case a debugger other than "none" is enabled
-- don't use an b/wpset action because that will supress the b/wp index
- manager:machine():debugger().execution_state = "run"
+ manager.machine.debugger.execution_state = "run"
end
else
local bp = breaks[point]
if bp then
run_if(bp.cheat, bp.func)
- manager:machine():debugger().execution_state = "run"
+ manager.machine.debugger.execution_state = "run"
end
end
end
@@ -313,7 +313,7 @@ function cheat.startplugin()
end
local function bwpclr(cheat)
- if not manager:machine():debugger() then
+ if not manager.machine.debugger then
return
end
for num, bp in pairs(breaks) do
@@ -340,7 +340,7 @@ function cheat.startplugin()
if entry.port:sub(1, 1) ~= ":" then
entry.port = ":" .. entry.port
end
- local port = manager:machine():ioport().ports[entry.port]
+ local port = manager.machine.ioport.ports[entry.port]
if not port then
errout(entry.port, entry.field)
end
@@ -372,7 +372,7 @@ function cheat.startplugin()
error("input_run only allowed in one shot cheats")
return
end
- local _, screen = next(manager:machine().screens)
+ local _, screen = next(manager.machine.screens)
list.begin = screen:frame_number()
inputs[#inputs + 1] = list
end
@@ -451,7 +451,7 @@ function cheat.startplugin()
frombcd = frombcd,
pairs = pairs,
ipairs = ipairs,
- outputs = manager:machine():outputs(),
+ outputs = manager.machine.output,
time = time,
input_trans = input_trans,
input_run = function(list) input_run(cheat, list) end,
@@ -483,8 +483,8 @@ function cheat.startplugin()
if cheat.cpu then
cheat.cpudev = {}
for name, tag in pairs(cheat.cpu) do
- if manager:machine():debugger() then
- local dev = manager:machine().devices[tag]
+ if manager.machine.debugger then
+ local dev = manager.machine.devices[tag]
if not dev or not dev.debug then
cheat_error(cheat, "missing or invalid device " .. tag)
return
@@ -505,7 +505,7 @@ function cheat.startplugin()
if cheat.space then
for name, space in pairs(cheat.space) do
local cpu, mem
- cpu = manager:machine().devices[space.tag]
+ cpu = manager.machine.devices[space.tag]
if not cpu then
cheat_error(cheat, "missing device " .. space.tag)
return
@@ -525,17 +525,17 @@ function cheat.startplugin()
end
if cheat.screen then
for name, screen in pairs(cheat.screen) do
- local scr = manager:machine().screens[screen]
+ local scr = manager.machine.screens[screen]
if not scr then
local tag
- tag, scr = next(manager:machine().screens) -- get any screen
+ tag, scr = next(manager.machine.screens) -- get any screen
end
cheat.cheat_env[name] = scr
end
end
if cheat.region then
for name, region in pairs(cheat.region) do
- local mem = manager:machine():memory().regions[region]
+ local mem = manager.machine.memory.regions[region]
if not mem then
cheat_error(cheat, "missing region " .. region)
return
@@ -545,7 +545,7 @@ function cheat.startplugin()
end
if cheat.ram then
for name, tag in pairs(cheat.ram) do
- local ram = manager:machine().devices[tag]
+ local ram = manager.machine.devices[tag]
if not ram then
cheat_error(cheat, "missing ram device " .. tag)
return
@@ -555,7 +555,7 @@ function cheat.startplugin()
end
if cheat.share then
for name, tag in pairs(cheat.share) do
- local share = manager:machine():memory().shares[tag]
+ local share = manager.machine.memory.shares[tag]
if not share then
cheat_error(cheat, "missing share " .. share)
return
@@ -615,36 +615,36 @@ function cheat.startplugin()
return
end
- local input = manager:machine():input()
+ local input = manager.machine.input
local poller = input:switch_sequence_poller()
- manager:machine():popmessage(_("Press button for hotkey or wait to leave unchanged"))
- manager:machine():video():frame_update(true)
+ manager.machine:popmessage(_("Press button for hotkey or wait to leave unchanged"))
+ manager.machine.video:frame_update()
poller:start()
local time = os.clock()
local clearmsg = true
while (not poller:poll()) and (poller.modified or (os.clock() < time + 1)) do
if poller.modified then
if not poller.valid then
- manager:machine():popmessage(_("Invalid sequence entered"))
+ manager.machine:popmessage(_("Invalid sequence entered"))
clearmsg = false
break
end
- manager:machine():popmessage(input:seq_name(poller.sequence))
- manager:machine():video():frame_update(true)
+ manager.machine:popmessage(input:seq_name(poller.sequence))
+ manager.machine.video:frame_update()
end
end
if poller.modified and poller.valid then
cheat.hotkeys = { pressed = false, keys = poller.sequence }
end
if clearmsg then
- manager:machine():popmessage()
+ manager.machine:popmessage()
end
- manager:machine():video():frame_update(true)
+ manager.machine.video:frame_update()
end
for num, cheat in ipairs(cheats) do
if cheat.script then
- menu[#menu + 1] = {cheat.desc, cheat.hotkeys and manager:machine():input():seq_name(cheat.hotkeys.keys) or _("None"), ""}
+ menu[#menu + 1] = {cheat.desc, cheat.hotkeys and manager.machine.input:seq_name(cheat.hotkeys.keys) or _("None"), ""}
hotkeylist[#hotkeylist + 1] = function(event) return hkcbfunc(cheat, event) end
end
end
@@ -703,7 +703,7 @@ function cheat.startplugin()
end
local function menu_callback(index, event)
- manager:machine():popmessage()
+ manager.machine:popmessage()
if hotkeymenu then
if event == "select" or event == "clear" then
index = index - 3
@@ -745,7 +745,7 @@ function cheat.startplugin()
end
if event == "up" or event == "down" or event == "comment" then
if cheat.comment then
- manager:machine():popmessage(string.format(_("Cheat Comment:\n%s"), cheat.comment))
+ manager.machine:popmessage(string.format(_("Cheat Comment:\n%s"), cheat.comment))
end
elseif event == "left" then
if cheat.parameter then
@@ -779,9 +779,9 @@ function cheat.startplugin()
else
itemtext = cheat.parameter.value
end
- manager:machine():popmessage(string.format(_("Activated: %s = %s"), cheat.desc, itemtext))
+ manager.machine:popmessage(string.format(_("Activated: %s = %s"), cheat.desc, itemtext))
elseif not cheat.parameter and cheat.script.on then
- manager:machine():popmessage(string.format(_("Activated: %s"), cheat.desc))
+ manager.machine:popmessage(string.format(_("Activated: %s"), cheat.desc))
end
end
end
@@ -803,7 +803,7 @@ function cheat.startplugin()
start_time = emu.time()
cheats = load_cheats()
local json = require("json")
- local file = io.open(manager:machine():options().entries.cheatpath:value():match("([^;]+)") .. "/output.json", "w")
+ local file = io.open(manager.machine.options.entries.cheatpath:value():match("([^;]+)") .. "/output.json", "w")
if file then
file:write(json.stringify(cheats, {indent = true}))
file:close()
@@ -812,8 +812,8 @@ function cheat.startplugin()
parse_cheat(cheat)
end
load_hotkeys()
- if manager:machine():debugger() then
- consolelog = manager:machine():debugger().consolelog
+ if manager.machine.debugger then
+ consolelog = manager.machine.debugger.consolelog
consolelast = 0
end
end)
@@ -833,22 +833,22 @@ function cheat.startplugin()
run_if(cheat, cheat.script.run)
end
if cheat.hotkeys and cheat.hotkeys.keys then
- if manager:machine():input():seq_pressed(cheat.hotkeys.keys) then
+ if manager.machine.input:seq_pressed(cheat.hotkeys.keys) then
if not cheat.hotkeys.pressed then
if cheat.is_oneshot then
if not run_if(cheat, cheat.script.change) then
run_if(cheat, cheat.script.on)
end
- manager:machine():popmessage(string.format(_("Activated: %s"), cheat.desc))
+ manager.machine:popmessage(string.format(_("Activated: %s"), cheat.desc))
elseif not cheat.enabled then
cheat.enabled = true
run_if(cheat, cheat.script.on)
- manager:machine():popmessage(string.format(_("Enabled: %s"), cheat.desc))
+ manager.machine:popmessage(string.format(_("Enabled: %s"), cheat.desc))
else
cheat.enabled = false
run_if(cheat, cheat.script.off)
bwpclr(cheat)
- manager:machine():popmessage(string.format(_("Disabled: %s"), cheat.desc))
+ manager.machine:popmessage(string.format(_("Disabled: %s"), cheat.desc))
end
end
cheat.hotkeys.pressed = true
@@ -858,7 +858,7 @@ function cheat.startplugin()
end
end
for num, input in pairs(inputs) do
- local _, screen = next(manager:machine().screens)
+ local _, screen = next(manager.machine.screens)
local framenum = screen:frame_number() - input.begin
local enttab = input.start[framenum]
if enttab then
@@ -907,7 +907,7 @@ function cheat.startplugin()
function ce.inject(newcheat)
cheats[#cheats + 1] = newcheat
parse_cheat(newcheat)
- manager:machine():popmessage(string.format(_("%s added"), newcheat.desc))
+ manager.machine:popmessage(string.format(_("%s added"), newcheat.desc))
end
function ce.get(index)
@@ -922,7 +922,7 @@ function cheat.startplugin()
is_oneshot = cheat.is_oneshot,
comment = cheat.comment,
get_hotkeys = function() if cheat.hotkeys then return cheat.hotkeys.keys end return nil end,
- set_hotkeys = function(seq) cheat.hotkeys = { pressed = false, keys = manager:machine():input():seq_clean(seq) } end
+ set_hotkeys = function(seq) cheat.hotkeys = { pressed = false, keys = manager.machine.input:seq_clean(seq) } end
}
if cheat.script then
intf.script = {}