@henols/c64-re-tools 2.6.0-rc.5 → 2.6.0-rc.6

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.6.0-rc.5",
3
+ "version": "2.6.0-rc.6",
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",
@@ -355,7 +355,7 @@ Errors of this group:
355
355
  - Each address has one module, and each file name has one module.
356
356
  - A file name has letters, digits, underscores or hyphens, and ends in `.asm`. It can have one folder, for example `music/driver.asm`. A folder name has lower-case letters, digits, underscores or hyphens.
357
357
  - Put the modules of one part of the program in one folder, for example `music/`, `irq/` or `graphics/`.
358
- - The generated source has the files `main.asm`, `loader.asm`, `switches.asm`, `config.asm`, `constants.asm`, `macros.asm` and `start_screen.asm` already. It also has the folders `leftovers/` and `segments/`. Thus a module cannot have one of these files or folders, in upper or lower case.
358
+ - The generated source has the files `main.asm`, `loader.asm`, `switches.asm`, `config.asm`, `constants.asm`, `macros.asm` and `start_screen.asm` already. It also has the folders `leftovers/` and `segments/`. Thus a module cannot have one of these files, also in a folder, or one of these folders, in upper or lower case.
359
359
  - Two modules cannot have file names that are different only in upper or lower case.
360
360
  - The title becomes the first line of the file.
361
361
  - `body.module` gives the module after the write.
@@ -548,7 +548,7 @@ A macro writes a run of instructions as one line of the source, for example `+in
548
548
  ### `apply <file>`
549
549
 
550
550
  - `<file>` is a JSON list of writes. Give `-` to read the list from standard input.
551
- - `body` holds `revision`, `writes` and `replaced`. Each item of `replaced` has the number of the `write`, its `op` and its `previous`.
551
+ - `body` holds `revision`, `writes` and `replaced`. `replaced` lists each write that replaced a row of a different origin, for example an `llm` write over a `user` row. Each item has the number of the `write`, its `op` and its `previous`. A write over a row of the same origin is not in `replaced`.
552
552
  - All writes become one revision. If the knowledge refuses one write, the script writes nothing, and the `error` names the write.
553
553
  - Each write has `op` and the fields of the command with the same name. Each write can also have `space`. For example:
554
554
 
@@ -72,7 +72,7 @@ Each flag applies only to the commands in the table. On another command, the scr
72
72
 
73
73
  | Flag | Command | Effect |
74
74
  |---|---|---|
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`, the loader program, `start_screen.asm` and `start_screen_stage.asm` 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, also in a folder of `--out`. A folder with a generated `main.asm` is the source of another space, and it stays. A run without `--loader` keeps `loader.asm`, the loader program, `start_screen.asm` and `start_screen_stage.asm` of an earlier run. `staleLoader` tells when they are of another knowledge revision. |
76
76
  | `--entry <address>` | `generate` | An address where code starts. Give the flag again for more addresses. There is no default. |
77
77
  | `--space <space>` | `generate` | The knowledge space: `c64`, `drive8`, `loading`, 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
78
  | `--loader` | `generate` | Also write `loader.asm` and the loader program, 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 the loader program only after the check of the new loader ran. Else the loader program of an earlier run stays. It needs a capture in the knowledge. The default is no loader. |
@@ -767,7 +767,8 @@ function outside(ranges: readonly AddressRange[], others: readonly AddressRange[
767
767
  * not_executed.json). An earlier loader.asm stays unless this run has
768
768
  * --loader: a source of the user can include loader.asm. The files of a
769
769
  * module are in `out` or in one folder of it: a folder that the run leaves
770
- * empty goes too. Other files stay. Gives the paths it removed.
770
+ * empty goes too. A folder with a generated main.asm is the source of another
771
+ * space, and it stays. Other files stay. Gives the paths it removed.
771
772
  */
772
773
  function removeOldFiles(out: string, keep: ReadonlySet<string>, loaderRun: boolean): string[] {
773
774
  const removed: string[] = [];
@@ -787,6 +788,8 @@ function removeOldFiles(out: string, keep: ReadonlySet<string>, loaderRun: boole
787
788
  for (const entry of readdirSync(directory, { withFileTypes: true })) {
788
789
  const name = folder === "" ? entry.name : `${folder}/${entry.name}`;
789
790
  if (entry.isDirectory() && folder === "") {
791
+ const main = join(root, name, "main.asm");
792
+ if (existsSync(main) && readFileSync(main, "utf8").startsWith(GENERATED_MARK)) continue;
790
793
  // A folder of the user that held no generated file stays, also when it is empty.
791
794
  if (clean(name) > 0 && readdirSync(join(root, name)).length === 0) rmSync(join(root, name), { recursive: true, force: true });
792
795
  continue;
@@ -111,10 +111,15 @@ export const SEGMENT_FOLDER = "segments";
111
111
  /** The folders that c64-source writes itself: no module file is in them. */
112
112
  export const GENERATED_FOLDERS = [LEFTOVER_FOLDER, SEGMENT_FOLDER] as const;
113
113
 
114
- /** True for a generated file name in any letter case: the file systems of macOS and Windows ignore case. */
114
+ /**
115
+ * True for a generated file name in any letter case (the file systems of macOS
116
+ * and Windows ignore case), also in a folder: a folder with a generated
117
+ * main.asm is the source of another space, not a folder of modules.
118
+ */
115
119
  export function isGeneratedFile(file: string): boolean {
116
120
  const lower = file.toLowerCase();
117
- return (GENERATED_FILES as readonly string[]).includes(lower) || GENERATED_FOLDERS.some((folder) => lower.startsWith(`${folder}/`));
121
+ const name = lower.slice(lower.lastIndexOf("/") + 1);
122
+ return (GENERATED_FILES as readonly string[]).includes(name) || GENERATED_FOLDERS.some((folder) => lower.startsWith(`${folder}/`));
118
123
  }
119
124
 
120
125
  /**
@@ -762,7 +762,7 @@ function checkModule(request: ModuleRequest): void {
762
762
  throw new Refusal("invalid-input", "A module file is a name of letters, digits, underscores or hyphens (at most 60) that ends in .asm. It can have one folder of lower-case letters, digits, underscores or hyphens (at most 30), for example music/driver.asm.");
763
763
  }
764
764
  if (isGeneratedFile(request.file)) {
765
- throw new Refusal("invalid-input", `A module cannot have the file ${request.file}, because the generated source writes ${GENERATED_FILES.join(", ")} and the folders ${GENERATED_FOLDERS.map((folder) => `${folder}/`).join(", ")} itself, in any letter case. Give the module another file.`);
765
+ throw new Refusal("invalid-input", `A module cannot have the file ${request.file}, because the generated source writes ${GENERATED_FILES.join(", ")} in any folder, and the folders ${GENERATED_FOLDERS.map((folder) => `${folder}/`).join(", ")} itself, in any letter case. Give the module another file.`);
766
766
  }
767
767
  if (request.title !== undefined && (request.title.trim().length === 0 || request.title.length > MAX_COMMENT)) throw new Refusal("invalid-input", `A module title has 1 to ${MAX_COMMENT} characters.`);
768
768
  }