@henols/c64-re-tools 2.7.1 → 2.8.0-rc.2

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.
Files changed (70) hide show
  1. package/package.json +1 -1
  2. package/skills/c64-assembler/SKILL.md +23 -38
  3. package/skills/c64-assembler/scripts/assembler.ts +137 -17
  4. package/skills/c64-basic/SKILL.md +11 -31
  5. package/skills/c64-basic/scripts/basic.ts +4 -1
  6. package/skills/c64-development/SKILL.md +2 -2
  7. package/skills/c64-disk/SKILL.md +11 -32
  8. package/skills/c64-docs/SKILL.md +27 -45
  9. package/skills/c64-docs/references/page-types.md +20 -18
  10. package/skills/c64-docs/references/style.md +10 -4
  11. package/skills/c64-docs/scripts/docs.ts +13 -2
  12. package/skills/c64-docs/scripts/lib/reference.ts +47 -5
  13. package/skills/c64-knowledge/SKILL.md +138 -267
  14. package/skills/c64-knowledge/references/batches.md +48 -0
  15. package/skills/c64-knowledge/references/coverage.md +29 -0
  16. package/skills/c64-knowledge/references/source-knowledge.md +72 -0
  17. package/skills/c64-knowledge/references/start-screen.md +44 -0
  18. package/skills/c64-knowledge/scripts/knowledge.ts +266 -61
  19. package/skills/c64-knowledge/scripts/lib/check.ts +133 -0
  20. package/skills/c64-knowledge/scripts/lib/listing.ts +71 -8
  21. package/skills/c64-memory-map/SKILL.md +11 -32
  22. package/skills/c64-packer/SKILL.md +11 -31
  23. package/skills/c64-provenance/SKILL.md +43 -64
  24. package/skills/c64-provenance/scripts/lib/leftovers.ts +8 -3
  25. package/skills/c64-provenance/scripts/provenance.ts +65 -56
  26. package/skills/c64-reverse-engineering/SKILL.md +20 -47
  27. package/skills/c64-reverse-engineering/references/comment-check.md +42 -0
  28. package/skills/c64-reverse-engineering/references/versions.md +47 -0
  29. package/skills/c64-source/SKILL.md +48 -237
  30. package/skills/c64-source/references/export.md +50 -0
  31. package/skills/c64-source/references/loader.md +78 -0
  32. package/skills/c64-source/references/source-format.md +46 -0
  33. package/skills/c64-source/scripts/lib/export.ts +28 -13
  34. package/skills/c64-source/scripts/lib/loader.ts +4 -82
  35. package/skills/c64-source/scripts/lib/source.ts +3 -5
  36. package/skills/c64-source/scripts/source.ts +48 -51
  37. package/skills/c64-static-analysis/SKILL.md +52 -52
  38. package/skills/c64-static-analysis/scripts/lib/coverage.ts +55 -2
  39. package/skills/c64-static-analysis/scripts/lib/idioms.ts +43 -17
  40. package/skills/c64-static-analysis/scripts/static-analysis.ts +79 -15
  41. package/skills/c64-testing/SKILL.md +72 -58
  42. package/skills/c64-testing/references/recording-format.md +5 -80
  43. package/skills/c64-testing/references/scenario-format.md +4 -12
  44. package/skills/c64-testing/scripts/lib/play.ts +16 -8
  45. package/skills/c64-testing/scripts/lib/recording.ts +74 -9
  46. package/skills/c64-testing/scripts/lib/replay.ts +4 -0
  47. package/skills/c64-testing/scripts/lib/runs.ts +112 -1
  48. package/skills/c64-testing/scripts/lib/scenario.ts +12 -6
  49. package/skills/c64-testing/scripts/lib/start-screen.ts +27 -0
  50. package/skills/c64-testing/scripts/testing.ts +34 -13
  51. package/skills/c64-unpacker/SKILL.md +10 -30
  52. package/skills/emulator/SKILL.md +7 -36
  53. package/src/build-name.ts +12 -1
  54. package/src/c64.ts +16 -0
  55. package/src/knowledge/history.ts +8 -0
  56. package/src/knowledge/program.ts +84 -4
  57. package/src/knowledge/read.ts +46 -2
  58. package/src/knowledge/recording-files.ts +32 -0
  59. package/src/knowledge/schema.ts +3 -1
  60. package/src/knowledge/separate.ts +165 -11
  61. package/src/knowledge/start-screen.ts +99 -17
  62. package/src/knowledge/text.ts +2 -1
  63. package/src/knowledge/write.ts +15 -8
  64. package/src/loader.ts +167 -0
  65. package/src/native/decompiler/analyze.ts +7 -6
  66. package/src/native/decompiler/walk.ts +32 -2
  67. package/src/native/dxa.ts +4 -4
  68. package/src/native/types.ts +34 -4
  69. package/src/script.ts +102 -25
  70. package/skills/c64-export/SKILL.md +0 -63
@@ -27,8 +27,10 @@ To get the command list, run the script with no arguments.
27
27
  | Keep the screens and all differing bytes of a FAIL | `test tests/moves-left.json --out .c64-re-tools/local/results/moves-left` |
28
28
  | Do many steps on one program and keep the results as files | `run .c64-re-tools/local/runs/rooms/run.json --out .c64-re-tools/local/runs/rooms` |
29
29
  | Test a new program or a correction with expected values | `run tests/title.json --out .c64-re-tools/local/runs/title` |
30
+ | Keep a run as evidence in a folder that git keeps | `keep .c64-re-tools/local/runs/rooms/run.json .c64-re-tools/local/runs/rooms runs/rooms` |
30
31
  | Record a play session of a person on the reference | `record tests/record/start.json --out tests/recordings/play1 --play --joystick 1` |
31
32
  | Record a session from steps only | `record tests/record/rooms.json --out tests/recordings/rooms` |
33
+ | Find the input sites and the coverage of a recording | `show tests/recordings/rooms` |
32
34
  | Make sure that a recording replays on the reference | `replay tests/recordings/rooms` |
33
35
  | Keep the screen at the end of a recorded session | `replay tests/recordings/final --screen .c64-re-tools/local/results/final.png` |
34
36
  | Compare the rebuild with a recording | `replay tests/recordings/rooms --checkpoint main_loop --state room --state lives --pin random_ptr:2 --rebuild build/clean.prg --symbols build/symbols/clean.json --out .c64-re-tools/local/results/rooms` |
@@ -43,6 +45,7 @@ To get the command list, run the script with no arguments.
43
45
  - The reference program and the rebuild are PRG files in the project. The script refuses a disk, tape or cartridge image. Extract the program file from the image first.
44
46
  - The reference gets its names from the project knowledge. Give `"symbols": "knowledge"` for the reference.
45
47
  - The rebuild gets its names from the symbol file of its build. Build the rebuild with a symbol file that has all symbols, also the constants that the source does not use.
