@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.
@@ -10,7 +10,7 @@
10
10
  // FAIL.
11
11
 
12
12
  import { createHash } from "node:crypto";
13
- import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
13
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
14
14
  import { basename, join, relative, sep } from "node:path";
15
15
 
16
16
  import { isRefusal, Refusal } from "#src/errors.ts";
@@ -26,8 +26,8 @@ import { conflicts } from "#src/knowledge/conflicts.ts";
26
26
  import { openForRead, withWrite } from "#src/knowledge/database.ts";
27
27
  import { identifiers } from "#src/knowledge/expression.ts";
28
28
  import { analyzedBytes, memoryRows, programCoverage, requireProgram, type ProgramImage } from "#src/knowledge/program.ts";
29
- import { ANALYZER_NAME_ORDER, baseValue, currentRevision, listAnalyzerNames, listComments, listMacros, listMacroUses, listModules, listOperands, listPatches, listReferences, listRegions, listReleases, listSpaces, listSwitches, listSymbols, type ReleaseRow, type SymbolRow } from "#src/knowledge/read.ts";
30
- import { CODE_REGION_TYPES, DEFAULT_SPACE, isSemantic, RELEASE_DEFINE, type Space } from "#src/knowledge/schema.ts";
29
+ import { ANALYZER_NAME_ORDER, baseValue, currentRevision, currentStartScreen, startScreenRanges, listAnalyzerNames, listComments, listMacros, listMacroUses, listModules, listOperands, listPatches, listReferences, listRegions, listReleases, listSpaces, listSwitches, listSymbols, type ReleaseRow, type SymbolRow } from "#src/knowledge/read.ts";
30
+ import { CODE_REGION_TYPES, DEFAULT_SPACE, isSemantic, RELEASE_DEFINE, START_SCREEN_SWITCH, type Space } from "#src/knowledge/schema.ts";
31
31
  import { subtract, write } from "#src/knowledge/write.ts";
32
32
  import { assemble, symbolsFileText } from "#src/native/acme.ts";
33
33
  import { analyze } from "#src/native/ghidra/analyze.ts";
@@ -39,10 +39,28 @@ import { isoCet } from "#src/time.ts";
39
39
  import { zipFiles } from "#src/zip.ts";
40
40
  import { listed, OPTIONS, reply, runScript, UsageError, type Call, type Reply } from "#src/script.ts";
41
41
  import { knowledgeNames } from "#src/knowledge/names.ts";
42
- import { COPIER_SOURCE, LOADER_JUMP, loaderLimits, packLoader, planLoader, rasterLine, loaderState, simulate, stopCause, VIC_DISPLAY_REGISTERS, type EntryState, type LoaderPlan, type PackedLoader } from "./lib/loader.ts";
42
+ import {
43
+ COPIER_SOURCE,
44
+ LOADER_JUMP,
45
+ loaderLimits,
46
+ packLoader,
47
+ planLoader,
48
+ rasterLine,
49
+ loaderState,
50
+ simulate,
51
+ START_SCREEN_CODE,
52
+ START_SCREEN_CONTINUE,
53
+ START_SCREEN_FILE,
54
+ START_SCREEN_WAIT,
55
+ stopCause,
56
+ VIC_DISPLAY_REGISTERS,
57
+ type EntryState,
58
+ type LoaderPlan,
59
+ type PackedLoader,
60
+ } from "./lib/loader.ts";
43
61
  import { instructionWith, OPCODES } from "#src/opcodes.ts";
44
62
  import { freeName, planDrops, readmeText, rewriteTest } from "./lib/export.ts";
45
- import { CONFIG_FILE, configText, configValues, entriesInData, entryOutsideImage, hasSwitchFile, layout, literalOperand, probeForms, render, switchesOf, type Layout, type PatchBlock, type Rendered, type SourceSwitch } from "./lib/source.ts";
63
+ import { CONFIG_FILE, configText, configValues, entriesInData, entryOutsideImage, hasConfigFile, hasSwitchFile, layout, literalOperand, probeForms, render, switchesOf, type Layout, type PatchBlock, type Rendered, type SourceSwitch } from "./lib/source.ts";
46
64
 
47
65
  /** At most this many diagnostics or differences of one check. */
48
66
  const MAX_DIAGNOSTICS = 20;
@@ -87,6 +105,8 @@ function readKnowledge(space: Space, analyzerNames = false) {
87
105
  releases,
88
106
  macros: listMacros(db, undefined, space),
89
107
  macroUses: listMacroUses(db, undefined, undefined, undefined, space),
108
+ // The start screen is of the C64 program: the loader shows it.
109
+ startScreen: space === DEFAULT_SPACE ? currentStartScreen(db, space) : undefined,
90
110
  };
