@henols/c64-re-tools 2.5.0-rc.1 → 2.6.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +2 -1
- package/skills/c64-basic/SKILL.md +2 -1
- package/skills/c64-development/SKILL.md +1 -1
- package/skills/c64-disk/SKILL.md +2 -1
- package/skills/c64-docs/SKILL.md +2 -1
- package/skills/c64-knowledge/SKILL.md +21 -5
- package/skills/c64-knowledge/scripts/knowledge.ts +10 -2
- package/skills/c64-memory-map/SKILL.md +2 -1
- package/skills/c64-packer/SKILL.md +2 -1
- package/skills/c64-provenance/SKILL.md +2 -1
- package/skills/c64-reverse-engineering/SKILL.md +6 -3
- package/skills/c64-source/SKILL.md +50 -13
- package/skills/c64-source/scripts/lib/loader.ts +41 -16
- package/skills/c64-source/scripts/lib/source.ts +47 -14
- package/skills/c64-source/scripts/lib/stage.ts +268 -0
- package/skills/c64-source/scripts/lib/start-screen.asm +28 -2
- package/skills/c64-source/scripts/source.ts +380 -119
- package/skills/c64-static-analysis/SKILL.md +2 -1
- package/skills/c64-testing/SKILL.md +2 -1
- package/skills/c64-unpacker/SKILL.md +3 -1
- package/src/cli/main.ts +4 -2
- package/src/cli/status.ts +0 -1
- package/src/knowledge/read.ts +8 -1
- package/src/knowledge/schema.ts +10 -2
- package/src/knowledge/text.ts +2 -0
- package/src/knowledge/write.ts +36 -6
package/package.json
CHANGED
|
@@ -67,7 +67,8 @@ A source that you generated from the project knowledge has switches in `config.a
|
|
|
67
67
|
- 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.
|
|
68
68
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
69
69
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
70
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
70
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
71
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
71
72
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
72
73
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
73
74
|
- 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`.
|
|
@@ -43,7 +43,8 @@ To get the command list, run the script with no arguments.
|
|
|
43
43
|
- 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.
|
|
44
44
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
45
45
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
46
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
46
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
47
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
47
48
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
48
49
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
49
50
|
- 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,7 +48,7 @@ Use this layout. No script makes it.
|
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
src/ the source, with src/main.a as the entry
|
|
51
|
-
build/ the built programs and their symbol files
|
|
51
|
+
build/ the built programs and their symbol files. Do not commit them: each build writes them again.
|
|
52
52
|
tests/ run files with expect steps
|
|
53
53
|
docs/ the documentation, when the user asks for it
|
|
54
54
|
```
|
package/skills/c64-disk/SKILL.md
CHANGED
|
@@ -69,7 +69,8 @@ To get the command list, run the script with no arguments.
|
|
|
69
69
|
- 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.
|
|
70
70
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
71
71
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
72
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
72
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
73
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
73
74
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
74
75
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
75
76
|
- 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`.
|
package/skills/c64-docs/SKILL.md
CHANGED
|
@@ -58,7 +58,8 @@ Get the values for the commands from these places:
|
|
|
58
58
|
- 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.
|
|
59
59
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
60
60
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
61
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
61
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
62
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
62
63
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
63
64
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
64
65
|
- 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`.
|
|
@@ -53,6 +53,7 @@ The knowledge is text in `.c64-re-tools/knowledge/` of the project. Commit that
|
|
|
53
53
|
| Write the code of a switch for a range | `patch '$100e-$1010' PROTECTION --code-file no-check.asm` |
|
|
54
54
|
| List the releases, switches and patches | `switches` |
|
|
55
55
|
| Record the start screen of the program | `start-screen --mode multicolour --screen '$5c00' --bitmap '$6000' --colours '$8328' --border 0 --background 0` |
|
|
56
|
+
| Record the start screen of a captured stage, and its tune | `start-screen --mode multicolour --screen '$cc00' --bitmap '$e000' --colours '$8328' --border 3 --background 1 --stage bank1 --call '$9000'` |
|
|
56
57
|
| Remove the start screen | `unstart-screen` |
|
|
57
58
|
| Write a macro | `macro inc16 --params dst --body-file inc16.asm` |
|
|
58
59
|
| Write instructions as one use of a macro | `use '$1005-$100a' inc16 --args ptr` |
|
|
@@ -71,7 +72,7 @@ The knowledge is text in `.c64-re-tools/knowledge/` of the project. Commit that
|
|
|
71
72
|
- An analyzer name is a second name from DXA, Ghidra or an idiom search, for example `FUN_17e2`. Each analyzer keeps its own name at an address. Get them from `at`, `search` or `symbols --analyzer`.
|
|
72
73
|
- The generated source uses only the symbols. To use an analyzer name in the source, give the address that name with `rename`.
|
|
73
74
|
- A symbol name is a label for ACME: a letter or an underscore, then letters, digits or underscores. The knowledge refuses the name of a 6502 instruction, for example `lda`, in upper or lower case.
|
|
74
|
-
- A space is `c64` (the default), `drive8` for code in the 1541 drive, or `bank0` to `bank255` for cartridge banks. Drive code and
|
|
75
|
+
- A space is `c64` (the default), `drive8` for code in the 1541 drive, or `bank0` to `bank255` for cartridge banks and for a captured stage of the loading. Drive code, banks and stages use the same addresses as the C64. Thus each space has its own knowledge. A name is unique in one space.
|
|
75
76
|
- A revision id has the form `20261015T214501.123-k3f9qz`. It starts with the date and the time. Give the full id, or a start of the id that only one revision has. Get the ids from `revisions`, or from the `revision` field of a result. The revision `0` is the knowledge before the first revision.
|
|
76
77
|
- A file of a capture is the `image.json` that the capture of a packed program wrote. Keep the other files of the capture next to it.
|
|
77
78
|
|
|
@@ -87,7 +88,8 @@ The knowledge is text in `.c64-re-tools/knowledge/` of the project. Commit that
|
|
|
87
88
|
- 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.
|
|
88
89
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
89
90
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
90
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
91
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
92
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
91
93
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
92
94
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
93
95
|
- 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`.
|
|
@@ -148,6 +150,8 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
148
150
|
| `--colour <0-15>` | `start-screen` | One colour for all of the colour RAM, in place of `--colours`. |
|
|
149
151
|
| `--border <0-15>` | `start-screen` | Necessary. The border colour. |
|
|
150
152
|
| `--background <0-15>` | `start-screen` | Necessary. The background colour. |
|
|
153
|
+
| `--stage <space>` | `start-screen` | The space of a captured stage that holds the bytes of the screen, for example `bank1`. Without it, the bytes are in the program at the entry. |
|
|
154
|
+
| `--call <address>` | `start-screen` | A routine of the stage that the start screen calls before it waits, for example the start of the loading tune. It must return with RTS. It needs `--stage`. |
|
|
151
155
|
|
|
152
156
|
---
|
|
153
157
|
|
|
@@ -379,7 +383,9 @@ An operand expression tells the generated source how to write the operand of one
|
|
|
379
383
|
|
|
380
384
|
### `release <label>`
|
|
381
385
|
|
|
382
|
-
A rebuild keeps all of the program: unused bytes, dead code, old copies and leftovers of the development. It keeps a copy protection, a trainer and a cheat in the source. A switch puts each of them in or out of the build. A start screen of the program stays too: record it with `start-screen`. Only a cracktro and the other screens of a crack are not in the rebuild.
|
|
386
|
+
A rebuild keeps all of the program in the source: unused bytes, dead code, old copies and leftovers of the development. The default build and the loader do not have the leftovers. The build of a release has them. It keeps a copy protection, a trainer and a cheat in the source. A switch puts each of them in or out of the build. A start screen of the program stays too: record it with `start-screen`. Only a cracktro and the other screens of a crack are not in the rebuild.
|
|
387
|
+
|
|
388
|
+
Do not write a file of the rebuild by hand, for example a boot file, a packed picture or a script that changes bytes. Record each change in the knowledge, and generate the source.
|
|
383
389
|
|
|
384
390
|
- A release is a PRG or the `image.json` of a capture, in a folder that git keeps, for example `original/`. The script refuses a file in `.c64-re-tools/local/`.
|
|
385
391
|
- A label is upper case, for example `ORIGINAL`, `FIRESTAR` or `V2`.
|
|
@@ -397,7 +403,17 @@ A rebuild keeps all of the program: unused bytes, dead code, old copies and left
|
|
|
397
403
|
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.
|
|
398
404
|
|
|
399
405
|
- Record only a screen of the program itself. Do not record a screen of a crack, for example a picture, an intro or a credit screen of a crack group.
|
|
400
|
-
-
|
|
406
|
+
- If a release changed the screen of the program, stop and ask the user how to deal with it. An example is a picture with the text of a crack in it. Do not decide alone. Give the user these options:
|
|
407
|
+
1. Record patches under a switch that take out the change.
|
|
408
|
+
2. Use the screen as it is.
|
|
409
|
+
3. Do not record a start screen.
|
|
410
|
+
- The bytes of the screen must be in the program of the knowledge at the entry, or in a captured stage. Thus capture the program while the bytes of the screen are in memory.
|
|
411
|
+
- When the bytes are only in a stage of the loading, do these steps:
|
|
412
|
+
1. Capture the stage while it shows the screen. Do not exclude the memory of the screen.
|
|
413
|
+
2. Put the capture into the knowledge in a space of its own, for example `image stage/image.json --space bank1`.
|
|
414
|
+
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 bank1`.
|
|
415
|
+
4. Record the start screen with `--stage bank1`, and with `--call` for the routine.
|
|
416
|
+
- With `--stage`, the addresses are in the program of that space. Each part and the call must be in it.
|
|
401
417
|
- Get the mode, the addresses and the colours from the VIC-II while the original program shows the screen.
|
|
402
418
|
- The colour RAM is not in the capture. Find the 1000 colour bytes in the program: compare them with the colour RAM at $d800 while the original shows the screen. Give their address with `--colours`. If the program does not have them, give one colour with `--colour`.
|
|
403
419
|
- `text` needs `--charset`. `hires` and `multicolour` need `--bitmap`. `text` and `multicolour` need `--colours` or `--colour`. `hires` uses neither.
|
|
@@ -405,7 +421,7 @@ A start screen is a loading screen, a title screen or a presentation screen of t
|
|
|
405
421
|
- 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.
|
|
406
422
|
- No part can be in $0000-$03ff. The colours cannot be in $d000-$dfff.
|
|
407
423
|
- A space has one start screen, and only the space `c64` has one. A write replaces the start screen of the knowledge.
|
|
408
|
-
- The generated source has the
|
|
424
|
+
- The generated source has the switches `START_SCREEN` and `LEFTOVERS`. Thus no symbol and no switch can have these names.
|
|
409
425
|
- `body.startScreen` gives the start screen after the write.
|
|
410
426
|
|
|
411
427
|
### `unstart-screen`
|
|
@@ -175,6 +175,8 @@ const startScreen = (row: StartScreenRow) => ({
|
|
|
175
175
|
...(row.colour === undefined ? {} : { colour: row.colour }),
|
|
176
176
|
border: row.border,
|
|
177
177
|
background: row.background,
|
|
178
|
+
...(row.stage === undefined ? {} : { stage: row.stage }),
|
|
179
|
+
...(row.call === undefined ? {} : { call: formatC64Address(row.call) }),
|
|
178
180
|
...(row.comment === undefined ? {} : { comment: row.comment }),
|
|
179
181
|
origin: row.origin,
|
|
180
182
|
revision: row.revision,
|
|
@@ -935,7 +937,7 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
935
937
|
writeCommand(
|
|
936
938
|
{
|
|
937
939
|
name: "start-screen",
|
|
938
|
-
summary: "Records the start screen of the program: a loading, title or presentation screen of the program itself
|
|
940
|
+
summary: "Records the start screen of the program: a loading, title or presentation screen of the program itself, in memory at the entry or in a captured stage of the loading. The loader of the generated source shows it and waits for a key or a fire button before the entry.",
|
|
939
941
|
options: {
|
|
940
942
|
mode: { kind: "choice", value: "<mode>", choices: START_SCREEN_MODES, help: `one of ${START_SCREEN_MODES.join(", ")}`, required: true },
|
|
941
943
|
screen: { kind: "address", value: "<address>", help: "the screen: the 1000 characters of a text screen, or the 1000 colour bytes of a bitmap", required: true },
|
|
@@ -945,15 +947,19 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
945
947
|
colour: { kind: "count", value: "<0-15>", min: 0, max: 15, help: "one colour for all of the colour RAM, in place of --colours" },
|
|
946
948
|
border: { kind: "count", value: "<0-15>", min: 0, max: 15, help: "the border colour", required: true },
|
|
947
949
|
background: { kind: "count", value: "<0-15>", min: 0, max: 15, help: "the background colour", required: true },
|
|
950
|
+
stage: { kind: "text", value: "<space>", help: "the space of a captured stage that holds the bytes of the screen, for example bank1. Without it, the bytes are in the program at the entry" },
|
|
951
|
+
call: { kind: "address", value: "<address>", help: "a routine of the stage that the start screen calls before it waits, for example the routine that starts the loading tune. It must return with RTS. Needs --stage" },
|
|
948
952
|
comment: { kind: "text", value: "<text>", help: "what the screen is" },
|
|
949
953
|
},
|
|
950
|
-
notes: "Record only a screen of the program itself, never a screen of a crack. text and multicolour need --colours or --colour; hires uses neither. A write replaces the start screen of the knowledge.",
|
|
954
|
+
notes: "Record only a screen of the program itself, never a screen of a crack. If a release changed the screen, for example with the text of a crack, stop and ask the user how to deal with it. text and multicolour need --colours or --colour; hires uses neither. With --stage, the addresses are in the program of that space. A write replaces the start screen of the knowledge.",
|
|
951
955
|
},
|
|
952
956
|
(call) => {
|
|
953
957
|
const context = contextOf(call);
|
|
954
958
|
const commentText = call.string("comment");
|
|
955
959
|
const optional = (key: "bitmap" | "charset" | "colours") => ((value) => (value === undefined ? {} : { [key]: value }))(call.address(key));
|
|
956
960
|
const colour = call.count("colour");
|
|
961
|
+
const stage = call.string("stage");
|
|
962
|
+
const routine = call.address("call");
|
|
957
963
|
const request = {
|
|
958
964
|
space: call.space,
|
|
959
965
|
mode: call.string("mode") as StartScreenMode,
|
|
@@ -964,6 +970,8 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
964
970
|
...(colour === undefined ? {} : { colour }),
|
|
965
971
|
border: call.count("border")!,
|
|
966
972
|
background: call.count("background")!,
|
|
973
|
+
...(stage === undefined ? {} : { stage }),
|
|
974
|
+
...(routine === undefined ? {} : { call: routine }),
|
|
967
975
|
...(commentText === undefined ? {} : { comment: commentText }),
|
|
968
976
|
};
|
|
969
977
|
return (db) => shown(setStartScreen(db, context, request), "startScreen", startScreen);
|
|
@@ -50,7 +50,8 @@ To get the command list, run the script with no arguments.
|
|
|
50
50
|
- 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.
|
|
51
51
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
52
52
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
53
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
53
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
54
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
54
55
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
55
56
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
56
57
|
- 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`.
|
|
@@ -49,7 +49,8 @@ To get the command list, run the script with no arguments.
|
|
|
49
49
|
- 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.
|
|
50
50
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
51
51
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
52
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
52
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
53
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
53
54
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
54
55
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
55
56
|
- 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`.
|
|
@@ -66,7 +66,8 @@ To get the command list, run the script with no arguments.
|
|
|
66
66
|
- 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.
|
|
67
67
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
68
68
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
69
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
69
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
70
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
70
71
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
71
72
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
72
73
|
- 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`.
|
|
@@ -37,7 +37,10 @@ These rules apply to each rebuild:
|
|
|
37
37
|
|
|
38
38
|
- Do not keep a cracktro. A capture of a packed program starts at the last stage, so the code of a cracktro is not in the program. When the capture has data of a cracktro that the program does not read, capture again and exclude that range.
|
|
39
39
|
- Keep the start screen of the program, for example the loading picture of the publisher. Keep its bytes in the capture, and record the start screen in the project knowledge. The loader of the rebuild then shows it and waits for a key or a fire button. Do not keep a screen of a crack, for example a picture, an intro or a credit screen of a crack group.
|
|
40
|
-
-
|
|
40
|
+
- When the start screen is only in a stage of the loading, capture that stage while it shows the screen. Put the capture into the project knowledge in a space of its own. Then record the start screen of that stage. Keep its tune: record the routine that starts the tune as the call of the start screen.
|
|
41
|
+
- A release can change the start screen, for example with the text of a crack. Then stop and ask the user how to deal with it. Do not decide alone.
|
|
42
|
+
- Keep all other bytes: unused bytes, dead code, old copies, texts and leftovers of the development. Record each one as a region with a comment. Do not remove them. The source keeps them, and the build of each release has them. The default build and the loader do not have them.
|
|
43
|
+
- Do not write a file of the rebuild by hand, for example a boot file, a packed picture or a script that changes bytes. Record each change in the project knowledge, and generate the source.
|
|
41
44
|
- Keep a copy protection in the source, off by default. Record a `protection` switch and its patches.
|
|
42
45
|
- Keep a trainer and a cheat in the source, off by default. Record a `trainer` or `cheat` switch and its patches.
|
|
43
46
|
- When two or more releases have different corrections, record each release and one `fix` switch for each correction. The switch names the releases that have the correction. The default build has all corrections.
|
|
@@ -131,7 +134,7 @@ If the project has no layout, use this one. No script checks it. Each script tak
|
|
|
131
134
|
```
|
|
132
135
|
original/ the disk image or the program as you got it
|
|
133
136
|
src/ the generated source
|
|
134
|
-
build/ the built programs
|
|
137
|
+
build/ the built programs. Do not commit them: each build writes them again.
|
|
135
138
|
tests/ the test scenarios, and the recordings in tests/recordings/
|
|
136
139
|
runs/ the runs that the knowledge gives as evidence
|
|
137
140
|
docs/ the documentation, with the reference in docs/reference/
|
|
@@ -139,7 +142,7 @@ tools/ scripts for the formats of this program only
|
|
|
139
142
|
README.md the entry page of the documentation
|
|
140
143
|
```
|
|
141
144
|
|
|
142
|
-
Commit each folder of the layout and `.c64-re-tools/knowledge/`. The knowledge holds the program, the entry state and the coverage, so the project needs no other folder for them. Put all other files that you make in `.c64-re-tools/local/`, also the captures and the coverage maps after you put them into the knowledge. Do not let git ignore a folder of the layout
|
|
145
|
+
Commit each folder of the layout other than `build/`, and `.c64-re-tools/knowledge/`. The knowledge holds the program, the entry state and the coverage, so the project needs no other folder for them. Put all other files that you make in `.c64-re-tools/local/`, also the captures and the coverage maps after you put them into the knowledge. Do not let git ignore a folder of the layout other than `build/`. Do not change the `.gitignore` files of the project.
|
|
143
146
|
|
|
144
147
|
If the project has a layout, use that layout.
|
|
145
148
|
|
|
@@ -58,7 +58,8 @@ To get the command list, run the script with no arguments.
|
|
|
58
58
|
- 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.
|
|
59
59
|
- The script refuses an `--out` path in `.c64-re-tools/knowledge/` and the index of the knowledge. Change the project knowledge only with the commands that change it.
|
|
60
60
|
- The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
|
|
61
|
-
- When a file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses evidence in that folder.
|
|
61
|
+
- When a test or another file is the evidence for a finding in the project knowledge, move it out of `.c64-re-tools/local/` first. The project knowledge refuses that evidence in that folder.
|
|
62
|
+
- A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
|
|
62
63
|
- Do not move a coverage map after you put it into the project knowledge. The knowledge refers to the map by its path at that time.
|
|
63
64
|
- Put a run that is evidence in `runs/<name>/`, with its run file, its results and its snapshot files. Change the paths in the run file to the new paths. Then git keeps them, and another person can do the run again.
|
|
64
65
|
- 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`.
|
|
@@ -71,10 +72,10 @@ Each flag applies only to the commands in the table. On another command, the scr
|
|
|
71
72
|
|
|
72
73
|
| Flag | Command | Effect |
|
|
73
74
|
|---|---|---|
|
|
74
|
-
| `--out <dir>` | `generate` | The folder for the source files. It is necessary. The script writes over the files of an earlier run. It removes a generated `.asm` file that this run does not write. A run without `--loader` keeps `loader.asm`, `loader.prg` and `
|
|
75
|
+
| `--out <dir>` | `generate` | The folder for the source files. It is necessary. The script writes over the files of an earlier run. It removes a generated `.asm` file that this run does not write. A run without `--loader` keeps `loader.asm`, `loader.prg`, `start_screen.asm` and `start_screen_stage.asm` of an earlier run. `staleLoader` tells when they are of another knowledge revision. |
|
|
75
76
|
| `--entry <address>` | `generate` | An address where code starts. Give the flag again for more addresses. There is no default. |
|
|
76
|
-
| `--space <space>` | `generate` | The knowledge space: `c64`, `drive8`, or `bank0` to `bank255`. The default is `c64`.
|
|
77
|
-
| `--loader` | `generate` | Also write `loader.asm` and `loader.prg`, and `start_screen.asm` when the knowledge has a start screen. It needs a capture in the knowledge. The default is no loader. |
|
|
77
|
+
| `--space <space>` | `generate` | The knowledge space: `c64`, `drive8`, or `bank0` to `bank255`. The default is `c64`. `--loader` and the platform names apply only to `c64`. The coverage is the coverage of the space. |
|
|
78
|
+
| `--loader` | `generate` | Also write `loader.asm` and `loader.prg`, and `start_screen.asm` when the knowledge has a start screen. A start screen of a captured stage also gives `start_screen_stage.asm`. The script writes `loader.prg` only after the check of the new loader ran. Else the `loader.prg` of an earlier run stays. It needs a capture in the knowledge. The default is no loader. |
|
|
78
79
|
| `--analyzer-names` | `generate` | Name an address without a name of the user or the LLM, and without a platform name, with its analyzer name, for example `FUN_17e2`. Without the flag, the source makes its own name, for example `l_17e2`. |
|
|
79
80
|
| `--to <folder>` | `export` | The folder of the new project. It is necessary. The script also writes `<folder>.zip` beside the folder. |
|
|
80
81
|
| `--name <name>` | `export` | The name of `baseline/<name>.prg` and `build/<name>.prg`. The default is the name of the folder. |
|
|
@@ -109,6 +110,7 @@ To make the source better, change the project knowledge. Then generate again.
|
|
|
109
110
|
- `asBytes`: the instructions that the source has as bytes.
|
|
110
111
|
- `notExecuted`: with coverage, the count of instructions that no run executed, and their ranges. `rest` names `not_executed.json`, which has all the ranges. Each range there has its source `file` and the `routine` before it.
|
|
111
112
|
- `unusedModules`: modules whose start is in no segment of the program. Often the program does not hold the code that the knowledge describes.
|
|
113
|
+
- `leftovers`: the bytes that nothing uses, with `bytes` and each range with its `file`. See "The leftovers". `noCoverage` tells that the knowledge has no coverage, so no range is a leftover.
|
|
112
114
|
- `operandExpressions`: the count of instructions with an operand expression.
|
|
113
115
|
- `operandsAsNumbers`: each operand expression that the source has as a number, with its `address`, `expression` and `reason`.
|
|
114
116
|
- `macroUses`: the count of macro uses in the source.
|
|
@@ -157,7 +159,8 @@ Do these actions for the findings:
|
|
|
157
159
|
- You can change a value in `config.asm` to 0 or 1. The next run keeps the values of the file. It adds a new switch with its default. It removes a switch that the knowledge does not have.
|
|
158
160
|
- When the knowledge has a start screen, `config.asm` also has `START_SCREEN = 1`. Set it to 0 to start the program at once. Then assemble `loader.asm` again.
|
|
159
161
|
- `start_screen.asm` is the code that shows the start screen and waits. It is the same for each program. `loader.asm` gives it the values of the start screen.
|
|
160
|
-
- `switches.asm` holds each release of the knowledge. `main.asm` and `loader.asm` include it first. The script writes it only when the knowledge has switches or releases. For each release, a block `!ifdef RELEASE_<label>` gives each switch the value of that release.
|
|
162
|
+
- `switches.asm` holds each release of the knowledge. `main.asm` and `loader.asm` include it first. The script writes it only when the knowledge has switches or releases, or when the source has leftovers. For each release, a block `!ifdef RELEASE_<label>` gives each switch the value of that release.
|
|
163
|
+
- `leftover_xxxx.asm` holds a range of leftovers. See "The leftovers".
|
|
161
164
|
- `macros.asm` holds the macros of the knowledge. `main.asm` and `loader.asm` include it.
|
|
162
165
|
|
|
163
166
|
#### Names in the source
|
|
@@ -189,15 +192,27 @@ Do these actions for the findings:
|
|
|
189
192
|
- A patch block has the code of the patch and NOP to the end of the range. `else` has the original code. The labels inside the range come before the zone as `name = * + n`.
|
|
190
193
|
- Alternatives are patches of two or more switches at one range. They follow as `} else { !if FIX_B {`. A line before them stops the build with `!error` when two of them are in.
|
|
191
194
|
|
|
195
|
+
#### The leftovers
|
|
196
|
+
|
|
197
|
+
A leftover is a range of the program that nothing uses: unused code, old copies and old data. The script finds the leftovers from the coverage, as the export finds its free ranges (see "The free ranges"). The start screen, the patches, the macro uses and the addresses that the code of a patch names are never leftovers.
|
|
198
|
+
|
|
199
|
+
- Each range of leftovers is a file `leftover_xxxx.asm`. When a range cuts a module, the module continues after the range in `<module>_xxxx.asm`. The module in the knowledge does not change.
|
|
200
|
+
- `main.asm` builds a leftover file only when `LEFTOVERS` is 1. When it is 0, the build skips the bytes. Thus the addresses after the range do not change.
|
|
201
|
+
- `config.asm` has `LEFTOVERS = 0`. Thus the default build is the clean program, without the leftovers.
|
|
202
|
+
- Each release has `LEFTOVERS = 1`. Thus the build of a release gives the bytes of its file.
|
|
203
|
+
- `loader.prg` never has the leftovers. The loader does not copy them, and the memory there keeps the bytes that were in it before.
|
|
204
|
+
- Without coverage, no range is a leftover. Put the coverage of the runs into the project knowledge. Then generate again.
|
|
205
|
+
- A leftover can be wrong when the coverage does not show a use. For example, the VIC-II reads a range, or the program reads a range before it writes it. Then a test of `loader.prg` fails. Record the region in the project knowledge, or put the coverage of more runs into it. Do not change the source.
|
|
206
|
+
|
|
192
207
|
#### Switches and releases
|
|
193
208
|
|
|
194
209
|
The program of the knowledge is the base release. The default build is the clean program: no copy protection, no trainer, no cheat, no crack change, and all corrections. Thus the default build can be different from the program.
|
|
195
210
|
|
|
196
211
|
The command does these checks. They use the defaults and the values of the knowledge, not the values in `config.asm`.
|
|
197
212
|
|
|
198
|
-
1. `check`: the build of the base release must give the program byte by byte. In this build, each switch has its base value.
|
|
213
|
+
1. `check`: the build of the base release must give the program byte by byte. In this build, each switch has its base value, and `LEFTOVERS` is 1.
|
|
199
214
|
2. `switches`: each switch alone at its other value. The build must have the same length as the base release. It can change bytes only in the patches of the switch.
|
|
200
|
-
3. `default`: the default build. It must have the same length. It can change bytes only in the patches of the switches in `default.in
|
|
215
|
+
3. `default`: the default build. It must have the same length. It can change bytes only in the patches of the switches in `default.in` and in the leftovers.
|
|
201
216
|
4. `releases`: each release, built with `RELEASE_<label>=1`, against the file of the release.
|
|
202
217
|
|
|
203
218
|
Each item of `switches` has `name`, `kind`, `default`, `base`, `define` and the patches.
|
|
@@ -223,7 +238,7 @@ The script writes a macro use only when the use gives the bytes of the program.
|
|
|
223
238
|
|
|
224
239
|
Build the program from the source in these ways:
|
|
225
240
|
|
|
226
|
-
- The build of `config.asm`: no option. With the defaults, this is the default build.
|
|
241
|
+
- The build of `config.asm`: no option. With the defaults, this is the default build, without the leftovers.
|
|
227
242
|
- A release: the build option `--release ORIGINAL`.
|
|
228
243
|
- One switch: set its value in `config.asm`, for example `TRAINER = 1`. Do not define a switch on the command line of the build. ACME stops with `Symbol already defined`, because `config.asm` also sets the switch.
|
|
229
244
|
|
|
@@ -233,7 +248,7 @@ Build the program from the source in these ways:
|
|
|
233
248
|
|
|
234
249
|
1. `10 SYS 2061` starts it.
|
|
235
250
|
2. It stops the interrupts and makes all RAM visible. It moves its copier to two free pages.
|
|
236
|
-
3. It copies each segment and the pages $0002-$03ff of the entry state into place. No copy writes over the packed bytes of a copy that has not run yet.
|
|
251
|
+
3. It copies each segment without the leftovers, and the pages $0002-$03ff of the entry state, into place. No copy writes over the packed bytes of a copy that has not run yet.
|
|
237
252
|
4. When the knowledge has a start screen and `START_SCREEN` is 1, it shows the start screen. It waits until the user releases all keys and fire buttons. Then it waits for a key, or for a fire button on joystick port 1 or 2, and for its release. A move of a joystick is not a key.
|
|
238
253
|
5. It sets the screen registers of the VIC-II and the VIC bank from the entry state. Then it waits for the raster line of the entry.
|
|
239
254
|
6. It sets the CIA timers, their latches and the interrupt masks from the entry state. A running timer gets the value that counts down to the timer value at the entry.
|
|
@@ -243,11 +258,11 @@ The copy table, the copier and the jump use labels, not numbers. `loader_from_xx
|
|
|
243
258
|
|
|
244
259
|
The loader changes the free stack byte below the stack pointer (`stackByte`). It does not set the SID, the time of day of the CIAs, the CIA interrupt flags or the interrupt registers of the VIC-II. A program that reads SID voice 3 for random numbers can thus give a different result. A start screen writes the colour RAM, and the loader does not set it again. When you compare the original and the rebuild, observe after the program sets its own random numbers.
|
|
245
260
|
|
|
246
|
-
The
|
|
261
|
+
The script builds and checks `loader.prg` with the values of `config.asm`. With the defaults, `loader.prg` is the clean program: no copy protection, all corrections and no leftovers. The entry state is the state of the base release. For a loader of a release, build `loader.asm` with the build option `--release <label>`. That loader also does not have the leftovers.
|
|
247
262
|
|
|
248
263
|
The start screen:
|
|
249
264
|
|
|
250
|
-
- The start screen needs the VIC-II values of the entry state. Its screen, bitmap, charset and colours must be in a segment of the program.
|
|
265
|
+
- The start screen needs the VIC-II values of the entry state. Its screen, bitmap, charset and colours must be in a segment of the program, or in a captured stage. See "The start screen of a captured stage".
|
|
251
266
|
- With a start screen, the copier uses three pages, not two.
|
|
252
267
|
- `loader.prg` always shows the start screen. To start the program at once, set `START_SCREEN = 0` in `config.asm`, and assemble `loader.asm`. Do not define `START_SCREEN` on the command line of the build: `config.asm` sets it. The build of a release does not read `config.asm`, so it shows the start screen.
|
|
253
268
|
- A test that runs `loader.prg` stops at the start screen, because the emulator cannot press a key of the keyboard matrix. Run until `loader_start_screen_wait`. Then set the PC to `loader_start_screen_continue`.
|
|
@@ -259,7 +274,9 @@ The start screen:
|
|
|
259
274
|
- `limits`: each CIA value that the loader cannot set as it was at the entry. An old capture has no CIA values. Then capture the program again at its entry point.
|
|
260
275
|
- `startScreen`: with a start screen, `shown: true` when the VIC-II had the values of the start screen, and `waits: true` when the start screen waited without a key. `wait` and `continue` are the addresses of the wait and of the code after it. The check sets the PC to `continue`, and then runs the loader to its jump.
|
|
261
276
|
- `packed`: `packedBytes` and `unpackedBytes` of the packed form.
|
|
262
|
-
-
|
|
277
|
+
- `stage`: the show stage of a start screen of a captured stage. It has the `space` of the stage and the address of the show `code`. It also has the `bytes` of the stage in `loader.prg`, the `stash` copies, `packedBytes` and `unpackedBytes`. `startScreen.stage` names the space.
|
|
278
|
+
- When the check of `loader.prg` cannot run, the script does not write `loader.prg`. The `loader.prg` of an earlier run stays as it was. `loader.asm` is new. `reason` tells why the check did not run.
|
|
279
|
+
- `kept`: when the result has no new `loader.prg`, the path of the `loader.prg` of an earlier run. That file is not of this source.
|
|
263
280
|
|
|
264
281
|
Do these actions when `verified` is `false`:
|
|
265
282
|
|
|
@@ -269,10 +286,29 @@ Do these actions when `verified` is `false`:
|
|
|
269
286
|
| `reason` about the packed form | If a tool is missing, stop the task and give the message to the user. If the free ranges are too small, write the loader by hand. If the check of the unpack fails, give the reason to the user. |
|
|
270
287
|
| `reason` that the source does not assemble | Correct the source first. The loader includes the source. |
|
|
271
288
|
| `reason` about the start screen | Correct the start screen in the project knowledge, or capture the program again with the start screen in memory. If the start screen is not necessary, remove it from the project knowledge. |
|
|
289
|
+
| `reason` about the show stage | If the reason names the coverage of the stage, run the stage with coverage. Put the map into the project knowledge in the space of the stage. If the memory is too small, capture the stage again with less memory. If a tool is missing, stop the task and give the message to the user. |
|
|
272
290
|
| `reason` that the check of `loader.prg` did not run | Stop the task and give the reason to the user. When the user tells you that the emulator is available, run the same command again. |
|
|
273
291
|
| `differences` | The loader ran. The list gives the bytes and the registers that are not equal. |
|
|
274
292
|
| `stop` | The loader did not get to its copier or its jump. `stop` gives the address and `port`, the value of $01. `history` gives the last 16 instructions. `cause` gives the first byte of the copier or of a copy that is not correct. |
|
|
275
293
|
|
|
294
|
+
#### The start screen of a captured stage
|
|
295
|
+
|
|
296
|
+
Often the loading stage of a program shows a picture that is not in memory at the entry. Then the knowledge has the picture in a captured stage: a space such as `bank1`. `--stage` of the start screen names that space. `--call` names a routine of the stage, for example the routine that starts the loading tune.
|
|
297
|
+
|
|
298
|
+
`loader.prg` then starts with a show stage, before the loader:
|
|
299
|
+
|
|
300
|
+
1. Exomizer unpacks the loader, the bytes of the stage and the show code. The bytes of the loader under the stage go to a stash in free memory.
|
|
301
|
+
2. The show code shows the start screen with `start_screen.asm`. With a call, it sets $01 to $37, starts the interrupts and calls the routine.
|
|
302
|
+
3. It waits for a key or a fire button, as the start screen in the program does.
|
|
303
|
+
4. It stops the interrupts and the sound, and it stops the screen. It sets the CIA timers as RUN leaves them.
|
|
304
|
+
5. It copies the stash back to the loader. Then it starts the loader.
|
|
305
|
+
|
|
306
|
+
- `loader.prg` has only the bytes of the stage that the start screen uses. These are the screen, the bitmap, the charset and the colours. With a call, they are also each byte of the stage that is not free from the call, as in "The free ranges". A call thus needs the coverage of the stage.
|
|
307
|
+
- The patches of the stage are in at the defaults of their switches. Thus a patch under a switch can remove the text of a crack from the picture.
|
|
308
|
+
- `start_screen_stage.asm` holds the show code and the bytes of the stage. Do not edit it. To make `loader.prg` again, run `generate --loader`.
|
|
309
|
+
- The show stage needs Exomizer. The show code needs free memory in $0400-$9fff or $c000-$cfff. When the memory is too small, the reason gives the largest free ranges.
|
|
310
|
+
- The check runs `loader.prg` to `loader_start_screen_wait` of the show stage. There, it compares the VIC-II with the start screen, and the screen bytes in memory with the stage. Then it sets the PC to `loader_start_screen_continue`, and it checks the loader as usual.
|
|
311
|
+
|
|
276
312
|
#### The packed loader
|
|
277
313
|
|
|
278
314
|
A loader file that loads into $d000 or higher writes the I/O area. When the program is too large for one loader file, `loader.asm` has the packed form:
|
|
@@ -283,7 +319,7 @@ A loader file that loads into $d000 or higher writes the I/O area. When the prog
|
|
|
283
319
|
|
|
284
320
|
To make the packed loader for other switch values, do these steps:
|
|
285
321
|
|
|
286
|
-
1. Assemble `main.asm` to `build/main.prg`.
|
|
322
|
+
1. Assemble `main.asm` to `build/main.prg`. The leftovers are $00 in this build.
|
|
287
323
|
2. Assemble `loader.asm` to `build/copier.prg`.
|
|
288
324
|
3. Pack the two files into `build/loader.prg`. The start address is the copier address in the comment at the start of `loader.asm`. The memory configuration at the exit is `$34`.
|
|
289
325
|
|
|
@@ -319,6 +355,7 @@ The build with these values can change bytes only in the patches. Then the comma
|
|
|
319
355
|
- `loader`: the copies, the copier, `stackByte` and `simulated: true`. The export does not run the loader.
|
|
320
356
|
- `noCoverage` or `unrooted`: why nothing became free without `--drop`.
|
|
321
357
|
- `spacesLeftOut`: the spaces that the export does not have. The export has only the space `c64`.
|
|
358
|
+
- `startScreenLeftOut`: the start screen is of a captured stage. The export does not have it, because the export has only the space `c64`.
|
|
322
359
|
|
|
323
360
|
On `PASS`, `hint` tells you to build and test the new project as its `README.md` tells. When the knowledge has no coverage, or `unreachableExecuted` has items, `hint` also tells how to make more ranges free.
|
|
324
361
|
On `FAIL`, `hint` gives the action for the stage:
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// copier, and the copier writes only pages $0002-$03ff. With a start
|
|
11
11
|
// screen in the knowledge, the copier shows it after the copies and waits for
|
|
12
12
|
// a key or a fire button: the code is start-screen.asm, the same for each program.
|
|
13
|
+
// The loader loads the segments without the leftovers: the ranges of the
|
|
14
|
+
// source that nothing uses are not in loader.prg.
|
|
13
15
|
|
|
14
16
|
import { readFileSync } from "node:fs";
|
|
15
17
|
import { fileURLToPath } from "node:url";
|
|
@@ -105,6 +107,8 @@ export interface PackedBlock {
|
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
export interface LoaderPlan {
|
|
110
|
+
/** The ranges that the loader puts in place: the segments without the leftovers. */
|
|
111
|
+
loaded: AddressRange[];
|
|
108
112
|
blocks: PackedBlock[];
|
|
109
113
|
copies: Copy[];
|
|
110
114
|
/** The first of the two free pages where the copier runs. */
|
|
@@ -173,7 +177,7 @@ export function startScreenPlan(row: StartScreenRow): StartScreenPlan {
|
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
/** The lines of loader.asm that give the start screen code its values. */
|
|
176
|
-
function startScreenValues(row: StartScreenRow, plan: StartScreenPlan): string[] {
|
|
180
|
+
export function startScreenValues(row: StartScreenRow, plan: StartScreenPlan): string[] {
|
|
177
181
|
const value = (name: string, number: number, comment?: string) => `c64_source_ss_${name} = ${formatC64Byte(number)}${comment === undefined ? "" : ` ; ${comment}`}`;
|
|
178
182
|
const font = row.charset !== undefined && isRomFont(row.charset) ? " (the character ROM)" : "";
|
|
179
183
|
const what = [`screen ${formatC64Address(row.screen)}`, ...(row.bitmap === undefined ? [] : [`bitmap ${formatC64Address(row.bitmap)}`]), ...(row.charset === undefined ? [] : [`charset ${formatC64Address(row.charset)}${font}`])];
|
|
@@ -223,7 +227,7 @@ const overlaps = (a: AddressRange, b: AddressRange) => a.start <= b.end && b.sta
|
|
|
223
227
|
const show = (range: AddressRange) => `${formatC64Address(range.start)}-${formatC64Address(range.end)}`;
|
|
224
228
|
|
|
225
229
|
/** Parts of `range` that no range in `holes` covers. */
|
|
226
|
-
function subtract(range: AddressRange, holes: AddressRange[]): AddressRange[] {
|
|
230
|
+
export function subtract(range: AddressRange, holes: AddressRange[]): AddressRange[] {
|
|
227
231
|
let pieces = [range];
|
|
228
232
|
for (const hole of holes) {
|
|
229
233
|
pieces = pieces.flatMap((piece) => {
|
|
@@ -445,7 +449,7 @@ export function ciaSection(state: EntryState): { ops: Op[]; plan: CiaPlan } | un
|
|
|
445
449
|
}
|
|
446
450
|
|
|
447
451
|
export interface LoaderInput {
|
|
448
|
-
/** The
|
|
452
|
+
/** The ranges to load, each with the files that hold it, in address order: the segments without the leftovers. */
|
|
449
453
|
segments: Array<AddressRange & { files: string[] }>;
|
|
450
454
|
byteAt: (address: number) => number;
|
|
451
455
|
state: EntryState;
|
|
@@ -549,7 +553,7 @@ export function planLoader(input: LoaderInput): LoaderPlan {
|
|
|
549
553
|
if (end > LOAD_LIMIT) return planPacked(input, blocks, cia, codeSize, screen, `The plain loader would end ${end > 0xffff ? "past $ffff" : `at ${formatC64Address(end)}`}, after ${formatC64Address(LOAD_LIMIT)}: loading it would write the I/O area.`);
|
|
550
554
|
// The CIA part and the start screen take room from the copy table in the copier's pages.
|
|
551
555
|
const maxCopies = Math.max(0, Math.min(TABLE_COPIES, Math.floor((copierBytes - codeSize - 2) / COPY_ENTRY)));
|
|
552
|
-
if (plain.length > maxCopies)
|
|
556
|
+
if (plain.length > maxCopies) return planPacked(input, blocks, cia, codeSize, screen, `The plain loader needs ${plain.length} copies, and its copier can do at most ${maxCopies}.`);
|
|
553
557
|
|
|
554
558
|
const order = copyOrder(plain);
|
|
555
559
|
if (order === undefined) {
|
|
@@ -621,6 +625,7 @@ export function planLoader(input: LoaderInput): LoaderPlan {
|
|
|
621
625
|
lines.push(" !word 0", "}", "}");
|
|
622
626
|
|
|
623
627
|
return {
|
|
628
|
+
loaded: input.segments.map(({ start, end }) => ({ start, end })),
|
|
624
629
|
blocks: blocks.map((block, index) => ({ what: block.what, range: block.range, packedAt: packedAt[index]!, bytes: block.bytes })),
|
|
625
630
|
copies,
|
|
626
631
|
copier,
|
|
@@ -719,6 +724,7 @@ function planPacked(input: LoaderInput, blocks: Block[], cia: ReturnType<typeof
|
|
|
719
724
|
parts.sort((a, b) => a.range.start - b.range.start);
|
|
720
725
|
for (const part of parts) lines.push("", ...part.text);
|
|
721
726
|
return {
|
|
727
|
+
loaded: input.segments.map(({ start, end }) => ({ start, end })),
|
|
722
728
|
blocks: pieces.map((piece) => ({ what: piece.what, range: piece.target, packedAt: piece.at, bytes: piece.bytes })),
|
|
723
729
|
copies,
|
|
724
730
|
copier,
|
|
@@ -735,7 +741,7 @@ function planPacked(input: LoaderInput, blocks: Block[], cia: ReturnType<typeof
|
|
|
735
741
|
const MAX_PACKED_COPIES = Math.floor((256 - 2) / COPY_ENTRY);
|
|
736
742
|
|
|
737
743
|
/** A piece of pages 0-3 in the packed form: its target and where the copier reads it. */
|
|
738
|
-
interface Piece {
|
|
744
|
+
export interface Piece {
|
|
739
745
|
what: string;
|
|
740
746
|
target: AddressRange;
|
|
741
747
|
at: number;
|
|
@@ -748,7 +754,7 @@ interface Piece {
|
|
|
748
754
|
* A part that does not fit in one range is split, and each piece is a copy.
|
|
749
755
|
* Undefined when the ranges are too small.
|
|
750
756
|
*/
|
|
751
|
-
function placePieces(ranges: AddressRange[], low: ReadonlyArray<{ what: string; range: AddressRange; bytes: (address: number) => number }>, distance: (range: AddressRange) => number): Piece[] | undefined {
|
|
757
|
+
export function placePieces(ranges: AddressRange[], low: ReadonlyArray<{ what: string; range: AddressRange; bytes: (address: number) => number }>, distance: (range: AddressRange) => number): Piece[] | undefined {
|
|
752
758
|
const left = ranges.map((range) => ({ ...range }));
|
|
753
759
|
const pieces: Piece[] = [];
|
|
754
760
|
let rest = low.reduce((sum, block) => sum + block.range.end - block.range.start + 1, 0);
|
|
@@ -815,24 +821,43 @@ export interface PackedLoader {
|
|
|
815
821
|
}
|
|
816
822
|
|
|
817
823
|
/**
|
|
818
|
-
* Packs the build of main.asm from $0400 and the build of
|
|
819
|
-
* copier wins where they overlap) with the entry at the copier
|
|
820
|
-
* and checks the unpack in the emulator of Exomizer: every byte
|
|
821
|
-
* builds, and the jump to the copier. Refuses by name when it does
|
|
824
|
+
* Packs the loaded ranges of the build of main.asm from $0400 and the build of
|
|
825
|
+
* loader.asm (the copier wins where they overlap) with the entry at the copier
|
|
826
|
+
* and $01 = $34, and checks the unpack in the emulator of Exomizer: every byte
|
|
827
|
+
* of the two builds, and the jump to the copier. Refuses by name when it does
|
|
828
|
+
* not hold.
|
|
822
829
|
*/
|
|
823
830
|
export async function packLoader(main: Uint8Array, copier: Uint8Array, plan: LoaderPlan, context: ToolContext): Promise<PackedLoader> {
|
|
824
|
-
|
|
831
|
+
return packParts(packedParts(main, copier, plan), plan.copier, 0x34, "main.asm and loader.asm", "the copier", context);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/** What Exomizer packs in the packed form: the loaded ranges of the build of main.asm from $0400, and the build of loader.asm. */
|
|
835
|
+
export function packedParts(main: Uint8Array, copier: Uint8Array, plan: Pick<LoaderPlan, "loaded">): Array<{ start: number; body: Uint8Array }> {
|
|
836
|
+
// The unpacker uses pages 0-3; the copier writes them. The leftovers between the loaded ranges are not packed.
|
|
825
837
|
const program = prgRange(main);
|
|
826
|
-
const
|
|
827
|
-
|
|
838
|
+
const ranges = plan.loaded.flatMap((range) => {
|
|
839
|
+
const start = Math.max(range.start, 0x0400, program.start);
|
|
840
|
+
const end = Math.min(range.end, program.start + program.body.length - 1);
|
|
841
|
+
return start <= end ? [{ start, body: program.body.subarray(start - program.start, end - program.start + 1) }] : [];
|
|
842
|
+
});
|
|
843
|
+
return [...ranges, prgRange(copier)];
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Packs parts (a later one wins where they overlap) into one program that
|
|
848
|
+
* unpacks itself, starts at `entry` with $01 = `exitMemory`, and checks the
|
|
849
|
+
* unpack in the emulator of Exomizer: every byte of the parts, and the jump
|
|
850
|
+
* to the entry. Refuses by name when it does not hold.
|
|
851
|
+
*/
|
|
852
|
+
export async function packParts(parts: ReadonlyArray<{ start: number; body: Uint8Array }>, entry: number, exitMemory: number, what: string, entryName: string, context: ToolContext): Promise<PackedLoader> {
|
|
828
853
|
const prg = (part: { start: number; body: Uint8Array }) => Buffer.concat([Buffer.from([part.start & 0xff, part.start >> 8]), part.body]);
|
|
829
|
-
const packed = await pack({ programs: parts.map(prg), entry
|
|
830
|
-
if (packed.entry !==
|
|
854
|
+
const packed = await pack({ programs: parts.map(prg), entry, exitMemory }, context);
|
|
855
|
+
if (packed.entry !== entry) throw new WireFailure("operation-failed", `The unpack in the emulator of Exomizer jumps to ${formatC64Address(packed.entry)}, not to ${entryName} at ${formatC64Address(entry)}.`);
|
|
831
856
|
const reference = mergedPrograms(parts);
|
|
832
857
|
const wrong = compareBuild(packed.unpacked, reference).segments.find((segment) => segment.result !== "identical");
|
|
833
858
|
if (wrong !== undefined) {
|
|
834
859
|
const first = wrong.firstDifference === undefined ? "" : `: the first is ${wrong.firstDifference.address}, ${wrong.firstDifference.built} and not ${wrong.firstDifference.reference}`;
|
|
835
|
-
throw new WireFailure("operation-failed", `The unpack in the emulator of Exomizer does not give ${wrong.start}-${wrong.end} of
|
|
860
|
+
throw new WireFailure("operation-failed", `The unpack in the emulator of Exomizer does not give ${wrong.start}-${wrong.end} of ${what} (${wrong.result}${first}).`);
|
|
836
861
|
}
|
|
837
862
|
const unpackedBytes = reference.segments.reduce((sum, segment) => sum + segment.end - segment.start + 1, 0);
|
|
838
863
|
return { program: packed.program, packedBytes: packed.program.length, unpackedBytes, ...(packed.cycles === undefined ? {} : { cycles: packed.cycles }) };
|