From 8dc66466ccf4bec371e06cc01fc5d6746f36866a Mon Sep 17 00:00:00 2001 From: sup39 Date: Mon, 27 Mar 2023 23:52:33 +0900 Subject: [PATCH] [v0.1.1] Fixed bug reading MEM2 --- CHANGELOG.md | 5 +++++ setup.cfg | 2 +- src/supDolphinWS/server/dolphin.py | 10 ++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..59a0100 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Change Log +## 0.1.1 (2023/03/27) +- Fixed bug reading MEM2 +## 0.1.0 (2023/03/09) +- Implemented WebSocket server diff --git a/setup.cfg b/setup.cfg index 066d579..c5275cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = supDolphinWS-server -version = 0.1.0 +version = 0.1.1 author = sup39 author_email = sms@sup39.dev description = A WebSocket server for accessing memory of emulated games in Dolphin diff --git a/src/supDolphinWS/server/dolphin.py b/src/supDolphinWS/server/dolphin.py index a54bb5d..63974c1 100644 --- a/src/supDolphinWS/server/dolphin.py +++ b/src/supDolphinWS/server/dolphin.py @@ -46,24 +46,26 @@ class Dolphin(): self.m = None def _read_bytes(self, addr, size): ''' - addr: int + addr: int|None size: int ''' + if addr is None: return None if MEM1_START <= addr <= MEM1_END-size: idx = addr-MEM1_START - elif MEM2_START <= addr <= MEM2_END-size and len(self.m) > MEM2_OFFSET: + elif MEM2_START <= addr <= MEM2_END-size and len(self.m.buf) > MEM2_OFFSET: idx = MEM2_OFFSET + addr-MEM2_START else: return None return self.m.buf[idx:idx+size].tobytes() def _write_bytes(self, addr, payload): ''' - addr: int + addr: int|None payload: bytes ''' + if addr is None: return None size = len(payload) if MEM1_START <= addr <= MEM1_END-size: idx = addr-MEM1_START - elif MEM2_START <= addr <= MEM2_END-size and len(self.m) > MEM2_OFFSET: + elif MEM2_START <= addr <= MEM2_END-size and len(self.m.buf) > MEM2_OFFSET: idx = MEM2_OFFSET + addr-MEM2_START else: return None self.m.buf[idx:idx+size] = payload