@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.
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +23 -38
- package/skills/c64-assembler/scripts/assembler.ts +137 -17
- package/skills/c64-basic/SKILL.md +11 -31
- package/skills/c64-basic/scripts/basic.ts +4 -1
- package/skills/c64-development/SKILL.md +2 -2
- package/skills/c64-disk/SKILL.md +11 -32
- package/skills/c64-docs/SKILL.md +27 -45
- package/skills/c64-docs/references/page-types.md +20 -18
- package/skills/c64-docs/references/style.md +10 -4
- package/skills/c64-docs/scripts/docs.ts +13 -2
- package/skills/c64-docs/scripts/lib/reference.ts +47 -5
- package/skills/c64-knowledge/SKILL.md +138 -267
- package/skills/c64-knowledge/references/batches.md +48 -0
- package/skills/c64-knowledge/references/coverage.md +29 -0
- package/skills/c64-knowledge/references/source-knowledge.md +72 -0
- package/skills/c64-knowledge/references/start-screen.md +44 -0
- package/skills/c64-knowledge/scripts/knowledge.ts +266 -61
- package/skills/c64-knowledge/scripts/lib/check.ts +133 -0
- package/skills/c64-knowledge/scripts/lib/listing.ts +71 -8
- package/skills/c64-memory-map/SKILL.md +11 -32
- package/skills/c64-packer/SKILL.md +11 -31
- package/skills/c64-provenance/SKILL.md +43 -64
- package/skills/c64-provenance/scripts/lib/leftovers.ts +8 -3
- package/skills/c64-provenance/scripts/provenance.ts +65 -56
- package/skills/c64-reverse-engineering/SKILL.md +20 -47
- package/skills/c64-reverse-engineering/references/comment-check.md +42 -0
- package/skills/c64-reverse-engineering/references/versions.md +47 -0
- package/skills/c64-source/SKILL.md +48 -237
- package/skills/c64-source/references/export.md +50 -0
- package/skills/c64-source/references/loader.md +78 -0
- package/skills/c64-source/references/source-format.md +46 -0
- package/skills/c64-source/scripts/lib/export.ts +28 -13
- package/skills/c64-source/scripts/lib/loader.ts +4 -82
- package/skills/c64-source/scripts/lib/source.ts +3 -5
- package/skills/c64-source/scripts/source.ts +48 -51
- package/skills/c64-static-analysis/SKILL.md +52 -52
- package/skills/c64-static-analysis/scripts/lib/coverage.ts +55 -2
- package/skills/c64-static-analysis/scripts/lib/idioms.ts +43 -17
- package/skills/c64-static-analysis/scripts/static-analysis.ts +79 -15
- package/skills/c64-testing/SKILL.md +72 -58
- package/skills/c64-testing/references/recording-format.md +5 -80
- package/skills/c64-testing/references/scenario-format.md +4 -12
- package/skills/c64-testing/scripts/lib/play.ts +16 -8
- package/skills/c64-testing/scripts/lib/recording.ts +74 -9
- package/skills/c64-testing/scripts/lib/replay.ts +4 -0
- package/skills/c64-testing/scripts/lib/runs.ts +112 -1
- package/skills/c64-testing/scripts/lib/scenario.ts +12 -6
- package/skills/c64-testing/scripts/lib/start-screen.ts +27 -0
- package/skills/c64-testing/scripts/testing.ts +34 -13
- package/skills/c64-unpacker/SKILL.md +10 -30
- package/skills/emulator/SKILL.md +7 -36
- package/src/build-name.ts +12 -1
- package/src/c64.ts +16 -0
- package/src/knowledge/history.ts +8 -0
- package/src/knowledge/program.ts +84 -4
- package/src/knowledge/read.ts +46 -2
- package/src/knowledge/recording-files.ts +32 -0
- package/src/knowledge/schema.ts +3 -1
- package/src/knowledge/separate.ts +165 -11
- package/src/knowledge/start-screen.ts +99 -17
- package/src/knowledge/text.ts +2 -1
- package/src/knowledge/write.ts +15 -8
- package/src/loader.ts +167 -0
- package/src/native/decompiler/analyze.ts +7 -6
- package/src/native/decompiler/walk.ts +32 -2
- package/src/native/dxa.ts +4 -4
- package/src/native/types.ts +34 -4
- package/src/script.ts +102 -25
- package/skills/c64-export/SKILL.md +0 -63
|
@@ -98,25 +98,32 @@ Do the stages in this sequence. Go to the next stage only when its exit check is
|
|
|
98
98
|
| 2. Get | List the disk image. Extract the start file into `releases/`. | The start file is in the project. |
|
|
99
99
|
| 3. Start | Find the SYS address of the BASIC start. | You have the entry address. |
|
|
100
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. |
|
|
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/`.
|
|
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/`. Put each map and the coverage of each recording into the project knowledge. | The program in the project knowledge has a coverage map for each part that the scope names. |
|
|
102
102
|
| 6. Analyze | Analyze the program statically. The analysis reads the program and the coverage from the project knowledge. | No coverage conflict is open. |
|
|
103
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. |
|
|
104
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. |
|
|
105
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". |
|
|
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
|
|
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
|
|
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: the loader program when the source has a loader, else the clean build. The result of the generation gives its file. 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, the limits of the evidence and the result of the last comment check 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. |
|
|
108
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. |
|
|
109
109
|
|
|
110
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.
|
|
111
111
|
|
|
112
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:
|
|
113
113
|
|
|
114
|
-
- Replay only the default build
|
|
114
|
+
- Replay only the default build. Do not replay a release build or a build with a switch that is not at its default.
|
|
115
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.
|
|
116
116
|
- Do the other tests of stage 1 only when the user selected them.
|
|
117
117
|
|
|
118
118
|
After stage 7, save each routine that other programs can have to the routine library of the workspace. Examples are a music driver, a decruncher and a loader. Ask the user before you make a library.
|
|
119
119
|
|
|
120
|
+
After the last pass of stages 7 to 9, check the comments:
|
|
121
|
+
|
|
122
|
+
1. Start a check of 30 comments of the LLM in the project knowledge. Keep the seed of the check.
|
|
123
|
+
2. Give the check to an agent that did not write the comments, for example a new subagent. Give it the seed and the instructions in `<skill>/references/comment-check.md`.
|
|
124
|
+
3. Get the result of the check. Correct each `wrong` comment and name in the project knowledge. Give the file of the verdicts as evidence of each correction.
|
|
125
|
+
4. Generate the source again.
|
|
126
|
+
|
|
120
127
|
### Deliverables of a full rebuild
|
|
121
128
|
|
|
122
129
|
- `.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
|
|
@@ -136,55 +143,16 @@ All other files that you made are not deliverables. Keep them in `.c64-re-tools/
|
|
|
136
143
|
Give the user a short answer at the end. Do not write a report file. Write a report file only when the user asks for it. The knowledge, `docs/` and the scenarios keep the durable results. The answer has:
|
|
137
144
|
|
|
138
145
|
1. Each criterion of stage 1 and its result, and each exception that the user accepted.
|
|
139
|
-
2. The count of the code ranges that no run executed. The
|
|
146
|
+
2. The count of the code ranges that no run executed. The result of the generation gives the count and the ranges.
|
|
140
147
|
3. The switches: the name, the kind and the default of each, and the releases that have it on. Also a copy protection that a crack removed and that no release has.
|
|
141
148
|
4. Open questions: what the evidence does not explain.
|
|
149
|
+
5. The result of each comment check: the seed, the number of comments in the sample, and the number of `wrong` and `unsure` comments before the corrections.
|
|
142
150
|
|
|
143
151
|
Keep observed facts apart from your conclusions.
|
|
144
152
|
|
|
145
|
-
### Project layout
|
|
146
|
-
|
|
147
|
-
If the project has no layout, use this one. No script checks it. Each script takes the paths that you give.
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
releases/ the disk image or the program as you got it
|
|
151
|
-
src/ the generated source
|
|
152
|
-
build/ the built programs. Do not commit them: each build writes them again.
|
|
153
|
-
tests/ the test scenarios, and the recordings in tests/recordings/
|
|
154
|
-
runs/ the runs that the knowledge gives as evidence
|
|
155
|
-
docs/ the documentation, with the reference in docs/reference/
|
|
156
|
-
tools/ scripts for the formats of this program only
|
|
157
|
-
README.md the entry page of the documentation
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Commit each folder of the layout other than `build/`, and `.c64-re-tools/knowledge/`. The knowledge holds the program, the entry state, the bytes of each release and the coverage, so the project needs no other folder for them. Put all other files that you make in `.c64-re-tools/local/`, also the captures and the coverage maps after you put them into the knowledge. Do not let git ignore a folder of the layout other than `build/`. Do not change the `.gitignore` files of the project.
|
|
161
|
-
|
|
162
|
-
If the project has a layout, use that layout.
|
|
153
|
+
### Project layout and versions
|
|
163
154
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
### Versions of one program
|
|
167
|
-
|
|
168
|
-
Some releases of a program have a different layout. Their code is at different addresses, so patches cannot hold the differences. Each of these releases is a version of the program. Give each version a project of its own in a group folder:
|
|
169
|
-
|
|
170
|
-
```
|
|
171
|
-
<game>/ the group folder: not a project
|
|
172
|
-
README.md the shared entry page: the program, each version, and how the versions differ
|
|
173
|
-
docs/ the shared pages: the development, the changes between the versions, the releases, the disk layout
|
|
174
|
-
library/ the routine library of the versions
|
|
175
|
-
tools/ the scripts for the formats of the program, for all versions
|
|
176
|
-
v1/ the project of the first version, with the project layout
|
|
177
|
-
v2/ the project of the second version, with the project layout
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
1. Make the group folder in the git repository. Do not put `.c64-re-tools/` in it.
|
|
181
|
-
2. Ask the user before you move a project folder. Then move the current project into `<game>/v1/`. The project knowledge keeps its paths relative to the project folder. Thus the knowledge stays valid after the move.
|
|
182
|
-
3. Make a project folder for the new version, for example `<game>/v2/`. Start at stage 2 with the file of that release. From the group folder, give `--project v2`. In the empty folder `v2/`, give `--project .`. The first write makes the project.
|
|
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.
|
|
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.
|
|
185
|
-
6. Use the same folders in each version, for example `src` and `docs/reference`.
|
|
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.
|
|
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.
|
|
155
|
+
For a project without a layout, and for a release whose code is at other addresses, read `<skill>/references/versions.md`. It gives the project layout and the group folder of the versions of one program.
|
|
188
156
|
|
|
189
157
|
## Knowledge
|
|
190
158
|
|
|
@@ -214,3 +182,8 @@ A clear answer for the scope, with the durable conclusions in the project knowle
|
|
|
214
182
|
|
|
215
183
|
- To add a feature or a correction to the rebuilt program, develop it as a change of a rebuilt program.
|
|
216
184
|
- To start a new program from the rebuilt program, export the rebuilt program as a new project.
|
|
185
|
+
|
|
186
|
+
## Reference
|
|
187
|
+
|
|
188
|
+
- `<skill>/references/versions.md`: the project layout, and the group folder for the versions of one program.
|
|
189
|
+
- `<skill>/references/comment-check.md`: the instructions for the agent that checks a sample of comments.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Check of the comments
|
|
2
|
+
|
|
3
|
+
You check comments that another agent wrote about a C64 program. You did not write them. Find each claim that the evidence does not support.
|
|
4
|
+
|
|
5
|
+
## Inputs
|
|
6
|
+
|
|
7
|
+
- The seed of the check.
|
|
8
|
+
- The project knowledge of the program: the listing, the references and the coverage.
|
|
9
|
+
|
|
10
|
+
## Procedure
|
|
11
|
+
|
|
12
|
+
1. Get the comments of the check with its seed. Each comment has an address, a placement and a text. It has a name when the address has a symbol.
|
|
13
|
+
2. For each comment, read the listing of the code that the comment explains. Start at the address and stop at the end of the routine.
|
|
14
|
+
3. Read the references to the address. Read the access of each line in the coverage.
|
|
15
|
+
4. Find each claim of the comment. Check each claim against the code, the references and the coverage. Also check the name.
|
|
16
|
+
5. Record the verdict of the comment in the check.
|
|
17
|
+
6. Get the result of the check. Make sure that each comment of the check has a verdict.
|
|
18
|
+
|
|
19
|
+
Do not change the project knowledge. Do not use other comments or the documentation as evidence. They can have the same errors.
|
|
20
|
+
|
|
21
|
+
## Verdicts
|
|
22
|
+
|
|
23
|
+
- `correct`: each claim agrees with the evidence.
|
|
24
|
+
- `wrong`: one or more claims do not agree with the evidence. Record the class of the error, the evidence, and the correct text or the correct name.
|
|
25
|
+
- `unsure`: the code and the coverage do not show the claim. Record the run that can show it.
|
|
26
|
+
|
|
27
|
+
A comment that does not give a detail is not wrong. A comment that tells more than the evidence shows is wrong.
|
|
28
|
+
|
|
29
|
+
## Error classes
|
|
30
|
+
|
|
31
|
+
| Class | Errors | Check |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `callers` | "Only X calls it", "no code calls it", "each frame". | Read all references to the address: calls, jumps and the entries of address tables. For "each frame", find a path from the interrupt. |
|
|
34
|
+
| `bits` | A wrong bit number or mask. `AND #$7f` clears bit 7. Bit 0 is the lowest bit. | Write the mask in binary. |
|
|
35
|
+
| `registers` | A wrong register or flag, for example a result in X, not in A. | Follow each register and flag from the entry to each RTS. |
|
|
36
|
+
| `bounds` | A count or an end that is wrong by one. `LDX #$07`, `DEX`, `BPL` runs 8 times. | Count the loop. Find out if the end address is in the range. |
|
|
37
|
+
| `units` | Bytes and entries, frames and seconds, or pixels and characters in the wrong place. | Check the step of the index and the size of each element. |
|
|
38
|
+
| `paths` | A claim that is true on one path only. A branch with the wrong sense: `BCC` jumps when the carry is clear. | Read each branch to the end of the routine. |
|
|
39
|
+
| `tables` | A claim about all entries of a table that is true only for some entries. | Read all entries of the table in the listing. |
|
|
40
|
+
| `hardware` | A wrong meaning of a chip register, a ROM routine or a memory configuration. | Find the address in the memory map of the C64. |
|
|
41
|
+
| `place` | A comment that explains other code: the address is wrong, or the code changed. | Compare the comment with the code at its address. |
|
|
42
|
+
| `scope` | A claim of history, intent or a release that nobody examined. | Find the evidence of the claim. |
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Project layout and versions
|
|
2
|
+
|
|
3
|
+
The project layout, and the group folder for versions of one program. The section "The stages of a full rebuild" of `<skill>/SKILL.md` refers to them.
|
|
4
|
+
|
|
5
|
+
## Project layout
|
|
6
|
+
|
|
7
|
+
If the project has no layout, use this one. No script checks it. Each script takes the paths that you give.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
releases/ the disk image or the program as you got it
|
|
11
|
+
src/ the generated source
|
|
12
|
+
build/ the built programs. Do not commit them: each build writes them again.
|
|
13
|
+
tests/ the test scenarios, and the recordings in tests/recordings/
|
|
14
|
+
runs/ the runs that the knowledge gives as evidence
|
|
15
|
+
docs/ the documentation, with the reference in docs/reference/
|
|
16
|
+
tools/ scripts for the formats of this program only
|
|
17
|
+
README.md the entry page of the documentation
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Commit each folder of the layout other than `build/`, and `.c64-re-tools/knowledge/`. The project knowledge holds the program, the entry state, the bytes of each release and the coverage. Thus the project needs no other folder for them. Put all other files that you make in `.c64-re-tools/local/`, also the captures and the coverage maps after you put them into the knowledge. Do not let git ignore a folder of the layout other than `build/`. Do not change the `.gitignore` files of the project.
|
|
21
|
+
|
|
22
|
+
If the project has a layout, use that layout.
|
|
23
|
+
|
|
24
|
+
A workspace with several projects keeps its routine library in `library/` beside the projects. The library is not a project folder.
|
|
25
|
+
|
|
26
|
+
## Versions of one program
|
|
27
|
+
|
|
28
|
+
Some releases of a program have a different layout. Their code is at different addresses, so patches cannot hold the differences. Each of these releases is a version of the program. Give each version a project of its own in a group folder:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
<game>/ the group folder: not a project
|
|
32
|
+
README.md the shared entry page: the program, each version, and how the versions differ
|
|
33
|
+
docs/ the shared pages: the development, the changes between the versions, the releases, the disk layout
|
|
34
|
+
library/ the routine library of the versions
|
|
35
|
+
tools/ the scripts for the formats of the program, for all versions
|
|
36
|
+
v1/ the project of the first version, with the project layout
|
|
37
|
+
v2/ the project of the second version, with the project layout
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
1. Make the group folder in the git repository. Do not put `.c64-re-tools/` in it.
|
|
41
|
+
2. Ask the user before you move a project folder. Then move the current project into `<game>/v1/`. The project knowledge stays valid after the move.
|
|
42
|
+
3. Make a project folder for the new version, for example `<game>/v2/`. Start at stage 2 with the file of that release. From the group folder, give `--project v2`. In the empty folder `v2/`, give `--project .`. The first write makes the project.
|
|
43
|
+
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.
|
|
44
|
+
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.
|
|
45
|
+
6. Use the same folders in each version, for example `src` and `docs/reference`.
|
|
46
|
+
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.
|
|
47
|
+
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.
|