LADX: fix bizhawk 2.9 (#1784)
This commit is contained in:
parent
a60f370224
commit
97fd78ba1b
|
@ -1,3 +1,5 @@
|
||||||
|
print("Loading AP lua connector script")
|
||||||
|
|
||||||
local lua_major, lua_minor = _VERSION:match("Lua (%d+)%.(%d+)")
|
local lua_major, lua_minor = _VERSION:match("Lua (%d+)%.(%d+)")
|
||||||
lua_major = tonumber(lua_major)
|
lua_major = tonumber(lua_major)
|
||||||
lua_minor = tonumber(lua_minor)
|
lua_minor = tonumber(lua_minor)
|
||||||
|
@ -101,3 +103,7 @@ function checkBizhawkVersion()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function stripPrefix(s, p)
|
||||||
|
return (s:sub(0, #p) == p) and s:sub(#p+1) or s
|
||||||
|
end
|
||||||
|
|
|
@ -43,12 +43,12 @@
|
||||||
|
|
||||||
|
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
local udp = socket.udp()
|
local udp = socket.socket.udp()
|
||||||
|
require('common')
|
||||||
|
|
||||||
udp:setsockname('127.0.0.1', 55355)
|
udp:setsockname('127.0.0.1', 55355)
|
||||||
udp:settimeout(0)
|
udp:settimeout(0)
|
||||||
|
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
-- Attempt to lessen the CPU load by only polling the UDP socket every x frames.
|
-- Attempt to lessen the CPU load by only polling the UDP socket every x frames.
|
||||||
-- x = 10 is entirely arbitrary, very little thought went into it.
|
-- x = 10 is entirely arbitrary, very little thought went into it.
|
||||||
|
@ -97,6 +97,7 @@ while true do
|
||||||
end
|
end
|
||||||
elseif command == "READ_CORE_MEMORY" then
|
elseif command == "READ_CORE_MEMORY" then
|
||||||
local _, address, length = string.match(data, "(%S+) (%S+) (%S+)")
|
local _, address, length = string.match(data, "(%S+) (%S+) (%S+)")
|
||||||
|
address = stripPrefix(address, "0x")
|
||||||
address = tonumber(address, 16)
|
address = tonumber(address, 16)
|
||||||
length = tonumber(length)
|
length = tonumber(length)
|
||||||
|
|
||||||
|
@ -116,12 +117,14 @@ while true do
|
||||||
udp:sendto(reply, msg_or_ip, port_or_nil)
|
udp:sendto(reply, msg_or_ip, port_or_nil)
|
||||||
elseif command == "WRITE_CORE_MEMORY" then
|
elseif command == "WRITE_CORE_MEMORY" then
|
||||||
local _, address = string.match(data, "(%S+) (%S+)")
|
local _, address = string.match(data, "(%S+) (%S+)")
|
||||||
|
address = stripPrefix(address, "0x")
|
||||||
address = tonumber(address, 16)
|
address = tonumber(address, 16)
|
||||||
|
|
||||||
local to_write = {}
|
local to_write = {}
|
||||||
local i = 1
|
local i = 1
|
||||||
for byte_str in string.gmatch(data, "%S+") do
|
for byte_str in string.gmatch(data, "%S+") do
|
||||||
if i > 2 then
|
if i > 2 then
|
||||||
|
byte_str = stripPrefix(byte_str, "0x")
|
||||||
table.insert(to_write, tonumber(byte_str, 16))
|
table.insert(to_write, tonumber(byte_str, 16))
|
||||||
end
|
end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
|
@ -58,6 +58,8 @@ else
|
||||||
_ENV = M -- for 5.2
|
_ENV = M -- for 5.2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.socket = socket
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Exported auxiliar functions
|
-- Exported auxiliar functions
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue