mirror of
https://github.com/holub/mame
synced 2025-07-02 00:29:37 +03:00
plugins/cheatfind: yet more changes (nw)
This commit is contained in:
parent
262524206b
commit
1d31d7c55f
@ -230,10 +230,10 @@ function cheatfind.startplugin()
|
|||||||
local leftop = 2
|
local leftop = 2
|
||||||
local rightop = 1
|
local rightop = 1
|
||||||
local matches = {}
|
local matches = {}
|
||||||
local matchsel = 1
|
local matchsel = 0
|
||||||
local menu_blocks = {}
|
local menu_blocks = {}
|
||||||
local midx = { region = 1, init = 2, lop = 4, op = 5, rop = 6, val = 7,
|
local midx = { region = 1, init = 2, save = 4, comp = 5, lop = 6, op = 7, rop = 8, val = 9,
|
||||||
width = 9, bcd = 10, undo = 11, save = 12, comp = 13, match = 15, watch = 0 }
|
width = 11, bcd = 12, undo = 13, match = 15, watch = 0 }
|
||||||
local watches = {}
|
local watches = {}
|
||||||
|
|
||||||
local function start()
|
local function start()
|
||||||
@ -247,7 +247,7 @@ function cheatfind.startplugin()
|
|||||||
leftop = 2
|
leftop = 2
|
||||||
rightop = 1
|
rightop = 1
|
||||||
matches = {}
|
matches = {}
|
||||||
matchsel = 1
|
matchsel = 0
|
||||||
menu_blocks = {}
|
menu_blocks = {}
|
||||||
watches = {}
|
watches = {}
|
||||||
|
|
||||||
@ -299,6 +299,8 @@ function cheatfind.startplugin()
|
|||||||
menu[midx.init] = { "Start new search", "", 0 }
|
menu[midx.init] = { "Start new search", "", 0 }
|
||||||
if #menu_blocks ~= 0 then
|
if #menu_blocks ~= 0 then
|
||||||
menu[midx.init + 1] = { "---", "", "off" }
|
menu[midx.init + 1] = { "---", "", "off" }
|
||||||
|
menu[midx.save] = { "Save current -- #" .. #menu_blocks[1] + 1, "", 0 }
|
||||||
|
menu[midx.comp] = { "Compare", "", 0 }
|
||||||
menu[midx.lop] = { "Left operand", leftop, "" }
|
menu[midx.lop] = { "Left operand", leftop, "" }
|
||||||
menu_lim(leftop, 1, #menu_blocks[1] + 1, menu[midx.lop])
|
menu_lim(leftop, 1, #menu_blocks[1] + 1, menu[midx.lop])
|
||||||
if leftop == #menu_blocks[1] + 1 then
|
if leftop == #menu_blocks[1] + 1 then
|
||||||
@ -322,18 +324,41 @@ function cheatfind.startplugin()
|
|||||||
menu[midx.bcd][2] = "On"
|
menu[midx.bcd][2] = "On"
|
||||||
end
|
end
|
||||||
menu[midx.undo] = { "Undo last search -- #" .. #matches, "", 0 }
|
menu[midx.undo] = { "Undo last search -- #" .. #matches, "", 0 }
|
||||||
menu[midx.save] = { "Save current -- #" .. #menu_blocks[1] + 1, "", 0 }
|
|
||||||
menu[midx.comp] = { "Compare", "", 0 }
|
|
||||||
if #matches ~= 0 then
|
if #matches ~= 0 then
|
||||||
menu[midx.comp + 1] = { "---", "", "off" }
|
menu[midx.undo + 1] = { "---", "", "off" }
|
||||||
menu[midx.match] = { "Match block", matchsel, "" }
|
menu[midx.match] = { "Match block", matchsel, "" }
|
||||||
if #matches[#matches] == 1 then
|
menu_lim(matchsel, 0, #matches[#matches], menu[midx.match])
|
||||||
menu[midx.match][3] = 0
|
if matchsel == 0 then
|
||||||
else
|
menu[midx.match][2] = "All"
|
||||||
menu_lim(matchsel, 1, #matches[#matches], menu[midx.match])
|
|
||||||
end
|
end
|
||||||
for num2, match in ipairs(matches[#matches][matchsel]) do
|
local function mpairs(sel, list)
|
||||||
if #menu > 50 then
|
if #list == 0 then
|
||||||
|
return function() end, nil, nil
|
||||||
|
end
|
||||||
|
if sel ~= 0 then
|
||||||
|
return ipairs(list[sel])
|
||||||
|
end
|
||||||
|
local function mpairs_it(list, i)
|
||||||
|
local match
|
||||||
|
i = i + 1
|
||||||
|
local sel = i
|
||||||
|
for j = 1, #list do
|
||||||
|
if sel <= #list[j] then
|
||||||
|
match = list[j][sel]
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sel = sel - #list[j]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not match then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return i, match
|
||||||
|
end
|
||||||
|
return mpairs_it, list, 0
|
||||||
|
end
|
||||||
|
for num2, match in mpairs(matchsel, matches[#matches]) do
|
||||||
|
if #menu > 100 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local numform = ""
|
local numform = ""
|
||||||
@ -402,6 +427,7 @@ function cheatfind.startplugin()
|
|||||||
watches = {}
|
watches = {}
|
||||||
leftop = 2
|
leftop = 2
|
||||||
rightop = 1
|
rightop = 1
|
||||||
|
matchsel = 0
|
||||||
ret = true
|
ret = true
|
||||||
end
|
end
|
||||||
devcur = devsel
|
devcur = devsel
|
||||||
@ -458,6 +484,7 @@ function cheatfind.startplugin()
|
|||||||
bcd = incdec(bcd, 0, 1)
|
bcd = incdec(bcd, 0, 1)
|
||||||
elseif index == midx.comp then
|
elseif index == midx.comp then
|
||||||
if event == "select" then
|
if event == "select" then
|
||||||
|
local count = 0
|
||||||
if #matches == 0 then
|
if #matches == 0 then
|
||||||
matches[1] = {}
|
matches[1] = {}
|
||||||
for num = 1, #menu_blocks do
|
for num = 1, #menu_blocks do
|
||||||
@ -468,6 +495,7 @@ function cheatfind.startplugin()
|
|||||||
matches[1][num] = cheat.comp(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
matches[1][num] = cheat.comp(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
||||||
optable[opsel], formtable[width], value, bcd == 1)
|
optable[opsel], formtable[width], value, bcd == 1)
|
||||||
end
|
end
|
||||||
|
count = count + #matches[1][num]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lastmatch = matches[#matches]
|
lastmatch = matches[#matches]
|
||||||
@ -480,9 +508,10 @@ function cheatfind.startplugin()
|
|||||||
matches[#matches][num] = cheat.compnext(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
matches[#matches][num] = cheat.compnext(menu_blocks[num][leftop], menu_blocks[num][rightop],
|
||||||
lastmatch[num], optable[opsel], formtable[width], value, bcd == 1)
|
lastmatch[num], optable[opsel], formtable[width], value, bcd == 1)
|
||||||
end
|
end
|
||||||
|
count = count + #matches[#matches][num]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
manager:machine():popmessage(#matches[#matches] .. " found" .. ((#matches[#matches] > 50) and ", first 50 shown" or ""))
|
manager:machine():popmessage(count .. " total matches found")
|
||||||
ret = true
|
ret = true
|
||||||
end
|
end
|
||||||
elseif index == midx.match then
|
elseif index == midx.match then
|
||||||
@ -491,7 +520,20 @@ function cheatfind.startplugin()
|
|||||||
watches = {}
|
watches = {}
|
||||||
ret = true
|
ret = true
|
||||||
elseif index > midx.match then
|
elseif index > midx.match then
|
||||||
local match = matches[#matches][matchsel][index - midx.match]
|
local match
|
||||||
|
if matchsel == 0 then
|
||||||
|
local sel = index - midx.match
|
||||||
|
for i = 1, #matches[#matches] do
|
||||||
|
if sel <= #matches[#matches][i] then
|
||||||
|
match = matches[#matches][i][sel]
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sel = sel - #matches[#matches][i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
match = matches[#matches][matchsel][index - midx.match]
|
||||||
|
end
|
||||||
match.mode = incdec(match.mode, 1, 3)
|
match.mode = incdec(match.mode, 1, 3)
|
||||||
if event == "select" then
|
if event == "select" then
|
||||||
local dev = devtable[devcur]
|
local dev = devtable[devcur]
|
||||||
@ -555,6 +597,7 @@ function cheatfind.startplugin()
|
|||||||
watches[#watches + 1] = { addr = match.addr, func = load(func, func, "t", env), format = form }
|
watches[#watches + 1] = { addr = match.addr, func = load(func, func, "t", env), format = form }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
ret = true
|
||||||
end
|
end
|
||||||
devsel = devcur
|
devsel = devcur
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user