@henols/c64-re-tools 2.7.0 → 2.8.0-rc.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.
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +23 -38
- package/skills/c64-assembler/scripts/assembler.ts +114 -16
- package/skills/c64-basic/SKILL.md +11 -31
- package/skills/c64-basic/scripts/basic.ts +4 -1
- package/skills/c64-development/SKILL.md +2 -2
- package/skills/c64-disk/SKILL.md +11 -32
- package/skills/c64-docs/SKILL.md +27 -45
- package/skills/c64-docs/references/page-types.md +20 -18
- package/skills/c64-docs/references/style.md +10 -4
- package/skills/c64-docs/scripts/docs.ts +13 -2
- package/skills/c64-docs/scripts/lib/reference.ts +47 -5
- package/skills/c64-knowledge/SKILL.md +138 -267
- package/skills/c64-knowledge/references/batches.md +48 -0
- package/skills/c64-knowledge/references/coverage.md +29 -0
- package/skills/c64-knowledge/references/source-knowledge.md +72 -0
- package/skills/c64-knowledge/references/start-screen.md +44 -0
- package/skills/c64-knowledge/scripts/knowledge.ts +266 -61
- package/skills/c64-knowledge/scripts/lib/check.ts +133 -0
- package/skills/c64-knowledge/scripts/lib/listing.ts +72 -8
- package/skills/c64-memory-map/SKILL.md +11 -32
- package/skills/c64-packer/SKILL.md +11 -31
- package/skills/c64-provenance/SKILL.md +40 -62
- package/skills/c64-provenance/scripts/lib/leftovers.ts +8 -3
- package/skills/c64-provenance/scripts/provenance.ts +64 -55
- package/skills/c64-reverse-engineering/SKILL.md +20 -47
- package/skills/c64-reverse-engineering/references/comment-check.md +42 -0
- package/skills/c64-reverse-engineering/references/versions.md +47 -0
- package/skills/c64-source/SKILL.md +43 -235
- package/skills/c64-source/references/export.md +50 -0
- package/skills/c64-source/references/loader.md +78 -0
- package/skills/c64-source/references/source-format.md +46 -0
- package/skills/c64-source/scripts/lib/export.ts +20 -7
- package/skills/c64-source/scripts/lib/loader.ts +116 -104
- package/skills/c64-source/scripts/source.ts +62 -52
- package/skills/c64-static-analysis/SKILL.md +51 -52
- package/skills/c64-static-analysis/scripts/lib/coverage.ts +55 -2
- package/skills/c64-static-analysis/scripts/lib/idioms.ts +28 -9
- package/skills/c64-static-analysis/scripts/static-analysis.ts +69 -15
- package/skills/c64-testing/SKILL.md +77 -59
- package/skills/c64-testing/references/recording-format.md +5 -79
- package/skills/c64-testing/references/scenario-format.md +4 -12
- package/skills/c64-testing/scripts/lib/play.ts +16 -8
- package/skills/c64-testing/scripts/lib/recording.ts +76 -9
- package/skills/c64-testing/scripts/lib/replay.ts +14 -0
- package/skills/c64-testing/scripts/lib/runs.ts +112 -1
- package/skills/c64-testing/scripts/lib/scenario.ts +12 -6
- package/skills/c64-testing/scripts/lib/start-screen.ts +27 -0
- package/skills/c64-testing/scripts/testing.ts +37 -15
- package/skills/c64-unpacker/SKILL.md +10 -30
- package/skills/emulator/SKILL.md +7 -36
- package/src/build-name.ts +12 -1
- package/src/knowledge/history.ts +8 -0
- package/src/knowledge/program.ts +73 -1
- package/src/knowledge/read.ts +46 -2
- package/src/knowledge/recording-files.ts +32 -0
- package/src/knowledge/schema.ts +3 -1
- package/src/knowledge/separate.ts +90 -3
- package/src/knowledge/start-screen.ts +99 -17
- package/src/knowledge/text.ts +2 -1
- package/src/knowledge/write.ts +15 -8
- package/src/loader.ts +167 -0
- package/src/native/c64run.ts +11 -0
- package/src/native/decompiler/analyze.ts +7 -6
- package/src/native/decompiler/walk.ts +32 -2
- package/src/native/dxa.ts +4 -4
- package/src/native/types.ts +32 -4
- package/src/script.ts +87 -17
- package/skills/c64-export/SKILL.md +0 -63
|
@@ -20,6 +20,14 @@ const DOPS = new Set([0x04, 0x14, 0x34, 0x44, 0x54, 0x64, 0x74, 0x80, 0x82, 0x89
|
|
|
20
20
|
/** "CBM80" in PETSCII at $8004: the KERNAL then starts the cartridge through the vectors at $8000 (cold) and $8002 (warm). */
|
|
21
21
|
const CBM80 = [0xc3, 0xc2, 0xcd, 0x38, 0x30];
|
|
22
22
|
|
|
23
|
+
/** An idiom that the pass found but could not record: its bytes leave the program, or an idiom found before holds some of them. */
|
|
24
|
+
export interface LeftOutIdiom {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
kind: "cartridge-header" | "rts-table" | "jump-table" | "bit-skip";
|
|
28
|
+
reason: "leaves-program" | "overlaps-idiom";
|
|
29
|
+
}
|
|
30
|
+
|
|
23
31
|
export interface Idioms {
|
|
24
32
|
findings: NormalizedFindings;
|
|
25
33
|
/** Entry points for the same analysis run: analyzer facts are never seeds. */
|
|
@@ -27,6 +35,8 @@ export interface Idioms {
|
|
|
27
35
|
/** Table ranges for the same run: they are data. */
|
|
28
36
|
dataRanges: Array<{ start: number; end: number }>;
|
|
29
37
|
counts: { cartridgeHeaders: number; rtsTables: number; jumpTables: number; bitSkips: number };
|
|
38
|
+
/** The idioms that were found but not recorded, with the reason. */
|
|
39
|
+
leftOut: LeftOutIdiom[];
|
|
30
40
|
/** Seen in the coverage, not written: the LLM decides. All of them: the result lists the first ones. */
|
|
31
41
|
candidates: { dop: number[]; selfModified: number[] };
|
|
32
42
|
}
|
|
@@ -54,16 +64,24 @@ export function findIdioms(byteAt: ImageByte, range: { start: number; end: numbe
|
|
|
54
64
|
const references: NormalizedFindings["references"] = [];
|
|
55
65
|
const entryPoints = new Set<number>();
|
|
56
66
|
const counts = { cartridgeHeaders: 0, rtsTables: 0, jumpTables: 0, bitSkips: 0 };
|
|
67
|
+
const leftOut: LeftOutIdiom[] = [];
|
|
57
68
|
const taken = (start: number, end: number) => regions.some((region) => start <= region.end && end >= region.start);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
const blocked = (start: number, end: number): LeftOutIdiom["reason"] | undefined => (start < range.start || end > range.end ? "leaves-program" : taken(start, end) ? "overlaps-idiom" : undefined);
|
|
70
|
+
/** Records the region of an idiom when all of its parts fit; else records why the idiom is left out. */
|
|
71
|
+
const addRegions = (kind: LeftOutIdiom["kind"], parts: ReadonlyArray<{ start: number; end: number; type: NormalizedFindings["regions"][number]["type"] }>) => {
|
|
72
|
+
for (const part of parts) {
|
|
73
|
+
const reason = blocked(part.start, part.end) ?? (parts.some((other) => other !== part && part.start <= other.end && part.end >= other.start) ? "overlaps-idiom" : undefined);
|
|
74
|
+
if (reason === undefined) continue;
|
|
75
|
+
leftOut.push({ start: Math.min(...parts.map((item) => item.start)), end: Math.max(...parts.map((item) => item.end)), kind, reason });
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
regions.push(...parts);
|
|
61
79
|
return true;
|
|
62
80
|
};
|
|
63
81
|
|
|
64
82
|
if (range.start <= 0x8000 && range.end >= 0x8008 && CBM80.every((byte, index) => byteAt(0x8004 + index) === byte)) {
|
|
65
83
|
const vectors = [word(byteAt, 0x8000)!, word(byteAt, 0x8002)!].filter((target) => plausible(byteAt, target, range));
|
|
66
|
-
if (
|
|
84
|
+
if (addRegions("cartridge-header", [{ start: 0x8000, end: 0x8003, type: "addresses" }, { start: 0x8004, end: 0x8008, type: "petscii" }])) {
|
|
67
85
|
counts.cartridgeHeaders++;
|
|
68
86
|
for (const target of vectors) entryPoints.add(target);
|
|
69
87
|
}
|
|
@@ -88,10 +106,10 @@ export function findIdioms(byteAt: ImageByte, range: { start: number; end: numbe
|
|
|
88
106
|
if (targets.length === 0) continue;
|
|
89
107
|
const n = targets.length;
|
|
90
108
|
const written = interleaved
|
|
91
|
-
?
|
|
109
|
+
? addRegions("rts-table", [{ start: low, end: low + 2 * n - 1, type: "rts-addresses" }])
|
|
92
110
|
: low + n === high
|
|
93
|
-
?
|
|
94
|
-
:
|
|
111
|
+
? addRegions("rts-table", [{ start: low, end: high + n - 1, type: "rts-addresses-split" }])
|
|
112
|
+
: addRegions("rts-table", [{ start: low, end: low + n - 1, type: "bytes" }, { start: high, end: high + n - 1, type: "bytes" }]);
|
|
95
113
|
if (!written) continue;
|
|
96
114
|
counts.rtsTables++;
|
|
97
115
|
for (const target of targets) {
|
|
@@ -105,7 +123,7 @@ export function findIdioms(byteAt: ImageByte, range: { start: number; end: numbe
|
|
|
105
123
|
for (let at = range.start; at + 3 * MIN_JUMPS - 1 <= range.end; at++) {
|
|
106
124
|
let n = 0;
|
|
107
125
|
while (at + 3 * n + 2 <= range.end && byteAt(at + 3 * n) === 0x4c) n++;
|
|
108
|
-
if (n < MIN_JUMPS || !
|
|
126
|
+
if (n < MIN_JUMPS || !addRegions("jump-table", [{ start: at, end: at + 3 * n - 1, type: "jumps" }])) continue;
|
|
109
127
|
counts.jumpTables++;
|
|
110
128
|
for (let index = 0; index < n; index++) {
|
|
111
129
|
entryPoints.add(at + 3 * index);
|
|
@@ -123,7 +141,7 @@ export function findIdioms(byteAt: ImageByte, range: { start: number; end: numbe
|
|
|
123
141
|
if (coverage !== undefined) for (let address = range.start; address <= range.end; address++) if ((coverage[address]! & COVERAGE.ramExecute) !== 0) entered.add(address);
|
|
124
142
|
for (let at = range.start; at + 2 <= range.end; at++) {
|
|
125
143
|
if (byteAt(at) !== 0x2c || !entered.has(at + 1) || !plausible(byteAt, at + 1, range)) continue;
|
|
126
|
-
if (!
|
|
144
|
+
if (!addRegions("bit-skip", [{ start: at + 1, end: at + 2, type: "dual-use" }])) continue;
|
|
127
145
|
counts.bitSkips++;
|
|
128
146
|
entryPoints.add(at);
|
|
129
147
|
entryPoints.add(at + 1);
|
|
@@ -157,6 +175,7 @@ export function findIdioms(byteAt: ImageByte, range: { start: number; end: numbe
|
|
|
157
175
|
entryPoints: [...entryPoints].sort((a, b) => a - b),
|
|
158
176
|
dataRanges,
|
|
159
177
|
counts,
|
|
178
|
+
leftOut,
|
|
160
179
|
candidates,
|
|
161
180
|
};
|
|
162
181
|
}
|
|
@@ -11,7 +11,7 @@ import { knowledgeNames } from "#src/knowledge/names.ts";
|
|
|
11
11
|
import { analyze as analyzeWithDxa } from "#src/native/dxa.ts";
|
|
12
12
|
import { analyze as analyzeWithDecompiler } from "#src/native/decompiler/analyze.ts";
|
|
13
13
|
import { localToolContext } from "#src/native/local.ts";
|
|
14
|
-
import { DECOMPILER_LIMITS } from "#src/native/types.ts";
|
|
14
|
+
import { DECOMPILER_LIMITS, type RefusedSeed, type SeedReport } from "#src/native/types.ts";
|
|
15
15
|
import { openForRead, withWrite } from "#src/knowledge/database.ts";
|
|
16
16
|
import { analyzedBytes, operandImages, programCoverage, requireProgram } from "#src/knowledge/program.ts";
|
|
17
17
|
import { applyBatch, type BatchOperation } from "#src/knowledge/write.ts";
|
|
@@ -20,7 +20,7 @@ import { currentRevision, listMacros, listMacroUses, listPatches, listReferences
|
|
|
20
20
|
import { DEFAULT_SPACE, SEMANTIC_ORIGINS, type Analyzer } from "#src/knowledge/schema.ts";
|
|
21
21
|
import { platformNames, platformNamesFor, romUseOfProgram, type RomUse } from "#src/platform.ts";
|
|
22
22
|
import { listed, OPTIONS, reply, runScript, UsageError, type Call } from "#src/script.ts";
|
|
23
|
-
import { codeEntries, coverageConflicts, coverageEntries, coverageSeedKinds, executedStarts, imageReader, romOnlyRanges, type ImageByte } from "./lib/coverage.ts";
|
|
23
|
+
import { codeEntries, coverageConflicts, coverageEntries, coverageSeedKinds, executedStarts, imageReader, romOnlyRanges, writtenNotExecuted, explainGaps, type GapReason, type ImageByte } from "./lib/coverage.ts";
|
|
24
24
|
import { dxaFindings, decompilerFindings, seedsFromKnowledge } from "./lib/findings.ts";
|
|
25
25
|
import { findIdioms } from "./lib/idioms.ts";
|
|
26
26
|
import { instructionList } from "./lib/instructions.ts";
|
|
@@ -30,14 +30,18 @@ import { findPointers, type PointerCandidate } from "./lib/pointers.ts";
|
|
|
30
30
|
|
|
31
31
|
/** The rest of a cut label or function list: the knowledge has all of them as analyzer names. */
|
|
32
32
|
const ALL_NAMES = "a larger --max-listed. The project knowledge has all of them as analyzer names";
|
|
33
|
+
/** The rest of a cut region list: the knowledge has all of them. */
|
|
34
|
+
const ALL_REGIONS = "a larger --max-listed. The project knowledge has all of them as regions";
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* The result with a hint for what the agent does next: conflicts to examine,
|
|
36
38
|
* analyzer data over executed code to classify, and macro candidates to write.
|
|
37
39
|
* The envelope adds the sentence for a cut list.
|
|
38
40
|
*/
|
|
39
|
-
function withHint(body: Record<string, unknown>, conflicts: number, coverageConflicts: number, macros: { candidates: number; applied: boolean; revision: string | null | undefined }, version: { now: string | undefined; last: string | undefined; revision: string | null }, retiredReferences: number) {
|
|
41
|
+
function withHint(body: Record<string, unknown>, conflicts: number, coverageConflicts: number, macros: { candidates: number; applied: boolean; revision: string | null | undefined }, version: { now: string | undefined; last: string | undefined; revision: string | null }, retiredReferences: number, guards: { refused: number; writtenNotExecuted: number }) {
|
|
40
42
|
const hints: string[] = [];
|
|
43
|
+
if (guards.refused > 0) hints.push(`The analysis did not decode ${guards.refused} of its seeds: seeds.refused gives each one with its reason. A seed inside an instruction or in data is often a wrong routine or region in the project knowledge. Examine it in the listing, and correct the project knowledge.`);
|
|
44
|
+
if (guards.writtenNotExecuted > 0) hints.push("Each range in writtenNotExecuted is code of the analyzer on bytes that the runs wrote and never executed. Its from gives the instructions that reach it. Examine the routine that holds them: a wrong entry point leads the analyzer into data. Correct the project knowledge, and run the analysis again.");
|
|
41
45
|
if (version.revision !== null && version.now !== undefined && version.last !== undefined && version.now !== version.last) {
|
|
42
46
|
hints.push(`The last analysis of this program used ${version.last}. Thus a change in revision ${version.revision} can come from the new analyzer version, and not from the program or the project knowledge.`);
|
|
43
47
|
}
|
|
@@ -51,6 +55,35 @@ function withHint(body: Record<string, unknown>, conflicts: number, coverageConf
|
|
|
51
55
|
return reply(body, { hint: hints.join(" ") });
|
|
52
56
|
}
|
|
53
57
|
|
|
58
|
+
/** A refused seed with $ addresses. */
|
|
59
|
+
function showRefused(seed: RefusedSeed) {
|
|
60
|
+
return { address: formatC64Address(seed.address), reason: seed.reason, ...(seed.at === undefined ? {} : { at: formatC64Address(seed.at) }) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The seeds part of a result: the counts that the analyzer got, the counts over its limits, and the seeds and data ranges that it left out. */
|
|
64
|
+
function seedsResult(given: Record<string, number>, overLimit: Record<string, number>, report: SeedReport, max: number) {
|
|
65
|
+
const over = Object.fromEntries(Object.entries(overLimit).filter(([, count]) => count > 0));
|
|
66
|
+
const byReason: Record<string, number> = {};
|
|
67
|
+
for (const seed of report.refused) byReason[seed.reason] = (byReason[seed.reason] ?? 0) + 1;
|
|
68
|
+
return {
|
|
69
|
+
...given,
|
|
70
|
+
...(Object.keys(over).length === 0 ? {} : { overLimit: over }),
|
|
71
|
+
...(report.refused.length === 0 ? {} : { refused: { ...listed(report.refused, max, showRefused), byReason } }),
|
|
72
|
+
...(report.dataRangesLeftOut.length === 0 ? {} : { dataRangesLeftOut: listed(report.dataRangesLeftOut, max, (range) => ({ start: formatC64Address(range.start), end: formatC64Address(range.end), code: formatC64Address(range.code) })) }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The code regions of the analyzer on bytes that the runs wrote and never executed, from the knowledge after the import. */
|
|
77
|
+
function writtenNotExecutedOf(analyzer: Analyzer, space: string, coverage: Uint8Array | undefined) {
|
|
78
|
+
if (coverage === undefined) return [];
|
|
79
|
+
const db = openForRead();
|
|
80
|
+
try {
|
|
81
|
+
return writtenNotExecuted(db, analyzer, coverage, space);
|
|
82
|
+
} finally {
|
|
83
|
+
db?.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
54
87
|
/** A pitfall with $ addresses and what goes wrong. */
|
|
55
88
|
function showPitfall(pitfall: Pitfall) {
|
|
56
89
|
return {
|
|
@@ -216,13 +249,16 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
216
249
|
const kinds = analyzer === "dxa" || coverage === undefined ? { routines: fromCoverage, codeStarts: [] } : coverageSeedKinds(coverage, inProgram);
|
|
217
250
|
const ordered = [...new Set([...known, ...idioms.entryPoints, ...kinds.routines])];
|
|
218
251
|
seeds.entryPoints = ordered.slice(0, DECOMPILER_LIMITS.entryPoints).sort((a, b) => a - b);
|
|
219
|
-
const
|
|
252
|
+
const allCodeStarts = kinds.codeStarts.filter((entry) => !seeds.entryPoints.includes(entry));
|
|
253
|
+
const codeStarts = allCodeStarts.slice(0, DECOMPILER_LIMITS.codeStarts);
|
|
220
254
|
// Idiom tables and the RAM under ROM that the runs never used are data for this run too; semantic data ranges come first.
|
|
221
255
|
// A range with an entry point of the knowledge or --entry in it is left out: that code stays code.
|
|
222
256
|
const fromRom = coverage === undefined ? [] : romOnlyRanges(coverage, byteAt).filter((range) => !known.some((entry) => entry >= range.start && entry <= range.end));
|
|
223
257
|
const dataRanges = [...seeds.dataRanges];
|
|
224
258
|
for (const range of [...idioms.dataRanges, ...fromRom]) if (!dataRanges.some((seed) => range.start <= seed.end && range.end >= seed.start)) dataRanges.push(range);
|
|
225
259
|
seeds.dataRanges = dataRanges.slice(0, DECOMPILER_LIMITS.dataRanges);
|
|
260
|
+
// The seeds over the limits of the analyzer: it never sees them.
|
|
261
|
+
const overLimit = { entryPoints: Math.max(0, ordered.length - DECOMPILER_LIMITS.entryPoints), codeStarts: allCodeStarts.length - codeStarts.length, dataRanges: Math.max(0, dataRanges.length - DECOMPILER_LIMITS.dataRanges) };
|
|
226
262
|
const romUsed = fromRom.filter((range) => seeds.dataRanges.includes(range)).length;
|
|
227
263
|
const coverageUsed = fromCoverage.filter((entry) => seeds.entryPoints.includes(entry) || codeStarts.includes(entry)).length;
|
|
228
264
|
// Platform names are C64 names: drive code and banks get none.
|
|
@@ -253,6 +289,7 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
253
289
|
revision: imported.revision,
|
|
254
290
|
changes: { regions: imported.regions, references: imported.references },
|
|
255
291
|
conflicts: imported.conflicts.map((conflict) => showConflict(conflict, "heuristic")),
|
|
292
|
+
...(idioms.leftOut.length === 0 ? {} : { leftOut: listed(idioms.leftOut, max, (item) => ({ start: formatC64Address(item.start), end: formatC64Address(item.end), kind: item.kind, reason: item.reason })) }),
|
|
256
293
|
// Candidates are not knowledge: a larger --max-listed gives more of them.
|
|
257
294
|
candidates: {
|
|
258
295
|
dop: listed(idioms.candidates.dop, max, formatC64Address, "a larger --max-listed"),
|
|
@@ -289,7 +326,7 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
289
326
|
};
|
|
290
327
|
};
|
|
291
328
|
if (analyzer === "dxa") {
|
|
292
|
-
const { result, attachments } = await analyzeWithDxa({ imageKind, ...seeds }, bytes, localToolContext());
|
|
329
|
+
const { result, attachments, seeds: report } = await analyzeWithDxa({ imageKind, ...seeds }, bytes, localToolContext());
|
|
293
330
|
const listing = attachments[0]!.toString("utf8");
|
|
294
331
|
// The listing is written only after the import: a refused import leaves no new file.
|
|
295
332
|
const imported = record({ ...dxaFindings(result), space, ...executed }, revision, "DXA analysis of the program", runProvenance(bytes, result.toolVersion));
|
|
@@ -303,22 +340,25 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
303
340
|
}
|
|
304
341
|
}
|
|
305
342
|
const found = idiomsResult();
|
|
343
|
+
const runOnWritten = writtenNotExecutedOf("dxa", space, coverage);
|
|
306
344
|
const body = {
|
|
307
345
|
analyzer: "dxa",
|
|
308
346
|
...(result.toolVersion === undefined ? {} : { analyzerVersion: result.toolVersion }),
|
|
309
347
|
...(space === DEFAULT_SPACE ? {} : { space }),
|
|
310
|
-
...
|
|
348
|
+
...imported,
|
|
349
|
+
seeds: seedsResult({ entryPoints: seeds.entryPoints.length, dataRanges: seeds.dataRanges.length }, { entryPoints: overLimit.entryPoints, dataRanges: overLimit.dataRanges }, report, max),
|
|
311
350
|
...coverageResult(),
|
|
351
|
+
...(runOnWritten.length === 0 ? {} : { writtenNotExecuted: listed(runOnWritten, max, showWritten) }),
|
|
352
|
+
...found,
|
|
312
353
|
coverage: result.coverage.map((range) => ({ start: formatC64Address(range.start), end: formatC64Address(range.end) })),
|
|
313
|
-
|
|
314
|
-
regions: result.regions.map((region) => ({ start: formatC64Address(region.start), end: formatC64Address(region.end), classification: region.classification })),
|
|
354
|
+
regions: listed(result.regions, max, (region) => ({ start: formatC64Address(region.start), end: formatC64Address(region.end), classification: region.classification }), ALL_REGIONS),
|
|
315
355
|
labels: listed(result.labels, max, (label) => ({ address: formatC64Address(label.address), name: label.name }), ALL_NAMES),
|
|
316
356
|
...(written === undefined ? {} : { listing: written }),
|
|
317
357
|
};
|
|
318
|
-
return withHint(body, imported.conflicts.length + found.idioms.conflicts.length, body.coverageConflicts?.length ?? 0, { candidates: found.idioms.candidates.macros.count, applied: applyMacros, revision: found.idioms.candidates.macros.revision }, { now: result.toolVersion, last: lastVersion, revision: imported.revision }, imported.changes.references.retired);
|
|
358
|
+
return withHint(body, imported.conflicts.length + found.idioms.conflicts.length, body.coverageConflicts?.length ?? 0, { candidates: found.idioms.candidates.macros.count, applied: applyMacros, revision: found.idioms.candidates.macros.revision }, { now: result.toolVersion, last: lastVersion, revision: imported.revision }, imported.changes.references.retired, { refused: report.refused.length, writtenNotExecuted: runOnWritten.length });
|
|
319
359
|
}
|
|
320
360
|
|
|
321
|
-
const { result } = await analyzeWithDecompiler({ imageKind, ...seeds, codeStarts, decompile }, bytes, localToolContext());
|
|
361
|
+
const { result, seeds: report } = await analyzeWithDecompiler({ imageKind, ...seeds, codeStarts, decompile }, bytes, localToolContext());
|
|
322
362
|
// Executed instruction starts that the decompiler did not decode: the instruction list and the source miss them.
|
|
323
363
|
const decoded = new Set(result.instructions.map((instruction) => instruction.address));
|
|
324
364
|
const imported = record({ ...decompilerFindings(result), space, ...executed }, revision, "Decompiler analysis of the program", runProvenance(bytes, result.toolVersion));
|
|
@@ -329,6 +369,8 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
329
369
|
const overlaps = listRegions(overlapDb, undefined, "dual-use", undefined, space);
|
|
330
370
|
overlapDb?.close();
|
|
331
371
|
const gaps = coverage === undefined ? [] : executedStarts(coverage, inProgram).filter((address) => address >= loaded.start && address <= loaded.end && !decoded.has(address) && !overlaps.some((region) => address >= region.start && address <= region.end));
|
|
372
|
+
const explained = explainGaps(gaps, result.instructions, report.refused, seeds.dataRanges);
|
|
373
|
+
const runOnWritten = writtenNotExecutedOf("decompiler", space, coverage);
|
|
332
374
|
let instructions: Record<string, unknown> | undefined;
|
|
333
375
|
if (instructionsPath !== undefined) {
|
|
334
376
|
const list = instructionList(result.instructions, coverage);
|
|
@@ -338,19 +380,31 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
338
380
|
analyzer: "decompiler",
|
|
339
381
|
...(result.toolVersion === undefined ? {} : { analyzerVersion: result.toolVersion }),
|
|
340
382
|
...(space === DEFAULT_SPACE ? {} : { space }),
|
|
341
|
-
...
|
|
342
|
-
|
|
383
|
+
...imported,
|
|
384
|
+
seeds: seedsResult({ entryPoints: seeds.entryPoints.length, codeStarts: codeStarts.length, dataRanges: seeds.dataRanges.length }, overLimit, report, max),
|
|
343
385
|
...coverageResult(),
|
|
344
|
-
...(coverage === undefined ? {} : { coverageGaps: listed(
|
|
386
|
+
...(coverage === undefined ? {} : { coverageGaps: listed(explained, max, showGap, "a larger --max-listed") }),
|
|
387
|
+
...(runOnWritten.length === 0 ? {} : { writtenNotExecuted: listed(runOnWritten, max, showWritten) }),
|
|
388
|
+
...found,
|
|
389
|
+
...(instructions === undefined ? {} : { instructions }),
|
|
345
390
|
coverage: result.coverage.map((range) => ({ start: formatC64Address(range.start), end: formatC64Address(range.end) })),
|
|
346
|
-
...imported,
|
|
347
391
|
functions: listed(result.functions, max, (fn) => ({ entry: formatC64Address(fn.entry), name: fn.name }), ALL_NAMES),
|
|
348
392
|
decompilations: result.decompilations.map((item) => ({ entry: formatC64Address(item.entry), text: item.text, ...(item.truncated ? { truncated: true } : {}) })),
|
|
349
393
|
...((result.notDecompiled ?? []).length === 0
|
|
350
394
|
? {}
|
|
351
395
|
: { notDecompiled: result.notDecompiled!.map((item) => ({ entry: formatC64Address(item.entry), reason: item.reason })) }),
|
|
352
396
|
};
|
|
353
|
-
return withHint(body, imported.conflicts.length + found.idioms.conflicts.length, body.coverageConflicts?.length ?? 0, { candidates: found.idioms.candidates.macros.count, applied: applyMacros, revision: found.idioms.candidates.macros.revision }, { now: result.toolVersion, last: lastVersion, revision: imported.revision }, imported.changes.references.retired);
|
|
397
|
+
return withHint(body, imported.conflicts.length + found.idioms.conflicts.length, body.coverageConflicts?.length ?? 0, { candidates: found.idioms.candidates.macros.count, applied: applyMacros, revision: found.idioms.candidates.macros.revision }, { now: result.toolVersion, last: lastVersion, revision: imported.revision }, imported.changes.references.retired, { refused: report.refused.length, writtenNotExecuted: runOnWritten.length });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** A coverage gap with $ addresses. */
|
|
401
|
+
function showGap(gap: GapReason) {
|
|
402
|
+
return { address: formatC64Address(gap.address), reason: gap.reason, ...(gap.at === undefined ? {} : { at: formatC64Address(gap.at) }), ...(gap.range === undefined ? {} : { range: { start: formatC64Address(gap.range.start), end: formatC64Address(gap.range.end) } }) };
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** A range of writtenNotExecuted with $ addresses. */
|
|
406
|
+
function showWritten(range: { start: number; end: number; from: number[] }) {
|
|
407
|
+
return { start: formatC64Address(range.start), end: formatC64Address(range.end), from: range.from.map(formatC64Address) };
|
|
354
408
|
}
|
|
355
409
|
|
|
356
410
|
await runScript({
|
|
@@ -27,9 +27,12 @@ To get the command list, run the script with no arguments.
|
|
|
27
27
|
| Keep the screens and all differing bytes of a FAIL | `test tests/moves-left.json --out .c64-re-tools/local/results/moves-left` |
|
|
28
28
|
| Do many steps on one program and keep the results as files | `run .c64-re-tools/local/runs/rooms/run.json --out .c64-re-tools/local/runs/rooms` |
|
|
29
29
|
| Test a new program or a correction with expected values | `run tests/title.json --out .c64-re-tools/local/runs/title` |
|
|
30
|
+
| Keep a run as evidence in a folder that git keeps | `keep .c64-re-tools/local/runs/rooms/run.json .c64-re-tools/local/runs/rooms runs/rooms` |
|
|
30
31
|
| Record a play session of a person on the reference | `record tests/record/start.json --out tests/recordings/play1 --play --joystick 1` |
|
|
31
32
|
| Record a session from steps only | `record tests/record/rooms.json --out tests/recordings/rooms` |
|
|
33
|
+
| Find the input sites and the coverage of a recording | `show tests/recordings/rooms` |
|
|
32
34
|
| Make sure that a recording replays on the reference | `replay tests/recordings/rooms` |
|
|
35
|
+
| Keep the screen at the end of a recorded session | `replay tests/recordings/final --screen .c64-re-tools/local/results/final.png` |
|
|
33
36
|
| Compare the rebuild with a recording | `replay tests/recordings/rooms --checkpoint main_loop --state room --state lives --pin random_ptr:2 --rebuild build/clean.prg --symbols build/symbols/clean.json --out .c64-re-tools/local/results/rooms` |
|
|
34
37
|
| Find what changed between two snapshot files | `diff .c64-re-tools/local/runs/rooms/before.vsf .c64-re-tools/local/runs/rooms/after.vsf` |
|
|
35
38
|
| Find what changed between two observations of runs | `diff .c64-re-tools/local/runs/rooms/results.json:room0 .c64-re-tools/local/runs/rooms/results.json:room3` |
|
|
@@ -42,6 +45,7 @@ To get the command list, run the script with no arguments.
|
|
|
42
45
|
- The reference program and the rebuild are PRG files in the project. The script refuses a disk, tape or cartridge image. Extract the program file from the image first.
|
|
43
46
|
- The reference gets its names from the project knowledge. Give `"symbols": "knowledge"` for the reference.
|
|
44
47
|
- The rebuild gets its names from the symbol file of its build. Build the rebuild with a symbol file that has all symbols, also the constants that the source does not use.
|
|
48
|
+
- The loader program of a generated source can show a start screen that waits for a key. If the symbols of the program have the labels of that start screen, `test`, `run` and `replay` start the program after the start screen. Do not add a step for the start screen.
|
|
45
49
|
- You write the scenario file, the run file and the record file. Their formats are in the files of the section "Reference".
|
|
46
50
|
- A file in `tests/` is a scenario or a run file with expected values. Give a scenario to `test` and a run file to `run`. `test` refuses a run file.
|
|
47
51
|
- `<recording>` is the `--out` folder of `record`.
|
|
@@ -61,12 +65,11 @@ To get the command list, run the script with no arguments.
|
|
|
61
65
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
62
66
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
63
67
|
- Write each file that you make for your work in `.c64-re-tools/local/` of the project. Git ignores that folder. Examples are results, batches, step files, runs, snapshots and memory dumps.
|
|
64
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
68
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
65
69
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
66
70
|
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
67
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
68
|
-
-
|
|
69
|
-
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
71
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
72
|
+
- To keep a run as evidence, use the command that keeps a run. It copies the run, its results and its snapshot files into `runs/<name>/`, and it changes the paths in the copy. Then git keeps them, and another person can do the run again.
|
|
70
73
|
- A shell redirect (`>`) is relative to the working directory, not to the project folder. From the folder above the project, write `<folder>/.c64-re-tools/local/result.json`.
|
|
71
74
|
|
|
72
75
|
## Flags
|
|
@@ -82,12 +85,14 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
82
85
|
| `--play` | `record` | A person plays after the steps. Off by default. |
|
|
83
86
|
| `--joystick <1\|2>` | `record` | With `--play`: the joystick port at the start. The default is 2. |
|
|
84
87
|
| `--http-port <n>` | `record` | With `--play`: the port of the page. The default is 6465. |
|
|
88
|
+
| `--max-listed <n>` | `show` | List at most n input sites. The default is 50. The count is always in the body. |
|
|
85
89
|
| `--checkpoint <routine>` | `replay` | The routine of the checkpoints. Each entry of the routine is a checkpoint. The default is the comparison of the record file. |
|
|
86
90
|
| `--state <item>` | `replay` | A memory item to compare at each checkpoint. Give it again for each item. |
|
|
87
91
|
| `--pin <item>` | `replay` | Random state in RAM. At each checkpoint, the rebuild gets the values of the reference there. Give it again for each item. |
|
|
88
92
|
| `--rebuild <prg>` | `replay` | The rebuild to compare with the reference. Without it, the script replays only on the reference. |
|
|
89
93
|
| `--symbols <file>` | `replay` | The symbol file of the rebuild. The default is the symbols of the recording. |
|
|
90
94
|
| `--out <dir>` | `replay` | With a FAIL, write the RAM of each side at the first different checkpoint into this folder. |
|
|
95
|
+
| `--screen <png>` | `replay` | Write the screen of the reference at the end of the session into this PNG file. |
|
|
91
96
|
| `--gap <n>` | `diff` | Join changed ranges across at most n equal bytes. The default is 0. |
|
|
92
97
|
| `--max-listed <n>` | `diff` | List at most n items of each list. The default is 50. |
|
|
93
98
|
| `--ntsc` | `diff` | The snapshot files are of an NTSC machine. The default is PAL. |
|
|
@@ -102,7 +107,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
102
107
|
### `test <scenario.json>`
|
|
103
108
|
|
|
104
109
|
The script runs the scenario on the reference and then on the rebuild. Before each side, it does a hard reset. The CPU then stops at the reset vector.
|
|
105
|
-
Before the test starts, the script examines the scenario and each file that it names. The section "Checks" of
|
|
110
|
+
Before the test starts, the script examines the scenario and each file that it names. The section "Checks" of `<skill>/references/scenario-format.md` gives each refusal.
|
|
106
111
|
|
|
107
112
|
`body` holds:
|
|
108
113
|
|
|
@@ -112,7 +117,7 @@ Before the test starts, the script examines the scenario and each file that it n
|
|
|
112
117
|
- A memory item gives `bytes`. `bytes.count` is the number of differing bytes. `bytes.listed` gives the first bytes, each with `address`, `reference` and `rebuild`.
|
|
113
118
|
- Another item gives the `reference` value and the `rebuild` value.
|
|
114
119
|
- `excluded`: each byte that an `exclude` left out of the comparison, with its `reason`.
|
|
115
|
-
- `files`: with `--out` and a FAIL, the files that the script wrote. These are both screens
|
|
120
|
+
- `files`: with `--out` and a FAIL, the files that the script wrote. These are both screens, the difference image for each screen difference, and all bytes of each memory item that differs.
|
|
116
121
|
- `reason`: with an INCONCLUSIVE, why the script could not compare.
|
|
117
122
|
|
|
118
123
|
The pc and each address are `$xxxx`. Memory is lowercase hex. Other register values and chip values are decimal numbers.
|
|
@@ -149,8 +154,8 @@ A run file must have `name`, `start` and `steps`:
|
|
|
149
154
|
{ "name": "rooms", "start": { "program": "game.prg" }, "steps": [{ "frames": 100 }, { "screen": "title" }] }
|
|
150
155
|
```
|
|
151
156
|
|
|
152
|
-
`symbols` and `videoStandard` are optional. The section "Runs" of
|
|
153
|
-
Before the run starts, the script examines the run file, each file that it names and each name of the steps. The section "Checks" of
|
|
157
|
+
`symbols` and `videoStandard` are optional. The section "Runs" of `<skill>/references/scenario-format.md` gives each key and step.
|
|
158
|
+
Before the run starts, the script examines the run file, each file that it names and each name of the steps. The section "Checks" of `<skill>/references/scenario-format.md` gives each refusal.
|
|
154
159
|
|
|
155
160
|
`body` holds:
|
|
156
161
|
|
|
@@ -158,8 +163,9 @@ Before the run starts, the script examines the run file, each file that it names
|
|
|
158
163
|
- `completed`, `steps` and `done`: if the run completed, the number of steps, and the number of steps that ran.
|
|
159
164
|
- `reason`: why a step did not run.
|
|
160
165
|
- `pc`: the pc at the end of the run.
|
|
166
|
+
- `startScreen`: `skipped` when the run started the program after its start screen.
|
|
161
167
|
- `files`: each file that the run wrote.
|
|
162
|
-
- `observations`: the
|
|
168
|
+
- `observations`: the values of each observation, by its name. Memory is hex. A memory item of more than 4096 bytes, and `"memory": "all"`, give the name of their file in `file`.
|
|
163
169
|
- `expectations`: for each `expect` step, `pass`, `count` and at most 16 `mismatches` with the expected and the actual value.
|
|
164
170
|
- `failedExpectations`: the names of the `expect` steps that did not pass.
|
|
165
171
|
- `traces`: for each `trace` step, its file, the count of hits, the frames and why the trace ended.
|
|
@@ -171,6 +177,20 @@ Traps:
|
|
|
171
177
|
- A long run can need more time than one shell call. Then run the command in the background.
|
|
172
178
|
- Add each coverage map of a run to the project knowledge as coverage.
|
|
173
179
|
|
|
180
|
+
### `keep <run.json> <out> <folder>`
|
|
181
|
+
|
|
182
|
+
The script keeps a run as evidence in a new folder that git keeps, for example `runs/rooms`. `<out>` is the `--out` folder of the run.
|
|
183
|
+
The script copies the run file, the files of the run in `<out>`, and each file in `.c64-re-tools/local/` that the run file names. In the copy of the run file, it changes only the paths of the copied files.
|
|
184
|
+
|
|
185
|
+
`body` holds:
|
|
186
|
+
|
|
187
|
+
- `out`: the new folder. The copy of the run file is `run.json` in it.
|
|
188
|
+
- `files`: each file that the script wrote.
|
|
189
|
+
- `paths`: each path that changed in the run file, with its `field`, the old path in `from` and the new path in `to`.
|
|
190
|
+
|
|
191
|
+
Commit the folder, and give its files as evidence, as `hint` tells. The script refuses a folder that exists, a folder that git ignores, and an `<out>` with the results of another run.
|
|
192
|
+
If you changed the run file after the run, run it again before you keep it. The results must agree with the run file.
|
|
193
|
+
|
|
174
194
|
---
|
|
175
195
|
|
|
176
196
|
## Recordings
|
|
@@ -183,13 +203,11 @@ A recording keeps a session of the reference program, for example a play through
|
|
|
183
203
|
- Replay each recording on the default build. Do not replay a release build or a build with a switch that is not at its default.
|
|
184
204
|
- When the generated source has a loader, the default build is `build/clean_loader.prg`. Give `--symbols build/symbols/clean_loader.json` with it. Else the default build is `build/clean.prg`, with `--symbols build/symbols/clean.json`.
|
|
185
205
|
- Commit the recording folder with the scenarios. Do not put a recording into the project knowledge. Do not put test results, screenshots or playtest results into it.
|
|
186
|
-
- A finding that a recording shows can go into the project knowledge. Give
|
|
206
|
+
- A finding that a recording shows can go into the project knowledge. Give `evidence` of `show` as its test evidence.
|
|
187
207
|
- The C64 of a recording has no disk drive. For a program that loads more files from a disk, use a scenario with `test`.
|
|
188
|
-
- The emulator cannot examine the C64 of a recording or a replay.
|
|
208
|
+
- The emulator cannot examine the C64 of a recording or a replay. To keep the screen at the end of a recorded session, use `--screen` of `replay`.
|
|
189
209
|
|
|
190
|
-
A replay
|
|
191
|
-
|
|
192
|
-
Control each source of random numbers:
|
|
210
|
+
A replay gives the rebuild the same input as the reference, also when the timing of the rebuild is different. Control each source of random numbers:
|
|
193
211
|
|
|
194
212
|
- A program that reads a seed from the SID gets the recorded value. You do not need to do more.
|
|
195
213
|
- A program that reads a seed from the raster line or a CIA timer: add the address to `inputs` of the record file. Do this only when the program does not wait in a loop on that address.
|
|
@@ -197,7 +215,7 @@ Control each source of random numbers:
|
|
|
197
215
|
|
|
198
216
|
### `record <record.json>`
|
|
199
217
|
|
|
200
|
-
The script does the steps of the record file on the reference program. Then it writes the recording folder
|
|
218
|
+
The script does the steps of the record file on the reference program. Then it writes the recording into the folder `--out`. The program must be a PRG file.
|
|
201
219
|
|
|
202
220
|
`body` holds:
|
|
203
221
|
|
|
@@ -212,20 +230,18 @@ The script does the steps of the record file on the reference program. Then it w
|
|
|
212
230
|
|
|
213
231
|
Do this for each result:
|
|
214
232
|
|
|
215
|
-
- `PASS`: for a folder in `tests/recordings/`, `hint` tells you to commit the folder and to add its
|
|
216
|
-
- `PASS` with `evidence`: you recorded into the folder of an earlier recording. Put the new
|
|
233
|
+
- `PASS`: for a folder in `tests/recordings/`, `hint` tells you to commit the folder and to add its coverage map to the project knowledge as coverage. Git ignores `.c64-re-tools/local/`, thus the project knowledge must not name a file in it. For a folder there, `hint` tells you to record again with `--out tests/recordings/<name>`. `nextAction` replays the recording on the reference. Run it to make sure that the recording replays.
|
|
234
|
+
- `PASS` with `evidence`: you recorded into the folder of an earlier recording. Put the new coverage map into the project knowledge as coverage, as `hint` tells. It replaces the map of the earlier recording. For another file in `evidence`, examine the facts of its revisions against the new recording.
|
|
217
235
|
- `FAIL` after a cancel on the page: `hint` tells you to ask the user what to do. Do not record a session from steps in place of the session of the user.
|
|
218
236
|
- Another `FAIL`: `reason` names the step that did not complete. Examples are a `runUntil` step that did not get to its target, and a `type` step with too many keys. Change the step, then run `record` again.
|
|
219
237
|
- `coverageFrom` is `null` and `executed` is 0: the coverage did not start, so the coverage map is empty. The recording can still replay.
|
|
220
238
|
|
|
221
239
|
With `--play`, a person plays the program after the steps. The steps can start the program, for example a key for an intro.
|
|
222
240
|
|
|
223
|
-
- The script writes the address of a page to stderr. Give the address to the user.
|
|
224
|
-
- The page shows the screen after the steps. The C64 is frozen until the user pushes Enter or clicks Start. Tell the user to read the screen first.
|
|
225
|
-
-
|
|
226
|
-
-
|
|
227
|
-
- End (F12) stops the C64 and freezes the screen. Then the script writes the recording folder. Run the command in the background.
|
|
228
|
-
- Cancel (F11) stops the session. The script writes no folder.
|
|
241
|
+
- The script writes the address of a page to stderr. Give the address to the user. Run the command in the background.
|
|
242
|
+
- The page shows the screen after the steps. The C64 is frozen until the user pushes Enter or clicks Start. Tell the user to read the screen first, and that F9 changes the joystick port.
|
|
243
|
+
- The page sends the full C64 keyboard and the joystick, also from a gamepad. It shows its buttons and its key maps.
|
|
244
|
+
- End (F12) stops the C64. Then the script writes the recording folder. Cancel (F11) stops the session, and the script writes no folder.
|
|
229
245
|
|
|
230
246
|
Traps:
|
|
231
247
|
|
|
@@ -233,18 +249,39 @@ Traps:
|
|
|
233
249
|
- Put a `runUntil` step with the checkpoint routine before a `registers` step. A `registers` step that sets the pc during an interrupt stops the program.
|
|
234
250
|
- A record file has no `raster` target and no `condition`. The script refuses them.
|
|
235
251
|
|
|
252
|
+
### `show <recording>`
|
|
253
|
+
|
|
254
|
+
The script tells what a recording holds. It does not replay the recording. Use it in place of your own read of the files of a recording.
|
|
255
|
+
|
|
256
|
+
`body` holds:
|
|
257
|
+
|
|
258
|
+
- `name`, `program`, `symbols`, `load` and `inputs`: the values of the record file. `checkpoint`, `state` and `pin`: its comparison, if it has one.
|
|
259
|
+
- `frames` and `events`: the length of the session, and the number of events.
|
|
260
|
+
- `inputSites`: each instruction that read input, in the order of its address. Each item has the `site`, the `address` that it read, the number of `reads`, and the number of `changes` of the value. A site with 0 `changes` got the same value at each read.
|
|
261
|
+
- `coverage`: the number of RAM addresses in the coverage map that the session `executed`, `read` and `written`.
|
|
262
|
+
- `evidence`: the test evidence for a finding that the recording shows.
|
|
263
|
+
|
|
236
264
|
### `replay <recording>`
|
|
237
265
|
|
|
238
266
|
The script first replays the recording on the reference. The reference must end the session with the recorded state. With `--rebuild`, the script then replays the recording on the rebuild and compares the state at each checkpoint. Without `--rebuild`, it replays only on the reference.
|
|
239
267
|
|
|
240
268
|
`--checkpoint` and `--state` go together. `--pin` needs both of them. `--symbols` needs `--rebuild`. Give at most 16 `--state` and `--pin` items. Without `--checkpoint`, the script uses the comparison of the record file.
|
|
241
|
-
A `$` address is an address of the reference. On the rebuild, it moves with the name before it.
|
|
269
|
+
A `$` address is an address of the reference. On the rebuild, it moves with the name before it. Give each state item a name when you can.
|
|
270
|
+
`--screen` writes the screen of the reference at the end of the session into a PNG file. The screen is the same on each replay. The script writes it only when the reference ends the session with the recorded state.
|
|
242
271
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
A rebuild can be the loader program of a generated source. Give its symbols. Then the replay counts from the entry of the program, where the loader jumps to. The checkpoints of both sides start at that entry. At the entry, the rebuild gets the raster position, the CIA timers and the interrupt state of the reference. The loader cannot set them as the reference has them in the replay. A runUntil step to an address does not count the code of the loader, or the code that the reference runs before that entry. If another step of the recording runs before the entry, the result is INCONCLUSIVE. Then start the steps of the record file after the entry.
|
|
272
|
+
`body` holds:
|
|
246
273
|
|
|
247
|
-
|
|
274
|
+
- `result`: `PASS`, `FAIL` or `INCONCLUSIVE`.
|
|
275
|
+
- `side`: `reference` for the check of the reference only, `rebuild` with `--rebuild`.
|
|
276
|
+
- `checkpoint`: the routine of the comparison.
|
|
277
|
+
- `checkpoints` and `compared`: the checkpoints of the reference, and the checkpoints of the rebuild that were the same.
|
|
278
|
+
- `firstDifference`: with a FAIL, the checkpoint (1 is the first), the cycle on each side, and each state item that is different. An item has `address`, and the `reference` and `rebuild` values as hex.
|
|
279
|
+
- `reason`: why the result is FAIL or INCONCLUSIVE.
|
|
280
|
+
- `movedSites`: the number of input sites at a different address in the rebuild.
|
|
281
|
+
- `startScreen`: `skipped` when the rebuild started after its start screen.
|
|
282
|
+
- `idleReads`: the number of input reads of the rebuild that the recording had no value for.
|
|
283
|
+
- `files`: with `--out` and a FAIL, the RAM of each side at the first different checkpoint.
|
|
284
|
+
- `screen`: with `--screen`, the PNG file of the screen of the reference at the end of the session.
|
|
248
285
|
|
|
249
286
|
Do this for each result:
|
|
250
287
|
|
|
@@ -256,10 +293,12 @@ Do this for each result:
|
|
|
256
293
|
- "does not reproduce": the reference does not end the session with the recorded state. Record the session again.
|
|
257
294
|
- "never came to the checkpoint": the reference did not execute the checkpoint routine in the session. Give another routine.
|
|
258
295
|
- "is not the program of the recording": the program file changed after the recording. Record the session again.
|
|
296
|
+
- "ran before the program came to its entry": a step of the recording ran in the loader of the rebuild. Make the steps of the record file start after the entry of the program. Then record the session again.
|
|
259
297
|
|
|
260
298
|
Traps:
|
|
261
299
|
|
|
262
|
-
-
|
|
300
|
+
- A run does not have the timing of a recording. The same steps in a run can give a different session, for example a lost fight. To show the screen of a recorded session, use `replay --screen`. Do not do the steps again in a run.
|
|
301
|
+
- On the reference, an input read with no recorded value makes the result INCONCLUSIVE. The rebuild can read input where the reference does not, for example in its loader before the start screen. `idleReads` counts these reads. They do not change a PASS of the rebuild.
|
|
263
302
|
- The script refuses a recording of an older version in an old form with `invalid-input`. Record the session again.
|
|
264
303
|
|
|
265
304
|
---
|
|
@@ -310,24 +349,15 @@ Give the checklist to the human tester. Do not put the results of the playtest i
|
|
|
310
349
|
|
|
311
350
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
312
351
|
|
|
313
|
-
On success, the exit code is 0:
|
|
314
|
-
|
|
315
|
-
```json
|
|
316
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
On failure, the exit code is 2:
|
|
320
|
-
|
|
321
|
-
```json
|
|
322
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
323
|
-
```
|
|
324
|
-
|
|
352
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
353
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
325
354
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
326
355
|
- A check gives its verdict in `body.result`: `PASS`, `FAIL` or `INCONCLUSIVE`. The exit code is 0 for each verdict. Thus read `body.result`, not the exit code.
|
|
327
|
-
- `error` is one sentence. It tells what is wrong.
|
|
328
|
-
- `
|
|
329
|
-
- `
|
|
330
|
-
- `
|
|
356
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
357
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
358
|
+
- A list has `count`, `listed` and `rest`. `listed` holds at most `--max-listed` items. `rest` tells how to get the other items. A file that the command wrote has `out`, `bytes` and `sha256`.
|
|
359
|
+
- To get only some fields of `body`, give `--fields <path>,<path>`, for example `--fields count,listed.start`. A path through a list gives that field of each item. Do not write code to filter an envelope.
|
|
360
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
331
361
|
|
|
332
362
|
| `code` | Action |
|
|
333
363
|
|---|---|
|
|
@@ -336,19 +366,7 @@ On failure, the exit code is 2:
|
|
|
336
366
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
337
367
|
| Another code | Do as `hint` tells. |
|
|
338
368
|
|
|
339
|
-
These fields have the same meaning in each body:
|
|
340
|
-
|
|
341
|
-
| Field | Meaning |
|
|
342
|
-
|---|---|
|
|
343
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
344
|
-
| `count`, `listed`, `rest` | A list. `count` is the number of items. `listed` holds the first items, at most `--max-listed`. `rest` tells how to get the other items. |
|
|
345
|
-
|
|
346
|
-
To get the command list, run the script with no arguments. The envelope has `command: "help"`, and `body.commands` gives the name, the summary and the synopsis of each command.
|
|
347
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|
|
348
|
-
|
|
349
|
-
---
|
|
350
|
-
|
|
351
369
|
## Reference
|
|
352
370
|
|
|
353
|
-
-
|
|
354
|
-
-
|
|
371
|
+
- `<skill>/references/scenario-format.md`: the scenario file of `test` and the run file of `run`. It gives each step, each observation, the expected values, and the checks before a test or a run.
|
|
372
|
+
- `<skill>/references/recording-format.md`: the record file of `record` and its steps.
|