@henols/c64-re-tools 2.6.0-rc.2 → 2.6.0-rc.3

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.
@@ -24,6 +24,7 @@ import { isRomFont, startScreenRanges, type StartScreenRow } from "#src/knowledg
24
24
  import { WireFailure } from "#src/host-client/tools.ts";
25
25
  import { pack } from "#src/native/exomizer.ts";
26
26
  import type { ToolContext } from "#src/native/run.ts";
27
+ import type { AssembledSymbol } from "#src/native/types.ts";
27
28
 
28
29
  export interface EntryState {
29
30
  pc: number;
@@ -138,9 +139,7 @@ export function loaderLimits(plan: { cia?: CiaPlan }): string[] {
138
139
 
139
140
  /** The label of the loader's jump to the entry, in ACME's symbol list. */
140
141
  export const LOADER_JUMP = "c64_source_loader_jump";
141
- /** The labels of the start screen: its wait for a key or a fire button, and the code after the wait. */
142
- export const START_SCREEN_WAIT = "loader_start_screen_wait";
143
- export const START_SCREEN_CONTINUE = "loader_start_screen_continue";
142
+ export { START_SCREEN_CONTINUE, START_SCREEN_WAIT } from "#src/knowledge/start-screen.ts";
144
143
  /** The file of the start screen in the generated source. */
145
144
  export const START_SCREEN_FILE = "start_screen.asm";
146
145
  /** The code of the start screen: the same for each program. loader.asm sets its values. */
@@ -172,7 +171,7 @@ export function startScreenPlan(row: StartScreenRow): StartScreenPlan {
172
171
  bank,
173
172
  border: row.border,
174
173
  background: row.background,
175
- colourMode: row.colours !== undefined ? 2 : row.colour !== undefined ? 1 : 0,
174
+ colourMode: row.colours !== undefined || row.colourRam === true ? 2 : row.colour !== undefined ? 1 : 0,
176
175
  };
177
176
  }
178
177
 
@@ -191,7 +190,8 @@ export function startScreenValues(row: StartScreenRow, plan: StartScreenPlan): s
191
190
  value("background", plan.background),
192
191
  value("colour_mode", plan.colourMode),
193
192
  value("colour", row.colour ?? 0),
194
- `c64_source_ss_colours = ${formatC64Address(row.colours ?? 0)}`,
193
+ // The colour RAM of a captured stage is in the show code: STAGE_COLOURS in stage.ts.
194
+ `c64_source_ss_colours = ${row.colourRam === true ? "c64_source_stage_colours" : formatC64Address(row.colours ?? 0)}`,
195
195
  ];
196
196
  }
197
197
 
@@ -991,3 +991,23 @@ function vicLines(state: EntryState, earlier: number): string[] {
991
991
  " bne .raster",
992
992
  ];
993
993
  }
994
+
995
+ /**
996
+ * The symbols of loader.prg: the labels of the build of loader.asm, which
997
+ * includes main.asm, and of start_screen_stage.asm when the loader has a show
998
+ * stage. A test takes one symbols file. Refuses a name with two values.
999
+ */
1000
+ export function loaderSymbols(...builds: ReadonlyArray<readonly AssembledSymbol[]>): AssembledSymbol[] {
1001
+ const valueOf = (symbol: AssembledSymbol) => (symbol.kind === "address" ? symbol.address : symbol.value);
1002
+ const byName = new Map<string, AssembledSymbol>();
1003
+ for (const symbol of builds.flat()) {
1004
+ const known = byName.get(symbol.name);
1005
+ if (known !== undefined && valueOf(known) !== valueOf(symbol)) {
1006
+ throw new WireFailure("operation-failed", `The builds of loader.prg give ${symbol.name} two values, ${valueOf(known)} and ${valueOf(symbol)}. This is a defect of the script.`);
1007
+ }
1008
+ // An address in one build can be outside the load range of the other build, where it is a constant.
1009
+ const kept = known === undefined || (known.kind === "constant" && symbol.kind === "address") ? symbol : known;
1010
+ byName.set(symbol.name, { ...kept, used: symbol.used || (known?.used ?? false) });
1011
+ }
1012
+ return [...byName.values()].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
1013
+ }
@@ -977,7 +977,7 @@ export function configText(layout: Pick<Layout, "switches" | "patches" | "startS
977
977
  }
978
978
  }
979
979
  if (layout.startScreen) {
980
- out.push("", "; Start screen: on by default", `${START_SCREEN_SWITCH} = ${values.get(START_SCREEN_SWITCH) ?? 1} ; the loader shows the start screen and waits for a key or a fire button. 0 starts the program at once`);
980
+ out.push("", "; Start screen: on by default", `${START_SCREEN_SWITCH} = ${values.get(START_SCREEN_SWITCH) ?? 1} ; the loader shows the start screen and waits for a key or a fire button. 0 starts the program at once. Only the clean build has it: a release and LEFTOVERS = 1 have none`);
981
981
  }
