@henols/c64-re-tools 2.7.1 → 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 -237
- 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 +4 -82
- package/skills/c64-source/scripts/source.ts +48 -51
- 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 +72 -58
- package/skills/c64-testing/references/recording-format.md +5 -80
- 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 +74 -9
- package/skills/c64-testing/scripts/lib/replay.ts +4 -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 +34 -13
- 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/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
package/package.json
CHANGED
|
@@ -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
|
|
31
|
+
| Build a generated source with other switch values, and its loader program | `build src main.asm --switch TRAINER=1` |
|
|
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 FIRESTAR --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` |
|
|
@@ -44,7 +44,7 @@ To get the command list, run the script with no arguments.
|
|
|
44
44
|
- `<entry>` is the main source file, relative to the source root. It normally sets its start address, for example `* = $0801`. If it does not, give `--set-pc`.
|
|
45
45
|
- For a source that you generated from the project knowledge, the source root is the folder of that source. The entry is `main.asm`.
|
|
46
46
|
- `--out` is the path of the program, relative to the project folder. Without `--out`, the script writes `build/<name>.prg`. See "Build names".
|
|
47
|
-
- The script writes the symbols of the program
|
|
47
|
+
- The script also writes the symbols file of the program. `symbolsFile.out` gives its path. Give this file to a test run as the symbols of the rebuild.
|
|
48
48
|
- Get the label of a release from the releases in the project knowledge. Record a release in the project knowledge before you build it.
|
|
49
49
|
- Before you use `--compare`, put the program bytes into the project knowledge.
|
|
50
50
|
- The target CPU is the 6510. The program is a C64 PRG, or the bytes only with `--plain`.
|
|
@@ -54,7 +54,8 @@ To get the command list, run the script with no arguments.
|
|
|
54
54
|
A source that you generated from the project knowledge has switches in `config.asm`.
|
|
55
55
|
|
|
56
56
|
- Without `--release`, the build uses the values in `config.asm`. With the default values, the program is the clean program: no copy protection, no trainers, no cheats, no crack changes, and all corrections. This program can be different from the base release. Thus `--compare` can give `FAIL`.
|
|
57
|
-
- To
|
|
57
|
+
- To build other switch values, give `--switch` for each switch, for example `--switch TRAINER=1`. `config.asm` does not change. Do not use `--define` for a switch.
|
|
58
|
+
- With `--switch` and the entry `main.asm`, a source with `loader.asm` also gives its loader program with these switch values. See "Build".
|
|
58
59
|
- With `--release <label>`, each switch has the value of that release. A release build does not read `config.asm`.
|
|
59
60
|
|
|
60
61
|
### Build names
|
|
@@ -64,11 +65,11 @@ Without `--out`, the name of the program tells what the build is:
|
|
|
64
65
|
| Build | Name |
|
|
65
66
|
|---|---|
|
|
66
67
|
| `--release <label>` | `release_<label>.prg`, for example `release_FIRESTAR.prg` |
|
|
67
|
-
| Each value
|
|
68
|
-
| A value
|
|
68
|
+
| Each switch value is its default | `clean.prg` |
|
|
69
|
+
| A switch value 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
70
|
| A source without `config.asm` | the name of the entry, for example `main.prg` |
|
|
70
71
|
|
|
71
|
-
An entry other than `main.asm` adds its name
|
|
72
|
+
An entry other than `main.asm` adds its name. 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
73
|
|
|
73
74
|
### Paths and the project folder
|
|
74
75
|
|
|
@@ -80,12 +81,11 @@ An entry other than `main.asm` adds its name, for example `clean_loader.prg` for
|
|
|
80
81
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
81
82
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
82
83
|
- 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.
|
|
83
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
84
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
84
85
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
85
86
|
- 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.
|
|
86
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
87
|
-
-
|
|
88
|
-
- 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.
|
|
87
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
88
|
+
- 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.
|
|
89
89
|
- 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`.
|
|
90
90
|
|
|
91
91
|
---
|
|
@@ -99,6 +99,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
99
99
|
| `--out <file.prg>` | `build` | The path of the program, relative to the project folder. The default is `build/<name>.prg`. See "Build names". |
|
|
100
100
|
| `--include <folder>` | `build` | An include folder: a path relative to the source root, inside the project folder. Give the flag again for each folder. The default is no include folder. |
|
|
101
101
|
| `--define NAME=VALUE` | `build` | An assembler symbol: an integer, also `$` and hex digits, or `true` or `false`. Give the flag again for each symbol. Do not use it for a switch. |
|
|
102
|
+
| `--switch NAME=VALUE` | `build` | A switch of `config.asm` with the value 0 or 1 for this build. Give the flag again for each switch. `config.asm` does not change. The script refuses it with `--release`. |
|
|
102
103
|
| `--set-pc <address>` | `build` | The start address when the source does not set one, for example `'$0801'`. |
|
|
103
104
|
| `--release <label>` | `build` | Build a release of the project knowledge. Each switch gets the value of that release. With `--compare`, the reference is the bytes of the release in the project knowledge. |
|
|
104
105
|
| `--compare` | `build` | Compare the program byte by byte with the program in the project knowledge, or with the file of `--release`, segment by segment. Off by default. |
|
|
@@ -113,7 +114,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
113
114
|
|
|
114
115
|
### `build <source-root> <entry>`
|
|
115
116
|
|
|
116
|
-
Assembles the source and writes the program to `--out`, or to `build/<name>.prg`. It also writes the symbols
|
|
117
|
+
Assembles the source and writes the program to `--out`, or to `build/<name>.prg`. It also writes the symbols file, which `symbolsFile` gives. Without `--all-symbols`, that file does not have the constants that the source does not use.
|
|
117
118
|
|
|
118
119
|
`body` holds:
|
|
119
120
|
|
|
@@ -133,10 +134,11 @@ Assembles the source and writes the program to `--out`, or to `build/<name>.prg`
|
|
|
133
134
|
- `identical`.
|
|
134
135
|
- `different`, with `differences` and `firstDifference`. `firstDifference` gives `address`, and the byte of the build (`built`) and of the reference (`reference`), each as `$` and two hex digits.
|
|
135
136
|
- `not covered`, with `uncovered`: the build does not hold all bytes of the segment.
|
|
137
|
+
- `loader`: only with `--switch`, the entry `main.asm` and a `loader.asm` in the source root. It is the loader program of these switch values, with `out`, `bytes` and `sha256`. `symbolsFile` is its symbols file. `packed` gives `packedBytes` and `unpackedBytes` of the packed form. `verified` is always `false`, because no check of the loader program runs.
|
|
136
138
|
|
|
137
139
|
Do as the result tells:
|
|
138
140
|
|
|
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.
|
|
141
|
+
- `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: `loader.program` of the generation of the source with the loader, or `loader.out` of a build with `--switch`. Test the loader program of `loader.out` before you trust it.
|
|
140
142
|
- `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
143
|
- `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
144
|
- `hint` tells that `symbols` is cut: give a larger `--max-listed`, or read the symbols file for the full list.
|
|
@@ -145,6 +147,8 @@ Do as the result tells:
|
|
|
145
147
|
- Error `invalid-input` names an include folder: the folder is outside the project folder. Give `--include` a folder inside the project folder.
|
|
146
148
|
- Error `not-found` names a release: the project knowledge has no release with that label. Record the release in the project knowledge, or give the label of a recorded release.
|
|
147
149
|
- Error `not-found` tells that the knowledge has no program: put the program bytes into the project knowledge. Then use `--compare` again.
|
|
150
|
+
- Error `invalid-input` names a switch: give `--switch` a switch of `config.asm`, with the value 0 or 1.
|
|
151
|
+
- Error `invalid-input` tells you to set the switch values in `config.asm`: this build cannot make the loader program of these switch values. Set the values in `config.asm`. Then generate the source with the loader.
|
|
148
152
|
- Error `invalid-input`: an option or a path is wrong. Do as `hint` tells. The script refuses `--space` without `--compare` or `--release`.
|
|
149
153
|
|
|
150
154
|
The script does not keep the diagnostics or the program in the project knowledge.
|
|
@@ -167,24 +171,15 @@ To compare runs of the rebuild with runs of the reference, give the symbols file
|
|
|
167
171
|
|
|
168
172
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
169
173
|
|
|
170
|
-
On success, the exit code is 0:
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
On failure, the exit code is 2:
|
|
177
|
-
|
|
178
|
-
```json
|
|
179
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
180
|
-
```
|
|
181
|
-
|
|
174
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
175
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
182
176
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
183
177
|
- 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.
|
|
184
|
-
- `error` is one sentence. It tells what is wrong.
|
|
185
|
-
- `
|
|
186
|
-
- `
|
|
187
|
-
- `
|
|
178
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
179
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
180
|
+
- 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`.
|
|
181
|
+
- 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.
|
|
182
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
188
183
|
|
|
189
184
|
| `code` | Action |
|
|
190
185
|
|---|---|
|
|
@@ -192,13 +187,3 @@ On failure, the exit code is 2:
|
|
|
192
187
|
| `invalid-input`, `not-found` | Correct the call as `hint` tells. Then run the command again. |
|
|
193
188
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
194
189
|
| Another code | Do as `hint` tells. |
|
|
195
|
-
|
|
196
|
-
These fields have the same meaning in each body:
|
|
197
|
-
|
|
198
|
-
| Field | Meaning |
|
|
199
|
-
|---|---|
|
|
200
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
201
|
-
| `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. |
|
|
202
|
-
|
|
203
|
-
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.
|
|
204
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
// The c64-assembler script: assembles project source with ACME, which it runs
|
|
2
|
-
// itself, and writes the program into the project.
|
|
2
|
+
// itself, and writes the program into the project. With --switch, a generated
|
|
3
|
+
// source gets other switch values: the script changes them in its copy of
|
|
4
|
+
// config.asm, so the file stays as it is, and the build name follows from the
|
|
5
|
+
// values. A generated source with loader.asm then also gets its loader
|
|
6
|
+
// program with the same values: the build of loader.asm in the plain form,
|
|
7
|
+
// and in the packed form the pack of the build of main.asm with the build of
|
|
8
|
+
// loader.asm, the copier, as generate packs it. No check of that loader runs.
|
|
3
9
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
10
|
+
import { posix } from "node:path";
|
|
11
|
+
|
|
12
|
+
import { BUILD_DIRECTORY, type BuildKind, buildName, CONFIG_FILE, configValues, COPIER_LINE, symbolsPath, withConfigValues } from "#src/build-name.ts";
|
|
13
|
+
import { type AddressRange, formatC64Address } from "#src/c64.ts";
|
|
6
14
|
import { Refusal } from "#src/errors.ts";
|
|
7
15
|
import { readSourceTree, writeReported } from "#src/host-client/transfer.ts";
|
|
8
16
|
import { openForRead } from "#src/knowledge/database.ts";
|
|
9
17
|
import { knowledgeNames } from "#src/knowledge/names.ts";
|
|
10
18
|
import { releaseImage, requireProgram } from "#src/knowledge/program.ts";
|
|
11
|
-
import { listSwitches, releaseLabeled } from "#src/knowledge/read.ts";
|
|
12
|
-
import { LEFTOVERS_SWITCH, RELEASE_DEFINE, START_SCREEN_SWITCH, type Space } from "#src/knowledge/schema.ts";
|
|
19
|
+
import { currentStartScreen, listSwitches, releaseLabeled } from "#src/knowledge/read.ts";
|
|
20
|
+
import { LEFTOVER_FOLDER, LEFTOVERS_SWITCH, RELEASE_DEFINE, START_SCREEN_SWITCH, type Space } from "#src/knowledge/schema.ts";
|
|
21
|
+
import { checkPackedBuilds, COPIER_SOURCE, leftoverRange, loaderSymbols, packedRanges, packLoader, type PackedLoader } from "#src/loader.ts";
|
|
13
22
|
import { assemble, showSymbol, symbolsFileText } from "#src/native/acme.ts";
|
|
23
|
+
import { EXOMIZER, findTool } from "#src/native/discover.ts";
|
|
14
24
|
import { localToolContext } from "#src/native/local.ts";
|
|
15
25
|
import type { AcmeParams, AssembledSymbol } from "#src/native/types.ts";
|
|
16
26
|
import { listed as listedItems, OPTIONS, reply, runScript, UsageError } from "#src/script.ts";
|
|
17
27
|
import { compareBuild, type Reference } from "#src/compare.ts";
|
|
18
28
|
|
|
29
|
+
/** The loader of a generated source, which a build of main.asm with --switch also makes. */
|
|
30
|
+
const LOADER_FILE = "loader.asm";
|
|
31
|
+
|
|
19
32
|
function parseDefine(text: string): [string, number | boolean] {
|
|
20
33
|
const match = /^([A-Za-z_][A-Za-z0-9_]*)=(.+)$/.exec(text);
|
|
21
34
|
if (match === null) throw new UsageError(`--define needs NAME=VALUE, not ${text}`);
|
|
@@ -26,6 +39,18 @@ function parseDefine(text: string): [string, number | boolean] {
|
|
|
26
39
|
throw new UsageError(`--define ${match[1]} needs an integer or true/false, not ${value}`);
|
|
27
40
|
}
|
|
28
41
|
|
|
42
|
+
/** The values of --switch, by name: each is 0 or 1, and each name comes once. */
|
|
43
|
+
function parseSwitches(texts: readonly string[]): Map<string, 0 | 1> {
|
|
44
|
+
const values = new Map<string, 0 | 1>();
|
|
45
|
+
for (const text of texts) {
|
|
46
|
+
const match = /^([A-Za-z_][A-Za-z0-9_]*)=([01])$/.exec(text);
|
|
47
|
+
if (match === null) throw new UsageError(`--switch needs NAME=0 or NAME=1, not ${text}`);
|
|
48
|
+
if (values.has(match[1]!)) throw new UsageError(`--switch gives ${match[1]} two times. Give each switch one time.`);
|
|
49
|
+
values.set(match[1]!, match[2] === "1" ? 1 : 0);
|
|
50
|
+
}
|
|
51
|
+
return values;
|
|
52
|
+
}
|
|
53
|
+
|
|
29
54
|
/** The default of each switch of a generated source: the knowledge gives them, the start screen is in and the leftovers are out. */
|
|
30
55
|
function switchDefaults(space: Space): Map<string, number> {
|
|
31
56
|
const db = openForRead();
|
|
@@ -36,6 +61,16 @@ function switchDefaults(space: Space): Map<string, number> {
|
|
|
36
61
|
}
|
|
37
62
|
}
|
|
38
63
|
|
|
64
|
+
/** What the packed form needs from the knowledge: the loaded ranges. Refuses a start screen of a captured stage and a segment below $0400. */
|
|
65
|
+
function packedLoaded(leftovers: readonly AddressRange[]): AddressRange[] {
|
|
66
|
+
const db = openForRead();
|
|
67
|
+
try {
|
|
68
|
+
return packedRanges(requireProgram(db).segments, leftovers, currentStartScreen(db)?.stage);
|
|
69
|
+
} finally {
|
|
70
|
+
db?.close();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
39
74
|
await runScript({
|
|
40
75
|
name: "assembler",
|
|
41
76
|
summary: "Assembles project source with ACME and writes the program into the project.",
|
|
@@ -49,9 +84,10 @@ await runScript({
|
|
|
49
84
|
{ name: "<entry>", help: "the main source file, relative to the source root" },
|
|
50
85
|
],
|
|
51
86
|
options: {
|
|
52
|
-
out: { ...OPTIONS.out, output: "file", value: "<file.prg>", help: "where to write the program, relative to the project folder. The default is build/<build>.prg: release_<label> with --release, else clean or custom_<switches> from
|
|
87
|
+
out: { ...OPTIONS.out, output: "file", value: "<file.prg>", help: "where to write the program, relative to the project folder. The default is build/<build>.prg: release_<label> with --release, else clean or custom_<switches> from the switch values, with _<entry> for an entry other than main.asm" },
|
|
53
88
|
include: { kind: "text", value: "<folder>", multiple: true, help: "an include folder: a path relative to the source root, inside the project folder" },
|
|
54
|
-
define: { kind: "text", value: "NAME=VALUE", multiple: true, help: "an assembler symbol: an integer ($hex allowed) or true/false" },
|
|
89
|
+
define: { kind: "text", value: "NAME=VALUE", multiple: true, help: "an assembler symbol: an integer ($hex allowed) or true/false. Not for a switch of config.asm: give --switch" },
|
|
90
|
+
switch: { kind: "text", value: "NAME=VALUE", multiple: true, help: "a switch of config.asm with the value 0 or 1 for this build. config.asm stays as it is. With main.asm and a loader.asm, the build also writes the loader program with these values" },
|
|
55
91
|
"set-pc": { kind: "address", value: "<address>", help: "the start address when the source sets none, for example '$0801'" },
|
|
56
92
|
release: { kind: "text", value: "<label>", help: `build a release of the knowledge: defines ${RELEASE_DEFINE}<label>=1, so each switch has the value of that release. With --compare, the reference is the file of the release` },
|
|
57
93
|
compare: { kind: "flag", help: "check the program byte by byte against the program in the knowledge (or the file of --release), each segment" },
|
|
@@ -60,13 +96,16 @@ await runScript({
|
|
|
60
96
|
"all-symbols": { kind: "flag", help: "list also the constants that the source does not use" },
|
|
61
97
|
"max-listed": { ...OPTIONS["max-listed"], help: "list at most n symbols (default 50). The count is always given" },
|
|
62
98
|
},
|
|
63
|
-
notes:
|
|
99
|
+
notes:
|
|
100
|
+
"Symbol values are $ and at least four hex digits. Before --compare, put the program bytes into the project knowledge. Without --release, the build has the switch values of config.asm and of --switch. With the defaults, this is the clean program, which is not the bytes of a release when a switch has a default that the base release does not have. Give a switch with --switch, not with --define: ACME stops with Symbol already defined. The loader program of --switch is not checked: loader.verified is false.",
|
|
64
101
|
run: async (call) => {
|
|
65
102
|
const [sourceRoot, entry] = [call.subject(0), call.subject(1)];
|
|
66
103
|
// Read the reference before ACME runs, so a project without it stops at once.
|
|
67
104
|
let program: Reference | undefined;
|
|
68
105
|
const label = call.string("release");
|
|
106
|
+
const switches = parseSwitches(call.strings("switch"));
|
|
69
107
|
if (call.string("space") !== undefined && !call.flag("compare") && label === undefined) throw new UsageError("--space works only with --compare or --release: it names the knowledge space of the program");
|
|
108
|
+
if (switches.size > 0 && label !== undefined) throw new UsageError("--switch does not work with --release: a release build has the switch values of that release");
|
|
70
109
|
let releaseDefine: Record<string, number> = {};
|
|
71
110
|
if (call.flag("compare") || label !== undefined) {
|
|
72
111
|
const db = openForRead();
|
|
@@ -85,29 +124,78 @@ await runScript({
|
|
|
85
124
|
const setPc = call.address("set-pc");
|
|
86
125
|
const { contents, ...tree } = readSourceTree(sourceRoot, call.strings("include"));
|
|
87
126
|
const inSource = (name: string) => tree.files.findIndex((file) => file.path === (tree.sourceDir === "" ? name : `${tree.sourceDir}/${name}`));
|
|
127
|
+
const textOf = (index: number) => contents[index]!.toString("utf8");
|
|
88
128
|
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.`);
|
|
89
|
-
// The name of the build tells what it is: the release, or the switch values of config.asm.
|
|
90
129
|
const config = inSource(CONFIG_FILE);
|
|
91
|
-
|
|
130
|
+
if (switches.size > 0) {
|
|
131
|
+
// ACME refuses a define of a symbol that config.asm sets: the values go into the copy of config.asm that ACME gets.
|
|
132
|
+
if (config < 0) throw new Refusal("invalid-input", `${sourceRoot} has no ${CONFIG_FILE}, so the source has no switches. Give --switch only for a generated source with switches.`);
|
|
133
|
+
const known = configValues(textOf(config));
|
|
134
|
+
const unknown = [...switches.keys()].filter((name) => !known.has(name));
|
|
135
|
+
if (unknown.length > 0) throw new Refusal("invalid-input", `${unknown.join(", ")} ${unknown.length === 1 ? "is not a switch" : "are not switches"} of ${CONFIG_FILE}. Give a switch of ${CONFIG_FILE}: ${[...known.keys()].join(", ")}.`);
|
|
136
|
+
const changed = Buffer.from(withConfigValues(textOf(config), switches), "utf8");
|
|
137
|
+
contents[config] = changed;
|
|
138
|
+
tree.files[config] = { ...tree.files[config]!, size: changed.length };
|
|
139
|
+
}
|
|
140
|
+
// The name of the build tells what it is: the release, or the switch values.
|
|
141
|
+
const kind: BuildKind | undefined = label !== undefined ? { release: label } : config < 0 ? undefined : { values: configValues(textOf(config)), defaults: switchDefaults(call.space) };
|
|
92
142
|
const plain = call.flag("plain");
|
|
93
|
-
const out = call.string("out") ?? `${BUILD_DIRECTORY}/${buildName(entry, kind,
|
|
143
|
+
const out = call.string("out") ?? `${BUILD_DIRECTORY}/${buildName(entry, kind, textOf(inSource(entry)))}.${plain ? "bin" : "prg"}`;
|
|
94
144
|
const params: AcmeParams = { ...tree, entrySource: entry, defines: { ...releaseDefine, ...Object.fromEntries(call.strings("define").map(parseDefine)) }, ...(setPc === undefined ? {} : { setPc }) };
|
|
95
145
|
|
|
146
|
+
// With --switch, main.asm of a generated source with a loader also gives the loader program of these values.
|
|
147
|
+
const loaderIndex = switches.size > 0 && entry === "main.asm" ? inSource(LOADER_FILE) : -1;
|
|
148
|
+
let loaded: AddressRange[] | undefined;
|
|
149
|
+
if (loaderIndex >= 0 && textOf(loaderIndex).split(/\r?\n/).includes(COPIER_LINE)) {
|
|
150
|
+
// The packed form: the loaded ranges are the segments of the program without the leftover files of the source.
|
|
151
|
+
const folder = posix.join(tree.sourceDir, LEFTOVER_FOLDER);
|
|
152
|
+
const leftovers = tree.files.flatMap((file, index) => (posix.dirname(file.path) === folder ? (leftoverRange(textOf(index)) ?? []) : []));
|
|
153
|
+
loaded = packedLoaded(leftovers);
|
|
154
|
+
// The toolkit never installs a tool: without Exomizer the build refuses by name before ACME runs.
|
|
155
|
+
findTool(EXOMIZER);
|
|
156
|
+
}
|
|
157
|
+
|
|
96
158
|
const { result, attachments } = await assemble(params, contents, localToolContext());
|
|
97
159
|
if (!result.assembled) return reply({ result: "FAIL", assembled: false, diagnostics: result.diagnostics }, { hint: "The source has errors, and no program was written. Correct the source at the file and the line of each diagnostic. Then run build again." });
|
|
98
|
-
const
|
|
99
|
-
const range = result.loadRange!;
|
|
100
|
-
const compared = program === undefined ? undefined : compareBuild(attachments![0]!, program);
|
|
160
|
+
const built = attachments![0]!;
|
|
101
161
|
// An include file of platform names gives many constants that the program does not use.
|
|
102
162
|
const all = call.flag("all-symbols");
|
|
103
|
-
const
|
|
163
|
+
const shownOf = (symbols: readonly AssembledSymbol[]) => symbols.filter((symbol) => all || symbol.kind === "address" || symbol.used);
|
|
164
|
+
const shown = shownOf(result.symbols!);
|
|
165
|
+
|
|
166
|
+
// The loader is made before a file is written: a refusal writes nothing.
|
|
167
|
+
let loader: { program: Buffer; symbols: AssembledSymbol[]; packed?: PackedLoader } | undefined;
|
|
168
|
+
if (loaderIndex >= 0) {
|
|
169
|
+
const copier = await assemble({ ...params, entrySource: LOADER_FILE }, contents, localToolContext());
|
|
170
|
+
if (!copier.result.assembled) {
|
|
171
|
+
const [first] = copier.result.diagnostics;
|
|
172
|
+
const where = first === undefined ? "" : `: ${first.file ?? LOADER_FILE}${first.line === undefined ? "" : ` line ${first.line}`}: ${first.message}`;
|
|
173
|
+
throw new Refusal("operation-failed", `${LOADER_FILE} does not assemble with these switch values${where}. Generate the source with the loader again. If it still does not assemble, give this message to the user.`);
|
|
174
|
+
}
|
|
175
|
+
const copierBuild = copier.attachments![0]!;
|
|
176
|
+
const symbols = loaderSymbols(result.symbols!, copier.result.symbols!);
|
|
177
|
+
if (loaded === undefined) loader = { program: copierBuild, symbols };
|
|
178
|
+
else {
|
|
179
|
+
const at = copier.result.symbols!.find((symbol) => symbol.name === COPIER_SOURCE);
|
|
180
|
+
if (at?.kind !== "address") throw new Refusal("invalid-input", `${LOADER_FILE} has no label ${COPIER_SOURCE} at its copier. Generate the source with the loader again.`);
|
|
181
|
+
checkPackedBuilds(built, copierBuild, loaded);
|
|
182
|
+
const packed = await packLoader(built, copierBuild, { loaded, copier: at.address }, localToolContext());
|
|
183
|
+
loader = { program: packed.program, symbols, packed };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const written = writeReported(out, plain ? built.subarray(2) : built, { what: "--out" });
|
|
188
|
+
const range = result.loadRange!;
|
|
189
|
+
const compared = program === undefined ? undefined : compareBuild(built, program);
|
|
104
190
|
const symbols = listedItems(shown, call.count("max-listed")!, showSymbol, `a larger --max-listed, or read ${symbolsPath(out)}`);
|
|
105
191
|
// A build that differs from its reference is a failed check.
|
|
106
192
|
const different = compared !== undefined && !compared.identical;
|
|
193
|
+
const loaderPath = `${BUILD_DIRECTORY}/${buildName(LOADER_FILE, kind)}.prg`;
|
|
107
194
|
const hints = [
|
|
108
195
|
...(different ? ["The program is not identical to the reference program. Read compare.segments: each segment that is different gives its first difference."] : []),
|
|
109
|
-
...(different && label === undefined ? ["Without --release, a source with switches builds with the values of config.asm, and that program can differ from the base release. To check a release, give --release <label> with --compare."] : []),
|
|
196
|
+
...(different && label === undefined ? ["Without --release, a source with switches builds with the values of config.asm and --switch, and that program can differ from the base release. To check a release, give --release <label> with --compare."] : []),
|
|
110
197
|
...(symbols.rest === undefined ? [] : [`symbols is cut. To get all symbols, give ${symbols.rest}.`]),
|
|
198
|
+
...(loader === undefined ? [] : ["loader.out is the loader program of these switch values. No check of the loader program ran, so loader.verified is false."]),
|
|
111
199
|
];
|
|
112
200
|
return reply({
|
|
113
201
|
result: different ? "FAIL" : "PASS",
|
|
@@ -121,6 +209,16 @@ await runScript({
|
|
|
121
209
|
...(all ? {} : { unusedConstants: result.symbols!.length - shown.length }),
|
|
122
210
|
diagnostics: result.diagnostics,
|
|
123
211
|
...(compared === undefined ? {} : { compare: compared }),
|
|
212
|
+
...(loader === undefined
|
|
213
|
+
? {}
|
|
214
|
+
: {
|
|
215
|
+
loader: {
|
|
216
|
+
...writeReported(loaderPath, loader.program),
|
|
217
|
+
symbolsFile: writeReported(symbolsPath(loaderPath), symbolsFileText(shownOf(loader.symbols))),
|
|
218
|
+
...(loader.packed === undefined ? {} : { packed: { packedBytes: loader.packed.packedBytes, unpackedBytes: loader.packed.unpackedBytes } }),
|
|
219
|
+
verified: false,
|
|
220
|
+
},
|
|
221
|
+
}),
|
|
124
222
|
}, hints.length === 0 ? {} : { hint: hints.join(" ") });
|
|
125
223
|
},
|
|
126
224
|
},
|
|
@@ -41,12 +41,11 @@ To get the command list, run the script with no arguments.
|
|
|
41
41
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
42
42
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
43
43
|
- 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.
|
|
44
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
44
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
45
45
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
46
46
|
- 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.
|
|
47
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
48
|
-
-
|
|
49
|
-
- 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.
|
|
47
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
48
|
+
- 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.
|
|
50
49
|
- 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`.
|
|
51
50
|
|
|
52
51
|
## Decode a program
|
|
@@ -61,6 +60,7 @@ To get the command list, run the script with no arguments.
|
|
|
61
60
|
- A handoff with `computed: true` gets its address from a calculation at run time, for example with `PEEK`. A `sys` handoff of this type gives its argument in `expression`.
|
|
62
61
|
- `loadRange`: the `start` and the `end` of the program in memory.
|
|
63
62
|
- `basicEnd`: the first address after the BASIC, or `null`. From `basicEnd` to the end of `loadRange`, the file holds bytes that are not BASIC. Usually these bytes are the machine code that the handoff calls.
|
|
63
|
+
- `machineCode`: only when the file has bytes after the BASIC. `start` and `end` are their addresses. `fileOffset` is the position of the first byte in the file, after the 2 bytes of the load address.
|
|
64
64
|
|
|
65
65
|
The addresses are for a load to the load address of the file. A load without `,1` puts a BASIC program at `$0801`. Most loaders have `$0801` as their load address.
|
|
66
66
|
|
|
@@ -85,24 +85,15 @@ Failure:
|
|
|
85
85
|
|
|
86
86
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
87
87
|
|
|
88
|
-
On success, the exit code is 0:
|
|
89
|
-
|
|
90
|
-
```json
|
|
91
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
On failure, the exit code is 2:
|
|
95
|
-
|
|
96
|
-
```json
|
|
97
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
98
|
-
```
|
|
99
|
-
|
|
88
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
89
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
100
90
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
101
91
|
- 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.
|
|
102
|
-
- `error` is one sentence. It tells what is wrong.
|
|
103
|
-
- `
|
|
104
|
-
- `
|
|
105
|
-
- `
|
|
92
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
93
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
94
|
+
- 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`.
|
|
95
|
+
- 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.
|
|
96
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
106
97
|
|
|
107
98
|
| `code` | Action |
|
|
108
99
|
|---|---|
|
|
@@ -110,14 +101,3 @@ On failure, the exit code is 2:
|
|
|
110
101
|
| `invalid-input`, `not-found` | Correct the call as `hint` tells. Then run the command again. |
|
|
111
102
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
112
103
|
| Another code | Do as `hint` tells. |
|
|
113
|
-
|
|
114
|
-
These fields have the same meaning in each body:
|
|
115
|
-
|
|
116
|
-
| Field | Meaning |
|
|
117
|
-
|---|---|
|
|
118
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
119
|
-
| `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. |
|
|
120
|
-
|
|
121
|
-
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.
|
|
122
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|
|
123
|
-
|
|
@@ -25,10 +25,13 @@ await runScript({
|
|
|
25
25
|
const size = statSync(resolveProjectPath(program)).size - 2;
|
|
26
26
|
const end = result.loadAddress + size - 1;
|
|
27
27
|
const handoffs = result.handoffs.map((handoff) => ("address" in handoff ? { ...handoff, address: formatC64Address(handoff.address) } : handoff));
|
|
28
|
+
const after = result.basicEnd <= end;
|
|
28
29
|
const body = {
|
|
29
30
|
loadRange: { start: formatC64Address(result.loadAddress), end: formatC64Address(end) },
|
|
30
31
|
// From here to the end of the load range, the file holds no BASIC (often machine code).
|
|
31
|
-
basicEnd:
|
|
32
|
+
basicEnd: after ? formatC64Address(result.basicEnd) : null,
|
|
33
|
+
// The same bytes in the file: 2 bytes of load address come before the program.
|
|
34
|
+
...(after ? { machineCode: { start: formatC64Address(result.basicEnd), end: formatC64Address(end), fileOffset: result.basicEnd - result.loadAddress + 2 } } : {}),
|
|
32
35
|
listing: result.listing,
|
|
33
36
|
handoffs,
|
|
34
37
|
};
|
|
@@ -68,9 +68,9 @@ Do these steps for each small part of the program:
|
|
|
68
68
|
|
|
69
69
|
1. Find the meaning of each register in the memory map of the C64. Export the platform names as an include file to `src/hw.a`. Include it with `!source`. Do not type the addresses of registers yourself.
|
|
70
70
|
2. Write the code for one part.
|
|
71
|
-
3. Assemble `src/main.a` into `build/<name>.prg
|
|
71
|
+
3. Assemble `src/main.a` into `build/<name>.prg`. Change the source at the file and the line of each error.
|
|
72
72
|
4. Start the program in the emulator with an autostart. Look at the screen. Read the screen memory, not only the screen image.
|
|
73
|
-
5. Write the `expect` steps of this part in a run file. Give the
|
|
73
|
+
5. Write the `expect` steps of this part in a run file. Give the symbols file of the build in the run file, so that a step can use the labels of the source. The result of the build gives the symbols file.
|
|
74
74
|
6. Run all run files in `tests/`. Go to the next part only when each run gives PASS.
|
|
75
75
|
|
|
76
76
|
To find a defect, debug the program in the emulator:
|
package/skills/c64-disk/SKILL.md
CHANGED
|
@@ -67,12 +67,11 @@ To get the command list, run the script with no arguments.
|
|
|
67
67
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
68
68
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
69
69
|
- 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.
|
|
70
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
70
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
71
71
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
72
72
|
- 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.
|
|
73
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
74
|
-
-
|
|
75
|
-
- 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.
|
|
73
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
74
|
+
- 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.
|
|
76
75
|
- 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`.
|
|
77
76
|
|
|
78
77
|
## Flags
|
|
@@ -93,7 +92,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
93
92
|
|
|
94
93
|
For a disk image, `body` holds `diskName`, `diskId`, `dosType`, `freeBlocks` and `entries`. Each entry has `name`, `type`, `blocks`, `closed` and `locked`.
|
|
95
94
|
|
|
96
|
-
For a tape file, `body` holds `name` and `entries`. Each entry has `name`, `start`, `end` and `bytes`. Many T64 files have a wrong end address. Then the entry has `fixedSize: true`, and the
|
|
95
|
+
For a tape file, `body` holds `name` and `entries`. Each entry has `name`, `start`, `end` and `bytes`. Many T64 files have a wrong end address. Then the entry has `fixedSize: true`, and the script gives the correct `end` and `bytes`.
|
|
97
96
|
|
|
98
97
|
For a cartridge file, `body` holds the header and `chips`. The header is `name`, `type`, `typeName`, `exrom`, `game`, and `mode` for type 0. Each chip has `bank`, `address`, `size` and `space`.
|
|
99
98
|
|
|
@@ -161,24 +160,15 @@ All banks use the same addresses. Thus `hint` tells you to analyze each bank PRG
|
|
|
161
160
|
|
|
162
161
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
163
162
|
|
|
164
|
-
On success, the exit code is 0:
|
|
165
|
-
|
|
166
|
-
```json
|
|
167
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
On failure, the exit code is 2:
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
174
|
-
```
|
|
175
|
-
|
|
163
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
164
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
176
165
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
177
166
|
- 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.
|
|
178
|
-
- `error` is one sentence. It tells what is wrong.
|
|
179
|
-
- `
|
|
180
|
-
- `
|
|
181
|
-
- `
|
|
167
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
168
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
169
|
+
- 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`.
|
|
170
|
+
- 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.
|
|
171
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
182
172
|
|
|
183
173
|
| `code` | Action |
|
|
184
174
|
|---|---|
|
|
@@ -186,14 +176,3 @@ On failure, the exit code is 2:
|
|
|
186
176
|
| `invalid-input`, `not-found` | Correct the call as `hint` tells. Then run the command again. |
|
|
187
177
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
188
178
|
| Another code | Do as `hint` tells. |
|
|
189
|
-
|
|
190
|
-
These fields have the same meaning in each body:
|
|
191
|
-
|
|
192
|
-
| Field | Meaning |
|
|
193
|
-
|---|---|
|
|
194
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
195
|
-
| `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. |
|
|
196
|
-
|
|
197
|
-
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.
|
|
198
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|
|
199
|
-
|