@henols/c64-re-tools 2.0.0-rc.6 → 2.0.0-rc.7

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 (48) hide show
  1. package/package.json +1 -1
  2. package/skills/c64-assembler/SKILL.md +1 -1
  3. package/skills/c64-basic/SKILL.md +1 -1
  4. package/skills/c64-disk/SKILL.md +3 -3
  5. package/skills/c64-disk/scripts/disk.ts +2 -1
  6. package/skills/c64-emulator/SKILL.md +3 -1
  7. package/skills/c64-knowledge/SKILL.md +1 -1
  8. package/skills/c64-provenance/SKILL.md +7 -5
  9. package/skills/c64-provenance/scripts/compare.ts +26 -0
  10. package/skills/c64-provenance/scripts/provenance.ts +24 -10
  11. package/skills/c64-provenance/scripts/separate.ts +12 -4
  12. package/skills/c64-reverse-engineering/SKILL.md +2 -2
  13. package/skills/c64-source/SKILL.md +15 -9
  14. package/skills/c64-source/scripts/generate.ts +36 -10
  15. package/skills/c64-source/scripts/loader.ts +88 -6
  16. package/skills/c64-source/scripts/source.ts +40 -9
  17. package/skills/c64-static-analysis/SKILL.md +4 -4
  18. package/skills/c64-static-analysis/scripts/analyze.ts +13 -6
  19. package/skills/c64-static-analysis/scripts/coverage.ts +4 -4
  20. package/skills/c64-static-analysis/scripts/idioms.ts +14 -9
  21. package/skills/c64-testing/SKILL.md +1 -1
  22. package/skills/c64-testing/scripts/scenario.ts +2 -2
  23. package/skills/c64-unpacker/SKILL.md +9 -7
  24. package/skills/c64-unpacker/scripts/loads.ts +12 -1
  25. package/skills/c64-unpacker/scripts/stages.ts +66 -3
  26. package/skills/c64-unpacker/scripts/unpack.ts +96 -30
  27. package/src/c64.ts +14 -5
  28. package/src/cli/status.ts +26 -3
  29. package/src/host/tools/c1541.ts +34 -5
  30. package/src/host/tools/petcat.ts +5 -2
  31. package/src/host/tools/status.ts +6 -3
  32. package/src/host/vice/adapter.ts +23 -9
  33. package/src/host/vice/process.ts +7 -2
  34. package/src/host/vice/session.ts +47 -10
  35. package/src/host-client/connect.ts +10 -10
  36. package/src/host-client/coverage.ts +19 -10
  37. package/src/host-client/tools.ts +5 -5
  38. package/src/host-client/vice-session.ts +1 -1
  39. package/src/knowledge/schema.ts +7 -0
  40. package/src/knowledge/write.ts +5 -0
  41. package/src/mcp/tools/debug.ts +3 -2
  42. package/src/mcp/tools/machine.ts +4 -1
  43. package/src/mcp/tools/media.ts +5 -1
  44. package/src/mcp/tools/video.ts +2 -0
  45. package/src/native/discover.ts +2 -1
  46. package/src/platform.ts +3 -2
  47. package/src/protocol/tools.ts +19 -4
  48. package/src/protocol/vice.ts +11 -2
@@ -259,6 +259,8 @@ export interface Rectangle {
259
259
  export interface ScreenComparison {
260
260
  match: boolean;
261
261
  mismatchingPixels: number;
262
+ /** Pixels compared: the frame minus the masked ones; always at least 1. */
263
+ comparedPixels: number;
262
264
  mismatchRatio: number;
263
265
  /** Absent when no pixel differs. */
264
266
  bounds?: Rectangle;
@@ -310,6 +312,8 @@ export interface MachineStatus {
310
312
  window: boolean;
311
313
  /** Present only while the C64 CPU is stopped. */
312
314
  pc?: number;
315
+ /** Present, true, while a cartridge from an autostart is attached. */
316
+ cartridge?: true;
313
317
  }
314
318
 
315
319
  export interface MemoryReadParams {
@@ -417,7 +421,8 @@ export interface ViceOperations {
417
421
  /** Attachment: the PRG bytes, load address first. */
418
422
  programLoad: { params: { address?: number }; result: { state: RunState; loadAddress: number; size: number } };
419
423
  /** Attachment: the program or image bytes; `type` is the file's extension. `index` is VICE's file number: 0 loads "*", 1 is the first directory entry. */
420
- autostart: { params: { type: string; index: number; run: boolean }; result: { state: RunState } };
424
+ /** `emulatorFlaw`: for a tape image, a known flaw of the host's VICE version that a tape load meets (D56). */
425
+ autostart: { params: { type: string; index: number; run: boolean }; result: { state: RunState; emulatorFlaw?: string } };
421
426
  /** Attachment: the disk image bytes; `type` is the file's extension. */
422
427
  diskAttach: { params: { type: string }; result: { attached: boolean } };
423
428
  /** pc is the reset vector when run is false: the CPU stops there. */
@@ -966,7 +971,8 @@ export function validateViceResult<O extends ViceOperation>(op: O, value: unknow
966
971
  isOneOf(VIDEO_STANDARDS, value.videoStandard) &&
967
972
  typeof value.warp === "boolean" &&
968
973
  typeof value.window === "boolean" &&
969
- (value.pc === undefined || isInteger(value.pc, 0, 0xffff));
974
+ (value.pc === undefined || isInteger(value.pc, 0, 0xffff)) &&
975
+ (value.cartridge === undefined || value.cartridge === true);
970
976
  if (!ok) throw new ProtocolError("status result is malformed");
971
977
  break;
972
978
  }
@@ -1052,6 +1058,7 @@ export function validateViceResult<O extends ViceOperation>(op: O, value: unknow
1052
1058
  case "autostart": {
1053
1059
  if (!isOneOf(RUN_STATES, value.state)) throw new ProtocolError(`${op} result is malformed`);
1054
1060
  if (op === "reset" && value.pc !== undefined && !isInteger(value.pc, 0, 0xffff)) throw new ProtocolError("reset result is malformed");
1061
+ if (op === "autostart" && !(value.emulatorFlaw === undefined || typeof value.emulatorFlaw === "string")) throw new ProtocolError("autostart result is malformed");
1055
1062
  break;
1056
1063
  }
1057
1064
  case "programLoad": {
@@ -1082,6 +1089,8 @@ export function validateViceResult<O extends ViceOperation>(op: O, value: unknow
1082
1089
  const ok =
1083
1090
  typeof value.match === "boolean" &&
1084
1091
  isInteger(value.mismatchingPixels, 0, 1 << 20) &&
1092
+ isInteger(value.comparedPixels, 1, 1 << 20) &&
1093
+ (value.mismatchingPixels as number) <= (value.comparedPixels as number) &&
1085
1094
  typeof value.mismatchRatio === "number" &&
1086
1095
  value.mismatchRatio >= 0 &&
1087
1096
  value.mismatchRatio <= 1 &&