Commit graph

10 commits

Author SHA1 Message Date
Simen Svale
40c2ecd1a5 Fix response types per official VICE manual
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 <noreply@anthropic.com>
2025-12-30 03:13:00 +01:00
Simen Svale
067ec7af24 Try removing async matching for MemoryGet
Testing if VICE sends MemoryGet responses with matched ReqID
instead of as async events (ReqID=0xff).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:11:49 +01:00
Simen Svale
caa3bc8e22 Fix async event handling for VICE API v1
VICE API v1 sends some responses (RegisterInfo, MemoryGet) as async
events with ReqID=0xff instead of matched responses. This caused
timeouts because we were waiting for responses with our request ID.

Fix: Match async responses (ReqID=0xff) to pending requests by
expected response type instead of request ID.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 03:01:54 +01:00
Simen Svale
995683a936 Fix VICE protocol: API v1, correct command codes, body length
Multiple fixes based on live testing:
- API version changed to 0x01 (VICE 3.x uses v1, not v2)
- Command codes updated per KB docs:
  - RegistersGet: 0x22 (was 0x31)
  - Continue: 0x31 (was 0x81)
  - Step: 0x32 (was 0x82)
- Body length field now excludes ReqID and Cmd (just command body)
- Response parsing: totalLength = 9 + bodyLength

Added test script for debugging protocol issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:55:10 +01:00
Simen Svale
0a6982ae40 Fix VICE protocol: 1-byte request ID, correct header sizes
Per KB docs, the actual protocol format is:
- Request: STX(1) + API(1) + Length(4) + ReqID(1) + Cmd(1) + Body (header = 8)
- Response: STX(1) + API(1) + Length(4) + Type(1) + Error(1) + ReqID(1) + Body (header = 9)

Previous fix incorrectly used 4-byte request IDs. Also added debug
logging to stderr to help diagnose protocol issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:47:49 +01:00
Simen Svale
3fece5cb1e Fix VICE binary protocol packet format
The request ID field is 4 bytes (not 1), and the packet structure was
incorrect:
- Request: STX(1) + API(1) + Length(4) + ReqID(4) + Cmd(1) + Body
- Response: STX(1) + API(1) + Length(4) + Type(1) + Error(1) + ReqID(4) + Body

This was causing all commands after connect() to timeout because response
matching was reading the wrong bytes for the request ID.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:44:27 +01:00
Simen Svale
76a1069436 Add visual feedback tools
Protocol layer:
- Add DisplayGet command (0x84) for screen capture
- Add PaletteGet command (0x91) for color palette
- Implement getDisplay() and getPalette() client methods

New tools:
- screenshot: Capture display as indexed pixel data with palette
  - Returns base64-encoded pixel buffer for efficient transfer
  - Includes display dimensions and visible area bounds
  - Optionally includes RGB palette values
- renderScreen: ASCII art representation of current display
  - Converts pixel luminance to ASCII shading characters
  - Configurable output dimensions and character set
  - Useful for quick visual debugging in text-only contexts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:05:52 +01:00
Simen Svale
cebe6f4a14 Add advanced debugging tools
Protocol layer:
- Add watchpoint support (setWatchpoint, toggleCheckpoint, listWatchpoints)
- Add snapshot methods (saveSnapshot, loadSnapshot)
- Add autostart support
- Update command codes to match VICE binary monitor protocol
- Refactor BreakpointInfo to CheckpointInfo for unified handling

New tools:
- toggleBreakpoint: Enable/disable breakpoints without deleting
- setWatchpoint: Memory read/write watchpoints
- listWatchpoints: Show active watchpoints
- runTo: Run until specific address (temporary breakpoint)
- disassemble: 6502 disassembler with KERNAL/BASIC labels
- saveSnapshot/loadSnapshot: Machine state persistence
- loadProgram: Autostart PRG/D64/T64 files

Utilities:
- Add full 6502 disassembler with all addressing modes
- Include KERNAL/BASIC entry point labels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:04:23 +01:00
Simen Svale
84b10689d0 Address AX review feedback
- Fix status hint: clarify step() vs setBreakpoint+continue for pausing
- Add flag string to getRegisters: "NV-BDIZC" format (uppercase=set)
- Add listBreakpoints tool with local breakpoint tracking
- Track breakpoints in client for listing support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:53:16 +01:00
Simen Svale
32eb8f3c17 Add VICE binary protocol layer and core debugging tools
Protocol layer (src/protocol/):
- TCP socket client with connection management
- Binary packet encoding/decoding per VICE monitor protocol
- Async response handling and request ID tracking
- Proper error handling with actionable suggestions

MCP tools implemented:
- status: Connection and emulation state
- connect/disconnect: VICE session management
- readMemory/writeMemory: Memory access with hex dump formatting
- getRegisters: CPU state with decoded flags
- step/continue: Execution control
- reset: Machine reset (soft/hard)
- setBreakpoint/deleteBreakpoint: Breakpoint management

AX patterns integrated:
- _meta block in all responses (connection state context)
- Structured output (value + hex + hint where relevant)
- Rich tool descriptions with cross-references
- Actionable error messages with suggestions
- Memory region hints for common addresses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:50:27 +01:00