@henols/c64-re-tools 2.6.0-rc.2 → 2.6.0-rc.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/skills/c64-assembler/SKILL.md +28 -14
- package/skills/c64-assembler/scripts/assembler.ts +28 -15
- package/skills/c64-development/SKILL.md +4 -4
- package/skills/c64-docs/SKILL.md +9 -7
- package/skills/c64-docs/scripts/docs.ts +24 -11
- package/skills/c64-docs/scripts/lib/reference.ts +119 -33
- package/skills/c64-docs/scripts/lib/source-map.ts +23 -4
- package/skills/c64-knowledge/SKILL.md +67 -42
- package/skills/c64-knowledge/scripts/knowledge.ts +90 -67
- package/skills/c64-knowledge/scripts/lib/listing.ts +18 -3
- package/skills/c64-packer/SKILL.md +1 -1
- package/skills/c64-provenance/SKILL.md +11 -10
- package/skills/c64-provenance/scripts/lib/library.ts +16 -16
- package/skills/c64-provenance/scripts/provenance.ts +33 -23
- package/skills/c64-reverse-engineering/SKILL.md +17 -11
- package/skills/c64-source/SKILL.md +71 -47
- package/skills/c64-source/scripts/lib/export.ts +89 -34
- package/skills/c64-source/scripts/lib/loader.ts +79 -36
- package/skills/c64-source/scripts/lib/source.ts +38 -32
- package/skills/c64-source/scripts/lib/stage.ts +11 -5
- package/skills/c64-source/scripts/lib/start-screen.asm +4 -2
- package/skills/c64-source/scripts/source.ts +278 -145
- package/skills/c64-static-analysis/SKILL.md +29 -25
- package/skills/c64-static-analysis/scripts/lib/coverage.ts +2 -25
- package/skills/c64-static-analysis/scripts/lib/findings.ts +11 -11
- package/skills/c64-static-analysis/scripts/lib/instructions.ts +26 -24
- package/skills/c64-static-analysis/scripts/lib/macros.ts +3 -1
- package/skills/c64-static-analysis/scripts/static-analysis.ts +69 -67
- package/skills/c64-testing/SKILL.md +15 -5
- package/skills/c64-testing/references/recording-format.md +26 -5
- package/skills/c64-testing/references/scenario-format.md +11 -8
- package/skills/c64-testing/scripts/lib/diff-files.ts +4 -18
- package/skills/c64-testing/scripts/lib/play.ts +39 -41
- package/skills/c64-testing/scripts/lib/recording.ts +220 -46
- package/skills/c64-testing/scripts/lib/replay.ts +32 -6
- package/skills/c64-testing/scripts/lib/runs.ts +8 -3
- package/skills/c64-testing/scripts/lib/scenario.ts +18 -11
- package/skills/c64-testing/scripts/testing.ts +23 -2
- package/skills/c64-unpacker/SKILL.md +10 -5
- package/skills/c64-unpacker/scripts/lib/loads.ts +34 -13
- package/skills/c64-unpacker/scripts/lib/machine.ts +7 -3
- package/skills/c64-unpacker/scripts/lib/stages.ts +18 -3
- package/skills/c64-unpacker/scripts/unpacker.ts +43 -9
- package/skills/emulator/SKILL.md +7 -12
- package/src/build-name.ts +55 -0
- package/src/c64-keys.ts +98 -0
- package/src/c64.ts +22 -2
- package/src/cli/main.ts +3 -29
- package/src/host/main.ts +3 -3
- package/src/host/server.ts +3 -1
- package/src/host/tools/index.ts +2 -7
- package/src/host/vice/process.ts +34 -17
- package/src/host/vice/session.ts +138 -31
- package/src/host-client/steps.ts +21 -18
- package/src/host-client/tools.ts +2 -7
- package/src/host-client/vice-session.ts +7 -1
- package/src/knowledge/evidence.ts +66 -0
- package/src/knowledge/history.ts +5 -5
- package/src/knowledge/import.ts +12 -5
- package/src/knowledge/program.ts +123 -32
- package/src/knowledge/read.ts +36 -13
- package/src/knowledge/schema.ts +43 -17
- package/src/knowledge/start-screen.ts +70 -0
- package/src/knowledge/text.ts +33 -5
- package/src/knowledge/write.ts +75 -36
- package/src/mcp/inputs.ts +12 -0
- package/src/mcp/server.ts +1 -1
- package/src/mcp/tools/debug.ts +23 -21
- package/src/mcp/tools/input.ts +38 -5
- package/src/mcp/tools/machine.ts +3 -42
- package/src/mcp/tools/media.ts +1 -1
- package/src/mcp/tools/memory.ts +12 -9
- package/src/native/acme.ts +1 -1
- package/src/native/c64run.ts +7 -4
- package/src/native/decompiler/analyze.ts +98 -0
- package/src/native/decompiler/c64rt-wasm.ts +4 -0
- package/src/native/decompiler/language/c64rt_6510.sla +0 -0
- package/src/native/{ghidra → decompiler}/language/c64rt_6510.slaspec +1 -1
- package/src/native/decompiler/pcode.ts +222 -0
- package/src/native/decompiler/walk.ts +205 -0
- package/src/native/decompiler/wasm.ts +98 -0
- package/src/native/discover.ts +3 -3
- package/src/native/dxa.ts +12 -1
- package/src/native/processes.ts +4 -4
- package/src/native/types.ts +27 -27
- package/src/opcodes.ts +1 -1
- package/src/platform.ts +30 -1
- package/src/project.ts +17 -4
- package/src/protocol/tools.ts +1 -45
- package/src/protocol/vice.ts +47 -0
- package/src/reference-pages.ts +64 -0
- package/src/script.ts +4 -4
- package/src/vsf.ts +98 -0
- package/tools/c64run.c +158 -15
- package/tools/install-container.sh +1 -2
- package/src/cli/status.ts +0 -127
- package/src/host/tools/status.ts +0 -47
- package/src/native/ghidra/analyze.ts +0 -87
- package/src/native/ghidra/index.ts +0 -170
- package/src/native/ghidra/scripts/C64Export.java +0 -274
- package/src/native/ghidra/scripts/C64Prepare.java +0 -66
- package/src/native/status.ts +0 -135
- package/tools/install-ghidra.sh +0 -40
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.cspec +0 -0
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.ldefs +0 -0
- /package/src/native/{ghidra → decompiler}/language/c64rt_6510.pspec +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ACME source from an image, current knowledge and
|
|
1
|
+
// ACME source from an image, current knowledge and the decompiler's instruction
|
|
2
2
|
// boundaries. The same input gives the same text. Names come from
|
|
3
3
|
// knowledge; a target that knowledge does not name gets l_xxxx. A read or
|
|
4
4
|
// write in the I/O area names the register, also where the image holds RAM. Data is
|
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
// each release has it, the default build does not, and the loader never
|
|
15
15
|
// loads it.
|
|
16
16
|
|
|
17
|
+
import { CONFIG_FILE, configValues } from "#src/build-name.ts";
|
|
17
18
|
import { type AddressRange, COVERAGE, formatC64Address, formatC64Byte, POINTER_TABLE_TYPES, pointerTableEntries, type PointerTableType } from "#src/c64.ts";
|
|
18
19
|
import { WireFailure } from "#src/host-client/tools.ts";
|
|
19
20
|
import { identifiers, operandText, replaceIdentifiers, type OperandExpression } from "#src/knowledge/expression.ts";
|
|
20
|
-
import { type CommentPlacement, isAnalyzer, isGeneratedFile, LEFTOVERS_SWITCH, RELEASE_DEFINE, START_SCREEN_SWITCH, type Origin, type RegionType, type SwitchKind } from "#src/knowledge/schema.ts";
|
|
21
|
+
import { type CommentPlacement, isAnalyzer, isGeneratedFile, LEFTOVER_FOLDER, LEFTOVERS_SWITCH, SEGMENT_FOLDER, RELEASE_DEFINE, START_SCREEN_SWITCH, type Origin, type RegionType, type SwitchKind } from "#src/knowledge/schema.ts";
|
|
21
22
|
import type { Area } from "#src/platform.ts";
|
|
22
23
|
import { hasZeroPageForm, instructionWith, labelProblem, MODE_LENGTH, OPCODES, takesAddress, USE_KINDS, useKind, type UseKind } from "#src/opcodes.ts";
|
|
23
24
|
|
|
@@ -29,7 +30,7 @@ export interface SourceInput {
|
|
|
29
30
|
/** The image byte at an address inside a segment. */
|
|
30
31
|
byteAt: (address: number) => number;
|
|
31
32
|
entry?: number;
|
|
32
|
-
/** Where
|
|
33
|
+
/** Where the decompiler decoded an instruction, with its length. */
|
|
33
34
|
instructions: ReadonlyMap<number, number>;
|
|
34
35
|
/** Without an origin, a symbol counts as a user or LLM name. */
|
|
35
36
|
symbols: ReadonlyArray<{ address: number; name: string; origin?: Origin }>;
|
|
@@ -95,7 +96,6 @@ export interface SourceSwitch {
|
|
|
95
96
|
/** A release: the build with RELEASE_<label> gives each switch the value of this release. */
|
|
96
97
|
export interface SourceRelease {
|
|
97
98
|
label: string;
|
|
98
|
-
file: string;
|
|
99
99
|
base: boolean;
|
|
100
100
|
comment?: string;
|
|
101
101
|
}
|
|
@@ -204,7 +204,7 @@ interface DataItem {
|
|
|
204
204
|
kind: "data";
|
|
205
205
|
start: number;
|
|
206
206
|
end: number;
|
|
207
|
-
/** The region type, or unclassified. In a code region, bytes that
|
|
207
|
+
/** The region type, or unclassified. In a code region, bytes that the decompiler did not decode. */
|
|
208
208
|
type: RegionType | "unclassified" | "undecoded";
|
|
209
209
|
region?: Region;
|
|
210
210
|
}
|
|
@@ -280,7 +280,7 @@ function operandValue(address: number, opcode: number, byteAt: (address: number)
|
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
282
|
* Each entry point inside a data region of the knowledge, with that region.
|
|
283
|
-
* A data region wins over an entry:
|
|
283
|
+
* A data region wins over an entry: the decompiler does not decode there,
|
|
284
284
|
* and the source has data there. A code region in the knowledge changes that.
|
|
285
285
|
*/
|
|
286
286
|
export function entriesInData<R extends { start: number; end: number; type: RegionType }>(entries: readonly number[], regions: readonly R[]): Array<{ entry: number; region: R }> {
|
|
@@ -330,23 +330,24 @@ export function layout(input: SourceInput): Layout {
|
|
|
330
330
|
const end = bounds[index + 1]! - 1;
|
|
331
331
|
const segmentTitle = `Segment ${formatC64Address(segment.start)}-${formatC64Address(segment.end)}`;
|
|
332
332
|
if (leftovers.some((range) => range.start === start)) {
|
|
333
|
-
pieces.push({ start, end, file:
|
|
333
|
+
pieces.push({ start, end, file: `${LEFTOVER_FOLDER}/leftover_${hex(start)}.asm`, title: `Leftovers ${formatC64Address(start)}-${formatC64Address(end)}: ${end - start + 1} bytes that nothing uses. Only LEFTOVERS = 1 builds them.`, segmentStart: index === 0, leftover: true, items: [] });
|
|
334
334
|
continue;
|
|
335
335
|
}
|
|
336
|
-
// A module that leftovers cut goes on in a file of its own after them: <module>_xxxx.asm.
|
|
336
|
+
// A module that leftovers cut goes on in a file of its own after them, in its folder: <module>_xxxx.asm.
|
|
337
337
|
const module = modules.find((row) => row.start === start);
|
|
338
338
|
const holder = module ?? modules.filter((row) => row.start >= segment.start && row.start < start).at(-1);
|
|
339
339
|
const title = (text: string | undefined) => text?.replace(/\s*\r?\n\s*/g, " ");
|
|
340
|
-
const file = module?.file ?? (holder === undefined ?
|
|
340
|
+
const file = module?.file ?? (holder === undefined ? `${SEGMENT_FOLDER}/segment_${hex(start)}.asm` : `${holder.file.replace(/\.asm$/i, "")}_${hex(start)}.asm`);
|
|
341
341
|
const named = module === undefined && holder !== undefined ? `${title(holder.title) ?? holder.file}, from ${formatC64Address(start)}` : title(module?.title);
|
|
342
342
|
pieces.push({ start, end, file, title: named ?? segmentTitle, segmentStart: index === 0, leftover: false, items: [] });
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
+
// In any letter case: the file systems of macOS and Windows ignore it.
|
|
345
346
|
const files = new Map<string, number>();
|
|
346
347
|
for (const piece of pieces) {
|
|
347
|
-
const other = files.get(piece.file);
|
|
348
|
+
const other = files.get(piece.file.toLowerCase());
|
|
348
349
|
if (other !== undefined) throw new WireFailure("invalid-input", `The file ${piece.file} is used at ${formatC64Address(other)} and at ${formatC64Address(piece.start)}. Give the module another file.`);
|
|
349
|
-
files.set(piece.file, piece.start);
|
|
350
|
+
files.set(piece.file.toLowerCase(), piece.start);
|
|
350
351
|
}
|
|
351
352
|
|
|
352
353
|
for (const piece of pieces) {
|
|
@@ -527,7 +528,11 @@ export function layout(input: SourceInput): Layout {
|
|
|
527
528
|
expressions.push({ address: operand.address, text: expression, kind: mode === "imm" ? "address" : useKind(item!.opcode) });
|
|
528
529
|
}
|
|
529
530
|
// The names of expressions and macro args come first: a platform name there names the register for the plain operands too.
|
|
530
|
-
|
|
531
|
+
// An expression inside a written use names nothing: the macro line names only its args.
|
|
532
|
+
const useExpression = ({ text, kind }: { text: string; kind: UseKind }) => {
|
|
533
|
+
for (const name of identifiers(text)) useName(name, kind);
|
|
534
|
+
};
|
|
535
|
+
for (const expression of expressions) if (!inUse.has(expression.address)) useExpression(expression);
|
|
531
536
|
for (const candidate of candidates) for (const arg of candidate.use.args) for (const name of identifiers(arg)) useName(name, "macro argument");
|
|
532
537
|
// An instruction with an expression names what the expression names, not its plain target.
|
|
533
538
|
const written = new Set(expressions.map((expression) => expression.address));
|
|
@@ -556,7 +561,9 @@ export function layout(input: SourceInput): Layout {
|
|
|
556
561
|
macrosAsInstructions.push({ start: candidate.use.start, end: candidate.use.end, macro: candidate.use.macro, reason: `The source has a label at ${formatC64Address(inside)}, inside the use.` });
|
|
557
562
|
for (const item of candidate.items) {
|
|
558
563
|
inUse.delete(item.address);
|
|
559
|
-
|
|
564
|
+
const expression = expressions.find((each) => each.address === item.address);
|
|
565
|
+
if (expression !== undefined) useExpression(expression);
|
|
566
|
+
else if (takesAddress(OPCODES[item.opcode]!.mode)) useOperand(item);
|
|
560
567
|
}
|
|
561
568
|
}
|
|
562
569
|
}
|
|
@@ -930,21 +937,7 @@ export const hasSwitchFile = (layout: Pick<Layout, "switches" | "releases" | "le
|
|
|
930
937
|
/** True when the source has config.asm: the knowledge has switches or a start screen, or the source has leftovers. */
|
|
931
938
|
export const hasConfigFile = (layout: Pick<Layout, "switches" | "startScreen" | "leftovers">) => layout.switches.length > 0 || layout.startScreen || layout.leftovers.length > 0;
|
|
932
939
|
|
|
933
|
-
|
|
934
|
-
export const CONFIG_FILE = "config.asm";
|
|
935
|
-
|
|
936
|
-
/** A value line of config.asm: NAME = 0 or NAME = 1. */
|
|
937
|
-
const CONFIG_VALUE = /^\s*([A-Z][A-Z0-9_]*)\s*=\s*([01])\s*(?:;.*)?$/;
|
|
938
|
-
|
|
939
|
-
/** The values of the switches in a config.asm text, by name. Lines that are not a value line are not read. */
|
|
940
|
-
export function configValues(text: string): Map<string, 0 | 1> {
|
|
941
|
-
const values = new Map<string, 0 | 1>();
|
|
942
|
-
for (const line of text.split(/\r?\n/)) {
|
|
943
|
-
const match = CONFIG_VALUE.exec(line);
|
|
944
|
-
if (match !== null) values.set(match[1]!, match[2] === "1" ? 1 : 0);
|
|
945
|
-
}
|
|
946
|
-
return values;
|
|
947
|
-
}
|
|
940
|
+
export { CONFIG_FILE, configValues };
|
|
948
941
|
|
|
949
942
|
/**
|
|
950
943
|
* config.asm: the value of each switch as a plain assignment, grouped by
|
|
@@ -977,14 +970,14 @@ export function configText(layout: Pick<Layout, "switches" | "patches" | "startS
|
|
|
977
970
|
}
|
|
978
971
|
}
|
|
979
972
|
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`);
|
|
973
|
+
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
974
|
}
|
|
982
975
|
if (layout.leftovers.length > 0) {
|
|
983
976
|
const bytes = layout.leftovers.reduce((sum, range) => sum + range.end - range.start + 1, 0);
|
|
984
977
|
out.push(
|
|
985
978
|
"",
|
|
986
979
|
"; Leftovers: off by default",
|
|
987
|
-
`${LEFTOVERS_SWITCH} = ${values.get(LEFTOVERS_SWITCH) ?? 0} ; ${bytes} bytes in ${layout.leftovers.length}
|
|
980
|
+
`${LEFTOVERS_SWITCH} = ${values.get(LEFTOVERS_SWITCH) ?? 0} ; ${bytes} bytes in ${layout.leftovers.length} ${layout.leftovers.length === 1 ? "file" : "files"} in ${LEFTOVER_FOLDER}/ that nothing uses. 1 builds them, so main.asm gives the bytes of the program. Each release has them. The loader never loads them`,
|
|
988
981
|
);
|
|
989
982
|
}
|
|
990
983
|
return `${out.join("\n")}\n`;
|
|
@@ -1002,10 +995,12 @@ function switchesText(layout: Layout): string {
|
|
|
1002
995
|
"; then each switch has the value of that release, and the build does not read config.asm.",
|
|
1003
996
|
];
|
|
1004
997
|
for (const release of layout.releases) {
|
|
1005
|
-
out.push("", `; ${release.label}${release.base ? " (the program of the knowledge)" : ""}
|
|
998
|
+
out.push("", `; ${release.label}${release.base ? " (the program of the knowledge)" : ""}${release.comment === undefined ? "" : `: ${release.comment.replace(/\s*\r?\n\s*/g, " ")}`}`);
|
|
1006
999
|
out.push(`!ifdef ${RELEASE_DEFINE}${release.label} {`);
|
|
1007
1000
|
for (const row of layout.switches) out.push(`${INDENT}${row.name} = ${row.releases.includes(release.label) ? 1 : 0}`);
|
|
1008
1001
|
if (layout.leftovers.length > 0) out.push(`${INDENT}${LEFTOVERS_SWITCH} = 1`);
|
|
1002
|
+
// The start screen is part of the clean build only: the build of a release is the bytes of its file.
|
|
1003
|
+
if (layout.startScreen) out.push(`${INDENT}${START_SCREEN_SWITCH} = 0`);
|
|
1009
1004
|
out.push("}");
|
|
1010
1005
|
}
|
|
1011
1006
|
if (hasConfigFile(layout)) {
|
|
@@ -1107,6 +1102,17 @@ function macrosText(layout: Layout): { text: string; lines: Map<string, { first:
|
|
|
1107
1102
|
return { text: `${out.join("\n")}\n`, lines };
|
|
1108
1103
|
}
|
|
1109
1104
|
|
|
1105
|
+
/** The bytes of patch code from `start` so far: after a byte at $ffff, ACME sets * to $0000. */
|
|
1106
|
+
const patchLength = (start: string) => `((* - ${start}) & $ffff)`;
|
|
1107
|
+
const LENGTH = patchLength(".patch_start");
|
|
1108
|
+
|
|
1109
|
+
/** The source of one patch of a captured stage on its own: the names of the stage, the code, and NOP to the end of its range. */
|
|
1110
|
+
export function stagePatchText(names: ReadonlyArray<{ name: string; address: number }>, patch: { start: number; end: number; code: string }): string {
|
|
1111
|
+
const start = formatC64Address(patch.start);
|
|
1112
|
+
const lines = ["!cpu 6510", ...names.map((symbol) => `${symbol.name} = ${formatC64Address(symbol.address)}`), `* = ${start}`, ...patch.code.split(/\r?\n/)];
|
|
1113
|
+
return `${[...lines, `!fill ${patch.end - patch.start + 1} - ${patchLength(start)}, $ea`].join("\n")}\n`;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1110
1116
|
/** The condition that puts in the code of a switch: the switch has the value that the program does not have. */
|
|
1111
1117
|
const patchCondition = (alternative: PatchAlternative) => (alternative.base === 0 ? alternative.switch : `${alternative.switch} = 0`);
|
|
1112
1118
|
|
|
@@ -1133,7 +1139,7 @@ function patchOpening(patch: PatchBlock): string[] {
|
|
|
1133
1139
|
`${INDENT}; ${alternative.switch} ${state}: ${bytes} byte${bytes === 1 ? "" : "s"} at ${range}, NOP after the code`,
|
|
1134
1140
|
...comment,
|
|
1135
1141
|
...(alternative.code === "" ? [] : alternative.code.split(/\r?\n/)),
|
|
1136
|
-
`${INDENT}!if
|
|
1142
|
+
`${INDENT}!if ${LENGTH} > ${bytes} { !error "The patch ${alternative.switch} at ${formatC64Address(patch.start)} has ", ${LENGTH}, " bytes; the range has ${bytes}." } else { !fill ${bytes} - ${LENGTH}, $ea }`,
|
|
1137
1143
|
);
|
|
1138
1144
|
});
|
|
1139
1145
|
out.push("} else {");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// the loader as it is in memory before it starts (the plain loader file, or
|
|
4
4
|
// the parts of the packed form), the bytes of the stage that the start screen
|
|
5
5
|
// uses at their own addresses, the bytes of the loader that those cover in a
|
|
6
|
-
// stash, and the show code into one loader.
|
|
6
|
+
// stash, and the show code into one loader program. The show code shows the
|
|
7
7
|
// screen with start-screen.asm, calls the routine of the stage, waits for a
|
|
8
8
|
// key or a fire button, stops the interrupts of the stage, sets the CIAs as
|
|
9
9
|
// RUN leaves them, copies the stash back and starts the loader.
|
|
@@ -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`,
|
|
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
|
|
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. */
|
|
@@ -139,7 +143,7 @@ export function stageText(input: StageInput, code: number, stash: StagePlan["sta
|
|
|
139
143
|
const { row } = input;
|
|
140
144
|
const lines = [
|
|
141
145
|
...input.header.map((line) => `; ${line}`),
|
|
142
|
-
`; The show stage of the start screen from ${row.stage}: Exomizer packs it with the loader into loader
|
|
146
|
+
`; The show stage of the start screen from ${row.stage}: Exomizer packs it with the loader into the loader program, with --entry '${formatC64Address(code)}'.`,
|
|
143
147
|
"; It shows the start screen, waits for a key or a fire button, copies back the bytes of the loader that the stage covers, and starts the loader.",
|
|
144
148
|
"",
|
|
145
149
|
"!cpu 6510",
|
|
@@ -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))}`,
|
|
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
|