982
982
  if (layout.leftovers.length > 0) {
983
983
  const bytes = layout.leftovers.reduce((sum, range) => sum + range.end - range.start + 1, 0);
@@ -1006,6 +1006,8 @@ function switchesText(layout: Layout): string {
1006
1006
  out.push(`!ifdef ${RELEASE_DEFINE}${release.label} {`);
1007
1007
  for (const row of layout.switches) out.push(`${INDENT}${row.name} = ${row.releases.includes(release.label) ? 1 : 0}`);
1008
1008
  if (layout.leftovers.length > 0) out.push(`${INDENT}${LEFTOVERS_SWITCH} = 1`);
1009
+ // The start screen is part of the clean build only: the build of a release is the bytes of its file.
1010
+ if (layout.startScreen) out.push(`${INDENT}${START_SCREEN_SWITCH} = 0`);
1009
1011
  out.push("}");
1010
1012
  }
1011
1013
  if (hasConfigFile(layout)) {
@@ -27,6 +27,8 @@ export interface StageInput {
27
27
  innerPort: number;
28
28
  /** The bytes of the stage that the start screen uses, in address order, at $0400 or higher. */
29
29
  stage: StagePart[];
30
+ /** The colour RAM of the capture of the stage, when the start screen takes its colours from it: the show code holds it. */
31
+ colourRam?: Uint8Array;
30
32
  row: StartScreenRow;
31
33
  plan: StartScreenPlan;
32
34
  /** The lines that include switches.asm or config.asm, for START_SCREEN. */
@@ -41,7 +43,7 @@ export interface StagePlan {
41
43
  code: number;
42
44
  /** The parts of the loader under the bytes of the stage: where the show code copies them back from. */
43
45
  stash: Array<{ target: AddressRange; at: number }>;
44
- /** start_screen_stage.asm: the show code at `code`, then each part of the stage, packed after it. */
46
+ /** start_screen_stage.asm: the show code at `code`, and each part of the stage at its own address. */
45
47
  text: string;
46
48
  }
47
49
 
@@ -50,7 +52,9 @@ export const STAGE_FILE = "start_screen_stage.asm";
50
52
  /** The labels of the show stage: its start and the end of the show code. */
51
53
  export const STAGE_START = "c64_source_stage";
52
54
  export const STAGE_CODE_END = "c64_source_stage_code_end";
53
- /** The label of a part of the stage: its first byte and the byte after it in the build of start_screen_stage.asm. */
55
+ /** The label of the colour RAM of the capture in the show code. */
56
+ export const STAGE_COLOURS = "c64_source_stage_colours";
57
+ /** The label of a part of the stage: its first byte and the byte after it. */
54
58
  export const stageLabel = (start: number, part: "from" | "end") => `stage_${part}_${start.toString(16).padStart(4, "0")}`;
55
59
 
56
60
  /** One copy of the stash: the length, where it is read and where it is written. */
@@ -244,10 +248,12 @@ export function stageText(input: StageInput, code: number, stash: StagePlan["sta
244
248
  ...stash.map((item) => ` !word ${item.target.end - item.target.start + 1}, ${formatC64Address(item.at)}, ${formatC64Address(item.target.start)} ; ${show(item.target)} of the loader`),
245
249
  " !word 0",
246
250
  "}",
251
+ ...(input.colourRam === undefined ? [] : [`; The colour RAM of the capture of ${row.stage}.`, STAGE_COLOURS, ...byteLines({ start: 0, body: input.colourRam })]),
247
252
  STAGE_CODE_END,
248
253
  ];
254
+ // Each part at its own address: the code is in a free range, so no part overlaps it, and the build never runs past $ffff.
249
255
  for (const part of input.stage) {
250
- lines.push("", `; ${row.stage} ${show(rangeOf(part))}`, stageLabel(part.start, "from"), `!pseudopc ${formatC64Address(part.start)} {`, ...byteLines(part), "}", stageLabel(part.start, "end"));
256
+ lines.push("", `; ${row.stage} ${show(rangeOf(part))}`, `* = ${formatC64Address(part.start)}`, stageLabel(part.start, "from"), ...byteLines(part), stageLabel(part.start, "end"));
251
257
  }
252
258
  return `${lines.join("\n")}\n`;
253
259
  }
@@ -4,7 +4,8 @@
4
4
  ; The loader includes this file in its copier, with the interrupts off. The
5
5
  ; code uses no stack and writes only the I/O area, the colour RAM and its own
6
6
  ; bytes: the copies wrote pages 0-3 of the entry state already.
7
- ; Set START_SCREEN = 0 in config.asm to start the program at once.
7
+ ; Set START_SCREEN = 0 in config.asm to start the program at once. The start
8
+ ; screen is part of the clean build only: a release and LEFTOVERS = 1 have none.
8
9
  ; loader.asm sets these values from the start screen of the knowledge:
9
10
  ; c64_source_ss_d011, c64_source_ss_d016, c64_source_ss_d018: the VIC-II mode
10
11
  ; c64_source_ss_bank: the VIC bank, as bits 0-1 of $dd00
@@ -19,8 +20,9 @@
19
20
  ; wait, so each read of the keyboard and the joysticks is done with SEI.
20
21
 
21
22
  !ifndef START_SCREEN { START_SCREEN = 1 }
23
+ !ifndef LEFTOVERS { LEFTOVERS = 0 }
22
24
 
23
- lda #START_SCREEN
25
+ lda #START_SCREEN & (1 - LEFTOVERS)
24
26
  bne .on
25
27
  jmp .end
26
28
  .port !byte 0
@@ -11,7 +11,7 @@
11
11
 
12
12
  import { createHash } from "node:crypto";
13
13
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
14
- import { basename, join, relative, sep } from "node:path";
14
+ import { basename, dirname, join, relative, sep } from "node:path";
15
15
 
16
16
  import { isRefusal, Refusal } from "#src/errors.ts";
17
17
  import { type AddressRange, coverageSeedKinds, findHandoffs, formatC64Address, parseTokenized, textToPetscii } from "#src/c64.ts";
@@ -33,7 +33,7 @@ import { assemble, symbolsFileText } from "#src/native/acme.ts";
33
33
  import { analyze } from "#src/native/ghidra/analyze.ts";
34
34
  import { localToolContext } from "#src/native/local.ts";
35
35
  import { GHIDRA_LIMITS, type AssembledSymbol, type Diagnostic } from "#src/native/types.ts";
36
- import { decode as decodeRegister, describeAddress, platformNames, platformNamesFor, romUseOfProgram } from "#src/platform.ts";
36
+ import { decode as decodeRegister, describeAddress, platformNames, platformNamesFor, romRanges, romUseOfProgram } from "#src/platform.ts";
37
37
  import { ensureLocal, LOCAL_DIRECTORY, newProjectFolder, PROJECT_DIRECTORY, projectRoot, resolveProjectPath } from "#src/project.ts";
38
38
  import { isoCet } from "#src/time.ts";
39
39
  import { zipFiles } from "#src/zip.ts";
@@ -49,6 +49,7 @@ import {
49
49
  startScreenPlan,
50
50
  rasterLine,
51
51
  loaderState,
52
+ loaderSymbols,
52
53
  simulate,
53
54
  START_SCREEN_CODE,
54
55
  START_SCREEN_CONTINUE,
@@ -62,6 +63,7 @@ import {
62
63
  type StartScreenPlan,
63
64
  } from "./lib/loader.ts";
64
65
  import { instructionWith, OPCODES } from "#src/opcodes.ts";
66
+ import { capturedColourRam } from "#src/knowledge/start-screen.ts";
65
67
  import { planStage, STAGE_CODE_END, STAGE_FILE, STAGE_START, stageParts, stageText, type StageInput, type StagePart, type StagePlan } from "./lib/stage.ts";
66
68
  import { freeName, planDrops, readmeText, rewriteTest } from "./lib/export.ts";
67
69
  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";
@@ -141,6 +143,14 @@ function withAnalyzerNames(symbols: SymbolRow[], second: SymbolRow[]): SymbolRow
141
143
  return [...symbols, ...added].sort((a, b) => a.address - b.address);
142
144
  }
143
145
 
146
+ /** Where the CPU sees ROM in the image (romRanges): the entry, the routines, the code regions and `entries` stay code. */
147
+ function romOf(image: ProgramImage, knowledge: Pick<SourceKnowledge, "routines" | "regions">, entries: readonly number[], coverage: Uint8Array | undefined): AddressRange[] {
148
+ const inImage = (address: number) => image.segments.some((segment) => address >= segment.start && address <= segment.end);
149
+ const code = knowledge.regions.filter((region) => CODE_REGION_TYPES.includes(region.type) || region.type === "dual-use").map((region) => region.start);
150
+ const known = [...(image.entry === undefined ? [] : [image.entry]), ...entries, ...knowledge.routines, ...code];
151
+ return romRanges(coverage, image.state, (address) => (inImage(address) ? image.byteAt(address) : undefined), known);
152
+ }
153
+
144
154
  /**
145
155
  * Ghidra's instruction starts and lengths inside the image, seeded from the
146
156
  * entry, from knowledge of any origin, and from the coverage: a run's flow
@@ -166,6 +176,8 @@ async function decode(image: ProgramImage, knowledge: Pick<SourceKnowledge, "rou
166
176
  const dataRanges = knowledge.regions
167
177
  .filter((region) => !CODE_REGION_TYPES.includes(region.type) && region.type !== "dual-use")
168
178
  .flatMap((region) => image.segments.filter((segment) => region.start <= segment.end && segment.start <= region.end).map((segment) => ({ start: Math.max(region.start, segment.start), end: Math.min(region.end, segment.end) })));
179
+ // A JSR into ROM runs the ROM: the RAM bytes of the image under it are data, not the code of the call.
180
+ for (const range of romOf(image, knowledge, entries, coverage)) if (!dataRanges.some((data) => range.start <= data.end && data.start <= range.end)) dataRanges.push(range);
169
181
  const { result } = await analyze(
170
182
  {
171
183
  imageKind: analyzedBytes(image).kind,
@@ -544,7 +556,7 @@ interface LoaderRunPlan {
544
556
  /** The wait of the start screen and the code after it, when the loader has a start screen. */
545
557
  startScreen?: { wait: number; continue: number };
546
558
  /** The show stage of a start screen from a captured stage, which runs before the loader: its wait, the code after it, its VIC-II values and the bytes of the stage. */
547
- stage?: { name: string; wait: number; continue: number; screen: StartScreenPlan; parts: StagePart[]; frames: number };
559
+ stage?: { name: string; wait: number; continue: number; screen: StartScreenPlan; parts: StagePart[]; colourRam?: Uint8Array; frames: number };
548
560
  copierSource: number;
549
561
  fileByte: (address: number) => number;
550
562
  copierFrames: number;
@@ -571,7 +583,7 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, state:
571
583
  // on each VICE, so the check lets it wait, then sets the PC to the code after the wait.
572
584
  let screen: LoaderRun["startScreen"];
573
585
  const screenDifferences: string[] = [];
574
- const showScreen = async (at: { wait: number; continue: number }, wanted: StartScreenPlan, frames: number, copied: boolean, parts: readonly StagePart[] = []): Promise<LoaderRun | undefined> => {
586
+ const showScreen = async (at: { wait: number; continue: number }, wanted: StartScreenPlan, frames: number, copied: boolean, parts: readonly StagePart[] = [], colourRam?: Uint8Array): Promise<LoaderRun | undefined> => {
575
587
  const labels = { wait: formatC64Address(at.wait), continue: formatC64Address(at.continue) };
576
588
  const atWait = await client.runUntil({ target: { kind: "address", address: at.wait, space: "c64" }, timeoutFrames: frames });
577
589
  if (!atWait.reached) return await stopped(atWait.pc, copied, `its start screen at ${labels.wait}`, parts.length === 0);
@@ -591,6 +603,12 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, state:
591
603
  const wrong = part.body.findIndex((byte, offset) => ram[offset] !== byte);
592
604
  if (wrong >= 0) screenDifferences.push(`the stage has $${ram[wrong]!.toString(16).padStart(2, "0")} at ${formatC64Address(part.start + wrong)}, not $${part.body[wrong]!.toString(16).padStart(2, "0")}`);
593
605
  }
606
+ // The colour RAM of a captured stage: the first wrong colour.
607
+ if (colourRam !== undefined) {
608
+ const colours = Buffer.from((await client.ioRead(0xd800, colourRam.length)).data, "hex");
609
+ const wrong = colourRam.findIndex((value, offset) => (colours[offset]! & 0x0f) !== value);
610
+ if (wrong >= 0) screenDifferences.push(`the colour RAM has ${colours[wrong]! & 0x0f} at ${formatC64Address(0xd800 + wrong)}, not ${colourRam[wrong]}`);
611
+ }
594
612
  screen = { shown: screenDifferences.length === before, waits: !held.reached, ...labels, ...(run.stage === undefined ? {} : { stage: run.stage.name }) };
595
613
  if (held.reached) screenDifferences.push(`the start screen did not wait: it got to ${labels.continue} without a key or a fire button`);
596
614
  if (!held.reached) await client.registersSet("c64", { pc: at.continue });
@@ -598,7 +616,7 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, state:
598
616
  };
599
617
  // The show stage of a captured stage runs before the loader.
600
618
  if (run.stage !== undefined) {
601
- const stop = await showScreen(run.stage, run.stage.screen, run.stage.frames, false, run.stage.parts);
619
+ const stop = await showScreen(run.stage, run.stage.screen, run.stage.frames, false, run.stage.parts, run.stage.colourRam);
602
620
  if (stop !== undefined) return stop;
603
621
  }
604
622
  const copier = await client.runUntil({ target: { kind: "address", address: plan.copier, space: "c64" }, timeoutFrames: run.copierFrames });
@@ -690,8 +708,11 @@ function sourceMapText(rendered: Rendered, space: string, revision: string | nul
690
708
  /** The folder in .c64-re-tools/local/ where the check of the loader runs the new loader.prg. */
691
709
  const LOADER_CHECK_DIRECTORY = "loader-check";
692
710
 
711
+ /** The symbols file of loader.prg: the labels of each build that it holds. */
712
+ const LOADER_SYMBOLS_FILE = "loader.json";
713
+
693
714
  /** The files of the loader. Only a run with --loader writes them, so only such a run removes them. */
694
- const LOADER_FILES: ReadonlySet<string> = new Set(["loader.asm", "loader.prg", START_SCREEN_FILE, STAGE_FILE]);
715
+ const LOADER_FILES: ReadonlySet<string> = new Set(["loader.asm", "loader.prg", LOADER_SYMBOLS_FILE, START_SCREEN_FILE, STAGE_FILE]);
695
716
 
696
717
  /** The start of the line of loader.asm that gives the knowledge revision of the loader. */
697
718
  const LOADER_REVISION = "Loader generated by c64-source from knowledge revision ";
@@ -827,7 +848,7 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
827
848
 
828
849
  let loader: LoaderPlan | undefined;
829
850
  /** The build of main.asm that the loader loads: the switch values of the loader. */
830
- let loaderMain: { program: Buffer; start: number } | undefined;
851
+ let loaderMain: { program: Buffer; start: number; symbols: AssembledSymbol[] } | undefined;
831
852
  // An image without its entry has no program: the source is still written and checked, but the run fails.
832
853
  const missingEntry = entryOutsideImage(image.entry, image.segments);
833
854
  // A loader that cannot be planned does not stop the source: the source is written and checked, and the result says why.
@@ -839,7 +860,7 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
839
860
  else {
840
861
  const program = main.program;
841
862
  const start = main.start!;
842
- loaderMain = { program, start };
863
+ loaderMain = { program, start, symbols: main.symbols ?? [] };
843
864
  try {
844
865
  const entryName = laid.names.get(image.entry!);
845
866
  loader = planLoader({
@@ -934,9 +955,11 @@ async function buildLoader(
934
955
  * of the stage whose switch default is not its base value is in, as in the
935
956
  * default build. Pages 0-3 are left out: the unpacker of Exomizer uses them.
936
957
  */
937
- async function stageBytes(row: StartScreenRow): Promise<StagePart[]> {
958
+ async function stageBytes(row: StartScreenRow): Promise<{ parts: StagePart[]; colourRam?: Uint8Array }> {
938
959
  const stage = row.stage!;
939
960
  const knowledge = readKnowledge(stage);
961
+ const colourRam = row.colourRam === true ? capturedColourRam(knowledge.program.state) : undefined;
962
+ if (row.colourRam === true && colourRam === undefined) throw new Refusal("not-found", `The start screen takes its colours from the colour RAM of the capture in ${stage}, and that capture has none. Capture the stage again while it shows the screen, and put it into the project knowledge with image --space ${stage}.`);
940
963
  const image = knowledge.program;
941
964
  const memory = Uint8Array.from(image.memory);
942
965
  const addresses = knowledge.symbols.map((symbol) => `${symbol.name} = ${formatC64Address(symbol.address)}`);
@@ -969,15 +992,18 @@ async function stageBytes(row: StartScreenRow): Promise<StagePart[]> {
969
992
  if (last !== undefined && range.start <= last.end + 1) last.end = Math.max(last.end, range.end);
970
993
  else parts.push({ ...range });
971
994
  }
972
- return parts.map((range) => ({ start: range.start, body: memory.slice(range.start, range.end + 1) }));
995
+ return { parts: parts.map((range) => ({ start: range.start, body: memory.slice(range.start, range.end + 1) })), ...(colourRam === undefined ? {} : { colourRam }) };
973
996
  }
974
997
 
975
998
  /** What the show stage gives: loader.prg, the source of the stage, and what its check needs. */
976
999
  interface BuiltStage {
977
1000
  program: Buffer;
978
1001
  text: string;
1002
+ /** The labels of the build of start_screen_stage.asm. */
1003
+ symbols: AssembledSymbol[];
979
1004
  plan: StagePlan;
980
1005
  parts: StagePart[];
1006
+ colourRam?: Uint8Array;
981
1007
  packed: PackedLoader;
982
1008
  wait: number;
983
1009
  continue: number;
@@ -990,7 +1016,7 @@ interface BuiltStage {
990
1016
  * is in memory before it starts. Refuses by name.
991
1017
  */
992
1018
  async function buildStage(files: Array<{ name: string; text: string }>, laid: Layout, program: PackedLoader, row: StartScreenRow, values: ReadonlyMap<string, number>, header: string[], mark: string): Promise<BuiltStage> {
993
- const stage = await stageBytes(row);
1019
+ const { parts: stage, colourRam } = await stageBytes(row);
994
1020
  // The packed program, as RUN would start it: its unpacker unpacks it over the start screen after the wait.
995
1021
  const inner: StagePart[] = [{ start: 0x0801, body: program.program.subarray(2) }];
996
1022
  const screen = startScreenPlan(row);
@@ -999,6 +1025,7 @@ async function buildStage(files: Array<{ name: string; text: string }>, laid: La
999
1025
  innerStart: 0x080d,
1000
1026
  innerPort: 0x37,
1001
1027
  stage,
1028
+ ...(colourRam === undefined ? {} : { colourRam }),
1002
1029
  row,
1003
1030
  plan: screen,
1004
1031
  settings: hasSwitchFile(laid) ? ['!source "switches.asm"'] : hasConfigFile(laid) ? ['!source "config.asm"'] : [],
@@ -1008,17 +1035,24 @@ async function buildStage(files: Array<{ name: string; text: string }>, laid: La
1008
1035
  const support = [...withValues(files, laid, values).filter((file) => file.name === CONFIG_FILE || file.name === "switches.asm"), { name: START_SCREEN_FILE, text: START_SCREEN_CODE }];
1009
1036
  const assembleStage = async (text: string) => {
1010
1037
  const built = await assembleFiles([...support, { name: STAGE_FILE, text }], STAGE_FILE);
1011
- if (built.program === undefined) throw new WireFailure("operation-failed", `${STAGE_FILE} does not assemble: ${built.diagnostics.map((diagnostic) => diagnostic.message).join("; ")}. This is a defect of the script.`);
1038
+ if (built.program === undefined) {
1039
+ // The source that failed stays readable: --out keeps the files of the last good run.
1040
+ ensureLocal(projectRoot());
1041
+ const kept = `${PROJECT_DIRECTORY}/${LOCAL_DIRECTORY}/${LOADER_CHECK_DIRECTORY}/${STAGE_FILE}`;
1042
+ mkdirSync(dirname(resolveProjectPath(kept)), { recursive: true });
1043
+ writeFileSync(resolveProjectPath(kept), `${mark}\n${text}`);
1044
+ throw new WireFailure("operation-failed", `${STAGE_FILE} does not assemble: ${built.diagnostics.map((diagnostic) => diagnostic.message).join("; ")}. The source that failed is ${kept}. This is a defect of the script.`);
1045
+ }
1012
1046
  const labels = new Map((built.symbols ?? []).map((symbol) => [symbol.name, symbol.kind === "address" ? symbol.address : symbol.value]));
1013
1047
  const label = (name: string) => {
1014
1048
  const value = labels.get(name);
1015
1049
  if (value === undefined) throw new WireFailure("operation-failed", `The build of ${STAGE_FILE} has no ${name} label. This is a defect of the script.`);
1016
1050
  return value;
1017
1051
  };
1018
- return { program: built.program, label };
1052
+ return { program: built.program, symbols: built.symbols ?? [], label };
1019
1053
  };
1020
- // The size of the show code does not depend on its address: one build without a stash gives it.
1021
- const probe = await assembleStage(stageText(input, 0x1000, []));
1054
+ // The size of the show code does not depend on its address: one build without a stash and without the parts gives it.
1055
+ const probe = await assembleStage(stageText({ ...input, stage: [] }, 0x1000, []));
1022
1056
  input.codeSize = probe.label(STAGE_CODE_END) - probe.label(STAGE_START) - 2;
1023
1057
  const plan = planStage(input);
1024
1058
  const built = await assembleStage(plan.text);
@@ -1027,7 +1061,7 @@ async function buildStage(files: Array<{ name: string; text: string }>, laid: La
1027
1061
  const packed = await packParts(parts, plan.code, 0x37, "the loader and the start screen of the stage", "the show stage", localToolContext());
1028
1062
  const end = 0x0801 + packed.program.length - 3;
1029
1063
  if (end > 0xcfff) throw new Refusal("invalid-input", `loader.prg with the start screen of ${row.stage} would end at ${formatC64Address(end)}, after $cfff: loading it would write the I/O area. Capture the stage with less memory, so that its program holds only the start screen and the routine of the call.`);
1030
- return { program: packed.program, text: `${mark}\n${plan.text}`, plan, parts: stage, packed, wait: built.label(START_SCREEN_WAIT), continue: built.label(START_SCREEN_CONTINUE), screen };
1064
+ return { program: packed.program, text: `${mark}\n${plan.text}`, symbols: built.symbols, plan, parts: stage, ...(colourRam === undefined ? {} : { colourRam }), packed, wait: built.label(START_SCREEN_WAIT), continue: built.label(START_SCREEN_CONTINUE), screen };
1031
1065
  }
1032
1066
 
1033
1067
  /** The first line of each file that generate writes. */
@@ -1230,7 +1264,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
1230
1264
  return part.body[address - part.start]!;
1231
1265
  };
1232
1266
  const screenParts = stage === undefined ? [] : startScreenRanges(stageRow!).map(({ range }) => ({ start: range.start, body: Uint8Array.from({ length: range.end - range.start + 1 }, (_, offset) => stageByte(range.start + offset)) }));
1233
- const stageRun = stage === undefined ? {} : { stage: { name: stageRow!.stage!, wait: stage.wait, continue: stage.continue, screen: stage.screen, parts: screenParts, frames: unpackFrames(stage.packed.cycles) + LOADER_FRAMES } };
1267
+ const stageRun = stage === undefined ? {} : { stage: { name: stageRow!.stage!, wait: stage.wait, continue: stage.continue, screen: stage.screen, parts: screenParts, ...(stage.colourRam === undefined ? {} : { colourRam: stage.colourRam }), frames: unpackFrames(stage.packed.cycles) + LOADER_FRAMES } };
1234
1268
  let ran: LoaderRun;
1235
1269
  try {
1236
1270
  ran = await runLoader(checkPath, program, loader, state, { jump, copierSource, fileByte, copierFrames, ...(startScreen === undefined ? {} : { startScreen }), ...stageRun }, expected);
@@ -1241,7 +1275,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
1241
1275
  } finally {
1242
1276
  rmSync(resolveProjectPath(scratch), { recursive: true, force: true });
1243
1277
  }
1244
- written.push(writeReported(loaderPath, program, { what: "--out" }));
1278
+ written.push(writeReported(loaderPath, program, { what: "--out" }), writeReported(`${out}/${LOADER_SYMBOLS_FILE}`, symbolsFileText(loaderSymbols(loaderMain.symbols, loaderBuilt.symbols, stage?.symbols ?? [])), { what: "--out" }));
1245
1279
  if (stage !== undefined) written.push(writeReported(`${out}/${STAGE_FILE}`, stage.text, { what: "--out" }), writeReported(`${out}/${START_SCREEN_FILE}`, `${GENERATED_LINE}\n${START_SCREEN_CODE}`, { what: "--out" }));
1246
1280
  output.loader = {
1247
1281
  program: loaderPath,
@@ -1276,15 +1310,21 @@ function exportValue(row: SourceSwitch): 0 | 1 {
1276
1310
 
1277
1311
  const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
1278
1312
 
1279
- /** The entry of a PRG without one in the knowledge: the address of the first SYS of its BASIC line, when the image holds it. */
1280
- function basicEntry(image: ProgramImage): number | undefined {
1313
+ /**
1314
+ * The BASIC line that starts a PRG: its bytes, and the address of its first
1315
+ * SYS when the image holds it (the entry of a PRG without one in the
1316
+ * knowledge). Undefined when the first segment holds no BASIC line with a SYS.
1317
+ */
1318
+ function basicStart(image: ProgramImage): { line: AddressRange; entry?: number } | undefined {
1281
1319
  const first = image.segments[0];
1282
1320
  if (first === undefined) return undefined;
1283
1321
  const tokenized = parseTokenized(Uint8Array.from([first.start & 0xff, first.start >> 8, ...image.memory.subarray(first.start, first.end + 1)]));
1284
1322
  if ("reason" in tokenized) return undefined;
1285
- const sys = findHandoffs(tokenized.lines).find((handoff) => handoff.kind === "sys" && "address" in handoff);
1286
- const address = sys !== undefined && "address" in sys ? sys.address : undefined;
1287
- return address !== undefined && image.segments.some((segment) => address >= segment.start && address <= segment.end) ? address : undefined;
1323
+ const sys = findHandoffs(tokenized.lines).find((handoff) => handoff.kind === "sys");
1324
+ if (sys === undefined) return undefined;
1325
+ const line = { start: first.start, end: Math.min(first.end, tokenized.basicEnd - 1) };
1326
+ const address = "address" in sys ? sys.address : undefined;
1327
+ return address !== undefined && image.segments.some((segment) => address >= segment.start && address <= segment.end) ? { line, entry: address } : { line };
1288
1328
  }
1289
1329
 
1290
1330
  /** The parts of a region outside the holes. A part that is not the whole region has no element size: its length need not be a multiple of it. */
@@ -1323,9 +1363,10 @@ function freeRanges(knowledge: SourceKnowledge, memory: Uint8Array, instructions
1323
1363
  for (const operand of knowledge.operands) {
1324
1364
  const names = operand.symbol !== undefined ? [operand.symbol] : identifiers(operand.expression ?? "");
1325
1365
  const targets = names.flatMap((item) => (addressOf.has(item) ? [(addressOf.get(item)! + (operand.symbol !== undefined ? operand.offset : 0)) & 0xffff] : []));
1326
- if (targets.length > 0) operandTargets.set(operand.address, targets);
1366
+ operandTargets.set(operand.address, targets);
1327
1367
  }
1328
- const entry = image.entry ?? basicEntry(image);
1368
+ const basic = basicStart(image);
1369
+ const entry = image.entry ?? basic?.entry;
1329
1370
  return planDrops({
1330
1371
  segments: image.segments,
1331
1372
  memory,
@@ -1335,6 +1376,8 @@ function freeRanges(knowledge: SourceKnowledge, memory: Uint8Array, instructions
1335
1376
  regions: effectiveRegions(knowledge.regions),
1336
1377
  references: knowledge.references,
1337
1378
  operandTargets,
1379
+ rom: romOf(image, knowledge, [], knowledge.coverage),
1380
+ ...(basic === undefined ? {} : { basic: basic.line }),
1338
1381
  changed: [...ranges.changed],
1339
1382
  keep: [...ranges.keep],
1340
1383
  drop: [...ranges.drop],
@@ -1700,7 +1743,7 @@ await runScript({
1700
1743
  options: {
1701
1744
  out: { ...OPTIONS.out, output: "folder", value: "<dir>", help: "the folder for the source files, relative to the project folder", required: true },
1702
1745
  entry: { ...OPTIONS.entry, multiple: true, help: "an address where code starts. The entry of the program, the routines and the code regions of the knowledge are entry points too" },
1703
- space: { ...OPTIONS.space, help: "the knowledge space of the program: c64 (the default), drive8, or bank0 to bank255. --loader is for c64 only" },
1746
+ space: { ...OPTIONS.space, help: "the knowledge space of the program: c64 (the default), drive8, loading, or bank0 to bank255. --loader is for c64 only" },
1704
1747
  loader: { kind: "flag", help: "also write loader.asm and loader.prg: the loader copies the segments into place, sets the entry state of the knowledge, and jumps to the entry. It is checked in the emulator. The loader leaves out the leftovers. When the check cannot run, the script keeps the loader.prg of an earlier run" },
1705
1748
  "analyzer-names": { kind: "flag", help: "name an address that has no name of the user or the LLM, and no platform name, with its analyzer name" },
1706
1749
  "max-listed": OPTIONS["max-listed"],
@@ -4,15 +4,12 @@
4
4
 
5
5
  import type { DatabaseSync } from "node:sqlite";
6
6
 
7
- import { COVERAGE, coverageEntries, coverageSeedKinds, executedStarts } from "#src/c64.ts";
7
+ import { COVERAGE, coverageEntries, coverageSeedKinds, executedStarts, romOnlyRanges } from "#src/c64.ts";
8
8
 
9
- export { coverageEntries, coverageSeedKinds, executedStarts };
10
- import { FULL_COVERAGE } from "#src/host-client/coverage.ts";
9
+ export { coverageEntries, coverageSeedKinds, executedStarts, romOnlyRanges };
11
10
  import { listRegions, type RegionRow } from "#src/knowledge/read.ts";
12
11
  import { CODE_REGION_TYPES, DEFAULT_SPACE, isAnalyzer, isSemantic, type Space } from "#src/knowledge/schema.ts";
13
12
 
14
- const FULL_MAP = FULL_COVERAGE;
15
-
16
13
  /** The byte at an address of the analyzed image, or undefined outside it. */
17
14
  export type ImageByte = (address: number) => number | undefined;
18
15
 
@@ -22,26 +19,6 @@ export function imageReader(bytes: Uint8Array, kind: "prg" | "flat64k"): ImageBy
22
19
  return (address) => (address >= load && address - load + 2 < bytes.length ? bytes[address - load + 2] : undefined);
23
20
  }
24
21
 
25
- const ROM_ACCESS = COVERAGE.romRead | COVERAGE.romExecute;
26
- const RAM_USE = COVERAGE.ramRead | COVERAGE.ramExecute;
27
-
28
- /**
29
- * The image bytes under ROM that the runs never used: the CPU read or ran the
30
- * ROM there, and never read or ran the RAM. A JSR $FFE4 or an IRQ
31
- * vector at $FFFE then leads into ROM, not into the leftover RAM bytes of a
32
- * flat image, so the ranges are data for the analysis run.
33
- */
34
- export function romOnlyRanges(map: Uint8Array, image: ImageByte): Array<{ start: number; end: number }> {
35
- const ranges: Array<{ start: number; end: number }> = [];
36
- for (let address = 0; address < FULL_MAP; address++) {
37
- if ((map[address]! & ROM_ACCESS) === 0 || (map[address]! & RAM_USE) !== 0 || image(address) === undefined) continue;
38
- const last = ranges.at(-1);
39
- if (last !== undefined && last.end === address - 1) last.end = address;
40
- else ranges.push({ start: address, end: address });
41
- }
42
- return ranges;
43
- }
44
-
45
22
  /** Entry points from semantic knowledge beyond routines: the start of each code region, and each entry of a JMP table with its target. */
46
23
  export function codeEntries(db: DatabaseSync | undefined, image: ImageByte, space: Space = DEFAULT_SPACE): number[] {
47
24
  const entries: number[] = [];
@@ -233,6 +233,8 @@ The script first replays the recording on the original. The original must end th
233
233
  `--checkpoint` and `--state` go together. `--pin` needs both of them. `--symbols` needs `--rebuild`. Give at most 16 `--state` and `--pin` items. Without `--checkpoint`, the script uses the comparison of the record file.
234
234
  A `$` address is an address of the original. On the rebuild, it moves with the name before it.
235
235
 
236
+ A rebuild can be a loader with a start screen that RUN starts. If the symbols of the rebuild have `loader_start_screen_wait` and `loader_start_screen_continue`, the script runs the rebuild to the wait. Then it sets the PC to `loader_start_screen_continue`. The cycles before the wait do not count.
237
+
236
238
  `body` holds `result`, `side`, `firstDifference`, `reason` and `files`. The section "Replay" of `references/recording-format.md` gives each field.
237
239
 
238
240
  Do this for each result:
@@ -126,5 +126,6 @@ The body of the envelope of `replay` has these fields:
126
126
  - `firstDifference`: on a FAIL, the checkpoint (1 is the first), the cycle on each side, and each state item that is different. An item has `address`, and the `original` and `rebuild` values as hex.
127
127
  - `reason`: why the result is FAIL or INCONCLUSIVE.
128
128
  - `movedSites`: the number of sites at a different address in the rebuild.
129
+ - `startScreen`: `skipped` when the rebuild went past the wait of its start screen.
129
130
  - `idleReads`: the input reads of the rebuild that the recording had no value for. Such a read is at a site that the recording does not have, or after its end. Each got the fixed value `$FF` (joystick, keyboard, paddles) or `$00`. An input site that the site map did not find shows here.
130
131
  - `files`: with `--out`, the RAM of each side at the first different checkpoint, `original-<n>.bin` and `rebuild-<n>.bin`.
@@ -74,13 +74,15 @@ An `observe` step has a checkpoint name. A scenario can have each name only one
74
74
 
75
75
  | Key | What the script compares |
76
76
  |---|---|
77
- | `memory` | A list of names, `$` addresses, or objects. An object has `address`, `size` (1 to 65536, default 1), `view` (`cpu` or `ram`, default `cpu`), `tolerance` (0 to 255, default 0) and `exclude`. The view `ram` reads the RAM under the ROMs and the I/O area. |
77
+ | `memory` | A list of names, `$` addresses, or objects. An object has `address`, `size` (1 to 65536, default 1), `view` (`cpu` or `ram`, default `cpu`), `tolerance` (0 to 255, default 0), `mask` and `exclude`. The view `ram` reads the RAM under the ROMs and the I/O area. |
78
78
  | `registers` | A list of register names: `pc`, `a`, `x`, `y`, `sp`, `flags`. |
79
79
  | `screen` | The screen of the rebuild against the screen of the original. `maxMismatchRatio` (default 0) is the largest permitted part of different pixels. `mask` is a list of rectangles (`x`, `y`, `width`, `height`) that the comparison does not include. |
80
80
  | `vicii` | The VIC-II state: mode, screen address, scroll and colors. |
81
81
  | `sprites` | A list of sprite numbers from 0 to 7. The script compares their position, color and flags. |
82
82
 
83
- A `tolerance` is the largest permitted difference for each byte. A `mask` has at most 64 rectangles. A `mask` must not cover all of the screen: PAL is 384×272 pixels and NTSC is 384×247 pixels. A scenario can observe the screen at most at 64 checkpoints.
83
+ A `tolerance` is the largest permitted difference for each byte. A screen `mask` has at most 64 rectangles. A `mask` must not cover all of the screen: PAL is 384×272 pixels and NTSC is 384×247 pixels. A scenario can observe the screen at most at 64 checkpoints.
84
+
85
+ The `mask` of a memory object gives the bits that the comparison uses, as hex. It is one byte for all bytes of the range, for example `0f`, or one byte for each byte of the range. The comparison applies the mask first and then the `tolerance`. The colour RAM at $d800 has only 4 bits, and its other 4 bits are not stable. Thus observe the colour RAM with the mask `0f`.
84
86
 
85
87
  `exclude` is a list of bytes in the observed range that the comparison does not include. Each has `address` and a `reason`, for example `{ "address": "$d01e", "reason": "latched sprite collision, not writable" }`. The result lists each excluded byte with its `address` and `reason`.
86
88
 
@@ -16,6 +16,7 @@ import { c64AddressOf, formatC64Address, parseC64Address } from "#src/c64.ts";
16
16
  import { READY_FRAMES } from "#src/host-client/entry-state.ts";
17
17
  import { ACTION_STEP_KINDS, checkActionStep, isInteger, isObject, keyboardBytes, renamedField, stepKind, type ActionStep, type Location } from "#src/host-client/steps.ts";
18
18
  import { readProjectFile, type Written } from "#src/host-client/transfer.ts";
19
+ import { START_SCREEN_CONTINUE, START_SCREEN_WAIT } from "#src/knowledge/start-screen.ts";
19
20
  import { PAL_FRAME_CYCLES, type C64RunSession, type CoreStatus } from "#src/native/c64run.ts";
20
21
  import type { Workspace } from "#src/native/staging.ts";
21
22
  import { namesOf, type Outcome } from "./scenario.ts";
@@ -387,10 +388,10 @@ function busiestSite(answer: string): { site: number; addr: number; count: numbe
387
388
  * Runs to the point of an event. `map` moves a site to the rebuild. "halted"
388
389
  * when a sample stop came first, "not-reached" when the point did not come before `until`.
389
390
  */
390
- async function runToKey(core: C64RunSession, key: RecordedEvent["key"], until: number, map: Map<number, number>): Promise<"reached" | "not-reached" | "halted"> {
391
+ async function runToKey(core: C64RunSession, key: RecordedEvent["key"], until: number, map: Map<number, number>, skipped: number): Promise<"reached" | "not-reached" | "halted"> {
391
392
  if ("previous" in key) return (await core.status("status")).word === "halted" ? "halted" : "reached";
392
393
  if ("tick" in key) {
393
- const status = await core.status(`run ${key.tick}`);
394
+ const status = await core.status(`run ${key.tick + skipped}`);
394
395
  return status.word === "halted" ? "halted" : "reached";
395
396
  }
396
397
  const site = parseC64Address(key.site);
@@ -509,7 +510,7 @@ export async function record(
509
510
  : busiest === undefined
510
511
  ? { tick: tick + 1 }
511
512
  : { site: formatC64Address(busiest.site), addr: formatC64Address(busiest.addr), count: busiest.count + 1 };
512
- if ((await runToKey(core, key, tick + 600 * PAL_FRAME_CYCLES, new Map())) !== "reached") return "the program did not read its input again within 600 frames";
513
+ if ((await runToKey(core, key, tick + 600 * PAL_FRAME_CYCLES, new Map(), 0)) !== "reached") return "the program did not read its input again within 600 frames";
513
514
  events.push({ ...(step === undefined ? {} : { step }), action, key });
514
515
  return doAction(core, action, at);
515
516
  };
@@ -590,6 +591,8 @@ export interface SideRun {
590
591
  end: CoreStatus;
591
592
  /** Why the side stopped before its last checkpoint, if it did. */
592
593
  problem?: string;
594
+ /** True when the rebuild went on after the wait of its start screen. */
595
+ startScreenSkipped?: boolean;
593
596
  /**
594
597
  * Input reads that the recording has no value for, which got the fixed idle value:
595
598
  * at sites that it does not have, and after its end at a site.
@@ -620,7 +623,8 @@ export async function replaySide(
620
623
  const move = original
621
624
  ? { code: same, data: same }
622
625
  : { code: mover(namesOf(names, "code"), namesOf(subject.symbols, "code")), data: mover(namesOf(names), namesOf(subject.symbols)) };
623
- const at = sideAddresses(namesOf(subject.symbols), subject.side, move);
626
+ const own = namesOf(subject.symbols);
627
+ const at = sideAddresses(own, subject.side, move);
624
628
  const moved = original ? [] : siteMap(recording.sites, namesOf(names, "code"), namesOf(subject.symbols, "code"));
625
629
  const map = new Map(moved);
626
630
  const reads = workspace.path(`${subject.side}-${RECORDING_FILES.reads}`);
@@ -645,11 +649,24 @@ export async function replaySide(
645
649
  await core.command(`sample ${hex(at.code(options.compare.checkpoint))} ${samples} ${rangesArgument([...options.compare.state, ...pinned], at)}${stop > 0 ? ` ${stop}` : ""}`);
646
650
  }
647
651
  await startProgram(core, prg, recording.load);
648
- const limit = original ? recording.ticks : recording.ticks * REBUILD_TIME_FACTOR;
652
+ let limit = original ? recording.ticks : recording.ticks * REBUILD_TIME_FACTOR;
649
653
  let problem: string | undefined;
650
- for (const event of recording.events) {
654
+ // A loader with a start screen that RUN starts waits for a key or a fire button that the recording does not have:
655
+ // the rebuild goes on after the wait, as the check of the loader does. The cycles to the wait do not count.
656
+ const wait = own.get(START_SCREEN_WAIT);
657
+ const resume = own.get(START_SCREEN_CONTINUE);
658
+ let skipped = 0;
659
+ if (!original && !recording.load && wait !== undefined && resume !== undefined) {
660
+ const reached = await core.status(`run-pc ${hex(wait)} ${limit}`);
661
+ if (reached.word === "reached") {
662
+ skipped = reached.tick;
663
+ limit += skipped;
664
+ await core.status(`goto ${hex(resume)}`);
665
+ } else problem = `the rebuild did not come to the wait of its start screen at ${formatC64Address(wait)}`;
666
+ }
667
+ for (const event of problem === undefined ? recording.events : []) {
651
668
  const what = event.step === undefined ? "the RESTORE of the play" : "step " + event.step;
652
- const point = await runToKey(core, event.key, limit, map);
669
+ const point = await runToKey(core, event.key, limit, map, skipped);
653
670
  if (point === "halted") break;
654
671
  if (point === "not-reached") {
655
672
  problem = "the program did not come to the point of " + what;
@@ -672,7 +689,7 @@ export async function replaySide(
672
689
  await core.command("sample off");
673
690
  lines = readFileSync(samples, "utf8").split("\n").filter((line) => line !== "");
674
691
  }
675
- return { samples: lines, end, unknown, misses, ...(problem === undefined ? {} : { problem }), ...(ram === undefined ? {} : { ram }) };
692
+ return { samples: lines, end, unknown, misses, ...(problem === undefined ? {} : { problem }), ...(skipped > 0 ? { startScreenSkipped: true } : {}), ...(ram === undefined ? {} : { ram }) };
676
693
  }
677
694
 
678
695
  export interface CheckpointDifference {
@@ -93,7 +93,7 @@ export async function replay(values: ReplayOptions): Promise<ReplayResult> {
93
93
  const replayed = await side(rebuild, { compare: compare!, stop: expected.length, pins });
94
94
  const difference = firstDifference(expected, replayed.samples, compare!.state);
95
95
  // A read that the recording has no value for gets the idle value: it is in the result, never silent.
96
- const base = { checkpoints: expected.length, movedSites, ...(replayed.unknown > 0 ? { idleReads: replayed.unknown } : {}) };
96
+ const base = { checkpoints: expected.length, movedSites, ...(replayed.startScreenSkipped === true ? { startScreen: "skipped" } : {}), ...(replayed.unknown > 0 ? { idleReads: replayed.unknown } : {}) };
97
97
  if (difference === undefined && replayed.samples.length >= expected.length) return result("PASS", "rebuild", { ...base, compared: expected.length });
98
98
  const reason =
99
99
  difference !== undefined