From 40c2ecd1a57da39faeb2c67b2796858558281c7d Mon Sep 17 00:00:00 2001 From: Simen Svale Date: Tue, 30 Dec 2025 03:13:00 +0100 Subject: [PATCH] Fix response types per official VICE manual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our KB had wrong response type codes. Corrected per VICE docs: - MemoryGet = 0x01 (was 0x31) - RegisterInfo = 0x31 (was 0x62) - Stopped = 0x62 (was 0x11) - Resumed = 0x63 (was 0x12) This should fix readMemory timeouts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/protocol/client.ts | 9 +++++---- src/protocol/types.ts | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/protocol/client.ts b/src/protocol/client.ts index c1ee6ab..c58ee88 100644 --- a/src/protocol/client.ts +++ b/src/protocol/client.ts @@ -219,7 +219,8 @@ export class ViceClient { debugLog(`handleResponse: type=0x${response.responseType.toString(16)}, reqId=${response.requestId}`); // Check for async events (state changes) - if (response.responseType === ResponseType.Stopped || response.responseType === ResponseType.CheckpointHit) { + // Stopped = 0x62, which VICE sends when emulation stops + if (response.responseType === ResponseType.Stopped) { this.state.running = false; this.onStopped?.(response); // Don't return - this might also be a response to a pending request @@ -386,8 +387,8 @@ export class ViceClient { body[3] = memspace; body.writeUInt16LE(endAddress, 4); - // Try without async matching - maybe VICE sends MemoryGet with matched ReqID - const response = await this.sendCommand(Command.MemoryGet, body); + // VICE sends MemoryGet response with type 0x01 + const response = await this.sendCommand(Command.MemoryGet, body, ResponseType.MemoryGet); // Response body: length(2) + data(N) const dataLength = response.body.readUInt16LE(0); @@ -439,7 +440,7 @@ export class ViceClient { async getRegisters(memspace: MemorySpace = MemorySpace.MainCPU): Promise { const body = Buffer.alloc(1); body[0] = memspace; - // VICE sends RegisterInfo (0x62) as async event with ReqID=0xff + // VICE sends RegisterInfo (0x31) as async event with ReqID=0xff return this.sendCommand(Command.RegistersGet, body, ResponseType.RegisterInfo); } diff --git a/src/protocol/types.ts b/src/protocol/types.ts index 5e2f5b8..dffe215 100644 --- a/src/protocol/types.ts +++ b/src/protocol/types.ts @@ -49,16 +49,20 @@ export enum Command { AutoStart = 0xdd, } -// Response types +// Response types (per official VICE manual) export enum ResponseType { Invalid = 0x00, - Ok = 0x01, - Object = 0x02, - Stopped = 0x11, - Resumed = 0x12, - MemoryGet = 0x31, - RegisterInfo = 0x62, - CheckpointHit = 0x63, + MemoryGet = 0x01, // Memory read response + MemorySet = 0x02, // Memory write response + CheckpointResponse = 0x11, // Checkpoint set/get/delete response + CheckpointInfo = 0x12, // Checkpoint info + RegisterInfo = 0x31, // Register info (async event when stopped) + Dump = 0x41, + Undump = 0x42, + ResourceGet = 0x51, + ResourceSet = 0x52, + Stopped = 0x62, // Stopped event (async) + Resumed = 0x63, // Resumed event (async) } // Memory spaces