@henols/c64-re-tools 2.6.0-rc.1 → 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
 
@@ -465,6 +465,8 @@ export interface LoaderInput {
465
465
  config?: boolean;
466
466
  /** The start screen of the knowledge: the copier shows it after the copies. */
467
467
  startScreen?: StartScreenRow;
468
+ /** Always the packed form: the show stage of a start screen from a captured stage holds the packed program while it shows the screen. */
469
+ packed?: boolean;
468
470
  }
469
471
 
470
472
  /** The checks of a start screen against the program and the entry state. Refuses by name. */
@@ -549,6 +551,7 @@ export function planLoader(input: LoaderInput): LoaderPlan {
549
551
  const codeSize = COPIER_CODE_SIZE + (state.vic === undefined ? 0 : VIC_SIZE) + ciaSize + (screen === undefined ? 0 : START_SCREEN_SIZES[screen.colourMode]);
550
552
  const copierImage = at;
551
553
  const end = copierImage + codeSize + COPY_ENTRY * plain.length + 2 - 1;
554
+ if (input.packed === true) return planPacked(input, blocks, cia, codeSize, screen, "The start screen of a captured stage shows while the program is still packed.");
552
555
  // The end can be past $ffff, which is no address.
553
556
  if (end > LOAD_LIMIT) return planPacked(input, blocks, cia, codeSize, screen, `The plain loader would end ${end > 0xffff ? "past $ffff" : `at ${formatC64Address(end)}`}, after ${formatC64Address(LOAD_LIMIT)}: loading it would write the I/O area.`);
554
557
  // The CIA part and the start screen take room from the copy table in the copier's pages.
@@ -832,7 +835,7 @@ export async function packLoader(main: Uint8Array, copier: Uint8Array, plan: Loa
832
835
  }
833
836
 
834
837
  /** What Exomizer packs in the packed form: the loaded ranges of the build of main.asm from $0400, and the build of loader.asm. */
835
- export function packedParts(main: Uint8Array, copier: Uint8Array, plan: Pick<LoaderPlan, "loaded">): Array<{ start: number; body: Uint8Array }> {
838
+ function packedParts(main: Uint8Array, copier: Uint8Array, plan: Pick<LoaderPlan, "loaded">): Array<{ start: number; body: Uint8Array }> {
836
839
  // The unpacker uses pages 0-3; the copier writes them. The leftovers between the loaded ranges are not packed.
837
840
  const program = prgRange(main);
838
841
  const ranges = plan.loaded.flatMap((range) => {
@@ -988,3 +991,23 @@ function vicLines(state: EntryState, earlier: number): string[] {
988
991
  " bne .raster",
989
992
  ];
990
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";
@@ -43,13 +43,13 @@ import {
43
43
  COPIER_SOURCE,
44
44
  LOADER_JUMP,
45
45
  loaderLimits,
46
- packedParts,
47
46
  packLoader,
48
47
  packParts,
49
48
  planLoader,
50
49
  startScreenPlan,
51
50
  rasterLine,
52
51
  loaderState,
52
+ loaderSymbols,
53
53
  simulate,
54
54
  START_SCREEN_CODE,
55
55
  START_SCREEN_CONTINUE,
@@ -63,6 +63,7 @@ import {
63
63
  type StartScreenPlan,
64
64
  } from "./lib/loader.ts";
65
65
  import { instructionWith, OPCODES } from "#src/opcodes.ts";
66
+ import { capturedColourRam } from "#src/knowledge/start-screen.ts";
66
67
  import { planStage, STAGE_CODE_END, STAGE_FILE, STAGE_START, stageParts, stageText, type StageInput, type StagePart, type StagePlan } from "./lib/stage.ts";
67
68
  import { freeName, planDrops, readmeText, rewriteTest } from "./lib/export.ts";
68
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";
@@ -142,6 +143,14 @@ function withAnalyzerNames(symbols: SymbolRow[], second: SymbolRow[]): SymbolRow
142
143
  return [...symbols, ...added].sort((a, b) => a.address - b.address);
143
144
  }
144
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
+
145
154
  /**
146
155
  * Ghidra's instruction starts and lengths inside the image, seeded from the
147
156
  * entry, from knowledge of any origin, and from the coverage: a run's flow
@@ -167,6 +176,8 @@ async function decode(image: ProgramImage, knowledge: Pick<SourceKnowledge, "rou
167
176
  const dataRanges = knowledge.regions
168
177
  .filter((region) => !CODE_REGION_TYPES.includes(region.type) && region.type !== "dual-use")
169
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);
170
181
  const { result } = await analyze(
171
182
  {
172
183
  imageKind: analyzedBytes(image).kind,
@@ -545,7 +556,7 @@ interface LoaderRunPlan {
545
556
  /** The wait of the start screen and the code after it, when the loader has a start screen. */
546
557
  startScreen?: { wait: number; continue: number };
547
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. */
548
- 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 };
549
560
  copierSource: number;
550
561
  fileByte: (address: number) => number;
551
562
  copierFrames: number;
@@ -572,7 +583,7 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, state:
572
583
  // on each VICE, so the check lets it wait, then sets the PC to the code after the wait.
573
584
  let screen: LoaderRun["startScreen"];
574
585
  const screenDifferences: string[] = [];
575
- 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> => {
576
587
  const labels = { wait: formatC64Address(at.wait), continue: formatC64Address(at.continue) };
577
588
  const atWait = await client.runUntil({ target: { kind: "address", address: at.wait, space: "c64" }, timeoutFrames: frames });
578
589
  if (!atWait.reached) return await stopped(atWait.pc, copied, `its start screen at ${labels.wait}`, parts.length === 0);
@@ -592,6 +603,12 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, state:
592
603
  const wrong = part.body.findIndex((byte, offset) => ram[offset] !== byte);
593
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")}`);
594
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
+ }
595
612
  screen = { shown: screenDifferences.length === before, waits: !held.reached, ...labels, ...(run.stage === undefined ? {} : { stage: run.stage.name }) };
596
613
  if (held.reached) screenDifferences.push(`the start screen did not wait: it got to ${labels.continue} without a key or a fire button`);
597
614
  if (!held.reached) await client.registersSet("c64", { pc: at.continue });
@@ -599,7 +616,7 @@ async function runLoader(path: string, program: Buffer, plan: LoaderPlan, state:
599
616
  };
600
617
  // The show stage of a captured stage runs before the loader.
601
618
  if (run.stage !== undefined) {
602
- 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);
603
620
  if (stop !== undefined) return stop;
604
621
  }
605
622
  const copier = await client.runUntil({ target: { kind: "address", address: plan.copier, space: "c64" }, timeoutFrames: run.copierFrames });
@@ -691,8 +708,11 @@ function sourceMapText(rendered: Rendered, space: string, revision: string | nul
691
708
  /** The folder in .c64-re-tools/local/ where the check of the loader runs the new loader.prg. */
692
709
  const LOADER_CHECK_DIRECTORY = "loader-check";
693
710
 
711
+ /** The symbols file of loader.prg: the labels of each build that it holds. */
712
+ const LOADER_SYMBOLS_FILE = "loader.json";
713
+
694
714
  /** The files of the loader. Only a run with --loader writes them, so only such a run removes them. */
695
- 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]);
696
716
 
697
717
  /** The start of the line of loader.asm that gives the knowledge revision of the loader. */
698
718
  const LOADER_REVISION = "Loader generated by c64-source from knowledge revision ";
@@ -828,7 +848,7 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
828
848
 
829
849
  let loader: LoaderPlan | undefined;
830
850
  /** The build of main.asm that the loader loads: the switch values of the loader. */
831
- let loaderMain: { program: Buffer; start: number } | undefined;
851
+ let loaderMain: { program: Buffer; start: number; symbols: AssembledSymbol[] } | undefined;
832
852
  // An image without its entry has no program: the source is still written and checked, but the run fails.
833
853
  const missingEntry = entryOutsideImage(image.entry, image.segments);
834
854
  // A loader that cannot be planned does not stop the source: the source is written and checked, and the result says why.
@@ -840,7 +860,7 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
840
860
  else {
841
861
  const program = main.program;
842
862
  const start = main.start!;
843
- loaderMain = { program, start };
863
+ loaderMain = { program, start, symbols: main.symbols ?? [] };
844
864
  try {
845
865
  const entryName = laid.names.get(image.entry!);
846
866
  loader = planLoader({
@@ -853,8 +873,9 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
853
873
  config: hasConfigFile(laid),
854
874
  macros: laid.macros.length > 0,
855
875
  header: options.loaderHeader ?? [],
856
- // A start screen of a stage shows before the loader, in the show stage: the copier has none.
876
+ // A start screen of a stage shows before the loader, in the show stage, while the program is still packed: the copier has none.
857
877
  ...(knowledge.startScreen === undefined || knowledge.startScreen.stage !== undefined ? {} : { startScreen: knowledge.startScreen }),
878
+ ...(knowledge.startScreen?.stage === undefined ? {} : { packed: true }),
858
879
  });
859
880
  } catch (error) {
860
881
  if (!isRefusal(error)) throw error;
@@ -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;
@@ -989,15 +1015,17 @@ interface BuiltStage {
989
1015
  * assembles start_screen_stage.asm and packs it with the loader as the loader
990
1016
  * is in memory before it starts. Refuses by name.
991
1017
  */
992
- async function buildStage(files: Array<{ name: string; text: string }>, laid: Layout, loader: LoaderPlan, main: { program: Buffer; start: number }, copierBuild: Buffer, row: StartScreenRow, values: ReadonlyMap<string, number>, header: string[], mark: string): Promise<BuiltStage> {
993
- const stage = await stageBytes(row);
994
- const inner: StagePart[] = loader.packed === undefined ? [{ start: 0x0801, body: copierBuild.subarray(2) }] : packedParts(main.program, copierBuild, loader).map((part) => ({ start: part.start, body: part.body }));
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> {
1019
+ const { parts: stage, colourRam } = await stageBytes(row);
1020
+ // The packed program, as RUN would start it: its unpacker unpacks it over the start screen after the wait.
1021
+ const inner: StagePart[] = [{ start: 0x0801, body: program.program.subarray(2) }];
995
1022
  const screen = startScreenPlan(row);
996
1023
  const input: StageInput = {
997
1024
  inner,
998
- innerStart: loader.packed === undefined ? 0x080d : loader.copier,
999
- innerPort: loader.packed === undefined ? 0x37 : 0x34,
1025
+ innerStart: 0x080d,
1026
+ innerPort: 0x37,
1000
1027
  stage,
1028
+ ...(colourRam === undefined ? {} : { colourRam }),
1001
1029
  row,
1002
1030
  plan: screen,
1003
1031
  settings: hasSwitchFile(laid) ? ['!source "switches.asm"'] : hasConfigFile(laid) ? ['!source "config.asm"'] : [],
@@ -1007,17 +1035,24 @@ async function buildStage(files: Array<{ name: string; text: string }>, laid: La
1007
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 }];
1008
1036
  const assembleStage = async (text: string) => {
1009
1037
  const built = await assembleFiles([...support, { name: STAGE_FILE, text }], STAGE_FILE);
1010
- 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
+ }
1011
1046
  const labels = new Map((built.symbols ?? []).map((symbol) => [symbol.name, symbol.kind === "address" ? symbol.address : symbol.value]));
1012
1047
  const label = (name: string) => {
1013
1048
  const value = labels.get(name);
1014
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.`);
1015
1050
  return value;
1016
1051
  };
1017
- return { program: built.program, label };
1052
+ return { program: built.program, symbols: built.symbols ?? [], label };
1018
1053
  };
1019
- // The size of the show code does not depend on its address: one build without a stash gives it.
1020
- 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, []));
1021
1056
  input.codeSize = probe.label(STAGE_CODE_END) - probe.label(STAGE_START) - 2;
1022
1057
  const plan = planStage(input);
1023
1058
  const built = await assembleStage(plan.text);
@@ -1026,7 +1061,7 @@ async function buildStage(files: Array<{ name: string; text: string }>, laid: La
1026
1061
  const packed = await packParts(parts, plan.code, 0x37, "the loader and the start screen of the stage", "the show stage", localToolContext());
1027
1062
  const end = 0x0801 + packed.program.length - 3;
1028
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.`);
1029
- 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 };
1030
1065
  }
1031
1066
 
1032
1067
  /** The first line of each file that generate writes. */
@@ -1191,11 +1226,11 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
1191
1226
  const { jump, copierSource, expected, startScreen } = loaderBuilt;
1192
1227
  const copierBuild = loaderBuilt.program;
1193
1228
  const fileByte = (address: number) => copierBuild[2 + address - (loader.packed?.start ?? 0x0801)]!;
1194
- // A start screen of a captured stage: the show stage packs the loader with it, so the packed form is not packed alone.
1229
+ // A start screen of a captured stage: the show stage holds the packed program, as a cracktro holds the game.
1195
1230
  const stageRow = knowledge.startScreen?.stage === undefined ? undefined : knowledge.startScreen;
1196
1231
  // 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.
1197
1232
  let packed: PackedLoader | undefined;
1198
- if (loader.packed !== undefined && stageRow === undefined) {
1233
+ if (loader.packed !== undefined) {
1199
1234
  try {
1200
1235
  packed = await packLoader(loaderMain.program, copierBuild, loader, localToolContext());
1201
1236
  } catch (error) {
@@ -1206,7 +1241,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
1206
1241
  let stage: BuiltStage | undefined;
1207
1242
  if (stageRow !== undefined) {
1208
1243
  try {
1209
- stage = await buildStage(files, laid, loader, loaderMain, copierBuild, stageRow, loaderValues, loaderHeader, GENERATED_LINE);
1244
+ stage = await buildStage(files, laid, packed!, stageRow, loaderValues, loaderHeader, GENERATED_LINE);
1210
1245
  } catch (error) {
1211
1246
  if (!isRefusal(error)) throw error;
1212
1247
  return { output: { ...output, loader: notVerified({ reason: `The show stage of the start screen from ${stageRow.stage} cannot be built. ${error.message}` }) }, removed, failed: true };
@@ -1222,14 +1257,14 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
1222
1257
  writeFileSync(resolveProjectPath(checkPath), program);
1223
1258
  // The unpack runs before the copier, or before the show stage, which then starts the loader.
1224
1259
  const unpackFrames = (cycles: number | undefined) => (cycles === undefined ? LOADER_FRAMES : RUN_LIMIT_FRAMES + Math.ceil(cycles / PAL_FRAME_CYCLES));
1225
- const copierFrames = stage !== undefined || packed === undefined ? RUN_LIMIT_FRAMES : unpackFrames(packed.cycles);
1260
+ const copierFrames = packed === undefined ? RUN_LIMIT_FRAMES : unpackFrames(packed.cycles);
1226
1261
  // The check compares the bytes of the screen of the stage: a routine of the stage can change its other bytes.
1227
1262
  const stageByte = (address: number) => {
1228
1263
  const part = stage!.parts.find((item) => address >= item.start && address < item.start + item.body.length)!;
1229
1264
  return part.body[address - part.start]!;
1230
1265
  };
1231
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)) }));
1232
- 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 } };
1233
1268
  let ran: LoaderRun;
1234
1269
  try {
1235
1270
  ran = await runLoader(checkPath, program, loader, state, { jump, copierSource, fileByte, copierFrames, ...(startScreen === undefined ? {} : { startScreen }), ...stageRun }, expected);
@@ -1240,7 +1275,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
1240
1275
  } finally {
1241
1276
  rmSync(resolveProjectPath(scratch), { recursive: true, force: true });
1242
1277
  }
1243
- 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" }));
1244
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" }));
1245
1280
  output.loader = {
1246
1281
  program: loaderPath,
@@ -1275,15 +1310,21 @@ function exportValue(row: SourceSwitch): 0 | 1 {
1275
1310
 
1276
1311
  const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
1277
1312
 
1278
- /** 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. */
1279
- 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 {
1280
1319
  const first = image.segments[0];
1281
1320
  if (first === undefined) return undefined;
1282
1321
  const tokenized = parseTokenized(Uint8Array.from([first.start & 0xff, first.start >> 8, ...image.memory.subarray(first.start, first.end + 1)]));
1283
1322
  if ("reason" in tokenized) return undefined;
1284
- const sys = findHandoffs(tokenized.lines).find((handoff) => handoff.kind === "sys" && "address" in handoff);
1285
- const address = sys !== undefined && "address" in sys ? sys.address : undefined;
1286
- 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 };
1287
1328
  }
1288
1329
 
1289
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. */
@@ -1322,9 +1363,10 @@ function freeRanges(knowledge: SourceKnowledge, memory: Uint8Array, instructions
1322
1363
  for (const operand of knowledge.operands) {
1323
1364
  const names = operand.symbol !== undefined ? [operand.symbol] : identifiers(operand.expression ?? "");
1324
1365
  const targets = names.flatMap((item) => (addressOf.has(item) ? [(addressOf.get(item)! + (operand.symbol !== undefined ? operand.offset : 0)) & 0xffff] : []));
1325
- if (targets.length > 0) operandTargets.set(operand.address, targets);
1366
+ operandTargets.set(operand.address, targets);
1326
1367
  }
1327
- const entry = image.entry ?? basicEntry(image);
1368
+ const basic = basicStart(image);
1369
+ const entry = image.entry ?? basic?.entry;
1328
1370
  return planDrops({
1329
1371
  segments: image.segments,
1330
1372
  memory,
@@ -1334,6 +1376,8 @@ function freeRanges(knowledge: SourceKnowledge, memory: Uint8Array, instructions
1334
1376
  regions: effectiveRegions(knowledge.regions),
1335
1377
  references: knowledge.references,
1336
1378
  operandTargets,
1379
+ rom: romOf(image, knowledge, [], knowledge.coverage),
1380
+ ...(basic === undefined ? {} : { basic: basic.line }),
1337
1381
  changed: [...ranges.changed],
1338
1382
  keep: [...ranges.keep],
1339
1383
  drop: [...ranges.drop],
@@ -1699,7 +1743,7 @@ await runScript({
1699
1743
  options: {
1700
1744
  out: { ...OPTIONS.out, output: "folder", value: "<dir>", help: "the folder for the source files, relative to the project folder", required: true },
1701
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" },
1702
- 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" },
1703
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" },
1704
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" },
1705
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