91
111
  } finally {
92
112
  db?.close();
@@ -409,7 +429,7 @@ function compareBuilds(built: Assembled, ranges: readonly AddressRange[], base:
409
429
  * from config.asm: a define of a switch is an error, because config.asm also
410
430
  * gives it a value. A switch without a value has its default.
411
431
  */
412
- function withValues(files: Array<{ name: string; text: string }>, laid: Pick<Layout, "switches" | "patches">, values: ReadonlyMap<string, number>): Array<{ name: string; text: string }> {
432
+ function withValues(files: Array<{ name: string; text: string }>, laid: Pick<Layout, "switches" | "patches" | "startScreen">, values: ReadonlyMap<string, number>): Array<{ name: string; text: string }> {
413
433
  return files.map((file) => (file.name === CONFIG_FILE ? { ...file, text: configText(laid, values) } : file));
414
434
  }
415
435
 
@@ -504,14 +524,21 @@ interface LoaderRun {
504
524
  verified: boolean;
505
525
  differences: string[];
506
526
  stop?: { pc: string; port: string; cause?: string; history: string[] };
527
+ /** The start screen: shown with its VIC-II values, and still waiting after START_SCREEN_FRAMES frames. */
528
+ startScreen?: { shown: boolean; waits: boolean; wait: string; continue: string };
507
529
  }
508
530
 
531
+ /** The frames that the check of the loader lets the start screen wait without a key. */
532
+ const START_SCREEN_FRAMES = 50;
533
+
509
534
  /** The history entries that a stop of the loader gives, so the agent sees the last instructions. */
510
535
  const STOP_HISTORY = 16;
511
536
 
512
537
  /** How the check of the loader runs it: the copier's address in the loader file, the file byte there, and the frames to the copier. */
513
538
  interface LoaderRunPlan {
514
539
  jump: number;
540
+ /** The wait of the start screen and the code after it, when the loader has a start screen. */
541
+ startScreen?: { wait: number; continue: number };
515
542
  copierSource: number;
516
543
  fileByte: (address: number) => number;
517
544
  copierFrames: number;
@@ -535,6 +562,28 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, image:
535
562
  };
536
563
  const copier = await client.runUntil({ target: { kind: "address", address: plan.copier, space: "c64" }, timeoutFrames: run.copierFrames });
537
564
  if (!copier.reached) return await stopped(copier.pc, false, `its copier at ${formatC64Address(plan.copier)}`);
565
+ // The start screen waits for a key or a fire button. The emulator cannot press a key of the keyboard matrix
566
+ // on each VICE, so the check lets it wait, then sets the PC to the code after the wait.
567
+ let screen: LoaderRun["startScreen"];
568
+ const screenDifferences: string[] = [];
569
+ if (run.startScreen !== undefined && plan.startScreen !== undefined) {
570
+ const labels = { wait: formatC64Address(run.startScreen.wait), continue: formatC64Address(run.startScreen.continue) };
571
+ const atWait = await client.runUntil({ target: { kind: "address", address: run.startScreen.wait, space: "c64" }, timeoutFrames: LOADER_FRAMES });
572
+ if (!atWait.reached) return await stopped(atWait.pc, true, `its start screen at ${labels.wait}`);
573
+ const held = await client.runUntil({ target: { kind: "address", address: run.startScreen.continue, space: "c64" }, timeoutFrames: START_SCREEN_FRAMES });
574
+ const vic = Buffer.from((await client.ioRead(0xd000, 0x2f)).data, "hex");
575
+ const bank = 3 - (Buffer.from((await client.ioRead(0xdd00, 1)).data, "hex")[0]! & 0x03);
576
+ const wanted = plan.startScreen;
577
+ const shown: Array<[number, number]> = [[0x11, wanted.d011], [0x15, 0], [0x16, wanted.d016], [0x18, wanted.d018], [0x20, wanted.border], [0x21, wanted.background]];
578
+ for (const [register, value] of shown) {
579
+ const mask = VIC_DISPLAY_REGISTERS.find((item) => item.register === register)!.mask;
580
+ if ((vic[register]! & mask) !== (value & mask)) screenDifferences.push(`the start screen has ${formatC64Address(0xd000 + register)} = $${(vic[register]! & mask).toString(16).padStart(2, "0")}, not $${(value & mask).toString(16).padStart(2, "0")}`);
581
+ }
582
+ if (bank !== wanted.bank) screenDifferences.push(`the start screen is in VIC bank ${bank}, not ${wanted.bank}`);
583
+ screen = { shown: screenDifferences.length === 0, waits: !held.reached, ...labels };
584
+ if (held.reached) screenDifferences.push(`the start screen did not wait: it got to ${labels.continue} without a key or a fire button`);
585
+ if (!held.reached) await client.registersSet("c64", { pc: run.startScreen.continue });
586
+ }
538
587
  const atJump = await client.runUntil({ target: { kind: "address", address: jump, space: "c64" }, timeoutFrames: LOADER_FRAMES });
539
588
  if (!atJump.reached) return await stopped(atJump.pc, true, `its jump to the entry at ${formatC64Address(jump)}`);
540
589
  const memory = await readRam(client, 0x0000, 0x10000);
@@ -582,7 +631,8 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, image:
582
631
  }
583
632
  plan.cia.masks.forEach((mask, index) => differ(`CIA ${index + 1} interrupt mask`, chips[index]!.interruptMask, mask));
584
633
  }
585
- return { verified: differences.length === 0, differences: differences.slice(0, MAX_DIAGNOSTICS) };
634
+ differences.unshift(...screenDifferences);
635
+ return { verified: differences.length === 0, differences: differences.slice(0, MAX_DIAGNOSTICS), ...(screen === undefined ? {} : { startScreen: screen }) };
586
636
  } finally {
587
637
  await client.close();
588
638
  }
@@ -613,8 +663,11 @@ function sourceMapText(rendered: Rendered, space: string, revision: string | nul
613
663
  return `${head},\n"labels": [\n${labels.join(",\n")}\n],\n"items": [\n${items.join(",\n")}\n]}\n`;
614
664
  }
615
665
 
666
+ /** The folder in .c64-re-tools/local/ where the check of the loader runs the new loader.prg. */
667
+ const LOADER_CHECK_DIRECTORY = "loader-check";
668
+
616
669
  /** The files of the loader. Only a run with --loader writes them, so only such a run removes them. */
617
- const LOADER_FILES: ReadonlySet<string> = new Set(["loader.asm", "loader.prg"]);
670
+ const LOADER_FILES: ReadonlySet<string> = new Set(["loader.asm", "loader.prg", START_SCREEN_FILE]);
618
671
 
619
672
  /** The start of the line of loader.asm that gives the knowledge revision of the loader. */
620
673
  const LOADER_REVISION = "Loader generated by c64-source from knowledge revision ";
