diff --git a/LinksAwakeningClient.py b/LinksAwakeningClient.py index 8f1cbc1e..f3fc9d2c 100644 --- a/LinksAwakeningClient.py +++ b/LinksAwakeningClient.py @@ -347,12 +347,13 @@ class LinksAwakeningClient(): f"Core type should be '{GAME_BOY}', found {core_type} instead - wrong type of ROM?") await asyncio.sleep(1.0) continue + self.stop_bizhawk_spam = False logger.info(f"Connected to Retroarch {version.decode('ascii')} running {rom_name.decode('ascii')}") return except (BlockingIOError, TimeoutError, ConnectionResetError): await asyncio.sleep(1.0) pass - self.stop_bizhawk_spam = False + async def reset_auth(self): auth = binascii.hexlify(await self.gameboy.async_read_memory(0x0134, 12)).decode() self.auth = auth diff --git a/data/lua/connector_ladx_bizhawk.lua b/data/lua/connector_ladx_bizhawk.lua index 038971be..6a5fbf70 100644 --- a/data/lua/connector_ladx_bizhawk.lua +++ b/data/lua/connector_ladx_bizhawk.lua @@ -43,13 +43,13 @@ local socket = require("socket") -local udp = socket.socket.udp() +udp = socket.socket.udp() require('common') udp:setsockname('127.0.0.1', 55355) udp:settimeout(0) -while true do +function on_vblank() -- 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. -- We could try to make use of client.get_approx_framerate() here, but the values returned @@ -112,6 +112,7 @@ while true do for _, v in ipairs(mem) do hex_string = hex_string .. string.format("%02X ", v) end + hex_string = hex_string:sub(1, -2) -- Hang head in shame, remove last " " local reply = string.format("%s %02x %s\n", command, address, hex_string) udp:sendto(reply, msg_or_ip, port_or_nil) @@ -135,6 +136,10 @@ while true do udp:sendto(reply, msg_or_ip, port_or_nil) end end - - emu.frameadvance() +end + +event.onmemoryexecute(on_vblank, 0x40, "ap_connector_vblank") + +while true do + emu.yield() end