@henols/c64-re-tools 2.4.0 → 2.5.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henols/c64-re-tools",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Agent-friendly Commodore 64 engineering toolkit for reverse engineering, debugging, development and testing.",
5
5
  "license": "MIT",
6
6
  "author": "Henrik Olsson",
@@ -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
  ```
@@ -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`.
@@ -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`.
@@ -24,7 +24,7 @@ The most interesting parts for a reader are the development of the program and i
24
24
  - A release is a memory dump of a program that ran.
25
25
  - A crack put a text or a tag into the program.
26
26
  - A crack damaged a part of the program, for example a level that does not load.
27
- 8. **The rebuild.** Which release is the base release, the program of the knowledge. Which changes of the release to the machine state stay, and how the loader sets them. A table of the switches of the project knowledge: the name, the kind, the default and the releases that have the switch on. How to build the default program and each release. Which scenarios compare the original with the rebuild.
27
+ 8. **The rebuild.** Which release is the base release, the program of the knowledge. Which changes of the release to the machine state stay, and how the loader sets them. A table of the switches of the project knowledge: the name, the kind, the default and the releases that have the switch on. How to build the default program and each release. What the runs that compare the original with the rebuild do, in words.
28
28
  9. **Still open.** What is not known yet, and which run can find it.
29
29
  10. **The reference.** One line with a link to `docs/reference/index.md`.
30
30
 
@@ -53,7 +53,7 @@ Look for findings of these kinds. They are often the most useful to a reader:
53
53
 
54
54
  ## Findings
55
55
 
56
- - **<Title of the finding>.** <What happens, and why.> **Observed** in <run>. <What it means in practice, for example: a test can use it to make a run repeat (**Conclusion**).> See [combat.md](docs/combat.md).
56
+ - **<Title of the finding>.** <What happens, and why.> **Observed** in <what the run did>. <What it means in practice, for example: a test can use it to make a run repeat (**Conclusion**).> See [combat.md](docs/combat.md).
57
57
 
58
58
  ## How the program works
59
59
 
@@ -233,7 +233,7 @@ One page, `docs/protection.md`, that explains the copy protection of the program
233
233
  2. **Each check.** For each check, tell where it is and when it runs. Tell what it compares, and how the program hides it. Link the code of the check one time. Use a table for a summary of the checks, without links.
234
234
  3. **The effect of a failed check.** What the program does when a check fails. Examples are a crash at once, a slow change of code, damaged data and a wipe of memory. Tell how long the effect takes to show.
235
235
  4. **The releases.** In one or two sentences: which checks still run in each release. When a crack changed bytes of the program to stop a check, tell which bytes, and link the code of the change one time.
236
- 5. **The rebuild.** The switch that turns the protection off, the bytes that it changes, and the scenarios that show that the program runs without it.
236
+ 5. **The rebuild.** The switch that turns the protection off, the bytes that it changes, and the runs that show that the program operates without it. Tell in words what each run did.
237
237
  6. **Still open.** The checks that no run reached, and the run that can reach them.
238
238
 
239
239
  ## 8. The conventions block
@@ -29,7 +29,9 @@ These rules apply to each page that you write. The `link` command checks the rul
29
29
  - **Code**: the code shows it, and no run showed it.
30
30
  - **Conclusion**: an interpretation of the facts.
31
31
  - Put the mark at the end of the paragraph or the list item. When the facts of a paragraph have different evidence, mark each fact.
32
- - Do not link to the files of a run in `.c64-re-tools/local/`. Name the run in the text when it helps a reader to do the run again. A scenario in `tests/` and a run in `runs/` are part of the project. You can link them.
32
+ - Do not write the name of a JSON file in a page, and do not link to it. Examples are a scenario, a run file, a capture and a list that the source generation wrote. These files are input and output of the tools. They do not help a reader to understand the program.
33
+ - Tell in words what the run did and what it showed. An example: "a run fills each leftover with `$A5` at the entry, and the memory and the screen stay the same at all 10 checkpoints (**Observed**)".
34
+ - Do not link to a file in `.c64-re-tools/local/`.
33
35
  - Do not write a fact that you did not check in the code, the knowledge or a run. Put a question in **Still open**.
34
36
 
35
37
  ## Diagrams and images
@@ -52,6 +52,8 @@ The knowledge is text in `.c64-re-tools/knowledge/` of the project. Commit that
52
52
  | Write a switch | `switch PROTECTION --kind protection --releases ORIGINAL` |
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
+ | Record the start screen of the program | `start-screen --mode multicolour --screen '$5c00' --bitmap '$6000' --colours '$8328' --border 0 --background 0` |
56
+ | Remove the start screen | `unstart-screen` |
55
57
  | Write a macro | `macro inc16 --params dst --body-file inc16.asm` |
56
58
  | Write instructions as one use of a macro | `use '$1005-$100a' inc16 --args ptr` |
57
59
  | Do many writes as one revision | `apply .c64-re-tools/local/batch.json` |
@@ -85,7 +87,8 @@ The knowledge is text in `.c64-re-tools/knowledge/` of the project. Commit that
85
87
  - 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.
86
88
  - 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.
87
89
  - The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
88
- - 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.
90
+ - 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.
91
+ - A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
89
92
  - 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.
90
93
  - 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.
91
94
  - 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`.
@@ -129,7 +132,7 @@ Each flag applies only to the commands in the table. On another command, the scr
129
132
  | `--code <text>` | `patch` | The ACME code of the patch. |
130
133
  | `--code-file <file>` | `patch` | A project file with the ACME code of the patch. |
131
134
  | `--nop` | `patch` | The patch is NOP only. |
132
- | `--comment <text>` | `patch`, `switch`, `release`, `macro` | A comment for the row. A `patch`, `switch` or `macro` write without `--comment` keeps the comment that the row has. |
135
+ | `--comment <text>` | `patch`, `switch`, `release`, `macro`, `start-screen` | A comment for the row. A `patch`, `switch`, `macro` or `start-screen` write without `--comment` keeps the comment that the row has. |
133
136
  | `--default <0\|1>` | `switch` | The value in the default build. See the section of `switch`. |
134
137
  | `--releases <A,B>` | `switch` | The labels of the releases that have the switch on, as a comma list. A write without it keeps the releases that the switch has. |
135
138
  | `--file <file>` | `release` | Necessary. The PRG or `image.json` of the release, in a folder that git keeps. |
@@ -138,6 +141,14 @@ Each flag applies only to the commands in the table. On another command, the scr
138
141
  | `--body <text>` | `macro` | The body of the macro. |
139
142
  | `--body-file <file>` | `macro` | A project file with the body of the macro. |
140
143
  | `--args <x, y>` | `use` | One expression for each param of the macro, as a comma list. |
144
+ | `--mode <mode>` | `start-screen` | Necessary. The mode of the VIC-II: `text`, `hires` or `multicolour`. |
145
+ | `--screen <address>` | `start-screen` | Necessary. The address of the screen memory: 1000 bytes. |
146
+ | `--bitmap <address>` | `start-screen` | The address of the bitmap: 8000 bytes. `hires` and `multicolour` need it. |
147
+ | `--charset <address>` | `start-screen` | The address of the charset: 2048 bytes. `text` needs it. |
148
+ | `--colours <address>` | `start-screen` | The address of the 1000 bytes that the loader copies to the colour RAM. |
149
+ | `--colour <0-15>` | `start-screen` | One colour for all of the colour RAM, in place of `--colours`. |
150
+ | `--border <0-15>` | `start-screen` | Necessary. The border colour. |
151
+ | `--background <0-15>` | `start-screen` | Necessary. The background colour. |
141
152
 
142
153
  ---
143
154
 
