c64bridge 0.8.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/.github/prompts/steer.prompt.md +55 -0
  2. package/AGENTS.md +9 -7
  3. package/README.md +192 -154
  4. package/data/embeddings_asm.json +1 -1
  5. package/data/embeddings_basic.json +1 -1
  6. package/data/embeddings_hardware.json +1 -1
  7. package/data/embeddings_mixed.json +1 -1
  8. package/data/embeddings_other.json +1 -1
  9. package/data/graphics/petscii-style-guide.md +4 -4
  10. package/data/graphics/sprite-charset-best-practices.md +9 -9
  11. package/data/vice/vice-binary-monitor-spec.md +938 -0
  12. package/dist/.tsbuildinfo +1 -1
  13. package/dist/c64Client.js +76 -2
  14. package/dist/device.js +129 -13
  15. package/dist/mcp-server.js +1 -1
  16. package/dist/prompts/registry.js +27 -25
  17. package/dist/rag/indexer.js +18 -8
  18. package/dist/rag/knowledgeIndex.js +112 -79
  19. package/dist/rag/resourceUris.js +93 -0
  20. package/dist/sidwaveCompiler.js +1 -1
  21. package/dist/{assemblyConverter.js → tools/assember.js} +10 -1
  22. package/dist/tools/audio.js +11 -11
  23. package/dist/{basicConverter.js → tools/basicTokenizer.js} +1 -1
  24. package/dist/tools/debug.js +159 -6
  25. package/dist/tools/developer.js +13 -13
  26. package/dist/tools/disassembler.js +478 -0
  27. package/dist/tools/graphics.js +10 -10
  28. package/dist/tools/input.js +338 -0
  29. package/dist/tools/machineControl.js +5 -5
  30. package/dist/tools/memory.js +336 -12
  31. package/dist/tools/meta/index.js +1 -1
  32. package/dist/tools/printer.js +11 -12
  33. package/dist/tools/programRunners.js +61 -22
  34. package/dist/tools/rag.js +9 -9
  35. package/dist/tools/registry/batch.js +167 -0
  36. package/dist/tools/registry/config.js +1 -1
  37. package/dist/tools/registry/disk.js +1 -1
  38. package/dist/tools/registry/drive.js +1 -1
  39. package/dist/tools/registry/extract.js +1 -1
  40. package/dist/tools/registry/graphics.js +102 -2
  41. package/dist/tools/registry/index.js +4 -0
  42. package/dist/tools/registry/input.js +2 -0
  43. package/dist/tools/registry/memory.js +62 -2
  44. package/dist/tools/registry/platform.js +1 -1
  45. package/dist/tools/registry/printer.js +1 -1
  46. package/dist/tools/registry/program.js +1 -1
  47. package/dist/tools/registry/rag.js +1 -1
  48. package/dist/tools/registry/sound.js +1 -1
  49. package/dist/tools/registry/stream.js +1 -1
  50. package/dist/tools/registry/system.js +1 -1
  51. package/dist/tools/schema.js +4 -5
  52. package/dist/tools/storage.js +15 -15
  53. package/dist/tools/streaming.js +3 -3
  54. package/dist/tools/symbolRegistry.js +49 -0
  55. package/dist/tools/types.js +56 -4
  56. package/dist/tools/vice.js +2 -5
  57. package/dist/vice/process.js +120 -2
  58. package/dist/vice/readiness.js +35 -0
  59. package/dist/vice/smokeOptions.js +44 -0
  60. package/dist/vice/viceClient.js +5 -1
  61. package/dist/viceRunner.js +2 -0
  62. package/doc/plans/prompts/README.md +7 -7
  63. package/mcp/prompts.json +42 -59
  64. package/mcp/protocol-examples.json +2 -2
  65. package/mcp/resources.json +179 -166
  66. package/mcp/schemas/c64_batch.schema.json +53 -0
  67. package/mcp/schemas/c64_config.schema.json +525 -283
  68. package/mcp/schemas/c64_debug.schema.json +763 -304
  69. package/mcp/schemas/c64_disk.schema.json +499 -243
  70. package/mcp/schemas/c64_drive.schema.json +165 -90
  71. package/mcp/schemas/c64_extract.schema.json +533 -274
  72. package/mcp/schemas/c64_graphics.schema.json +607 -295
  73. package/mcp/schemas/c64_input.schema.json +136 -0
  74. package/mcp/schemas/c64_memory.schema.json +637 -128
  75. package/mcp/schemas/c64_printer.schema.json +393 -196
  76. package/mcp/schemas/c64_program.schema.json +699 -340
  77. package/mcp/schemas/c64_rag.schema.json +100 -54
  78. package/mcp/schemas/c64_select_backend.schema.json +49 -23
  79. package/mcp/schemas/c64_sound.schema.json +1092 -577
  80. package/mcp/schemas/c64_stream.schema.json +89 -47
  81. package/mcp/schemas/c64_system.schema.json +351 -185
  82. package/mcp/schemas/c64_vice.schema.json +85 -47
  83. package/mcp/server.json +1 -1
  84. package/mcp/tools.json +7299 -3346
  85. package/mcp.json +3 -3
  86. package/package.json +17 -14
  87. package/scripts/fetch-external-sources.mjs +1 -2
  88. package/scripts/run-coverage.mjs +33 -1
  89. package/scripts/run-tests.mjs +2 -2
  90. package/scripts/run-tests.ts +275 -52
  91. package/scripts/update-readme.ts +132 -3
  92. package/server.json +2 -2
