From e4838f6d2b641e27d7cffdebe45d9850e50b870e Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 2 Nov 2021 11:11:57 +0100 Subject: [PATCH] LttPClient: add snes write command --- CommonClient.py | 1 + LttPClient.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CommonClient.py b/CommonClient.py index 9a928846..8d96f047 100644 --- a/CommonClient.py +++ b/CommonClient.py @@ -479,6 +479,7 @@ async def process_server_cmd(ctx: CommonContext, args: dict): elif cmd == "Bounced": tags = args.get("tags", []) + # we can skip checking "DeathLink" in ctx.tags, as otherwise we wouldn't have been send this if "DeathLink" in tags and ctx.last_death_link != args["data"]["time"]: ctx.on_deathlink(args["data"]) diff --git a/LttPClient.py b/LttPClient.py index d499afc3..f8ba296c 100644 --- a/LttPClient.py +++ b/LttPClient.py @@ -80,6 +80,18 @@ class LttPCommandProcessor(ClientCommandProcessor): else: return False + def _cmd_snes_write(self, address, data): + """Write the specified byte (base10) to the SNES' memory address (base16).""" + if self.ctx.snes_state != SNESState.SNES_ATTACHED: + self.output("No attached SNES Device.") + return False + + snes_buffered_write(self.ctx, int(address, 16), bytes([int(data)])) + asyncio.create_task(snes_flush_writes(self.ctx)) + self.output("Data Sent") + return True + + class Context(CommonContext): command_processor = LttPCommandProcessor game = "A Link to the Past"