summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/cheat
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2017-06-30 14:15:57 -0500
committer cracyc <cracyc@users.noreply.github.com>2017-06-30 14:15:57 -0500
commit38a74a3ae0789e5611c08fe7cc4811d193bd9ac0 (patch)
tree4734156756913c46bbd7340a2b399e5a9763435f /plugins/cheat
parente57ceef92754b5ec0b1eb5faa006d8e578997fcd (diff)
plugins/cheat: link simple cheats
Diffstat (limited to 'plugins/cheat')
-rw-r--r--plugins/cheat/cheat_simple.lua41
1 files changed, 31 insertions, 10 deletions
diff --git a/plugins/cheat/cheat_simple.lua b/plugins/cheat/cheat_simple.lua
index 104798416bc..f82bff0f98f 100644
--- a/plugins/cheat/cheat_simple.lua
+++ b/plugins/cheat/cheat_simple.lua
@@ -1,5 +1,5 @@
-- converter for simple cheats
--- simple cheats are single address every frame ram, rom or gg,ar cheats in one file called cheat.simple
+-- simple cheats are single/linked address every frame ram, rom or gg,ar cheats in one file called cheat.simple
--
-- ram/rom cheat format: <set name>,<cputag|regiontag>,<hex offset>,<b|w|d|q - size>,<hex value>,<desc>
-- only program address space is supported, comments are prepended with ;
@@ -22,10 +22,30 @@ function simple.filename(name)
end
local codefuncs = {}
+local currcheat
local function prepare_rom_cheat(desc, region, addr, val, size, banksize, comp)
- local cheat = { desc = desc, region = { rom = region } }
- cheat.script = { off = "if on then rom:write_u" .. size .. "(addr, save) end" }
+ local cheat
+ if desc:sub(1,1) ~= "^" then
+ currcheat = { desc = desc, region = { rom = region } }
+ currcheat.script = { off = string.format([[
+ if on then
+ for k, v in pairs(addrs) do
+ rom:write_u%d(v.addr, v.save)
+ end
+ end]], size),
+ on = string.format([[
+ addrs = {
+ --flag
+ }
+ on = true
+ for k, v in pairs(addrs) do
+ v.save = rom:read_u%d(v.addr)
+ rom:write_u%d(v.addr, v.val)
+ end]], size, size) }
+ cheat = currcheat
+
+ end
if banksize and comp then
local rom = manager:machine():memory().regions[region]
local bankaddr = addr & (banksize - 1)
@@ -43,17 +63,17 @@ local function prepare_rom_cheat(desc, region, addr, val, size, banksize, comp)
error("rom cheat compare value not found " .. desc)
end
end
- cheat.script.on = string.format([[
- on = true
- addr = %d
- save = rom:read_u%d(addr)
- rom:write_u%d(addr, %d)]], addr, size, size, val)
+ currcheat.script.on = currcheat.script.on:gsub("%-%-flag", string.format("{addr = %d, val = %d},\n--flag", addr, val), 1)
return cheat
end
local function prepare_ram_cheat(desc, tag, addr, val, size)
- local cheat = { desc = desc, space = { cpup = { tag = tag, type = "program" } } }
- cheat.script = { run = "cpup:write_u" .. size .. "(" .. addr .. "," .. val .. ", true)" }
+ local cheat
+ if desc:sub(1,1) ~= "^" then
+ currcheat = { desc = desc, space = { cpup = { tag = tag, type = "program" } }, script = { run = "" } }
+ cheat = currcheat
+ end
+ currcheat.script.run = currcheat.script.run .. " cpup:write_u" .. size .. "(" .. addr .. "," .. val .. ", true)"
return cheat
end
@@ -292,6 +312,7 @@ function simple.conv_cheat(data)
end
end
end
+ currcheat = nil
return cheats
end