@@ -0,0 +1,938 @@
1
+ # VICE Binary Monitor Specification
2
+
3
+ ## Purpose
4
+
5
+ This document is a concise implementation reference for C64 Bridge maintainers and LLM agents that need to understand how the VICE backend maps to the VICE binary monitor protocol.
6
+
7
+ For normal MCP use, agents should call the existing C64 Bridge tools instead of constructing VICE packets directly.
8
+
9
+ Recommended C64 Bridge entry points:
10
+
11
+ | Need | C64 Bridge tool | Typical operation |
12
+ |---|---|---|
13
+ | Select the VICE backend | `c64_select_backend` | `select` |
14
+ | Read or write memory | `c64_memory` | `read`, `write`, `read_screen`, `wait_for_text` |
15
+ | Debug registers and checkpoints | `c64_debug` | `get_registers`, `set_registers`, `create_checkpoint`, `list_checkpoints`, `step`, `step_return` |
16
+ | Send keyboard or joystick input | `c64_input` | `write_text`, `key`, `joystick` |
17
+ | Capture emulator display | `c64_graphics` | `capture_frame` |
18
+ | Reset or resume execution | `c64_system` | `reset`, `resume` |
19
+ | Read or write VICE resources | `c64_vice` | `resource_get`, `resource_set` |
20
+
21
+ ---
22
+
23
+ ## Core Protocol Rules
24
+
25
+ - The VICE binary monitor uses a dedicated connection configured with `-binarymonitor` and `-binarymonitoraddress`.
26
+ - Every packet starts with `STX = 0x02`.
27
+ - There is no packet terminator.
28
+ - Packet boundaries are determined by the length field in the frame header.
29
+ - Current API version: `0x02`.
30
+ - All multibyte integers are little-endian.
31
+ - Boolean fields use `0x00 = false`, `>= 0x01 = true`.
32
+ - Direct responses echo the command `request_id`.
33
+ - Responses with `request_id = 0xffffffff` are asynchronous events.
34
+ - Commands may cause asynchronous monitor-entry events before the direct command response.
35
+ - Register IDs and bank IDs are machine-dependent. Do not hard-code them.
36
+ - Use `REGISTERS_AVAILABLE` and `BANKS_AVAILABLE` to resolve IDs.
37
+ - Many array items include an item-size field. Use it to skip future extensions.
38
+
39
+ ---
40
+
41
+ ## Notation
42
+
43
+ | Notation | Meaning |
44
+ |---|---|
45
+ | `u8` | 1 byte unsigned |
46
+ | `u16` | 2 byte unsigned, little-endian |
47
+ | `u32` | 4 byte unsigned, little-endian |
48
+ | `u64` | 8 byte unsigned, little-endian |
49
+ | `bytes[N]` | exactly `N` bytes |
50
+ | `str[N]` | `N` bytes, not null-terminated unless stated otherwise |
51
+ | `FIELD?` | optional field |
52
+ | `ITEM[N]` | `N` repeated items |
53
+
54
+ ---
55
+
56
+ ## Common Values
57
+
58
+ ### Memspace
59
+
60
+ | Value | Meaning |
61
+ |---:|---|
62
+ | `0x00` | Main machine memory |
63
+ | `0x01` | Drive 8 |
64
+ | `0x02` | Drive 9 |
65
+ | `0x03` | Drive 10 |
66
+ | `0x04` | Drive 11 |
67
+
68
+ ### Generic Errors
69
+
70
+ | Code | Meaning |
71
+ |---:|---|
72
+ | `0x00` | OK |
73
+ | `0x01` | Object does not exist |
74
+ | `0x02` | Invalid memspace |
75
+ | `0x80` | Incorrect command length |
76
+ | `0x81` | Invalid parameter value |
77
+ | `0x82` | Unsupported API version |
78
+ | `0x83` | Unknown command type |
79
+ | `0x8f` | General failure after basic validation |
80
+
81
+ Always check the response error code before decoding the body.
82
+
83
+ ---
84
+
85
+ ## Command Frame
86
+
87
+ ```text
88
+ Offset Size Field
89
+ 0 1 STX = 0x02
90
+ 1 1 API version = 0x02
91
+ 2 4 Command body length as u32
92
+ 6 4 Request ID as u32
93
+ 10 1 Command type as u8
94
+ 11 N Command body
95
+ ````
96
+
97
+ ```text
98
+ command_body_length = total_command_packet_length - 11
99
+ ```
100
+
101
+ The command length excludes the whole command header.
102
+
103
+ ---
104
+
105
+ ## Response Frame
106
+
107
+ ```text
108
+ Offset Size Field
109
+ 0 1 STX = 0x02
110
+ 1 1 API version = 0x02
111
+ 2 4 Response body length as u32
112
+ 6 1 Response type as u8
113
+ 7 1 Error code as u8
114
+ 8 4 Request ID as u32
115
+ 12 N Response body
116
+ ```
117
+
118
+ ```text
119
+ response_body_length = total_response_packet_length - 12
120
+ ```
121
+
122
+ For asynchronous events:
123
+
124
+ ```text
125
+ request_id = 0xffffffff
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Forward-Compatible Arrays
131
+
132
+ Common array pattern:
133
+
134
+ ```text
135
+ COUNT | ITEM[COUNT]
136
+ ```
137
+
138
+ Common item pattern:
139
+
140
+ ```text
141
+ IS:u8 | ITEM_BODY[IS]
142
+ ```
143
+
144
+ `IS` is the item body size and excludes the `IS` byte itself. Use `IS` to skip unknown future fields.
145
+
146
+ ---
147
+
148
+ # Commands
149
+
150
+ ## `0x01` - Memory Get
151
+
152
+ Reads memory from inclusive range `[SA..EA]`.
153
+
154
+ ```text
155
+ cmd: FX:u8 | SA:u16 | EA:u16 | MS:u8 | BI:u16
156
+ rsp: 0x01 | ML:u16 | MM:bytes[ML]
157
+ ```
158
+
159
+ | Field | Meaning |
160
+ | ----- | ------------------------ |
161
+ | `FX` | Read causes side effects |
162
+ | `SA` | Start address |
163
+ | `EA` | End address, inclusive |
164
+ | `MS` | Memspace |
165
+ | `BI` | Bank ID |
166
+ | `ML` | Memory length |
167
+ | `MM` | Memory bytes |
168
+
169
+ For `$0000..$ffff`, `ML` may be `0`, meaning 65536 bytes.
170
+
171
+ C64 Bridge mapping:
172
+
173
+ | MCP tool | Operation |
174
+ | ------------ | --------------- |
175
+ | `c64_memory` | `read` |
176
+ | `c64_memory` | `read_screen` |
177
+ | `c64_memory` | `wait_for_text` |
178
+
179
+ ---
180
+
181
+ ## `0x02` - Memory Set
182
+
183
+ Writes memory to inclusive range `[SA..EA]`.
184
+
185
+ ```text
186
+ cmd: FX:u8 | SA:u16 | EA:u16 | MS:u8 | BI:u16 | MM:bytes[EA-SA+1]
187
+ rsp: 0x02 | empty
188
+ ```
189
+
190
+ C64 Bridge mapping:
191
+
192
+ | MCP tool | Operation |
193
+ | ------------ | --------- |
194
+ | `c64_memory` | `write` |
195
+
196
+ ---
197
+
198
+ ## `0x11` - Checkpoint Get
199
+
200
+ Gets a breakpoint, watchpoint, or tracepoint by checkpoint number.
201
+
202
+ ```text
203
+ cmd: CN:u32
204
+ rsp: 0x11 | CHECKPOINT_INFO
205
+ ```
206
+
207
+ C64 Bridge mapping:
208
+
209
+ | MCP tool | Operation |
210
+ | ----------- | ---------------- |
211
+ | `c64_debug` | `get_checkpoint` |
212
+
213
+ ---
214
+
215
+ ## `0x12` - Checkpoint Set
216
+
217
+ Creates a breakpoint, watchpoint, or tracepoint.
218
+
219
+ ```text
220
+ cmd: SA:u16 | EA:u16 | ST:u8 | EN:u8 | OP:u8 | TM:u8 | MS?:u8
221
+ rsp: 0x11 | CHECKPOINT_INFO
222
+ ```
223
+
224
+ | Field | Meaning |
225
+ | ----- | --------------------------------- |
226
+ | `ST` | Stop when hit |
227
+ | `EN` | Enabled |
228
+ | `OP` | Operation bitmask |
229
+ | `TM` | Temporary, delete after first hit |
230
+ | `MS` | Optional memspace |
231
+
232
+ `OP`: `0x01 = load`, `0x02 = store`, `0x04 = exec`.
233
+
234
+ Use `0x22 CONDITION_SET` after creation to add a condition.
235
+
236
+ C64 Bridge mapping:
237
+
238
+ | MCP tool | Operation |
239
+ | ----------- | ------------------- |
240
+ | `c64_debug` | `create_checkpoint` |
241
+
242
+ ---
243
+
244
+ ## `0x13` - Checkpoint Delete
245
+
246
+ ```text
247
+ cmd: CN:u32
248
+ rsp: 0x13 | empty
249
+ ```
250
+
251
+ C64 Bridge mapping:
252
+
253
+ | MCP tool | Operation |
254
+ | ----------- | ------------------- |
255
+ | `c64_debug` | `delete_checkpoint` |
256
+
257
+ ---
258
+
259
+ ## `0x14` - Checkpoint List
260
+
261
+ ```text
262
+ cmd: empty
263
+ rsp: zero or more 0x11 CHECKPOINT_INFO, then 0x14 | CC:u32
264
+ ```
265
+
266
+ `CC` is total checkpoint count.
267
+
268
+ C64 Bridge mapping:
269
+
270
+ | MCP tool | Operation |
271
+ | ----------- | ------------------ |
272
+ | `c64_debug` | `list_checkpoints` |
273
+
274
+ ---
275
+
276
+ ## `0x15` - Checkpoint Toggle
277
+
278
+ ```text
279
+ cmd: CN:u32 | EN:u8
280
+ rsp: 0x15 | empty
281
+ ```
282
+
283
+ C64 Bridge mapping:
284
+
285
+ | MCP tool | Operation |
286
+ | ----------- | ------------------- |
287
+ | `c64_debug` | `toggle_checkpoint` |
288
+
289
+ ---
290
+
291
+ ## `0x22` - Condition Set
292
+
293
+ Sets a text-monitor condition expression on an existing checkpoint.
294
+
295
+ ```text
296
+ cmd: CN:u32 | EL:u8 | ES:str[EL]
297
+ rsp: 0x22 | empty
298
+ ```
299
+
300
+ `ES` is not null-terminated. Conditions cannot currently be retrieved.
301
+
302
+ C64 Bridge mapping:
303
+
304
+ | MCP tool | Operation |
305
+ | ----------- | --------------- |
306
+ | `c64_debug` | `set_condition` |
307
+
308
+ ---
309
+
310
+ ## `0x31` - Registers Get
311
+
312
+ ```text
313
+ cmd: MS:u8
314
+ rsp: 0x31 | REGISTER_INFO
315
+ ```
316
+
317
+ C64 Bridge mapping:
318
+
319
+ | MCP tool | Operation |
320
+ | ----------- | --------------- |
321
+ | `c64_debug` | `get_registers` |
322
+
323
+ ---
324
+
325
+ ## `0x32` - Registers Set
326
+
327
+ ```text
328
+ cmd: MS:u8 | RC:u16 | ITEM[RC]
329
+ item: IS:u8 | RI:u8 | RV:u16
330
+ rsp: 0x31 | REGISTER_INFO
331
+ ```
332
+
333
+ Register IDs are machine-dependent. Query `0x83 REGISTERS_AVAILABLE`.
334
+
335
+ C64 Bridge mapping:
336
+
337
+ | MCP tool | Operation |
338
+ | ----------- | --------------- |
339
+ | `c64_debug` | `set_registers` |
340
+
341
+ ---
342
+
343
+ ## `0x41` - Dump
344
+
345
+ Saves emulator state to a snapshot file.
346
+
347
+ ```text
348
+ cmd: SR:u8 | SD:u8 | FL:u8 | FN:str[FL]
349
+ rsp: 0x41 | empty
350
+ ```
351
+
352
+ `SR = save ROMs`, `SD = save disks`.
353
+
354
+ No primary public C64 Bridge MCP mapping is listed in the README API reference.
355
+
356
+ ---
357
+
358
+ ## `0x42` - Undump
359
+
360
+ Loads emulator state from a snapshot file.
361
+
362
+ ```text
363
+ cmd: FL:u8 | FN:str[FL]
364
+ rsp: 0x42 | PC:u16
365
+ ```
366
+
367
+ No primary public C64 Bridge MCP mapping is listed in the README API reference.
368
+
369
+ ---
370
+
371
+ ## `0x51` - Resource Get
372
+
373
+ ```text
374
+ cmd: NL:u8 | RN:str[NL]
375
+ rsp: 0x51 | RT:u8 | VL:u8 | RV:bytes[VL]
376
+ ```
377
+
378
+ `RT`: `0x00 = string`, `0x01 = integer`.
379
+
380
+ C64 Bridge mapping:
381
+
382
+ | MCP tool | Operation |
383
+ | ---------- | -------------- |
384
+ | `c64_vice` | `resource_get` |
385
+
386
+ ---
387
+
388
+ ## `0x52` - Resource Set
389
+
390
+ ```text
391
+ cmd: RT:u8 | NL:u8 | RN:str[NL] | VL:u8 | RV:bytes[VL]
392
+ rsp: 0x52 | empty
393
+ ```
394
+
395
+ `RT`: `0x00 = string`, `0x01 = integer`.
396
+
397
+ C64 Bridge mapping:
398
+
399
+ | MCP tool | Operation |
400
+ | ---------- | -------------- |
401
+ | `c64_vice` | `resource_set` |
402
+
403
+ ---
404
+
405
+ ## `0x71` - Advance Instructions
406
+
407
+ Steps over a number of instructions.
408
+
409
+ ```text
410
+ cmd: SO:u8 | IC:u16
411
+ rsp: 0x71 | empty
412
+ ```
413
+
414
+ `SO` means step over subroutines.
415
+
416
+ C64 Bridge mapping:
417
+
418
+ | MCP tool | Operation |
419
+ | ----------- | --------- |
420
+ | `c64_debug` | `step` |
421
+
422
+ ---
423
+
424
+ ## `0x72` - Keyboard Feed
425
+
426
+ Adds PETSCII text to the keyboard buffer.
427
+
428
+ ```text
429
+ cmd: TL:u8 | TC:bytes[TL]
430
+ rsp: 0x72 | empty
431
+ ```
432
+
433
+ C64 Bridge mapping:
434
+
435
+ | MCP tool | Operation |
436
+ | ----------- | ------------ |
437
+ | `c64_input` | `write_text` |
438
+ | `c64_input` | `key` |
439
+
440
+ Public input tools inject PETSCII through the shared KERNAL keyboard queue for cross-platform parity. The VICE backend still exposes BM `0x72` internally via `ViceClient.keyboardFeed()` when a direct monitor call is needed.
441
+
442
+ ---
443
+
444
+ ## `0x73` - Execute Until Return
445
+
446
+ Continues execution until just after the next `RTS` or `RTI`.
447
+
448
+ ```text
449
+ cmd: empty
450
+ rsp: 0x73 | empty
451
+ ```
452
+
453
+ Equivalent to the text monitor `return` command.
454
+
455
+ C64 Bridge mapping:
456
+
457
+ | MCP tool | Operation |
458
+ | ----------- | ------------- |
459
+ | `c64_debug` | `step_return` |
460
+
461
+ ---
462
+
463
+ ## `0x81` - Ping
464
+
465
+ ```text
466
+ cmd: empty
467
+ rsp: 0x81 | empty
468
+ ```
469
+
470
+ Used internally for VICE connectivity checks.
471
+
472
+ ---
473
+
474
+ ## `0x82` - Banks Available
475
+
476
+ Lists machine-specific bank IDs and names.
477
+
478
+ ```text
479
+ cmd: empty
480
+ rsp: 0x82 | BC:u16 | ITEM[BC]
481
+ item: IS:u8 | BI:u16 | NL:u8 | BN:str[NL]
482
+ ```
483
+
484
+ Usually internal to the VICE backend. Required for robust banked memory support.
485
+
486
+ ---
487
+
488
+ ## `0x83` - Registers Available
489
+
490
+ Lists machine-specific register IDs and names.
491
+
492
+ ```text
493
+ cmd: MS:u8
494
+ rsp: 0x83 | RC:u16 | ITEM[RC]
495
+ item: IS:u8 | RI:u8 | RS:u8 | NL:u8 | RN:str[NL]
496
+ ```
497
+
498
+ `RS` is register size in bits.
499
+
500
+ C64 Bridge mapping:
501
+
502
+ | MCP tool | Operation |
503
+ | ----------- | ---------------- |
504
+ | `c64_debug` | `list_registers` |
505
+
506
+ ---
507
+
508
+ ## `0x84` - Display Get
509
+
510
+ Gets the current display buffer.
511
+
512
+ ```text
513
+ cmd: VC:u8 | FM:u8
514
+ rsp: 0x84 | FL:u32 | DW:u16 | DH:u16 | XO:u16 | YO:u16 | IW:u16 | IH:u16 | BP:u8 | BL:u32 | BD:bytes[BL]
515
+ ```
516
+
517
+ | Field | Meaning |
518
+ | --------- | -------------------------------------------------------- |
519
+ | `VC` | C128 only: true = VIC-II, false = VDC. Ignored otherwise |
520
+ | `FM` | Format. `0x00 = indexed 8-bit` |
521
+ | `DW`,`DH` | Uncropped display size |
522
+ | `XO`,`YO` | Inner display offset |
523
+ | `IW`,`IH` | Inner display size |
524
+ | `BP` | Bits per pixel |
525
+ | `BD` | Display buffer |
526
+
527
+ C64 Bridge mapping:
528
+
529
+ | MCP tool | Operation |
530
+ | -------------- | --------------- |
531
+ | `c64_graphics` | `capture_frame` |
532
+
533
+ ---
534
+
535
+ ## `0x85` - VICE Info
536
+
537
+ Gets VICE version information.
538
+
539
+ ```text
540
+ cmd: empty
541
+ rsp: 0x85 | ML:u8 | MV:bytes[ML] | SL:u8 | SV:bytes[SL]
542
+ ```
543
+
544
+ Example `MV = 03 05 00 00` means VICE `3.5.0.0`.
545
+
546
+ Used internally for diagnostics and backend capability checks.
547
+
548
+ ---
549
+
550
+ ## `0x86` - CPU History
551
+
552
+ Gets executed instruction history.
553
+
554
+ ```text
555
+ cmd: MS:u8 | HC:u32
556
+ rsp: 0x86 | HC:u32 | HISTORY_ITEM[HC]
557
+
558
+ history_item:
559
+ IS:u8 | RC:u16 | REGISTER_ITEM[RC] | CL:u64 | IL:u8 | IB:bytes[IL]
560
+
561
+ register_item:
562
+ RS:u8 | REGISTER_INFO_BODY:bytes[RS]
563
+ ```
564
+
565
+ `REGISTER_INFO_BODY` usually means:
566
+
567
+ ```text
568
+ RI:u8 | RV:u16
569
+ ```
570
+
571
+ `CL` is CPU clock. `IB` is instruction bytes.
572
+
573
+ No primary public C64 Bridge MCP mapping is listed in the README API reference.
574
+
575
+ ---
576
+
577
+ ## `0x91` - Palette Get
578
+
579
+ Gets current palette colors.
580
+
581
+ ```text
582
+ cmd: VC:u8
583
+ rsp: 0x91 | PC:u16 | ITEM[PC]
584
+ item: IS:u8 | RR:u8 | GG:u8 | BB:u8
585
+ ```
586
+
587
+ `VC` has the same C128 VIC-II/VDC meaning as `DISPLAY_GET`.
588
+
589
+ Usually internal to display capture and normalization.
590
+
591
+ ---
592
+
593
+ ## `0xa2` - Joyport Set
594
+
595
+ ```text
596
+ cmd: PN:u16 | PV:u16
597
+ rsp: 0xa2 | empty
598
+ ```
599
+
600
+ C64 Bridge mapping:
601
+
602
+ | MCP tool | Operation |
603
+ | ----------- | ---------- |
604
+ | `c64_input` | `joystick` |
605
+
606
+ The public joystick tool simulates the same port state by writing CIA1 joyport registers directly, rather than issuing BM `0xa2`.
607
+
608
+ ---
609
+
610
+ ## `0xb2` - Userport Set
611
+
612
+ ```text
613
+ cmd: UV:u16
614
+ rsp: 0xb2 | empty
615
+ ```
616
+
617
+ No primary public C64 Bridge MCP mapping is listed in the README API reference.
618
+
619
+ ---
620
+
621
+ ## `0xaa` - Exit
622
+
623
+ Exits the monitor and resumes emulation until the next breakpoint.
624
+
625
+ ```text
626
+ cmd: empty
627
+ rsp: 0xaa | empty
628
+ ```
629
+
630
+ May be followed by a `0x63 RESUMED` event.
631
+
632
+ C64 Bridge mapping:
633
+
634
+ | MCP tool | Operation |
635
+ | ------------ | --------- |
636
+ | `c64_system` | `resume` |
637
+
638
+ ---
639
+
640
+ ## `0xbb` - Quit
641
+
642
+ Quits VICE.
643
+
644
+ ```text
645
+ cmd: empty
646
+ rsp: 0xbb | empty
647
+ ```
648
+
649
+ Used internally for managed VICE lifecycle, not normally exposed as a user-facing MCP operation.
650
+
651
+ ---
652
+
653
+ ## `0xcc` - Reset
654
+
655
+ Resets system or drive.
656
+
657
+ ```text
658
+ cmd: RS:u8
659
+ rsp: 0xcc | empty
660
+ ```
661
+
662
+ `RS`: `0x00 = reset system`, `0x01 = power-cycle system`, `0x08..0x0b = reset drives 8..11`.
663
+
664
+ C64 Bridge mapping:
665
+
666
+ | MCP tool | Operation |
667
+ | ------------ | --------- |
668
+ | `c64_system` | `reset` |
669
+ | `c64_system` | `reboot` |
670
+ | `c64_drive` | `reset` |
671
+
672
+ ---
673
+
674
+ ## `0xdd` - Autostart / Autoload
675
+
676
+ Loads a program, then returns to monitor.
677
+
678
+ ```text
679
+ cmd: RL:u8 | FI:u16 | FL:u8 | FN:str[FL]
680
+ rsp: 0xdd | empty
681
+ ```
682
+
683
+ `RL` means run after loading. `FI` is file index inside disk image, use `0x0000` for default.
684
+
685
+ C64 Bridge mapping:
686
+
687
+ | MCP tool | Operation |
688
+ | ------------- | ------------------ |
689
+ | `c64_program` | `run_prg` |
690
+ | `c64_program` | `upload_run_basic` |
691
+ | `c64_program` | `upload_run_asm` |
692
+
693
+ ---
694
+
695
+ # Shared and Event Responses
696
+
697
+ ## `0x00` - Invalid / Error
698
+
699
+ ```text
700
+ body: usually empty
701
+ ```
702
+
703
+ Inspect the response header error code.
704
+
705
+ ---
706
+
707
+ ## `0x11` - Checkpoint Info
708
+
709
+ ```text
710
+ CN:u32 | CH:u8 | SA:u16 | EA:u16 | ST:u8 | EN:u8 | OP:u8 | TM:u8 | HC:u32 | IC:u32 | CE:u8 | MS:u8
711
+ ```
712
+
713
+ | Field | Meaning |
714
+ | --------- | -------------------------------------- |
715
+ | `CN` | Checkpoint number |
716
+ | `CH` | Currently hit |
717
+ | `SA`,`EA` | Inclusive address range |
718
+ | `ST` | Stop when hit |
719
+ | `EN` | Enabled |
720
+ | `OP` | `0x01 load`, `0x02 store`, `0x04 exec` |
721
+ | `TM` | Temporary |
722
+ | `HC` | Hit count |
723
+ | `IC` | Ignore count |
724
+ | `CE` | Has condition |
725
+ | `MS` | Memspace |
726
+
727
+ ---
728
+
729
+ ## `0x31` - Register Info
730
+
731
+ ```text
732
+ RC:u16 | ITEM[RC]
733
+ item: IS:u8 | RI:u8 | RV:u16
734
+ ```
735
+
736
+ Query `0x83 REGISTERS_AVAILABLE` before interpreting `RI`.
737
+
738
+ ---
739
+
740
+ ## `0x61` - JAM Event
741
+
742
+ ```text
743
+ PC:u16
744
+ ```
745
+
746
+ Usually emitted with `request_id = 0xffffffff`.
747
+
748
+ ---
749
+
750
+ ## `0x62` - Stopped Event
751
+
752
+ ```text
753
+ PC:u16
754
+ ```
755
+
756
+ Usually emitted with `request_id = 0xffffffff`.
757
+
758
+ ---
759
+
760
+ ## `0x63` - Resumed Event
761
+
762
+ ```text
763
+ PC:u16
764
+ ```
765
+
766
+ Usually emitted with `request_id = 0xffffffff`.
767
+
768
+ ---
769
+
770
+ # Command Summary
771
+
772
+ | Command | Hex | Direct Response | C64 Bridge surface |
773
+ | -------------------- | -----: | -----------------------: | ----------------------------------------------------------------------------------- |
774
+ | Memory Get | `0x01` | `0x01` | `c64_memory.read`, `c64_memory.read_screen`, `c64_memory.wait_for_text` |
775
+ | Memory Set | `0x02` | `0x02` | `c64_memory.write` |
776
+ | Checkpoint Get | `0x11` | `0x11` | `c64_debug.get_checkpoint` |
777
+ | Checkpoint Set | `0x12` | `0x11` | `c64_debug.create_checkpoint` |
778
+ | Checkpoint Delete | `0x13` | `0x13` | `c64_debug.delete_checkpoint` |
779
+ | Checkpoint List | `0x14` | many `0x11`, then `0x14` | `c64_debug.list_checkpoints` |
780
+ | Checkpoint Toggle | `0x15` | `0x15` | `c64_debug.toggle_checkpoint` |
781
+ | Condition Set | `0x22` | `0x22` | `c64_debug.set_condition` |
782
+ | Registers Get | `0x31` | `0x31` | `c64_debug.get_registers` |
783
+ | Registers Set | `0x32` | `0x31` | `c64_debug.set_registers` |
784
+ | Dump | `0x41` | `0x41` | internal or unmapped |
785
+ | Undump | `0x42` | `0x42` | internal or unmapped |
786
+ | Resource Get | `0x51` | `0x51` | `c64_vice.resource_get` |
787
+ | Resource Set | `0x52` | `0x52` | `c64_vice.resource_set` |
788
+ | Advance Instructions | `0x71` | `0x71` | `c64_debug.step` |
789
+ | Keyboard Feed | `0x72` | `0x72` | `c64_input.write_text`, `c64_input.key` |
790
+ | Execute Until Return | `0x73` | `0x73` | `c64_debug.step_return` |
791
+ | Ping | `0x81` | `0x81` | internal |
792
+ | Banks Available | `0x82` | `0x82` | internal |
793
+ | Registers Available | `0x83` | `0x83` | `c64_debug.list_registers` |
794
+ | Display Get | `0x84` | `0x84` | `c64_graphics.capture_frame` |
795
+ | VICE Info | `0x85` | `0x85` | internal diagnostics |
796
+ | CPU History | `0x86` | `0x86` | internal or unmapped |
797
+ | Palette Get | `0x91` | `0x91` | internal display support |
798
+ | Joyport Set | `0xa2` | `0xa2` | `c64_input.joystick` |
799
+ | Userport Set | `0xb2` | `0xb2` | internal or unmapped |
800
+ | Exit | `0xaa` | `0xaa` | `c64_system.resume` |
801
+ | Quit | `0xbb` | `0xbb` | managed VICE lifecycle |
802
+ | Reset | `0xcc` | `0xcc` | `c64_system.reset`, `c64_system.reboot`, `c64_drive.reset` |
803
+ | Autostart / Autoload | `0xdd` | `0xdd` | `c64_program.run_prg`, `c64_program.upload_run_basic`, `c64_program.upload_run_asm` |
804
+
805
+ ---
806
+
807
+ # C64 Bridge Implementation Guidance
808
+
809
+ ## Public MCP API First
810
+
811
+ LLM agents should prefer the public C64 Bridge MCP tools over raw VICE protocol details.
812
+
813
+ Examples:
814
+
815
+ | User intent | Prefer |
816
+ | ------------------------------- | ----------------------------------------- |
817
+ | Read memory at `$0801` | `c64_memory` with `op = read` |
818
+ | Write bytes to RAM | `c64_memory` with `op = write` |
819
+ | Show the current text screen | `c64_memory` with `op = read_screen` |
820
+ | Type `LOAD"*",8,1` then Return | `c64_input` with `op = write_text` |
821
+ | Tap a function key or Return | `c64_input` with `op = key` |
822
+ | Simulate joystick fire or left | `c64_input` with `op = joystick` |
823
+ | Capture the current video frame | `c64_graphics` with `op = capture_frame` |
824
+ | Set a breakpoint | `c64_debug` with `op = create_checkpoint` |
825
+ | List breakpoints | `c64_debug` with `op = list_checkpoints` |
826
+ | List registers | `c64_debug` with `op = list_registers` |
827
+ | Read PC and A | `c64_debug` with `op = get_registers` |
828
+ | Step one instruction | `c64_debug` with `op = step` |
829
+ | Step until return | `c64_debug` with `op = step_return` |
830
+ | Continue execution | `c64_system` with `op = resume` |
831
+ | Reset VICE | `c64_system` with `op = reset` |
832
+ | Change a VICE setting | `c64_vice` with `op = resource_set` |
833
+
834
+ ## Backend Selection
835
+
836
+ If both C64 Ultimate and VICE are configured, use `c64_select_backend` before making VICE-specific requests.
837
+
838
+ ```json
839
+ {
840
+ "tool": "c64_select_backend",
841
+ "op": "select",
842
+ "backend": "vice"
843
+ }
844
+ ```
845
+
846
+ Use backend switching instead of assuming the active backend is already VICE.
847
+
848
+ ## Internal VICE Backend Rules
849
+
850
+ The C64 Bridge VICE backend should:
851
+
852
+ - keep binary monitor request IDs internal;
853
+ - correlate direct replies by request ID;
854
+ - treat the protocol as asynchronous;
855
+ - buffer or route asynchronous events separately from command responses;
856
+ - decode binary data internally;
857
+ - return LLM-readable JSON from MCP tools;
858
+ - return memory and display payloads as hex strings or files, not raw byte arrays;
859
+ - cache register metadata from `REGISTERS_AVAILABLE`;
860
+ - cache bank metadata from `BANKS_AVAILABLE`;
861
+ - refresh cached metadata if the VICE machine type changes.
862
+
863
+ ## Suggested VICE Initialization
864
+
865
+ After connecting to the VICE binary monitor:
866
+
867
+ 1. Send `PING`.
868
+ 2. Send `VICE_INFO`.
869
+ 3. Send `BANKS_AVAILABLE`.
870
+ 4. Send `REGISTERS_AVAILABLE` for main memspace.
871
+ 5. Cache register and bank mappings.
872
+ 6. Drain or classify any asynchronous monitor events.
873
+
874
+ ## Suggested MCP Result Shapes
875
+
876
+ ### `c64_memory.read`
877
+
878
+ ```json
879
+ {
880
+ "address": 2048,
881
+ "endAddress": 2063,
882
+ "length": 16,
883
+ "memspace": "main",
884
+ "bankId": 0,
885
+ "hex": "0102030405060708090a0b0c0d0e0f10"
886
+ }
887
+ ```
888
+
889
+ ### `c64_debug.get_registers`
890
+
891
+ ```json
892
+ {
893
+ "memspace": "main",
894
+ "registers": [
895
+ {
896
+ "id": 3,
897
+ "name": "PC",
898
+ "value": 58575,
899
+ "hex": "e4cf"
900
+ }
901
+ ]
902
+ }
903
+ ```
904
+
905
+ ### `c64_debug.create_checkpoint`
906
+
907
+ ```json
908
+ {
909
+ "checkpointNumber": 2,
910
+ "hit": false,
911
+ "startAddress": 64738,
912
+ "endAddress": 64739,
913
+ "stopWhenHit": true,
914
+ "enabled": true,
915
+ "operation": ["exec"],
916
+ "temporary": true,
917
+ "hitCount": 0,
918
+ "ignoreCount": 0,
919
+ "hasCondition": false,
920
+ "memspace": "main"
921
+ }
922
+ ```
923
+
924
+ ---
925
+
926
+ # Attribution
927
+
928
+ This reference is derived from the VICE binary monitor documentation.
929
+
930
+ VICE is licensed under GPL v2 or later. Copyright belongs to the VICE authors as listed here:
931
+
932
+ [https://vice-emu.sourceforge.io/index.html#copyright](https://vice-emu.sourceforge.io/index.html#copyright)
933
+
934
+ The authoritative source of truth for the VICE binary monitor protocol is the VICE manual:
935
+
936
+ [https://vice-emu.sourceforge.io/vice_13.html](https://vice-emu.sourceforge.io/vice_13.html)
937
+
938
+ When this document conflicts with the upstream VICE manual, the upstream manual wins.