@@ -640,8 +693,9 @@ function staleLoader(out: string, revision: string): { files: string[]; revision
640
693
  /**
641
694
  * Removes the generated .asm files of an earlier run that this run does not
642
695
  * write, and an earlier not_executed.json and source-map.json. An earlier
643
- * loader.asm and loader.prg stay unless this run has --loader: a source of the
644
- * user can include loader.asm. Other files stay. Gives the names it removed.
696
+ * loader.asm stays unless this run has --loader: a source of the user can
697
+ * include loader.asm. An earlier loader.prg always stays: only a new loader.prg
698
+ * whose check ran replaces it. Other files stay. Gives the names it removed.
645
699
  */
646
700
  function removeOldFiles(out: string, keep: ReadonlySet<string>, loaderRun: boolean): string[] {
647
701
  const directory = resolveProjectPath(out);
@@ -652,7 +706,7 @@ function removeOldFiles(out: string, keep: ReadonlySet<string>, loaderRun: boole
652
706
  const name = entry.name;
653
707
  const path = join(directory, name);
654
708
  if (LOADER_FILES.has(name) && !loaderRun) continue;
655
- const old = name === "loader.prg" || name === NOT_EXECUTED_FILE || name === SOURCE_MAP_FILE || (name.endsWith(".asm") && !keep.has(name) && readFileSync(path, "utf8").startsWith(GENERATED_MARK));
709
+ const old = name === NOT_EXECUTED_FILE || name === SOURCE_MAP_FILE || (name.endsWith(".asm") && !keep.has(name) && readFileSync(path, "utf8").startsWith(GENERATED_MARK));
656
710
  if (!old) continue;
657
711
  rmSync(path, { force: true });
658
712
  removed.push(name);
@@ -680,6 +734,8 @@ interface SourceOptions {
680
734
  /** With an entry state, the loader is planned too. */
681
735
  state?: EntryState;
682
736
  loaderHeader?: string[];
737
+ /** The source of an export: no config.asm, so START_SCREEN has the default of start_screen.asm. */
738
+ exported?: boolean;
683
739
  }
684
740
 
685
741
  /**
@@ -711,6 +767,7 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
711
767
  releases: knowledge.releases.map((release) => ({ label: release.label, file: release.file, base: release.base, ...(release.comment === undefined ? {} : { comment: release.comment }) })),
712
768
  macros: knowledge.macros,
713
769
  macroUses: knowledge.macroUses,
770
+ startScreen: knowledge.startScreen !== undefined && options.exported !== true,
714
771
  ...(coverage === undefined || !options.notExecutedMarks ? {} : { coverage }),
715
772
  // The platform names are C64 names: drive code and banks get none. A ROM that the program does not use gives none.
716
773
  ...(space === DEFAULT_SPACE ? { platform, platformLeftOut: leftOutNames(platform), describe: describeAddress, decode: decodeRegister, io: IO_RAM } : {}),
@@ -727,7 +784,18 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
727
784
  const segments = image.segments.map((segment) => ({ ...segment, files: laid.pieces.filter((piece) => piece.start >= segment.start && piece.start <= segment.end).map((piece) => piece.file) }));
728
785
  try {
729
786
  const entryName = laid.names.get(image.entry!);
730
- loader = planLoader({ segments, byteAt: image.byteAt, state, entry: image.entry!, ...(entryName === undefined ? {} : { entryName }), switches: hasSwitchFile(laid), macros: laid.macros.length > 0, header: options.loaderHeader ?? [] });
787
+ loader = planLoader({
788
+ segments,
789
+ byteAt: image.byteAt,
790
+ state,
791
+ entry: image.entry!,
792
+ ...(entryName === undefined ? {} : { entryName }),
793
+ switches: hasSwitchFile(laid),
794
+ config: hasConfigFile(laid),
795
+ macros: laid.macros.length > 0,
796
+ header: options.loaderHeader ?? [],
797
+ ...(knowledge.startScreen === undefined ? {} : { startScreen: knowledge.startScreen }),
798
+ });
731
799
  } catch (error) {
732
800
  if (!isRefusal(error)) throw error;
733
801
  loaderRefused = error.message;
@@ -737,7 +805,7 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
737
805
  const { mark } = options;
738
806
  const marked = (list: Array<{ name: string; text: string }>) => (mark === undefined ? list : list.map((file) => (file.name === CONFIG_FILE ? file : { ...file, text: `${mark}\n${file.text}` })));
739
807
  const markLines = mark === undefined ? 0 : 1;
740
- const loaderFiles = loader === undefined ? [] : [{ name: "loader.asm", text: loader.text }];
808
+ const loaderFiles = loader === undefined ? [] : [{ name: "loader.asm", text: loader.text }, ...(loader.startScreen === undefined ? [] : [{ name: START_SCREEN_FILE, text: START_SCREEN_CODE }])];
741
809
  const numbers = new Map<number, string>();
742
810
  const asInstructions = new Map<number, string>();
743
811
  let rendered = render(laid, asBytes, header, numbers, asInstructions);
@@ -762,7 +830,14 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
762
830
  * loader as it loads, then every copy in its order, byte by byte. A layout
763
831
  * other than the plan is a defect of the script.
764
832
  */
765
- async function buildLoader(files: Array<{ name: string; text: string }>, laid: Layout, loader: LoaderPlan, image: ProgramImage, state: EntryState, values: ReadonlyMap<string, number>): Promise<{ program: Buffer; symbols: AssembledSymbol[]; jump: number; copierSource: number; expected: (address: number) => number } | { diagnostics: Diagnostic[] }> {
833
+ async function buildLoader(
834
+ files: Array<{ name: string; text: string }>,
835
+ laid: Layout,
836
+ loader: LoaderPlan,
837
+ image: ProgramImage,
838
+ state: EntryState,
839
+ values: ReadonlyMap<string, number>,
840
+ ): Promise<{ program: Buffer; symbols: AssembledSymbol[]; jump: number; copierSource: number; expected: (address: number) => number; startScreen?: { wait: number; continue: number } } | { diagnostics: Diagnostic[] }> {
766
841
  const loaderBuilt = await assembleFiles(withValues(files, laid, values), "loader.asm");
767
842
  if (loaderBuilt.program === undefined) return { diagnostics: loaderBuilt.diagnostics.slice(0, MAX_DIAGNOSTICS) };
768
843
  const program = loaderBuilt.program;
@@ -784,7 +859,8 @@ async function buildLoader(files: Array<{ name: string; text: string }>, laid: L
784
859
  const jump = symbolValue(LOADER_JUMP);
785
860
  const wrong = simulate(memory, loader.copies, expected);
786
861
  if (wrong !== undefined) throw new WireFailure("operation-failed", `The simulated loader writes a wrong byte at ${formatC64Address(wrong)}. This is a defect of the script.`);
787
- return { program, symbols: loaderBuilt.symbols ?? [], jump, copierSource: symbolValue(COPIER_SOURCE), expected };
862
+ const startScreen = loader.startScreen === undefined ? undefined : { wait: symbolValue(START_SCREEN_WAIT), continue: symbolValue(START_SCREEN_CONTINUE) };
863
+ return { program, symbols: loaderBuilt.symbols ?? [], jump, copierSource: symbolValue(COPIER_SOURCE), expected, ...(startScreen === undefined ? {} : { startScreen }) };
788
864
  }
789
865
 
790
866
  /** The first line of each file that generate writes. */
@@ -820,8 +896,10 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
820
896
  // config.asm keeps the value of each switch that it already has: the user sets the switches there.
821
897
  const configPath = resolveProjectPath(`${out}/${CONFIG_FILE}`);
822
898
  const given = existsSync(configPath) ? configValues(readFileSync(configPath, "utf8")) : new Map<string, 0 | 1>();
823
- const kept = new Map(laid.switches.flatMap((row) => (given.has(row.name) ? [[row.name, given.get(row.name)!] as const] : [])));
824
- const notDefault = laid.switches.flatMap((row) => (kept.has(row.name) && kept.get(row.name) !== row.default ? [{ name: row.name, value: kept.get(row.name)!, default: row.default }] : []));
899
+ // START_SCREEN is a switch of the start screen, with the default 1.
900
+ const configured = [...laid.switches, ...(laid.startScreen ? [{ name: START_SCREEN_SWITCH, default: 1 }] : [])];
901
+ const kept = new Map(configured.flatMap((row) => (given.has(row.name) ? [[row.name, given.get(row.name)!] as const] : [])));
902
+ const notDefault = configured.flatMap((row) => (kept.has(row.name) && kept.get(row.name) !== row.default ? [{ name: row.name, value: kept.get(row.name)!, default: row.default }] : []));
825
903
  const removed = removeOldFiles(out, new Set(files.map((file) => file.name)), loaderWanted).map((name) => `${out}/${name}`);
826
904
  const stale = loaderWanted || space !== DEFAULT_SPACE ? undefined : staleLoader(out, knowledge.revision);
827
905
  const written: Written[] = withValues(files, laid, kept).map((file) => writeReported(`${out}/${file.name}`, file.text, { what: "--out" }));
@@ -892,8 +970,12 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
892
970
  patchesNotWritten: listed(laid.patchesNotWritten, max, (item) => ({ start: formatC64Address(item.start), end: formatC64Address(item.end), switch: item.switch, reason: item.reason })),
893
971
  }),
894
972
  };
973
+ // A loader.prg of an earlier run stays when this run checks no new one: it can be a committed file.
974
+ const loaderPath = `${out}/loader.prg`;
975
+ const keptLoader = () => (existsSync(resolveProjectPath(loaderPath)) ? { kept: loaderPath } : {});
976
+ const notVerified = (fields: Record<string, unknown>) => ({ verified: false, ...fields, ...keptLoader() });
895
977
  // The loader includes the source, so it is built only from a source that is identical to the image.
896
- const notBuilt = (reason: string) => (state === undefined ? {} : { loader: { verified: false, reason: loaderRefused ?? reason } });
978
+ const notBuilt = (reason: string) => (state === undefined ? {} : { loader: notVerified({ reason: loaderRefused ?? reason }) });
897
979
  if (built.program === undefined) {
898
980
  return { output: { ...output, check: { identical: false, diagnostics: built.diagnostics.slice(0, MAX_DIAGNOSTICS) }, ...notBuilt("The source does not assemble, and the loader includes it.") }, removed, failed: true };
899
981
  }
@@ -924,40 +1006,46 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
924
1006
  if (releases.length > 0) output.releases = releases;
925
1007
  const releasesFailed = releases.some((item) => item.result !== "identical" && (item.base || item.result !== "layout differs"));
926
1008
  const sourceFailed = laid.patchesNotWritten.length > 0 || switches.some((item) => item.result !== "fits") || defaultFailed || releasesFailed;
927
- if (loaderRefused !== undefined) return { output: { ...output, loader: { verified: false, reason: loaderRefused } }, removed, failed: true };
1009
+ if (loaderRefused !== undefined) return { output: { ...output, loader: notVerified({ reason: loaderRefused }) }, removed, failed: true };
928
1010
  if (loader === undefined || state === undefined) return { output, removed, failed: missingEntry !== undefined || sourceFailed };
929
1011
 
930
1012
  // The entry state is the state of the base release: the loader is built and checked with it.
931
1013
  const loaderBuilt = await buildLoader(files, laid, loader, image, state, baseValues);
932
- if ("diagnostics" in loaderBuilt) return { output: { ...output, loader: { verified: false, reason: "loader.asm does not assemble.", diagnostics: loaderBuilt.diagnostics } }, removed, failed: true };
933
- const { jump, copierSource, expected } = loaderBuilt;
1014
+ if ("diagnostics" in loaderBuilt) return { output: { ...output, loader: notVerified({ reason: "loader.asm does not assemble.", diagnostics: loaderBuilt.diagnostics }) }, removed, failed: true };
1015
+ const { jump, copierSource, expected, startScreen } = loaderBuilt;
934
1016
  const copierBuild = loaderBuilt.program;
935
1017
  const fileByte = (address: number) => copierBuild[2 + address - (loader.packed?.start ?? 0x0801)]!;
936
- // The packed form: Exomizer packs the build of main.asm with the copier. Without Exomizer, or when its check fails, there is no loader.prg.
1018
+ // The packed form: Exomizer packs the build of main.asm with the copier. Without Exomizer, or when its check fails, there is no new loader.prg.
937
1019
  let packed: PackedLoader | undefined;
938
1020
  if (loader.packed !== undefined) {
939
1021
  try {
940
1022
  packed = await packLoader(built.program, copierBuild, loader, localToolContext());
941
1023
  } catch (error) {
942
1024
  if (!isRefusal(error)) throw error;
943
- return { output: { ...output, loader: { verified: false, reason: `loader.asm has the packed form, and the pack with Exomizer failed. ${error.message}` } }, removed, failed: true };
1025
+ return { output: { ...output, loader: notVerified({ reason: `loader.asm has the packed form, and the pack with Exomizer failed. ${error.message}` }) }, removed, failed: true };
944
1026
  }
945
1027
  }
946
1028
  const program = packed?.program ?? copierBuild;
947
- const loaderPath = `${out}/loader.prg`;
948
- written.push(writeReported(loaderPath, program, { what: "--out" }));
1029
+ // The check runs the new loader from a scratch file. Only a loader whose check ran goes to --out, so a check
1030
+ // that cannot run (no host, or a host of another release) keeps the loader.prg of an earlier run.
1031
+ ensureLocal(projectRoot());
1032
+ const scratch = `${PROJECT_DIRECTORY}/${LOCAL_DIRECTORY}/${LOADER_CHECK_DIRECTORY}`;
1033
+ mkdirSync(resolveProjectPath(scratch), { recursive: true });
1034
+ const checkPath = `${scratch}/loader.prg`;
1035
+ writeFileSync(resolveProjectPath(checkPath), program);
949
1036
  // The unpack runs before the copier.
950
1037
  const copierFrames = packed === undefined ? RUN_LIMIT_FRAMES : packed.cycles === undefined ? LOADER_FRAMES : RUN_LIMIT_FRAMES + Math.ceil(packed.cycles / PAL_FRAME_CYCLES);
951
1038
  let ran: LoaderRun;
952
1039
  try {
953
- ran = await runLoader(loaderPath, program, loader, image, state, { jump, copierSource, fileByte, copierFrames }, expected);
1040
+ ran = await runLoader(checkPath, program, loader, image, state, { jump, copierSource, fileByte, copierFrames, ...(startScreen === undefined ? {} : { startScreen }) }, expected);
954
1041
  } catch (error) {
955
- // A loader.prg without its check does not stay: it looks like a checked loader.
956
- rmSync(resolveProjectPath(loaderPath), { force: true });
957
- written.splice(written.findIndex((file) => file.out === loaderPath), 1);
958
1042
  if (!isRefusal(error)) throw error;
959
- return { output: { ...output, loader: { verified: false, reason: `The check of loader.prg did not run, so the script removed loader.prg. ${error.message}` } }, removed, failed: true };
1043
+ const what = existsSync(resolveProjectPath(loaderPath)) ? "kept the loader.prg of an earlier run" : "wrote no loader.prg";
1044
+ return { output: { ...output, loader: notVerified({ reason: `The check of loader.prg did not run, so the script ${what}. ${error.message}` }) }, removed, failed: true };
1045
+ } finally {
1046
+ rmSync(resolveProjectPath(scratch), { recursive: true, force: true });
960
1047
  }
1048
+ written.push(writeReported(loaderPath, program, { what: "--out" }));
961
1049
  output.loader = {
962
1050
  program: loaderPath,
963
1051
  ...(packed === undefined ? {} : { packed: { packedBytes: packed.packedBytes, unpackedBytes: packed.unpackedBytes } }),
@@ -1032,7 +1120,7 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
1032
1120
  const { root: to, zip } = newProjectFolder(call.string("to")!, project);
1033
1121
  const name = call.string("name") ?? basename(to);
1034
1122
  if (!NAME_PATTERN.test(name)) throw new UsageError(`--name ${name}: a name has letters, digits, dots, underscores and hyphens, and starts with a letter or a digit. Give --name`);
1035
- const keep = call.ranges("keep");
1123
+ const given = call.ranges("keep");
1036
1124
  const drop = call.ranges("drop");
1037
1125
  const max = call.count("max-listed")!;
1038
1126
  const shownRange = (range: AddressRange) => ({ start: formatC64Address(range.start), end: formatC64Address(range.end) });
@@ -1048,6 +1136,9 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
1048
1136
  })();
1049
1137
  const knowledge = readKnowledge(DEFAULT_SPACE);
1050
1138
  const image = knowledge.program;
1139
+ // The VIC-II reads the start screen, and the coverage does not show those reads: it stays.
1140
+ const screenParts = knowledge.startScreen === undefined ? [] : startScreenRanges(knowledge.startScreen).map((part) => part.range);
1141
+ const keep = [...given, ...screenParts.filter((range) => image.segments.some((segment) => range.start >= segment.start && range.end <= segment.end))];
1051
1142
  const state = image.state === undefined || image.entry === undefined ? undefined : loaderState(image.state, "the entry state of the knowledge");
1052
1143
 
1053
1144
  // 1. The source of the knowledge must give the base release byte for byte, with every patch in it.
@@ -1161,6 +1252,7 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
1161
1252
  values: new Map(),
1162
1253
  decoded: { instructions, dataOnly: decoded.dataOnly },
1163
1254
  notExecutedMarks: false,
1255
+ exported: true,
1164
1256
  ...(state === undefined ? {} : { state, loaderHeader: [`The loader of ${name}.`, "It copies the segments into place, sets the entry state and jumps to the entry."] }),
1165
1257
  });
