Skip to content

LADX: Fix getting old items over and over again in Bizhawk #2011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LinksAwakeningClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,13 @@ async def wait_for_retroarch_connection(self):
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
Expand Down
11 changes: 8 additions & 3 deletions data/lua/connector_ladx_bizhawk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -135,6 +136,10 @@ while true do
udp:sendto(reply, msg_or_ip, port_or_nil)
end
end
end

emu.frameadvance()
event.onmemoryexecute(on_vblank, 0x40, "ap_connector_vblank")

while true do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The emu.yield() loop should not be needed here, and is probably just burning cycles since there is now an event callback registered. Is there a reason for this I'm missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed on my machine and should have minimal perf impact

emu.yield()
end