From 148ade15b98729f3c158b4b6accdfe5adee8ba06 Mon Sep 17 00:00:00 2001 From: Simen Svale Date: Tue, 30 Dec 2025 03:14:03 +0100 Subject: [PATCH] Fix MemoryGet command format per official VICE docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Official format: FX(1) + Start(2) + End(2) + Memspace(1) + BankID(2) = 8 bytes Our code had: FX(1) + Start(2) + Memspace(1) + End(2) = 6 bytes (wrong order, missing bank) This was causing error 0x81 "invalid parameter". 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/protocol/client.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/protocol/client.ts b/src/protocol/client.ts index c58ee88..05e9f45 100644 --- a/src/protocol/client.ts +++ b/src/protocol/client.ts @@ -380,12 +380,14 @@ export class ViceClient { ); } - // Build request: side_effects(1) + start(2) + memspace(1) + end(2) - const body = Buffer.alloc(6); + // Build request per official VICE docs: + // side_effects(1) + start(2) + end(2) + memspace(1) + bankId(2) = 8 bytes + const body = Buffer.alloc(8); body[0] = 0; // No side effects body.writeUInt16LE(startAddress, 1); - body[3] = memspace; - body.writeUInt16LE(endAddress, 4); + body.writeUInt16LE(endAddress, 3); + body[5] = memspace; + body.writeUInt16LE(0, 6); // bankId = 0 (default bank) // VICE sends MemoryGet response with type 0x01 const response = await this.sendCommand(Command.MemoryGet, body, ResponseType.MemoryGet);