48
+ - The loader program of a generated source can show a start screen that waits for a key. If the symbols of the program have the labels of that start screen, `test`, `run` and `replay` start the program after the start screen. Do not add a step for the start screen.
46
49
  - You write the scenario file, the run file and the record file. Their formats are in the files of the section "Reference".
47
50
  - A file in `tests/` is a scenario or a run file with expected values. Give a scenario to `test` and a run file to `run`. `test` refuses a run file.
48
51
  - `<recording>` is the `--out` folder of `record`.
@@ -62,12 +65,11 @@ To get the command list, run the script with no arguments.
62
65
  - A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
63
66
  - Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
64
67
  - Write each file that you make for your work in `.c64-re-tools/local/` of the project. Git ignores that folder. Examples are results, batches, step files, runs, snapshots and memory dumps.
65
- - The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
68
+ - The script refuses an `--out` path in `.c64-re-tools/knowledge/`. Change the project knowledge only with the commands that change it.
66
69
  - The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
67
70
  - When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
68
- - A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
69
- - Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
70
- - Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
71
+ - A coverage map can stay in `.c64-re-tools/local/`. Do not move a coverage map after you put it into the project knowledge.
72
+ - To keep a run as evidence, use the command that keeps a run. It copies the run, its results and its snapshot files into `runs/<name>/`, and it changes the paths in the copy. Then git keeps them, and another person can do the run again.
71
73
  - A shell redirect (`>`) is relative to the working directory, not to the project folder. From the folder above the project, write `<folder>/.c64-re-tools/local/result.json`.
72
74
 
73
75
  ## Flags
@@ -83,6 +85,7 @@ Each flag applies only to the commands in the table. On another command, the scr
83
85
  | `--play` | `record` | A person plays after the steps. Off by default. |
84
86
  | `--joystick <1\|2>` | `record` | With `--play`: the joystick port at the start. The default is 2. |
85
87
  | `--http-port <n>` | `record` | With `--play`: the port of the page. The default is 6465. |
88
+ | `--max-listed <n>` | `show` | List at most n input sites. The default is 50. The count is always in the body. |
86
89
  | `--checkpoint <routine>` | `replay` | The routine of the checkpoints. Each entry of the routine is a checkpoint. The default is the comparison of the record file. |
87
90
  | `--state <item>` | `replay` | A memory item to compare at each checkpoint. Give it again for each item. |
88
91
  | `--pin <item>` | `replay` | Random state in RAM. At each checkpoint, the rebuild gets the values of the reference there. Give it again for each item. |
@@ -104,7 +107,7 @@ Each flag applies only to the commands in the table. On another command, the scr
104
107
  ### `test <scenario.json>`
105
108
 
106
109
  The script runs the scenario on the reference and then on the rebuild. Before each side, it does a hard reset. The CPU then stops at the reset vector.
107
- Before the test starts, the script examines the scenario and each file that it names. The section "Checks" of `references/scenario-format.md` gives each refusal.
110
+ Before the test starts, the script examines the scenario and each file that it names. The section "Checks" of `<skill>/references/scenario-format.md` gives each refusal.
108
111
 
109
112
  `body` holds:
110
113
 
@@ -114,7 +117,7 @@ Before the test starts, the script examines the scenario and each file that it n
114
117
  - A memory item gives `bytes`. `bytes.count` is the number of differing bytes. `bytes.listed` gives the first bytes, each with `address`, `reference` and `rebuild`.
115
118
  - Another item gives the `reference` value and the `rebuild` value.
116
119
  - `excluded`: each byte that an `exclude` left out of the comparison, with its `reason`.
117
- - `files`: with `--out` and a FAIL, the files that the script wrote. These are both screens and the difference image for each screen difference. `memory.json` has all bytes of each memory item that differs, and each byte that differs.
120
+ - `files`: with `--out` and a FAIL, the files that the script wrote. These are both screens, the difference image for each screen difference, and all bytes of each memory item that differs.
118
121
  - `reason`: with an INCONCLUSIVE, why the script could not compare.
119
122
 
120
123
  The pc and each address are `$xxxx`. Memory is lowercase hex. Other register values and chip values are decimal numbers.
@@ -151,8 +154,8 @@ A run file must have `name`, `start` and `steps`:
151
154
  { "name": "rooms", "start": { "program": "game.prg" }, "steps": [{ "frames": 100 }, { "screen": "title" }] }