@@ -223,6 +234,7 @@ When a git merge left conflicts in the knowledge, each read body also has `confl
223
234
 
224
235
  - `body.image` is `null` when the knowledge has no program in the space. Then put the program in with `image`.
225
236
  - Else `body.image` has `segments`, `bytes`, `entry`, `state` and `stages`. `state` is `true` when the knowledge has the entry state of a capture. `stages` is the number of unpacker stages.
237
+ - `body.startScreen` gives the start screen of the space, when the knowledge has one.
226
238
  - `body.coverage.maps` lists the coverage maps of the space. `body.coverage.ranges` gives the number of ranges of each access kind.
227
239
 
228
240
  ### `listing <range>`
@@ -238,7 +250,7 @@ When a git merge left conflicts in the knowledge, each read body also has `confl
238
250
  ### `export`
239
251
 
240
252
  - `body` holds `counts`, `revision`, `out`, `bytes` and `sha256`. `counts` gives the number of rows of each kind in the file.
241
- - The file has all current knowledge of the space in the range, with the analyzer names and the source knowledge.
253
+ - The file has all current knowledge of the space in the range, with the analyzer names and the source knowledge. `startScreen` is the start screen, when the knowledge has one.
242
254
 
243
255
  ---
244
256
 
@@ -368,7 +380,7 @@ An operand expression tells the generated source how to write the operand of one
368
380
 
369
381
  ### `release <label>`
370
382
 
371
- 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. Only a cracktro is not in the rebuild.
383
+ 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.
372
384
 
373
385
  - 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/`.
374
386
  - A label is upper case, for example `ORIGINAL`, `FIRESTAR` or `V2`.
@@ -381,6 +393,26 @@ A rebuild keeps all of the program: unused bytes, dead code, old copies and left
381
393
 
382
394
  - The knowledge refuses a release that a switch names. It also refuses the base release while the knowledge has switches.
383
395
 
396
+ ### `start-screen`
397
+
398
+ 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.
399
+
400
+ - 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.
401
+ - The bytes of the screen must be in the program of the knowledge at the entry. Thus capture the program while the bytes of the screen are in memory.
402
+ - Get the mode, the addresses and the colours from the VIC-II while the original program shows the screen.
403
+ - 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`.
404
+ - `text` needs `--charset`. `hires` and `multicolour` need `--bitmap`. `text` and `multicolour` need `--colours` or `--colour`. `hires` uses neither.
405
+ - 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.
406
+ - 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.
407
+ - No part can be in $0000-$03ff. The colours cannot be in $d000-$dfff.
408
+ - A space has one start screen, and only the space `c64` has one. A write replaces the start screen of the knowledge.
409
+ - The generated source has the switch `START_SCREEN`. Thus no symbol and no switch can have that name.
410
+ - `body.startScreen` gives the start screen after the write.
411
+
412
+ ### `unstart-screen`
413
+
414
+ - Removes the start screen. The loader of the generated source then starts the program at once.
415
+
384
416
  ### `switch <name>`
385
417
 
386
418
  A switch has a kind, a default, and the releases that have it on. The generated source writes all switches with their defaults.
