@henols/c64-re-tools 2.0.0-rc.2 → 2.0.0-rc.20
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/README.md +28 -62
- package/distribution/package.ts +1 -16
- package/distribution/plugin.ts +5 -3
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +25 -6
- package/skills/c64-assembler/scripts/assemble.ts +45 -10
- package/skills/c64-assembler/scripts/lib/compare.ts +48 -0
- package/skills/c64-basic/SKILL.md +15 -7
- package/skills/c64-basic/scripts/basic.ts +4 -4
- package/skills/c64-disk/SKILL.md +34 -11
- package/skills/c64-disk/scripts/disk.ts +65 -10
- package/skills/c64-disk/scripts/lib/containers.ts +124 -0
- package/skills/c64-docs/SKILL.md +137 -0
- package/skills/c64-docs/references/page-types.md +113 -0
- package/skills/c64-docs/references/style.md +43 -0
- package/skills/c64-docs/scripts/generate.ts +102 -0
- package/skills/c64-docs/scripts/lib/links.ts +155 -0
- package/skills/c64-docs/scripts/lib/markdown.ts +79 -0
- package/skills/c64-docs/scripts/lib/reference.ts +406 -0
- package/skills/c64-docs/scripts/lib/source-map.ts +81 -0
- package/skills/c64-docs/scripts/link.ts +193 -0
- package/skills/c64-emulator/SKILL.md +29 -8
- package/skills/c64-knowledge/SKILL.md +201 -15
- package/skills/c64-knowledge/scripts/knowledge.ts +927 -78
- package/skills/c64-knowledge/scripts/lib/listing.ts +162 -0
- package/skills/c64-memory-map/SKILL.md +14 -2
- package/skills/c64-memory-map/scripts/memmap.ts +15 -4
- package/skills/c64-provenance/SKILL.md +100 -11
- package/skills/c64-provenance/scripts/lib/compare.ts +152 -0
- package/skills/c64-provenance/scripts/lib/library.ts +584 -0
- package/skills/c64-provenance/scripts/lib/runtime.ts +191 -0
- package/skills/c64-provenance/scripts/lib/separate.ts +140 -0
- package/skills/c64-provenance/scripts/provenance.ts +477 -24
- package/skills/c64-reverse-engineering/SKILL.md +89 -11
- package/skills/c64-source/SKILL.md +174 -0
- package/skills/c64-source/scripts/generate.ts +788 -0
- package/skills/c64-source/scripts/lib/loader.ts +630 -0
- package/skills/c64-source/scripts/lib/source.ts +1121 -0
- package/skills/c64-static-analysis/SKILL.md +53 -13
- package/skills/c64-static-analysis/scripts/analyze.ts +260 -31
- package/skills/c64-static-analysis/scripts/lib/coverage.ts +72 -0
- package/skills/c64-static-analysis/scripts/{findings.ts → lib/findings.ts} +11 -5
- package/skills/c64-static-analysis/scripts/lib/idioms.ts +158 -0
- package/skills/c64-static-analysis/scripts/lib/instructions.ts +105 -0
- package/skills/c64-static-analysis/scripts/lib/macros.ts +233 -0
- package/skills/c64-static-analysis/scripts/lib/pitfalls.ts +68 -0
- package/skills/c64-static-analysis/scripts/lib/pointers.ts +108 -0
- package/skills/c64-testing/SKILL.md +57 -4
- package/skills/c64-testing/references/scenario-format.md +50 -6
- package/skills/c64-testing/scripts/checklist.ts +3 -3
- package/skills/c64-testing/scripts/diff.ts +167 -0
- package/skills/c64-testing/scripts/lib/diff.ts +70 -0
- package/skills/c64-testing/scripts/{scenario.ts → lib/scenario.ts} +183 -152
- package/skills/c64-testing/scripts/run.ts +241 -0
- package/skills/c64-testing/scripts/test.ts +20 -10
- package/skills/c64-unpacker/SKILL.md +88 -21
- package/skills/c64-unpacker/scripts/lib/evidence.ts +207 -0
- package/skills/c64-unpacker/scripts/lib/loads.ts +209 -0
- package/skills/c64-unpacker/scripts/lib/machine.ts +80 -0
- package/skills/c64-unpacker/scripts/lib/stages.ts +142 -0
- package/skills/c64-unpacker/scripts/unpack.ts +545 -60
- package/src/c64.ts +240 -12
- package/src/cli/cleanup.ts +1 -1
- package/src/cli/main.ts +14 -8
- package/src/cli/status.ts +105 -11
- package/src/graphics.ts +158 -0
- package/src/host/main.ts +57 -31
- package/src/host/server.ts +30 -47
- package/src/host/tools/c1541.ts +34 -5
- package/src/host/tools/index.ts +6 -2
- package/src/host/tools/petcat.ts +10 -3
- package/src/host/tools/status.ts +23 -6
- package/src/host/vice/adapter.ts +64 -20
- package/src/host/vice/chips.ts +11 -1
- package/src/host/vice/process.ts +19 -8
- package/src/host/vice/screen.ts +4 -44
- package/src/host/vice/session.ts +343 -60
- package/src/host-client/autostart.ts +55 -0
- package/src/host-client/connect.ts +14 -14
- package/src/host-client/coverage.ts +63 -0
- package/src/host-client/image.ts +66 -0
- package/src/host-client/steps.ts +175 -0
- package/src/host-client/tools.ts +7 -6
- package/src/host-client/transfer.ts +60 -10
- package/src/host-client/vice-session.ts +107 -28
- package/src/knowledge/conflicts.ts +161 -0
- package/src/knowledge/database.ts +150 -38
- package/src/knowledge/expression.ts +209 -0
- package/src/knowledge/graph.ts +104 -0
- package/src/knowledge/history.ts +105 -27
- package/src/knowledge/import.ts +141 -85
- package/src/knowledge/join.ts +211 -0
- package/src/knowledge/program.ts +258 -0
- package/src/knowledge/read.ts +445 -63
- package/src/knowledge/schema.ts +277 -65
- package/src/knowledge/text.ts +415 -0
- package/src/knowledge/write.ts +1145 -150
- package/src/mcp/main.ts +44 -19
- package/src/mcp/output.ts +39 -0
- package/src/mcp/server.ts +15 -4
- package/src/mcp/tools/debug.ts +203 -32
- package/src/mcp/tools/execution.ts +39 -5
- package/src/mcp/tools/input.ts +7 -4
- package/src/mcp/tools/machine.ts +14 -2
- package/src/mcp/tools/media.ts +44 -16
- package/src/mcp/tools/memory.ts +68 -12
- package/src/mcp/tools/video.ts +20 -9
- package/src/native/discover.ts +44 -6
- package/src/native/ghidra/analyze.ts +2 -2
- package/src/native/ghidra/index.ts +19 -3
- package/src/native/ghidra/language/c64rt_6510.slaspec +4 -1
- package/src/native/ghidra/scripts/C64Export.java +33 -1
- package/src/native/ghidra/scripts/C64Prepare.java +7 -1
- package/src/native/status.ts +15 -3
- package/src/native/types.ts +43 -8
- package/src/opcodes.ts +137 -0
- package/src/package.ts +21 -0
- package/{skills/c64-memory-map/scripts → src}/platform.ts +87 -7
- package/src/project.ts +166 -3
- package/src/protocol/messages.ts +17 -10
- package/src/protocol/tools.ts +27 -8
- package/src/protocol/vice.ts +255 -33
- package/src/script.ts +49 -9
- package/src/trace.ts +55 -23
- package/skills/c64-provenance/scripts/compare.ts +0 -92
- package/skills/c64-unpacker/scripts/evidence.ts +0 -135
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-knowledge
|
|
3
|
-
description: Use this skill to read, write, correct and review the durable knowledge of a C64 project in .c64-re-tools/knowledge.
|
|
3
|
+
description: Use this skill to read, write, correct and review the durable knowledge of a C64 project in .c64-re-tools/knowledge/. The knowledge holds the program, its entry state and the coverage of the runs. It gives the knowledge at an address, and it names symbols, classifies memory regions, sets comments and records references. It records patches and macros for the generated source. It also shows the history of each change, and it can revert to an earlier revision. Do not use it for live emulator state or for static analysis.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# c64-knowledge
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
9
|
|
|
10
|
-
Read, write, correct and review the durable understanding of a C64 project. The knowledge is in `.c64-re-tools/knowledge.db`
|
|
10
|
+
Read, write, correct and review the durable understanding of a C64 project. The knowledge also holds the program: its bytes, its entry state and the stages of its unpacker. It holds the coverage of the runs too. The other skills read the program and the coverage from the knowledge. The knowledge is text in `.c64-re-tools/knowledge/` in the project folder: one JSON line for each row. Commit that folder with git. The script keeps an index of the text in `.c64-re-tools/local/knowledge.db` and makes the index again when the text changes. Do not commit the index.
|
|
11
11
|
|
|
12
|
-
This skill is the only write path for conclusions of the user and the LLM. It does not run an emulator or an analyzer.
|
|
12
|
+
This skill is the only write path for conclusions of the user and the LLM. It does not run an emulator or an analyzer. Write the knowledge only with the script. The script checks each write. Do not write or edit the files in `.c64-re-tools/knowledge/` or the index yourself.
|
|
13
13
|
|
|
14
14
|
## Inputs
|
|
15
15
|
|
|
@@ -18,50 +18,233 @@ One of these:
|
|
|
18
18
|
- an address, a range or a symbol name to look up
|
|
19
19
|
- text to search for
|
|
20
20
|
- a change to a symbol, a region, a comment or a reference, with a short reason
|
|
21
|
+
- a capture of the c64-unpacker skill, a PRG, or coverage maps to put into the knowledge
|
|
21
22
|
- a request to see the history or a revision.
|
|
22
23
|
|
|
23
24
|
## Tools / execution path
|
|
24
25
|
|
|
25
|
-
Run the script in the project directory. The project directory is the directory that the harness started in.
|
|
26
|
-
|
|
27
26
|
```
|
|
28
27
|
node <skill>/scripts/knowledge.ts <command> [arguments] [options]
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
The script prints one JSON object. An error prints `{"error": {"code": ..., "message": ...}}`. Addresses are `$` and four hex digits. Quote them in a shell, for example `'$2100'`.
|
|
30
|
+
The script prints one JSON object. An error prints `{"error": {"code": ..., "message": ...}}`. Addresses are `$` and four hex digits. Quote them in a shell, for example `'$2100'`. A name also gives an address, for example `at update_player`. The script tries the symbols first and then the analyzer names.
|
|
31
|
+
|
|
32
|
+
A symbol is the name of an address from the user or the LLM. An analyzer name is a second name from DXA, Ghidra or an idiom, for example `FUN_17e2`. Each analyzer keeps its own name at an address. `at`, `search` and `export` show the analyzer names. The generated source uses only the symbols, unless c64-source gets `--analyzer-names`. To use an analyzer name in the source, `rename` the address with it.
|
|
32
33
|
|
|
33
34
|
| Need | Command |
|
|
34
35
|
|---|---|
|
|
35
36
|
| Everything known at one address | `at '$2100'` |
|
|
36
37
|
| Find names and comment text | `search player` |
|
|
37
38
|
| Lists in a range | `symbols`, `regions`, `comments`, `references` with `--start` and `--end` |
|
|
39
|
+
| The names that DXA, Ghidra and the idioms gave | `symbols --analyzer` |
|
|
40
|
+
| Only some origins | add `--origin semantic`, `--origin analyzer` (dxa, ghidra and heuristic), or `--origin user,llm` |
|
|
41
|
+
| All knowledge in one file | `export --out .c64-re-tools/local/knowledge.json` |
|
|
42
|
+
| Put the program into the knowledge | `image .c64-re-tools/local/capture/image.json` or `image original/game.prg` |
|
|
43
|
+
| Add the coverage of runs | `coverage .c64-re-tools/local/runs/rooms/room0.bin ...` |
|
|
44
|
+
| What the knowledge holds of the program | `program` |
|
|
45
|
+
| The code of a range with names, comments, access and references | `listing '$0400' '$04ff'` |
|
|
38
46
|
| Name the symbol at an address | `rename '$2100' update_player --kind routine` |
|
|
39
47
|
| Remove a symbol | `remove-symbol '$2100'` |
|
|
40
48
|
| Classify memory | `classify '$3000' '$303f' sprite` |
|
|
41
|
-
|
|
|
49
|
+
| Classify a table of records | `classify '$3000' '$303b' bytes --element 6` |
|
|
50
|
+
| Many writes as one revision | `apply -` with the JSON on standard input, or `apply <file>` |
|
|
51
|
+
| One batch from the batches of parallel agents | `join a.json b.json --out .c64-re-tools/local/joined.json` |
|
|
52
|
+
| Make memory unknown, and keep the analyzers out of it | `unclassify '$3000' '$303f'` |
|
|
42
53
|
| Set or remove a comment | `comment '$2100' line Reads joystick 2.` / `uncomment '$2100' line` |
|
|
43
54
|
| Add or remove a reference | `reference '$2000' '$2100' call` / `unreference ...` |
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
| Places that a removal blocks | `suppressions` with `--start` and `--end` |
|
|
56
|
+
| Start a file of generated source | `module '$2000' player.asm --title 'Player movement'` / `unmodule '$2000'` |
|
|
57
|
+
| Write the operand of an instruction as an expression | `operand '$8079' --lo irq_handler` / `unoperand '$8079'` |
|
|
58
|
+
| Operand expressions | `operands` with `--start` and `--end` |
|
|
59
|
+
| Replace a range with code when a switch is on | `patch '$100e' '$1010' CRACK --code-file crack.asm` / `unpatch '$100e'` |
|
|
60
|
+
| Patches and switches | `patches` with `--switch`, and `switches` |
|
|
61
|
+
| Write a macro | `macro inc16 --params dst --body-file inc16.asm` / `unmacro inc16` |
|
|
62
|
+
| Write instructions as one use of a macro | `use '$1005' '$100a' inc16 --args ptr` / `unuse '$1005'` |
|
|
63
|
+
| Macros and their uses | `macros`, and `uses` with `--start`, `--end` and `--macro` |
|
|
64
|
+
| Files of generated source | `modules` |
|
|
65
|
+
| The address spaces that hold knowledge | `spaces` |
|
|
66
|
+
| History | `history '$2100'`, `history --name update_player`, `history --macro inc16`, `revisions`, `revision 20261015T2145` |
|
|
67
|
+
| Go back to an earlier state | `revert 20261015T2145` |
|
|
68
|
+
| Decide the conflicts after a git merge | `merge --reason 'merge of two computers'` |
|
|
69
|
+
|
|
70
|
+
A revision has an id such as `20261015T214501.123-k3f9qz`. The id starts with the date and time. A command takes the full id, or a start of the id that only one revision has. The revision `0` is the knowledge before the first revision.
|
|
71
|
+
|
|
72
|
+
Every command takes `--space`: `c64` (the default), `drive8` for code in the 1541 drive, or `bank0` to `bank255` for cartridge banks. Drive code and banks use the same addresses as the C64, so each space has its own knowledge. A name is unique inside one space. In a batch, a write can name its own `space`.
|
|
73
|
+
|
|
74
|
+
Symbol kinds are `label`, `routine`, `variable`, `data` and `vector`. Reference kinds are `call`, `jump`, `read`, `write`, `reference` and `pointer`. Only an operand expression writes a `pointer` reference.
|
|
75
|
+
|
|
76
|
+
Region types:
|
|
77
|
+
|
|
78
|
+
| Type | Meaning |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `code` | Instructions. |
|
|
81
|
+
| `bytes`, `words`, `petscii`, `screen`, `bitmap`, `sprite` | Data of that form. |
|
|
82
|
+
| `charset` | Characters of a character set, 8 bytes for each character. |
|
|
83
|
+
| `addresses`, `addresses-split` | A table of addresses: one table of 16-bit values, or a low-byte table and then a high-byte table. |
|
|
84
|
+
| `rts-addresses`, `rts-addresses-split` | The same, with each value the target minus 1, for a PHA, PHA, RTS dispatch. |
|
|
85
|
+
| `jumps` | A table of `JMP abs` instructions. Each 3-byte entry is an entry point. It is code. |
|
|
86
|
+
| `workspace` | RAM that the program writes at run time. Its bytes in the image do not matter. |
|
|
87
|
+
| `unused` | Bytes that nothing executes or reads. |
|
|
88
|
+
| `dual-use` | Code at one time and data or a vector at another time. No analyzer finding conflicts with it. |
|
|
89
|
+
|
|
90
|
+
`--element` gives the bytes of one element of a table. The length of the region must be a multiple of it. The result shows `element` and `count`.
|
|
91
|
+
|
|
92
|
+
### Project folder
|
|
93
|
+
|
|
94
|
+
- Paths are relative to the project folder. The project folder is the nearest folder at or above the working directory that holds `.c64-re-tools/`.
|
|
95
|
+
- If the working directory is not in a project and has projects below it, the script refuses and lists them. Then give `--project <folder>` to each script.
|
|
96
|
+
- 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.
|
|
97
|
+
- Move a file out of `.c64-re-tools/local/` only when it is the evidence for a finding. Move it before you give it to `--evidence` of c64-knowledge. `--evidence` refuses a file in `.c64-re-tools/local/`.
|
|
98
|
+
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and the snapshot files that it uses. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
99
|
+
- 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`.
|
|
48
100
|
|
|
49
101
|
## Workflow
|
|
50
102
|
|
|
51
103
|
Read:
|
|
52
104
|
|
|
53
105
|
1. Use `at` for the addresses in the question before other work.
|
|
54
|
-
2. Use `history` when the current knowledge is surprising or disputed.
|
|
106
|
+
2. Use `history` when the current knowledge is surprising or disputed. Each row gives the `reason` and the `evidence` of the revision that wrote it.
|
|
55
107
|
|
|
56
108
|
Write:
|
|
57
109
|
|
|
58
110
|
1. Read the current value with `at`. Note the `revision` in the result.
|
|
59
111
|
2. Decide the change. Keep observed facts apart from your conclusions.
|
|
60
|
-
3. Write it with `--reason` and `--expect-revision` set to the revision you read.
|
|
112
|
+
3. Write it with `--reason` and `--expect-revision` set to the revision you read. Add `--evidence` for each thing that the change rests on: `coverage:<map>`, `test:<file>`, `file:<file>` or `note:<text>`. `<map>` is a coverage map that `coverage` put into the knowledge, by its path at that time. The script keeps the SHA-256 of each file and map.
|
|
61
113
|
4. Read the result. A `revision` of `null` means that nothing changed.
|
|
62
114
|
|
|
63
115
|
Each write is one revision. A classification inside a region splits that region, so regions never overlap.
|
|
64
116
|
|
|
117
|
+
## The program and the coverage
|
|
118
|
+
|
|
119
|
+
The knowledge holds the program, so a project needs no image or coverage files. The other skills read them from the knowledge and take no path to them.
|
|
120
|
+
|
|
121
|
+
1. Capture a packed program with the c64-unpacker skill into `.c64-re-tools/local/`. Then put it in with `image .c64-re-tools/local/capture/image.json`. The script reads `image.bin`, `entry_state.json` and the stages next to it.
|
|
122
|
+
2. For a program without a packer, drive code or a cartridge bank, put the PRG in with `image <file.prg>`. Give `--space drive8` or `--space bank0` for drive code or a bank.
|
|
123
|
+
3. Write each coverage map of a run into `.c64-re-tools/local/`. Then add it with `coverage <map.bin> ...`.
|
|
124
|
+
4. Read what the knowledge holds with `program`: the segments, the entry, and the coverage maps that it has.
|
|
125
|
+
|
|
126
|
+
- `image` writes only the bytes that changed. The same image again writes nothing. A new image replaces the program of the space. The history keeps the old bytes.
|
|
127
|
+
- `coverage` joins the maps. It keeps each address that a run executed, read or wrote. It also keeps each address that one run wrote and executed: self-modified code. A map that the knowledge has is not added again.
|
|
128
|
+
- The capture and the maps are not necessary after the import. Keep them in `.c64-re-tools/local/`.
|
|
129
|
+
|
|
130
|
+
For more than a few writes, use `apply -` and give the writes on standard input as one JSON list. Each write has `op` and the arguments of the command with the same name, for example:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
[
|
|
134
|
+
{ "op": "rename", "address": "$2100", "name": "update_player", "kind": "routine" },
|
|
135
|
+
{ "op": "classify", "start": "$3000", "end": "$303b", "type": "bytes", "element": 6 },
|
|
136
|
+
{ "op": "comment", "address": "$2100", "placement": "line", "text": "Reads joystick 2." }
|
|
137
|
+
]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The ops and their fields:
|
|
141
|
+
|
|
142
|
+
| op | Fields |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `rename` | `address`, `name`, `kind` (optional) |
|
|
145
|
+
| `remove-symbol` | `address` |
|
|
146
|
+
| `classify` | `start`, `end`, `type`, `element` (optional) |
|
|
147
|
+
| `unclassify` | `start`, `end` |
|
|
148
|
+
| `comment` | `address`, `placement` (`line` or `side`), `text` |
|
|
149
|
+
| `uncomment` | `address`, `placement` |
|
|
150
|
+
| `reference`, `unreference` | `from`, `to`, `kind` |
|
|
151
|
+
| `module` | `start`, `file`, `title` (optional) |
|
|
152
|
+
| `unmodule` | `start` |
|
|
153
|
+
| `operand` | `address`, `select` (`lo`, `hi`, `value` or `expr`), `symbol` and `offset` (optional), or `expression` for `expr` |
|
|
154
|
+
| `unoperand` | `address` |
|
|
155
|
+
| `patch` | `start`, `end`, `switch`, `code` (empty for NOP only), `comment` (optional) |
|
|
156
|
+
| `unpatch`, `unuse` | `start` |
|
|
157
|
+
| `macro` | `name`, `params` (a list or a comma list), `body`, `comment` (optional) |
|
|
158
|
+
| `unmacro` | `name` |
|
|
159
|
+
| `use` | `start`, `end`, `macro`, `args` (a list or a comma list) |
|
|
160
|
+
|
|
161
|
+
A `line` comment is a line of its own above the address. A `side` comment is at the end of the line of the address. The script checks an `operand`, `patch` or `use` write against the program of the knowledge in the space of `--space`. All writes become one revision. If the knowledge refuses one write, the script writes nothing, and the error names the write.
|
|
162
|
+
|
|
163
|
+
The c64-provenance skill writes a batch with `match --out`. The batch holds the names of library routines at their addresses in this program. Read the `batch.leftOut` of its result first. Then apply the batch with the command in its `apply`.
|
|
164
|
+
|
|
165
|
+
## Listing
|
|
166
|
+
|
|
167
|
+
`listing` reads the program and the other knowledge, and writes no knowledge. Use it in place of your own disassembler.
|
|
168
|
+
|
|
169
|
+
- `listing` gives one line for each instruction of a code region, and one `!byte` line for other bytes. A line has the name of the address, the instruction with the names of its target, and the comments. An operand expression of the knowledge replaces the operand. `analyzerNames` gives the second names. `referencesIn` and `referencesOut` count the references. When the knowledge has coverage, `access` tells if a run executed (`x`), read (`r`) or wrote (`w`) the bytes of the line, or `-` for none. `--out` writes the listing as text to a project file.
|
|
170
|
+
|
|
171
|
+
## Batches of parallel agents
|
|
172
|
+
|
|
173
|
+
When more agents name the program at the same time, give each agent one range of addresses. Each agent writes one batch file and does not apply it. A batch of an agent has the form `{"owner": "$1000-$1fff", "ops": [...]}`. `ops` holds the writes, as for `apply`. The owner ranges must not overlap.
|
|
174
|
+
|
|
175
|
+
`join` makes one batch from the batch files. It writes no knowledge.
|
|
176
|
+
|
|
177
|
+
- At an address in the owner range of a batch, the name, the comment, the operand and the module of that batch stay. At an address that no batch owns, the first batch in the command stays.
|
|
178
|
+
- A batch can give an address a name that `join` replaces. Then `join` also replaces that name in the operand expressions and macro args of that batch.
|
|
179
|
+
- The regions of the owner come after the regions of the other batches. Thus the regions of the owner stay where they overlap.
|
|
180
|
+
- A name from a batch stays when another batch removes the symbol at that address.
|
|
181
|
+
- `choices` lists each place where the batches gave different values, with the value that stays.
|
|
182
|
+
- When one name or one module file is at two addresses, `join` writes nothing. `clashes` lists the addresses and the batches. Correct the batches, then do `join` again.
|
|
183
|
+
|
|
184
|
+
Then apply the joined batch with the command in `apply`.
|
|
185
|
+
|
|
186
|
+
## Modules
|
|
187
|
+
|
|
188
|
+
A module tells the c64-source skill where a file of the generated source starts. The file runs to the next module or to the end of its segment. Each address has one module, and each file name has one module. A file name has letters, digits, underscores or hyphens, and ends in `.asm`. The c64-source skill writes `main.asm`, `loader.asm`, `constants.asm` and `macros.asm` itself. Thus a module cannot have one of these names, in upper or lower case. The title becomes the first line of the file. A `module` write without a title keeps the title that the module has. Modules have a history, and `revert` restores them.
|
|
189
|
+
|
|
190
|
+
## Operand expressions
|
|
191
|
+
|
|
192
|
+
An operand expression tells the c64-source skill how to write the operand of one instruction. The source then has a name, not a number. When code or data changes its length, the operand follows the address that moved.
|
|
193
|
+
|
|
194
|
+
Give one selector:
|
|
195
|
+
|
|
196
|
+
| Option | Operand | Source |
|
|
197
|
+
|---|---|---|
|
|
198
|
+
| `--lo <symbol>` | The low byte of the symbol plus the offset | `lda #<irq_handler` |
|
|
199
|
+
| `--hi <symbol>` | The high byte of the symbol plus the offset | `lda #>(sprite_bank+$1000)` |
|
|
200
|
+
| `--value <symbol>` | The symbol plus the offset | `lda bar_colours-1,x` |
|
|
201
|
+
| `--expr <text>` | ACME expression text with names and numbers | `lda #(sprite_bank + 5*64) / 64` |
|
|
202
|
+
|
|
203
|
+
- `--offset` adds a whole number to the symbol. Write a negative offset as `--offset=-1`.
|
|
204
|
+
- A name is a symbol of the knowledge or a platform name of the c64-memory-map skill.
|
|
205
|
+
- `--expr` takes `$`, `%` and decimal numbers, names, brackets, the operators `+ - * / % << >> >>> & | XOR`, and `<`, `>`, `-` and `!` before an operand.
|
|
206
|
+
- The script compares the value of the expression with the operand in the program of the knowledge. If they are not equal, the script refuses the write.
|
|
207
|
+
- Each name in the expression gets a `pointer` reference from the instruction. Thus `at` on the named address shows the code that uses the address.
|
|
208
|
+
- A `rename` of a symbol changes the name in each expression. The knowledge refuses `remove-symbol` while an expression uses the symbol. Use `unoperand` first.
|
|
209
|
+
|
|
210
|
+
Write an operand expression for each immediate that is a byte of an address. Also write one for each table read through the byte before the table. The pointer candidates of the c64-static-analysis skill show many of these places.
|
|
211
|
+
|
|
212
|
+
## Code switches
|
|
213
|
+
|
|
214
|
+
A patch is ACME code that replaces a range of the program when the build defines its switch as 1. Use patches to change the program, for example for a crack, a trainer or a debug hook. The default build does not define the switch. Thus the c64-source skill still makes a source that is identical to the program.
|
|
215
|
+
|
|
216
|
+
- A switch name is upper case, for example `CRACK` or `TRAINER`. It cannot be the name of a symbol or a platform name.
|
|
217
|
+
- Many patches can have the same switch. The c64-source skill builds each switch on its own. It does not build two switches together.
|
|
218
|
+
- The code must fit in the range. NOP ($EA) fills the bytes after the code. `--nop` gives a range of NOP only.
|
|
219
|
+
- `--code` gives the code as text. `--code-file` reads the code from a project file. The code can use the labels and the macros of the source, and local labels with a dot, for example `.skip`.
|
|
220
|
+
- The braces in the code must be pairs, because the source puts the code inside `{ }`.
|
|
221
|
+
- A patch cannot overlap another patch or a macro use.
|
|
222
|
+
- Each byte of the range must be in the program of the knowledge.
|
|
223
|
+
- A `patch` write without `--comment` keeps the comment that the patch has.
|
|
224
|
+
|
|
225
|
+
Build the program with a switch on with the c64-assembler skill: `--define CRACK=1`.
|
|
226
|
+
|
|
227
|
+
## Macros
|
|
228
|
+
|
|
229
|
+
A macro writes a run of instructions as one line of the source, for example `+inc16 ptr`. Use macros to make the source shorter and easier to read.
|
|
230
|
+
|
|
231
|
+
- `macro` writes the ACME macro: its name, its params and its body. `--params` gives the params as a comma list, without a dot. The body uses each param with a dot, for example `.dst`.
|
|
232
|
+
- `use` writes the instructions from the start to the end as one use of a macro. `--args` gives one expression for each param, as a comma list. Each name in an arg is a symbol of the knowledge or a platform name.
|
|
233
|
+
- The range of a use is complete instructions of the program of the knowledge.
|
|
234
|
+
- A `rename` of a symbol changes the name in each arg. The knowledge refuses `remove-symbol` while an arg uses the symbol.
|
|
235
|
+
- The knowledge refuses `unmacro` while the macro has uses. It also refuses a change of the number of params while the macro has uses.
|
|
236
|
+
- A use cannot overlap a patch or another use.
|
|
237
|
+
|
|
238
|
+
The c64-source skill writes a use only when the use gives the bytes of the program. If not, it writes the instructions and gives the reason. The c64-static-analysis skill finds uses of known 6502 idioms and writes them to a batch with `--macro-batch`.
|
|
239
|
+
|
|
240
|
+
## Removals
|
|
241
|
+
|
|
242
|
+
`unclassify` and `unreference` block the place for DXA and Ghidra. An analysis does not add a region in that range or that reference again. This applies to every removed fact, also to a fact from the LLM. `remove-symbol` does not block the address, because an analyzer name never becomes a symbol.
|
|
243
|
+
|
|
244
|
+
- `suppressions` lists the blocked places with the reason of each removal. `at` and `history` also show them.
|
|
245
|
+
- A `rename`, `classify` or `reference` at a blocked place ends the block there, because your own fact is at the place then.
|
|
246
|
+
- A `revert` to a revision before the removal also ends the block.
|
|
247
|
+
|
|
65
248
|
## Knowledge
|
|
66
249
|
|
|
67
250
|
Write after interpretation:
|
|
@@ -83,7 +266,7 @@ The script records the origin `llm`. Use `--origin user` only when the user deci
|
|
|
83
266
|
|
|
84
267
|
For a read: the current or historical knowledge in compact JSON.
|
|
85
268
|
|
|
86
|
-
For a write: the new revision and the current value after the write. If the write replaces a symbol
|
|
269
|
+
For a write: the new revision and the current value after the write. If the write replaces a symbol, a region or an operand expression of a different origin, `previous` gives that row as it was before the write. For example, an `llm` write over a `user` name gives `previous`. Read `previous` and tell the user about the change. For `apply`, `replaced` lists each write that replaced a row. Each item has the number of the write, its `op` and its `previous`.
|
|
87
270
|
|
|
88
271
|
The exit status is 0 for a result. The exit status is 1 for an error from the knowledge, for example `conflict`. The exit status is 2 for a wrong argument.
|
|
89
272
|
|
|
@@ -92,7 +275,8 @@ The exit status is 0 for a result. The exit status is 1 for an error from the kn
|
|
|
92
275
|
- `conflict`: the change contradicts current knowledge. For example, the name belongs to another address. Read that address and its history, then decide.
|
|
93
276
|
- `stale-revision`: the knowledge changed after you read it. Read it again, then decide again.
|
|
94
277
|
- `not-found`: there is nothing to remove or no such revision.
|
|
95
|
-
- `
|
|
278
|
+
- `conflict` with "from a git merge": git joined the knowledge of two computers, and two rows are current where the knowledge permits one row. For example, two names are at one address. Every read shows these rows in `conflicts`. Writes stop until you run `merge`. The `merge` command keeps the newest row of each conflict and closes the other rows, in one revision. Its result lists each choice. Tell the user the choices.
|
|
279
|
+
- `invalid-database` or `unsupported-schema`: tell the user the message. Do not edit the knowledge files.
|
|
96
280
|
|
|
97
281
|
A revert makes a new revision. The history stays complete.
|
|
98
282
|
|
|
@@ -100,3 +284,5 @@ A revert makes a new revision. The history stays complete.
|
|
|
100
284
|
|
|
101
285
|
- Runtime evidence → c64-emulator
|
|
102
286
|
- Static evidence → c64-static-analysis
|
|
287
|
+
- Source from the knowledge → c64-source
|
|
288
|
+
- Names of routines that other programs share → c64-provenance
|