summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-07-13 17:13:32 -0500
committer cracyc <cracyc@users.noreply.github.com>2016-07-13 17:13:32 -0500
commit62f2777ce2631f1cddd73d785f7885f0df5afc64 (patch)
tree11809de7579584e4c8f658f8936ef0d10606999a /plugins
parent24d749545cfc7ed4184e584f6b06b52b6c64555c (diff)
mark working
----------- Digital Equipment Corporation VT240 [Carl] vt240: fix scroll and complement (nw) plugins/cheat: add simple cheat file format (nw)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/cheat/init.lua10
-rw-r--r--plugins/cheat/simple_conv.lua23
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
+