@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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Batches
|
|
2
|
+
|
|
3
|
+
This file gives the format of a batch for `apply` and `join`, and the rules of `join`. For the commands, see their sections of `SKILL.md`. `apply --help` also gives the fields of each op.
|
|
4
|
+
|
|
5
|
+
## Writes of a batch
|
|
6
|
+
|
|
7
|
+
A batch file is a JSON list of writes. Each write has `op` and the fields of the command with the same name. Each write can also have `space`. For example:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
[
|
|
11
|
+
{ "op": "rename", "address": "$2100", "name": "update_player", "kind": "routine" },
|
|
12
|
+
{ "op": "classify", "start": "$3000", "end": "$303b", "type": "bytes", "element": 6 },
|
|
13
|
+
{ "op": "comment", "address": "$2100", "placement": "line", "text": "Reads joystick 2." }
|
|
14
|
+
]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| op | Fields |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `rename` | `address`, `name`, `kind` (optional) |
|
|
20
|
+
| `remove-symbol` | `address` |
|
|
21
|
+
| `classify` | `start`, `end`, `type`, `element` (optional) |
|
|
22
|
+
| `unclassify` | `start`, `end` |
|
|
23
|
+
| `comment` | `address`, `placement` (`line` or `side`), `text` |
|
|
24
|
+
| `uncomment` | `address`, `placement` |
|
|
25
|
+
| `reference`, `unreference` | `from`, `to`, `kind` |
|
|
26
|
+
| `module` | `start`, `file`, `title` (optional) |
|
|
27
|
+
| `unmodule` | `start` |
|
|
28
|
+
| `operand` | `address`, `select` (`lo`, `hi`, `value` or `expr`), `symbol` and `offset` (optional), or `expression` for `expr` |
|
|
29
|
+
| `unoperand` | `address` |
|
|
30
|
+
| `patch` | `start`, `end`, `switch`, `code` (empty for NOP only), `comment` (optional) |
|
|
31
|
+
| `unpatch` | `start`, `switch` (optional) |
|
|
32
|
+
| `macro` | `name`, `params` (a list or a comma list), `body`, `comment` (optional) |
|
|
33
|
+
| `unmacro` | `name` |
|
|
34
|
+
| `use` | `start`, `end`, `macro`, `args` (a list or a comma list) |
|
|
35
|
+
| `unuse` | `start` |
|
|
36
|
+
|
|
37
|
+
- The script checks an `operand`, `patch` or `use` write against the program of its space.
|
|
38
|
+
|
|
39
|
+
## Batches of parallel agents
|
|
40
|
+
|
|
41
|
+
When more agents name the program at the same time, give each agent one range of addresses. Each agent writes one batch file in `.c64-re-tools/local/` and does not apply it. A batch of an agent has the form `{"owner": {"start": "$1000", "end": "$1fff"}, "ops": [...]}`. `ops` holds the writes. The owner ranges must not overlap.
|
|
42
|
+
|
|
43
|
+
`join` makes one list of writes from the batches:
|
|
44
|
+
|
|
45
|
+
- 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.
|
|
46
|
+
- A batch can give an address a name that `join` replaces. Then `join` also replaces that name in the operand expressions and macro arguments of that batch.
|
|
47
|
+
- The regions of the owner come after the regions of the other batches. Thus the regions of the owner stay where they overlap.
|
|
48
|
+
- A name from a batch stays when another batch removes the symbol at that address.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Coverage
|
|
2
|
+
|
|
3
|
+
This file tells what the coverage of the knowledge shows. For the commands, see the sections of `coverage`, `at` and `listing` of `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## Maps and their paths
|
|
6
|
+
|
|
7
|
+
- The knowledge names a coverage map by its path. A recording folder gives the path of its map.
|
|
8
|
+
- A space has one map for each path. A new map of a path replaces the earlier map of that path. Thus, after you record a run again into the same folder, put its new map into the project knowledge. Then the coverage has only the new run of that folder.
|
|
9
|
+
- Do not move a coverage map after you put it into the project knowledge. Else `--evidence coverage:<map>` cannot name it.
|
|
10
|
+
- `coverage` puts each map into the space of `--space`. You can add the same map to each space.
|
|
11
|
+
- `--evidence coverage:<map>` names the last import of that map into the space of the write.
|
|
12
|
+
- A revert to a revision before an import removes the map. Then `--evidence coverage:<map>` refuses the map until you import it again.
|
|
13
|
+
|
|
14
|
+
## Access
|
|
15
|
+
|
|
16
|
+
- The coverage of a space is the union of its maps. It has each address that a run executed, read or wrote. It also has each address that one run wrote and executed: self-modified code.
|
|
17
|
+
- `at` gives the access of each map at the address, and the joined access of all maps: `x` executed, `rw` read and written, `r` read, `w` written, `-` none. An execute wins over a read and a write.
|
|
18
|
+
- `listing` gives the joined access of the bytes of each line: `x`, `r` and `w` as the runs did them, or `-` for none.
|
|
19
|
+
|
|
20
|
+
## Reads that the program does not do
|
|
21
|
+
|
|
22
|
+
An `r` on code can come from a read of the 6510 that the program does not do. Examples:
|
|
23
|
+
|
|
24
|
+
- The third byte of a JSR.
|
|
25
|
+
- The opcode after a branch that the CPU takes.
|
|
26
|
+
- The opcode at the PC when an interrupt starts.
|
|
27
|
+
- An indexed read (`lda table,x`) that crosses a page also reads the byte $100 below its target.
|
|
28
|
+
|
|
29
|
+
A read watchpoint does not stop at these reads. Thus an `r` on code alone does not show that the program reads the byte as data.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Source knowledge
|
|
2
|
+
|
|
3
|
+
This file gives the rules of the releases, the switches, the patches, the macros and the macro uses. For the commands, see their sections of `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## Releases
|
|
6
|
+
|
|
7
|
+
A release is one version of the program, for example the original or a crack. Record each release with `release <label> --file <file>`.
|
|
8
|
+
|
|
9
|
+
- A label is upper case, for example `FIRESTAR`, `TBC` or `V2`.
|
|
10
|
+
- `--file` is a PRG or the `image.json` of a capture. The project knowledge keeps the bytes of the release, the path of the file and its SHA-256. After the write, the project does not need the file. A file can stay in `.c64-re-tools/local/`.
|
|
11
|
+
- The base release is the release whose bytes are the program of the knowledge. Record it with `--base`. The script refuses `--base` when the segments or the bytes of the file are not the program.
|
|
12
|
+
- A space has one base release. Record the base release before the first switch.
|
|
13
|
+
- To change the bytes of a release, record the release again with its new file.
|
|
14
|
+
- A release of an earlier toolkit version has no `file` and no `sha256`. To get them, record the release again with its file.
|
|
15
|
+
|
|
16
|
+
## Switches
|
|
17
|
+
|
|
18
|
+
A switch puts one change of the program in or out of the build. A switch has a kind, a default and the releases that have it on. The generated source writes all switches with their defaults.
|
|
19
|
+
|
|
20
|
+
| Kind | What it changes | Default |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| `protection` | A copy protection | 0 (off) |
|
|
23
|
+
| `trainer` | A trainer, for example infinite lives | 0 (off) |
|
|
24
|
+
| `cheat` | A cheat | 0 (off) |
|
|
25
|
+
| `crack` | A change that a cracker made in the program, for example a credit text | 0 (off) |
|
|
26
|
+
| `fix` | A correction that one or more releases have | 1 (on). Give `--default 0` only for an alternative (see "Patches"). |
|
|
27
|
+
| `change` | Another difference between releases | Give `--default 0` or `--default 1`. |
|
|
28
|
+
|
|
29
|
+
- The default build is the clean program. It has no copy protection, trainer, cheat or crack change, and it has all corrections. Thus the script refuses `--default 1` for `protection`, `trainer`, `cheat` and `crack`.
|
|
30
|
+
- A switch that no release has on, for example a trainer of your own, has no `--releases`.
|
|
31
|
+
- The base value of a switch is 1 when the base release has it on, else 0. The program of the knowledge has the base value of each switch.
|
|
32
|
+
- A switch name is upper case, for example `PROTECTION`, `TRAINER` or `FIX_LIVES`. It cannot start with `RELEASE_`. It cannot be the name of a symbol or a platform name.
|
|
33
|
+
- The script refuses a change of the base value while the switch has patches. Remove the patches first, because they hold the other state.
|
|
34
|
+
- The script refuses defaults that put in two alternatives.
|
|
35
|
+
|
|
36
|
+
## Patches
|
|
37
|
+
|
|
38
|
+
A patch is ACME code for a range of the program. The code is the bytes of the switch in the state that the base release does not have. Examples:
|
|
39
|
+
|
|
40
|
+
- The base release has a copy protection. The switch `PROTECTION` names the base release. The code is the program without the protection, for example NOP in place of the `JSR` to the check.
|
|
41
|
+
- The base release has the protection already removed, and another release has it. The code is the bytes of the protection from that release. When no release has these bytes, write in a comment that the crack removed the protection.
|
|
42
|
+
- A correction is only in release `V2`. The switch `FIX_LIVES` names `V2`, and the code is the bytes of `V2`.
|
|
43
|
+
- A correction is in the base release and not in `V1`. The switch names the base release, and the code is the bytes of `V1`.
|
|
44
|
+
|
|
45
|
+
When another release has the bytes of the other state, give `--from-release <label>`. The script then writes the bytes of that release in the range as `!byte` lines. Do not copy the bytes yourself. The script refuses the base release, and a range where the release has no bytes.
|
|
46
|
+
|
|
47
|
+
Rules:
|
|
48
|
+
|
|
49
|
+
- Give exactly one of `--code`, `--code-file`, `--nop` and `--from-release`.
|
|
50
|
+
- Write the switch first. `patch` refuses a switch that the knowledge does not have.
|
|
51
|
+
- Many patches can have the same switch.
|
|
52
|
+
- The code must fit in the range. NOP (`$EA`) fills the bytes after the code. The script refuses code that is longer than the range. The check of the generated source finds the length errors of code with a label or a macro.
|
|
53
|
+
- The code can use the labels and the macros of the source, and local labels with a dot, for example `.skip`.
|
|
54
|
+
- The braces in the code must be pairs.
|
|
55
|
+
- Patches of different switches can have the same range. They are alternatives, for example two releases with two different corrections of one bug. The default build can put in only one of them.
|
|
56
|
+
- The knowledge refuses all other overlaps of patches. A patch cannot overlap a macro use.
|
|
57
|
+
- A patch with the same start and the same switch replaces the patch.
|
|
58
|
+
- Each byte of the range must be in the program of the knowledge.
|
|
59
|
+
|
|
60
|
+
## Macros
|
|
61
|
+
|
|
62
|
+
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.
|
|
63
|
+
|
|
64
|
+
- Give `--body` or `--body-file`. The body uses each param with a dot, for example `.dst`.
|
|
65
|
+
- The knowledge refuses a change of the number of params while the macro has uses.
|
|
66
|
+
|
|
67
|
+
## Macro uses
|
|
68
|
+
|
|
69
|
+
- The range of a use is complete instructions of the program of the knowledge.
|
|
70
|
+
- Each name in an argument is a symbol of the knowledge or a platform name.
|
|
71
|
+
- A use cannot overlap a patch or another use.
|
|
72
|
+
- The generated source writes a use only when the use gives the bytes of the program. Else it writes the instructions and gives the reason.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Start screens
|
|
2
|
+
|
|
3
|
+
This file tells how to record the start screen of the program. For the command, see its section of `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
A start screen is a loading screen, a title screen or a presentation screen of the program itself. The loader of the generated source shows it before the program starts. Then the loader waits for a key, or for a fire button on joystick port 1 or 2.
|
|
6
|
+
|
|
7
|
+
## A start screen in the program
|
|
8
|
+
|
|
9
|
+
Use this when the program at the entry has the bytes of the screen. Do these steps:
|
|
10
|
+
|
|
11
|
+
1. Run the program of the base release until it shows the screen.
|
|
12
|
+
2. Capture the program at that time. Do not exclude the memory of the screen.
|
|
13
|
+
3. Record the start screen with `start-screen --capture <image.json>`.
|
|
14
|
+
|
|
15
|
+
- The script takes the mode, the addresses, the border and the background from the capture. Do not find the addresses or the colours yourself.
|
|
16
|
+
- The script finds the 1000 colours of the colour RAM of the capture in the program. Then it records their address as `colours`. When the colour RAM has one colour, the script records that `colour`.
|
|
17
|
+
- If the script refuses because the program does not have the colours, find the stage of the loading that shows the screen. Then record the start screen of that stage. If no stage shows the screen, give `error` to the user.
|
|
18
|
+
- A capture of an older version has no colour RAM. Then capture the program again.
|
|
19
|
+
|
|
20
|
+
## A start screen of a captured stage
|
|
21
|
+
|
|
22
|
+
Use this when a stage of the loading shows the screen, and the program at the entry does not have it. Do these steps:
|
|
23
|
+
|
|
24
|
+
1. Capture the stage while it shows the screen. Do not exclude the memory of the screen.
|
|
25
|
+
2. Put the capture into the knowledge in the space `loading`: `image stage/image.json --space loading`. Do not use another space for it.
|
|
26
|
+
3. If the stage plays a tune or does other work during the screen, find the routine that starts it. Run the stage with coverage while that routine runs. Put the map into the knowledge with `coverage <map> --space loading`.
|
|
27
|
+
4. Record the start screen with `start-screen --stage loading`, and with `--call` for the routine.
|
|
28
|
+
|
|
29
|
+
- The script takes the mode, the screen, the bitmap or the charset, the colours and the colour RAM from the capture. Do not find the addresses or the colours yourself.
|
|
30
|
+
- A capture of an older version has no colour RAM. Then capture the stage again.
|
|
31
|
+
|
|
32
|
+
## Flags that correct a capture
|
|
33
|
+
|
|
34
|
+
- A flag that you give with `--capture` or `--stage` replaces the value of the capture. Give a flag only to correct a value.
|
|
35
|
+
- Without `--capture` and `--stage`, give `--mode`, `--screen`, `--border` and `--background`, and the bitmap, the charset and the colours that the mode needs.
|
|
36
|
+
|
|
37
|
+
## The rules of the VIC-II
|
|
38
|
+
|
|
39
|
+
- `text` needs `--charset`. `hires` and `multicolour` need `--bitmap`. `text` and `multicolour` need `--colours` or `--colour`. `hires` uses neither.
|
|
40
|
+
- The screen is at a step of $0400, the bitmap at a step of $2000 and the charset at a step of $0800. They must be in one VIC bank of 16 KB.
|
|
41
|
+
- In VIC bank 0 and 2, the VIC-II reads the character ROM at $1000-$1fff of the bank. A screen or a bitmap cannot be there. A charset at $1000 or $1800 of the bank is the character ROM.
|
|
42
|
+
- No part can be in $0000-$03ff. The colours cannot be in $d000-$dfff.
|
|
43
|
+
- A space has one start screen, and only the space `c64` has one. A write replaces the start screen of the knowledge.
|
|
44
|
+
- The generated source has the switches `START_SCREEN` and `LEFTOVERS`. Thus no symbol and no switch can have these names.
|