1166
1258
  if (exported.built.program === undefined) return { result: "FAIL", stage: "export", reason: "The source of the export does not assemble. This is a defect of the script.", diagnostics: exported.built.diagnostics.slice(0, MAX_DIAGNOSTICS) };
@@ -1210,6 +1302,10 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
1210
1302
  for (const { revision: _revision, ...comment } of comments) change.insertComment(comment);
1211
1303
  for (const { revision: _revision, ...region } of exportRegions) change.insertRegion(region);
1212
1304
  for (const { revision: _revision, ...module } of knowledge.modules) change.insertModule(module);
1305
+ if (knowledge.startScreen !== undefined) {
1306
+ const { revision: _revision, ...screen } = knowledge.startScreen;
1307
+ change.insertStartScreen({ ...screen, origin: "llm" });
1308
+ }
1213
1309
  }),
1214
1310
  to,
1215
1311
  );
@@ -1218,7 +1314,7 @@ async function exportProject(call: Call): Promise<Record<string, unknown>> {
1218
1314
  files.push(
1219
1315
  put(
1220
1316
  "README.md",
1221
- readmeText({ name, project: basename(project), revision: knowledge.revision, date: isoCet().slice(0, 10), entryFile: baseline.entryFile, free, switches, tests: { written: tests.map(({ file, kind }) => ({ file, kind })), leftOut: testsLeftOut } }),
1317
+ readmeText({ name, project: basename(project), revision: knowledge.revision, date: isoCet().slice(0, 10), entryFile: baseline.entryFile, free, switches, tests: { written: tests.map(({ file, kind }) => ({ file, kind })), leftOut: testsLeftOut }, startScreen: exported.loader?.startScreen !== undefined }),
1222
1318
  ),
1223
1319
  );
1224
1320
  for (const file of exported.files) files.push(put(`src/${file.name}`, file.text));
@@ -65,7 +65,8 @@ To get the command list, run the script with no arguments.
65
65
  - 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.
66
66
  - 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.
67
67
  - The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
68
- - 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.
68
+ - 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.
69
+ - A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
69
70
  - 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.
70
71
  - 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.
71
72
  - 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`.
@@ -60,7 +60,8 @@ To get the command list, run the script with no arguments.
60
60
  - 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.
61
61
  - 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.
62
62
  - The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
63
- - 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.
63
+ - 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.
64
+ - A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
64
65
  - 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.
65
66
  - 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.
66
67
  - 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`.
@@ -80,7 +80,8 @@ The script refuses a step in an old form. The message gives the step to write.
80
80
  - 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.
81
81
  - 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.
82
82
  - The script refuses a folder where the command writes a file. It refuses a file where the command writes a folder.
83
- - 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.
83
+ - 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.
84
+ - A coverage map can stay in `.c64-re-tools/local/`. The project knowledge keeps its ranges and its SHA-256.
84
85
  - 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.
85
86
  - 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.
86
87
  - 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`.
@@ -257,7 +258,8 @@ Traps:
257
258
  - Disassemble the code at the address. Make sure that it is the start of the program. The start of a program often sets the stack pointer, the interrupts and the vectors.
258
259
  4. Run `capture` with that address in `--until` and a folder in `--out`. Give the same `--steps` as before.
259
260
  5. Make sure that the result is the program. The code at the entry must not be the unpacker again. A segment can be data that a loader or a cracktro left, for example intro graphics. Keep it until other evidence shows that the program does not use it. Then capture again with `--exclude` for that range.
260
- - Exclude each range of a cracktro that the program does not read. A rebuild has no cracktro.
261
+ - Exclude each range of a cracktro that the program does not read. A rebuild has no cracktro. Also exclude a picture, an intro or a credit screen of a crack.
262
+ - Do not exclude the start screen of the program, also when the program does not read it. An example is the loading picture of the publisher. Record it as the start screen in the project knowledge. The loader of the rebuild shows it.
261
263
  - Do not exclude other unused bytes, for example leftovers of the development or an old copy of a routine. A rebuild keeps them.
262
264
  - Keep a crack change that the program reads, for example a credit text in the game. Record it as a `crack` switch in the project knowledge.
263
265
  6. Put `<out>/image.json` into the project knowledge. The knowledge keeps the segments, the entry, the entry state and the stages. After that, you do not need the files in `<out>`.
@@ -279,7 +281,7 @@ Do not record the unpacker in the project knowledge, unless the user asks you to
279
281
  ]
280
282
  ```
281
283
 
282
- 2. Run `loads` with the steps file and a folder in `--out`. Add `--drive` when the program has its own drive code, for example a fast loader. Add `--exclude` for each range of a loader, an intro or a loading picture that the program does not read.
284
+ 2. Run `loads` with the steps file and a folder in `--out`. Add `--drive` when the program has its own drive code, for example a fast loader. Add `--exclude` for each range of a loader or of a crack that the program does not read. Do not exclude the start screen of the program.
283
285
  3. Put `<out>/<name>/image.json` of the part that you work on into the project knowledge.
284
286
  4. With `--drive`, put `<out>/<name>/drive8.prg` into the project knowledge in the space `drive8`. Then analyze the drive code in the space `drive8`.
285
287
 
package/src/cli/main.ts CHANGED
@@ -92,8 +92,10 @@ async function main(argv: string[]): Promise<number> {
92
92
  const note = scope === "project" && (targets === undefined || targets.includes("windsurf")) ? undoWindsurfProjectMcp(before) : undefined;
93
93
  process.stdout.write(note === undefined ? output : withoutWindsurfMcp(output));
94
94
  if (note !== undefined) console.log(` ${note}\n`);
95
- // A skill that this version renamed or dropped must not stay next to the new ones.
96
- const removed = code === 0 ? removeDroppedItems(earlier, scope) : [];
95
+ // A skill that this version renamed or dropped must not stay next to the new ones. AP SDK can write its
96
+ // new manifest and still exit with an error: then the next install no longer knows the dropped items, so
97
+ // the cleanup runs after each install. An install that wrote no manifest drops nothing.
98
+ const removed = removeDroppedItems(earlier, scope);
97
99
  if (removed.length > 0) console.log(` Removed, because this version no longer has them: ${removed.join(", ")}\n`);
98
100
  return code;
99
101
  }
package/src/cli/status.ts CHANGED
@@ -91,7 +91,6 @@ export function installedLines(cwd = process.cwd()): string[] {
91
91
  }
92
92
  }
