@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
package/skills/c64-docs/SKILL.md
CHANGED
|
@@ -56,12 +56,11 @@ Get the values for the commands from these places:
|
|
|
56
56
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
57
57
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
58
58
|
- 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.
|
|
59
|
-
- The script refuses an `--out` path in `.c64-re-tools/knowledge
|
|
59
|
+
- The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
|
|
60
60
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
61
61
|
- 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.
|
|
62
|
-
- A coverage map can stay in `.c64-re-tools/local/`.
|
|
63
|
-
-
|
|
64
|
-
- 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.
|
|
62
|
+
- A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
|
|
63
|
+
- 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.
|
|
65
64
|
- 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`.
|
|
66
65
|
|
|
67
66
|
### The group folder
|
|
@@ -95,29 +94,32 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
95
94
|
|
|
96
95
|
### `generate <source-dir>`
|
|
97
96
|
|
|
98
|
-
Writes the reference pages from the project knowledge, the source
|
|
97
|
+
Writes the reference pages from the project knowledge, the generated source and the program bytes in the project knowledge. Before it writes, it removes the pages of an earlier run in `--out`.
|
|
99
98
|
|
|
100
99
|
`body` holds:
|
|
101
100
|
|
|
102
101
|
- `out`: the folder of the reference. `index`: the path of `index.md`. `revision`: the revision of the project knowledge.
|
|
103
102
|
- `pages`, `entries`, `tables`, `images` and `edges`: the counts of the reference.
|
|
104
103
|
- `files`: the pages and images that it wrote, each with `out`, `bytes` and `sha256`.
|
|
104
|
+
- `gaps`: what the project knowledge does not have yet. Each list holds at most `--max-listed` items.
|
|
105
|
+
- `routinesWithoutComment`: each routine of the module pages without a comment, with `name`, `address` and `file`.
|
|
106
|
+
- `modulesWithoutRoutines`: each module whose file has code but no routine, with `file`, `start` and `title`.
|
|
107
|
+
- `tablesWithoutName`: each table of addresses, jumps or words without a name, with `start`, `end` and `type`.
|
|
105
108
|
- `program`: `the knowledge`, or `none` when the project knowledge has no program bytes. Without them, the tables are not decoded, and the graphics page has no images.
|
|
106
109
|
|
|
107
110
|
`hint` and `nextAction`:
|
|
108
111
|
|
|
109
112
|
- `hint` tells you to write the pages. `nextAction` is the `link` command for `README.md` and the folder above `--out`. Run it after you write the pages.
|
|
113
|
+
- `gaps` has items: record a comment for each routine, the routines of each module, and a name for each table in the project knowledge. Then generate the source again, and run `generate` again.
|
|
110
114
|
- When `program` is `none`, `hint` tells you to put the program bytes into the project knowledge. Then run `generate` again.
|
|
111
115
|
|
|
112
|
-
The reference has these pages
|
|
116
|
+
The reference has these pages. Each page tells how to read its tables and its graphs.
|
|
113
117
|
|
|
114
118
|
- `index.md`: each file of the source, with its range, its title, the count of routines and the count of names.
|
|
115
|
-
- `modules/<file>.md`:
|
|
116
|
-
- `tables.md`: each table of addresses, jumps and words, entry by entry, with its 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.
|
|
118
|
-
- `graphics.md`: each `sprite`, `bitmap
|
|
119
|
-
|
|
120
|
-
In a call graph, a solid arrow is a call, and a thick arrow is a table entry. The graph does not show the jumps. A table entry goes from each routine that reads the table to each target in code. A table of data addresses gives no arrow.
|
|
119
|
+
- `modules/<file>.md`: the routines, the data regions and a call graph of one file. Then an entry for each routine and each data name, with its comment and its references.
|
|
120
|
+
- `tables.md`: each table of addresses, jumps and words, entry by entry, with its target.
|
|
121
|
+
- `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.
|
|
122
|
+
- `graphics.md`: each `sprite`, `bitmap` and `charset` region as images, and each `screen` region as text.
|
|
121
123
|
|
|
122
124
|
Errors and their actions:
|
|
123
125
|
|
|
@@ -212,9 +214,10 @@ Errors:
|
|
|
212
214
|
|
|
213
215
|
The terms and the rules of scope are in `<skill>/references/style.md`. Before you write a claim about the history or the rebuild, find these facts:
|
|
214
216
|
|
|
215
|
-
-
|
|
217
|
+
- Read the releases with their SHA-256 from the project knowledge. They give the label, the file and the SHA-256 of each reference file. Find the stage of each capture.
|
|
216
218
|
- Find out if somebody examined an authenticated original. When nobody examined one, write this fact in the first paragraph of `README.md`.
|
|
217
219
|
- What each compare included, and what it proves.
|
|
220
|
+
- Read the results of the checks of the comments from the project knowledge. Write the number of comments in the last check, and the number of `wrong` and `unsure` comments, in the first paragraph of `README.md`. When the project has no check, write this fact there.
|
|
218
221
|
|
|
219
222
|
`link --check` checks the links, the reference pages and the files of the evidence. It does not check if a claim is true. Read each claim against its evidence before you call the documentation complete.
|
|
220
223
|
|
|
@@ -222,9 +225,9 @@ The terms and the rules of scope are in `<skill>/references/style.md`. Before yo
|
|
|
222
225
|
|
|
223
226
|
## Workflow
|
|
224
227
|
|
|
225
|
-
1. Read the project knowledge. The documentation can only be as good as the knowledge. Each routine needs a name
|
|
226
|
-
2. Generate the source from the project knowledge. Make sure that the check of the source gives identical bytes.
|
|
227
|
-
3. Run `generate`.
|
|
228
|
+
1. Read the project knowledge. The documentation can only be as good as the knowledge. Each routine needs a name, each table needs a region, and each file of the source needs a module with a title. Record what is missing in the project knowledge.
|
|
229
|
+
2. Generate the source from the project knowledge. Make sure that the check of the source gives identical bytes.
|
|
230
|
+
3. Run `generate`. When `gaps` has items, record what is missing in the project knowledge. Then do steps 2 and 3 again.
|
|
228
231
|
4. Make the plan of the pages. Start from the modules and the call graphs. Find the main loop, the interrupt chain, the dispatch tables, the state machines and the data formats. Each subsystem gets one page in `docs/`. The entry page `README.md` lists the pages. Use the page types in `<skill>/references/page-types.md`.
|
|
229
232
|
5. Collect the facts about the development and the copy protection. Collect them from the reference files, not from a commercial original that nobody examined. These facts are the most interesting parts for a reader, so look for them carefully.
|
|
230
233
|
- Read the leftover spaces and their comments in the project knowledge. If the knowledge has none, find the leftovers of the development in the program.
|
|
@@ -251,24 +254,15 @@ Do not keep the pages, or the facts that are only in the pages, in the project k
|
|
|
251
254
|
|
|
252
255
|
Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
|
|
253
256
|
|
|
254
|
-
On success, the exit code is 0:
|
|
255
|
-
|
|
256
|
-
```json
|
|
257
|
-
{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
On failure, the exit code is 2:
|
|
261
|
-
|
|
262
|
-
```json
|
|
263
|
-
{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
|
|
264
|
-
```
|
|
265
|
-
|
|
257
|
+
- On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
|
|
258
|
+
- On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
|
|
266
259
|
- `body` holds the result. The section of each command gives the fields of its body.
|
|
267
260
|
- 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.
|
|
268
|
-
- `error` is one sentence. It tells what is wrong.
|
|
269
|
-
- `
|
|
270
|
-
- `
|
|
271
|
-
- `
|
|
261
|
+
- `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
|
|
262
|
+
- `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
|
|
263
|
+
- 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`.
|
|
264
|
+
- 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.
|
|
265
|
+
- To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
|
|
272
266
|
|
|
273
267
|
| `code` | Action |
|
|
274
268
|
|---|---|
|
|
@@ -277,19 +271,7 @@ On failure, the exit code is 2:
|
|
|
277
271
|
| `operation-failed` | Give `error` and `hint` to the user. |
|
|
278
272
|
| Another code | Do as `hint` tells. |
|
|
279
273
|
|
|
280
|
-
These fields have the same meaning in each body:
|
|
281
|
-
|
|
282
|
-
| Field | Meaning |
|
|
283
|
-
|---|---|
|
|
284
|
-
| `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
|
|
285
|
-
| `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. |
|
|
286
|
-
|
|
287
|
-
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.
|
|
288
|
-
To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
274
|
## Reference
|
|
293
275
|
|
|
294
|
-
- `<skill>/references/page-types.md`: the page types, with the parts of each type and a template. The types are the entry page, the workspace index, the group entry page, the subsystem page and the entity sections. Other types are the data-format page, the development page and the copy protection page.
|
|
276
|
+
- `<skill>/references/page-types.md`: the page types, with the parts of each type and a template. The types are the entry page, the workspace index, the group entry page, the subsystem page and the entity sections. Other types are the data-format page, the development page and the copy protection page.
|
|
295
277
|
- `<skill>/references/style.md`: the rules for the text of the pages. They tell how to explain, and how to write the names and the links. They also give the evidence marks, the diagrams and the images.
|
|
@@ -8,7 +8,7 @@ One entry page for the program: `README.md` in the project folder. A large subsy
|
|
|
8
8
|
|
|
9
9
|
The most interesting parts for a reader are the development of the program and its copy protection. Put them first, and explain them in depth. The entry page of the program has these parts, in this order:
|
|
10
10
|
|
|
11
|
-
1. **One paragraph.** What the program is, the authors and the year, and the reference files that the documentation is for. Tell if somebody examined an authenticated original. Under it,
|
|
11
|
+
1. **One paragraph.** What the program is, the authors and the year, and the reference files that the documentation is for. Tell if somebody examined an authenticated original. Under it, write the evidence line of the section "Evidence" of `<skill>/references/style.md`.
|
|
12
12
|
2. **The development.** How the authors made the program, as the code and the leftovers tell it. Bytes in a later copy can come from a crack or a release. Do not tell where they came from without evidence. Explain each trace in depth: what the bytes are, how you identified them, and what they tell about the work of the authors. Use as many paragraphs as the traces need. Link the development page (section 6) for the full details.
|
|
13
13
|
3. **The copy protection.** How the protection of the reference files works, in depth. Tell what the loader left in memory, and explain each check and where the program hides it. Tell what happens when a check fails, and how the rebuild turns it off. Link the copy protection page (section 7) for the full details.
|
|
14
14
|
4. **Findings.** The bugs and the facts that a reader does not expect. Write a bulleted list, not a table. Each item has a title in bold, the facts and the evidence. It also has a link to the page with the details. Then tell what the finding means in practice. Examples are what a player sees, what a test or a fix can use, and what a preservation project must know. Mark an idea that no run showed as **Conclusion**.
|
|
@@ -41,7 +41,7 @@ Look for findings of these kinds. They are often the most useful to a reader:
|
|
|
41
41
|
|
|
42
42
|
<What the program is. The authors and the year. The reference files that this documentation is for, and where they came from. Tell if somebody examined an authenticated original.>
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
<The evidence line.>
|
|
45
45
|
|
|
46
46
|
## The development
|
|
47
47
|
|
|
@@ -112,7 +112,7 @@ Reverse-engineered C64 games. Each game has its own folder with its reference fi
|
|
|
112
112
|
|
|
113
113
|
A program with two or more versions in a group folder has one `README.md` in the group folder. It tells the parts of the program that the versions share. Each version has its own entry page in its project folder. The group entry page has these parts, in this order:
|
|
114
114
|
|
|
115
|
-
1. **One paragraph.** What the program is, who made it and when, and which versions and reference files the documentation is for. Tell if somebody examined an authenticated original. Under it,
|
|
115
|
+
1. **One paragraph.** What the program is, who made it and when, and which versions and reference files the documentation is for. Tell if somebody examined an authenticated original. Under it, write the evidence line.
|
|
116
116
|
2. **The versions.** A table with one row for each version: the link to its entry page, the releases of the version, and its entry address. Under the table, tell how the versions are different and why the versions need a project each.
|
|
117
117
|
3. **The development**, **The copy protection** and **Findings**, as in the entry page of section 1, for the facts that the versions share. Write the label of the version before each name, for example `` `v1:speech_irq` `$29C8` ``.
|
|
118
118
|
4. **The pages.** A table of the shared pages in `docs/`, for example the development, the changes between the versions, the releases and the disk layout.
|
|
@@ -125,7 +125,7 @@ Each fact goes in one place. A fact of all versions goes in the group entry page
|
|
|
125
125
|
|
|
126
126
|
<What the program is. The authors and the year. The versions that this documentation is for.>
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
<The evidence line.>
|
|
129
129
|
|
|
130
130
|
## The versions
|
|
131
131
|
|
|
@@ -156,14 +156,27 @@ Each fact goes in one place. A fact of all versions goes in the group entry page
|
|
|
156
156
|
One page for each subsystem, for example the main loop, the interrupt chain, the room generation or the sound player. It has these parts:
|
|
157
157
|
|
|
158
158
|
1. **What it does.** One paragraph in the words of the program. Tell what the subsystem does for the player and why the program needs it. Do not list the routines.
|
|
159
|
-
2. **The conventions.** The terms of the page, for example "a pass is one run of the main loop". Use the conventions block of
|
|
159
|
+
2. **The conventions.** The terms of the page, for example "a pass is one run of the main loop", and the evidence line. Use the conventions block of the template below, and change the terms for the program.
|
|
160
160
|
3. **How it works.** A small mermaid flowchart, then the explanation in prose. Put a fact that a reader does not expect into the text where it belongs. The findings of the entry page link to it. Link the entry routine of the subsystem one time. For the main routine, give a numbered list of what it does and why, in the order of the code. Name a helper routine only when the reader needs it. Add pseudo-code when a loop or a condition is not clear from the list.
|
|
161
161
|
4. **The data.** Only the data that a reader needs to understand the subsystem. For each structure, give the layout: the bytes, the entries and the meaning of each byte. The reference lists every variable, so do not make a table of each variable.
|
|
162
162
|
5. **The state machine.** For code that changes from one state to another: a mermaid `stateDiagram-v2` and a transition table. The transition table has the state, the condition, the next state and the name of the code that makes the change, without a link.
|
|
163
|
-
6. **The worked example.** One real case
|
|
163
|
+
6. **The worked example.** One real case: read its bytes in the listing of the project knowledge, and tell what each byte gives. For example the first bytes of the map of level 1, and the screen cells that they give.
|
|
164
164
|
7. **Still open.**
|
|
165
165
|
|
|
166
166
|
```markdown
|
|
167
|
+
# <Subsystem>
|
|
168
|
+
|
|
169
|
+
<What it does for the player, and why the program needs it.>
|
|
170
|
+
|
|
171
|
+
**Conventions.**
|
|
172
|
+
- Addresses are C64 addresses. Names are the names of the knowledge.
|
|
173
|
+
- A *pass* is one run of the main loop. A *frame* is one raster interrupt.
|
|
174
|
+
- <The evidence line.>
|
|
175
|
+
|
|
176
|
+
## How it works
|
|
177
|
+
|
|
178
|
+
...
|
|
179
|
+
|
|
167
180
|
## The state machine of <thing>
|
|
168
181
|
|
|
169
182
|
The slider waits until its timer is 0, then moves one step. [`update_slider` `$3F8C`](../src/sliders.asm#L40) makes each change.
|
|
@@ -200,7 +213,7 @@ One page for each format of data, for example a packed map, a music stream or a
|
|
|
200
213
|
1. **Where the data is.** The table of pointers, the range of the data, and the routine that reads it. Link the routine one time.
|
|
201
214
|
2. **The byte layout.** A table of each byte or bit field, with its meaning. For a stream: each command byte, its arguments and what it does.
|
|
202
215
|
3. **The decoder.** Pseudo-code of the routine that reads the format.
|
|
203
|
-
4. **A worked example.** The first bytes of one item,
|
|
216
|
+
4. **A worked example.** The first bytes of one item: read them in the listing of the project knowledge, and tell what each byte means.
|
|
204
217
|
5. **The assets.** A link to the extracted files and images, for example `../assets/rooms/room00.png`. Embed the image.
|
|
205
218
|
|
|
206
219
|
```markdown
|
|
@@ -235,14 +248,3 @@ One page, `docs/protection.md`, that explains the copy protection of the program
|
|
|
235
248
|
4. **The releases.** In one or two sentences: which checks still run in each release. When a crack changed bytes of the program to stop a check, tell which bytes, and link the code of the change one time.
|
|
236
249
|
5. **The rebuild.** The switch that turns the protection off, the bytes that it changes, and the runs that show that the program operates without it. Tell in words what each run did.
|
|
237
250
|
6. **Still open.** The checks that no run reached, and the run that can reach them.
|
|
238
|
-
|
|
239
|
-
## 8. The conventions block
|
|
240
|
-
|
|
241
|
-
Put this block near the top of each subsystem page. Change the terms for the program.
|
|
242
|
-
|
|
243
|
-
```markdown
|
|
244
|
-
**Conventions.**
|
|
245
|
-
- Addresses are C64 addresses. Names are the names of the knowledge.
|
|
246
|
-
- A *pass* is one run of the main loop. A *frame* is one raster interrupt.
|
|
247
|
-
- **Observed** marks a fact that a run showed. **Code** marks a fact from the code only. **Conclusion** marks an interpretation.
|
|
248
|
-
```
|
|
@@ -25,10 +25,16 @@ These rules apply to each page that you write. The `link` command checks the rul
|
|
|
25
25
|
## Evidence
|
|
26
26
|
|
|
27
27
|
- Mark each fact with its evidence, as text:
|
|
28
|
-
- **Observed**: a run showed it.
|
|
28
|
+
- **Observed**: a run showed it. A capture of a run and a compare of the releases count as runs.
|
|
29
29
|
- **Code**: the code shows it, and no run showed it.
|
|
30
30
|
- **Conclusion**: an interpretation of the facts.
|
|
31
31
|
- Put the mark at the end of the paragraph or the list item. When the facts of a paragraph have different evidence, mark each fact.
|
|
32
|
+
- The evidence line tells the reader the marks. Put it under the first paragraph of each entry page, and in the conventions block of each subsystem page:
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
**Evidence.** **Observed** marks a fact that a run showed. **Code** marks a fact from the code only. **Conclusion** marks an interpretation.
|
|
36
|
+
```
|
|
37
|
+
|
|
32
38
|
- Do not write the name of a JSON file in a page, and do not link to it. Examples are a scenario, a run file, a capture and a list that the source generation wrote. These files are input and output of the tools. They do not help a reader to understand the program.
|
|
33
39
|
- Tell in words what the run did and what it showed. An example: "a run fills each leftover with `$A5` at the entry, and the memory and the screen stay the same at all 10 checkpoints (**Observed**)".
|
|
34
40
|
- Do not link to a file in `.c64-re-tools/local/`.
|
|
@@ -49,9 +55,9 @@ Rules:
|
|
|
49
55
|
- Give the release label of the reference file before you give the result of a byte compare. When the compare does not include all of the program, give the ranges.
|
|
50
56
|
- Write that a rebuild is identical to the commercial original only after a compare with an authenticated original. A PASS of a compare is true only for the bytes of its reference file, for example a crack.
|
|
51
57
|
- Two releases that can come from the same copy do not give two items of evidence. A byte that most releases have is not always a byte of the commercial original.
|
|
52
|
-
- **Observed
|
|
53
|
-
- **Code
|
|
54
|
-
- **Conclusion
|
|
58
|
+
- **Observed** does not tell who made the program, its history, or the bytes of a release that you did not examine.
|
|
59
|
+
- **Code** does not tell that a release that you did not examine does the same.
|
|
60
|
+
- For a **Conclusion**, give the facts that it uses and the other possible interpretations. For example, source text in the format of an Apple II assembler does not prove the computer of the authors.
|
|
55
61
|
- Bytes that no run read are not always bytes that the program cannot read. Give the runs and the checks that show the limit.
|
|
56
62
|
- Write the limits in the first paragraph. Write them again in each short summary that can tell more than the evidence shows.
|
|
57
63
|
|
|
@@ -9,6 +9,7 @@ import { existsSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs
|
|
|
9
9
|
import { basename, join, posix } from "node:path";
|
|
10
10
|
import type { DatabaseSync } from "node:sqlite";
|
|
11
11
|
|
|
12
|
+
import { formatC64Address } from "#src/c64.ts";
|
|
12
13
|
import { Refusal } from "#src/errors.ts";
|
|
13
14
|
import { WireFailure } from "#src/host-client/tools.ts";
|
|
14
15
|
import { writeProjectFile, writeReported } from "#src/host-client/transfer.ts";
|
|
@@ -93,15 +94,25 @@ function generate(call: Call): Reply {
|
|
|
93
94
|
});
|
|
94
95
|
for (const path of old) rmSync(join(directory, path), { force: true });
|
|
95
96
|
const written = built.files.map((file) => writeReported(file.path, file.bytes, { what: "--out" }));
|
|
96
|
-
const
|
|
97
|
+
const max = call.count("max-listed")!;
|
|
98
|
+
const files = listed(written, max);
|
|
99
|
+
// What the knowledge does not have yet: the empty summaries, the modules with code but no routine, and the tables without a name of the pages.
|
|
100
|
+
const gaps = {
|
|
101
|
+
routinesWithoutComment: listed(built.gaps.routinesWithoutComment, max, (routine) => ({ name: routine.name, address: formatC64Address(routine.address), file: routine.file })),
|
|
102
|
+
modulesWithoutRoutines: listed(built.gaps.modulesWithoutRoutines, max, (module) => ({ file: module.file, start: formatC64Address(module.start), ...(module.title === undefined ? {} : { title: module.title }) })),
|
|
103
|
+
tablesWithoutName: listed(built.gaps.tablesWithoutName, max, (table) => ({ start: formatC64Address(table.start), end: formatC64Address(table.end), type: table.type })),
|
|
104
|
+
};
|
|
97
105
|
const hints: string[] = [];
|
|
98
106
|
if (image === undefined) hints.push("The knowledge has no program bytes. Thus the reference does not decode the tables and does not show the graphics. To get them, put the program bytes into the project knowledge and run generate again.");
|
|
99
107
|
if (files.rest !== undefined) hints.push(`files is cut. To list all files, give ${files.rest}.`);
|
|
108
|
+
if (Object.values(gaps).some((gap) => gap.count > 0)) {
|
|
109
|
+
hints.push("gaps lists what the project knowledge does not have yet. Record a comment for each routine, the routines of each module, and a name for each table in the project knowledge. Then generate the source again, and run generate again.");
|
|
110
|
+
}
|
|
100
111
|
hints.push("Write the pages of the documentation. Then run nextAction to link them to the source.");
|
|
101
112
|
// The next step links the entry page and the folder above the reference, with the reference given, so that it also finds a reference that is not named reference/.
|
|
102
113
|
const parent = posix.dirname(posix.normalize(out));
|
|
103
114
|
return reply(
|
|
104
|
-
{ out, revision: knowledge.revision, index: posix.join(posix.normalize(out), "index.md"), ...built.counts, files, program: image === undefined ? "none" : "the knowledge" },
|
|
115
|
+
{ out, revision: knowledge.revision, index: posix.join(posix.normalize(out), "index.md"), ...built.counts, files, gaps, program: image === undefined ? "none" : "the knowledge" },
|
|
105
116
|
{ hint: hints.join(" "), nextAction: call.next("link", "README.md", ...(parent === "." ? [] : [parent]), "--source", source, "--reference", posix.normalize(out)) },
|
|
106
117
|
);
|
|
107
118
|
}
|
|
@@ -34,6 +34,16 @@ export interface ReferenceFile {
|
|
|
34
34
|
bytes: Buffer;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/** What the knowledge does not have yet, as the pages show it. */
|
|
38
|
+
export interface ReferenceGaps {
|
|
39
|
+
/** The routines of the module pages without a comment: an empty summary in the routine table. */
|
|
40
|
+
routinesWithoutComment: Array<{ name: string; address: number; file: string }>;
|
|
41
|
+
/** The modules of the knowledge whose file has code but no routine. */
|
|
42
|
+
modulesWithoutRoutines: Array<{ file: string; start: number; title?: string }>;
|
|
43
|
+
/** The tables of the tables page without a name: their heading is a range. */
|
|
44
|
+
tablesWithoutName: Array<{ start: number; end: number; type: RegionType }>;
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
/** Files that the source map lists but that hold no code of the program: they get no module page. */
|
|
38
48
|
const NOT_PIECES = new Set(["main.asm", "constants.asm", "macros.asm", "loader.asm", "config.asm", "switches.asm", "start_screen.asm", "start_screen_stage.asm"]);
|
|
39
49
|
const TABLE_TYPES: readonly RegionType[] = [...POINTER_TABLE_TYPES, "jumps", "words"];
|
|
@@ -65,8 +75,8 @@ interface Entry {
|
|
|
65
75
|
spanEnd: number;
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
/** Builds every page and image of the reference. */
|
|
69
|
-
export function buildReference(input: ReferenceInput): { files: ReferenceFile[]; counts: Record<string, number
|
|
78
|
+
/** Builds every page and image of the reference, and lists what the knowledge does not have yet. */
|
|
79
|
+
export function buildReference(input: ReferenceInput): { files: ReferenceFile[]; counts: Record<string, number>; gaps: ReferenceGaps } {
|
|
70
80
|
const { map, out } = input;
|
|
71
81
|
const pieces = map.files.filter((file) => !NOT_PIECES.has(file));
|
|
72
82
|
const pageOfFile = (file: string) => (file === "constants.asm" ? posix.join(out, "memory-map.md") : posix.join(out, "modules", `${stem(file)}.md`));
|
|
@@ -366,7 +376,12 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
366
376
|
const reaching = edges.filter((edge) => edge.kind !== "jump" && (ownAt.has(edge.from) || ownAt.has(edge.to)));
|
|
367
377
|
const shown = reaching.slice(0, MAX_EDGES);
|
|
368
378
|
if (shown.length > 0) {
|
|
369
|
-
lines.push(
|
|
379
|
+
lines.push(
|
|
380
|
+
"",
|
|
381
|
+
"## Call graph",
|
|
382
|
+
"",
|
|
383
|
+
"A solid arrow is a call, a thick arrow a table entry: from each routine that reads the table to each target in code. A table of data addresses gives no arrow, and the graph does not show the jumps. Rounded nodes are in this file.",
|
|
384
|
+
);
|
|
370
385
|
if (shown.length < reaching.length) lines.push("", `The graph shows ${shown.length} of the ${reaching.length} edges.`);
|
|
371
386
|
lines.push("", "```mermaid", mermaidGraph(heads, shown, ownAt), "```");
|
|
372
387
|
}
|
|
@@ -442,7 +457,16 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
442
457
|
// --- Memory map ---------------------------------------------------------------
|
|
443
458
|
{
|
|
444
459
|
const page = posix.join(out, "memory-map.md");
|
|
445
|
-
const lines = [
|
|
460
|
+
const lines = [
|
|
461
|
+
"# Memory map",
|
|
462
|
+
"",
|
|
463
|
+
`Every region of the knowledge in address order, then the variables outside the program. A platform name, for example a chip register, has a reader or a writer only where the source line uses that name. (indexed) after a routine: the line adds X or Y to the address, so the access can also reach the addresses after it, which can have no row. Index: [the reference](${rel(page, posix.join(out, "index.md"))}).`,
|
|
464
|
+
"",
|
|
465
|
+
"## Regions",
|
|
466
|
+
"",
|
|
467
|
+
"| Range | Bytes | Type | Name | File |",
|
|
468
|
+
"|---|---|---|---|---|",
|
|
469
|
+
];
|
|
446
470
|
for (const region of [...input.regions].sort((a, b) => a.start - b.start)) {
|
|
447
471
|
const name = entryAt.get(region.start);
|
|
448
472
|
const line = map.lineOf(region.start);
|
|
@@ -483,5 +507,23 @@ export function buildReference(input: ReferenceInput): { files: ReferenceFile[];
|
|
|
483
507
|
write(page, lines);
|
|
484
508
|
}
|
|
485
509
|
counts.pages = files.filter((file) => file.path.endsWith(".md")).length;
|
|
486
|
-
|
|
510
|
+
|
|
511
|
+
// --- Gaps -----------------------------------------------------------------------
|
|
512
|
+
const fileOf = (address: number) => map.lineOf(address)?.file;
|
|
513
|
+
const routineFiles = new Set(heads.map((head) => fileOf(head.address)));
|
|
514
|
+
// A module of data only needs no routine: only a file with code lines is a gap.
|
|
515
|
+
const codeFiles = new Set<string | undefined>();
|
|
516
|
+
for (const region of input.regions) if (region.type === "code") for (let address = region.start; address <= region.end; address++) codeFiles.add(fileOf(address));
|
|
517
|
+
const gaps: ReferenceGaps = {
|
|
518
|
+
routinesWithoutComment: heads.flatMap((head) => {
|
|
519
|
+
const file = fileOf(head.address);
|
|
520
|
+
return file !== undefined && pieces.includes(file) && commentLines(head.address).length === 0 ? [{ name: head.name, address: head.address, file }] : [];
|
|
521
|
+
}),
|
|
522
|
+
modulesWithoutRoutines: [...input.modules]
|
|
523
|
+
.sort((a, b) => a.start - b.start)
|
|
524
|
+
.filter((module) => pieces.includes(module.file) && codeFiles.has(module.file) && !routineFiles.has(module.file))
|
|
525
|
+
.map((module) => ({ file: module.file, start: module.start, ...(module.title === undefined ? {} : { title: module.title }) })),
|
|
526
|
+
tablesWithoutName: tables.filter((table) => entryAt.get(table.start) === undefined).map((table) => ({ start: table.start, end: table.end, type: table.type })),
|
|
527
|
+
};
|
|
528
|
+
return { files, counts, gaps };
|
|
487
529
|
}
|