@henols/c64-re-tools 2.2.1 → 2.3.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/README.md +4 -3
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +4 -3
- package/skills/c64-assembler/scripts/assembler.ts +1 -1
- package/skills/c64-basic/SKILL.md +3 -3
- package/skills/c64-development/SKILL.md +9 -9
- package/skills/c64-disk/SKILL.md +2 -2
- package/skills/c64-docs/SKILL.md +2 -2
- package/skills/c64-knowledge/SKILL.md +1 -1
- package/skills/c64-memory-map/SKILL.md +2 -2
- package/skills/c64-packer/SKILL.md +109 -0
- package/skills/c64-packer/scripts/packer.ts +95 -0
- package/skills/c64-provenance/SKILL.md +18 -5
- package/skills/c64-provenance/scripts/lib/compare.ts +144 -16
- package/skills/c64-provenance/scripts/provenance.ts +37 -8
- package/skills/c64-reverse-engineering/SKILL.md +3 -3
- package/skills/c64-source/SKILL.md +23 -2
- package/skills/c64-source/scripts/lib/loader.ts +281 -43
- package/skills/c64-source/scripts/source.ts +37 -9
- package/skills/c64-static-analysis/SKILL.md +3 -3
- package/skills/c64-testing/SKILL.md +4 -4
- package/skills/c64-testing/scripts/lib/play.ts +4 -4
- package/skills/c64-testing/scripts/testing.ts +1 -1
- package/skills/c64-unpacker/SKILL.md +8 -8
- package/skills/c64-unpacker/scripts/lib/loads.ts +17 -4
- package/skills/c64-unpacker/scripts/unpacker.ts +15 -3
- package/skills/emulator/SKILL.md +137 -0
- package/src/cli/main.ts +1 -1
- package/{skills/c64-assembler/scripts/lib → src}/compare.ts +21 -3
- package/src/host-client/coverage.ts +26 -0
- package/src/mcp/output.ts +4 -4
- package/src/mcp/server.ts +7 -2
- package/src/mcp/tools/debug.ts +6 -3
- package/src/mcp/tools/execution.ts +1 -0
- package/src/mcp/tools/input.ts +1 -0
- package/src/mcp/tools/machine.ts +1 -1
- package/src/mcp/tools/media.ts +4 -2
- package/src/native/discover.ts +8 -0
- package/src/native/exomizer.ts +90 -0
- package/src/native/status.ts +3 -2
- package/tools/install-container.sh +2 -1
- package/tools/install-exomizer.sh +70 -0
- package/skills/c64-emulator/SKILL.md +0 -160
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
Let an AI agent work on Commodore 64 programs. The agent drives a real VICE
|
|
7
|
-
emulator and runs ACME, DXA and
|
|
7
|
+
emulator and runs ACME, DXA, Ghidra and Exomizer. Use it to build new C64 apps and games,
|
|
8
8
|
and to reverse engineer old ones.
|
|
9
9
|
|
|
10
10
|
It works with Claude Code, Codex, pi, opencode, Gemini, Copilot, Cursor and
|
|
@@ -17,6 +17,7 @@ Ask for what you want in plain words. The agent picks the skill for each step.
|
|
|
17
17
|
**Build new apps and games**
|
|
18
18
|
|
|
19
19
|
- Assemble 6510 source with ACME, with errors by file and line, and symbols.
|
|
20
|
+
- Pack and crunch a program with Exomizer into one PRG that unpacks itself, checked byte for byte before it is written.
|
|
20
21
|
- Load and run the program in VICE. Set breakpoints and watchpoints, step, and read the CPU history and the call stack.
|
|
21
22
|
- Read, write, search and compare memory, and disassemble it.
|
|
22
23
|
- Show the VIC-II, sprite, SID and CIA state, and capture the screen.
|
|
@@ -42,7 +43,7 @@ Ask for what you want in plain words. The agent picks the skill for each step.
|
|
|
42
43
|
|
|
43
44
|
VICE and the Host Runtime run on your computer, where VICE can open a window.
|
|
44
45
|
The agent runs in a dev container in your project. It reaches VICE through an
|
|
45
|
-
MCP server, and it runs ACME, DXA, Ghidra and c64run through its skills.
|
|
46
|
+
MCP server, and it runs ACME, DXA, Ghidra, Exomizer and c64run through its skills.
|
|
46
47
|
|
|
47
48
|
## Install
|
|
48
49
|
|
|
@@ -72,7 +73,7 @@ and the address of the Host Runtime. If the project already has a
|
|
|
72
73
|
|
|
73
74
|
Open the project in the container, for example with "Reopen in Container" in
|
|
74
75
|
VS Code, or with `npx -y @devcontainers/cli up --workspace-folder .`. The
|
|
75
|
-
Feature gives the container ACME, dxa, Java 21, Ghidra and c64run. At each
|
|
76
|
+
Feature gives the container ACME, dxa, Exomizer, Java 21, Ghidra and c64run. At each
|
|
76
77
|
start it installs the newest toolkit of its channel into the project, with the
|
|
77
78
|
tools of that version. It reads its options only when the container is built:
|
|
78
79
|
rebuild after a change.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-assembler
|
|
3
|
-
description: Use this skill to assemble C64 6510 source code with the ACME assembler and write the program (PRG) into the project. It reports source errors with file and line, and the symbols with their addresses or values. Use it to build a rebuilt or new program. Do not use it to run the program. Give the PRG to the
|
|
3
|
+
description: Use this skill to assemble C64 6510 source code with the ACME assembler and write the program (PRG) into the project. It reports source errors with file and line, and the symbols with their addresses or values. Use it to build a rebuilt or new program. Do not use it to run the program. Give the PRG to the emulator skill for that.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# c64-assembler
|
|
@@ -73,7 +73,7 @@ The target CPU is the 6510. The output is a C64 PRG, or the bytes only with `--p
|
|
|
73
73
|
- Kind `constant` has a value outside `loadRange`. It gives the `value` as `$` and four or more hex digits. A label in a `!pseudopc` block can be a constant, because its value is the run address, not the load address.
|
|
74
74
|
- `used` is `false` when the source does not use the symbol.
|
|
75
75
|
4. If `result` is `FAIL` and `assembled` is `false`, read `diagnostics`. Each one has a severity, a file, a line and a message. Correct the source and run the script again.
|
|
76
|
-
5. To run the program, give the PRG path to the
|
|
76
|
+
5. To run the program, give the PRG path to the emulator skill.
|
|
77
77
|
|
|
78
78
|
The source of the c64-source skill has switches in `config.asm`. Without an option, the build uses the values in `config.asm`. With the defaults, this is the clean program without copy protection, trainers, cheats and crack changes, and with all corrections. This build can differ from the program in the knowledge, so `--compare` can give `FAIL`. Use `--release <label> --compare` to check the build of a release. To put in the patches of the switch `TRAINER`, set `TRAINER = 1` in `config.asm`. Do not use `--define` for a switch: ACME stops with `Symbol already defined`.
|
|
79
79
|
|
|
@@ -109,6 +109,7 @@ With `--compare`, `compare` gives `identical` and `segments`: one check for each
|
|
|
109
109
|
|
|
110
110
|
## Handoffs
|
|
111
111
|
|
|
112
|
-
- Run or debug the program →
|
|
112
|
+
- Run or debug the program → emulator
|
|
113
113
|
- Compare the rebuild with the original → c64-testing
|
|
114
|
+
- Pack the program into one small PRG that unpacks itself → c64-packer
|
|
114
115
|
- Write a new program, or add a feature or a fix → c64-development
|
|
@@ -16,7 +16,7 @@ import { assemble, showSymbol, symbolsFileText } from "#src/native/acme.ts";
|
|
|
16
16
|
import { localToolContext } from "#src/native/local.ts";
|
|
17
17
|
import type { AcmeParams, AssembledSymbol } from "#src/native/types.ts";
|
|
18
18
|
import { listed as listedItems, OPTIONS, runScript, UsageError } from "#src/script.ts";
|
|
19
|
-
import { compareBuild, type Reference } from "
|
|
19
|
+
import { compareBuild, type Reference } from "#src/compare.ts";
|
|
20
20
|
|
|
21
21
|
function parseDefine(text: string): [string, number | boolean] {
|
|
22
22
|
const match = /^([A-Za-z_][A-Za-z0-9_]*)=(.+)$/.exec(text);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: c64-basic
|
|
3
|
-
description: Use this skill to decode a C64 BASIC V2 program (PRG) into a readable listing. It also finds where the BASIC gives control to machine code with SYS or USR. Use it on the start file of a game or of a demo. Do not use it on machine code or to run the program. Give the handoff address to the c64-static-analysis or
|
|
3
|
+
description: Use this skill to decode a C64 BASIC V2 program (PRG) into a readable listing. It also finds where the BASIC gives control to machine code with SYS or USR. Use it on the start file of a game or of a demo. Do not use it on machine code or to run the program. Give the handoff address to the c64-static-analysis or emulator skill.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# c64-basic
|
|
@@ -51,7 +51,7 @@ node <skill>/scripts/basic.ts list extracted/game.prg
|
|
|
51
51
|
2. Read `listing`. Each line starts with its BASIC line number. Keywords show in lower case. Control characters in strings show in braces, for example `{clr}`.
|
|
52
52
|
3. Read `handoffs`. Each handoff has a `kind` (`sys` or `usr`) and the BASIC `line`.
|
|
53
53
|
- A `sys` handoff with an `address`: BASIC calls the machine code at that address. The script calculates a SYS argument with numbers, π, `+`, `-`, `*`, `/` and brackets. For example, `SYS π*656` calls `$080c`.
|
|
54
|
-
- A handoff with `computed: true`: the address comes from a calculation at run time, for example with `PEEK`. A `sys` handoff gives its argument in `expression`. Use the
|
|
54
|
+
- A handoff with `computed: true`: the address comes from a calculation at run time, for example with `PEEK`. A `sys` handoff gives its argument in `expression`. Use the emulator skill to find the address.
|
|
55
55
|
4. Compare the address with `loadRange` and `basicEnd`. From `basicEnd` to the end of `loadRange`, the file holds bytes that are not BASIC. Usually this is the machine code that the handoff calls. Some programs have no end marker (two zero bytes) after the last line. The machine code starts directly after the last line. Then `basicEnd` is the first byte of that machine code.
|
|
56
56
|
|
|
57
57
|
The address ranges are for a load to the load address of the file. A load without `,1` puts a BASIC program at `$0801`. Most loaders have `$0801` as their load address.
|
|
@@ -80,5 +80,5 @@ The listing and the handoff addresses.
|
|
|
80
80
|
## Handoffs
|
|
81
81
|
|
|
82
82
|
- Machine code at the handoff address → c64-static-analysis
|
|
83
|
-
- Run the program to the handoff →
|
|
83
|
+
- Run the program to the handoff → emulator
|
|
84
84
|
- Record the entry point → c64-knowledge
|
|
@@ -24,7 +24,7 @@ This skill uses the other skills. It does not use the host runtime or the emulat
|
|
|
24
24
|
| Work | Skill |
|
|
25
25
|
|---|---|
|
|
26
26
|
| Assemble the source to a PRG, with errors and symbols | c64-assembler |
|
|
27
|
-
| Run, look, debug and measure |
|
|
27
|
+
| Run, look, debug and measure | emulator |
|
|
28
28
|
| Tests with expected values (`expect` steps in a run), and original against rebuild | c64-testing |
|
|
29
29
|
| The meaning of an address or a register, and an include of the platform names | c64-memory-map |
|
|
30
30
|
| Patches and switches of a rebuilt program, names and comments | c64-knowledge |
|
|
@@ -88,11 +88,11 @@ Do these steps for each small part of the program:
|
|
|
88
88
|
1. Find the meaning of each register with c64-memory-map. Make an include of the platform names with `memory-map.ts export --out src/hw.a`. Include it with `!source`. Do not type the addresses of registers yourself.
|
|
89
89
|
2. Write the code for one part.
|
|
90
90
|
3. Build it with c64-assembler: `assembler.ts build src main.a --out build/<name>.prg --out-symbols build/<name>.json`. Change the source at the file and the line of each error.
|
|
91
|
-
4. Start it with `c64_autostart` of
|
|
91
|
+
4. Start it with `c64_autostart` of the emulator skill. Look at the screen with `c64_screen`. Read the screen memory, not only the image.
|
|
92
92
|
5. Write the `expect` steps of this part in a run file. Give `"symbols": "build/<name>.json"`, so that a step can use the labels of the source.
|
|
93
93
|
6. Run all run files in `tests/` with `testing.ts run`. Go to the next part only when each run gives PASS.
|
|
94
94
|
|
|
95
|
-
To find a defect, use
|
|
95
|
+
To find a defect, use the emulator skill:
|
|
96
96
|
|
|
97
97
|
- Stop at the code with `c64_breakpoint`, or at a write to a variable with `c64_watchpoint`.
|
|
98
98
|
- Get to a state with `c64_run_until`.
|
|
@@ -101,13 +101,13 @@ To find a defect, use c64-emulator:
|
|
|
101
101
|
|
|
102
102
|
Find the cause before you change the code. Do not change code at random until a test passes.
|
|
103
103
|
|
|
104
|
-
When the user must play or look at the program, use the window procedure of
|
|
104
|
+
When the user must play or look at the program, use the window procedure of the emulator skill.
|
|
105
105
|
|
|
106
106
|
### B. A feature or a fix in source that a person wrote
|
|
107
107
|
|
|
108
108
|
1. Write a run file with an `expect` step that shows the defect or the missing feature.
|
|
109
109
|
2. Run it with `testing.ts run`. Make sure that it gives FAIL. A test that gives PASS before the change does not test the change.
|
|
110
|
-
3. For a defect, find the cause with
|
|
110
|
+
3. For a defect, find the cause with the emulator skill.
|
|
111
111
|
4. Change the source. Build it with c64-assembler.
|
|
112
112
|
5. Run the new run file and all other run files in `tests/`. Each run must give PASS.
|
|
113
113
|
|
|
@@ -120,7 +120,7 @@ A rebuilt program gets its source from the knowledge. A change is a switch and i
|
|
|
120
120
|
- A fix: `fix`, for example `FIX_FLICKER`. The default build has it.
|
|
121
121
|
- A trainer or a cheat: `trainer` or `cheat`. The default build does not have it.
|
|
122
122
|
- Another feature: `change`, for example `HISCORE`. Ask the user if the default build must have it. Give `--default 1` or `--default 0`.
|
|
123
|
-
3. Find the code to change with c64-knowledge (`at`, `regions`) and
|
|
123
|
+
3. Find the code to change with c64-knowledge (`at`, `regions`) and the emulator skill.
|
|
124
124
|
4. Write the code in a file in `.c64-re-tools/local/`. Write the patch with `knowledge.ts patch '<range>' <SWITCH> --code-file <file>` of c64-knowledge. The code must fit in the range.
|
|
125
125
|
5. If the code does not fit, write a short patch with a `jsr` to the new code. Put the new code in a second patch of the same switch, in a range that the program does not use. The range must have evidence: `provenance.ts leftovers` of c64-provenance, or code that no run executed and that the program cannot reach. If no range has this evidence, stop and ask the user.
|
|
126
126
|
6. Make the source again with `source.ts generate --out src` of c64-source. The checks `check`, `switches`, `default` and `releases` must pass. A switch must not give `overflow` or `does not assemble`.
|
|
@@ -162,14 +162,14 @@ A program that builds, with a run file in `tests/` for each acceptance check, an
|
|
|
162
162
|
- A skill reports `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not make a replacement for the tool or the host runtime, for example your own assembler or emulator script.
|
|
163
163
|
- A tool gives a wrong result: tell the user the defect and the evidence, and wait for the user. Do not make a workaround.
|
|
164
164
|
- A test gives FAIL: change the program until the test gives PASS. Do not change the expected value to make the test pass. Change an expected value only when the user changes the acceptance check.
|
|
165
|
-
- A run gives FAIL because a `runUntil` did not get to its target: the program did not get to that state. Find why with
|
|
166
|
-
- The program reads the keyboard hardware, and a key does not arrive: read the
|
|
165
|
+
- A run gives FAIL because a `runUntil` did not get to its target: the program did not get to that state. Find why with the emulator skill.
|
|
166
|
+
- The program reads the keyboard hardware, and a key does not arrive: read the description of `c64_keyboard`. Do not change the program to make it accept a key.
|
|
167
167
|
- A patch does not fit, and no unused range has evidence: stop and ask the user.
|
|
168
168
|
|
|
169
169
|
## Handoffs
|
|
170
170
|
|
|
171
171
|
- Assemble → c64-assembler
|
|
172
|
-
- Run, debug and measure →
|
|
172
|
+
- Run, debug and measure → emulator
|
|
173
173
|
- Tests with expected values, and original against rebuild → c64-testing
|
|
174
174
|
- The meaning of an address or a register → c64-memory-map
|
|
175
175
|
- Patches, names and comments → c64-knowledge
|
package/skills/c64-disk/SKILL.md
CHANGED
|
@@ -87,7 +87,7 @@ The script reads T64 and CRT files itself. The host runtime is not necessary for
|
|
|
87
87
|
- T64: `directory` and `read`. Many T64 files have a wrong end address. Then the entry has `fixedSize: true`, and the size comes from the position of the next file.
|
|
88
88
|
- CRT: `directory` and `crt`. The script reads hardware types 0 (normal 8K, 16K or Ultimax), 5 (Ocean), 19 (Magic Desk) and 32 (EasyFlash). It refuses other types by name. `crt` writes `crt.json` and one PRG for each CHIP packet, for example `bank3-8000.prg`.
|
|
89
89
|
- A cartridge bank uses the same addresses as other banks. Analyze each bank PRG with c64-static-analysis and `--space bank3`, and record its knowledge in space `bank3`.
|
|
90
|
-
- TAP: a TAP file holds tape signals, and turbo loaders have their own formats. The script does not read it. Start it with the
|
|
90
|
+
- TAP: a TAP file holds tape signals, and turbo loaders have their own formats. The script does not read it. Start it with the emulator skill, or capture its parts with `loads` of the c64-unpacker skill.
|
|
91
91
|
|
|
92
92
|
## Result
|
|
93
93
|
|
|
@@ -110,4 +110,4 @@ A file that is not `closed` was not written fully. Its data can be incomplete.
|
|
|
110
110
|
- Packed program → c64-unpacker
|
|
111
111
|
- Machine code, also a cartridge bank → c64-static-analysis
|
|
112
112
|
- A TAP file → c64-unpacker
|
|
113
|
-
- Run the program →
|
|
113
|
+
- Run the program → emulator
|
package/skills/c64-docs/SKILL.md
CHANGED
|
@@ -71,7 +71,7 @@ node <skill>/scripts/docs.ts link README.md docs --source src --check
|
|
|
71
71
|
3. Run `docs.ts generate`. Read `index.md` of the reference. A module with no routines, or a routine with no comment, shows what the knowledge does not have yet.
|
|
72
72
|
4. Make the plan of the pages. Start from the modules and the call graphs. Find the main loop, the interrupt chain, the dispatch tables, the state machines and the data formats. Each subsystem gets one page in `docs/`. The entry page `README.md` in the project folder lists the pages. Use the page types in `references/page-types.md`.
|
|
73
73
|
5. Collect the facts about the development and the copy protection. These facts are the most interesting parts for a reader, so look for them carefully. Read the leftover spaces and their comments in the knowledge. If the knowledge has none, run `provenance.ts leftovers` of c64-provenance. For two or more releases, run `provenance.ts compare` of c64-provenance to separate the program from the changes of each release. Find each check of the copy protection in the code, and the effect of a failed check. These facts go into the development section, the copy protection section and their pages. Do not examine the cracks in detail. They are not part of the program.
|
|
74
|
-
6. Write each page. Read the code and the knowledge for each fact. Run the program with c64-testing or
|
|
74
|
+
6. Write each page. Read the code and the knowledge for each fact. Run the program with c64-testing or the emulator skill when a fact needs a run. Explain each part before you name the code. Link only the main parts: write `` `draw_room` `$09BC` `` for a link, and `` `draw_room` `` for each other mention. Mark each fact with its evidence. Several subagents can write the pages at the same time, one page each. Give each subagent `references/page-types.md` and `references/style.md`.
|
|
75
75
|
7. Record each new fact in the knowledge first: a name, a comment, a region or a module. Then the source and the reference show it too. A fact only in a page is lost at the next change of the knowledge.
|
|
76
76
|
8. Run `docs.ts link`. Read `problems` and correct each one. Then run `docs.ts link --check`. Make sure that `result` is `PASS`.
|
|
77
77
|
9. When the project folder is in a workspace with other projects, find `README.md` at the root of the workspace. This page lists each program of the workspace. Add one row for the program, with a link to `<project>/README.md` and one sentence. If the page does not exist, make it. Use the workspace index in `references/page-types.md`. `docs.ts link` does not read this page, because the page is not in the project folder.
|
|
@@ -156,6 +156,6 @@ Do not store:
|
|
|
156
156
|
|
|
157
157
|
- Names, comments, regions and modules → c64-knowledge
|
|
158
158
|
- The source and its source map → c64-source
|
|
159
|
-
- A fact that needs a run → c64-testing or
|
|
159
|
+
- A fact that needs a run → c64-testing or emulator
|
|
160
160
|
- Leftovers, traces of the development and the differences of releases → c64-provenance
|
|
161
161
|
- What an address of the C64 is → c64-memory-map
|
|
@@ -357,7 +357,7 @@ A revert makes a new revision. The history stays complete.
|
|
|
357
357
|
|
|
358
358
|
## Handoffs
|
|
359
359
|
|
|
360
|
-
- Runtime evidence →
|
|
360
|
+
- Runtime evidence → emulator
|
|
361
361
|
- Static evidence → c64-static-analysis
|
|
362
362
|
- Source from the knowledge → c64-source
|
|
363
363
|
- Names of routines that other programs share → c64-provenance
|
|
@@ -65,7 +65,7 @@ Write a value for `decode` and `--bank` as `$` and hex digits, as a decimal numb
|
|
|
65
65
|
1. Run `at` for the addresses in the code or the question.
|
|
66
66
|
2. Read `kind`:
|
|
67
67
|
- `platform`: the C64 gives the address a meaning. Read `name` and `meaning`.
|
|
68
|
-
- `application`: the address has no platform meaning. The program decides its use. Find its use with the c64-static-analysis or
|
|
68
|
+
- `application`: the address has no platform meaning. The program decides its use. Find its use with the c64-static-analysis or emulator skill.
|
|
69
69
|
3. For an I/O register, `mirrorOf` shows the register that a mirror address repeats. `visible` tells that an address in `$D000`-`$DFFF` is visible only when `$01` shows I/O at `$D000`. This area holds the chip registers, the color RAM and the cartridge I/O areas.
|
|
70
70
|
4. For a byte in a multi-byte entry, for example the high byte of a vector, `entryStart` gives the first address of the entry.
|
|
71
71
|
5. To understand a value in a register, run `decode`. For the memory configuration, decode the value of `$01`.
|
|
@@ -95,5 +95,5 @@ Some registers have a different meaning for a read and for a write, for example
|
|
|
95
95
|
|
|
96
96
|
## Handoffs
|
|
97
97
|
|
|
98
|
-
- The value of an address at run time →
|
|
98
|
+
- The value of an address at run time → emulator
|
|
99
99
|
- A conclusion about the application → c64-knowledge
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: c64-packer
|
|
3
|
+
description: Use this skill to pack and crunch a C64 program with Exomizer into one PRG that unpacks itself and starts with RUN. It can merge more PRG files into one program. It unpacks the result in an emulator and checks each byte and the entry before it writes the PRG. Use it to make a small release file of a rebuilt or new program. Do not use it to unpack a packed program. Use the c64-unpacker skill for that.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# c64-packer
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Pack and crunch PRG files of the project with Exomizer into one PRG. The PRG loads at $0801, starts with RUN, unpacks the program and jumps to its entry. Check the result before you use it.
|
|
11
|
+
|
|
12
|
+
This skill does not assemble the program, does not run it in VICE and does not change project knowledge.
|
|
13
|
+
|
|
14
|
+
## Inputs
|
|
15
|
+
|
|
16
|
+
- One or more PRG files in the project, in load order. Where two files overlap, the later file wins.
|
|
17
|
+
- The output path: where to write the packed PRG, relative to the project folder.
|
|
18
|
+
- The entry: the address where the program starts after the unpack. If the first PRG is a BASIC program at $0801 with `SYS` and a number, the script uses that address.
|
|
19
|
+
- Optional: the value of $01 when the program starts.
|
|
20
|
+
|
|
21
|
+
## Tools / execution path
|
|
22
|
+
|
|
23
|
+
The script runs Exomizer on this machine. Exomizer packs the files with `sfx`. Then the script unpacks the result with `desfx` in the 6502 emulator of Exomizer. It compares the unpacked bytes with the bytes of the inputs, and the jump address with the entry. The host runtime is not necessary.
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
node <skill>/scripts/packer.ts pack build/game.prg --out build/game-packed.prg
|
|
27
|
+
node <skill>/scripts/packer.ts pack build/loader.prg build/main.prg --entry '$0400' --out build/release.prg
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Option | Meaning |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `--entry '$0400'` | The address where the program starts after the unpack. It must be `$0400` or higher. A name of the knowledge is also correct. Without it, the script uses the `SYS` address of the BASIC line of the first input. |
|
|
33
|
+
| `--exit-memory '$35'` | The value of $01 when the program starts, `$34` to `$37`. Without it, the value is `$37`: BASIC, KERNAL and I/O. With it, the program starts with interrupts off. |
|
|
34
|
+
|
|
35
|
+
### Calling the script
|
|
36
|
+
|
|
37
|
+
- Call a script as `node <skill>/scripts/<script>.ts <command> [subjects] [options]`. The command comes first.
|
|
38
|
+
- `<script>.ts --help` lists the commands. `<script>.ts <command> --help` gives the subjects and the options of one command. The help is JSON: `{"text": "..."}`.
|
|
39
|
+
- 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. Quote an address in a shell.
|
|
40
|
+
- A range is `<start>-<end>`, for example `'$c000-$cfff'`. In a JSON file, a range is `start` and `end`.
|
|
41
|
+
- Bytes in a JSON file are hex in a field `data`, for example `"data": "a900"`.
|
|
42
|
+
- The script examines each `--out` path before it starts work. It refuses a path in `.c64-re-tools/knowledge/` and the index of the knowledge, because only c64-knowledge writes them. It refuses a folder where the command writes a file, and a file where the command writes a folder.
|
|
43
|
+
- The result is one JSON object on one line. A file that the script writes shows as `{"out", "bytes", "sha256"}`. A list shows as `{"count", "listed"}`, and `rest` tells where to get the rest of a long list.
|
|
44
|
+
- An error is `{"error": {"code": "...", "message": "..."}}`. The message tells what is wrong and what to do.
|
|
45
|
+
- The exit status is 0 for done or PASS, 1 for FAIL, 2 for an error and 3 for INCONCLUSIVE.
|
|
46
|
+
|
|
47
|
+
### Project folder
|
|
48
|
+
|
|
49
|
+
- 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/`.
|
|
50
|
+
- 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.
|
|
51
|
+
- 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.
|
|
52
|
+
- 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 test:<file>` or `--evidence file:<file>` of c64-knowledge. These two refuse a file in `.c64-re-tools/local/`.
|
|
53
|
+
- Do not move a coverage map after `coverage` of c64-knowledge imported it. `--evidence coverage:<map>` names the map by its path at the import. The knowledge keeps the coverage and the SHA-256 of the map, so the evidence stays valid.
|
|
54
|
+
- 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.
|
|
55
|
+
- 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`.
|
|
56
|
+
|
|
57
|
+
## Workflow
|
|
58
|
+
|
|
59
|
+
1. Assemble the program with the c64-assembler skill. Use the release or the switches that you want in the packed file.
|
|
60
|
+
2. Find the entry. For a BASIC program at $0801 with `SYS`, the script finds it. Else, use the start address of the program, for example the entry of the program in the knowledge.
|
|
61
|
+
3. Find the value of $01 that the program needs at its start. Give `--exit-memory` when the program uses RAM under BASIC or KERNAL and does not set $01 itself.
|
|
62
|
+
4. Run the script.
|
|
63
|
+
5. If `result` is `PASS`, the packed PRG is at `out`. Give it to the emulator skill and run it with RUN. Make sure that the program starts and works.
|
|
64
|
+
6. If `result` is `FAIL`, read `check`. Do not use the packed program. The script does not write it.
|
|
65
|
+
7. If `result` is `INCONCLUSIVE`, the check did not hold all bytes of the inputs. Run the packed program in the emulator and examine the memory of the segments that are `not covered`.
|
|
66
|
+
|
|
67
|
+
The packed program starts the unpacker with `SYS 2061`, at $080d. A BASIC program at $0801 often has its entry at $080d too. Then the CPU gets to $080d two times: first before the unpack, then at the start of the program. To examine the program at its entry in the emulator, stop at $080d, run one frame, and stop at $080d again.
|
|
68
|
+
|
|
69
|
+
The unpacker uses $0334 to $03ff and the zero page while it runs. A program that loads into these addresses can fail. Then Exomizer stops with an error, or the check gives `FAIL`.
|
|
70
|
+
|
|
71
|
+
## Knowledge
|
|
72
|
+
|
|
73
|
+
Automatic write:
|
|
74
|
+
- none.
|
|
75
|
+
|
|
76
|
+
Do not store:
|
|
77
|
+
- the packed program
|
|
78
|
+
- the check result
|
|
79
|
+
|
|
80
|
+
## Result
|
|
81
|
+
|
|
82
|
+
`result` is `PASS`, `FAIL` or `INCONCLUSIVE`.
|
|
83
|
+
|
|
84
|
+
- `PASS`: the packed program unpacks to the bytes of all inputs and jumps to the entry. The PRG is at `out`.
|
|
85
|
+
- `FAIL`: the packed program unpacks to different bytes, or jumps to a different address. The script did not write a file.
|
|
86
|
+
- `INCONCLUSIVE`: the emulator of Exomizer keeps only the largest range that the unpacker wrote. Bytes of the inputs outside that range have no check. This occurs when the inputs have gaps between them. The PRG is at `out`.
|
|
87
|
+
|
|
88
|
+
Other fields:
|
|
89
|
+
- `packedBytes` and `unpackedBytes`: the size of the packed PRG and of the bytes of the inputs. `percent` is the packed size as a percentage of the unpacked size.
|
|
90
|
+
- `unpackSeconds`: the time of the unpack in the emulator of Exomizer, in seconds at the PAL clock. A real C64 can need more time.
|
|
91
|
+
- `inputs`: each input with its `loadRange` and its `bytes`.
|
|
92
|
+
- `check.entry`: the address where the unpacker jumped.
|
|
93
|
+
- `check.segments`: one check for each segment of the merged inputs. The `result` of a segment is `identical`, `different` with `firstDifference`, or `not covered`. `firstDifference` gives the `address`, the unpacked byte (`built`) and the input byte (`reference`).
|
|
94
|
+
|
|
95
|
+
## Failure and conflicts
|
|
96
|
+
|
|
97
|
+
- `FAIL`: do not use the packed program. Read `check`. Give the call and the result to the user.
|
|
98
|
+
- `invalid-input` with `Give --entry`: the first input has no BASIC line with `SYS` and a number. Give `--entry`.
|
|
99
|
+
- `invalid-input` for the entry: the entry is below $0400. The unpacker runs there. A program with an entry below $0400 needs a different packer.
|
|
100
|
+
- `operation-failed` with `Exomizer could not pack the program`: read the last output of Exomizer in the message. Correct the inputs, or give the message to the user.
|
|
101
|
+
- `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the task. Give the message to the user and wait for the user. The message gives the remedy. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
|
|
102
|
+
- `not-found`: there is no file at an input path. Give a path relative to the project folder.
|
|
103
|
+
|
|
104
|
+
## Handoffs
|
|
105
|
+
|
|
106
|
+
- Assemble the program before the pack → c64-assembler
|
|
107
|
+
- Run the packed program → emulator
|
|
108
|
+
- Put the packed program on a disk image → c64-disk
|
|
109
|
+
- Unpack a packed program → c64-unpacker
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// The c64-packer script: packs and crunches PRG files of the project into one
|
|
2
|
+
// C64 program that unpacks itself, with Exomizer, which it runs itself. It
|
|
3
|
+
// unpacks the result again in the emulator of Exomizer and checks the bytes
|
|
4
|
+
// and the entry before it writes the program.
|
|
5
|
+
|
|
6
|
+
import { posix } from "node:path";
|
|
7
|
+
|
|
8
|
+
import { findHandoffs, formatC64Address, parseTokenized, prgRange } from "#src/c64.ts";
|
|
9
|
+
import { compareBuild, mergedPrograms } from "#src/compare.ts";
|
|
10
|
+
import { isRefusal, Refusal } from "#src/errors.ts";
|
|
11
|
+
import { readProjectFile, writeReported } from "#src/host-client/transfer.ts";
|
|
12
|
+
import { knowledgeNames } from "#src/knowledge/names.ts";
|
|
13
|
+
import { pack } from "#src/native/exomizer.ts";
|
|
14
|
+
import { localToolContext } from "#src/native/local.ts";
|
|
15
|
+
import { OPTIONS, runScript, UsageError } from "#src/script.ts";
|
|
16
|
+
|
|
17
|
+
/** CPU cycles in one second of a PAL C64. */
|
|
18
|
+
const PAL_CYCLES_PER_SECOND = 985_248;
|
|
19
|
+
|
|
20
|
+
/** The SYS address of the BASIC line of a PRG at $0801, or the reason that there is none. */
|
|
21
|
+
function sysEntry(program: Uint8Array): number | string {
|
|
22
|
+
const load = prgRange(program).start;
|
|
23
|
+
if (load !== 0x0801) return `It loads at ${formatC64Address(load)}, not at $0801 where BASIC starts.`;
|
|
24
|
+
const tokenized = parseTokenized(program);
|
|
25
|
+
if ("reason" in tokenized) return tokenized.reason;
|
|
26
|
+
const sys = findHandoffs(tokenized.lines).find((handoff) => handoff.kind === "sys");
|
|
27
|
+
if (sys === undefined) return "Its BASIC program has no SYS.";
|
|
28
|
+
if (!("address" in sys)) return `Its SYS in line ${sys.line} has the argument ${sys.expression}, which needs run-time values.`;
|
|
29
|
+
return sys.address;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const samePath = (a: string, b: string) => posix.normalize(a.replaceAll("\\", "/")) === posix.normalize(b.replaceAll("\\", "/"));
|
|
33
|
+
|
|
34
|
+
await runScript({
|
|
35
|
+
name: "packer",
|
|
36
|
+
summary: "Packs and crunches PRG files of the project into one C64 program that unpacks itself, with Exomizer, and checks that it unpacks to the same bytes.",
|
|
37
|
+
names: knowledgeNames,
|
|
38
|
+
commands: [
|
|
39
|
+
{
|
|
40
|
+
name: "pack",
|
|
41
|
+
summary:
|
|
42
|
+
"Packs the PRG files into one program that unpacks itself and starts at the entry, and checks it in the emulator of Exomizer. result is PASS when it unpacks to the bytes of the inputs and jumps to the entry, FAIL when it does not (no program is written), and INCONCLUSIVE when the check does not hold all bytes of the inputs.",
|
|
43
|
+
subjects: [{ name: "<input.prg>", help: "a PRG in the project. Give more files to put them into one program: in load order, a later file wins where two overlap", list: true }],
|
|
44
|
+
options: {
|
|
45
|
+
out: { ...OPTIONS.out, output: "file", value: "<file.prg>", help: "where to write the packed program, relative to the project folder", required: true },
|
|
46
|
+
entry: { ...OPTIONS.entry, help: "where the program starts after the unpack, $0400 or above. Without it, the SYS address of the BASIC line of the first input" },
|
|
47
|
+
"exit-memory": { kind: "number", value: "<value>", min: 0x34, max: 0x37, help: "the value of $01 when the program starts, $34 to $37, for example '$35'. Without it, $37: BASIC, KERNAL and I/O. With it, the program starts with interrupts off" },
|
|
48
|
+
},
|
|
49
|
+
notes: "The packed program loads at $0801 and starts with RUN. The unpacker uses $0334 to $03ff and the zero page while it runs.",
|
|
50
|
+
run: async (call) => {
|
|
51
|
+
const files = call.rest(0);
|
|
52
|
+
const out = call.string("out")!;
|
|
53
|
+
const same = files.find((file) => samePath(file, out));
|
|
54
|
+
if (same !== undefined) throw new UsageError(`--out ${out} is the input ${same}. Write the packed program to a different file.`);
|
|
55
|
+
const programs = files.map((file) => {
|
|
56
|
+
const { bytes } = readProjectFile(file, { what: file });
|
|
57
|
+
try {
|
|
58
|
+
return { file, bytes, ...prgRange(bytes) };
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (isRefusal(error)) throw new Refusal("invalid-input", `${file} is not a PRG: ${error.message}`);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
let entry = call.address("entry");
|
|
65
|
+
if (entry === undefined) {
|
|
66
|
+
const found = sysEntry(programs[0]!.bytes);
|
|
67
|
+
if (typeof found === "string") throw new UsageError(`Give --entry: there is no SYS address in ${files[0]}. ${found}`);
|
|
68
|
+
entry = found;
|
|
69
|
+
}
|
|
70
|
+
const exitMemory = call.count("exit-memory");
|
|
71
|
+
const packed = await pack({ programs: programs.map((program) => program.bytes), entry, ...(exitMemory === undefined ? {} : { exitMemory }) }, localToolContext());
|
|
72
|
+
|
|
73
|
+
const reference = mergedPrograms(programs);
|
|
74
|
+
const check = compareBuild(packed.unpacked, reference);
|
|
75
|
+
const entryReached = packed.entry === entry;
|
|
76
|
+
const different = !entryReached || check.segments.some((segment) => segment.result === "different");
|
|
77
|
+
const result = different ? "FAIL" : check.identical ? "PASS" : "INCONCLUSIVE";
|
|
78
|
+
const unpackedBytes = reference.segments.reduce((sum, segment) => sum + segment.end - segment.start + 1, 0);
|
|
79
|
+
return {
|
|
80
|
+
result,
|
|
81
|
+
// A program that does not unpack to its inputs is not written.
|
|
82
|
+
...(different ? {} : writeReported(out, packed.program, { what: "--out" })),
|
|
83
|
+
packedBytes: packed.program.length,
|
|
84
|
+
unpackedBytes,
|
|
85
|
+
percent: Math.round((packed.program.length / unpackedBytes) * 1000) / 10,
|
|
86
|
+
entry: formatC64Address(entry),
|
|
87
|
+
...(exitMemory === undefined ? {} : { exitMemory: `$${exitMemory.toString(16)}` }),
|
|
88
|
+
...(packed.cycles === undefined ? {} : { unpackSeconds: Math.round((packed.cycles / PAL_CYCLES_PER_SECOND) * 10) / 10 }),
|
|
89
|
+
inputs: programs.map((program) => ({ file: program.file, loadRange: { start: formatC64Address(program.start), end: formatC64Address(program.end) }, bytes: program.body.length })),
|
|
90
|
+
check: { entry: formatC64Address(packed.entry), ...check },
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
});
|
|
@@ -20,6 +20,7 @@ This skill does not change project knowledge.
|
|
|
20
20
|
- Two or more releases, relative to the project folder. A release is `knowledge` (the program in the knowledge), a PRG file, or an `image.json` from c64-unpacker capture with its `entry_state.json` beside it. Extract releases from disk images with the c64-disk skill. Unpack packed releases with the c64-unpacker skill first.
|
|
21
21
|
- Optional: an address range to compare.
|
|
22
22
|
- Optional: a shift for a release that loads at a different address.
|
|
23
|
+
- Optional: `--align`, to map two releases with moved code in blocks of equal bytes.
|
|
23
24
|
- Optional: a number of frames to run each release, and a steps file.
|
|
24
25
|
- For one release: the program, the coverage and the other knowledge of the project. Put the program and the coverage in with `image` and `coverage` of the c64-knowledge skill.
|
|
25
26
|
- For the library: the program and the other knowledge of its project, and the library folder.
|
|
@@ -31,6 +32,7 @@ The script compares the releases locally. Only `--frames` uses the host runtime:
|
|
|
31
32
|
```
|
|
32
33
|
node <skill>/scripts/provenance.ts compare releases/a.prg releases/b.prg releases/c.prg
|
|
33
34
|
node <skill>/scripts/provenance.ts compare releases/a.prg releases/b.prg --shift 2:-256 --range '$0900-$09ff'
|
|
35
|
+
node <skill>/scripts/provenance.ts compare releases/a/image.json releases/b/image.json --align --range '$0400-$bfff'
|
|
34
36
|
node <skill>/scripts/provenance.ts compare knowledge .c64-re-tools/local/b/image.json --frames 600 --steps .c64-re-tools/local/start-game.json
|
|
35
37
|
node <skill>/scripts/provenance.ts separate --out .c64-re-tools/local/separate.json
|
|
36
38
|
node <skill>/scripts/provenance.ts leftovers --out .c64-re-tools/local/leftovers.json
|
|
@@ -40,6 +42,8 @@ node <skill>/scripts/provenance.ts leftovers --out .c64-re-tools/local/leftovers
|
|
|
40
42
|
|---|---|
|
|
41
43
|
| `--shift 2:-256` | Move release 2 (the first release is 1) by -256 bytes. Use it again for more releases. Give one shift for each release. |
|
|
42
44
|
| `--range '$0900-$09ff'` | Compare only the addresses in this range. |
|
|
45
|
+
| `--align` | Map release 1 to release 2 in blocks of equal bytes. Each block has its own shift. Give two releases. Do not use it with `--shift` or `--frames`. |
|
|
46
|
+
| `--min-block 24` | With `--align`: the minimum number of bytes in a block. The default is 16. |
|
|
43
47
|
| `--frames 600` | Run each release for this many frames, and give each listed difference its runtime evidence. |
|
|
44
48
|
| `--steps .c64-re-tools/local/start-game.json` | With `--frames`: a JSON list of action steps to run before the frames, for example a key to start the game. The steps are the steps of a c64-unpacker steps file. |
|
|
45
49
|
|
|
@@ -47,6 +51,15 @@ The script puts each PRG at its load address. An image has bytes only in its seg
|
|
|
47
51
|
|
|
48
52
|
With `--shift`, the addresses of `segments`, `common` and `differences` are the release addresses plus the `shift` of the release. The `start` and `end` of `runtime` are the addresses in the release itself, without the shift.
|
|
49
53
|
|
|
54
|
+
Use `--align` for two releases with added code and moved data. One shift does not fit them, and the shift suggestions are not useful. The map tells what each block of one release is in the other release. With `--align`, the result has the map, not `differences` and not the shift suggestions:
|
|
55
|
+
|
|
56
|
+
- `blocks`: the blocks of equal bytes, in the order of their addresses in release 1. `a` is the range in release 1. `b` is the range in release 2. `bytes` is the length of the block.
|
|
57
|
+
- `shift`: the address in `b` minus the address in `a`. The address of a byte in release 2 is its address in release 1 plus the `shift` of its block. The blocks can have a different order in release 2, because code moved.
|
|
58
|
+
- `onlyInA`: the ranges of release 1 that no block holds. Release 2 does not have these bytes, or it has other bytes there.
|
|
59
|
+
- `onlyInB`: the ranges of release 2 that no block holds. Release 2 added these bytes, or it changed them.
|
|
60
|
+
- `alignedShare`: the share of the bytes of the two releases that a block holds, with 3 decimals.
|
|
61
|
+
- Each list shows at most 64 items. `moreBlocks`, `moreOnlyInA` and `moreOnlyInB` give the number of the items that the list does not show. Use `--range` to see them.
|
|
62
|
+
|
|
50
63
|
With `--frames`, a PRG starts with autostart and RUN. An image starts from its bytes: the script writes the segments and the entry state from `entry_state.json` into the emulator, and starts at the entry. Watchpoints on each difference stop the run at its first access.
|
|
51
64
|
|
|
52
65
|
### Calling the script
|
|
@@ -74,7 +87,7 @@ With `--frames`, a PRG starts with autostart and RUN. An image starts from its b
|
|
|
74
87
|
## Workflow
|
|
75
88
|
|
|
76
89
|
1. Run the script on the releases.
|
|
77
|
-
2. Read `identicalShare`. If it is low and `suggestedShifts` is present, the releases are at different addresses. Run the script again with a `--shift` of `suggestedShifts`. `shiftsNotSuggested` tells why a found shift does not fit in `$0000-$ffff`.
|
|
90
|
+
2. Read `identicalShare`. If it is low and `suggestedShifts` is present, the releases are at different addresses. Run the script again with a `--shift` of `suggestedShifts`. `shiftsNotSuggested` tells why a found shift does not fit in `$0000-$ffff`. If no shift gives a high `identicalShare`, the code and the data can be at other addresses in each release. Then run the script again with `--align`.
|
|
78
91
|
|
|
79
92
|
`suggestedShifts` has at most 3 shifts for each release. The shift with the most `matchingSequences` is first. Data that did not move and code that moved give different shifts. Try each shift. `current: true` marks the shift of this run.
|
|
80
93
|
3. Read `differences`. Each one has an address range, the bytes of each release, and `groups`: the releases that have the same bytes there.
|
|
@@ -85,7 +98,7 @@ With `--frames`, a PRG starts with autostart and RUN. An image starts from its b
|
|
|
85
98
|
- A range with `none` in each release is not used in this run. Run more frames or other steps before you decide.
|
|
86
99
|
- `run.skipped`: the releases have no differences, so no release ran.
|
|
87
100
|
5. Examine each important difference:
|
|
88
|
-
- Disassemble the bytes of each release with the
|
|
101
|
+
- Disassemble the bytes of each release with the emulator skill, or analyze them with the c64-static-analysis skill.
|
|
89
102
|
- Find what the change does, for example a trainer, a removed copy protection, or a changed text.
|
|
90
103
|
6. Decide which bytes are probably the original application. Use more than the byte comparison: the code, the text, and the history of the releases.
|
|
91
104
|
7. Record each release with `release` of the c64-knowledge skill. The base release is the program of the knowledge.
|
|
@@ -143,7 +156,7 @@ Do these steps:
|
|
|
143
156
|
3. Run c64-static-analysis. Without code regions, `deadCode` is empty, and `residue` can include code.
|
|
144
157
|
4. Run `leftovers`. When you have two or more releases, also compare them.
|
|
145
158
|
5. Read `text` first: names, dates, greetings and credits. Then read `copies`, `residue`, `basic` and `deadCode`.
|
|
146
|
-
6. Examine each important finding with the
|
|
159
|
+
6. Examine each important finding with the emulator skill or the c64-static-analysis skill.
|
|
147
160
|
7. Record each confirmed finding with the c64-knowledge skill. Do not remove a leftover from the program: a rebuild keeps it. Only the data of a cracktro goes out, with `capture --exclude` of the c64-unpacker skill. Classify a confirmed PETSCII text as a `petscii` region, and a screen code text as a `screen` region. Classify other text as `bytes`. Write a comment that tells what the leftover is.
|
|
148
161
|
|
|
149
162
|
Read the findings with care:
|
|
@@ -201,7 +214,7 @@ Record a confirmed conclusion as a normal comment, region, symbol, release, swit
|
|
|
201
214
|
|
|
202
215
|
## Result
|
|
203
216
|
|
|
204
|
-
The differing ranges with the bytes of each release and the groups that agree, and the share of identical bytes. `identicalShare` has 3 decimals. It is 1 only when no byte differs. `identicalBytes` and `differingBytes` give the counts. `common` gives the ranges where all releases have bytes. `releases` gives the segments and the `shift` of each release. With `--frames`, each difference also has `runtime`, and `run` tells if each release started, or why not.
|
|
217
|
+
The differing ranges with the bytes of each release and the groups that agree, and the share of identical bytes. `identicalShare` has 3 decimals. It is 1 only when no byte differs. `identicalBytes` and `differingBytes` give the counts. `common` gives the ranges where all releases have bytes. `releases` gives the segments and the `shift` of each release. With `--frames`, each difference also has `runtime`, and `run` tells if each release started, or why not. With `--align`, the result has `blocks`, `onlyInA`, `onlyInB` and `alignedShare` in place of `differences`.
|
|
205
218
|
|
|
206
219
|
For `leftovers`: the lists of findings, with `entry`, `roots` and the number of `stages`. `noStages` and `noCoverage` tell which knowledge is missing. Without a root, `roots` tells why `deadCode` is empty.
|
|
207
220
|
|
|
@@ -226,7 +239,7 @@ The runtime evidence and the leftovers are evidence only. The script does not de
|
|
|
226
239
|
|
|
227
240
|
- Get releases from disk images → c64-disk
|
|
228
241
|
- Unpack a packed release → c64-unpacker
|
|
229
|
-
- Run or examine the different code →
|
|
242
|
+
- Run or examine the different code → emulator
|
|
230
243
|
- Analyze the different code → c64-static-analysis
|
|
231
244
|
- Record a conclusion → c64-knowledge
|
|
232
245
|
- Apply the batch of `match` → c64-knowledge
|