@henols/c64-re-tools 2.6.0-rc.14 → 2.6.0-rc.15
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 +3 -3
- package/skills/c64-assembler/scripts/assembler.ts +4 -3
- package/skills/c64-docs/SKILL.md +1 -1
- package/skills/c64-docs/scripts/lib/reference.ts +28 -6
- package/skills/c64-docs/scripts/lib/source-map.ts +14 -0
- package/skills/c64-knowledge/SKILL.md +2 -2
- package/skills/c64-knowledge/scripts/knowledge.ts +9 -1
- package/skills/c64-source/SKILL.md +1 -1
- package/skills/c64-source/scripts/lib/loader.ts +2 -0
- package/skills/c64-source/scripts/source.ts +9 -4
- package/skills/c64-static-analysis/SKILL.md +1 -0
- package/skills/c64-static-analysis/scripts/static-analysis.ts +5 -3
- package/skills/c64-testing/scripts/testing.ts +5 -3
- package/src/build-name.ts +9 -4
- package/src/native/c64run.ts +1 -1
- package/tools/c64run.c +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henols/c64-re-tools",
|
|
3
|
-
"version": "2.6.0-rc.
|
|
3
|
+
"version": "2.6.0-rc.15",
|
|
4
4
|
"description": "Agent-friendly Commodore 64 engineering toolkit for reverse engineering, debugging, development and testing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Henrik Olsson",
|
|
@@ -28,7 +28,7 @@ To get the command list, run the script with no arguments.
|
|
|
28
28
|
| Build a source that includes a file that you generated into a folder next to the source root | `build src boot.asm --out build/boot.prg --include ../build` |
|
|
29
29
|
| Build a source that sets no start address | `build src main.a --out build/game.prg --set-pc '$0801'` |
|
|
30
30
|
| Build a generated source with the values of `config.asm` | `build src main.asm` |
|
|
31
|
-
| Build the loader of a generated source | `build src loader.asm` |
|
|
31
|
+
| Build the loader of a generated source. For the packed form, this is only the copier. | `build src loader.asm` |
|
|
32
32
|
| Check that the rebuild is identical to the program in the project knowledge | `build src main.asm --compare` |
|
|
33
33
|
| Build a release and check it against the bytes of that release | `build src main.asm --release ORIGINAL --compare` |
|
|
34
34
|
| Check the rebuild of a program in another space, for example the drive | `build src main.asm --out build/drive.prg --compare --space drive8` |
|
|
@@ -68,7 +68,7 @@ Without `--out`, the name of the program tells what the build is:
|
|
|
68
68
|
| A value of `config.asm` is not its default | `custom_<switches>.prg`, for example `custom_trainer.prg`. A switch that is off has `no_` before its name, for example `custom_no_start_screen.prg`. |
|
|
69
69
|
| A source without `config.asm` | the name of the entry, for example `main.prg` |
|
|
70
70
|
|
|
71
|
-
An entry other than `main.asm` adds its name, for example `clean_loader.prg` for `loader.asm`. With `--plain`, the extension is `.bin`. Do not give `--out` for a build of a generated source. Then the name always tells the build.
|
|
71
|
+
An entry other than `main.asm` adds its name, for example `clean_loader.prg` for `loader.asm`. The `loader.asm` of the packed form holds only the copier, so its build is `clean_copier.prg`. The packed loader program `clean_loader.prg` of the generated source stays. With `--plain`, the extension is `.bin`. Do not give `--out` for a build of a generated source. Then the name always tells the build.
|
|
72
72
|
|
|
73
73
|
### Paths and the project folder
|
|
74
74
|
|
|
@@ -136,7 +136,7 @@ Assembles the source and writes the program to `--out`, or to `build/<name>.prg`
|
|
|
136
136
|
|
|
137
137
|
Do as the result tells:
|
|
138
138
|
|
|
139
|
-
- `result` is `PASS`: the program is at `out`. To run or debug the program, load the file at `out` into the emulator.
|
|
139
|
+
- `result` is `PASS`: the program is at `out`. To run or debug the program, load the file at `out` into the emulator. A generated source with a loader is different: the build of `main.asm` does not set the entry state, and it can hold bytes for $d000-$dfff. Load the loader program in its place.
|
|
140
140
|
- `result` is `FAIL` and `assembled` is `false`: the source has errors, and the script wrote no program. `hint` tells you to correct the source. Correct the source at the file and the line of each diagnostic. Then run `build` again.
|
|
141
141
|
- `result` is `FAIL` and `assembled` is `true`: the program is not identical to the reference. The script wrote the program. Read the first difference of each segment in `compare.segments`. Without `--release`, read the section "Switches" first.
|
|
142
142
|
- `hint` tells that `symbols` is cut: give a larger `--max-listed`, or read the symbols file for the full list.
|
|
@@ -84,12 +84,13 @@ await runScript({
|
|
|
84
84
|
}
|
|
85
85
|
const setPc = call.address("set-pc");
|
|
86
86
|
const { contents, ...tree } = readSourceTree(sourceRoot, call.strings("include"));
|
|
87
|
-
|
|
87
|
+
const inSource = (name: string) => tree.files.findIndex((file) => file.path === (tree.sourceDir === "" ? name : `${tree.sourceDir}/${name}`));
|
|
88
|
+
if (inSource(entry) < 0) throw new Refusal("not-found", `${entry} is not a file in ${sourceRoot}. Give the main source file relative to the source root.`);
|
|
88
89
|
// The name of the build tells what it is: the release, or the switch values of config.asm.
|
|
89
|
-
const config =
|
|
90
|
+
const config = inSource(CONFIG_FILE);
|
|
90
91
|
const kind: BuildKind | undefined = label !== undefined ? { release: label } : config < 0 ? undefined : { values: configValues(contents[config]!.toString("utf8")), defaults: switchDefaults(call.space) };
|
|
91
92
|
const plain = call.flag("plain");
|
|
92
|
-
const out = call.string("out") ?? `${BUILD_DIRECTORY}/${buildName(entry, kind)}.${plain ? "bin" : "prg"}`;
|
|
93
|
+
const out = call.string("out") ?? `${BUILD_DIRECTORY}/${buildName(entry, kind, contents[inSource(entry)]!.toString("utf8"))}.${plain ? "bin" : "prg"}`;
|
|
93
94
|
const params: AcmeParams = { ...tree, entrySource: entry, defines: { ...releaseDefine, ...Object.fromEntries(call.strings("define").map(parseDefine)) }, ...(setPc === undefined ? {} : { setPc }) };
|
|
94
95
|
|
|
95
96
|
const { result, attachments } = await assemble(params, contents, localToolContext());
|
package/skills/c64-docs/SKILL.md
CHANGED
|
@@ -114,7 +114,7 @@ The reference has these pages:
|
|
|
114
114
|
- `index.md`: each file of the source, with its range, its title, the count of routines and the count of names.
|
|
115
115
|
- `modules/<file>.md`: a call graph of the file, its data regions with their readers and writers, and an entry for each name. An entry has the comment, the callers and the table that holds the name. For a routine, it also has the calls, the jumps, the reads and the writes.
|
|
116
116
|
- `tables.md`: each table of addresses, jumps and words, entry by entry, with its target. An RTS table holds each target minus 1. The page gives the target.
|
|
117
|
-
- `memory-map.md`: each region in address order. Then each variable outside the program, with its comment and the routines that read it and write it.
|
|
117
|
+
- `memory-map.md`: each region in address order. Then each variable outside the program, with its comment and the routines that read it and write it. A platform name, for example a chip register, has a routine only where the source line uses that name. `(indexed)` after a routine tells that the line adds X or Y to the address. That access can also go to the addresses after it, which can have no row.
|
|
118
118
|
- `graphics.md`: each `sprite`, `bitmap`, `charset` and `screen` region. The project knowledge has no graphics mode. Thus a sprite, a bitmap or a charset shows in hires and in multicolour. A charset shows 16 characters in each row. A screen shows as text.
|
|
119
119
|
|
|
120
120
|
In a call graph, a solid arrow is a call, a thick arrow is a table entry, and a dotted arrow is a jump. A table entry goes from each routine that reads the table to each target in code. A table of data addresses gives no arrow.
|
|
@@ -145,12 +145,34 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
145
145
|
*/
|
|
146
146
|
const named = new Set(input.symbols.map((symbol) => symbol.address));
|
|
147
147
|
const dataReferences = input.references.filter((reference) => !(reference.to >= IO_RAM.start && reference.to <= IO_RAM.end && input.image?.inImage(reference.to) === true && !named.has(reference.to)));
|
|
148
|
-
/**
|
|
149
|
-
|
|
148
|
+
/**
|
|
149
|
+
* How the source line of a reference uses a platform name, as the source writes it: "named", "indexed"
|
|
150
|
+
* (name,x or name,y: the index can reach the registers after it), or undefined when the line does not
|
|
151
|
+
* name it, for example lda $d000,x with the character ROM in. "named" when the source text is not there.
|
|
152
|
+
*/
|
|
153
|
+
const platformUse = (reference: ReferenceRow, name: string): "named" | "indexed" | undefined => {
|
|
154
|
+
const line = map.lineOf(reference.from);
|
|
155
|
+
const text = line === undefined ? undefined : map.textOf?.(line);
|
|
156
|
+
if (text === undefined) return "named";
|
|
157
|
+
const use = new RegExp(`(?<![\\w.])${name}(?!\\w)([^,)]*,\\s*[xXyY]\\b)?`).exec(text);
|
|
158
|
+
return use === null ? undefined : use[1] === undefined ? "named" : "indexed";
|
|
159
|
+
};
|
|
160
|
+
/** The routines that read or write a range, each linked to its entry. `platform` is the platform name of the range. */
|
|
161
|
+
const ownersOf = (page: string, start: number, end: number, kind: string, platform?: string) =>
|
|
150
162
|
capped(
|
|
151
|
-
[
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
[
|
|
164
|
+
...new Set(
|
|
165
|
+
dataReferences
|
|
166
|
+
.filter((reference) => reference.kind === kind && reference.to >= start && reference.to <= end)
|
|
167
|
+
.flatMap((reference) => {
|
|
168
|
+
const use = platform === undefined ? "named" : platformUse(reference, platform);
|
|
169
|
+
if (use === undefined) return [];
|
|
170
|
+
const name = ownerAt(reference.from)?.name ?? hex(reference.from);
|
|
171
|
+
const shown = entries.has(name) ? entryOfName(page, name, name) : `\`${name}\``;
|
|
172
|
+
return [use === "indexed" ? `${shown} (indexed)` : shown];
|
|
173
|
+
}),
|
|
174
|
+
),
|
|
175
|
+
],
|
|
154
176
|
);
|
|
155
177
|
|
|
156
178
|
// --- The routine graph ----------------------------------------------------
|
|
@@ -381,7 +403,7 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
381
403
|
lines.push("", "## Variables outside the program", "", "| Address | Name | Comment | Read by | Written by |", "|---|---|---|---|---|");
|
|
382
404
|
for (const entry of outside) {
|
|
383
405
|
const at = `\`${entry.spanEnd > entry.address ? range(entry.address, entry.spanEnd) : hex(entry.address)}\``;
|
|
384
|
-
const owners = (kind: string) => ownersOf(page, entry.address, entry.spanEnd, kind);
|
|
406
|
+
const owners = (kind: string) => ownersOf(page, entry.address, entry.spanEnd, kind, entry.kind === "platform" ? entry.name : undefined);
|
|
385
407
|
lines.push(`| ${at} | <a id="${entry.name}"></a>${codeOfName(page, entry.name)} | ${commentLines(entry.address).join(" ").replace(/\|/g, "\\|")} | ${owners("read")} | ${owners("write")} |`);
|
|
386
408
|
}
|
|
387
409
|
counts.entries += outside.length;
|
|
@@ -32,6 +32,8 @@ export interface SourceMap {
|
|
|
32
32
|
lineOf: (address: number) => SourceLine | undefined;
|
|
33
33
|
/** The project path of a source file. */
|
|
34
34
|
pathOf: (file: string) => string;
|
|
35
|
+
/** The text of a source line, without its comment; undefined when the file or the line is not there. */
|
|
36
|
+
textOf?: (line: SourceLine) => string | undefined;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/** Reads the source map of the source in `directory` of the project `root`. A missing map is a refusal with the remedy. */
|
|
@@ -61,6 +63,7 @@ export function readSourceMap(directory: string, root?: string): SourceMap {
|
|
|
61
63
|
.map((item) => ({ start: parseC64Address(String(item.start)), end: parseC64Address(String(item.end)), file: String(item.file), line: Number(item.line) }))
|
|
62
64
|
.sort((a, b) => a.start - b.start);
|
|
63
65
|
const byName = new Map(labels.map((label) => [label.name, label]));
|
|
66
|
+
const texts = new Map<string, string[] | undefined>();
|
|
64
67
|
return {
|
|
65
68
|
directory,
|
|
66
69
|
mapPath: path,
|
|
@@ -82,5 +85,16 @@ export function readSourceMap(directory: string, root?: string): SourceMap {
|
|
|
82
85
|
return undefined;
|
|
83
86
|
},
|
|
84
87
|
pathOf: (file) => posix.join(directory, file),
|
|
88
|
+
textOf: (line) => {
|
|
89
|
+
if (!texts.has(line.file)) {
|
|
90
|
+
try {
|
|
91
|
+
texts.set(line.file, readProjectFile(posix.join(directory, line.file), root === undefined ? {} : { root }).bytes.toString("utf8").split(/\r?\n/));
|
|
92
|
+
} catch {
|
|
93
|
+
texts.set(line.file, undefined);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const text = texts.get(line.file)?.[line.line - 1];
|
|
97
|
+
return text?.replace(/;.*$/, "");
|
|
98
|
+
},
|
|
85
99
|
};
|
|
86
100
|
}
|
|
@@ -251,7 +251,7 @@ When a git merge left conflicts in the knowledge, each read body also has `confl
|
|
|
251
251
|
- `body.lines` has `count` and `listed`. `listed` holds one line for each instruction of a code region, and one `!byte` line for other bytes.
|
|
252
252
|
- Each line has `address`, `bytes`, `text`, `referencesIn` and `referencesOut`. It can also have `label`, `analyzerNames`, `lineComments` and `comment`. `lineComments` are the line comments before the line. `comment` is the side comment.
|
|
253
253
|
- `text` is the instruction with the names of its target. An operand expression of the knowledge replaces the operand.
|
|
254
|
-
- `access` is there when the knowledge has coverage. It tells if a run executed (`x`), read (`r`) or wrote (`w`) the bytes of the line. `-` tells that no run did. An `r` on code can come from a read of the 6502 that the program does not do. Examples are the byte
|
|
254
|
+
- `access` is there when the knowledge has coverage. It tells if a run executed (`x`), read (`r`) or wrote (`w`) the bytes of the line. `-` tells that no run did. An `r` on code can come from a read of the 6502 that the program does not do. Examples are the third byte of a JSR and the opcode after a branch that the CPU takes. Another example is the opcode at the PC when an interrupt starts. An indexed read (`lda table,x`) that crosses a page also reads the byte $100 below its target. A read watchpoint does not stop at these reads.
|
|
255
255
|
- With `--out`, the body has `lines` as a number, and `out`, `bytes` and `sha256` of the text file.
|
|
256
256
|
- If the knowledge has no program in the space, the script refuses. Put the program in with `image` first.
|
|
257
257
|
- Use `listing` in place of your own disassembler.
|
|
@@ -540,7 +540,7 @@ A macro writes a run of instructions as one line of the source, for example `+in
|
|
|
540
540
|
### `coverage <map>...`
|
|
541
541
|
|
|
542
542
|
- `<map>` is a 64 KiB coverage map of a run. Write each map in `.c64-re-tools/local/`.
|
|
543
|
-
- `body` holds `revision`, `imported`, `known` and `ranges`. `imported` lists the new maps. `known` lists the maps that the space has already.
|
|
543
|
+
- `body` holds `revision`, `imported`, `known` and `ranges`. `imported` lists the new maps. `known` lists the maps that the space has already. `ranges` counts the new ranges of accesses that no earlier map has. When `ranges` is 0, the source and the reference do not change.
|
|
544
544
|
- `coverage` joins the maps. It keeps each address that a run executed, read or wrote. It also keeps each address that one run wrote and executed: self-modified code.
|
|
545
545
|
- `coverage` puts each map into the space of `--space`. You can add the same map to each space.
|
|
546
546
|
- `--evidence coverage:<map>` names a map by its path at the import. It refers to the last import of that map into the space of the write.
|
|
@@ -1069,7 +1069,15 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
1069
1069
|
const maps = call.subjects.map((path) => ({ bytes: readProjectFile(path).bytes, name: knowledgePath(path, "<map>") }));
|
|
1070
1070
|
return (db) => {
|
|
1071
1071
|
const { revision, current } = addCoverage(db, context, { space: call.space, maps });
|
|
1072
|
-
|
|
1072
|
+
const body = { revision, ...spaceOf(current), imported: current.imported, known: current.known, ranges: current.ranges };
|
|
1073
|
+
// ranges counts the accesses that no earlier map had: only they change the source and the reference.
|
|
1074
|
+
const hint =
|
|
1075
|
+
revision === null
|
|
1076
|
+
? "The knowledge has each map already. Nothing changed."
|
|
1077
|
+
: current.ranges === 0
|
|
1078
|
+
? "The maps add no access that the knowledge did not have. The knowledge keeps them as evidence. The source and the reference do not change."
|
|
1079
|
+
: `The maps add ${current.ranges} ranges of accesses. They can change the leftovers and the code that no run executed. Generate the source again, then the reference.`;
|
|
1080
|
+
return reply(body, { hint });
|
|
1073
1081
|
};
|
|
1074
1082
|
},
|
|
1075
1083
|
),
|
|
@@ -335,7 +335,7 @@ A loader file that loads into $d000 or higher writes the I/O area. When the prog
|
|
|
335
335
|
To make the packed loader for other switch values, do these steps:
|
|
336
336
|
|
|
337
337
|
1. Assemble `main.asm` without an output path. The build name of the program tells the switch values, for example `build/custom_trainer.prg`. The leftovers are $00 in this build.
|
|
338
|
-
2. Assemble `loader.asm` without an output path, for example to `build/
|
|
338
|
+
2. Assemble `loader.asm` without an output path, for example to `build/custom_trainer_copier.prg`. This is the copier. The build name has `copier` in place of `loader`, so the build does not write over the loader program.
|
|
339
339
|
3. Pack the two files into `build/custom_trainer_packed.prg`. The start address is the copier address in the comment at the start of `loader.asm`. The memory configuration at the exit is `$34`.
|
|
340
340
|
|
|
341
341
|
These steps do not work when a segment starts below $0400. They also do not work when a patch is between the free ranges of `loader.asm`. In these cases, use `generate --loader` for the base release.
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { readFileSync } from "node:fs";
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
|
|
19
|
+
import { COPIER_LINE } from "#src/build-name.ts";
|
|
19
20
|
import { type AddressRange, formatC64Address, formatC64Byte, prgRange } from "#src/c64.ts";
|
|
20
21
|
import { compareBuild, mergedPrograms } from "#src/compare.ts";
|
|
21
22
|
import { Refusal } from "#src/errors.ts";
|
|
@@ -691,6 +692,7 @@ function planPacked(input: LoaderInput, blocks: Block[], cia: ReturnType<typeof
|
|
|
691
692
|
"; The image is too large for one loader file, so this is the packed form. Exomizer packs the",
|
|
692
693
|
`; build of main.asm and the build of this file into the loader program, with --entry '${formatC64Address(copier)}' and --exit-memory '$34'.`,
|
|
693
694
|
"; The unpacker of Exomizer uses the zero page and $0334-$03ff, so the copier writes pages $0002-$03ff after the unpack.",
|
|
695
|
+
COPIER_LINE,
|
|
694
696
|
"",
|
|
695
697
|
"!cpu 6510",
|
|
696
698
|
...settingsLines(input),
|
|
@@ -703,6 +703,9 @@ const LOADER_CHECK_DIRECTORY = "loader-check";
|
|
|
703
703
|
/** The source files of the loader. Only a run with --loader writes them, so only such a run removes them. */
|
|
704
704
|
const LOADER_FILES: ReadonlySet<string> = new Set(["loader.asm", START_SCREEN_FILE, STAGE_FILE]);
|
|
705
705
|
|
|
706
|
+
/** The source files of the show stage. A run writes them only with a loader program whose check ran, so only such a run removes them. */
|
|
707
|
+
const STAGE_FILES: ReadonlySet<string> = new Set([START_SCREEN_FILE, STAGE_FILE]);
|
|
708
|
+
|
|
706
709
|
/** A loader program that generate wrote: its build name, as buildName gives it for loader.asm. */
|
|
707
710
|
const LOADER_PROGRAM = /^(clean|custom_[a-z0-9_]+|release_[A-Za-z0-9_]+)_loader\.prg$/;
|
|
708
711
|
|
|
@@ -802,7 +805,7 @@ function removeOldFiles(out: string, keep: ReadonlySet<string>, loaderRun: boole
|
|
|
802
805
|
}
|
|
803
806
|
if (!entry.isFile()) continue;
|
|
804
807
|
const path = join(directory, entry.name);
|
|
805
|
-
if (LOADER_FILES.has(name) && !loaderRun) continue;
|
|
808
|
+
if ((LOADER_FILES.has(name) && !loaderRun) || STAGE_FILES.has(name)) continue;
|
|
806
809
|
if (!name.endsWith(".asm") || keep.has(name) || !readFileSync(path, "utf8").startsWith(GENERATED_MARK)) continue;
|
|
807
810
|
rmSync(path, { force: true });
|
|
808
811
|
removed.push(`${out}/${name}`);
|
|
@@ -1216,7 +1219,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
|
|
|
1216
1219
|
...(rendered.notExecuted === undefined
|
|
1217
1220
|
? {}
|
|
1218
1221
|
: {
|
|
1219
|
-
notExecuted: { instructions: rendered.notExecuted.instructions, ...listed(rendered.notExecuted.ranges, max, showRange,
|
|
1222
|
+
notExecuted: { instructions: rendered.notExecuted.instructions, ...listed(rendered.notExecuted.ranges, max, showRange, `a larger --max-listed, or read ${reports}/${NOT_EXECUTED_FILE}`) },
|
|
1220
1223
|
}),
|
|
1221
1224
|
...(laid.unusedModules.length === 0 ? {} : { unusedModules: laid.unusedModules.map((module) => ({ start: formatC64Address(module.start), file: module.file })) }),
|
|
1222
1225
|
// The bytes that nothing uses: in leftover files, which the default build and the loader leave out.
|
|
@@ -1346,7 +1349,9 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
|
|
|
1346
1349
|
rmSync(resolveProjectPath(scratch), { recursive: true, force: true });
|
|
1347
1350
|
}
|
|
1348
1351
|
// A loader program of an earlier run with another build name goes: config.asm has other values now.
|
|
1349
|
-
|
|
1352
|
+
// The files of an earlier show stage go when this loader has no stage and this run did not write them.
|
|
1353
|
+
const stageFiles = stage === undefined ? [...STAGE_FILES].filter((name) => !files.some((file) => file.name === name)).map((name) => `${out}/${name}`).filter((path) => existsSync(resolveProjectPath(path)) && readFileSync(resolveProjectPath(path), "utf8").startsWith(GENERATED_MARK)) : [];
|
|
1354
|
+
for (const path of [...loaderPrograms().filter((item) => item !== loaderPath && item !== symbolsPath(loaderPath)), ...stageFiles]) {
|
|
1350
1355
|
rmSync(resolveProjectPath(path), { force: true });
|
|
1351
1356
|
removed.push(path);
|
|
1352
1357
|
}
|
|
@@ -1700,7 +1705,7 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
|
|
|
1700
1705
|
to: fromProject(to),
|
|
1701
1706
|
zip: zipWritten,
|
|
1702
1707
|
source: { project: basename(project), revision: knowledge.revision },
|
|
1703
|
-
files: listed(files.map((file) => ({ ...file, out: fromProject(join(to, file.out)) })), max, (file) => file, "the folder of the new project"),
|
|
1708
|
+
files: listed(files.map((file) => ({ ...file, out: fromProject(join(to, file.out)) })), max, (file) => file, "a larger --max-listed, or list the folder of the new project"),
|
|
1704
1709
|
switches,
|
|
1705
1710
|
check: exportCheck,
|
|
1706
1711
|
...(loaderOutput === undefined ? {} : { loader: loaderOutput }),
|
|
@@ -131,6 +131,7 @@ The `hint` gives each of these cases:
|
|
|
131
131
|
- `coverageConflicts` is not empty. Classify each range as code in the project knowledge, or as `dual-use` when its bytes are also data. For many ranges, write all classifications in one batch of changes.
|
|
132
132
|
- `idioms.candidates.macros` has candidates, and the run had no `--apply-macros`. Examine the candidates. To write the correct candidates to the project knowledge, run the analysis again with `--apply-macros`. Give `--skip` with the start of each candidate that is not correct. Then generate the source again.
|
|
133
133
|
- The last analysis of the same program bytes used another analyzer version. Thus a change in `revision` can come from the new analyzer, and not from the program or the project knowledge.
|
|
134
|
+
- `changes.references.retired` is more than 0. A data range that only a retired reference used can be a leftover now. Generate the source again, and examine the leftovers that changed.
|
|
134
135
|
- A list is cut. Give a larger `--max-listed`. The project knowledge has all `labels` and `functions` as analyzer names.
|
|
135
136
|
|
|
136
137
|
There is no `nextAction`.
|
|
@@ -36,11 +36,13 @@ const ALL_NAMES = "a larger --max-listed. The project knowledge has all of them
|
|
|
36
36
|
* analyzer data over executed code to classify, and macro candidates to write.
|
|
37
37
|
* The envelope adds the sentence for a cut list.
|
|
38
38
|
*/
|
|
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 }) {
|
|
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) {
|
|
40
40
|
const hints: string[] = [];
|
|
41
41
|
if (version.revision !== null && version.now !== undefined && version.last !== undefined && version.now !== version.last) {
|
|
42
42
|
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
43
|
}
|
|
44
|
+
// A leftover is data that no reference reads: a retired reference can make one.
|
|
45
|
+
if (retiredReferences > 0) hints.push("The analysis retired references. A data range that only a retired reference used can be a leftover now. Generate the source again, and examine the leftovers that changed.");
|
|
44
46
|
if (conflicts > 0) hints.push("The analysis and the project knowledge disagree at each place in conflicts. Find the correct answer in the emulator. Then correct the project knowledge.");
|
|
45
47
|
if (coverageConflicts > 0) hints.push("The coverage shows executed code in each range of coverageConflicts. Classify each range as code, or as dual-use when its bytes are also data, in the project knowledge.");
|
|
46
48
|
if (typeof macros.revision === "string") hints.push("The project knowledge has the macro candidates now. Generate the source again.");
|
|
@@ -313,7 +315,7 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
313
315
|
labels: listed(result.labels, max, (label) => ({ address: formatC64Address(label.address), name: label.name }), ALL_NAMES),
|
|
314
316
|
...(written === undefined ? {} : { listing: written }),
|
|
315
317
|
};
|
|
316
|
-
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 });
|
|
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);
|
|
317
319
|
}
|
|
318
320
|
|
|
319
321
|
const { result } = await analyzeWithDecompiler({ imageKind, ...seeds, codeStarts, decompile }, bytes, localToolContext());
|
|
@@ -348,7 +350,7 @@ async function analyze(call: Call): Promise<unknown> {
|
|
|
348
350
|
? {}
|
|
349
351
|
: { notDecompiled: result.notDecompiled!.map((item) => ({ entry: formatC64Address(item.entry), reason: item.reason })) }),
|
|
350
352
|
};
|
|
351
|
-
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 });
|
|
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);
|
|
352
354
|
}
|
|
353
355
|
|
|
354
356
|
await runScript({
|
|
@@ -105,13 +105,15 @@ async function recordCommand(call: Call): Promise<Reply> {
|
|
|
105
105
|
writeReported(`${out}/${RECORDING_FILES.reads}`, outcome.reads, { what: "--out" }),
|
|
106
106
|
writeReported(`${out}/${RECORDING_FILES.coverage}`, outcome.coverage, { what: "--out" }),
|
|
107
107
|
];
|
|
108
|
-
// A recording in the local folder is a work file: git ignores it, so it is no test.
|
|
109
|
-
const
|
|
108
|
+
// A recording in the local folder is a work file: git ignores it, so it is no test. A record file there is not kept either.
|
|
109
|
+
const local = (path: string) => projectRelative(path).startsWith(`${PROJECT_DIRECTORY}/${LOCAL_DIRECTORY}/`);
|
|
110
|
+
const keep = local(out)
|
|
110
111
|
? `Git ignores ${out}. To keep the recording as a test and to add its coverage to the project knowledge, record again with --out tests/recordings/<name>.`
|
|
111
112
|
: `Commit ${out} with the scenarios. Add ${out}/${RECORDING_FILES.coverage} to the project knowledge as coverage.`;
|
|
113
|
+
const recordFile = local(call.subject(0)) ? ` Git also ignores the record file ${call.subject(0)}. To record again later, keep a copy in a folder that git keeps, for example tests/record/.` : "";
|
|
112
114
|
return reply(
|
|
113
115
|
{ result: "PASS", recorded: true, out, ...summary, files },
|
|
114
|
-
{ hint: `${keep} ${summary.coverageFrom === null ? "The coverage did not start: the map is empty." : "The map has no marks for the code that ran before coverageFrom."} To make sure that the recording replays, run nextAction.`, nextAction: call.next("replay", out) },
|
|
116
|
+
{ hint: `${keep}${recordFile} ${summary.coverageFrom === null ? "The coverage did not start: the map is empty." : "The map has no marks for the code that ran before coverageFrom."} To make sure that the recording replays, run nextAction.`, nextAction: call.next("replay", out) },
|
|
115
117
|
);
|
|
116
118
|
} finally {
|
|
117
119
|
await core.close();
|
package/src/build-name.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
// A release build is release_<label>. A build of config.asm is clean when each
|
|
3
3
|
// switch has its default, else custom_ with each switch that differs: its
|
|
4
4
|
// name when it is on, no_<name> when it is off. A build of an entry other
|
|
5
|
-
// than main.asm adds the entry, for example clean_loader.
|
|
5
|
+
// than main.asm adds the entry, for example clean_loader. The loader of the
|
|
6
|
+
// packed form alone is only its copier, so its build is clean_copier: the loader
|
|
7
|
+
// program, which generate packs, keeps clean_loader. A source without
|
|
6
8
|
// config.asm and without a release keeps the name of its entry. The symbols
|
|
7
9
|
// of a build go into symbols/ next to the program, so the program folder
|
|
8
10
|
// holds only programs.
|
|
@@ -31,9 +33,12 @@ export function configValues(text: string): Map<string, 0 | 1> {
|
|
|
31
33
|
/** What a build is made of: a release, or the values of config.asm with the default of each switch (0 when the defaults do not have it). */
|
|
32
34
|
export type BuildKind = { release: string } | { values: ReadonlyMap<string, number>; defaults: ReadonlyMap<string, number> };
|
|
33
35
|
|
|
34
|
-
/** The
|
|
35
|
-
export
|
|
36
|
-
|
|
36
|
+
/** The line of a generated loader.asm of the packed form. Its build alone is only the copier, not the loader program. */
|
|
37
|
+
export const COPIER_LINE = "; A build of this file alone is only the copier: its build name has copier in place of loader.";
|
|
38
|
+
|
|
39
|
+
/** The name of a build of `entry`, without an extension. `source` is the text of the entry: COPIER_LINE in it gives the name copier. */
|
|
40
|
+
export function buildName(entry: string, kind: BuildKind | undefined, source?: string): string {
|
|
41
|
+
const base = source?.split(/\r?\n/).includes(COPIER_LINE) ? "copier" : basename(entry, extname(entry));
|
|
37
42
|
if (kind === undefined) return base;
|
|
38
43
|
let type: string;
|
|
39
44
|
if ("release" in kind) type = `release_${kind.release}`;
|
package/src/native/c64run.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { SupervisedProcess } from "./processes.ts";
|
|
|
12
12
|
import type { ToolContext } from "./run.ts";
|
|
13
13
|
|
|
14
14
|
/** The command protocol that this module speaks; c64run --version and version name it. */
|
|
15
|
-
export const C64RUN_PROTOCOL =
|
|
15
|
+
export const C64RUN_PROTOCOL = 5;
|
|
16
16
|
|
|
17
17
|
/** CPU cycles in one PAL frame: 312 lines of 63 cycles. */
|
|
18
18
|
export const PAL_FRAME_CYCLES = 19_656;
|
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 5
|
|
31
31
|
// The key code of matrix place 0 (row 0, column 0); place n has code 0x80 + n.
|
|
32
32
|
#define C64RUN_KEY_PLACE 0x80
|
|
33
33
|
#ifndef CHIPS_COMMIT
|
|
@@ -241,6 +241,13 @@ static void tick(void) {
|
|
|
241
241
|
if (sample_file && addr == sample_pc && decoded) sample();
|
|
242
242
|
if (coverage_armed_pc && addr == coverage_pc && decoded) { coverage_armed_pc = 0; coverage_start(addr); }
|
|
243
243
|
}
|
|
244
|
+
if (read && !sync && decoded && sys.io_mapped && (addr & 0xFF0F) == 0xDC00) {
|
|
245
|
+
// chips gives port A of CIA 1 only joystick 2. A key also pulls its line of port A
|
|
246
|
+
// low while port B drives its column low: the scan from port B that some games use.
|
|
247
|
+
const m6526_port_t* pb = &sys.cia_1.pb;
|
|
248
|
+
const uint8_t low_columns = (uint8_t)~(pb->reg | ~pb->ddr);
|
|
249
|
+
if (low_columns) M6502_SET_DATA(pins, M6502_GET_DATA(pins) & (uint8_t)~kbd_test_lines(&sys.kbd, low_columns));
|
|
250
|
+
}
|
|
244
251
|
if (read && !sync && decoded && sys.io_mapped && (addr & 0xF000) == 0xD000 && input_addr[addr & 0x0FFF]) {
|
|
245
252
|
input_read(last_sync_pc, addr);
|
|
246
253
|
}
|