@henols/c64-re-tools 2.4.0-rc.1 → 2.4.0-rc.3
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.
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +6 -3
- package/skills/c64-assembler/scripts/assembler.ts +6 -16
- package/skills/c64-disk/SKILL.md +19 -4
- package/skills/c64-disk/scripts/disk.ts +43 -3
- package/skills/c64-docs/SKILL.md +3 -2
- package/skills/c64-docs/references/page-types.md +13 -2
- package/skills/c64-provenance/SKILL.md +8 -4
- package/skills/c64-provenance/scripts/lib/library.ts +85 -11
- package/skills/c64-provenance/scripts/provenance.ts +4 -3
- package/skills/c64-source/SKILL.md +8 -2
- package/skills/c64-source/scripts/lib/export.ts +3 -3
- package/skills/c64-source/scripts/lib/source.ts +80 -24
- package/skills/c64-source/scripts/source.ts +49 -8
- package/skills/c64-static-analysis/SKILL.md +1 -1
- package/skills/c64-testing/SKILL.md +11 -1
- package/skills/c64-testing/references/recording-format.md +5 -1
- package/skills/c64-testing/references/scenario-format.md +5 -3
- package/skills/c64-testing/scripts/lib/recording.ts +32 -6
- package/skills/c64-testing/scripts/lib/runs.ts +13 -7
- package/skills/c64-testing/scripts/lib/scenario.ts +13 -6
- package/skills/c64-testing/scripts/testing.ts +6 -3
- package/src/host/server.ts +31 -6
- package/src/host/tools/c1541.ts +32 -8
- package/src/host/vice/binary-monitor.ts +19 -7
- package/src/host/vice/session.ts +6 -2
- package/src/host-client/connect.ts +12 -2
- package/src/host-client/tools.ts +9 -4
- package/src/host-client/transfer.ts +54 -1
- package/src/host-client/vice-session.ts +10 -3
- package/src/knowledge/import.ts +28 -5
- package/src/knowledge/write.ts +4 -0
- package/src/mcp/main.ts +4 -66
- package/src/mcp/session-source.ts +76 -0
- package/src/native/acme.ts +45 -12
- package/src/native/c64run.ts +1 -1
- package/src/native/types.ts +5 -2
- package/src/protocol/framing.ts +15 -2
- package/src/protocol/messages.ts +77 -25
- package/src/protocol/tools.ts +33 -4
- package/src/protocol/vice.ts +40 -20
- package/tools/c64run.c +48 -12
package/tools/c64run.c
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
#include "systems/c1541.h"
|
|
28
28
|
#include "systems/c64.h"
|
|
29
29
|
|
|
30
|
-
#define C64RUN_PROTOCOL
|
|
30
|
+
#define C64RUN_PROTOCOL 3
|
|
31
31
|
// Keys that chips has no code for: each SHIFT alone, and the up arrow.
|
|
32
32
|
#define C64RUN_KEY_LSHIFT 0x11
|
|
33
33
|
#define C64RUN_KEY_RSHIFT 0x12
|
|
@@ -73,6 +73,7 @@ static int watch_hit;
|
|
|
73
73
|
|
|
74
74
|
static int area(uint16_t addr);
|
|
75
75
|
static int coverage_on, coverage_armed_input;
|
|
76
|
+
static void coverage_start(uint16_t pc);
|
|
76
77
|
|
|
77
78
|
static site_t* site_for(uint16_t pc, uint16_t addr) {
|
|
78
79
|
for (int i = 0; i < site_count; i++) if (sites[i].pc == pc && sites[i].addr == addr) return &sites[i];
|
|
@@ -106,7 +107,7 @@ static void input_read(uint16_t pc, uint16_t addr) {
|
|
|
106
107
|
if (replaying) { M6502_SET_DATA(pins, idle_value(addr)); replay_unknown++; }
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
109
|
-
if (coverage_armed_input && !s->rom) { coverage_armed_input = 0;
|
|
110
|
+
if (coverage_armed_input && !s->rom) { coverage_armed_input = 0; coverage_start(pc); }
|
|
110
111
|
const uint64_t index = s->count++;
|
|
111
112
|
if (replaying) {
|
|
112
113
|
if (s->nruns == 0) {
|
|
@@ -140,7 +141,25 @@ enum { COV_RAM_R = 1, COV_RAM_W = 2, COV_RAM_X = 4, COV_ROM_R = 8, COV_ROM_X = 1
|
|
|
140
141
|
static uint8_t coverage[0x10000];
|
|
141
142
|
// Set by "coverage on-checkpoint": the map starts at the first sample. coverage_armed_input,
|
|
142
143
|
// set by "coverage on-input": the map starts at the first input read of code in RAM.
|
|
143
|
-
|
|
144
|
+
// coverage_armed_pc, set by "coverage on-pc": the map starts at the first opcode fetch at coverage_pc.
|
|
145
|
+
static int coverage_armed, coverage_armed_pc;
|
|
146
|
+
static uint16_t coverage_pc;
|
|
147
|
+
// Where the map started: the tick and the pc of the instruction ("coverage status").
|
|
148
|
+
static int coverage_started;
|
|
149
|
+
static uint64_t coverage_from_tick;
|
|
150
|
+
static uint16_t coverage_from_pc;
|
|
151
|
+
|
|
152
|
+
static void coverage_start(uint16_t pc) {
|
|
153
|
+
coverage_on = coverage_started = 1;
|
|
154
|
+
coverage_from_tick = ticks;
|
|
155
|
+
coverage_from_pc = pc;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Clears the map and every way that it can start.
|
|
159
|
+
static void coverage_reset(void) {
|
|
160
|
+
memset(coverage, 0, sizeof coverage);
|
|
161
|
+
coverage_on = coverage_armed = coverage_armed_input = coverage_armed_pc = coverage_started = 0;
|
|
162
|
+
}
|
|
144
163
|
|
|
145
164
|
// 0: RAM, 1: ROM, 2: I/O, as the CPU sees the address now (the CPU port bits).
|
|
146
165
|
static int area(uint16_t addr) {
|
|
@@ -205,7 +224,7 @@ static void sample(void) {
|
|
|
205
224
|
}
|
|
206
225
|
fputc('\n', sample_file);
|
|
207
226
|
samples++;
|
|
208
|
-
if (coverage_armed) { coverage_armed = 0;
|
|
227
|
+
if (coverage_armed) { coverage_armed = 0; coverage_start(sample_pc); }
|
|
209
228
|
if (sample_stop && samples >= sample_stop) halted = 1;
|
|
210
229
|
}
|
|
211
230
|
|
|
@@ -222,6 +241,7 @@ static void tick(void) {
|
|
|
222
241
|
if (sync) {
|
|
223
242
|
last_sync_pc = addr;
|
|
224
243
|
if (sample_file && addr == sample_pc && decoded) sample();
|
|
244
|
+
if (coverage_armed_pc && addr == coverage_pc && decoded) { coverage_armed_pc = 0; coverage_start(addr); }
|
|
225
245
|
}
|
|
226
246
|
if (read && !sync && decoded && sys.io_mapped && (addr & 0xF000) == 0xD000 && input_addr[addr & 0x0FFF]) {
|
|
227
247
|
input_read(last_sync_pc, addr);
|
|
@@ -420,11 +440,10 @@ int main(int argc, char** argv) {
|
|
|
420
440
|
halted = 0;
|
|
421
441
|
sample_stop = 0;
|
|
422
442
|
maps = 0;
|
|
423
|
-
|
|
443
|
+
coverage_reset();
|
|
424
444
|
if (pin_file) { fclose(pin_file); pin_file = NULL; }
|
|
425
445
|
if (record_file) { fclose(record_file); record_file = NULL; }
|
|
426
446
|
if (sample_file) { fclose(sample_file); sample_file = NULL; }
|
|
427
|
-
memset(coverage, 0, sizeof coverage);
|
|
428
447
|
const char* problem = init(dir);
|
|
429
448
|
if (problem) printf("err init: %s\n", problem); else status("ok");
|
|
430
449
|
} else if (!strcmp(cmd, "quit")) {
|
|
@@ -468,6 +487,9 @@ int main(int argc, char** argv) {
|
|
|
468
487
|
M6502_SET_DATA(pins, mem_rd(&sys.mem_cpu, pc));
|
|
469
488
|
m6502_set_pc(&sys.cpu, pc);
|
|
470
489
|
last_sync_pc = pc;
|
|
490
|
+
// The prefetch is the opcode fetch at pc: it does not pass through tick.
|
|
491
|
+
if (coverage_armed_pc && pc == coverage_pc) { coverage_armed_pc = 0; coverage_start(pc); }
|
|
492
|
+
if (coverage_on) cover(pc, 1, 1);
|
|
471
493
|
status("ok");
|
|
472
494
|
} else if (!strcmp(cmd, "run")) {
|
|
473
495
|
// run <tick>: run to the absolute tick (a tick in the past does nothing)
|
|
@@ -617,12 +639,26 @@ int main(int argc, char** argv) {
|
|
|
617
639
|
pin_file = fopen(a1, "r");
|
|
618
640
|
if (pin_file) printf("ok ranges=%d\n", pin_ranges); else printf("err pin: cannot read %s\n", a1);
|
|
619
641
|
} else if (!strcmp(cmd, "coverage")) {
|
|
620
|
-
// coverage on | on-checkpoint | on-input | off | <file>: start
|
|
621
|
-
// at the first input read of code in RAM
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
642
|
+
// coverage on | on-checkpoint | on-input | on-pc <pc hex> | off | status | <file>: start
|
|
643
|
+
// now, at the next sample, at the first input read of code in RAM, at the first opcode
|
|
644
|
+
// fetch at pc; stop; where the map started ("ok from tick=<n> pc=<hex>" or "ok
|
|
645
|
+
// not-started"); or write the 65536-byte map
|
|
646
|
+
unsigned pc;
|
|
647
|
+
if (!strcmp(a1, "on")) { coverage_reset(); coverage_start(last_sync_pc); printf("ok\n"); }
|
|
648
|
+
else if (!strcmp(a1, "on-checkpoint")) { coverage_reset(); coverage_armed = 1; printf("ok\n"); }
|
|
649
|
+
else if (!strcmp(a1, "on-input")) { coverage_reset(); coverage_armed_input = 1; printf("ok\n"); }
|
|
650
|
+
else if (!strcmp(a1, "on-pc")) {
|
|
651
|
+
if (sscanf(a2, "%x", &pc) != 1 || pc > 0xFFFF) { printf("err coverage: give on-pc and a pc\n"); continue; }
|
|
652
|
+
coverage_reset();
|
|
653
|
+
coverage_armed_pc = 1;
|
|
654
|
+
coverage_pc = (uint16_t)pc;
|
|
655
|
+
printf("ok\n");
|
|
656
|
+
}
|
|
657
|
+
else if (!strcmp(a1, "off")) { coverage_on = coverage_armed = coverage_armed_input = coverage_armed_pc = 0; printf("ok\n"); }
|
|
658
|
+
else if (!strcmp(a1, "status")) {
|
|
659
|
+
if (coverage_started) printf("ok from tick=%llu pc=%04x\n", (unsigned long long)coverage_from_tick, coverage_from_pc);
|
|
660
|
+
else printf("ok not-started\n");
|
|
661
|
+
}
|
|
626
662
|
else printf(write_file(a1, coverage, sizeof coverage) ? "ok\n" : "err coverage: cannot write %s\n", a1);
|
|
627
663
|
} else if (!strcmp(cmd, "palette")) {
|
|
628
664
|
// palette: the 16 colours as RRGGBB
|