diff options
Diffstat (limited to 'plugins/cheat')
| -rw-r--r-- | plugins/cheat/init.lua | 10 | ||||
| -rw-r--r-- | plugins/cheat/simple_conv.lua | 23 |
2 files changed, 31 insertions, 2 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index e2d44150e22..303ffad6ffd 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -71,7 +71,6 @@ function cheat.startplugin() local function load_cheats() local filename = emu.romname() - local json = require("json") local newcheats = {} local file = emu.file(manager:machine():options().entries.cheatpath:value():gsub("([^;]+)", "%1;%1/cheat") , 1) if emu.softname() ~= "" then @@ -81,7 +80,7 @@ function cheat.startplugin() end end end - function add(addcheats) + local function add(addcheats) if not next(newcheats) then newcheats = addcheats else @@ -90,6 +89,7 @@ function cheat.startplugin() end end end + local json = require("json") local ret = file:open(filename .. ".json") while not ret do add(json.parse(file:read(file:size()))) @@ -101,6 +101,12 @@ function cheat.startplugin() add(xml.conv_cheat(file:read(file:size()))) ret = file:open_next() end + local simp = require("cheat/simple_conv") + ret = file:open("cheat.simple") + while not ret do + add(simp.conv_cheat(filename, file:read(file:size()))) + ret = file:open_next() + end return newcheats end diff --git a/plugins/cheat/simple_conv.lua b/plugins/cheat/simple_conv.lua new file mode 100644 index 00000000000..1fad3d7dfea --- /dev/null +++ b/plugins/cheat/simple_conv.lua @@ -0,0 +1,23 @@ +local simple = {} + +-- converter for simple cheats +-- simple cheats are single address every frame ram cheats in one file called cheat.simple +-- format: <set name>,<cputag>,<hex offset>,<hex value>,<desc> +-- only program address space is supported, comments are prepended with ; +function simple.conv_cheat(romset, data) + local cheats = {} + for line in data:gmatch('([^\n;]+)') do + local set, cputag, offset, val, name = line:match('([^,]+),([^,]+),([^,]+),([^,]+),(.+)') + if set == romset then + local cheat = {} + cheat.desc = name + cheat.space = { cpup = { tag = cputag, type = "program" } } + cheat.script = { run = "cpup:write_u8(0x" .. offset .. ",0x" .. val .. ", true)" } + cheats[#cheats + 1] = cheat + end + end + return cheats +end + +return simple + |
