@henols/c64-re-tools 2.6.0 → 2.7.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 +4 -4
- package/skills/c64-basic/SKILL.md +1 -1
- package/skills/c64-development/SKILL.md +5 -5
- package/skills/c64-disk/SKILL.md +13 -13
- package/skills/c64-docs/SKILL.md +22 -9
- package/skills/c64-docs/references/page-types.md +11 -11
- package/skills/c64-docs/references/style.md +21 -0
- package/skills/c64-docs/scripts/docs.ts +64 -17
- package/skills/c64-docs/scripts/lib/links.ts +1 -1
- package/skills/c64-knowledge/SKILL.md +7 -7
- package/skills/c64-knowledge/scripts/knowledge.ts +1 -1
- package/skills/c64-memory-map/SKILL.md +1 -1
- package/skills/c64-packer/SKILL.md +1 -1
- package/skills/c64-provenance/SKILL.md +5 -4
- package/skills/c64-provenance/scripts/lib/compare.ts +1 -1
- package/skills/c64-reverse-engineering/SKILL.md +20 -11
- package/skills/c64-source/SKILL.md +8 -8
- package/skills/c64-source/scripts/lib/export.ts +7 -6
- package/skills/c64-source/scripts/lib/source.ts +3 -3
- package/skills/c64-source/scripts/source.ts +17 -17
- package/skills/c64-static-analysis/SKILL.md +1 -1
- package/skills/c64-testing/SKILL.md +25 -24
- package/skills/c64-testing/references/recording-format.md +7 -7
- package/skills/c64-testing/references/scenario-format.md +5 -5
- package/skills/c64-testing/scripts/lib/recording.ts +38 -38
- package/skills/c64-testing/scripts/lib/replay.ts +26 -26
- package/skills/c64-testing/scripts/lib/scenario.ts +28 -28
- package/skills/c64-testing/scripts/testing.ts +14 -14
- package/skills/c64-unpacker/SKILL.md +12 -12
- package/src/knowledge/separate.ts +2 -2
- package/src/knowledge/write.ts +1 -1
- package/src/project.ts +1 -1
- package/src/script.ts +1 -1
- package/tools/c64run.c +1 -1
|
@@ -891,7 +891,7 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
891
891
|
{
|
|
892
892
|
name: "release",
|
|
893
893
|
summary: "Records a release of the program from its PRG or the image.json of its capture: the knowledge keeps the bytes of the release. The base release is the one whose bytes are the program of the knowledge.",
|
|
894
|
-
subjects: [{ name: "<label>", help: "the release label, for example
|
|
894
|
+
subjects: [{ name: "<label>", help: "the release label, for example FIRESTAR or V2" }],
|
|
895
895
|
options: {
|
|
896
896
|
file: { kind: "path", value: "<file>", help: "the PRG or image.json of the release. After the write, the knowledge does not need the file", required: true },
|
|
897
897
|
base: { kind: "flag", help: "this release is the program of the knowledge: its segments and bytes must be the same" },
|
|
@@ -43,7 +43,7 @@ To get the command list, run the script with no arguments.
|
|
|
43
43
|
- Give each path relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
44
44
|
- If the working directory is not in a project, give `--project <folder>` to each command. If the working directory has projects below it, the script refuses and lists them.
|
|
45
45
|
- In a group folder, each version of a program is a project. The script refuses the group folder and each folder in it that is not a project. Give `--project` with a project of the group, for example `--project v1`.
|
|
46
|
-
- A path that a command only reads can go into another project of the group, for example `../v1/
|
|
46
|
+
- A path that a command only reads can go into another project of the group, for example `../v1/releases/game.prg`. The command writes only in its own project.
|
|
47
47
|
- An address is `$` and 1 to 4 hex digits, for example `'$c000'` or `'$fb'`, or a name. A name is a symbol, else an analyzer name that only one analyzer gives. Put an address in single quotes in a shell.
|
|
48
48
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
49
49
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
@@ -42,7 +42,7 @@ To get the command list, run the script with no arguments.
|
|
|
42
42
|
- Give each path relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
43
43
|
- If the working directory is not in a project, give `--project <folder>` to each command. If the working directory has projects below it, the script refuses and lists them.
|
|
44
44
|
- In a group folder, each version of a program is a project. The script refuses the group folder and each folder in it that is not a project. Give `--project` with a project of the group, for example `--project v1`.
|
|
45
|
-
- A path that a command only reads can go into another project of the group, for example `../v1/
|
|
45
|
+
- A path that a command only reads can go into another project of the group, for example `../v1/releases/game.prg`. The command writes only in its own project.
|
|
46
46
|
- An address is `$` and 1 to 4 hex digits, for example `'$c000'` or `'$fb'`, or a name. A name is a symbol, else an analyzer name that only one analyzer gives. Put an address in single quotes in a shell.
|
|
47
47
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
48
48
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-provenance
|
|
3
|
-
description: Compares two or more releases of a C64 program byte by byte and tells which releases agree at each difference. It can run each release and tell how the program uses each difference. It gives evidence for each range of the program in the project knowledge. It finds the leftovers in the program, for example texts, assembler source, BASIC lines, unused bytes, copies and dead code. It keeps a library of routines that several programs share, and finds these routines in a program. Use it to separate the
|
|
3
|
+
description: Compares two or more releases of a C64 program byte by byte and tells which releases agree at each difference. It can run each release and tell how the program uses each difference. It gives evidence for each range of the program in the project knowledge. It finds the leftovers in the program, for example texts, assembler source, BASIC lines, unused bytes, copies and dead code. It keeps a library of routines that several programs share, and finds these routines in a program. Use it to separate the program from the changes of a crack or of a release. The bytes that the releases share do not prove the bytes of the commercial original. Use it to find the history of a program in its leftovers. Use it to find known routines, for example a music driver, in a program. It does not disassemble or analyze the code, and it does not change the project knowledge.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# C64 provenance
|
|
@@ -59,7 +59,7 @@ To get the command list, run the script with no arguments.
|
|
|
59
59
|
- Give each path relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
60
60
|
- If the working directory is not in a project, give `--project <folder>` to each command. If the working directory has projects below it, the script refuses and lists them.
|
|
61
61
|
- In a group folder, each version of a program is a project. The script refuses the group folder and each folder in it that is not a project. Give `--project` with a project of the group, for example `--project v1`.
|
|
62
|
-
- A path that a command only reads can go into another project of the group, for example `../v1/
|
|
62
|
+
- A path that a command only reads can go into another project of the group, for example `../v1/releases/game.prg`. The command writes only in its own project.
|
|
63
63
|
- An address is `$` and 1 to 4 hex digits, for example `'$c000'` or `'$fb'`, or a name. A name is a symbol, else an analyzer name that only one analyzer gives. Put an address in single quotes in a shell.
|
|
64
64
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
65
65
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
@@ -303,9 +303,9 @@ Traps:
|
|
|
303
303
|
3. Read `differences`.
|
|
304
304
|
4. To find how the program uses the differences, run `compare` again with `--frames`. Give the frames and the steps that get the program to the part that you examine. Read `runtime` of each difference.
|
|
305
305
|
5. Examine each important difference. Disassemble or analyze the bytes of each release. Find what the change does, for example a trainer, a removed copy protection, or a changed text.
|
|
306
|
-
6. Decide which bytes are
|
|
306
|
+
6. Decide which bytes of each difference are the program, and which bytes are a change of a crack or of a release. Steps 7 and 8 use this decision. Use more than the byte comparison: the code, the text, and the history of the releases.
|
|
307
307
|
- Do not call releases independent when you do not know their relation. Two cracks can come from the same source.
|
|
308
|
-
- Do not call a byte original only because one release has it. A majority of releases is also not proof.
|
|
308
|
+
- Do not call a byte a byte of the commercial original only because one release has it. A majority of releases is also not proof.
|
|
309
309
|
7. Record each release in the project knowledge. The base release is the program in the project knowledge.
|
|
310
310
|
8. Record each difference in the project knowledge as a switch and a patch. Select the kind of the switch:
|
|
311
311
|
- `protection`: a copy protection, or the code that a crack changed to remove it.
|
|
@@ -324,6 +324,7 @@ Traps:
|
|
|
324
324
|
4. Run `leftovers`. When you have two or more releases, also run `compare`.
|
|
325
325
|
5. Read `text` first: names, dates, greetings and credits. Then read `copies`, `residue`, `basic` and `deadCode`.
|
|
326
326
|
6. Examine each important finding. Disassemble or analyze its bytes, or examine them in the emulator.
|
|
327
|
+
- Old code or old source text is evidence of the development. It does not prove the computer of the authors, the order of their work, or the path of a copy through the crackers.
|
|
327
328
|
7. Record each finding that you proved in the project knowledge. Do not record the full list of leftovers.
|
|
328
329
|
- Do not remove a leftover from the program. A rebuild keeps it. Only the data of a cracktro goes out: leave it out of the capture of the program.
|
|
329
330
|
- Classify a PETSCII text that you proved as a `petscii` region, and a screen code text as a `screen` region. Classify other text as `bytes`.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// covers the addresses where every release has bytes, and reports where the
|
|
5
5
|
// releases differ and which releases agree there. For two releases with
|
|
6
6
|
// moved code, align maps the bytes of one to the other in blocks of equal
|
|
7
|
-
// bytes. It never decides which bytes
|
|
7
|
+
// bytes. It never decides which bytes the publisher shipped: that needs evidence
|
|
8
8
|
// beyond one comparison.
|
|
9
9
|
|
|
10
10
|
import { type AddressRange, formatC64Address } from "#src/c64.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-reverse-engineering
|
|
3
|
-
description: Reverse engineers a C64 program or a part of it, from an unknown disk image or file to documented understanding or a rebuilt program. It selects the next unknown to examine and the task that examines it. Use it when the user asks what a program does, for example "what does this game do", "find the main loop" or "understand $2100". Use it to rebuild a program from
|
|
3
|
+
description: Reverse engineers a C64 program or a part of it, from an unknown disk image or file to documented understanding or a rebuilt program. It selects the next unknown to examine and the task that examines it. Use it when the user asks what a program does, for example "what does this game do", "find the main loop" or "understand $2100". Use it to rebuild a program from a named reference file or capture, for example "rebuild this program". It does not do the specialist work of each task itself, and it does not add a feature to a program.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# C64 reverse engineering
|
|
@@ -22,6 +22,15 @@ Do the specialist work of each task as that task tells. Do not do it in another
|
|
|
22
22
|
- reverse engineer and rebuild the whole program
|
|
23
23
|
- The current project knowledge.
|
|
24
24
|
|
|
25
|
+
## Terms
|
|
26
|
+
|
|
27
|
+
- **Reference file**: the program file or the capture that you examined. A test compares the rebuild with it. It can be a crack, a snapshot, a memory dump, a disk image or a commercial release.
|
|
28
|
+
- **Base release**: the release whose bytes are the program of the project knowledge. Its label and its folder do not tell where the bytes came from.
|
|
29
|
+
- **Commercial original**: the release that the publisher sold. You can use this term also when nobody examined that release.
|
|
30
|
+
- **Authenticated original**: a commercial original with recorded evidence that it is genuine, for example the disk of the publisher.
|
|
31
|
+
- 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.
|
|
32
|
+
- Bytes that several related copies share do not prove the bytes of the commercial original.
|
|
33
|
+
|
|
25
34
|
## Project rules
|
|
26
35
|
|
|
27
36
|
- One repository can hold several programs, with one project folder for each program. Work on one project at a time.
|
|
@@ -73,7 +82,7 @@ Select the path for the scope:
|
|
|
73
82
|
| A routine that another program of the workspace has, for example a music driver | Match the program against the routine library of the workspace. |
|
|
74
83
|
| Source code from the knowledge | Generate the source from the project knowledge. |
|
|
75
84
|
| Source code to build | Assemble the source. |
|
|
76
|
-
| Proof that a rebuild behaves as the
|
|
85
|
+
| Proof that a rebuild behaves as the reference file | Test the rebuild against the reference file. |
|
|
77
86
|
|
|
78
87
|
4. Interpret the result. Keep observed facts apart from your conclusions.
|
|
79
88
|
5. Record each conclusion that the evidence supports in the project knowledge: names of routines and variables, data classifications, comments.
|
|
@@ -85,22 +94,22 @@ Do the stages in this sequence. Go to the next stage only when its exit check is
|
|
|
85
94
|
|
|
86
95
|
| Stage | Work | Exit check |
|
|
87
96
|
|---|---|---|
|
|
88
|
-
| 1. Acceptance | Ask the user for the criteria of the rebuild. Offer
|
|
89
|
-
| 2. Get | List the disk image. Extract the start file into `
|
|
97
|
+
| 1. Acceptance | Ask the user for the criteria of the rebuild. Offer a build of the base release that is identical to its bytes in the project knowledge. Also offer a passed replay of each recording on the default build. Also offer test scenarios and a list of the code that no run executed. Also offer documentation of the flows, tables, formats and graphics. | The user gave the criteria. |
|
|
98
|
+
| 2. Get | List the disk image. Extract the start file into `releases/`. | The start file is in the project. |
|
|
90
99
|
| 3. Start | Find the SYS address of the BASIC start. | You have the entry address. |
|
|
91
100
|
| 4. Unpack | Examine the program for a packer. Trace it and find its stages. Capture a packed program into `.c64-re-tools/local/`. When a segment is the data of a cracktro and the program does not read it, capture again and exclude that range. Put the capture, or the PRG of a program without a packer, into the project knowledge. | The program in the project knowledge has the segments and the entry. |
|
|
92
101
|
| 5. Run | First, record. Ask the user to play each part that the scope names, in a recording session. Tell the user which parts. Record a part yourself only when the sessions of the user do not have it. Put the recordings in `tests/recordings/`. Then run the parts that a recording cannot have, in the emulator or as test runs. Write a coverage map for each part into `.c64-re-tools/local/`. Add the maps and the `coverage.bin` of each recording to the project knowledge. | The program in the project knowledge has a coverage map for each part that the scope names. |
|
|
93
102
|
| 6. Analyze | Analyze the program statically. The analysis reads the program and the coverage from the project knowledge. | No coverage conflict is open. |
|
|
94
103
|
| 7. Name | If the workspace has a routine library, match the program against it. Write the names of the matches to the project knowledge. Then name each routine in the scope and give it a comment. Find the platform addresses in the memory map of the C64. Record the modules. Put the modules of one part of the program in one folder, for example `music/`, `irq/` or `graphics/`. When the scope has hundreds of routines, ask the user which routines to name. The source gives the other routines an `l_xxxx` label. | Each routine that the user selected has a name and a comment. |
|
|
95
|
-
| 8. Releases and switches | Record the
|
|
104
|
+
| 8. Releases and switches | Record the examined reference file, or its capture, as the base release in the project knowledge. The project knowledge keeps the bytes of each release. Record each other release. Compare the releases. Find the leftovers. Record a switch for each copy protection, trainer, cheat, crack change and correction. Record a patch for each range of a switch. Record each leftover as a region with a comment. | The project knowledge lists each switch. Each difference between the releases is in a patch, or the answer gives it as an exception. |
|
|
96
105
|
| 9. Generate | Generate the source from the project knowledge into `src`. For an unpacked program, also generate the loader. | The result of the generation is PASS. A release whose code is at other addresses is a version with a project of its own, or an exception in the answer. See "Versions of one program". |
|
|
97
|
-
| 10. Build and test | Build the base release into `build/`, and compare it with the
|
|
98
|
-
| 11. Document | When the criteria ask for documentation, generate it into `README.md` and `docs/`. For versions in a group folder, also write the shared pages of the group folder. Then link the pages. | The link check of the documentation gives PASS. |
|
|
106
|
+
| 10. Build and test | Build the base release into `build/`, and compare it with the base release in the project knowledge. The compare includes each segment of the base release. Build the default build. For a generated source with a loader, the default build is `build/clean_loader.prg`. Else it is `build/clean.prg`. Replay each recording on the default build. For each replay, give the checkpoint routine, the state and the random state with the names of stage 7. Then do only the tests that the next paragraph gives. | The criteria of stage 1 are true. |
|
|
107
|
+
| 11. Document | When the criteria ask for documentation, generate it into `README.md` and `docs/`. For versions in a group folder, also write the shared pages of the group folder. Write the reference files and the limits of the evidence in the first paragraph. Then link the pages. | The link check of the documentation gives PASS. Each claim stays in the limits of its evidence. |
|
|
99
108
|
| 12. Hand over | Find each file that you made outside `.c64-re-tools/local/` and that is not a deliverable. Move it into `.c64-re-tools/local/`. Then give the answer (below). | Each file that you made outside `.c64-re-tools/local/` is a deliverable. |
|
|
100
109
|
|
|
101
110
|
In stage 5, make the recordings before you change the program. A recording needs no names, and its coverage gives the analysis of stage 6 more code. If you cannot get to a part of the program, ask the user how to get to it. Do stages 7 to 9 again until the source is clear. Each generation writes the source again.
|
|
102
111
|
|
|
103
|
-
In stage 10, a
|
|
112
|
+
In stage 10, a build that is identical to the base release proves the source. It proves only the bytes of the base release. Do not test the base release more. The capture of stage 4 can leave out ranges, for example the data of a cracktro. Give each such range in the answer. The default build is different from the base release only in its patches, its leftovers and its loader. The replays on the default build test these differences:
|
|
104
113
|
|
|
105
114
|
- Replay only the default build: `build/clean_loader.prg` for a source with a loader, else `build/clean.prg`. Do not replay a release build or a build with a switch that is not at its default.
|
|
106
115
|
- Write a test scenario only for a test that a replay cannot do. Examples are a program that loads more files from a disk, and a criterion of the user.
|
|
@@ -111,7 +120,7 @@ After stage 7, save each routine that other programs can have to the routine lib
|
|
|
111
120
|
### Deliverables of a full rebuild
|
|
112
121
|
|
|
113
122
|
- `.c64-re-tools/knowledge/` with the program, its entry state, the coverage, the names, the regions, the comments, the modules, the releases, the switches and the patches
|
|
114
|
-
- the files of the program in `
|
|
123
|
+
- the files of the program in `releases/`, as the user gave them
|
|
115
124
|
- the generated source
|
|
116
125
|
- the built program and the loader
|
|
117
126
|
- the test scenarios, if you wrote them
|
|
@@ -138,7 +147,7 @@ Keep observed facts apart from your conclusions.
|
|
|
138
147
|
If the project has no layout, use this one. No script checks it. Each script takes the paths that you give.
|
|
139
148
|
|
|
140
149
|
```
|
|
141
|
-
|
|
150
|
+
releases/ the disk image or the program as you got it
|
|
142
151
|
src/ the generated source
|
|
143
152
|
build/ the built programs. Do not commit them: each build writes them again.
|
|
144
153
|
tests/ the test scenarios, and the recordings in tests/recordings/
|
|
@@ -174,7 +183,7 @@ Some releases of a program have a different layout. Their code is at different a
|
|
|
174
183
|
4. Keep the releases with the same layout in one version. Record them as releases with switches. For example, `v2` holds a base release and a second release from a different crack.
|
|
175
184
|
5. Save the routines of `v1` to the routine library in `<game>/library/`. Give `--library ../library`, because `--library` is relative to the project folder. In stage 7 of `v2`, match the program against that library. Then `v2` gets the names of `v1` for the same routines.
|
|
176
185
|
6. Use the same folders in each version, for example `src` and `docs/reference`.
|
|
177
|
-
7. From the group folder, give `--project v1` or `--project v2` to each script. A script can read a file of another version, for example `../v1/
|
|
186
|
+
7. From the group folder, give `--project v1` or `--project v2` to each script. A script can read a file of another version, for example `../v1/releases/<file>`. Use this to compare the releases of two versions. Record each release only in the project of its version.
|
|
178
187
|
8. Write the facts that the versions share one time, in the pages of the group folder. The pages of each version tell only how that version works.
|
|
179
188
|
|
|
180
189
|
## Knowledge
|
|
@@ -51,7 +51,7 @@ To get the command list, run the script with no arguments.
|
|
|
51
51
|
- Give each path relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
52
52
|
- If the working directory is not in a project, give `--project <folder>` to each command. If the working directory has projects below it, the script refuses and lists them.
|
|
53
53
|
- In a group folder, each version of a program is a project. The script refuses the group folder and each folder in it that is not a project. Give `--project` with a project of the group, for example `--project v1`.
|
|
54
|
-
- A path that a command only reads can go into another project of the group, for example `../v1/
|
|
54
|
+
- A path that a command only reads can go into another project of the group, for example `../v1/releases/game.prg`. The command writes only in its own project.
|
|
55
55
|
- An address is `$` and 1 to 4 hex digits, for example `'$c000'` or `'$fb'`, or a name. A name is a symbol, else an analyzer name that only one analyzer gives. Put an address in single quotes in a shell.
|
|
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"`.
|
|
@@ -192,7 +192,7 @@ Do these actions for the findings:
|
|
|
192
192
|
- `; not executed $xxxx-$yyyy` starts code that no run of the coverage executed. The range is the same as in `not_executed.json`.
|
|
193
193
|
- `+inc16 ptr` is a use of a macro of the knowledge. The comments inside a use go to its side comment.
|
|
194
194
|
- `!zone patch_PROTECTION_100e` starts a patch. The condition is the switch state that the program does not have. It is `!if TRAINER` when the base release has the switch off. It is `!if PROTECTION = 0` when the base release has it on.
|
|
195
|
-
- A patch block has the code of the patch and NOP to the end of the range. `else` has the
|
|
195
|
+
- A patch block has the code of the patch and NOP to the end of the range. `else` has the code of the base release. The labels inside the range come before the zone as `name = * + n`.
|
|
196
196
|
- Alternatives are patches of two or more switches at one range. They follow as `} else { !if FIX_B {`. A line before them stops the build with `!error` when two of them are in.
|
|
197
197
|
|
|
198
198
|
#### The leftovers
|
|
@@ -242,7 +242,7 @@ The script writes a macro use only when the use gives the bytes of the program.
|
|
|
242
242
|
Build the program from the source in these ways:
|
|
243
243
|
|
|
244
244
|
- The build of `config.asm`: no option. With the defaults, this is the default build, without the leftovers.
|
|
245
|
-
- A release: the build option `--release
|
|
245
|
+
- A release: the build option `--release FIRESTAR`.
|
|
246
246
|
- One switch: set its value in `config.asm`, for example `TRAINER = 1`. Do not define a switch on the command line of the build. ACME stops with `Symbol already defined`, because `config.asm` also sets the switch.
|
|
247
247
|
|
|
248
248
|
#### The loader
|
|
@@ -266,7 +266,7 @@ The loader does these steps:
|
|
|
266
266
|
|
|
267
267
|
The copy table, the copier and the jump use labels, not numbers. `loader_from_xxxx` and `loader_end_xxxx` are around each packed segment. `loader_to_xxxx` is its first address in place. Thus a segment can change its length, and the loader still works.
|
|
268
268
|
|
|
269
|
-
The loader changes the free stack byte below the stack pointer (`stackByte`). It does not set the SID, the time of day of the CIAs, the CIA interrupt flags or the interrupt registers of the VIC-II. A program that reads SID voice 3 for random numbers can thus give a different result. A start screen writes the colour RAM, and the loader does not set it again. When you compare the
|
|
269
|
+
The loader changes the free stack byte below the stack pointer (`stackByte`). It does not set the SID, the time of day of the CIAs, the CIA interrupt flags or the interrupt registers of the VIC-II. A program that reads SID voice 3 for random numbers can thus give a different result. A start screen writes the colour RAM, and the loader does not set it again. When you compare the reference and the rebuild, observe after the program sets its own random numbers.
|
|
270
270
|
|
|
271
271
|
The script builds and checks the loader program with the values of `config.asm`. With the defaults, the loader program is the clean program: no copy protection, all corrections and no leftovers. The entry state is the state of the base release. For a loader of a release, build `loader.asm` with the build option `--release <label>`. That loader also does not have the leftovers.
|
|
272
272
|
|
|
@@ -281,7 +281,7 @@ The start screen:
|
|
|
281
281
|
`loader` holds these fields:
|
|
282
282
|
|
|
283
283
|
- `program`, the `copies` in their order, `copier` and `stackByte`.
|
|
284
|
-
- `verified: true`: the check ran the loader program to its jump to the entry. There, the memory, $00/$01, the registers and the VIC-II are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the
|
|
284
|
+
- `verified: true`: the check ran the loader program to its jump to the entry. There, the memory, $00/$01, the registers and the VIC-II are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the program of the base release.
|
|
285
285
|
- `limits`: each CIA value that the loader cannot set as it was at the entry. An old capture has no CIA values. Then capture the program again at its entry point.
|
|
286
286
|
- `startScreen`: with a start screen, `shown: true` when the VIC-II had the values of the start screen, and `waits: true` when the start screen waited without a key. `wait` and `continue` are the addresses of the wait and of the code after it. The check sets the PC to `continue`, and then runs the loader to its jump.
|
|
287
287
|
- `packed`: `packedBytes` and `unpackedBytes` of the packed form. With a start screen of a captured stage, this is the packed program in the loader program.
|
|
@@ -379,7 +379,7 @@ On `FAIL`, `hint` gives the action for the stage:
|
|
|
379
379
|
|
|
380
380
|
| `stage` | Action |
|
|
381
381
|
|---|---|
|
|
382
|
-
| `
|
|
382
|
+
| `base` | The source of the knowledge does not pass. Run `generate`, and correct the project knowledge until `generate` gives `PASS`. Then export again. |
|
|
383
383
|
| `switches` | The build with the export values changes bytes outside the patches, or a patch does not fit. Read `build`. Run `generate`, and correct the patches. |
|
|
384
384
|
| `export` | This is a defect of the script. Give the result to the user. |
|
|
385
385
|
| `loader` | Read `reason`, and give it to the user. The export does not make the packed form of the loader. |
|
|
@@ -433,7 +433,7 @@ tests/ the tests of the project, changed for the new program
|
|
|
433
433
|
|
|
434
434
|
- The source has no mark line, no `switches.asm` or `config.asm`, no patch zones and no `; not executed` lines. A start screen stays in the loader. Build with `-DSTART_SCREEN=0` to start the program at once. It keeps the names, the comments, the operand expressions and the macros. A line comment at each changed patch gives the switch, its kind, its value and the comments.
|
|
435
435
|
- The knowledge has one revision `export`. It holds the program, the entry and its state, the names, the comments, the regions, the modules and the start screen. It has no history, analyzer names, references, operand expressions, macros, patches, switches, releases or coverage.
|
|
436
|
-
- A scenario of `tests/` compares the build of the new project with the baseline. Both sides are the same program. Thus a step of the
|
|
436
|
+
- A scenario of `tests/` compares the build of the new project with the baseline. Both sides are the same program. Thus a step of the reference side alone goes. A step of the rebuild side alone runs on both sides.
|
|
437
437
|
- A run file of `tests/` runs the build of the new project. Scenarios and run files take the names from the symbol files.
|
|
438
438
|
- The export leaves out a test that restores a snapshot. It also leaves out a test with a name that the new program does not have, or with an address in a free range.
|
|
439
439
|
- The export does not copy recordings, record files or `runs/`.
|
|
@@ -450,7 +450,7 @@ tests/ the tests of the project, changed for the new program
|
|
|
450
450
|
5. Record names, comments, regions and modules in the project knowledge.
|
|
451
451
|
6. Run `generate` again. Do steps 4 to 6 again until the source is clear.
|
|
452
452
|
7. Assemble `main.asm` to a program. This is the default build. For a release, give the build option `--release <label>`.
|
|
453
|
-
8. For an unpacked program, run `generate --out <dir> --loader` at the end. Compare the loader program with the
|
|
453
|
+
8. For an unpacked program, run `generate --out <dir> --loader` at the end. Compare the loader program with the program of the base release in a test.
|
|
454
454
|
9. To start a new program from the rebuild, run `export`.
|
|
455
455
|
|
|
456
456
|
---
|
|
@@ -408,7 +408,7 @@ const hasSnapshot = (value: unknown): boolean =>
|
|
|
408
408
|
/**
|
|
409
409
|
* A scenario or a run file of the project for the new project. A scenario
|
|
410
410
|
* compares the baseline (the exported program) with the build of the new
|
|
411
|
-
* project: a step of the
|
|
411
|
+
* project: a step of the reference side alone goes, and a step of the rebuild
|
|
412
412
|
* side alone runs on both sides. A run file runs the build. A test is left out when it restores a
|
|
413
413
|
* snapshot (a state of the old program), names something that the exported
|
|
414
414
|
* program does not have, or names an address in a free range.
|
|
@@ -422,8 +422,9 @@ export function rewriteTest(text: string, name: string, symbols: ReadonlyMap<str
|
|
|
422
422
|
} catch {
|
|
423
423
|
return { reason: "it is not JSON" };
|
|
424
424
|
}
|
|
425
|
-
const scenario = typeof test.
|
|
425
|
+
const scenario = typeof test.reference === "object" && typeof test.rebuild === "object" && Array.isArray(test.steps);
|
|
426
426
|
const run = typeof test.start === "object" && test.start !== null && Array.isArray(test.steps);
|
|
427
|
+
if (!scenario && typeof test.rebuild === "object" && Array.isArray(test.steps)) return { reason: "it is a scenario without a reference side. A scenario has reference, rebuild and steps" };
|
|
427
428
|
if (!scenario && !run) return { reason: "it is not a scenario or a run file" };
|
|
428
429
|
if (hasSnapshot(test)) return { reason: "it restores a snapshot, which is a state of the old program" };
|
|
429
430
|
for (const location of locationsOf(test.steps)) {
|
|
@@ -434,14 +435,14 @@ export function rewriteTest(text: string, name: string, symbols: ReadonlyMap<str
|
|
|
434
435
|
}
|
|
435
436
|
const side = (program: string) => ({ program: `${program}.prg`, symbols: symbolsPath(`${program}.prg`) });
|
|
436
437
|
if (scenario) {
|
|
437
|
-
// Both sides are the exported program now: a step of the
|
|
438
|
-
const {
|
|
438
|
+
// Both sides are the exported program now: a step of the reference alone (for example a key for its intro) goes, and a step of the rebuild alone runs on both sides.
|
|
439
|
+
const { reference: _reference, rebuild: _rebuild, steps, ...rest } = test;
|
|
439
440
|
const both = (steps as unknown[]).flatMap((step) => {
|
|
440
441
|
if (step === null || typeof step !== "object" || !("side" in step)) return [step];
|
|
441
442
|
const { side: only, ...action } = step as Record<string, unknown>;
|
|
442
|
-
return only === "
|
|
443
|
+
return only === "reference" ? [] : [action];
|
|
443
444
|
});
|
|
444
|
-
return { kind: "scenario", text: `${JSON.stringify({ ...rest,
|
|
445
|
+
return { kind: "scenario", text: `${JSON.stringify({ ...rest, reference: side(`baseline/${name}`), rebuild: side(`build/${name}`), steps: both }, null, 2)}\n` };
|
|
445
446
|
}
|
|
446
447
|
const start = test.start as Record<string, unknown>;
|
|
447
448
|
const symbolsFile = test.symbols === undefined || test.symbols === "none" ? {} : { symbols: symbolsPath(`build/${name}.prg`) };
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// generator forces operand sizes, and writes an opcode form that ACME
|
|
7
7
|
// encodes differently as bytes (see the probe in source.ts). An operand
|
|
8
8
|
// expression of the knowledge is written in place of its number. A
|
|
9
|
-
// patch is written as !if SWITCH { code } else {
|
|
9
|
+
// patch is written as !if SWITCH { code } else { base code }, with the
|
|
10
10
|
// condition of the state that the program does not have, and a macro use as
|
|
11
11
|
// one +name args line. config.asm holds the value of each switch, and
|
|
12
12
|
// switches.asm the values of each release. A range of leftovers (bytes that
|
|
@@ -1119,7 +1119,7 @@ const patchCondition = (alternative: PatchAlternative) => (alternative.base ===
|
|
|
1119
1119
|
/**
|
|
1120
1120
|
* The lines that open a patch: its zone, a guard that stops two alternatives
|
|
1121
1121
|
* together, then for each switch its condition, its code and the guard that
|
|
1122
|
-
* stops code longer than the range. The
|
|
1122
|
+
* stops code longer than the range. The code of the base release follows in the last
|
|
1123
1123
|
* else; the patch closes with closingBraces.
|
|
1124
1124
|
*/
|
|
1125
1125
|
function patchOpening(patch: PatchBlock): string[] {
|
|
@@ -1200,7 +1200,7 @@ export function render(layout: Layout, asBytes: ReadonlySet<string>, header: str
|
|
|
1200
1200
|
let running = false;
|
|
1201
1201
|
/** The line of the mark of the open range of instructions that did not execute. */
|
|
1202
1202
|
let markLine = 0;
|
|
1203
|
-
/** The open patch: its labels are defined before it, so the
|
|
1203
|
+
/** The open patch: its labels are defined before it, so the code of the base release writes none. */
|
|
1204
1204
|
let patch: PatchBlock | undefined;
|
|
1205
1205
|
/** The last address of the macro use just written: its instructions are in the use line. */
|
|
1206
1206
|
let useEnd = -1;
|
|
@@ -279,9 +279,9 @@ function usesInErrors(diagnostics: Diagnostic[], lineOf: ReadonlyMap<string, num
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
/** The first address where two byte runs differ, as a reason. */
|
|
282
|
-
function firstDifference(start: number, built: (address: number) => number,
|
|
282
|
+
function firstDifference(start: number, built: (address: number) => number, imageByte: (address: number) => number, end: number): string | undefined {
|
|
283
283
|
for (let address = start; address <= end; address++) {
|
|
284
|
-
if (built(address) !==
|
|
284
|
+
if (built(address) !== imageByte(address)) return `ACME assembles it to other bytes than the image: at ${formatC64Address(address)} it gives $${built(address).toString(16).padStart(2, "0")}, and the image has $${imageByte(address).toString(16).padStart(2, "0")}.`;
|
|
285
285
|
}
|
|
286
286
|
return undefined;
|
|
287
287
|
}
|
|
@@ -371,8 +371,8 @@ function blame(rendered: Rendered, built: Awaited<ReturnType<typeof assembleFile
|
|
|
371
371
|
for (const item of rendered.expressions) {
|
|
372
372
|
if (item.address + item.length - 1 > end || item.address < built.start!) continue;
|
|
373
373
|
const assembled = word((address) => built.program![2 + address - built.start!]!, item);
|
|
374
|
-
const
|
|
375
|
-
if (assembled !==
|
|
374
|
+
const imageWord = word(image.byteAt, item);
|
|
375
|
+
if (assembled !== imageWord) blamed.set(item.address, `ACME assembles it to ${show(assembled, item.length)}, and the image has ${show(imageWord, item.length)}.`);
|
|
376
376
|
}
|
|
377
377
|
return { numbers: blamed, uses };
|
|
378
378
|
}
|
|
@@ -526,7 +526,7 @@ async function readRam(client: ViceSessionClient, start: number, size: number):
|
|
|
526
526
|
* Runs the loader in the emulator to its jump to the entry and compares the
|
|
527
527
|
* machine with the entry state there. At the jump, every byte and register is
|
|
528
528
|
* set and no interrupt has run since the PLP: the 6502 takes one only after
|
|
529
|
-
* the JMP, as the
|
|
529
|
+
* the JMP, as the program can take one right at its entry.
|
|
530
530
|
*/
|
|
531
531
|
/** What the check of the loader gives. `stop`: why the loader did not get to its copier or its jump. */
|
|
532
532
|
interface LoaderRun {
|
|
@@ -1541,28 +1541,28 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
|
|
|
1541
1541
|
|
|
1542
1542
|
// 1. The source of the knowledge must give the base release byte for byte, with every patch in it.
|
|
1543
1543
|
const baseValues = new Map(knowledge.switches.map((row) => [row.name, row.base]));
|
|
1544
|
-
const
|
|
1545
|
-
if (
|
|
1546
|
-
const checked = check(
|
|
1547
|
-
if (!checked.identical) return { result: "FAIL", stage: "
|
|
1548
|
-
if (
|
|
1549
|
-
if (
|
|
1550
|
-
return { result: "FAIL", stage: "
|
|
1544
|
+
const baseSource = await buildSource(knowledge, { space: DEFAULT_SPACE, entries: [], header: [], values: baseValues, notExecutedMarks: false });
|
|
1545
|
+
if (baseSource.built.program === undefined) return { result: "FAIL", stage: "base", reason: "The source of the knowledge does not assemble.", diagnostics: baseSource.built.diagnostics.slice(0, MAX_DIAGNOSTICS) };
|
|
1546
|
+
const checked = check(baseSource.built.program, baseSource.built.start!, image);
|
|
1547
|
+
if (!checked.identical) return { result: "FAIL", stage: "base", reason: "The source of the knowledge does not assemble to the program.", check: checked };
|
|
1548
|
+
if (baseSource.missingEntry !== undefined) return { result: "FAIL", stage: "base", reason: baseSource.missingEntry };
|
|
1549
|
+
if (baseSource.laid.patchesNotWritten.length > 0) {
|
|
1550
|
+
return { result: "FAIL", stage: "base", reason: "The source cannot write every patch.", patchesNotWritten: listed(baseSource.laid.patchesNotWritten, max, (item) => ({ ...shownRange(item), switch: item.switch, reason: item.reason })) };
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
1553
|
// 2. Each switch at its export value. Two alternatives of one range cannot both be in.
|
|
1554
1554
|
const values = new Map(knowledge.switches.map((row) => [row.name, exportValue(row)]));
|
|
1555
|
-
for (const patch of
|
|
1555
|
+
for (const patch of baseSource.laid.patches.values()) {
|
|
1556
1556
|
const both = patch.alternatives.filter((alternative) => values.get(alternative.switch) !== alternative.base);
|
|
1557
1557
|
if (both.length > 1) {
|
|
1558
1558
|
throw new Refusal("invalid-input", `The switches ${both.map((item) => item.switch).join(" and ")} change ${formatC64Address(patch.start)}-${formatC64Address(patch.end)} in different ways, and the export puts both in. In the project knowledge, give all but one of them the kind change, with the default of the base release. Then export again.`);
|
|
1559
1559
|
}
|
|
1560
1560
|
}
|
|
1561
|
-
const withPatches = switchesOf(
|
|
1561
|
+
const withPatches = switchesOf(baseSource.laid);
|
|
1562
1562
|
const changedSwitches = knowledge.switches.filter((row) => values.get(row.name) !== row.base);
|
|
1563
1563
|
const patchesIn = changedSwitches.flatMap((row) => withPatches.get(row.name) ?? []);
|
|
1564
|
-
const baked = await assembleFiles(withValues(
|
|
1565
|
-
const bakedCheck = compareBuilds(baked, patchesIn, { program:
|
|
1564
|
+
const baked = await assembleFiles(withValues(baseSource.files, baseSource.laid, values), "main.asm");
|
|
1565
|
+
const bakedCheck = compareBuilds(baked, patchesIn, { program: baseSource.built.program, start: baseSource.built.start! });
|
|
1566
1566
|
const switches = knowledge.switches.map((row) => ({ name: row.name, kind: row.kind, base: row.base, value: values.get(row.name)! }));
|
|
1567
1567
|
if (bakedCheck.result !== "fits" || baked.program === undefined) return { result: "FAIL", stage: "switches", reason: "The build with the export values of the switches does not fit.", switches, build: bakedCheck };
|
|
1568
1568
|
|
|
@@ -1808,7 +1808,7 @@ function generateReply(call: Call, body: Record<string, unknown>): Reply {
|
|
|
1808
1808
|
function exportReply(body: Record<string, unknown>): Reply {
|
|
1809
1809
|
if (body.result === "FAIL") {
|
|
1810
1810
|
const hints: Record<string, string> = {
|
|
1811
|
-
|
|
1811
|
+
base: "Run generate, and correct the project knowledge until generate gives PASS. Then export again.",
|
|
1812
1812
|
switches: "Run generate. It builds each switch alone. Correct the patches in the project knowledge until each switch fits. Then export again.",
|
|
1813
1813
|
export: "This is a defect of the script. Give the result to the user.",
|
|
1814
1814
|
loader: "Read reason, and give it to the user.",
|
|
@@ -59,7 +59,7 @@ To get the command list, run the script with no arguments.
|
|
|
59
59
|
- Give each path relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
60
60
|
- If the working directory is not in a project, give `--project <folder>` to each command. If the working directory has projects below it, the script refuses and lists them.
|
|
61
61
|
- In a group folder, each version of a program is a project. The script refuses the group folder and each folder in it that is not a project. Give `--project` with a project of the group, for example `--project v1`.
|
|
62
|
-
- A path that a command only reads can go into another project of the group, for example `../v1/
|
|
62
|
+
- A path that a command only reads can go into another project of the group, for example `../v1/releases/game.prg`. The command writes only in its own project.
|
|
63
63
|
- An address is `$` and 1 to 4 hex digits, for example `'$c000'` or `'$fb'`, or a name. A name is a symbol, else an analyzer name that only one analyzer gives. Put an address in single quotes in a shell.
|
|
64
64
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
65
65
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-testing
|
|
3
|
-
description: Tests if a rebuilt or changed C64 program behaves as the
|
|
3
|
+
description: Tests if a rebuilt or changed C64 program behaves as the reference, or if a program has the expected values. It runs a scenario on the reference and on the rebuild in an emulator. It compares memory, registers, chip state and the screen with explicit rules, and gives PASS, FAIL or INCONCLUSIVE. Use it when you must show that a rebuild or a correction keeps the behavior of the reference. Use it to do many steps on one program and keep the screens, coverage maps, traces and snapshots as files. Use it to test a new program or a correction with expected values. Use it to record a play session of the reference and replay it on the default build of the rebuild. Use it to find what changed between two machine states, and to make a checklist for a human playtest. It does not find the cause of a difference. It does not build the program.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# C64 testing
|
|
7
7
|
|
|
8
|
-
Use this script to test a rebuild or a changed C64 program against the
|
|
8
|
+
Use this script to test a rebuild or a changed C64 program against the reference, or against expected values.
|
|
9
9
|
Use only the commands of the script. Do not compare machine states or replay play sessions in another way.
|
|
10
10
|
|
|
11
11
|
```bash
|
|
@@ -23,13 +23,13 @@ To get the command list, run the script with no arguments.
|
|
|
23
23
|
|
|
24
24
|
| Goal | Command |
|
|
25
25
|
|---|---|
|
|
26
|
-
| Compare the rebuild with the
|
|
26
|
+
| Compare the rebuild with the reference in a scenario | `test tests/moves-left.json` |
|
|
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
|
-
| Record a play session of a person on the
|
|
30
|
+
| Record a play session of a person on the reference | `record tests/record/start.json --out tests/recordings/play1 --play --joystick 1` |
|
|
31
31
|
| Record a session from steps only | `record tests/record/rooms.json --out tests/recordings/rooms` |
|
|
32
|
-
| Make sure that a recording replays on the
|
|
32
|
+
| Make sure that a recording replays on the reference | `replay tests/recordings/rooms` |
|
|
33
33
|
| Compare the rebuild with a recording | `replay tests/recordings/rooms --checkpoint main_loop --state room --state lives --pin random_ptr:2 --rebuild build/clean.prg --symbols build/symbols/clean.json --out .c64-re-tools/local/results/rooms` |
|
|
34
34
|
| Find what changed between two snapshot files | `diff .c64-re-tools/local/runs/rooms/before.vsf .c64-re-tools/local/runs/rooms/after.vsf` |
|
|
35
35
|
| Find what changed between two observations of runs | `diff .c64-re-tools/local/runs/rooms/results.json:room0 .c64-re-tools/local/runs/rooms/results.json:room3` |
|
|
@@ -38,8 +38,9 @@ To get the command list, run the script with no arguments.
|
|
|
38
38
|
|
|
39
39
|
## Programs, files and names
|
|
40
40
|
|
|
41
|
-
- The
|
|
42
|
-
- The
|
|
41
|
+
- The reference is the reference file: the program file or the capture that you examined. A test compares the rebuild with it. It can be a crack, a snapshot, a memory dump, a disk image or a commercial release. Here it must be a PRG file, for example the file of the base release. A PASS tells only about that file.
|
|
42
|
+
- The reference program and the rebuild are PRG files in the project. The script refuses a disk, tape or cartridge image. Extract the program file from the image first.
|
|
43
|
+
- The reference gets its names from the project knowledge. Give `"symbols": "knowledge"` for the reference.
|
|
43
44
|
- 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.
|
|
44
45
|
- You write the scenario file, the run file and the record file. Their formats are in the files of the section "Reference".
|
|
45
46
|
- 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.
|
|
@@ -55,7 +56,7 @@ To get the command list, run the script with no arguments.
|
|
|
55
56
|
- Give each path relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
56
57
|
- If the working directory is not in a project, give `--project <folder>` to each command. If the working directory has projects below it, the script refuses and lists them.
|
|
57
58
|
- In a group folder, each version of a program is a project. The script refuses the group folder and each folder in it that is not a project. Give `--project` with a project of the group, for example `--project v1`.
|
|
58
|
-
- A path that a command only reads can go into another project of the group, for example `../v1/
|
|
59
|
+
- A path that a command only reads can go into another project of the group, for example `../v1/releases/game.prg`. The command writes only in its own project.
|
|
59
60
|
- An address is `$` and 1 to 4 hex digits, for example `'$c000'` or `'$fb'`, or a name. A name is a symbol, else an analyzer name that only one analyzer gives. Put an address in single quotes in a shell.
|
|
60
61
|
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
61
62
|
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
@@ -83,8 +84,8 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
83
84
|
| `--http-port <n>` | `record` | With `--play`: the port of the page. The default is 6465. |
|
|
84
85
|
| `--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. |
|
|
85
86
|
| `--state <item>` | `replay` | A memory item to compare at each checkpoint. Give it again for each item. |
|
|
86
|
-
| `--pin <item>` | `replay` | Random state in RAM. At each checkpoint, the rebuild gets the values of the
|
|
87
|
-
| `--rebuild <prg>` | `replay` | The rebuild to compare with the
|
|
87
|
+
| `--pin <item>` | `replay` | Random state in RAM. At each checkpoint, the rebuild gets the values of the reference there. Give it again for each item. |
|
|
88
|
+
| `--rebuild <prg>` | `replay` | The rebuild to compare with the reference. Without it, the script replays only on the reference. |
|
|
88
89
|
| `--symbols <file>` | `replay` | The symbol file of the rebuild. The default is the symbols of the recording. |
|
|
89
90
|
| `--out <dir>` | `replay` | With a FAIL, write the RAM of each side at the first different checkpoint into this folder. |
|
|
90
91
|
| `--gap <n>` | `diff` | Join changed ranges across at most n equal bytes. The default is 0. |
|
|
@@ -100,7 +101,7 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
100
101
|
|
|
101
102
|
### `test <scenario.json>`
|
|
102
103
|
|
|
103
|
-
The script runs the scenario on the
|
|
104
|
+
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.
|
|
104
105
|
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.
|
|
105
106
|
|
|
106
107
|
`body` holds:
|
|
@@ -108,8 +109,8 @@ Before the test starts, the script examines the scenario and each file that it n
|
|
|
108
109
|
- `result`: `PASS`, `FAIL` or `INCONCLUSIVE`.
|
|
109
110
|
- `checkpoints`: the names of the checkpoints.
|
|
110
111
|
- `differences`: with a FAIL, each difference with its `checkpoint` and the item in `what`.
|
|
111
|
-
- A memory item gives `bytes`. `bytes.count` is the number of differing bytes. `bytes.listed` gives the first bytes, each with `address`, `
|
|
112
|
-
- Another item gives the `
|
|
112
|
+
- A memory item gives `bytes`. `bytes.count` is the number of differing bytes. `bytes.listed` gives the first bytes, each with `address`, `reference` and `rebuild`.
|
|
113
|
+
- Another item gives the `reference` value and the `rebuild` value.
|
|
113
114
|
- `excluded`: each byte that an `exclude` left out of the comparison, with its `reason`.
|
|
114
115
|
- `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.
|
|
115
116
|
- `reason`: with an INCONCLUSIVE, why the script could not compare.
|
|
@@ -130,7 +131,7 @@ Traps:
|
|
|
130
131
|
|
|
131
132
|
- A FAIL with only a `screen` difference: add `vicii` or `sprites` to the observation. Then you find the chip state that is different.
|
|
132
133
|
- A program that uses random numbers: set the random seed with a `write` step on both sides. If you cannot set it, observe only values that do not depend on the random numbers.
|
|
133
|
-
- The two sides start differently, for example the
|
|
134
|
+
- The two sides start differently, for example the reference after a cracked intro. Give a `side` to the steps that only one side needs. Then make the memory the same with a `normalize` step.
|
|
134
135
|
- `normalize` needs the entry state of a capture in the project knowledge. If the knowledge has no capture, the script refuses. Then capture the unpacked program at its entry point, and put the capture image into the project knowledge.
|
|
135
136
|
- The frame counts of the sides are different by one frame. The sides got to the same address at different raster positions. Do not synchronize on an interrupt handler. Synchronize on a value that the interrupt changes, with a `runUntil` step with a `memory` target. Or use an `address` target with a `raster` condition.
|
|
136
137
|
- A byte cannot be the same on both sides, for example a read-only collision register. Use `exclude` with the reason. Do not use `exclude` to hide a real difference.
|
|
@@ -174,7 +175,7 @@ Traps:
|
|
|
174
175
|
|
|
175
176
|
## Recordings
|
|
176
177
|
|
|
177
|
-
A recording keeps a session of the
|
|
178
|
+
A recording keeps a session of the reference program, for example a play through some rooms of a game. A replay gives the same input to a rebuild and compares the game state. A recording needs no names.
|
|
178
179
|
|
|
179
180
|
- Make the recordings early, before you change the program.
|
|
180
181
|
- Ask the user to play first. Tell the user which parts of the program the recordings must have, for example each room, a fight and a lost life.
|
|
@@ -196,7 +197,7 @@ Control each source of random numbers:
|
|
|
196
197
|
|
|
197
198
|
### `record <record.json>`
|
|
198
199
|
|
|
199
|
-
The script does the steps of the record file on the
|
|
200
|
+
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.
|
|
200
201
|
|
|
201
202
|
`body` holds:
|
|
202
203
|
|
|
@@ -211,7 +212,7 @@ The script does the steps of the record file on the original program. Then it wr
|
|
|
211
212
|
|
|
212
213
|
Do this for each result:
|
|
213
214
|
|
|
214
|
-
- `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
|
|
215
|
+
- `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.
|
|
215
216
|
- `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.
|
|
216
217
|
- `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.
|
|
217
218
|
- 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.
|
|
@@ -234,31 +235,31 @@ Traps:
|
|
|
234
235
|
|
|
235
236
|
### `replay <recording>`
|
|
236
237
|
|
|
237
|
-
The script first replays the recording on the
|
|
238
|
+
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.
|
|
238
239
|
|
|
239
240
|
`--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.
|
|
240
|
-
A `$` address is an address of the
|
|
241
|
+
A `$` address is an address of the reference. On the rebuild, it moves with the name before it.
|
|
241
242
|
|
|
242
243
|
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.
|
|
243
244
|
|
|
244
|
-
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
|
|
245
|
+
A rebuild can be the loader program of a generated source. Give its symbols. Then the replay counts from the entry of the program, where the loader jumps to. The checkpoints of both sides start at that entry. At the entry, the rebuild gets the raster position, the CIA timers and the interrupt state of the reference. The loader cannot set them as the reference has them in the replay. A runUntil step to an address does not count the code of the loader, or the code that the reference runs before that entry. If another step of the recording runs before the entry, the result is INCONCLUSIVE. Then start the steps of the record file after the entry.
|
|
245
246
|
|
|
246
247
|
`body` holds `result`, `side`, `firstDifference`, `reason` and `files`. The section "Replay" of `references/recording-format.md` gives each field.
|
|
247
248
|
|
|
248
249
|
Do this for each result:
|
|
249
250
|
|
|
250
|
-
- `PASS`: each checkpoint of the rebuild has the state of the
|
|
251
|
+
- `PASS`: each checkpoint of the rebuild has the state of the reference. Without `--rebuild`, the recording replays on the reference.
|
|
251
252
|
- `FAIL` with `--out`: `files` has the RAM of each side at the first different checkpoint. `nextAction` compares the two files with `diff`. Then examine the first different state item in the emulator.
|
|
252
253
|
- `FAIL` without `--out`: `hint` tells you to give `--out`. A FAIL where an enemy or an event is different, but the input is the same, often shows that a `--pin` is missing.
|
|
253
254
|
- `FAIL` with no `firstDifference`: the rebuild did not get to all checkpoints. `reason` gives the number. Examine the rebuild in the emulator after its last checkpoint.
|
|
254
255
|
- `INCONCLUSIVE`: `reason` gives the cause:
|
|
255
|
-
- "does not reproduce": the
|
|
256
|
-
- "never came to the checkpoint": the
|
|
256
|
+
- "does not reproduce": the reference does not end the session with the recorded state. Record the session again.
|
|
257
|
+
- "never came to the checkpoint": the reference did not execute the checkpoint routine in the session. Give another routine.
|
|
257
258
|
- "is not the program of the recording": the program file changed after the recording. Record the session again.
|
|
258
259
|
|
|
259
260
|
Traps:
|
|
260
261
|
|
|
261
|
-
- `idleReads` counts the input reads of the rebuild that the recording had no value for. On the
|
|
262
|
+
- `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.
|
|
262
263
|
- The script refuses a recording of an older version in an old form with `invalid-input`. Record the session again.
|
|
263
264
|
|
|
264
265
|
---
|