diff options
| author | 2016-04-10 21:42:33 -0500 | |
|---|---|---|
| committer | 2016-04-10 21:42:33 -0500 | |
| commit | d818313f8f75089ccf3bbf2697577ded9097c899 (patch) | |
| tree | cdb972f48000ab19e0ce84fbf5af8e11d761a5f1 | |
| parent | 5d8e00ae584833cd994168e0738f757e06e7cb7c (diff) | |
plugins/cheatfind: preliminary support to inject cheats for testing (nw)
| -rw-r--r-- | plugins/cheat/init.lua | 12 | ||||
| -rw-r--r-- | plugins/cheatfind/init.lua | 31 |
2 files changed, 42 insertions, 1 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index 0bd9427f8c0..2dee3677f34 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -462,6 +462,18 @@ function cheat.startplugin() end output = {} end) + + local ce = {} + + -- interface to script cheat engine + function ce.inject(newcheat) + cheats[#cheats + 1] = newcheat + parse_cheat(newcheat) + manager:machine():popmessage(newcheat.desc .. " added") + end + + _G.ce = ce + end return exports diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua index a777a908e36..eadcb5b6c42 100644 --- a/plugins/cheatfind/init.lua +++ b/plugins/cheatfind/init.lua @@ -347,6 +347,15 @@ function cheatfind.startplugin() end menu[#menu + 1] = { string.format("%08x" .. numform .. numform, match.addr, match.oldval, match.newval), "", 0 } + if not match.mode then + match.mode = 1 + end + if match.mode == 1 then + menu[#menu][2] = "Test" + else + menu[#menu][2] = "Write" + end + menu_lim(match.mode, 1, 2, menu[#menu]) end end end @@ -456,8 +465,28 @@ function cheatfind.startplugin() elseif index == midx.match then matchsel = incdec(matchsel, 0, #matches) elseif index > midx.match then + local match = matches[matchsel][index - midx.match] + match.mode = incdec(match.mode, 1, 2) if event == "select" then - -- write out a script? + local dev = devtable[devcur] + local cheat = { desc = string.format("Test cheat at addr %08x", match.addr), script = {} } + if dev.space.shortname then + cheat.ram = dev.tag + cheat.script.on = "ram:write(" .. match.addr .. "," .. match.newval .. ")" + else + cheat.space = { cpu = { tag = dev.tag, type = "program" } } + cheat.script.on = "cpu:write_u8(" .. match.addr .. "," .. match.newval .. ")" + end + if match.mode == 1 then + if not _G.ce then + manager:machine():popmessage("Cheat engine not available") + else + ce.inject(cheat) + end + else + + end + end end devsel = devcur |