93
93
  if (lines.length === 0) return ["Installed: nothing in this project or globally."];
94
- lines.push(" The MCP server gives its own version in the result of c64_status.");
95
94
  return lines;
96
95
  }
97
96
 
@@ -16,6 +16,7 @@ import {
16
16
  PATCH_COLUMNS,
17
17
  REFERENCE_COLUMNS,
18
18
  RELEASE_COLUMNS,
19
+ START_SCREEN_COLUMNS,
19
20
  SWITCH_COLUMNS,
20
21
  REGION_COLUMNS,
21
22
  SUPPRESSION_COLUMNS,
@@ -28,6 +29,7 @@ import {
28
29
  toPatch,
29
30
  toReference,
30
31
  toRelease,
32
+ toStartScreen,
31
33
  toSwitch,
32
34
  toRegion,
33
35
  toSuppression,
@@ -56,6 +58,7 @@ export const CONFLICT_RULES = {
56
58
  switch: "two switches with one name",
57
59
  release: "two releases with one label",
58
60
  "release-base": "two base releases",
61
+ "start-screen": "two start screens",
59
62
  macro: "two macros with one name",
60
63
  "macro-use": "macro uses that overlap",
61
64
  } as const;
@@ -116,6 +119,7 @@ const RULES: readonly TableRule[] = [
116
119
  { rule: "switch", table: "switches", entity: "switch", columns: SWITCH_COLUMNS, map: toSwitch, key: ["name"] },
117
120
  { rule: "release", table: "releases", entity: "release", columns: RELEASE_COLUMNS, map: toRelease, key: ["label"] },
118
121
  { rule: "release-base", table: "releases", entity: "release", columns: RELEASE_COLUMNS, map: toRelease, key: ["base"], where: "base = 1" },
122
+ { rule: "start-screen", table: "start_screens", entity: "start-screen", columns: START_SCREEN_COLUMNS, map: toStartScreen, key: [] },
119
123
  { rule: "macro", table: "macros", entity: "macro", columns: MACRO_COLUMNS, map: toMacro, key: ["name"] },
120
124
  { rule: "macro-use", table: "macro_uses", entity: "macro-use", columns: MACRO_USE_COLUMNS, map: toMacroUse, key: "overlap" },
121
125
  ];
@@ -26,6 +26,8 @@ import {
26
26
  toPatch,
27
27
  toReference,
28
28
  toRelease,
29
+ toStartScreen,
30
+ START_SCREEN_COLUMNS,
29
31
  toSwitch,
30
32
  toRegion,
31
33
  toSuppression,
@@ -38,6 +40,7 @@ import {
38
40
  type PatchRow,
39
41
  type ReferenceRow,
40
42
  type ReleaseRow,
43
+ type StartScreenRow,
41
44
  type SwitchRow,
42
45
  type RegionRow,
43
46
  type SuppressionRow,
@@ -109,6 +112,7 @@ export type HistoryEntry =
109
112
  | { entity: "patch"; row: PatchRow; from: string; to?: string }
110
113
  | { entity: "switch"; row: SwitchRow; from: string; to?: string }
111
114
  | { entity: "release"; row: ReleaseRow; from: string; to?: string }
115
+ | { entity: "start-screen"; row: StartScreenRow; from: string; to?: string }
112
116
  | { entity: "macro"; row: MacroRow; from: string; to?: string }
113
117
  | { entity: "macro-use"; row: MacroUseRow; from: string; to?: string };
114
118
 
@@ -265,6 +269,7 @@ export function revision(db: DatabaseSync | undefined, text: string): RevisionCh
265
269
  ["patch", "patches", PATCH_COLUMNS, toPatch],
266
270
  ["switch", "switches", SWITCH_COLUMNS, toSwitch],
267
271
  ["release", "releases", RELEASE_COLUMNS, toRelease],
272
+ ["start-screen", "start_screens", START_SCREEN_COLUMNS, toStartScreen],
268
273
  ["macro", "macros", MACRO_COLUMNS, toMacro],
269
274
  ["macro-use", "macro_uses", MACRO_USE_COLUMNS, toMacroUse],
270
275
  ] as const;
@@ -6,7 +6,7 @@ import type { DatabaseSync } from "node:sqlite";
6
6
 
7
7
  import type { AddressRange } from "../c64.ts";
8
8
  import { Refusal } from "../errors.ts";
9
- import { DEFAULT_SPACE, type CommentPlacement, type OperandSelect, type Origin, type ReferenceKind, type RegionType, type Space, type SuppressionEntity, type SwitchKind, type SymbolKind } from "./schema.ts";
9
+ import { DEFAULT_SPACE, type CommentPlacement, type OperandSelect, type Origin, type ReferenceKind, type RegionType, type Space, type StartScreenMode, type SuppressionEntity, type SwitchKind, type SymbolKind } from "./schema.ts";
10
10
  import { NO_REVISION } from "./text.ts";
11
11
 
12
12
  export interface SymbolRow {
@@ -126,6 +126,37 @@ export interface ReleaseRow {
126
126
  revision: string;
127
127
  }
128
128
 
129
+ /**
130
+ * The start screen of the program: a screen of the program itself, not of a
131
+ * crack, that the loader of the generated source shows before the entry.
132
+ * A text screen has a charset, a bitmap screen has a bitmap. The colour RAM
133
+ * comes from 1000 bytes at `colours` or is one `colour`; a hires bitmap has none.
134
+ */
135
+ export interface StartScreenRow {
136
+ space: Space;
137
+ mode: StartScreenMode;
138
+ screen: number;
139
+ bitmap?: number;
140
+ charset?: number;
141
+ colours?: number;
142
+ colour?: number;
143
+ border: number;
144
+ background: number;
145
+ comment?: string;
146
+ origin: Extract<Origin, "user" | "llm">;
147
+ revision: string;
148
+ }
149
+
150
+ /** The memory that a start screen shows: each part with its range. A ROM charset is not RAM, so it has no range. */
151
+ export function startScreenRanges(row: Pick<StartScreenRow, "screen" | "bitmap" | "charset" | "colours">): Array<{ what: string; range: AddressRange }> {
152
+ const part = (what: string, start: number | undefined, size: number) => (start === undefined ? [] : [{ what, range: { start, end: start + size - 1 } }]);
153
+ const romFont = row.charset !== undefined && isRomFont(row.charset);
154
+ return [...part("screen", row.screen, 1000), ...part("bitmap", row.bitmap, 8000), ...(romFont ? [] : part("charset", row.charset, 2048)), ...part("colours", row.colours, 1000)];
155
+ }
156
+
157
+ /** True for a charset address where the VIC-II reads the character ROM: $1000 or $1800 in VIC bank 0 or 2. */
158
+ export const isRomFont = (address: number) => (address & 0x7fff) === 0x1000 || (address & 0x7fff) === 0x1800;
159
+
129
160
  /** An ACME macro of the generated source. The body names a parameter with a dot in front: .dst. */
130
161
  export interface MacroRow {
131
162
  space: Space;
@@ -166,6 +197,7 @@ export const SWITCH_COLUMNS = "space, name, kind, default_value, releases, comme
166
197
  export const RELEASE_COLUMNS = "space, label, file, sha256, base, comment, origin, valid_from_revision";
167
198
  export const MACRO_COLUMNS = "space, name, params, body, comment, origin, valid_from_revision";
168
199
  export const MACRO_USE_COLUMNS = "space, start_address, end_address, macro, args, origin, valid_from_revision";
200
+ export const START_SCREEN_COLUMNS = "space, mode, screen, bitmap, charset, colours, colour, border, background, comment, origin, valid_from_revision";
169
201
 
170
202
  export function toSymbol(row: Raw): SymbolRow {
171
203
  return { space: row.space as Space, address: row.address as number, name: row.name as string, kind: row.kind as SymbolKind, origin: row.origin as Origin, revision: row.valid_from_revision as string };
@@ -275,6 +307,21 @@ export function toRelease(row: Raw): ReleaseRow {
275
307
  return release;
276
308
  }
277
309
 
310
+ export function toStartScreen(row: Raw): StartScreenRow {
311
+ const value: StartScreenRow = {
312
+ space: row.space as Space,
313
+ mode: row.mode as StartScreenMode,
314
+ screen: row.screen as number,
315
+ border: row.border as number,
316
+ background: row.background as number,
317
+ origin: row.origin as StartScreenRow["origin"],
318
+ revision: row.valid_from_revision as string,
319
+ };
320
+ for (const key of ["bitmap", "charset", "colours", "colour"] as const) if (row[key] !== null && row[key] !== undefined) value[key] = row[key] as number;
321
+ if (row.comment !== null && row.comment !== undefined) value.comment = row.comment as string;
322
+ return value;
323
+ }
324
+
278
325
  export function toMacro(row: Raw): MacroRow {
279
326
  const macro: MacroRow = { space: row.space as Space, name: row.name as string, params: items(row.params as string), body: row.body as string, origin: row.origin as MacroRow["origin"], revision: row.valid_from_revision as string };
280
327
  if (row.comment !== null && row.comment !== undefined) macro.comment = row.comment as string;
@@ -523,6 +570,12 @@ export function listReleases(db: DatabaseSync | undefined, origins?: OriginFilte
523
570
  .filter(kept(origins));
524
571
  }
525
572
 
573
+ /** The current start screen of a space, if the knowledge has one. */
574
+ export function currentStartScreen(db: DatabaseSync | undefined, space: Space = DEFAULT_SPACE): StartScreenRow | undefined {
575
+ const row = db?.prepare(`SELECT ${START_SCREEN_COLUMNS} FROM current_start_screens WHERE space = ?`).get(space) as Raw | undefined;
576
+ return row === undefined ? undefined : toStartScreen(row);
577
+ }
578
+
526
579
  /**
527
580
  * The value of a switch in the program of the knowledge: 1 when the base
528
581
  * release has it on. A patch holds the code of the other value.
@@ -679,7 +732,7 @@ export function listSpaces(db: DatabaseSync | undefined): Space[] {
679
732
  if (db === undefined) return [];
680
733
  const rows = db
681
734
  .prepare(
682
- `SELECT space FROM current_symbols UNION SELECT space FROM current_analyzer_names UNION SELECT space FROM current_regions UNION SELECT space FROM current_comments UNION SELECT space FROM current_references UNION SELECT space FROM current_suppressions UNION SELECT space FROM current_modules UNION SELECT space FROM current_operands UNION SELECT space FROM current_patches UNION SELECT space FROM current_switches UNION SELECT space FROM current_releases UNION SELECT space FROM current_macros UNION SELECT space FROM current_macro_uses UNION SELECT space FROM current_memory UNION SELECT space FROM current_entries UNION SELECT space FROM current_coverage`,
735
+ `SELECT space FROM current_symbols UNION SELECT space FROM current_analyzer_names UNION SELECT space FROM current_regions UNION SELECT space FROM current_comments UNION SELECT space FROM current_references UNION SELECT space FROM current_suppressions UNION SELECT space FROM current_modules UNION SELECT space FROM current_operands UNION SELECT space FROM current_patches UNION SELECT space FROM current_switches UNION SELECT space FROM current_releases UNION SELECT space FROM current_macros UNION SELECT space FROM current_macro_uses UNION SELECT space FROM current_start_screens UNION SELECT space FROM current_memory UNION SELECT space FROM current_entries UNION SELECT space FROM current_coverage`,
683
736
  )
684
737
  .all() as Array<{ space: Space }>;
685
738
  const order = (space: Space) => (space === "c64" ? -2 : space === "drive8" ? -1 : Number(space.slice(4)));