mirror of
https://github.com/holub/mame
synced 2025-06-07 21:33:45 +03:00
luaengine: add optional arg for physical address space to disable address shift (nw)
---- Cheats created with the cheatfinder won't work with the builtin cheat finder if the cpu has an address bus that isn't 8bits unless the addresses are fixed up.
This commit is contained in:
parent
4c20f32839
commit
bccd9ad271
@ -65,10 +65,10 @@ function cheatfind.startplugin()
|
|||||||
local j = 1
|
local j = 1
|
||||||
for i = start, start + size do
|
for i = start, start + size do
|
||||||
if j < 65536 then
|
if j < 65536 then
|
||||||
temp[j] = string.pack("B", space:read_u8(i))
|
temp[j] = string.pack("B", space:read_u8(i, true))
|
||||||
j = j + 1
|
j = j + 1
|
||||||
else
|
else
|
||||||
block = block .. table.concat(temp) .. string.pack("B", space:read_u8(i))
|
block = block .. table.concat(temp) .. string.pack("B", space:read_u8(i, true))
|
||||||
temp = {}
|
temp = {}
|
||||||
j = 1
|
j = 1
|
||||||
end
|
end
|
||||||
@ -604,7 +604,7 @@ function cheatfind.startplugin()
|
|||||||
cheat.script.run = "ram:write(" .. match.addr .. "," .. match.newval .. ")"
|
cheat.script.run = "ram:write(" .. match.addr .. "," .. match.newval .. ")"
|
||||||
else
|
else
|
||||||
cheat.space = { cpu = { tag = dev.tag, type = "program" } }
|
cheat.space = { cpu = { tag = dev.tag, type = "program" } }
|
||||||
cheat.script.run = "cpu:write_" .. wid .. "(" .. match.addr .. "," .. match.newval .. ")"
|
cheat.script.run = "cpu:write_" .. wid .. "(" .. match.addr .. "," .. match.newval .. ", true)"
|
||||||
end
|
end
|
||||||
if match.mode == 1 then
|
if match.mode == 1 then
|
||||||
if not _G.ce then
|
if not _G.ce then
|
||||||
|
@ -929,9 +929,11 @@ int lua_engine::lua_addr_space::l_mem_read(lua_State *L)
|
|||||||
lua_addr_space &lsp = luabridge::Stack<lua_addr_space &>::get(L, 1);
|
lua_addr_space &lsp = luabridge::Stack<lua_addr_space &>::get(L, 1);
|
||||||
address_space &sp = lsp.space;
|
address_space &sp = lsp.space;
|
||||||
luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected");
|
luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected");
|
||||||
|
luaL_argcheck(L, lua_isboolean(L, 3) || lua_isnone(L, 3), 3, "optional argument: disable address shift (bool) expected");
|
||||||
offs_t address = lua_tounsigned(L, 2);
|
offs_t address = lua_tounsigned(L, 2);
|
||||||
T mem_content = 0;
|
T mem_content = 0;
|
||||||
address = sp.address_to_byte(address);
|
if(!lua_toboolean(L, 3))
|
||||||
|
address = sp.address_to_byte(address);
|
||||||
switch(sizeof(mem_content) * 8) {
|
switch(sizeof(mem_content) * 8) {
|
||||||
case 8:
|
case 8:
|
||||||
mem_content = sp.read_byte(address);
|
mem_content = sp.read_byte(address);
|
||||||
@ -983,10 +985,11 @@ int lua_engine::lua_addr_space::l_mem_write(lua_State *L)
|
|||||||
address_space &sp = lsp.space;
|
address_space &sp = lsp.space;
|
||||||
luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected");
|
luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected");
|
||||||
luaL_argcheck(L, lua_isnumber(L, 3), 3, "value (integer) expected");
|
luaL_argcheck(L, lua_isnumber(L, 3), 3, "value (integer) expected");
|
||||||
|
luaL_argcheck(L, lua_isboolean(L, 4) || lua_isnone(L, 4), 4, "optional argument: disable address shift (bool) expected");
|
||||||
offs_t address = lua_tounsigned(L, 2);
|
offs_t address = lua_tounsigned(L, 2);
|
||||||
T val = lua_tounsigned(L, 3);
|
T val = lua_tounsigned(L, 3);
|
||||||
address = sp.address_to_byte(address);
|
if(!lua_toboolean(L, 4))
|
||||||
|
address = sp.address_to_byte(address);
|
||||||
switch(sizeof(val) * 8) {
|
switch(sizeof(val) * 8) {
|
||||||
case 8:
|
case 8:
|
||||||
sp.write_byte(address, val);
|
sp.write_byte(address, val);
|
||||||
|
Loading…
Reference in New Issue
Block a user