@henols/c64-re-tools 2.1.8 → 2.2.0-rc.2
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/README.md +29 -41
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +5 -2
- package/skills/c64-assembler/scripts/assembler.ts +24 -12
- package/skills/c64-development/SKILL.md +179 -0
- package/skills/c64-docs/references/page-types.md +1 -1
- package/skills/c64-knowledge/SKILL.md +66 -13
- package/skills/c64-knowledge/scripts/knowledge.ts +165 -18
- package/skills/c64-provenance/SKILL.md +11 -3
- package/skills/c64-reverse-engineering/SKILL.md +30 -13
- package/skills/c64-source/SKILL.md +33 -13
- package/skills/c64-source/scripts/lib/loader.ts +3 -1
- package/skills/c64-source/scripts/lib/source.ts +151 -37
- package/skills/c64-source/scripts/source.ts +135 -45
- package/skills/c64-testing/SKILL.md +5 -3
- package/skills/c64-testing/references/scenario-format.md +34 -2
- package/skills/c64-testing/scripts/lib/runs.ts +122 -12
- package/skills/c64-testing/scripts/testing.ts +1 -1
- package/skills/c64-unpacker/SKILL.md +4 -1
- package/src/cli/main.ts +7 -7
- package/src/knowledge/conflicts.ts +32 -8
- package/src/knowledge/history.ts +18 -0
- package/src/knowledge/read.ts +98 -4
- package/src/knowledge/schema.ts +43 -2
- package/src/knowledge/text.ts +22 -0
- package/src/knowledge/write.ts +248 -25
- package/src/native/c64run.ts +1 -1
- package/src/native/discover.ts +5 -5
- package/src/native/ghidra/index.ts +5 -9
- package/src/native/status.ts +1 -1
- package/tools/install-chips.sh +10 -19
- package/tools/install-dxa.sh +9 -51
- package/tools/install-ghidra.sh +6 -6
|
@@ -14,13 +14,14 @@ import { readProjectFile, writeReported } from "#src/host-client/transfer.ts";
|
|
|
14
14
|
import { CONFLICT_RULES, conflicts, type Conflict } from "#src/knowledge/conflicts.ts";
|
|
15
15
|
import { openForRead, withWrite } from "#src/knowledge/database.ts";
|
|
16
16
|
import { operandText } from "#src/knowledge/expression.ts";
|
|
17
|
-
import { historyAt, historyNamed, historyOfMacro, revision, revisionNote, revisions, type HistoryEntry } from "#src/knowledge/history.ts";
|
|
17
|
+
import { historyAt, historyNamed, historyOfMacro, historyOfSwitch, revision, revisionNote, revisions, type HistoryEntry } from "#src/knowledge/history.ts";
|
|
18
18
|
import { joinBatches, type Batch, type JoinChoice, type JoinClash } from "#src/knowledge/join.ts";
|
|
19
19
|
import { knowledgeNames } from "#src/knowledge/names.ts";
|
|
20
20
|
import { addCoverage, programCoverage, programImage, requireProgram, setImage, type ImageRequest } from "#src/knowledge/program.ts";
|
|
21
21
|
import {
|
|
22
22
|
analyzerNamesAt,
|
|
23
23
|
at,
|
|
24
|
+
baseValue,
|
|
24
25
|
commentsAt,
|
|
25
26
|
coverageRuns,
|
|
26
27
|
currentRevision,
|
|
@@ -33,7 +34,9 @@ import {
|
|
|
33
34
|
listPatches,
|
|
34
35
|
listReferences,
|
|
35
36
|
listRegions,
|
|
37
|
+
listReleases,
|
|
36
38
|
listSpaces,
|
|
39
|
+
listSwitches,
|
|
37
40
|
listSuppressions,
|
|
38
41
|
listSymbols,
|
|
39
42
|
operandAt,
|
|
@@ -49,10 +52,12 @@ import {
|
|
|
49
52
|
type PatchRow,
|
|
50
53
|
type ReferenceRow,
|
|
51
54
|
type RegionRow,
|
|
55
|
+
type ReleaseRow,
|
|
52
56
|
type SuppressionRow,
|
|
57
|
+
type SwitchRow,
|
|
53
58
|
type SymbolRow,
|
|
54
59
|
} from "#src/knowledge/read.ts";
|
|
55
|
-
import { ANALYZERS, COMMENT_PLACEMENTS, DEFAULT_SPACE, EVIDENCE_KINDS, isSemantic, OPERAND_SELECTS, ORIGINS, REFERENCE_KINDS, REGION_TYPES, SEMANTIC_ORIGINS, SYMBOL_KINDS, type Origin, type OperandSelect } from "#src/knowledge/schema.ts";
|
|
60
|
+
import { ANALYZERS, COMMENT_PLACEMENTS, DEFAULT_SPACE, EVIDENCE_KINDS, isSemantic, OPERAND_SELECTS, ORIGINS, REFERENCE_KINDS, REGION_TYPES, RELEASE_DEFINE, SEMANTIC_ORIGINS, SWITCH_KINDS, SYMBOL_KINDS, type Origin, type OperandSelect, type SwitchKind } from "#src/knowledge/schema.ts";
|
|
56
61
|
import {
|
|
57
62
|
addReference,
|
|
58
63
|
applyBatch,
|
|
@@ -65,6 +70,8 @@ import {
|
|
|
65
70
|
removeOperand,
|
|
66
71
|
removePatch,
|
|
67
72
|
removeReference,
|
|
73
|
+
removeRelease,
|
|
74
|
+
removeSwitch,
|
|
68
75
|
removeSymbol,
|
|
69
76
|
renameSymbol,
|
|
70
77
|
revert,
|
|
@@ -74,6 +81,8 @@ import {
|
|
|
74
81
|
setModule,
|
|
75
82
|
setOperand,
|
|
76
83
|
setPatch,
|
|
84
|
+
setRelease,
|
|
85
|
+
setSwitch,
|
|
77
86
|
unclassifyRegion,
|
|
78
87
|
type BatchOperation,
|
|
79
88
|
type BatchStep,
|
|
@@ -129,6 +138,32 @@ const patch = (row: PatchRow) => ({
|
|
|
129
138
|
origin: row.origin,
|
|
130
139
|
revision: row.revision,
|
|
131
140
|
});
|
|
141
|
+
/** A switch with its value in the program (`base`), the defines that put it on or off, and its patches when they are given. */
|
|
142
|
+
const switchRow = (row: SwitchRow, base?: string, patches?: readonly PatchRow[]) => ({
|
|
143
|
+
...spaceOf(row),
|
|
144
|
+
name: row.name,
|
|
145
|
+
kind: row.kind,
|
|
146
|
+
default: row.default,
|
|
147
|
+
base: baseValue(row, base),
|
|
148
|
+
releases: row.releases,
|
|
149
|
+
on: `--define ${row.name}=1`,
|
|
150
|
+
off: `--define ${row.name}=0`,
|
|
151
|
+
...(row.comment === undefined ? {} : { comment: row.comment }),
|
|
152
|
+
...(patches === undefined ? {} : { patches: patches.map((patch) => ({ start: formatC64Address(patch.start), end: formatC64Address(patch.end) })) }),
|
|
153
|
+
origin: row.origin,
|
|
154
|
+
revision: row.revision,
|
|
155
|
+
});
|
|
156
|
+
const release = (row: ReleaseRow) => ({
|
|
157
|
+
...spaceOf(row),
|
|
158
|
+
label: row.label,
|
|
159
|
+
file: row.file,
|
|
160
|
+
sha256: row.sha256,
|
|
161
|
+
base: row.base,
|
|
162
|
+
define: `--define ${RELEASE_DEFINE}${row.label}=1`,
|
|
163
|
+
...(row.comment === undefined ? {} : { comment: row.comment }),
|
|
164
|
+
origin: row.origin,
|
|
165
|
+
revision: row.revision,
|
|
166
|
+
});
|
|
132
167
|
const macro = (row: MacroRow) => ({ ...spaceOf(row), name: row.name, params: row.params, body: row.body, ...(row.comment === undefined ? {} : { comment: row.comment }), origin: row.origin, revision: row.revision });
|
|
133
168
|
const macroUse = (row: MacroUseRow) => ({
|
|
134
169
|
...spaceOf(row),
|
|
@@ -176,6 +211,10 @@ function historyEntry(entry: HistoryEntry) {
|
|
|
176
211
|
? operand(entry.row)
|
|
177
212
|
: entry.entity === "patch"
|
|
178
213
|
? patch(entry.row)
|
|
214
|
+
: entry.entity === "switch"
|
|
215
|
+
? switchRow(entry.row)
|
|
216
|
+
: entry.entity === "release"
|
|
217
|
+
? release(entry.row)
|
|
179
218
|
: entry.entity === "macro"
|
|
180
219
|
? macro(entry.row)
|
|
181
220
|
: entry.entity === "macro-use"
|
|
@@ -348,7 +387,7 @@ const BATCH_FIELDS: Record<BatchOperation["op"], string[]> = {
|
|
|
348
387
|
operand: ["address", "select", "symbol", "offset", "expression"],
|
|
349
388
|
unoperand: ["address"],
|
|
350
389
|
patch: ["start", "end", "switch", "code", "comment"],
|
|
351
|
-
unpatch: ["start"],
|
|
390
|
+
unpatch: ["start", "switch"],
|
|
352
391
|
macro: ["name", "params", "body", "comment"],
|
|
353
392
|
unmacro: ["name"],
|
|
354
393
|
use: ["start", "end", "macro", "args"],
|
|
@@ -524,12 +563,15 @@ const READ_COMMANDS: CommandSpec[] = [
|
|
|
524
563
|
readCommand({ name: "patches", summary: "The code that a switch puts in.", options: { ...FILTER, switch: { kind: "text", value: "<switch>", help: "only the patches of this switch" }, ...LIST } }, (db, call) => ({
|
|
525
564
|
patches: list(call, listPatches(db, rangeOf(call), call.string("switch"), originsOf(call), call.space), patch, RANGE_REST),
|
|
526
565
|
})),
|
|
527
|
-
readCommand({ name: "switches", summary: "Each switch
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
const show = (
|
|
531
|
-
return { switches: list(call,
|
|
566
|
+
readCommand({ name: "switches", summary: "Each switch: its kind, its default, its value in the program (base), the releases that have it on and the ranges of its patches.", options: LIST }, (db, call) => {
|
|
567
|
+
const base = listReleases(db, undefined, call.space).find((row) => row.base)?.label;
|
|
568
|
+
const patches = listPatches(db, undefined, undefined, undefined, call.space);
|
|
569
|
+
const show = (row: SwitchRow) => switchRow(row, base, patches.filter((patch) => patch.switch === row.name));
|
|
570
|
+
return { switches: list(call, listSwitches(db, undefined, call.space), show, MORE) };
|
|
532
571
|
}),
|
|
572
|
+
readCommand({ name: "releases", summary: "The releases of the program, the base release first, each with the define that builds it.", options: LIST }, (db, call) => ({
|
|
573
|
+
releases: list(call, listReleases(db, undefined, call.space), release, MORE),
|
|
574
|
+
})),
|
|
533
575
|
readCommand({ name: "macros", summary: "The macros of the generated source.", options: { origin: OPTIONS.origin, ...LIST } }, (db, call) => ({ macros: list(call, listMacros(db, originsOf(call), call.space), macro, MORE) })),
|
|
534
576
|
readCommand({ name: "uses", summary: "The instructions written as a macro.", options: { ...FILTER, macro: { kind: "text", value: "<name>", help: "only the uses of this macro" }, ...LIST } }, (db, call) => ({
|
|
535
577
|
uses: list(call, listMacroUses(db, rangeOf(call), call.string("macro"), originsOf(call), call.space), macroUse, RANGE_REST),
|
|
@@ -558,14 +600,27 @@ const READ_COMMANDS: CommandSpec[] = [
|
|
|
558
600
|
name: "history",
|
|
559
601
|
summary: "The rows at an address, of a name or of a macro, through all revisions, each with the reason and the evidence of its revision.",
|
|
560
602
|
subjects: [{ ...ADDRESS, optional: true }],
|
|
561
|
-
options: {
|
|
562
|
-
|
|
603
|
+
options: {
|
|
604
|
+
name: { kind: "text", value: "<name>", help: "the history of a name in place of an address" },
|
|
605
|
+
macro: { kind: "text", value: "<name>", help: "the history of a macro in place of an address" },
|
|
606
|
+
switch: { kind: "text", value: "<name>", help: "the history of a switch and its patches in place of an address" },
|
|
607
|
+
...LIST,
|
|
608
|
+
},
|
|
609
|
+
notes: "Give exactly one of <address>, --name, --macro and --switch.",
|
|
563
610
|
},
|
|
564
611
|
(db, call) => {
|
|
565
612
|
const name = call.string("name");
|
|
566
613
|
const macroName = call.string("macro");
|
|
567
|
-
|
|
568
|
-
|
|
614
|
+
const switchName = call.string("switch");
|
|
615
|
+
if ([call.subjects.length > 0, name !== undefined, macroName !== undefined, switchName !== undefined].filter(Boolean).length !== 1) throw new UsageError("history needs exactly one of <address>, --name, --macro and --switch");
|
|
616
|
+
const entries =
|
|
617
|
+
switchName !== undefined
|
|
618
|
+
? historyOfSwitch(db, switchName, call.space)
|
|
619
|
+
: macroName !== undefined
|
|
620
|
+
? historyOfMacro(db, macroName, call.space)
|
|
621
|
+
: name !== undefined
|
|
622
|
+
? historyNamed(db, name, call.space)
|
|
623
|
+
: historyAt(db, call.parseAddress(call.subject(0), "<address>"), call.space);
|
|
569
624
|
return { history: list(call, entries, (entry) => ({ ...historyEntry(entry), ...revisionNote(db, entry.from) }), MORE) };
|
|
570
625
|
},
|
|
571
626
|
),
|
|
@@ -597,6 +652,8 @@ const READ_COMMANDS: CommandSpec[] = [
|
|
|
597
652
|
modules: listModules(db, range, origins, space).map(module),
|
|
598
653
|
operands: listOperands(db, range, origins, space).map(operand),
|
|
599
654
|
patches: listPatches(db, range, undefined, origins, space).map(patch),
|
|
655
|
+
switches: listSwitches(db, origins, space).map((row) => switchRow(row, listReleases(db, undefined, space).find((item) => item.base)?.label)),
|
|
656
|
+
releases: listReleases(db, origins, space).map(release),
|
|
600
657
|
macros: listMacros(db, origins, space).map(macro),
|
|
601
658
|
macroUses: listMacroUses(db, range, undefined, origins, space).map(macroUse),
|
|
602
659
|
};
|
|
@@ -739,15 +796,15 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
739
796
|
writeCommand(
|
|
740
797
|
{
|
|
741
798
|
name: "patch",
|
|
742
|
-
summary: "ACME code
|
|
743
|
-
subjects: [RANGE, { name: "<switch>", help: "the switch
|
|
799
|
+
summary: "ACME code for a range of the program in the state of the switch that the base release does not have. NOP fills the rest of the range.",
|
|
800
|
+
subjects: [RANGE, { name: "<switch>", help: "the name of a switch of the knowledge" }],
|
|
744
801
|
options: {
|
|
745
802
|
code: { kind: "text", value: "<text>", help: "the ACME code" },
|
|
746
803
|
"code-file": { kind: "path", value: "<file>", help: "a project file with the ACME code" },
|
|
747
804
|
nop: { kind: "flag", help: "put only NOP" },
|
|
748
805
|
comment: { kind: "text", value: "<text>", help: "a comment for the patch" },
|
|
749
806
|
},
|
|
750
|
-
notes: "Give exactly one of --code, --code-file and --nop.",
|
|
807
|
+
notes: "Give exactly one of --code, --code-file and --nop. Write the switch first (switch). The program holds the bytes of the base release: when the base release has the switch on, the code is the bytes with the switch off. Another switch can have a patch at the same range, as an alternative.",
|
|
751
808
|
},
|
|
752
809
|
(call) => {
|
|
753
810
|
const context = contextOf(call);
|
|
@@ -758,10 +815,99 @@ const WRITE_COMMANDS: CommandSpec[] = [
|
|
|
758
815
|
return (db) => shown(setPatch(db, { ...context, image: operandImage(db, call.space) }, request), "patch", patch);
|
|
759
816
|
},
|
|
760
817
|
),
|
|
761
|
-
writeCommand(
|
|
818
|
+
writeCommand(
|
|
819
|
+
{
|
|
820
|
+
name: "unpatch",
|
|
821
|
+
summary: "Removes the patch that starts at an address.",
|
|
822
|
+
subjects: [START],
|
|
823
|
+
options: { switch: { kind: "text", value: "<switch>", help: "the switch of the patch, when patches of more than one switch start there" } },
|
|
824
|
+
},
|
|
825
|
+
(call) => {
|
|
826
|
+
const context = contextOf(call);
|
|
827
|
+
const switchName = call.string("switch");
|
|
828
|
+
const request = { space: call.space, start: call.parseAddress(call.subject(0), "<start>"), ...(switchName === undefined ? {} : { switch: switchName }) };
|
|
829
|
+
return (db) => ({ revision: removePatch(db, context, request).revision });
|
|
830
|
+
},
|
|
831
|
+
),
|
|
832
|
+
writeCommand(
|
|
833
|
+
{
|
|
834
|
+
name: "switch",
|
|
835
|
+
summary: "Writes a switch of the patches: what it changes, its default in the build, and the releases that have it on.",
|
|
836
|
+
subjects: [{ name: "<name>", help: "the switch name, for example PROTECTION or FIX_LIVES" }],
|
|
837
|
+
options: {
|
|
838
|
+
kind: { kind: "choice", value: "<kind>", choices: SWITCH_KINDS, help: `one of ${SWITCH_KINDS.join(", ")}`, required: true },
|
|
839
|
+
default: { kind: "choice", value: "<0|1>", choices: ["0", "1"], help: "the value in the default build. protection, trainer, cheat and crack are always 0; fix is 1 unless you give 0; change needs it" },
|
|
840
|
+
releases: { kind: "text", value: "<A,B>", help: "the labels of the releases that have the switch on, a comma list" },
|
|
841
|
+
comment: { kind: "text", value: "<text>", help: "what the switch changes" },
|
|
842
|
+
},
|
|
843
|
+
notes: "Record the base release first (release --base). A write keeps the releases and the comment that it does not give.",
|
|
844
|
+
},
|
|
845
|
+
(call) => {
|
|
846
|
+
const context = contextOf(call);
|
|
847
|
+
const given = call.string("default");
|
|
848
|
+
const releases = call.string("releases");
|
|
849
|
+
const commentText = call.string("comment");
|
|
850
|
+
const request = {
|
|
851
|
+
space: call.space,
|
|
852
|
+
name: call.subject(0),
|
|
853
|
+
kind: call.string("kind") as SwitchKind,
|
|
854
|
+
...(given === undefined ? {} : { default: given === "1" ? (1 as const) : (0 as const) }),
|
|
855
|
+
...(releases === undefined ? {} : { releases: commaList(releases) }),
|
|
856
|
+
...(commentText === undefined ? {} : { comment: commentText }),
|
|
857
|
+
};
|
|
858
|
+
return (db) => {
|
|
859
|
+
const result = setSwitch(db, { ...context, image: operandImage(db, call.space) }, request);
|
|
860
|
+
const base = listReleases(db, undefined, call.space).find((row) => row.base)?.label;
|
|
861
|
+
return shown(result, "switch", (row: SwitchRow) => switchRow(row, base));
|
|
862
|
+
};
|
|
863
|
+
},
|
|
864
|
+
),
|
|
865
|
+
writeCommand({ name: "unswitch", summary: "Removes a switch that has no patch.", subjects: [{ name: "<name>", help: "the switch name" }] }, (call) => {
|
|
762
866
|
const context = contextOf(call);
|
|
763
|
-
const request = { space: call.space,
|
|
764
|
-
return (db) => ({ revision:
|
|
867
|
+
const request = { space: call.space, name: call.subject(0) };
|
|
868
|
+
return (db) => ({ revision: removeSwitch(db, context, request).revision });
|
|
869
|
+
}),
|
|
870
|
+
writeCommand(
|
|
871
|
+
{
|
|
872
|
+
name: "release",
|
|
873
|
+
summary: "Records a release of the program: its PRG or c64-unpacker image.json in the project. The base release is the one whose bytes are the program of the knowledge.",
|
|
874
|
+
subjects: [{ name: "<label>", help: "the release label, for example ORIGINAL or FIRESTAR" }],
|
|
875
|
+
options: {
|
|
876
|
+
file: { kind: "path", value: "<file>", help: "the PRG or image.json of the release, in a folder that git keeps", required: true },
|
|
877
|
+
base: { kind: "flag", help: "this release is the program of the knowledge: its segments and bytes must be the same" },
|
|
878
|
+
comment: { kind: "text", value: "<text>", help: "what the release is, for example the group and the date" },
|
|
879
|
+
},
|
|
880
|
+
notes: "The build of a release defines RELEASE_<label>=1: each switch then has the value of that release. c64-source checks that this build gives the bytes of the file.",
|
|
881
|
+
},
|
|
882
|
+
(call) => {
|
|
883
|
+
const context = contextOf(call);
|
|
884
|
+
const file = knowledgePath(call.string("file")!, "--file");
|
|
885
|
+
const root = projectRoot();
|
|
886
|
+
if (isInside(join(root, PROJECT_DIRECTORY, LOCAL_DIRECTORY), resolveProjectPath(file, root))) {
|
|
887
|
+
throw new UsageError(`--file ${file} is in ${PROJECT_DIRECTORY}/${LOCAL_DIRECTORY}/, which git ignores: move the release to a folder that git keeps, for example original/`);
|
|
888
|
+
}
|
|
889
|
+
const image = readImage(file);
|
|
890
|
+
const sha256 = createHash("sha256").update(readProjectFile(file).bytes).digest("hex");
|
|
891
|
+
const commentText = call.string("comment");
|
|
892
|
+
const base = call.flag("base");
|
|
893
|
+
const request = { space: call.space, label: call.subject(0), file, sha256, ...(base ? { base } : {}), ...(commentText === undefined ? {} : { comment: commentText }) };
|
|
894
|
+
return (db) => {
|
|
895
|
+
if (base) {
|
|
896
|
+
const program = requireProgram(db, call.space);
|
|
897
|
+
const same = JSON.stringify(program.segments) === JSON.stringify(image.segments) && program.segments.every((segment) => {
|
|
898
|
+
for (let address = segment.start; address <= segment.end; address++) if (program.byteAt(address) !== image.byteAt(address)) return false;
|
|
899
|
+
return true;
|
|
900
|
+
});
|
|
901
|
+
if (!same) throw new Refusal("invalid-input", `The bytes of ${file} are not the program of the knowledge. The base release is the file that knowledge.ts image put in.`);
|
|
902
|
+
}
|
|
903
|
+
return shown(setRelease(db, context, request), "release", release);
|
|
904
|
+
};
|
|
905
|
+
},
|
|
906
|
+
),
|
|
907
|
+
writeCommand({ name: "unrelease", summary: "Removes a release that no switch names.", subjects: [{ name: "<label>", help: "the release label" }] }, (call) => {
|
|
908
|
+
const context = contextOf(call);
|
|
909
|
+
const request = { space: call.space, label: call.subject(0) };
|
|
910
|
+
return (db) => ({ revision: removeRelease(db, context, request).revision });
|
|
765
911
|
}),
|
|
766
912
|
writeCommand(
|
|
767
913
|
{
|
|
@@ -1012,6 +1158,7 @@ function batchFields(fields: Record<string, unknown>, at: string, address: (text
|
|
|
1012
1158
|
case "use":
|
|
1013
1159
|
return { op, start: place("start"), end: place("end"), macro: text("macro"), args: list("args") };
|
|
1014
1160
|
case "unpatch":
|
|
1161
|
+
return { op, start: place("start"), ...optional("switch") };
|
|
1015
1162
|
case "unuse":
|
|
1016
1163
|
return { op, start: place("start") };
|
|
1017
1164
|
case "reference":
|
|
@@ -88,7 +88,15 @@ With `--frames`, a PRG starts with autostart and RUN. An image starts from its b
|
|
|
88
88
|
- Disassemble the bytes of each release with the c64-emulator skill, or analyze them with the c64-static-analysis skill.
|
|
89
89
|
- Find what the change does, for example a trainer, a removed copy protection, or a changed text.
|
|
90
90
|
6. Decide which bytes are probably the original application. Use more than the byte comparison: the code, the text, and the history of the releases.
|
|
91
|
-
7. Record the
|
|
91
|
+
7. Record each release with `release` of the c64-knowledge skill. The base release is the program of the knowledge.
|
|
92
|
+
8. Record each difference as a switch and a patch with the c64-knowledge skill. Select the kind of the switch:
|
|
93
|
+
- `protection`: a copy protection, or the code that a crack changed to remove it.
|
|
94
|
+
- `trainer` or `cheat`: a trainer or a cheat.
|
|
95
|
+
- `crack`: another change of a cracker in the program, for example a credit text.
|
|
96
|
+
- `fix`: a correction of a bug. Make one switch for each correction, not one switch for each release.
|
|
97
|
+
- `change`: another difference.
|
|
98
|
+
9. Give the switch the labels of the releases that have it on. The patch holds the bytes of the state that the base release does not have.
|
|
99
|
+
10. Record each other conclusion as a comment or a region with the c64-knowledge skill.
|
|
92
100
|
|
|
93
101
|
## One release
|
|
94
102
|
|
|
@@ -136,7 +144,7 @@ Do these steps:
|
|
|
136
144
|
4. Run `leftovers`. When you have two or more releases, also compare them.
|
|
137
145
|
5. Read `text` first: names, dates, greetings and credits. Then read `copies`, `residue`, `basic` and `deadCode`.
|
|
138
146
|
6. Examine each important finding with the c64-emulator skill or the c64-static-analysis skill.
|
|
139
|
-
7. Record each confirmed finding with the c64-knowledge skill. Classify a confirmed PETSCII text as a `petscii` region, and a screen code text as a `screen` region. Classify other text as `bytes`. Write a comment that tells what the leftover is.
|
|
147
|
+
7. Record each confirmed finding with the c64-knowledge skill. Do not remove a leftover from the program: a rebuild keeps it. Only the data of a cracktro goes out, with `capture --exclude` of the c64-unpacker skill. Classify a confirmed PETSCII text as a `petscii` region, and a screen code text as a `screen` region. Classify other text as `bytes`. Write a comment that tells what the leftover is.
|
|
140
148
|
|
|
141
149
|
Read the findings with care:
|
|
142
150
|
|
|
@@ -187,7 +195,7 @@ To find the routines in a program:
|
|
|
187
195
|
Automatic write:
|
|
188
196
|
- none.
|
|
189
197
|
|
|
190
|
-
Record a confirmed conclusion as a normal comment, region or
|
|
198
|
+
Record a confirmed conclusion as a normal comment, region, symbol, release, switch or patch with the c64-knowledge skill. Do not record the full comparison or the full list of leftovers.
|
|
191
199
|
|
|
192
200
|
`match --out` writes a batch file and does not change the knowledge. Apply the batch with the c64-knowledge skill.
|
|
193
201
|
|
|
@@ -42,6 +42,18 @@ One repository can hold several programs, with one project folder for each progr
|
|
|
42
42
|
- Do not write a script that makes a deliverable again, for example a capture, copy or replay script. Commit the deliverable.
|
|
43
43
|
- Write the knowledge only with the c64-knowledge script. Do not write or edit the files in `.c64-re-tools/knowledge/` yourself.
|
|
44
44
|
|
|
45
|
+
## What a rebuild keeps
|
|
46
|
+
|
|
47
|
+
These rules apply to each rebuild:
|
|
48
|
+
|
|
49
|
+
- Do not keep a cracktro. The capture of the c64-unpacker skill starts at the last stage, so the code of a cracktro is not in the program. Cut the data of a cracktro that the program does not read with `capture --exclude`.
|
|
50
|
+
- Keep all other bytes: unused bytes, dead code, old copies, texts and leftovers of the development. Record each one as a region with a comment. Do not remove them.
|
|
51
|
+
- Keep a copy protection in the source, off by default. Record a `protection` switch and its patches.
|
|
52
|
+
- Keep a trainer and a cheat in the source, off by default. Record a `trainer` or `cheat` switch and its patches.
|
|
53
|
+
- When two or more releases have different corrections, record each release and one `fix` switch for each correction. The switch names the releases that have the correction. The default build has all corrections.
|
|
54
|
+
- Record all switches with the c64-knowledge skill. Do not write a switch in a source file.
|
|
55
|
+
- When a crack removed a copy protection and no release has its bytes, write this in a comment and in the answer.
|
|
56
|
+
|
|
45
57
|
## Workflow
|
|
46
58
|
|
|
47
59
|
Select the path for the scope:
|
|
@@ -63,7 +75,7 @@ Select the path for the scope:
|
|
|
63
75
|
| What the program does at run time: values, input, timing, screen | c64-emulator |
|
|
64
76
|
| The routines, code, data and references of the program | c64-static-analysis |
|
|
65
77
|
| The platform meaning of an address or a register | c64-memory-map |
|
|
66
|
-
| Differences between releases of the program | c64-provenance `compare` |
|
|
78
|
+
| Differences between releases of the program | c64-provenance `compare`, then c64-knowledge `release`, `switch` and `patch` |
|
|
67
79
|
| Leftovers of the development, a crack or a recrack: texts, old copies, unused bytes, dead code | c64-provenance `leftovers` |
|
|
68
80
|
| A routine that another program of the workspace has, for example a music driver | c64-provenance, with the library |
|
|
69
81
|
| Source code from the knowledge | c64-source |
|
|
@@ -76,29 +88,31 @@ Select the path for the scope:
|
|
|
76
88
|
|
|
77
89
|
### The stages of a full rebuild
|
|
78
90
|
|
|
79
|
-
Do the stages in this sequence. Go to the next stage only when its exit check is true, or when the user accepts an exception. Remember each exception for the answer of stage
|
|
91
|
+
Do the stages in this sequence. Go to the next stage only when its exit check is true, or when the user accepts an exception. Remember each exception for the answer of stage 12.
|
|
80
92
|
|
|
81
93
|
| Stage | Work | Exit check |
|
|
82
94
|
|---|---|---|
|
|
83
95
|
| 1. Acceptance | Ask the user for the criteria of the rebuild. Offer these: identical source, a verified loader, passed c64-testing scenarios, passed replays of the recordings, and a list of the code that no run executed. Also offer documentation of the flows, tables, formats and graphics. | The user gave the criteria. |
|
|
84
96
|
| 2. Get | c64-disk: list the disk. Extract the start file into `original/`. | The start file is in the project. |
|
|
85
97
|
| 3. Start | c64-basic: find the SYS address of the BASIC start. | You have the entry address. |
|
|
86
|
-
| 4. Unpack | c64-unpacker: examine the program with `unpacker.ts inspect`, `trace` and `stages`. Capture a packed program with `unpacker.ts capture` into `.c64-re-tools/local/`. Then c64-knowledge: put the capture, or the PRG of a program without a packer, into the knowledge with `knowledge.ts image`. | `program` of c64-knowledge shows the segments and the entry. |
|
|
98
|
+
| 4. Unpack | c64-unpacker: examine the program with `unpacker.ts inspect`, `trace` and `stages`. Capture a packed program with `unpacker.ts capture` into `.c64-re-tools/local/`. When a segment is the data of a cracktro and the program does not read it, capture again with `--exclude` for that range. Then c64-knowledge: put the capture, or the PRG of a program without a packer, into the knowledge with `knowledge.ts image`. | `program` of c64-knowledge shows the segments and the entry. |
|
|
87
99
|
| 5. Run | First record: ask the user to play each part that the scope names, with `testing.ts record --play` of c64-testing. Tell the user which parts. Record a part yourself only when the sessions of the user do not have it. Put the recordings in `tests/recordings/`. Then use c64-emulator and `testing.ts run` of c64-testing for the parts that a recording cannot have. Write a coverage map for each part into `.c64-re-tools/local/`. Then c64-knowledge: add the maps and the `coverage.bin` of each recording with `knowledge.ts coverage`. | `program` of c64-knowledge lists a coverage map for each part that the scope names. |
|
|
88
100
|
| 6. Analyze | c64-static-analysis: `static-analysis.ts analyze`. It reads the program and the coverage from the knowledge. | No coverage conflict is open. |
|
|
89
101
|
| 7. Name | c64-provenance: if the workspace has a library, find its routines with `provenance.ts match` and apply the batch. Then c64-knowledge and c64-memory-map: name each routine in the scope and give it a comment. Record the modules. When the scope has hundreds of routines, ask the user which routines to name. The source gives the other routines an `l_xxxx` label. | Each routine that the user selected has a name and a comment. |
|
|
90
|
-
| 8.
|
|
91
|
-
| 9.
|
|
92
|
-
| 10.
|
|
93
|
-
| 11.
|
|
102
|
+
| 8. Releases and switches | c64-knowledge: record the base release with `knowledge.ts release <label> --file original/<file> --base`. For a capture, copy its folder to `original/<label>/` first, because git ignores `.c64-re-tools/local/`. Record each other release. c64-provenance: compare the releases with `provenance.ts compare`, and find leftovers with `provenance.ts leftovers`. c64-knowledge: record a switch for each copy protection, trainer, cheat, crack change and correction, and a patch for each of its ranges. Record each leftover as a region with a comment. | `knowledge.ts switches` lists each switch. Each difference between the releases is in a patch, or the answer gives it as an exception. |
|
|
103
|
+
| 9. Generate | c64-source: `source.ts generate --out src`. For an unpacked program, add `--loader`. | `check.identical` is true. `default.result` is `fits`. Each item of `releases` is `identical`, or `layout differs` as an exception. For an unpacked program, `loader.verified` is true. |
|
|
104
|
+
| 10. Build and test | c64-assembler: `assembler.ts build` with `--release <base label> --compare` into `build/`, and the default build without options. c64-testing: `testing.ts test` with the scenarios in `tests/`. Replay each recording on the rebuild with `testing.ts replay`: give the checkpoint routine, the state and the random state (`--pin`) with the names of stage 7. | The criteria of stage 1 are true. |
|
|
105
|
+
| 11. Document | When the criteria ask for documentation: c64-docs into `README.md` and `docs/`, with `docs.ts generate` and `docs.ts link`. | `docs.ts link --check` of c64-docs gives `result: "PASS"`. |
|
|
106
|
+
| 12. Hand over | Find each file that you made outside `.c64-re-tools/local/` and that is not a deliverable. Move it into `.c64-re-tools/local/`. Then give the answer (below). | Each file that you made outside `.c64-re-tools/local/` is a deliverable. |
|
|
94
107
|
|
|
95
|
-
In stage 5, make the recordings before you change the program. A recording needs no names, and its coverage gives the analysis of stage 6 more code. If you cannot get to a part of the program, ask the user how to get to it. Do stages 7
|
|
108
|
+
In stage 5, make the recordings before you change the program. A recording needs no names, and its coverage gives the analysis of stage 6 more code. If you cannot get to a part of the program, ask the user how to get to it. Do stages 7 to 9 again until the source is clear. Each run of c64-source writes the source again.
|
|
96
109
|
|
|
97
110
|
After stage 7, save each routine that other programs can have to the library with `provenance.ts routine` of c64-provenance. Examples are a music driver, a decruncher and a loader. Ask the user before you make a library.
|
|
98
111
|
|
|
99
112
|
### Deliverables of a full rebuild
|
|
100
113
|
|
|
101
|
-
- `.c64-re-tools/knowledge/` with the program, its entry state, the coverage, the names, the regions, the comments and the
|
|
114
|
+
- `.c64-re-tools/knowledge/` with the program, its entry state, the coverage, the names, the regions, the comments, the modules, the releases, the switches and the patches
|
|
115
|
+
- the file of each release in `original/`
|
|
102
116
|
- the generated source
|
|
103
117
|
- the built program and the loader
|
|
104
118
|
- the c64-testing scenarios
|
|
@@ -107,7 +121,7 @@ After stage 7, save each routine that other programs can have to the library wit
|
|
|
107
121
|
- the runs in `runs/` that the knowledge gives as evidence
|
|
108
122
|
- the scripts in `tools/` for the formats of this program, when you wrote them.
|
|
109
123
|
|
|
110
|
-
All other files that you made are not deliverables. Keep them in `.c64-re-tools/local/`. Do not
|
|
124
|
+
All other files that you made are not deliverables. Keep them in `.c64-re-tools/local/`. Do not remove a file that the user made.
|
|
111
125
|
|
|
112
126
|
### The answer
|
|
113
127
|
|
|
@@ -115,7 +129,8 @@ Give the user a short answer at the end. Do not write a report file. Write a rep
|
|
|
115
129
|
|
|
116
130
|
1. Each criterion of stage 1 and its result, and each exception that the user accepted.
|
|
117
131
|
2. The count of the code ranges that no run executed. The ranges are in the `not_executed.json` file of c64-source.
|
|
118
|
-
3.
|
|
132
|
+
3. The switches: the name, the kind and the default of each, and the releases that have it on. Also a copy protection that a crack removed and that no release has.
|
|
133
|
+
4. Open questions: what the evidence does not explain.
|
|
119
134
|
|
|
120
135
|
Keep observed facts apart from your conclusions.
|
|
121
136
|
|
|
@@ -156,12 +171,12 @@ Record durable conclusions with the c64-knowledge skill. Do not store:
|
|
|
156
171
|
|
|
157
172
|
## Result
|
|
158
173
|
|
|
159
|
-
A clear answer for the scope, with the durable conclusions in the project knowledge. For a full rebuild, the deliverables and the answer of stage
|
|
174
|
+
A clear answer for the scope, with the durable conclusions in the project knowledge. For a full rebuild, the deliverables and the answer of stage 12, with the criteria of the user met or each exception in the answer.
|
|
160
175
|
|
|
161
176
|
## Failure and conflicts
|
|
162
177
|
|
|
163
178
|
- A skill reports `installation-incomplete`, or `machine-unavailable` with a message that the host runtime does not run: stop the whole task. Give the message to the user and wait for the user. Do not continue with other skills. Do not make a replacement for the tool or the host runtime, for example your own disk parser, disassembler or emulator script.
|
|
164
|
-
- A tool gives a wrong result, and the exit check of a stage cannot be true. Tell the user the defect and the evidence, and wait for the user. Do not make a workaround, for example a change to a generated file. When the user accepts an exception, give the defect and the exception in the answer of stage
|
|
179
|
+
- A tool gives a wrong result, and the exit check of a stage cannot be true. Tell the user the defect and the evidence, and wait for the user. Do not make a workaround, for example a change to a generated file. When the user accepts an exception, give the defect and the exception in the answer of stage 12.
|
|
165
180
|
- If the evidence does not support a conclusion, keep the unknown and get more evidence. Do not make up a meaning.
|
|
166
181
|
- Before you replace current knowledge from the user or the LLM, read its history and the evidence for it.
|
|
167
182
|
- A conflict from the static analysis: find the correct answer at run time with the c64-emulator skill.
|
|
@@ -170,3 +185,5 @@ A clear answer for the scope, with the durable conclusions in the project knowle
|
|
|
170
185
|
## Handoffs
|
|
171
186
|
|
|
172
187
|
All specialist skills in the table above.
|
|
188
|
+
|
|
189
|
+
A new feature or a fix for the rebuilt program → c64-development
|
|
@@ -66,11 +66,11 @@ When the knowledge has coverage, code that no run executed gets the line `; not
|
|
|
66
66
|
|
|
67
67
|
1. Put the program into the knowledge with `image` of the c64-knowledge skill. For a packed program, capture it first with the c64-unpacker skill. For a program without a packer, use the PRG.
|
|
68
68
|
2. Run the script.
|
|
69
|
-
3. Read `result` and `check`. `check.identical: true` tells that the
|
|
69
|
+
3. Read `result` and `check`. `check.identical: true` tells that the build of the base release assembles to the program byte by byte. Without switches, this build is the default build.
|
|
70
70
|
4. Read the source. A label `l_xxxx` is an address that has no name in the knowledge.
|
|
71
71
|
5. Record names, comments, regions and modules with the c64-knowledge skill. Use `apply` for many changes.
|
|
72
72
|
6. Run the script again. Do steps 4 to 6 again until the source is clear.
|
|
73
|
-
7. Build the program with the c64-assembler skill: `assembler.ts build src main.asm --out <file.prg>`.
|
|
73
|
+
7. Build the program with the c64-assembler skill: `assembler.ts build src main.asm --out <file.prg>`. This is the default build. For a release, add `--release <label>`.
|
|
74
74
|
8. For an unpacked program, run the script with `--loader` at the end. Test `loader.prg` against the original with the c64-testing skill.
|
|
75
75
|
|
|
76
76
|
## The source
|
|
@@ -78,7 +78,7 @@ When the knowledge has coverage, code that no run executed gets the line `; not
|
|
|
78
78
|
- `main.asm` sets the address of each segment and includes the files in address order.
|
|
79
79
|
- Each module in the knowledge is one file. A module starts at its address and stops at the next module or at the end of its segment. Without modules, each segment is one file, `segment_xxxx.asm`.
|
|
80
80
|
- `constants.asm` holds the names of addresses outside the program, for example `EXTCOL = $d020`. The file puts the names in groups by memory area, for example zero page, VIC-II registers or CIA 1 registers. Each group is in address order. Drive code and banks have one group only. The side comment of a name tells what the address is. This text is the knowledge comment of the address. Without a comment, the text is the platform meaning. When the knowledge name is not the platform name, the platform name comes first. For an I/O mirror without a meaning, the text gives the register that the mirror repeats. Then `Used:` counts how the source uses the name. The kinds are `read`, `written`, `modified`, `called`, `jumped to`, `jumped through`, `branched to`, `pointer`, `address`, `table` and `macro argument`. `address` is an immediate operand expression. `table` is an entry in a table of addresses.
|
|
81
|
-
-
|
|
81
|
+
- `switches.asm` holds every switch and every release of the knowledge. `main.asm` and `loader.asm` include it first. The script writes it only when the knowledge has switches or releases. For each release, a block `!ifdef RELEASE_<label>` gives each switch the value of that release. Then each switch gets its default, for example `!ifndef PROTECTION { PROTECTION = 0 }`. The switches are in groups by kind. The side comment gives the releases that have the switch on, the ranges of its patches and the comment of the switch.
|
|
82
82
|
- A label or a constant gets the name of the address in the knowledge. Without a knowledge name, it gets the platform name of the c64-memory-map skill, for example `EXTCOL` or `CHROUT`. A platform name wins over a name from an analyzer (`dxa`, `ghidra` or `heuristic`), for example `EXTCOL` over `ld020`. A `user` or `llm` name wins over a platform name. An address in the program without a name gets `l_xxxx`.
|
|
83
83
|
- The source uses the names of a ROM only when the program uses that ROM. When the knowledge has coverage, a ROM is in use when a run executed code of it. A read of ROM bytes as data does not count. Without coverage, `$01` of the entry state tells which ROMs are in. When the program uses neither ROM, the zero page and pages 2 and 3 get no system names. `romNamesLeftOut` gives the ROMs that the source did not name, and the evidence. An operand expression or a macro use with such a name gets that reason.
|
|
84
84
|
- `sta $d011 ; $d011: yScroll 3, rows 25, displayEnabled` is a store of an immediate to a register that the c64-memory-map skill decodes. The side comment gives the decoded value. A side comment in the knowledge replaces it.
|
|
@@ -94,18 +94,25 @@ When the knowledge has coverage, code that no run executed gets the line `; not
|
|
|
94
94
|
- `not decoded` marks bytes in a code region that Ghidra did not decode.
|
|
95
95
|
- `; not executed $xxxx-$yyyy` starts code that no run of the coverage executed. The range is the same as in `not_executed.json`.
|
|
96
96
|
- `+inc16 ptr` is a use of a macro of the knowledge. `macros.asm` holds the macros. `main.asm` and `loader.asm` include it. The comments inside a use go to its side comment.
|
|
97
|
-
- `!zone
|
|
97
|
+
- `!zone patch_PROTECTION_100e` starts a patch of the knowledge. The condition is the state that the program does not have. It is `!if TRAINER` when the base release has the switch off. It is `!if PROTECTION = 0` when the base release has it on. The block has the code of the patch and NOP to the end of the range. `else` has the original code. The labels inside the range come before the zone as `name = * + n`. Thus all builds have them.
|
|
98
|
+
- Alternatives are patches of two or more switches at one range. They follow as `} else { !if FIX_B {`. A line before them stops the build with `!error` when two of them are in.
|
|
98
99
|
|
|
99
100
|
Do not edit the generated files. The next run writes over them.
|
|
100
101
|
|
|
101
102
|
## Switches and macros
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
The program of the knowledge is the base release. The default build is the clean program: no copy protection, no trainer, no cheat and no crack change, and all corrections. Thus the default build can differ from the program. The script does these checks:
|
|
104
105
|
|
|
105
|
-
1.
|
|
106
|
-
2.
|
|
107
|
-
3.
|
|
108
|
-
4.
|
|
106
|
+
1. `check`: the build of the base release, with each switch at its base value, must give the program byte by byte.
|
|
107
|
+
2. `switches`: the script builds each switch alone at the other value. It does not build two switches together. The build must have the same length as the build of the base release. It can change bytes only in the ranges of the patches of the switch.
|
|
108
|
+
3. `default`: the default build must have the same length. It can change bytes only in the patches of the switches in `default.in`. These are the switches whose default is not their base value.
|
|
109
|
+
4. `releases`: the script builds each release with `RELEASE_<label>=1` and compares it with the file of the release.
|
|
110
|
+
|
|
111
|
+
Build the program with the c64-assembler skill:
|
|
112
|
+
|
|
113
|
+
- The default build: no option.
|
|
114
|
+
- A release: `--release ORIGINAL`.
|
|
115
|
+
- One switch: `--define TRAINER=1`.
|
|
109
116
|
|
|
110
117
|
The script writes a patch only when its range is complete items of one file. A patch cannot cut an instruction. Its switch name cannot be a name of the source.
|
|
111
118
|
|
|
@@ -128,6 +135,8 @@ The flags go through the free stack byte below the stack pointer (`stackByte`).
|
|
|
128
135
|
|
|
129
136
|
The script simulates the copies first. Then it runs `loader.prg` in the emulator to its jump to the entry. It compares the memory, $00/$01, the registers, the screen registers of the VIC-II, the VIC bank and the raster line with the entry state there. It also compares the CIA timers, latches and interrupt masks. `loader.verified: true` tells that all of them are equal. An interrupt can run right at the entry, as in the original program.
|
|
130
137
|
|
|
138
|
+
The entry state is the state of the base release. Thus the script builds and checks `loader.prg` with the switch values of the base release. For a loader of the default build, build `loader.asm` with the c64-assembler skill and no option.
|
|
139
|
+
|
|
131
140
|
## Knowledge
|
|
132
141
|
|
|
133
142
|
Read:
|
|
@@ -157,11 +166,19 @@ Do not store:
|
|
|
157
166
|
- `macroUses`: the count of macro uses that the source has.
|
|
158
167
|
- `macrosAsInstructions`: the macro uses that the source has as instructions, each with its `start`, `end`, `macro` and `reason`.
|
|
159
168
|
- `patchesNotWritten`: the patches that the source does not have, each with its range, `switch` and `reason`.
|
|
160
|
-
- `check`: `identical`, and the result for each segment. A different segment gives its first different address.
|
|
161
|
-
- `switches`: the build of each switch. Each item has the `define` for the c64-assembler skill
|
|
169
|
+
- `check`: `identical`, and the result for each segment of the build of the base release. A different segment gives its first different address.
|
|
170
|
+
- `switches`: the build of each switch that has patches. Each item has `kind`, `default`, `base`, the `define` for the c64-assembler skill and the patches. `result` is the result of the build with the switch at the value that is not `base`. `fits` tells that the build is good, and `changedBytes` counts the changed bytes. `overflow` tells that the code of a patch is longer than its range. `changes outside` gives the first byte outside the ranges that changed. `does not assemble` gives the diagnostics of ACME. `insideNames` lists the labels inside a patch. Code that writes to one of these labels changes the patch when the switch is on.
|
|
171
|
+
- `default`: the default build. `in` lists the switches whose patches are in. `result` and `changedBytes` are as in `switches`.
|
|
172
|
+
- `releases`: the build of each release. Each item has `label`, `base`, `file`, the `define` and the `result`. `identical` tells that the build gives the bytes of the file. `different` gives the segments that differ. `layout differs` tells that the release has other segments than the program: patches cannot move code, so this result does not fail the run. `file changed` tells that the file is not the file that the knowledge recorded. `does not assemble` gives the diagnostics of ACME.
|
|
162
173
|
- `loader`: the program, the copies in their order, the copier page, `stackByte`, `verified` and `differences`. `limits` lists the CIA values that the loader cannot set. An entry state from an old capture has no CIA values. Then `limits` tells you to capture the program again. When the script cannot make the loader, `loader` has `verified: false` and a `reason`. The loader includes the source. Thus a source that does not assemble to the program also stops the loader.
|
|
163
174
|
|
|
164
|
-
`result` is `PASS` when the source is identical and the emulator check of the loader passes. `result` is `FAIL` for a failed check and for an entry in no segment.
|
|
175
|
+
`result` is `PASS` when the source is identical and the emulator check of the loader passes. `result` is `FAIL` for a failed check and for an entry in no segment. These also give `FAIL`:
|
|
176
|
+
|
|
177
|
+
- a patch that the source does not have
|
|
178
|
+
- a switch or a default build that does not fit
|
|
179
|
+
- a release that the build does not give. A release with `layout differs` does not give `FAIL`, but the base release must be `identical`.
|
|
180
|
+
|
|
181
|
+
`asBytes`, `notExecuted`, `operandsAsNumbers`, `macrosAsInstructions` and `patchesNotWritten` are lists of at most `--max-listed` items.
|
|
165
182
|
|
|
166
183
|
## Failure and conflicts
|
|
167
184
|
|
|
@@ -171,7 +188,10 @@ Do not store:
|
|
|
171
188
|
- `invalid-input` that names a symbol or a module: change that symbol or module in the knowledge.
|
|
172
189
|
- `switches` with `overflow`: make the code of the patch shorter, or make the range of the patch larger, with `patch` of the c64-knowledge skill.
|
|
173
190
|
- `switches` with `does not assemble`: read the diagnostics and correct the code of the patch.
|
|
174
|
-
- `patchesNotWritten`: read each `reason`. Move the start or the end of the patch to an instruction, or give the switch another name.
|
|
191
|
+
- `patchesNotWritten`: read each `reason`. Move the start or the end of the patch to an instruction, or give the switch another name. For a switch that is not in the knowledge, write it with `switch` of the c64-knowledge skill.
|
|
192
|
+
- `default` with `overflow` and the message `turn on one of them`: two alternatives are in the default build. Give one of the switches the default of the base release.
|
|
193
|
+
- `releases` with `different`: the release has bytes that no patch gives. Compare the releases with the c64-provenance skill. Then record a switch and a patch for each difference.
|
|
194
|
+
- `releases` with `file changed`: put back the file, or record the release again with `release` of the c64-knowledge skill.
|
|
175
195
|
- `macrosAsInstructions`: read each `reason`. Correct the macro or the args, or remove the use with `unuse`. The source stays identical, so this is not a failure.
|
|
176
196
|
- `entryOutside`: the run fails, but the script still writes and checks the source. With `--loader`, `loader.verified` is `false` with the same `reason`. Capture the program again with c64-unpacker `loads` or `capture`. Make sure that a segment holds the entry. Then put it into the knowledge again with `image`.
|
|
177
197
|
- `dataOnly`: this is not a failure. If the space has code, give `--entry` or classify the code with the c64-knowledge skill. Then generate again.
|
|
@@ -368,6 +368,8 @@ export interface LoaderInput {
|
|
|
368
368
|
/** The label of the entry in the source: the loader jumps to it, so the jump follows the code when it moves. */
|
|
369
369
|
entryName?: string;
|
|
370
370
|
header: string[];
|
|
371
|
+
/** The source has switches.asm: the loader includes it before the constants. */
|
|
372
|
+
switches?: boolean;
|
|
371
373
|
/** The source has macros.asm: the loader includes it after the constants. */
|
|
372
374
|
macros?: boolean;
|
|
373
375
|
}
|
|
@@ -432,7 +434,7 @@ export function planLoader(input: LoaderInput): LoaderPlan {
|
|
|
432
434
|
const copyBlocks = order.map((index) => blockOf[index]!);
|
|
433
435
|
|
|
434
436
|
const stackByte = 0x0100 + state.sp;
|
|
435
|
-
const lines: string[] = [...input.header.map((line) => `; ${line}`), "", "!cpu 6510", '!source "constants.asm"', ...(input.macros ? ['!source "macros.asm"'] : []), "", `* = ${formatC64Address(LOAD)}`];
|
|
437
|
+
const lines: string[] = [...input.header.map((line) => `; ${line}`), "", "!cpu 6510", ...(input.switches === true ? ['!source "switches.asm"'] : []), '!source "constants.asm"', ...(input.macros ? ['!source "macros.asm"'] : []), "", `* = ${formatC64Address(LOAD)}`];
|
|
436
438
|
lines.push(` !byte $0b,$08,$0a,$00,$9e,${[...String(STUB)].map((digit) => formatC64Byte(digit.charCodeAt(0))).join(",")},$00,$00,$00 ; 10 SYS ${STUB}`);
|
|
437
439
|
lines.push(
|
|
438
440
|
"!zone loader_stub {",
|