152
155
  ```
153
156
 
154
- `symbols` and `videoStandard` are optional. The section "Runs" of `references/scenario-format.md` gives each key and step.
155
- Before the run starts, the script examines the run file, each file that it names and each name of the steps. The section "Checks" of `references/scenario-format.md` gives each refusal.
157
+ `symbols` and `videoStandard` are optional. The section "Runs" of `<skill>/references/scenario-format.md` gives each key and step.
158
+ Before the run starts, the script examines the run file, each file that it names and each name of the steps. The section "Checks" of `<skill>/references/scenario-format.md` gives each refusal.
156
159
 
157
160
  `body` holds:
158
161
 
@@ -160,8 +163,9 @@ Before the run starts, the script examines the run file, each file that it names
160
163
  - `completed`, `steps` and `done`: if the run completed, the number of steps, and the number of steps that ran.
161
164
  - `reason`: why a step did not run.
162
165
  - `pc`: the pc at the end of the run.
166
+ - `startScreen`: `skipped` when the run started the program after its start screen.
163
167
  - `files`: each file that the run wrote.
164
- - `observations`: the names of the observations. `results.json` in `--out` has their values.
168
+ - `observations`: the values of each observation, by its name. Memory is hex. A memory item of more than 4096 bytes, and `"memory": "all"`, give the name of their file in `file`.
165
169
  - `expectations`: for each `expect` step, `pass`, `count` and at most 16 `mismatches` with the expected and the actual value.
166
170
  - `failedExpectations`: the names of the `expect` steps that did not pass.
167
171
  - `traces`: for each `trace` step, its file, the count of hits, the frames and why the trace ended.
@@ -173,6 +177,20 @@ Traps:
173
177
  - A long run can need more time than one shell call. Then run the command in the background.
174
178
  - Add each coverage map of a run to the project knowledge as coverage.
175
179
 
180
+ ### `keep <run.json> <out> <folder>`
181
+
182
+ The script keeps a run as evidence in a new folder that git keeps, for example `runs/rooms`. `<out>` is the `--out` folder of the run.
183
+ The script copies the run file, the files of the run in `<out>`, and each file in `.c64-re-tools/local/` that the run file names. In the copy of the run file, it changes only the paths of the copied files.
184
+
185
+ `body` holds:
186
+
187
+ - `out`: the new folder. The copy of the run file is `run.json` in it.
188
+ - `files`: each file that the script wrote.
189
+ - `paths`: each path that changed in the run file, with its `field`, the old path in `from` and the new path in `to`.
190
+
191
+ Commit the folder, and give its files as evidence, as `hint` tells. The script refuses a folder that exists, a folder that git ignores, and an `<out>` with the results of another run.
192
+ If you changed the run file after the run, run it again before you keep it. The results must agree with the run file.
193
+
176
194
  ---
177
195
 
178
196
  ## Recordings
@@ -185,13 +203,11 @@ A recording keeps a session of the reference program, for example a play through
185
203
  - Replay each recording on the default build. Do not replay a release build or a build with a switch that is not at its default.
186
204
  - When the generated source has a loader, the default build is `build/clean_loader.prg`. Give `--symbols build/symbols/clean_loader.json` with it. Else the default build is `build/clean.prg`, with `--symbols build/symbols/clean.json`.
187
205
  - Commit the recording folder with the scenarios. Do not put a recording into the project knowledge. Do not put test results, screenshots or playtest results into it.
188
- - A finding that a recording shows can go into the project knowledge. Give the `recording.json` of the recording as its test evidence.
206
+ - A finding that a recording shows can go into the project knowledge. Give `evidence` of `show` as its test evidence.
189
207
  - The C64 of a recording has no disk drive. For a program that loads more files from a disk, use a scenario with `test`.
190
208
  - The emulator cannot examine the C64 of a recording or a replay. To keep the screen at the end of a recorded session, use `--screen` of `replay`.
191
209
 
192
- A replay is deterministic. The same recording gives the same session, to the cycle. The n-th read of an input at each instruction gets the value of the n-th read in the recording. Thus a rebuild with different timing gets the same input, also the same random values from the SID.
193
-
194
- Control each source of random numbers:
210
+ A replay gives the rebuild the same input as the reference, also when the timing of the rebuild is different. Control each source of random numbers:
195
211
 
196
212
  - A program that reads a seed from the SID gets the recorded value. You do not need to do more.
197
213
  - A program that reads a seed from the raster line or a CIA timer: add the address to `inputs` of the record file. Do this only when the program does not wait in a loop on that address.
@@ -199,7 +215,7 @@ Control each source of random numbers:
199
215
 
200
216
  ### `record <record.json>`
201
217
 
202
- The script does the steps of the record file on the reference program. Then it writes the recording folder into `--out`: `recording.json`, `reads.txt` and `coverage.bin`. The program must be a PRG file.
218
+ The script does the steps of the record file on the reference program. Then it writes the recording into the folder `--out`. The program must be a PRG file.
203
219
 
204
220
  `body` holds:
205
221
 
@@ -214,20 +230,18 @@ The script does the steps of the record file on the reference program. Then it w
214
230
 
215
231
  Do this for each result:
216
232
 
217
- - `PASS`: for a folder in `tests/recordings/`, `hint` tells you to commit the folder and to add its `coverage.bin` to the project knowledge as coverage. Git ignores `.c64-re-tools/local/`, thus the project knowledge must not name a file in it. For a folder there, `hint` tells you to record again with `--out tests/recordings/<name>`. `nextAction` replays the recording on the reference. Run it to make sure that the recording replays.
218
- - `PASS` with `evidence`: you recorded into the folder of an earlier recording. Put the new `coverage.bin` into the project knowledge as coverage. It replaces the map of the earlier recording. For another file in `evidence`, examine the facts of its revisions against the new recording.
233
+ - `PASS`: for a folder in `tests/recordings/`, `hint` tells you to commit the folder and to add its coverage map to the project knowledge as coverage. Git ignores `.c64-re-tools/local/`, thus the project knowledge must not name a file in it. For a folder there, `hint` tells you to record again with `--out tests/recordings/<name>`. `nextAction` replays the recording on the reference. Run it to make sure that the recording replays.
234
+ - `PASS` with `evidence`: you recorded into the folder of an earlier recording. Put the new coverage map into the project knowledge as coverage, as `hint` tells. It replaces the map of the earlier recording. For another file in `evidence`, examine the facts of its revisions against the new recording.
219
235
  - `FAIL` after a cancel on the page: `hint` tells you to ask the user what to do. Do not record a session from steps in place of the session of the user.
220
236
  - Another `FAIL`: `reason` names the step that did not complete. Examples are a `runUntil` step that did not get to its target, and a `type` step with too many keys. Change the step, then run `record` again.
221
237
  - `coverageFrom` is `null` and `executed` is 0: the coverage did not start, so the coverage map is empty. The recording can still replay.
222
238
 
223
239
  With `--play`, a person plays the program after the steps. The steps can start the program, for example a key for an intro.
224
240
 
225
- - The script writes the address of a page to stderr. Give the address to the user.
226
- - The page shows the screen after the steps. The C64 is frozen until the user pushes Enter or clicks Start. Tell the user to read the screen first.
227
- - Tell the user that F9 changes the joystick port.
228
- - The page has the full C64 keyboard and the joystick. F10 changes the arrow keys and space between the joystick and the C64 keys. A gamepad is always the joystick. The key maps are in `references/recording-format.md`.
229
- - End (F12) stops the C64 and freezes the screen. Then the script writes the recording folder. Run the command in the background.
230
- - Cancel (F11) stops the session. The script writes no folder.
241
+ - The script writes the address of a page to stderr. Give the address to the user. Run the command in the background.
242
+ - The page shows the screen after the steps. The C64 is frozen until the user pushes Enter or clicks Start. Tell the user to read the screen first, and that F9 changes the joystick port.
243
+ - The page sends the full C64 keyboard and the joystick, also from a gamepad. It shows its buttons and its key maps.
244
+ - End (F12) stops the C64. Then the script writes the recording folder. Cancel (F11) stops the session, and the script writes no folder.
231
245
 
232
246
  Traps:
233
247
 
@@ -235,19 +249,39 @@ Traps:
235
249
  - Put a `runUntil` step with the checkpoint routine before a `registers` step. A `registers` step that sets the pc during an interrupt stops the program.
236
250
  - A record file has no `raster` target and no `condition`. The script refuses them.
237
251
 
252
+ ### `show <recording>`
253
+
254
+ The script tells what a recording holds. It does not replay the recording. Use it in place of your own read of the files of a recording.
255
+
256
+ `body` holds:
257
+
258
+ - `name`, `program`, `symbols`, `load` and `inputs`: the values of the record file. `checkpoint`, `state` and `pin`: its comparison, if it has one.
259
+ - `frames` and `events`: the length of the session, and the number of events.
260
+ - `inputSites`: each instruction that read input, in the order of its address. Each item has the `site`, the `address` that it read, the number of `reads`, and the number of `changes` of the value. A site with 0 `changes` got the same value at each read.
261
+ - `coverage`: the number of RAM addresses in the coverage map that the session `executed`, `read` and `written`.
262
+ - `evidence`: the test evidence for a finding that the recording shows.
263
+
238
264
  ### `replay <recording>`
239
265
 
240
266
  The script first replays the recording on the reference. The reference must end the session with the recorded state. With `--rebuild`, the script then replays the recording on the rebuild and compares the state at each checkpoint. Without `--rebuild`, it replays only on the reference.
241
267
 
242
268
  `--checkpoint` and `--state` go together. `--pin` needs both of them. `--symbols` needs `--rebuild`. Give at most 16 `--state` and `--pin` items. Without `--checkpoint`, the script uses the comparison of the record file.
243
- A `$` address is an address of the reference. On the rebuild, it moves with the name before it.
269
+ A `$` address is an address of the reference. On the rebuild, it moves with the name before it. Give each state item a name when you can.
244
270
  `--screen` writes the screen of the reference at the end of the session into a PNG file. The screen is the same on each replay. The script writes it only when the reference ends the session with the recorded state.
245
271
 
246
- A rebuild can be a loader with a start screen that RUN starts. If the symbols of the rebuild have `loader_start_screen_wait` and `loader_start_screen_continue`, the script runs the rebuild to the wait. Then it sets the PC to `loader_start_screen_continue`. The cycles before the wait do not count.
247
-
248
- A rebuild can be the loader program of a generated source. Give its symbols. Then the replay counts from the entry of the program, where the loader jumps to. The checkpoints of both sides start at that entry. At the entry, the rebuild gets the raster position, the CIA timers and the interrupt state of the reference. The loader cannot set them as the reference has them in the replay. A runUntil step to an address does not count the code of the loader, or the code that the reference runs before that entry. If another step of the recording runs before the entry, the result is INCONCLUSIVE. Then start the steps of the record file after the entry.
272
+ `body` holds:
249
273
 
250
- `body` holds `result`, `side`, `firstDifference`, `reason` and `files`. The section "Replay" of `references/recording-format.md` gives each field.
274
+ - `result`: `PASS`, `FAIL` or `INCONCLUSIVE`.
275
+ - `side`: `reference` for the check of the reference only, `rebuild` with `--rebuild`.
276
+ - `checkpoint`: the routine of the comparison.
277
+ - `checkpoints` and `compared`: the checkpoints of the reference, and the checkpoints of the rebuild that were the same.
278
+ - `firstDifference`: with a FAIL, the checkpoint (1 is the first), the cycle on each side, and each state item that is different. An item has `address`, and the `reference` and `rebuild` values as hex.
279
+ - `reason`: why the result is FAIL or INCONCLUSIVE.
280
+ - `movedSites`: the number of input sites at a different address in the rebuild.
281
+ - `startScreen`: `skipped` when the rebuild started after its start screen.
282
+ - `idleReads`: the number of input reads of the rebuild that the recording had no value for.
283
+ - `files`: with `--out` and a FAIL, the RAM of each side at the first different checkpoint.
284
+ - `screen`: with `--screen`, the PNG file of the screen of the reference at the end of the session.
251
285
 
252
286
  Do this for each result:
253
287
 
@@ -259,11 +293,12 @@ Do this for each result:
259
293
  - "does not reproduce": the reference does not end the session with the recorded state. Record the session again.
260
294
  - "never came to the checkpoint": the reference did not execute the checkpoint routine in the session. Give another routine.
261
295
  - "is not the program of the recording": the program file changed after the recording. Record the session again.
296
+ - "ran before the program came to its entry": a step of the recording ran in the loader of the rebuild. Make the steps of the record file start after the entry of the program. Then record the session again.
262
297
 
263
298
  Traps:
264
299
 
265
300
  - A run does not have the timing of a recording. The same steps in a run can give a different session, for example a lost fight. To show the screen of a recorded session, use `replay --screen`. Do not do the steps again in a run.
266
- - `idleReads` counts the input reads of the rebuild that the recording had no value for. On the reference, such a read makes the result INCONCLUSIVE. The rebuild can read input where the reference does not, for example in its loader before the start screen. Such reads do not change a PASS of the rebuild.
301
+ - On the reference, an input read with no recorded value makes the result INCONCLUSIVE. The rebuild can read input where the reference does not, for example in its loader before the start screen. `idleReads` counts these reads. They do not change a PASS of the rebuild.
267
302
  - The script refuses a recording of an older version in an old form with `invalid-input`. Record the session again.
268
303
 
269
304
  ---
@@ -314,24 +349,15 @@ Give the checklist to the human tester. Do not put the results of the playtest i
314
349
 
315
350
  Each command prints one JSON envelope on one line on stdout. Notes go to stderr.
316
351
 
317
- On success, the exit code is 0:
318
-
319
- ```json
320
- {"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}
321
- ```
322
-
323
- On failure, the exit code is 2:
324
-
325
- ```json
326
- {"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}
327
- ```
328
-
352
+ - On success, the exit code is 0: `{"ok": true, "command": "<command>", "body": {}, "hint": "...", "nextAction": "..."}`
353
+ - On failure, the exit code is 2: `{"ok": false, "command": "<command>", "code": "<code>", "error": "...", "hint": "...", "nextAction": "..."}`
329
354
  - `body` holds the result. The section of each command gives the fields of its body.
330
355
  - A check gives its verdict in `body.result`: `PASS`, `FAIL` or `INCONCLUSIVE`. The exit code is 0 for each verdict. Thus read `body.result`, not the exit code.
331
- - `error` is one sentence. It tells what is wrong.
332
- - `hint` tells what to do or what to examine. Read it before your next step. Some envelopes have no `hint`.
333
- - `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task. Some envelopes have no `nextAction`.
334
- - `code` does not change between versions. Do the action for the code:
356
+ - `error` is one sentence. It tells what is wrong. `hint` tells what to do or what to examine. Read it before your next step.
357
+ - `nextAction` is a full command line. It runs from any directory. Run it when it agrees with your task.
358
+ - A list has `count`, `listed` and `rest`. `listed` holds at most `--max-listed` items. `rest` tells how to get the other items. A file that the command wrote has `out`, `bytes` and `sha256`.
359
+ - To get only some fields of `body`, give `--fields <path>,<path>`, for example `--fields count,listed.start`. A path through a list gives that field of each item. Do not write code to filter an envelope.
360
+ - To get the command list, run the script with no arguments. To get the subjects and the flags of one command, run `<command> --help`.
335
361
 
336
362
  | `code` | Action |
337
363
  |---|---|
@@ -340,19 +366,7 @@ On failure, the exit code is 2:
340
366
  | `operation-failed` | Give `error` and `hint` to the user. |
341
367
  | Another code | Do as `hint` tells. |
342
368
 
343
- These fields have the same meaning in each body:
344
-
345
- | Field | Meaning |
346
- |---|---|
347
- | `out`, `bytes`, `sha256` | A file that the command wrote: its path, its size and its SHA-256. |
348
- | `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. |
349
-
350
- 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.
351
- To get the subjects and the flags of one command, run `<command> --help`. Then `body.subjects` and `body.options` give them.
352
-
353
- ---
354
-
355
369
  ## Reference
356
370
 
357
- - `references/scenario-format.md`: the scenario file of `test` and the run file of `run`. It gives each step, each observation, the expected values, and the checks before a test or a run.
358
- - `references/recording-format.md`: the record file of `record`, the play page and its key maps, and the files of a recording folder. It also gives the fields of the body of `replay`.
371
+ - `<skill>/references/scenario-format.md`: the scenario file of `test` and the run file of `run`. It gives each step, each observation, the expected values, and the checks before a test or a run.
372
+ - `<skill>/references/recording-format.md`: the record file of `record` and its steps.
@@ -1,6 +1,6 @@
1
1
  # Recording format
2
2
 
3
- This file gives the format of a record file and of a recording folder. For the commands, see the sections ``### `record <record.json>` `` and ``### `replay <recording>` `` of `SKILL.md`.
3
+ This file gives the format of a record file. For the commands, see the sections ``### `record <record.json>` `` and ``### `replay <recording>` `` of `SKILL.md`.
4
4
 
5
5
  ## Record file
6
6
 
@@ -43,7 +43,7 @@ A record file has no `raster` target and no `condition`. `write` and `runUntil`
43
43
 
44
44
  | Step | Effect |
45
45
  |---|---|
46
- | `{ "frames": 300 }` | Run 300 frames (19656 cycles each). |
46
+ | `{ "frames": 300 }` | Run 300 frames. |
47
47
  | `{ "joystick": { "port": 2, "direction": "left", "fire": true } }` | Set a joystick. It stays in this state until the next joystick step. |
48
48
  | `{ "press": { "keys": "RUN\n" } }` | Press the keys of the keyboard matrix. Each tap holds its keys for 3 frames, then releases them for 3 frames. `frames` sets a different number, from 1 to 3000. |
49
49
  | `{ "type": { "mode": "text", "text": "RUN\n" } }` | Put at most 10 keys into the keyboard queue of the KERNAL, after the keys that wait there. |
@@ -68,85 +68,10 @@ To hold keys together in one tap, join them with `+` in braces. For example, `{
68
68
 
69
69
  The keyboard queue of the KERNAL holds 10 keys. If the keys of a `type` step and the keys that wait in the queue do not fit, the session stops. A program that reads the keyboard hardware does not see the keys of a `type` step. Use `press` for that program.
70
70
 
71
- `joystick`, `press` and `frames` steps are input and time. The recording keeps their effect in the reads, so a replay does not do these steps again.
71
+ `joystick`, `press` and `frames` steps are input and time. The recording keeps the input that the program read, so a replay does not do these steps again.
72
72
 
73
- RESTORE starts an NMI and is not a read. The recording keeps each RESTORE of a `press` step as an event of that step. The replay presses RESTORE again at the same read of the program.
73
+ RESTORE starts an NMI and is not an input read. A replay presses each RESTORE of a `press` step again at the same point of the program.
74
74
 
75
- `type`, `write`, `registers` and `runUntil` steps are events. The recording keeps a point in the program for each event. A replay does the event again at the same point:
76
-
77
- - A `runUntil` step to an address: the point is the number of times that the CPU got to that address. This step does not need an input read.
78
- - An event that comes directly after another event runs at once after that event.
79
- - Each other event: the point is the next read at the input site with the most reads. That site is not in ROM. If the program does not read input in 600 frames, the session stops.
75
+ `type`, `write`, `registers` and `runUntil` steps are events. A replay does each event again at the same point of the program. A `runUntil` step to an address needs no input. Another event needs an input read of the program.
80
76
 
81
77
  Some parts of a program read no input, for example an intro or a bonus screen. To do an event in such a part, put a `runUntil` step to an address before the event.
82
-
83
- ## Play
84
-
85
- With `--play`, `record` does the steps, then a person plays. The page on `http://localhost:<port>/` (`--http-port`) shows the screen at 50 frames each second. It has no sound.
86
-
87
- | Button | Key | Effect |
88
- |---|---|---|
89
- | Start | Enter, on the start screen | The C64 runs. Before Start, the page shows the screen after the steps, and the C64 is frozen. The time before Start is not in the recording. |
90
- | End and save | F12 | The C64 stops at the frame on the page, and the screen stays frozen. The script writes the recording folder. |
91
- | Cancel | F11 | The session stops before or during the play. The script writes no folder and gives `recorded: false`. |
92
- | Port | F9 | The joystick goes to the other port. `--joystick` gives the first port. |
93
- | Arrows | F10 | The arrow keys and space change between the joystick and the C64 keys. At the start, they are the joystick. |
94
- | Keys | | The keyboard changes between the symbolic map (the default) and the positional map. |
95
-
96
- The buttons are in one row above the screen.
97
-
98
- | Page input | C64 input |
99
- |---|---|
100
- | Arrow keys and space, when they are the joystick | The joystick: directions and fire. |
101
- | A gamepad | The joystick: the left stick or the cross for directions, button 1 or 2 for fire. |
102
- | Arrow keys and space, when they are C64 keys | CRSR up, down, left and right, and SPACE. |
103
- | Escape, Shift+Escape | RUN/STOP, RUN |
104
- | Page Up | RESTORE |
105
- | Tab, left Alt | CTRL, C= |
106
- | Home, Shift+Home | CLR/HOME, CLR |
107
- | Backspace, Shift+Backspace | INST/DEL, INST |
108
- | F1-F8 | F1-F8 |
109
-
110
- In the symbolic map, a key gives the character on the PC key. a-z give the C64 letters, and A-Z give the letters with SHIFT. The digits and the symbols give the same characters. `£` gives the pound key, `^` gives the up arrow, and the backquote gives the left arrow.
111
-
112
- In the positional map, a key gives the C64 key at the same place on the keyboard. Each SHIFT key is a C64 SHIFT key, also alone. The C64 keys `+ - @ * : ; =` are on the PC keys `- = [ ] ; ' \`. Insert gives the pound key, Delete gives the up arrow, and the backquote gives the left arrow. Use the positional map when the program reads SHIFT alone or a key with SHIFT.
113
-
114
- Ctrl and Cmd are not C64 keys. They keep their function in the browser.
115
-
116
- The page sends input only between Start and End. The input of the page goes into the reads, as the input of the steps does. RESTORE starts an NMI and is not a read. The recording keeps each RESTORE as an event without a step number. The replay presses RESTORE again at the same read of the program.
117
-
118
- ## Recording folder
119
-
120
- `record` writes these files into the `--out` folder:
121
-
122
- | File | Content |
123
- |---|---|
124
- | `recording.json` | The program and its SHA-256, the symbols, and the comparison of the record file. Also the inputs, the events, the input sites, the cycles of the session and the state hash at its end. |
125
- | `reads.txt` | One line `<site> <addr> <from> <value>` for each change of the value at a site. From the read with the index `<from>`, the reads at `<site>` from `<addr>` get `<value>`. One line `end <site> <addr> <count>` for each site gives its number of reads. |
126
- | `coverage.bin` | The coverage map of the session: 65536 bytes, one for each address, in the format of the coverage maps of the emulator. It starts where the key `coverage` of the record file tells. The code before that point has no marks. |
127
-
128
- A site is the address of the instruction that reads. The values are hex. `<from>` and `<count>` are decimal.
129
-
130
- `replay` examines `recording.json` before the replay starts. A recording of an older version can have events or a comparison in an old form. For example, `"at"` is in place of `"address"`, or a `runUntil` step to an address has no count of the CPU at its target. The script refuses such a recording with `invalid-input`, and the message names the event. Record the session again.
131
-
132
- ## Replay
133
-
134
- `replay` replays the recording on the reference program first. The session must end with the recorded cycles and state hash. Else the result is INCONCLUSIVE. With `--rebuild`, `replay` then replays the recording on the rebuild. At each checkpoint, the rebuild first gets the pinned values of the reference. Then the script compares the state. The cycles can be different.
135
-
136
- A recording without names (`symbols` is `none`) takes the names of the project knowledge at the time of the replay.
137
-
138
- For the rebuild, the script finds each name with the names of the rebuild (`--symbols`). A `$` address is an address of the reference. It moves with the name before it in the reference: the script finds the same name in the rebuild and adds the same offset. Code moves with a code label, and data with any name. A site in ROM does not move. Give a state item a name, or the state moves with the code before it.
139
-
140
- The body of the envelope of `replay` has these fields:
141
-
142
- - `result`: PASS, FAIL or INCONCLUSIVE.
143
- - `side`: `reference` for the check of the reference only, `rebuild` with `--rebuild`.
144
- - `checkpoint`: the routine of the comparison.
145
- - `checkpoints` and `compared`: the checkpoints of the reference, and the checkpoints of the rebuild that were the same.
146
- - `firstDifference`: on a FAIL, the checkpoint (1 is the first), the cycle on each side, and each state item that is different. An item has `address`, and the `reference` and `rebuild` values as hex.
147
- - `reason`: why the result is FAIL or INCONCLUSIVE.
148
- - `movedSites`: the number of sites at a different address in the rebuild.
149
- - `startScreen`: `skipped` when the rebuild went past the wait of its start screen.
150
- - `idleReads`: the input reads of the rebuild that the recording had no value for. Such a read is at a site that the recording does not have, or after its end. Each got the fixed value `$FF` (joystick, keyboard, paddles) or `$00`. An input site that the site map did not find shows here.
151
- - `files`: with `--out`, the RAM of each side at the first different checkpoint, `reference-<n>.bin` and `rebuild-<n>.bin`.
152
- - `screen`: with `--screen`, the PNG file of the screen of the reference at the end of the session.
@@ -57,14 +57,12 @@ Before the first step of each side, the script does a hard reset. The CPU stops
57
57
  | `{ "normalize": true }` | Write pages 0 to 3 and `$00`/`$01` from the entry state in the project knowledge. The entry state comes from a capture of the unpacked program. Then both sides have the same zero page, stack and KERNAL work area. |
58
58
  | `{ "observe": "moved", ... }` | Record a checkpoint. |
59
59
 
60
- The `timeoutFrames` of a `runUntil` step is from 1 to 30000. The default is 3000. For a longer wait, put `frames` steps before the `runUntil` step.
60
+ The `timeoutFrames` of a `runUntil` step is from 1 to 30000. The default is 3000. A `runUntil` step that does not get to its target in `timeoutFrames` frames makes the result INCONCLUSIVE. For a longer wait, put `frames` steps before the `runUntil` step.
61
61
 
62
62
  The `port` of a joystick is 1 or 2. The `direction` is `center`, `up`, `down`, `left`, `right`, `up-left`, `up-right`, `down-left` or `down-right`.
63
63
 
64
64
  A `condition` has the `kind` `register`, `memory` or `raster`. A `register` condition has `register` (`a`, `x`, `y` or `sp`), `operator` and `value`. A `memory` condition has `address`, `operator` and `value`. A `raster` condition has `line` and an optional `cycle`.
65
65
 
66
- `timeoutFrames` is from 1 to 30000, and 3000 by default. A `runUntil` that does not get to its target in `timeoutFrames` frames makes the result INCONCLUSIVE.
67
-
68
66
  Each step except `observe` can have `"side": "reference"` or `"side": "rebuild"`. Then only that side does the step. Use it when only one side needs a step, for example a key for the intro of the reference. An `observe` step has no `side`, because it compares both sides.
69
67
 
70
68
  Each side finds a name in its own symbols.
@@ -112,13 +110,11 @@ The run steps have these effects:
112
110
  | `{ "trace": "d011", "points": [{ "kind": "write", "start": "$d011" }], "frames": 100 }` | Record each hit of the points for 100 frames in `d011.json`: the instruction, its registers, and the raster line and cycle. |
113
111
  | `{ "expect": "title", "memory": [{ "address": "$0400", "text": "HELLO" }] }` | Compare memory and registers with the expected values. See the section "Expected values". |
114
112
 
115
- A `trace` step has a name, `points` (1 to 8), `frames` (1 to 3000) and an optional `maxHits` (at most 20000). A point has `kind` (`exec`, `read` or `write`), `start` and an optional `end`. The step writes `<name>.json` with each hit. `results.json` gives the file, the count of hits, the frames and why the trace ended. A trace that a breakpoint, a watchpoint or a JAM ends also ends the run.
116
-
117
- In a run, an `observe` step can have `memory`, `registers`, `vicii` and `sprites`. `registers` and `vicii` are `true` or `false`, not a list. `"registers": true` gives all registers. A scenario takes a list of register names, a run does not. `sprites` is a list of sprite numbers from 0 to 7. In a run, the screen is not a key of `observe`. Write it with a `screen` step, for example `{ "screen": "room3" }`.
113
+ A `trace` step has a name, `points` (1 to 8), `frames` (1 to 3000) and an optional `maxHits` (at most 20000). A point has `kind` (`exec`, `read` or `write`), `start` and an optional `end`. The step writes `<name>.json` with each hit. A trace that a breakpoint, a watchpoint or a JAM ends also ends the run.
118
114
 
119
- In a run, a memory item has `address`, `size` (1 to 65536) and `view`. An item larger than 4096 bytes goes into the file `<observe>-<address>.bin`, without the `$`. `results.json` gives the file name.
115
+ In a run, an `observe` step can have `memory`, `registers`, `vicii` and `sprites`. A memory item has only `address`, `size` (1 to 65536) and `view`. `registers` and `vicii` are `true` or `false`, not a list. `"registers": true` gives all registers. A scenario takes a list of register names, a run does not. `sprites` is a list of sprite numbers from 0 to 7. In a run, the screen is not a key of `observe`. Write it with a `screen` step, for example `{ "screen": "room3" }`.
120
116
 
121
- A name in `save`, `screen`, `coverage`, `observe` and `expect` has 1 to 64 letters, digits, dots, underscores or hyphens. The files go into the `--out` directory, with `results.json`. It has the observations, the expectations, the files and the steps done. If a `runUntil` step did not reach its target, it also tells why the run stopped.
117
+ A name in `save`, `screen`, `coverage`, `observe` and `expect` has 1 to 64 letters, digits, dots, underscores or hyphens. The files go into the `--out` folder.
122
118
 
123
119
  ### Expected values
124
120
 
@@ -150,8 +146,6 @@ A memory item has at most 4096 bytes.
150
146
 
151
147
  `registers` has the fields of a `registers` step: `pc`, `a`, `x`, `y`, `sp` and `flags`. Only `pc` can be a name.
152
148
 
153
- A value that is not equal does not stop the run. The later steps run. `results.json` and the result have `expectations`. For each step, it gives `pass` and the count of values that are not equal. It also lists at most 16 of them, with the expected and the actual value. `failedExpectations` names each step that did not pass. The result is FAIL when an expectation did not pass.
154
-
155
149
  Example: visit two rooms from the same start.
156
150
 
157
151
  ```json
@@ -182,6 +176,4 @@ The script also examines each file before it does a step: the program and the sy
182
176
 
183
177
  A run also examines each name of its steps before it does a step. An unknown name stops the run with `invalid-input`, and the message names the step. In a scenario, a side that does not have a name gives INCONCLUSIVE, and `reason` names the step.
184
178
 
185
- A step in the form of version 2.0 stops the script with `invalid-input`. The message names the old field and gives the step to write. For example, the script refuses `{ "runUntil": { "at": "main_loop" }, "timeoutFrames": 300 }` and gives `{"runUntil": {"target": {"kind": "address", "address": "main_loop"}, "timeoutFrames": 300}}`. A memory item with `at` gets the same refusal: write `address`.
186
-
187
179
  In a run, two steps must not write the same file name. The script refuses such a run before it starts. Names that differ only in upper and lower case are the same name.
@@ -77,19 +77,27 @@ canvas{image-rendering:pixelated;width:min(784px,100%);aspect-ratio:392/272;back
77
77
  button{font:inherit;font-size:12px;padding:3px 8px}
78
78
  .row{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:center}
79
79
  .gap{width:12px}
80
- table{border-collapse:collapse;font-size:13px}td{padding:2px 10px;border-top:1px solid #333}
80
+ table{border-collapse:collapse;font-size:13px;max-width:784px}th{text-align:left;padding:2px 10px}td{padding:2px 10px;border-top:1px solid #333;vertical-align:top}
81
81
  </style></head><body>
82
82
  <div class="row"><button id="start" disabled>Start (Enter)</button><button id="end" disabled>End and save (F12)</button><button id="cancel" disabled>Cancel (F11)</button><span class="gap"></span><button id="port">Port 2 (F9)</button><button id="arrows">Arrows: joystick (F10)</button><button id="map">Keys: symbolic</button></div>
83
83
  <canvas id="screen" width="392" height="272"></canvas>
84
84
  <div id="state">connecting</div>
85
85
  <table>
86
- <tr><td>Start, End, Cancel</td><td>Enter (on the start screen), F12, F11</td></tr>
87
- <tr><td>Joystick</td><td>arrow keys and space (when F10 sets joystick), or a gamepad</td></tr>
88
- <tr><td>RUN/STOP, RESTORE</td><td>Esc, Page Up</td></tr>
89
- <tr><td>CTRL, C=</td><td>Tab, left Alt</td></tr>
90
- <tr><td>CLR/HOME, INST/DEL</td><td>Home, Backspace</td></tr>
91
- <tr><td>Symbolic map</td><td>the characters on the PC keys; £, ^ (up arrow) and the backquote (left arrow)</td></tr>
92
- <tr><td>Positional map</td><td>the C64 keys at the places of the PC keys; each SHIFT alone; Insert £, Delete up arrow, the backquote left arrow</td></tr>
86
+ <tr><th>Page</th><th>C64</th></tr>
87
+ <tr><td>Start, End and save, Cancel</td><td>Enter (on the start screen), F12, F11. The time before Start is not in the recording. End freezes the screen and the script saves the recording. Cancel saves none.</td></tr>
88
+ <tr><td>Port, Arrows, Keys</td><td>F9 changes the joystick port. F10 changes the arrow keys and space between the joystick (at the start) and the C64 keys. Keys changes between the symbolic map (the default) and the positional map.</td></tr>
89
+ <tr><td>Arrow keys and space as the joystick</td><td>the joystick: directions and fire</td></tr>
90
+ <tr><td>A gamepad</td><td>the joystick: the left stick or the cross for directions, button 1 or 2 for fire</td></tr>
91
+ <tr><td>Arrow keys and space as C64 keys</td><td>CRSR up, down, left and right, and SPACE</td></tr>
92
+ <tr><td>Escape, Shift+Escape</td><td>RUN/STOP, RUN</td></tr>
93
+ <tr><td>Page Up</td><td>RESTORE</td></tr>
94
+ <tr><td>Tab, left Alt</td><td>CTRL, C=</td></tr>
95
+ <tr><td>Home, Shift+Home</td><td>CLR/HOME, CLR</td></tr>
96
+ <tr><td>Backspace, Shift+Backspace</td><td>INST/DEL, INST</td></tr>
97
+ <tr><td>F1-F8</td><td>F1-F8</td></tr>
98
+ <tr><td>Symbolic map</td><td>the character on the PC key: a-z are the C64 letters, A-Z the letters with SHIFT, and the digits and the symbols the same characters. £ is the pound key, ^ the up arrow, and the backquote the left arrow.</td></tr>
99
+ <tr><td>Positional map</td><td>the C64 key at the place of the PC key. Each SHIFT key is a C64 SHIFT key, also alone. The C64 keys + - @ * : ; = are on the PC keys - = [ ] ; ' \. Insert is the pound key, Delete the up arrow, and the backquote the left arrow. Use it when the program reads SHIFT alone or a key with SHIFT.</td></tr>
100
+ <tr><td>Ctrl, Cmd</td><td>no C64 key: they keep their function in the browser</td></tr>
93
101
  </table>
94
102
  <script>
95
103
  const KEYS = __KEYS__;
@@ -12,14 +12,16 @@ import { createHash } from "node:crypto";
12
12
  import { readFileSync, writeFileSync } from "node:fs";
13
13
 
14
14
  import { isRefusal, Refusal } from "#src/errors.ts";
15
- import { c64AddressOf, formatC64Address, parseC64Address } from "#src/c64.ts";
15
+ import { c64AddressOf, COVERAGE, formatC64Address, parseC64Address } from "#src/c64.ts";
16
16
  import { keyTaps, type KeyTap } from "#src/c64-keys.ts";
17
17
  import { READY_FRAMES } from "#src/host-client/entry-state.ts";
18
18
  import { ACTION_STEP_KINDS, checkActionStep, isInteger, isObject, keyboardBytes, renamedField, stepKind, type ActionStep, type Location } from "#src/host-client/steps.ts";
19
19
  import { readProjectFile, type Written } from "#src/host-client/transfer.ts";
20
- import { LOADER_JUMP, START_SCREEN_CONTINUE, START_SCREEN_WAIT } from "#src/knowledge/start-screen.ts";
20
+ import { RECORDING_FILES } from "#src/knowledge/recording-files.ts";
21
+ import { LOADER_JUMP, startScreenLabels } from "#src/knowledge/start-screen.ts";
21
22
  import { PAL_FRAME_CYCLES, type C64RunSession, type CoreStatus } from "#src/native/c64run.ts";
22
23
  import type { Workspace } from "#src/native/staging.ts";
24
+ import { listed } from "#src/script.ts";
23
25
  import { namesOf, type Outcome } from "./scenario.ts";
24
26
 
25
27
  export const RECORDING_FORMAT = 1;
@@ -134,7 +136,7 @@ export interface Recording {
134
136
  hash: string;
135
137
  }
136
138
 
137
- export const RECORDING_FILES = { recording: "recording.json", reads: "reads.txt", coverage: "coverage.bin" } as const;
139
+ export { RECORDING_FILES };
138
140
 
139
141
  /** Steps that are input or time: the replay gives the program the reads that they caused, and does not do them again. */
140
142
  const INPUT_KINDS = new Set(["joystick", "press", "frames"]);
@@ -381,12 +383,11 @@ export interface EntryPoint {
381
383
  * undefined when the rebuild has no start screen.
382
384
  */
383
385
  async function passStartScreen(core: C64RunSession, own: Map<string, number>, limit: number): Promise<number | string | undefined> {
384
- const wait = own.get(START_SCREEN_WAIT);
385
- const resume = own.get(START_SCREEN_CONTINUE);
386
- if (wait === undefined || resume === undefined) return undefined;
387
- const reached = await core.status(`run-pc ${hex(wait)} ${limit}`);
388
- if (reached.word !== "reached") return `the rebuild did not come to the wait of its start screen at ${formatC64Address(wait)}`;
389
- await core.status(`goto ${hex(resume)}`);
386
+ const labels = startScreenLabels(own);
387
+ if (labels === undefined) return undefined;
388
+ const reached = await core.status(`run-pc ${hex(labels.wait)} ${limit}`);
389
+ if (reached.word !== "reached") return `the rebuild did not come to the wait of its start screen at ${formatC64Address(labels.wait)}`;
390
+ await core.status(`goto ${hex(labels.continue)}`);
390
391
  return reached.tick;
391
392
  }
392
393
 
@@ -897,3 +898,67 @@ export interface ReplayResult {
897
898
  /** The screen of the reference at the end of the session (--screen). */
898
899
  screen?: Written;
899
900
  }
901
+
902
+ /** An input site of a recording: the instruction that reads, the address that it reads, its reads, and how often the value changed. */
903
+ export interface InputSite {
904
+ site: Location;
905
+ address: Location;
906
+ reads: number;
907
+ changes: number;
908
+ }
909
+
910
+ /** What `show` gives of a recording folder: the program, the session, the input sites and the coverage counts. */
911
+ export interface RecordingSummary {
912
+ recording: string;
913
+ name: string;
914
+ program: string;
915
+ symbols: string;
916
+ load: boolean;
917
+ checkpoint?: Location;
918
+ state?: StateItem[];
919
+ pin?: StateItem[];
920
+ inputs: string[];
921
+ frames: number;
922
+ events: number;
923
+ inputSites: { count: number; listed: InputSite[]; rest?: string };
924
+ /** The RAM addresses that the session executed, read and wrote, from the start of the coverage map. */
925
+ coverage: { executed: number; read: number; written: number };
926
+ /** The test evidence of a finding that the recording shows: the --evidence value of a knowledge write. */
927
+ evidence: string;
928
+ }
929
+
930
+ /**
931
+ * What a recording folder holds, without a replay: recording.json, the value
932
+ * changes of each site in reads.txt (each line `<site> <addr> <from> <value>`
933
+ * after the first read is a change), and the counts of coverage.bin.
934
+ */
935
+ export function showRecording(folder: string, max: number): RecordingSummary {
936
+ const recording = readRecording(folder);
937
+ const changes = new Map<string, number>();
938
+ for (const line of readProjectFile(`${folder}/${RECORDING_FILES.reads}`).bytes.toString("utf8").split("\n")) {
939
+ const [site, addr, from] = line.split(" ");
940
+ if (site === undefined || site === "end" || addr === undefined || from === undefined || Number(from) === 0) continue;
941
+ const key = `${site} ${addr}`;
942
+ changes.set(key, (changes.get(key) ?? 0) + 1);
943
+ }
944
+ const sites = recording.sites
945
+ .map((site): InputSite => ({ site: site.site, address: site.addr, reads: site.reads, changes: changes.get(`${hex(parseC64Address(site.site))} ${hex(parseC64Address(site.addr))}`) ?? 0 }))
946
+ .sort((a, b) => parseC64Address(a.site) - parseC64Address(b.site) || parseC64Address(a.address) - parseC64Address(b.address));
947
+ const map = readProjectFile(`${folder}/${RECORDING_FILES.coverage}`).bytes;
948
+ const count = (bit: number) => map.reduce((total, byte) => total + ((byte & bit) === 0 ? 0 : 1), 0);
949
+ const compare = recording.compare;
950
+ return {
951
+ recording: folder,
952
+ name: recording.name,
953
+ program: recording.program,
954
+ symbols: recording.symbols,
955
+ load: recording.load,
956
+ ...(compare === undefined ? {} : { checkpoint: compare.checkpoint, state: compare.state, ...(compare.pin === undefined ? {} : { pin: compare.pin }) }),
957
+ inputs: recording.inputs,
958
+ frames: Math.round(recording.ticks / PAL_FRAME_CYCLES),
959
+ events: recording.events.length,
960
+ inputSites: listed(sites, max),
961
+ coverage: { executed: count(COVERAGE.ramExecute), read: count(COVERAGE.ramRead), written: count(COVERAGE.ramWrite) },
962
+ evidence: `test:${folder}/${RECORDING_FILES.recording}`,
963
+ };
964
+ }
@@ -78,6 +78,10 @@ export async function replay(values: ReplayOptions): Promise<ReplayResult> {
78
78
  const side = (subject: ReplaySubject, options: Parameters<typeof replaySide>[5]) => replaySide(core, recording, folder, subject, workspace, options);
79
79
  const rebuildSymbols = values.symbols ?? referenceSymbols;
80
80
  // A rebuild with a generated loader starts the program where its loader jumps to. The reference comes to that entry by the same name.
81
+ // The checkpoints of both sides count from that entry, and at the entry the rebuild gets the raster position, the CIA timers and
82
+ // the interrupt state of the reference, which the loader cannot set as the reference has them. A runUntil to an address counts
83
+ // neither the code of the loader nor the code of the reference before the entry; another event before the entry has no point in
84
+ // the rebuild, and the result is INCONCLUSIVE.
81
85
  let loader: { entry: number; reference: number } | undefined;
82
86
  if (values.rebuild !== undefined && !recording.load && namesOf(rebuildSymbols).has(LOADER_JUMP)) {
83
87
  const entry = await loaderEntry(core, recording, { side: "rebuild", program: values.rebuild, symbols: rebuildSymbols });