@@ -25,6 +25,7 @@ import {
25
25
  commentsAt,
26
26
  coverageRuns,
27
27
  currentRevision,
28
+ currentStartScreen,
28
29
  listAnalyzerNames,
29
30
  listComments,
30
31
  listMacros,
@@ -53,11 +54,12 @@ import {
53
54
  type ReferenceRow,
54
55
  type RegionRow,
55
56
  type ReleaseRow,
57
+ type StartScreenRow,
56
58
  type SuppressionRow,
57
59
  type SwitchRow,
58
60
  type SymbolRow,
59
61
  } from "#src/knowledge/read.ts";
60
- import { ANALYZERS, COMMENT_PLACEMENTS, DEFAULT_SPACE, EVIDENCE_KINDS, isSemantic, OPERAND_SELECTS, ORIGINS, REFERENCE_KINDS, REGION_TYPES, RELEASE_DEFINE, SEMANTIC_ORIGINS, SWITCH_KINDS, SYMBOL_KINDS, type Origin, type OperandSelect, type SwitchKind } from "#src/knowledge/schema.ts";
62
+ import { ANALYZERS, COMMENT_PLACEMENTS, DEFAULT_SPACE, EVIDENCE_KINDS, isSemantic, OPERAND_SELECTS, ORIGINS, REFERENCE_KINDS, REGION_TYPES, RELEASE_DEFINE, SEMANTIC_ORIGINS, START_SCREEN_MODES, SWITCH_KINDS, SYMBOL_KINDS, type Origin, type OperandSelect, type StartScreenMode, type SwitchKind } from "#src/knowledge/schema.ts";
61
63
  import {
62
64
  addReference,
63
65
  applyBatch,
@@ -71,6 +73,7 @@ import {
71
73
  removePatch,
72
74
  removeReference,
73
75
  removeRelease,
76
+ removeStartScreen,
74
77
  removeSwitch,
75
78
  removeSymbol,
76
79
  renameSymbol,
@@ -78,6 +81,7 @@ import {
78
81
  setComment,
79
82
  setMacro,
80
83
  setMacroUse,
84
+ setStartScreen,
81
85
  setModule,
82
86
  setOperand,
83
87
  setPatch,
@@ -162,6 +166,19 @@ const release = (row: ReleaseRow) => ({
162
166
  origin: row.origin,
163
167
  revision: row.revision,
164
168
  });
169
+ const startScreen = (row: StartScreenRow) => ({
170
+ mode: row.mode,
171
+ screen: formatC64Address(row.screen),
172
+ ...(row.bitmap === undefined ? {} : { bitmap: formatC64Address(row.bitmap) }),
173
+ ...(row.charset === undefined ? {} : { charset: formatC64Address(row.charset) }),
174
+ ...(row.colours === undefined ? {} : { colours: formatC64Address(row.colours) }),
175
+ ...(row.colour === undefined ? {} : { colour: row.colour }),
176
+ border: row.border,
177
+ background: row.background,
178
+ ...(row.comment === undefined ? {} : { comment: row.comment }),
179
+ origin: row.origin,
180
+ revision: row.revision,
181
+ });
165
182
  const macro = (row: MacroRow) => ({ ...spaceOf(row), name: row.name, params: row.params, body: row.body, ...(row.comment === undefined ? {} : { comment: row.comment }), origin: row.origin, revision: row.revision });
166
183
  const macroUse = (row: MacroUseRow) => ({
167
184
  ...spaceOf(row),
@@ -213,6 +230,8 @@ function historyEntry(entry: HistoryEntry) {
213
230
  ? switchRow(entry.row)
214
231
  : entry.entity === "release"
215
232
  ? release(entry.row)
233
+ : entry.entity === "start-screen"
234
+ ? startScreen(entry.row)
216
235
  : entry.entity === "macro"
217
236
  ? macro(entry.row)
218
237
  : entry.entity === "macro-use"
@@ -594,6 +613,7 @@ const READ_COMMANDS: CommandSpec[] = [
594
613
  state: image.state !== undefined,
595
614
  stages: image.stages?.length ?? 0,
596
615
  },
616
+ ...((row) => (row === undefined ? {} : { startScreen: startScreen(row) }))(currentStartScreen(db, call.space)),
597
617
  coverage: { maps: [...new Set(coverageRuns(db).filter((run) => run.space === call.space).map((run) => run.name))], ranges: Object.fromEntries(ranges.map((row) => [row.kind, row.count])) },
598
618
  };
599
619
  }),
@@ -658,6 +678,7 @@ const READ_COMMANDS: CommandSpec[] = [
658
678
  releases: listReleases(db, origins, space).map(release),
659
679
  macros: listMacros(db, origins, space).map(macro),
660
680
  macroUses: listMacroUses(db, range, undefined, origins, space).map(macroUse),
681
+ ...((row) => (row === undefined ? {} : { startScreen: startScreen(row) }))(currentStartScreen(db, space)),
661
682
  };
662
683
  const counts = Object.fromEntries(Object.entries(exported).flatMap(([key, value]) => (Array.isArray(value) ? [[key, value.length]] : [])));
663
684
  return { counts, revision: exported.revision, ...writeReported(call.string("out")!, `${JSON.stringify(exported, null, 2)}\n`, { what: "--out" }) };
@@ -911,6 +932,48 @@ const WRITE_COMMANDS: CommandSpec[] = [
911
932
  const request = { space: call.space, label: call.subject(0) };
912
933
  return (db) => ({ revision: removeRelease(db, context, request).revision });
913
934
  }),
935
+ writeCommand(
936
+ {
937
+ name: "start-screen",
938
+ summary: "Records the start screen of the program: a loading, title or presentation screen of the program itself that is still in memory at the entry. The loader of the generated source shows it and waits for a key or a fire button before the entry.",
939
+ options: {
940
+ mode: { kind: "choice", value: "<mode>", choices: START_SCREEN_MODES, help: `one of ${START_SCREEN_MODES.join(", ")}`, required: true },
941
+ 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 },
942
+ bitmap: { kind: "address", value: "<address>", help: "the 8000 bytes of the bitmap. hires and multicolour need it" },
943
+ charset: { kind: "address", value: "<address>", help: "the 2048 bytes of the charset, or '$1000' or '$1800' for the character ROM in VIC bank 0. text needs it" },
944
+ colours: { kind: "address", value: "<address>", help: "the 1000 bytes that the loader copies to the colour RAM" },
945
+ colour: { kind: "count", value: "<0-15>", min: 0, max: 15, help: "one colour for all of the colour RAM, in place of --colours" },
946
+ border: { kind: "count", value: "<0-15>", min: 0, max: 15, help: "the border colour", required: true },
947
+ background: { kind: "count", value: "<0-15>", min: 0, max: 15, help: "the background colour", required: true },
948
+ comment: { kind: "text", value: "<text>", help: "what the screen is" },
949
+ },
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.",
951
+ },
952
+ (call) => {
953
+ const context = contextOf(call);
954
+ const commentText = call.string("comment");
955
+ const optional = (key: "bitmap" | "charset" | "colours") => ((value) => (value === undefined ? {} : { [key]: value }))(call.address(key));
956
+ const colour = call.count("colour");
957
+ const request = {
958
+ space: call.space,
959
+ mode: call.string("mode") as StartScreenMode,
960
+ screen: call.address("screen")!,
961
+ ...optional("bitmap"),
962
+ ...optional("charset"),
963
+ ...optional("colours"),
964
+ ...(colour === undefined ? {} : { colour }),
965
+ border: call.count("border")!,
966
+ background: call.count("background")!,
967
+ ...(commentText === undefined ? {} : { comment: commentText }),
968
+ };
969
+ return (db) => shown(setStartScreen(db, context, request), "startScreen", startScreen);
970
+ },
971
+ ),
972
+ writeCommand({ name: "unstart-screen", summary: "Removes the start screen. The loader of the generated source then starts the program at once." }, (call) => {
973
+ const context = contextOf(call);
974
+ const request = { space: call.space };
975
+ return (db) => ({ revision: removeStartScreen(db, context, request).revision });
976
+ }),
914
977
  writeCommand(
915
978
  {
916
979
  name: "macro",
@@ -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`.
@@ -36,6 +36,7 @@ Do the specialist work of each task as that task tells. Do not do it in another
36
36
  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
+ - 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.
39
40
  - 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.
40
41
  - Keep a copy protection in the source, off by default. Record a `protection` switch and its patches.
41
42
  - Keep a trainer and a cheat in the source, off by default. Record a `trainer` or `cheat` switch and its patches.
@@ -130,7 +131,7 @@ If the project has no layout, use this one. No script checks it. Each script tak
130
131
  ```
131
132
  original/ the disk image or the program as you got it
132
133
  src/ the generated source
133
- build/ the built programs
134
+ build/ the built programs. Do not commit them: each build writes them again.
134
135
  tests/ the test scenarios, and the recordings in tests/recordings/
135
136
  runs/ the runs that the knowledge gives as evidence
136
137
  docs/ the documentation, with the reference in docs/reference/
@@ -138,7 +139,7 @@ tools/ scripts for the formats of this program only
138
139
  README.md the entry page of the documentation
139
140
  ```
140
141
 
141
- 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. Do not change the `.gitignore` files of the project.
142
+ 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.
142
143
 
143
144
  If the project has a layout, use that layout.
144
145
 
@@ -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` and `loader.prg` of an earlier run. `staleLoader` tells when they are of another knowledge revision. |
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` and `start_screen.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
77
  | `--space <space>` | `generate` | The knowledge space: `c64`, `drive8`, or `bank0` to `bank255`. The default is `c64`. The coverage, `--loader` and the platform names apply only to `c64`. |
77
- | `--loader` | `generate` | Also write `loader.asm` and `loader.prg`. It needs a capture in the knowledge. The default is no loader. |
78
+ | `--loader` | `generate` | Also write `loader.asm` and `loader.prg`, and `start_screen.asm` when the knowledge has a start screen. 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. |
@@ -155,6 +156,8 @@ Do these actions for the findings:
155
156
  - After the side comment, `Used:` counts how the source uses the name. The kinds are `read`, `written`, `modified`, `called`, `jumped to`, `jumped through`, `branched to`, `pointer`, `address`, `table` and `macro argument`. `address` is an immediate operand expression. `table` is an entry in a table of addresses.
156
157
  - `config.asm` holds the value of each switch, for example `PROTECTION = 0`. The switches are in groups by kind. The side comment gives the releases that have the switch on, the ranges of its patches and the comment of the switch.
157
158
  - 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.
159
+ - 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.
160
+ - `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.
158
161
  - `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.
159
162
  - `macros.asm` holds the macros of the knowledge. `main.asm` and `loader.asm` include it.
160
163
 
@@ -232,23 +235,33 @@ Build the program from the source in these ways:
232
235
  1. `10 SYS 2061` starts it.
233
236
  2. It stops the interrupts and makes all RAM visible. It moves its copier to two free pages.
234
237
  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.
235
- 4. 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.
236
- 5. 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.
237
- 6. It sets $00/$01, the stack pointer, A, X, Y and the flags. Then it jumps to the entry.
238
+ 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.
239
+ 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.
240
+ 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.
241
+ 7. It sets $00/$01, the stack pointer, A, X, Y and the flags. Then it jumps to the entry.
238
242
 
239
243
  The copy table, the copier and the jump use labels, not numbers. `loader_from_xxxx` and `loader_end_xxxx` are around each packed segment. `loader_to_xxxx` is its first address in place. Thus a segment can change its length, and the loader still works.
240
244
 
241
- 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. When you compare the original and the rebuild, observe after the program sets its own random numbers.
245
+ 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.
242
246
 
243
247
  The entry state is the state of the base release. Thus the script builds and checks `loader.prg` with the switch values of the base release. For a loader of the default build, build `loader.asm` with no option.
244
248
 
249
+ The start screen:
250
+
251
+ - 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.
252
+ - With a start screen, the copier uses three pages, not two.
253
+ - `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.
254
+ - 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`.
255
+
245
256
  `loader` holds these fields:
246
257
 
247
258
  - `program`, the `copies` in their order, `copier` and `stackByte`.
248
259
  - `verified: true`: the check ran `loader.prg` to its jump to the entry. There, the memory, $00/$01, the registers and the VIC-II are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the original program.
249
260
  - `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.
261
+ - `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.
250
262
  - `packed`: `packedBytes` and `unpackedBytes` of the packed form.
251
- - When the check of `loader.prg` cannot run, the script removes `loader.prg`. `loader.asm` stays. `reason` tells why the check did not run.
263
+ - 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.
264
+ - `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.
252
265
 
253
266
  Do these actions when `verified` is `false`:
254
267
 
@@ -257,6 +270,7 @@ Do these actions when `verified` is `false`:
257
270
  | `reason` about the copy order, the free pages or the count of copies | The reason gives the ranges. Capture the program again with fewer segments, or write the loader by hand. |
258
271
  | `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. |
259
272
  | `reason` that the source does not assemble | Correct the source first. The loader includes the source. |
273
+ | `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. |
260
274
  | `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. |
261
275
  | `differences` | The loader ran. The list gives the bytes and the registers that are not equal. |
262
276
  | `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. |
@@ -340,7 +354,7 @@ Data becomes free only when all of these are true:
340
354
  - No code that stays reads it or names it. No table that stays has an entry in it.
341
355
  - It is not at the first address of the program, and not at $fffa-$ffff.
342
356
 
343
- The coverage does not show the reads of the VIC-II. Thus `charset`, `sprite`, `bitmap` and `screen` data stay, unless `--drop` names them. Bytes without a region also stay.
357
+ The coverage does not show the reads of the VIC-II. Thus `charset`, `sprite`, `bitmap` and `screen` data stay, unless `--drop` names them. The bytes of the start screen always stay. Bytes without a region also stay.
344
358
 
345
359
  The entry is the entry of the knowledge. Without it, the entry is the address of the first SYS in the BASIC line of the program. Without coverage, nothing becomes free without `--drop`. Without an entry and without the hardware vectors in the program, no code is unreachable.
346
360
 
@@ -354,8 +368,8 @@ tests/ the tests of the project, changed for the new program
354
368
  .c64-re-tools/knowledge/ the knowledge of the new program
355
369
  ```
356
370
 
357
- - The source has no mark line, no `switches.asm` or `config.asm`, no patch zones and no `; not executed` lines. It keeps the names, the comments, the operand expressions and the macros. A line comment at each changed patch gives the switch, its kind, its value and the comments.
358
- - The knowledge has one revision `export`. It holds the program, the entry and its state, the names, the comments, the regions and the modules. It has no history, analyzer names, references, operand expressions, macros, patches, switches, releases or coverage.
371
+ - The source has no mark line, no `switches.asm` or `config.asm`, no patch zones and no `; not executed` lines. A start screen stays in the loader. Build with `-DSTART_SCREEN=0` to start the program at once. It keeps the names, the comments, the operand expressions and the macros. A line comment at each changed patch gives the switch, its kind, its value and the comments.
372
+ - The knowledge has one revision `export`. It holds the program, the entry and its state, the names, the comments, the regions, the modules and the start screen. It has no history, analyzer names, references, operand expressions, macros, patches, switches, releases or coverage.
359
373
  - A scenario of `tests/` compares the build of the new project with the baseline. Both sides are the same program. Thus a step of the original side alone goes. A step of the rebuild side alone runs on both sides.
360
374
  - A run file of `tests/` runs the build of the new project. Scenarios and run files take the names from the symbol files.
361
375
  - The export leaves out a test that restores a snapshot. It also leaves out a test with a name that the new program does not have, or with an address in a free range.
@@ -403,6 +403,8 @@ export interface ReadmeInput {
403
403
  free: readonly FreeRange[];
404
404
  switches: ReadonlyArray<{ name: string; kind: string; value: number }>;
405
405
  tests: { written: ReadonlyArray<{ file: string; kind: "scenario" | "run" }>; leftOut: ReadonlyArray<{ file: string; reason: string }> };
406
+ /** The loader shows the start screen of the program. */
407
+ startScreen?: boolean;
406
408
  }
407
409
 
408
410
  /** The README of the new project: the build and the tests first, then the free ranges, the files and where the program comes from. */
@@ -426,6 +428,7 @@ export function readmeText(input: ReadmeInput): string {
426
428
  "```",
427
429
  `acme -f cbm -o ../build/${name}.prg ${input.entryFile}`,
428
430
  "```",
431
+ ...(input.startScreen === true ? ["", "The loader shows the start screen of the program and waits for a key or a fire button. To start the program at once, add `-DSTART_SCREEN=0` to the command."] : []),
429
432
  "",
430
433
  "## Test",
431
434
  "",