plugins/cheat: Migrate remaining XML cheat code for Lua API changes.

This commit is contained in:
Vas Crabb 2021-01-01 01:31:12 +11:00
parent 9c961d992a
commit 525f744b38

View File

@ -76,7 +76,7 @@ function xml.conv_cheat(data)
local function convert_memref(cpu, phys, space, width, addr, rw)
-- debug expressions address spaces by index not by name
local function get_space_name(index)
local prefix = cpu:sub(1,1)
local prefix = cpu:sub(1, 1)
if prefix == ":" then
return cpu_spaces[cpu][index]
else
@ -85,7 +85,6 @@ function xml.conv_cheat(data)
end
local mod = ""
local count
if space == "p" then
fullspace = get_space_name(0)
elseif space == "d" then
@ -94,11 +93,11 @@ function xml.conv_cheat(data)
fullspace = get_space_name(2)
elseif space == "r" then
fullspace = get_space_name(0)
mod = "direct_"
mod = "_direct"
space = "p"
elseif space == "o" then
fullspace = get_space_name(3)
mod = "direct_"
mod = "_direct"
space = "o"
end
if width == "b" then
@ -122,14 +121,15 @@ function xml.conv_cheat(data)
else
spaces[cpuname .. space] = { tag = ":" .. cpu, type = fullspace }
if phys ~= "p" and mod == "" then
mod = "log_"
mod = "v"
end
end
local ret
if rw == "=" then
write = true
ret = cpuname .. space .. ":" .. "write_" .. mod .. width .. "(" .. addr .. ","
ret = string.format("%s%s:write%s_%s(%s,", cpuname, space, mod, width, addr)
else
ret = cpuname .. space .. ":" .. "read_" .. mod .. width .. "(" .. addr .. ")"
ret = string.format("%s%s:read%s_%s(%s)", cpuname, space, mod, width, addr)
end
if rw == "==" then
ret = ret .. "=="
@ -161,6 +161,7 @@ function xml.conv_cheat(data)
data = data:gsub("%f[%w](%x+)%f[%W]", "0x%1")
-- 0?x? avoids an issue where db (data region byte) is interepeted as a hex number
data = data:gsub("([%w_:]-)%.(p?)0?x?([pmrodi3])([bwdq])@(%w+) *(=*)", convert_memref)
local count
repeat
data, count = data:gsub("([%w_:]-)%.(p?)0?x?([pmrodi3])([bwdq])@(%b()) *(=*)", convert_memref)
until count == 0