mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
Cheat Finder Usability Improvements
1. Changes visual indications to make it nicer & quicker to use. 2. Adds selectable automatic pause capability to the cheat finder menu. 3. Allows the Test/Write poke to be changed 4. Adds another cheat format capability for cheat.simple (write support only)
This commit is contained in:
parent
24e192fc86
commit
87e633e039
@ -109,7 +109,6 @@ function cheatfind.startplugin()
|
|||||||
if (olddata.shift < 0) and (step < (1 << -olddata.shift)) then
|
if (olddata.shift < 0) and (step < (1 << -olddata.shift)) then
|
||||||
step = 1 << -olddata.shift;
|
step = 1 << -olddata.shift;
|
||||||
end
|
end
|
||||||
|
|
||||||
local cfoper = {
|
local cfoper = {
|
||||||
lt = function(a, b, val) return (a < b and val == 0) or (val > 0 and (a + val) == b) end,
|
lt = function(a, b, val) return (a < b and val == 0) or (val > 0 and (a + val) == b) end,
|
||||||
gt = function(a, b, val) return (a > b and val == 0) or (val > 0 and (a - val) == b) end,
|
gt = function(a, b, val) return (a > b and val == 0) or (val > 0 and (a - val) == b) end,
|
||||||
@ -260,18 +259,35 @@ function cheatfind.startplugin()
|
|||||||
local devtable = {}
|
local devtable = {}
|
||||||
local devsel = 1
|
local devsel = 1
|
||||||
local devcur = 1
|
local devcur = 1
|
||||||
local formtable = { " I1", " i1", "<I2", ">I2", "<i2", ">i2", "<I4", ">I4", "<i4", ">i4", "<I8", ">I8", "<i8", ">i8", }-- " <f", " >f", " <d", " >d" }
|
|
||||||
local formname = { "u8", "s8", "little u16", "big u16", "little s16", "big s16",
|
|
||||||
"little u32", "big u32", "little s32", "big s32", "little u64", "big u64", "little s64", "big s64", }
|
--local formtable = { " I1", " i1", "<I2", ">I2", "<i2", ">i2", "<I4", ">I4", "<i4", ">i4", "<I8", ">I8", "<i8", ">i8", }-- " <f", " >f", " <d", " >d" }
|
||||||
-- "little float", "big float", "little double", "big double" }
|
--local formname = { "u8", "s8", "little u16", "big u16", "little s16", "big s16",
|
||||||
|
-- "little u32", "big u32", "little s32", "big s32", "little u64", "big u64", "little s64", "big s64", }
|
||||||
|
-- -- "little float", "big float", "little double", "big double" }
|
||||||
|
-- Reordered into likelyhood of use order: unsigned byte by big endian unsigned by little endian unsigned then unsigned in same order
|
||||||
|
local formtable = { " I1", ">I2", ">I4", ">I8", "<I2", "<I4", "<I8", " i1", ">i2", ">i4", ">i8", "<i2", "<i4", "<i8", }-- " <f", " >f", " <d", " >d" }
|
||||||
|
local formname = { "u8", "big u16", "big u32", "big u64", "little u16", "little u32",
|
||||||
|
"little u64", "s8", "big s16", "big s32", "big s64", "little s16", "little s32", "little s64", }
|
||||||
|
|
||||||
local width = 1
|
local width = 1
|
||||||
local bcd = 0
|
local bcd = 0
|
||||||
local align = 0
|
local align = 0
|
||||||
local optable = { "lt", "gt", "eq", "ne", "beq", "bne", "ltv", "gtv", "eqv", "nev" }
|
local optable = { "lt", "gt", "eq", "ne", "beq", "bne", "ltv", "gtv", "eqv", "nev" }
|
||||||
local opsel = 1
|
local opsel = 1
|
||||||
local value = 0
|
local value = 0
|
||||||
local leftop = 2
|
local leftop = 1
|
||||||
local rightop = 1
|
local rightop = 1
|
||||||
|
local leftop_text = "Slot 1"
|
||||||
|
local rightop_text = "Slot 1"
|
||||||
|
local value_text = ""
|
||||||
|
local expression_text = "Slot 1 < Slot 1"
|
||||||
|
local pausetable = { "Automatic", "Manual" }
|
||||||
|
local pausesel = 1
|
||||||
|
local pokevaltable = { "Slot 1 Value", "Last Slot Value", "0x00", "0x01", "0x02", "0x03", "0x04", "0x05", "0x06", "0x07", "0x08", "0x09", "0x63 (Decimal 99)", "0x99 (BCD 99)",
|
||||||
|
"0xFF (Decimal 255)" , "0x3E7 (Decimal 999)", "0x999 (BCD 999)", "0x270F (Decimal 9999)", "0x9999 (BCD 9999)", "0xFFFF (Decimal 65535)" }
|
||||||
|
local pokevalsel = 1
|
||||||
|
|
||||||
local matches = {}
|
local matches = {}
|
||||||
local matchsel = 0
|
local matchsel = 0
|
||||||
local matchpg = 0
|
local matchpg = 0
|
||||||
@ -292,7 +308,7 @@ function cheatfind.startplugin()
|
|||||||
bcd = 0
|
bcd = 0
|
||||||
opsel = 1
|
opsel = 1
|
||||||
value = 0
|
value = 0
|
||||||
leftop = 2
|
leftop = 1
|
||||||
rightop = 1
|
rightop = 1
|
||||||
matches = {}
|
matches = {}
|
||||||
matchsel = 0
|
matchsel = 0
|
||||||
@ -335,7 +351,14 @@ function cheatfind.startplugin()
|
|||||||
|
|
||||||
emu.register_start(start)
|
emu.register_start(start)
|
||||||
|
|
||||||
|
local menu_is_showing = false
|
||||||
|
local tabbed_out = false
|
||||||
|
|
||||||
local function menu_populate()
|
local function menu_populate()
|
||||||
|
if pausesel == 1 then
|
||||||
|
emu.pause()
|
||||||
|
menu_is_showing = true
|
||||||
|
end
|
||||||
local menu = {}
|
local menu = {}
|
||||||
|
|
||||||
local function menu_prepare()
|
local function menu_prepare()
|
||||||
@ -433,6 +456,8 @@ function cheatfind.startplugin()
|
|||||||
file:close()
|
file:close()
|
||||||
file = io.open(cheat_save.path .. "/cheat.simple", "a")
|
file = io.open(cheat_save.path .. "/cheat.simple", "a")
|
||||||
file:write(string.format(cheat_save.simple, desc))
|
file:write(string.format(cheat_save.simple, desc))
|
||||||
|
-- old cheat .dat format, write support only (for cheat forum posting of new cheats if posted in simple format)
|
||||||
|
file:write(string.format(cheat_save.dat, desc))
|
||||||
file:close()
|
file:close()
|
||||||
manager:machine():popmessage(string.format(_("Cheat written to %s and added to cheat.simple"), filename))
|
manager:machine():popmessage(string.format(_("Cheat written to %s and added to cheat.simple"), filename))
|
||||||
end
|
end
|
||||||
@ -441,6 +466,8 @@ function cheatfind.startplugin()
|
|||||||
file = io.open(cheat_save.path .. "/cheat.simple", "a")
|
file = io.open(cheat_save.path .. "/cheat.simple", "a")
|
||||||
if file then
|
if file then
|
||||||
file:write(string.format(cheat_save.simple, desc))
|
file:write(string.format(cheat_save.simple, desc))
|
||||||
|
-- old cheat .dat format, write support only (for cheat forum posting of new cheats if posted in simple format)
|
||||||
|
file:write(string.format(cheat_save.dat, desc))
|
||||||
file:close()
|
file:close()
|
||||||
manager:machine():popmessage(_("Cheat added to cheat.simple"))
|
manager:machine():popmessage(_("Cheat added to cheat.simple"))
|
||||||
written = true
|
written = true
|
||||||
@ -473,6 +500,28 @@ function cheatfind.startplugin()
|
|||||||
return m, f
|
return m, f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
menu[#menu + 1] = function()
|
||||||
|
local m = { _("Pause Mode"), pausetable[pausesel], 0 }
|
||||||
|
menu_lim(pausesel, 1, pausetable, m)
|
||||||
|
local function f(event)
|
||||||
|
if (event == "left" or event == "right") then
|
||||||
|
if pausesel == 1 then
|
||||||
|
pausesel = 2
|
||||||
|
menu_is_showing = false
|
||||||
|
manager:machine():popmessage(_("Manually pause & unpause the game when needed with the pause hotkey"))
|
||||||
|
else
|
||||||
|
pausesel = 1
|
||||||
|
emu.pause()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return m, f
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
menu[#menu + 1] = function()
|
menu[#menu + 1] = function()
|
||||||
local function f(event)
|
local function f(event)
|
||||||
local ret = false
|
local ret = false
|
||||||
@ -484,16 +533,26 @@ function cheatfind.startplugin()
|
|||||||
menu_blocks[num] = {}
|
menu_blocks[num] = {}
|
||||||
menu_blocks[num][1] = cheat.save(devtable[devcur].space, region.offset, region.size)
|
menu_blocks[num][1] = cheat.save(devtable[devcur].space, region.offset, region.size)
|
||||||
end
|
end
|
||||||
manager:machine():popmessage(_("Data cleared and current state saved"))
|
manager:machine():popmessage(_("All slots cleared and current state saved to Slot 1"))
|
||||||
watches = {}
|
watches = {}
|
||||||
leftop = 2
|
opsel = 1
|
||||||
|
value = 0
|
||||||
|
leftop = 1
|
||||||
rightop = 1
|
rightop = 1
|
||||||
|
leftop_text = "Slot 1"
|
||||||
|
rightop_text = "Slot 1"
|
||||||
|
value_text = ""
|
||||||
|
expression_text = "Slot 1 < Slot 1"
|
||||||
matchsel = 0
|
matchsel = 0
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local opsel = 1
|
||||||
return { _("Start new search"), "", 0 }, f
|
return { _("Start new search"), "", 0 }, f
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if #menu_blocks ~= 0 then
|
if #menu_blocks ~= 0 then
|
||||||
menu[#menu + 1] = function() return { "---", "", "off" }, nil end
|
menu[#menu + 1] = function() return { "---", "", "off" }, nil end
|
||||||
menu[#menu + 1] = function()
|
menu[#menu + 1] = function()
|
||||||
@ -502,15 +561,28 @@ function cheatfind.startplugin()
|
|||||||
for num, region in ipairs(devtable[devcur].ram) do
|
for num, region in ipairs(devtable[devcur].ram) do
|
||||||
menu_blocks[num][#menu_blocks[num] + 1] = cheat.save(devtable[devcur].space, region.offset, region.size)
|
menu_blocks[num][#menu_blocks[num] + 1] = cheat.save(devtable[devcur].space, region.offset, region.size)
|
||||||
end
|
end
|
||||||
manager:machine():popmessage(_("Current state saved"))
|
manager:machine():popmessage(string.format(_("Memory State saved to Slot %d"), #menu_blocks[1]))
|
||||||
leftop = (leftop == #menu_blocks[1]) and #menu_blocks[1] + 1 or leftop
|
|
||||||
rightop = (rightop == #menu_blocks[1] - 1) and #menu_blocks[1] or rightop
|
if (leftop == #menu_blocks[1] - 1 and rightop == #menu_blocks[1] - 2 ) then
|
||||||
|
leftop = #menu_blocks[1]
|
||||||
|
rightop = #menu_blocks[1]-1
|
||||||
|
elseif (leftop == #menu_blocks[1] - 2 and rightop == #menu_blocks[1] - 1 ) then
|
||||||
|
leftop = #menu_blocks[1]-1
|
||||||
|
rightop = #menu_blocks[1]
|
||||||
|
elseif (leftop == #menu_blocks[1] - 1 ) then
|
||||||
|
leftop = #menu_blocks[1]
|
||||||
|
elseif (rightop == #menu_blocks[1] - 1) then
|
||||||
|
rightop = #menu_blocks[1]
|
||||||
|
end
|
||||||
|
leftop_text = string.format("Slot %d", leftop)
|
||||||
|
rightop_text = string.format("Slot %d", rightop)
|
||||||
devsel = devcur
|
devsel = devcur
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return { _("Save current -- #") .. #menu_blocks[1] + 1, "", 0 }, f
|
return { _("Save Current Memory State to Slot ") .. #menu_blocks[1] + 1, "", 0 }, f
|
||||||
end
|
end
|
||||||
|
menu[#menu + 1] = function() return { "---", "", "off" }, nil end
|
||||||
menu[#menu + 1] = function()
|
menu[#menu + 1] = function()
|
||||||
local function f(event)
|
local function f(event)
|
||||||
if event == "select" then
|
if event == "select" then
|
||||||
@ -526,26 +598,16 @@ function cheatfind.startplugin()
|
|||||||
if #matches == 0 then
|
if #matches == 0 then
|
||||||
matches[1] = {}
|
matches[1] = {}
|
||||||
for num = 1, #menu_blocks do
|
for num = 1, #menu_blocks do
|
||||||
if leftop == #menu_blocks[1] + 1 then
|
matches[1][num] = cheat.comp(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
||||||
matches[1][num] = cheat.compcur(menu_blocks[num][rightop], optable[opsel],
|
optable[opsel], formtable[width], value, bcd == 1, step)
|
||||||
formtable[width], value, bcd == 1, step)
|
|
||||||
else
|
|
||||||
matches[1][num] = cheat.comp(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
|
||||||
optable[opsel], formtable[width], value, bcd == 1, step)
|
|
||||||
end
|
|
||||||
count = count + #matches[1][num]
|
count = count + #matches[1][num]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lastmatch = matches[#matches]
|
lastmatch = matches[#matches]
|
||||||
matches[#matches + 1] = {}
|
matches[#matches + 1] = {}
|
||||||
for num = 1, #menu_blocks do
|
for num = 1, #menu_blocks do
|
||||||
if leftop == #menu_blocks[1] + 1 then
|
matches[#matches][num] = cheat.compnext(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
||||||
matches[#matches][num] = cheat.compcurnext(menu_blocks[num][rightop], lastmatch[num],
|
lastmatch[num], optable[opsel], formtable[width], value, bcd == 1, step)
|
||||||
optable[opsel], formtable[width], value, bcd == 1, step)
|
|
||||||
else
|
|
||||||
matches[#matches][num] = cheat.compnext(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
|
||||||
lastmatch[num], optable[opsel], formtable[width], value, bcd == 1, step)
|
|
||||||
end
|
|
||||||
count = count + #matches[#matches][num]
|
count = count + #matches[#matches][num]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -556,31 +618,64 @@ function cheatfind.startplugin()
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return { _("Compare"), "", 0 }, f
|
|
||||||
end
|
if optable[opsel] == "lt" then
|
||||||
menu[#menu + 1] = function()
|
if (value == 0 ) then
|
||||||
local m = { _("Left operand"), leftop, "" }
|
expression_text = string.format("%s < %s", leftop_text, rightop_text)
|
||||||
menu_lim(leftop, 1, #menu_blocks[1] + 1, m)
|
else
|
||||||
if leftop == #menu_blocks[1] + 1 then
|
expression_text = string.format("%s == %s - %d", leftop_text, rightop_text, value)
|
||||||
m[2] = _("Current")
|
end
|
||||||
|
elseif optable[opsel] == "gt" then
|
||||||
|
if (value == 0 ) then
|
||||||
|
expression_text = string.format("%s > %s", leftop_text, rightop_text)
|
||||||
|
else
|
||||||
|
expression_text = string.format("%s == %s + %d", leftop_text, rightop_text, value)
|
||||||
|
end
|
||||||
|
elseif optable[opsel] == "eq" then
|
||||||
|
expression_text = string.format("%s == %s", leftop_text, rightop_text)
|
||||||
|
elseif optable[opsel] == "ne" then
|
||||||
|
if (value == 0 ) then
|
||||||
|
expression_text = string.format("%s != %s", leftop_text, rightop_text)
|
||||||
|
else
|
||||||
|
expression_text = string.format("%s == %s +/- %d", leftop_text, rightop_text, value)
|
||||||
|
end
|
||||||
|
elseif optable[opsel] == "beq" then
|
||||||
|
expression_text = string.format("%s BITWISE== %s", leftop_text, rightop_text)
|
||||||
|
elseif optable[opsel] == "bne" then
|
||||||
|
expression_text = string.format("%s BITWISE!= %s", leftop_text, rightop_text)
|
||||||
|
elseif optable[opsel] == "ltv" then
|
||||||
|
expression_text = string.format("%s < %d", leftop_text, value)
|
||||||
|
elseif optable[opsel] == "gtv" then
|
||||||
|
expression_text = string.format("%s > %d", leftop_text, value)
|
||||||
|
elseif optable[opsel] == "eqv" then
|
||||||
|
expression_text = string.format("%s == %d", leftop_text, value)
|
||||||
|
elseif optable[opsel] == "nev" then
|
||||||
|
string.format("%s != %d", leftop_text, value)
|
||||||
end
|
end
|
||||||
return m, function(event) local r leftop, r = incdec(event, leftop, 1, #menu_blocks[1] + 1) return r end
|
return { _("Perform Compare : ") .. expression_text, "", 0 }, f
|
||||||
|
end
|
||||||
|
menu[#menu + 1] = function() return { "---", "", "off" }, nil end
|
||||||
|
menu[#menu + 1] = function()
|
||||||
|
local m = { _(leftop), "", 0 }
|
||||||
|
menu_lim(leftop, 1, #menu_blocks[1], m)
|
||||||
|
m[1] = string.format("Slot %d", leftop)
|
||||||
|
return m, function(event) local r leftop, r = incdec(event, leftop, 1, #menu_blocks[1]) leftop_text = "Slot " .. leftop return r end
|
||||||
end
|
end
|
||||||
menu[#menu + 1] = function()
|
menu[#menu + 1] = function()
|
||||||
local m = { _("Operator"), optable[opsel], "" }
|
local m = { _(optable[opsel]), "", 0 }
|
||||||
menu_lim(opsel, 1, #optable, m)
|
menu_lim(opsel, 1, #optable, m)
|
||||||
local function f(event)
|
local function f(event)
|
||||||
local r
|
local r
|
||||||
opsel, r = incdec(event, opsel, 1, #optable)
|
opsel, r = incdec(event, opsel, 1, #optable)
|
||||||
if event == "left" or event == "right" or event == "comment" then
|
if event == "left" or event == "right" or event == "comment" then
|
||||||
if optable[opsel] == "lt" then
|
if optable[opsel] == "lt" then
|
||||||
manager:machine():popmessage(_("Left less than right, value is difference"))
|
manager:machine():popmessage(_("Left less than right"))
|
||||||
elseif optable[opsel] == "gt" then
|
elseif optable[opsel] == "gt" then
|
||||||
manager:machine():popmessage(_("Left greater than right, value is difference"))
|
manager:machine():popmessage(_("Left greater than right"))
|
||||||
elseif optable[opsel] == "eq" then
|
elseif optable[opsel] == "eq" then
|
||||||
manager:machine():popmessage(_("Left equal to right"))
|
manager:machine():popmessage(_("Left equal to right"))
|
||||||
elseif optable[opsel] == "ne" then
|
elseif optable[opsel] == "ne" then
|
||||||
manager:machine():popmessage(_("Left not equal to right, value is difference"))
|
manager:machine():popmessage(_("Left not equal to right"))
|
||||||
elseif optable[opsel] == "beq" then
|
elseif optable[opsel] == "beq" then
|
||||||
manager:machine():popmessage(_("Left equal to right with bitmask"))
|
manager:machine():popmessage(_("Left equal to right with bitmask"))
|
||||||
elseif optable[opsel] == "bne" then
|
elseif optable[opsel] == "bne" then
|
||||||
@ -603,15 +698,21 @@ function cheatfind.startplugin()
|
|||||||
if optable[opsel]:sub(3, 3) == "v" then
|
if optable[opsel]:sub(3, 3) == "v" then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local m = { _("Right operand"), rightop, "" }
|
local m = { _(rightop), "", 0 }
|
||||||
menu_lim(rightop, 1, #menu_blocks[1], m)
|
menu_lim(rightop, 1, #menu_blocks[1], m)
|
||||||
return m, function(event) local r rightop, r = incdec(event, rightop, 1, #menu_blocks[1]) return r end
|
m[1] = string.format("Slot %d", rightop)
|
||||||
|
return m, function(event) local r rightop, r = incdec(event, rightop, 1, #menu_blocks[1]) rightop_text = "Slot " .. rightop return r end
|
||||||
end
|
end
|
||||||
menu[#menu + 1] = function()
|
menu[#menu + 1] = function()
|
||||||
if optable[opsel] == "bne" or optable[opsel] == "beq" or optable[opsel] == "eq" then
|
if optable[opsel] == "bne" or optable[opsel] == "beq" or optable[opsel] == "eq" then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local m = { _("Value"), value, "" }
|
local m
|
||||||
|
if optable[opsel] == "ltv" or optable[opsel] == "gtv" or optable[opsel] == "eqv" or optable[opsel] == "nev" then
|
||||||
|
m = { _("Value"), value, "" }
|
||||||
|
else
|
||||||
|
m = { _("Difference"), value, "" }
|
||||||
|
end
|
||||||
local max = 100 -- max value?
|
local max = 100 -- max value?
|
||||||
menu_lim(value, 0, max, m)
|
menu_lim(value, 0, max, m)
|
||||||
if value == 0 and optable[opsel]:sub(3, 3) ~= "v" then
|
if value == 0 and optable[opsel]:sub(3, 3) ~= "v" then
|
||||||
@ -625,6 +726,62 @@ function cheatfind.startplugin()
|
|||||||
menu_lim(width, 1, #formtable, m)
|
menu_lim(width, 1, #formtable, m)
|
||||||
return m, function(event) local r width, r = incdec(event, width, 1, #formtable) return r end
|
return m, function(event) local r width, r = incdec(event, width, 1, #formtable) return r end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
menu[#menu + 1] = function()
|
||||||
|
local m = { _("Test/Write Poke Value"), pokevaltable[pokevalsel], 0 }
|
||||||
|
menu_lim(pokevalsel, 1, #pokevaltable, m)
|
||||||
|
local function f(event)
|
||||||
|
local r
|
||||||
|
pokevalsel, r = incdec(event, pokevalsel, 1, #pokevaltable)
|
||||||
|
if event == "left" or event == "right" or event == "comment" then
|
||||||
|
if pokevalsel == 1 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke the Slot 1 value (eg. You started with something but lost it)"))
|
||||||
|
elseif pokevalsel == 2 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke the Last Slot value (eg. You started without an item but finally got it)"))
|
||||||
|
elseif pokevalsel == 3 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x00"))
|
||||||
|
elseif pokevalsel == 4 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x01"))
|
||||||
|
elseif pokevalsel == 5 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x02"))
|
||||||
|
elseif pokevalsel == 6 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x03"))
|
||||||
|
elseif pokevalsel == 7 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x04"))
|
||||||
|
elseif pokevalsel == 8 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x05"))
|
||||||
|
elseif pokevalsel == 9 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x06"))
|
||||||
|
elseif pokevalsel == 10 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x07"))
|
||||||
|
elseif pokevalsel == 11 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x08"))
|
||||||
|
elseif pokevalsel == 12 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x09"))
|
||||||
|
elseif pokevalsel == 13 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x63 (Decimal 99)"))
|
||||||
|
elseif pokevalsel == 14 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x99 (BCD 99)"))
|
||||||
|
elseif pokevalsel == 15 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0xFF (Decimal 255)"))
|
||||||
|
elseif pokevalsel == 16 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x3E7 (Decimal 999)"))
|
||||||
|
elseif pokevalsel == 17 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x999 (BCD 999)"))
|
||||||
|
elseif pokevalsel == 18 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x270F (Decimal 9999)"))
|
||||||
|
elseif pokevalsel == 19 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0x9999 (BCD 9999)"))
|
||||||
|
elseif pokevalsel == 20 then
|
||||||
|
manager:machine():popmessage(_("Use this if you want to poke 0xFFFF (Decimal 65535)"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
return m, f
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
menu[#menu + 1] = function()
|
menu[#menu + 1] = function()
|
||||||
if optable[opsel] == "bne" or optable[opsel] == "beq" then
|
if optable[opsel] == "bne" or optable[opsel] == "beq" then
|
||||||
return nil
|
return nil
|
||||||
@ -716,10 +873,66 @@ function cheatfind.startplugin()
|
|||||||
|
|
||||||
local function match_exec(match)
|
local function match_exec(match)
|
||||||
local dev = devtable[devcur]
|
local dev = devtable[devcur]
|
||||||
local cheat = { desc = string.format(_("Test cheat at addr %08X"), match.addr), script = {} }
|
|
||||||
local wid = formtable[width]:sub(3, 3)
|
local wid = formtable[width]:sub(3, 3)
|
||||||
local widchar
|
local widchar
|
||||||
|
local pokevalue
|
||||||
local form
|
local form
|
||||||
|
|
||||||
|
if pokevalsel == 1 then
|
||||||
|
pokevalue = match.oldval
|
||||||
|
elseif pokevalsel == 2 then
|
||||||
|
pokevalue = match.newval
|
||||||
|
elseif pokevalsel == 3 then
|
||||||
|
pokevalue = 0
|
||||||
|
elseif pokevalsel == 4 then
|
||||||
|
pokevalue = 1
|
||||||
|
elseif pokevalsel == 5 then
|
||||||
|
pokevalue = 2
|
||||||
|
elseif pokevalsel == 6 then
|
||||||
|
pokevalue = 3
|
||||||
|
elseif pokevalsel == 7 then
|
||||||
|
pokevalue = 4
|
||||||
|
elseif pokevalsel == 8 then
|
||||||
|
pokevalue = 5
|
||||||
|
elseif pokevalsel == 9 then
|
||||||
|
pokevalue = 6
|
||||||
|
elseif pokevalsel == 10 then
|
||||||
|
pokevalue = 7
|
||||||
|
elseif pokevalsel == 11 then
|
||||||
|
pokevalue = 8
|
||||||
|
elseif pokevalsel == 12 then
|
||||||
|
pokevalue = 9
|
||||||
|
elseif pokevalsel == 13 then
|
||||||
|
pokevalue = 99
|
||||||
|
elseif pokevalsel == 14 then
|
||||||
|
pokevalue = 153
|
||||||
|
elseif pokevalsel == 15 then
|
||||||
|
pokevalue = 255
|
||||||
|
elseif pokevalsel == 16 and wid == "1" then
|
||||||
|
pokevalue = 99
|
||||||
|
elseif pokevalsel == 17 and wid == "1" then
|
||||||
|
pokevalue = 153
|
||||||
|
elseif pokevalsel == 18 and wid == "1" then
|
||||||
|
pokevalue = 99
|
||||||
|
elseif pokevalsel == 19 and wid == "1" then
|
||||||
|
pokevalue = 153
|
||||||
|
elseif pokevalsel == 20 and wid == "1" then
|
||||||
|
pokevalue = 255
|
||||||
|
elseif pokevalsel == 16 then
|
||||||
|
pokevalue = 999
|
||||||
|
elseif pokevalsel == 17 then
|
||||||
|
pokevalue = 2457
|
||||||
|
elseif pokevalsel == 18 then
|
||||||
|
pokevalue = 9999
|
||||||
|
elseif pokevalsel == 19 then
|
||||||
|
pokevalue = 39321
|
||||||
|
elseif pokevalsel == 20 then
|
||||||
|
pokevalue = 65535
|
||||||
|
end
|
||||||
|
|
||||||
|
local cheat = { desc = string.format(_("Test Cheat %08X:%02X"), match.addr, pokevalue), script = {} }
|
||||||
|
|
||||||
if wid == "2" then
|
if wid == "2" then
|
||||||
wid = "u16"
|
wid = "u16"
|
||||||
form = "%08x %04x"
|
form = "%08x %04x"
|
||||||
@ -746,16 +959,15 @@ function cheatfind.startplugin()
|
|||||||
widchar = "b"
|
widchar = "b"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if getmetatable(dev.space).__name:match("device_t") then
|
if getmetatable(dev.space).__name:match("device_t") then
|
||||||
cheat.ram = { ram = dev.tag }
|
cheat.ram = { ram = dev.tag }
|
||||||
cheat.script.run = "ram:write(" .. match.addr .. "," .. match.newval .. ")"
|
cheat.script.run = "ram:write(" .. match.addr .. "," .. pokevalue .. ")"
|
||||||
elseif getmetatable(dev.space).__name:match("memory_share") then
|
elseif getmetatable(dev.space).__name:match("memory_share") then
|
||||||
cheat.share = { share = dev.tag }
|
cheat.share = { share = dev.tag }
|
||||||
cheat.script.run = "share:write_" .. wid .. "(" .. match.addr .. "," .. match.newval .. ")"
|
cheat.script.run = "share:write_" .. wid .. "(" .. match.addr .. "," .. pokevalue .. ")"
|
||||||
else
|
else
|
||||||
cheat.space = { cpu = { tag = dev.tag, type = dev.sname } }
|
cheat.space = { cpu = { tag = dev.tag, type = dev.sname } }
|
||||||
cheat.script.run = "cpu:write_" .. wid .. "(" .. match.addr .. "," .. match.newval .. ")"
|
cheat.script.run = "cpu:write_" .. wid .. "(" .. match.addr .. "," .. pokevalue .. ")"
|
||||||
end
|
end
|
||||||
if match.mode == 1 then
|
if match.mode == 1 then
|
||||||
if not _G.ce then
|
if not _G.ce then
|
||||||
@ -787,8 +999,9 @@ function cheatfind.startplugin()
|
|||||||
local json = require("json")
|
local json = require("json")
|
||||||
cheat.desc = "%s"
|
cheat.desc = "%s"
|
||||||
cheat_save.json = json.stringify({[1] = cheat}, {indent = true})
|
cheat_save.json = json.stringify({[1] = cheat}, {indent = true})
|
||||||
cheat_save.xml = string.format("<mamecheat version=\"1\">\n<cheat desc=\"%%s\">\n<script state=\"run\">\n<action>%s.pp%s@%X=%X</action>\n</script>\n</cheat>\n</mamecheat>", dev.tag:sub(2), widchar, match.addr, match.newval)
|
cheat_save.xml = string.format("<mamecheat version=\"1\">\n <cheat desc=\"%%s\">\n <script state=\"run\">\n <action>%s.pp%s@%X=%X</action>\n </script>\n </cheat>\n</mamecheat>", dev.tag:sub(2), widchar, match.addr, match.newval)
|
||||||
cheat_save.simple = string.format("%s,%s,%X,%s,%X,%%s\n", setname, dev.tag, match.addr, widchar, match.newval)
|
cheat_save.simple = string.format("%s,%s,%X,%s,%X,%%s\n", setname, dev.tag, match.addr, widchar, pokevalue)
|
||||||
|
cheat_save.dat = string.format(":%s:40000000:%X:%08X:FFFFFFFF:%%s\n", setname, match.addr, pokevalue)
|
||||||
manager:machine():popmessage(string.format(_("Default name is %s"), cheat_save.name))
|
manager:machine():popmessage(string.format(_("Default name is %s"), cheat_save.name))
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
@ -855,6 +1068,11 @@ function cheatfind.startplugin()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function menu_callback(index, event)
|
local function menu_callback(index, event)
|
||||||
|
if event == "cancel" and pausesel == 1 then
|
||||||
|
emu.unpause()
|
||||||
|
menu_is_showing = false
|
||||||
|
return {0,0,0}
|
||||||
|
end
|
||||||
return menu_func[index](event)
|
return menu_func[index](event)
|
||||||
end
|
end
|
||||||
emu.register_menu(menu_callback, menu_populate, _("Cheat Finder"))
|
emu.register_menu(menu_callback, menu_populate, _("Cheat Finder"))
|
||||||
@ -864,7 +1082,19 @@ function cheatfind.startplugin()
|
|||||||
for num, watch in ipairs(watches) do
|
for num, watch in ipairs(watches) do
|
||||||
screen:draw_text("left", num * height, string.format(watch.format, watch.addr, watch.func()))
|
screen:draw_text("left", num * height, string.format(watch.format, watch.addr, watch.func()))
|
||||||
end
|
end
|
||||||
|
if tabbed_out and manager:ui():is_menu_active() then
|
||||||
|
emu.pause()
|
||||||
|
menu_is_showing = true
|
||||||
|
tabbed_out = false
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
emu.register_periodic(function ()
|
||||||
|
if menu_is_showing and not manager:ui():is_menu_active() then
|
||||||
|
emu.unpause()
|
||||||
|
menu_is_showing = false
|
||||||
|
tabbed_out = true
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return exports
|
return exports
|
||||||
|
Loading…
Reference in New Issue
Block a user