@henols/c64-re-tools 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/c64-assembler/SKILL.md +2 -1
- package/skills/c64-basic/SKILL.md +2 -1
- package/skills/c64-development/SKILL.md +1 -1
- package/skills/c64-disk/SKILL.md +2 -1
- package/skills/c64-docs/SKILL.md +2 -1
- package/skills/c64-docs/references/page-types.md +3 -3
- package/skills/c64-docs/references/style.md +3 -1
- package/skills/c64-knowledge/SKILL.md +36 -4
- package/skills/c64-knowledge/scripts/knowledge.ts +64 -1
- package/skills/c64-memory-map/SKILL.md +2 -1
- package/skills/c64-packer/SKILL.md +2 -1
- package/skills/c64-provenance/SKILL.md +2 -1
- package/skills/c64-reverse-engineering/SKILL.md +3 -2
- package/skills/c64-source/SKILL.md +25 -11
- package/skills/c64-source/scripts/lib/export.ts +3 -0
- package/skills/c64-source/scripts/lib/loader.ts +140 -20
- package/skills/c64-source/scripts/lib/source.ts +15 -4
- package/skills/c64-source/scripts/lib/start-screen.asm +139 -0
- package/skills/c64-source/scripts/source.ts +128 -32
- package/skills/c64-static-analysis/SKILL.md +2 -1
- package/skills/c64-testing/SKILL.md +2 -1
- package/skills/c64-unpacker/SKILL.md +5 -3
- package/src/cli/main.ts +4 -2
- package/src/cli/status.ts +0 -1
- package/src/knowledge/conflicts.ts +4 -0
- package/src/knowledge/history.ts +5 -0
- package/src/knowledge/read.ts +55 -2
- package/src/knowledge/schema.ts +32 -2
- package/src/knowledge/text.ts +19 -0
- package/src/knowledge/write.ts +122 -1
package/src/knowledge/schema.ts
CHANGED
|
@@ -73,6 +73,14 @@ export const SWITCH_KINDS = ["protection", "trainer", "cheat", "crack", "fix", "
|
|
|
73
73
|
export type SwitchKind = (typeof SWITCH_KINDS)[number];
|
|
74
74
|
/** The kinds that are always off by default: the default build is the clean program. */
|
|
75
75
|
export const OFF_KINDS: readonly SwitchKind[] = ["protection", "trainer", "cheat", "crack"];
|
|
76
|
+
/**
|
|
77
|
+
* The display mode of a start screen: a text screen, a hires bitmap or a
|
|
78
|
+
* multicolour bitmap. The loader of the generated source shows it.
|
|
79
|
+
*/
|
|
80
|
+
export const START_SCREEN_MODES = ["text", "hires", "multicolour"] as const;
|
|
81
|
+
export type StartScreenMode = (typeof START_SCREEN_MODES)[number];
|
|
82
|
+
/** The switch of the start screen in the generated source: no symbol, switch or release can have this name. */
|
|
83
|
+
export const START_SCREEN_SWITCH = "START_SCREEN";
|
|
76
84
|
/** A macro name and a macro parameter. The body names a parameter with a dot in front: .dst. */
|
|
77
85
|
export const MACRO_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,31}$/;
|
|
78
86
|
export const MACRO_PARAM = /^[a-z_][a-z0-9_]{0,31}$/;
|
|
@@ -88,7 +96,7 @@ export type CoverageKind = (typeof COVERAGE_KINDS)[number];
|
|
|
88
96
|
export const MEMORY_ROW = 64;
|
|
89
97
|
|
|
90
98
|
/** Files that c64-source writes itself: no module can have these names. */
|
|
91
|
-
export const GENERATED_FILES = ["main.asm", "loader.asm", "switches.asm", "config.asm", "constants.asm", "macros.asm"] as const;
|
|
99
|
+
export const GENERATED_FILES = ["main.asm", "loader.asm", "switches.asm", "config.asm", "constants.asm", "macros.asm", "start_screen.asm"] as const;
|
|
92
100
|
|
|
93
101
|
/** True for a generated file name in any letter case: the file systems of macOS and Windows ignore case. */
|
|
94
102
|
export function isGeneratedFile(file: string): boolean {
|
|
@@ -295,6 +303,27 @@ function createSchema(db: DatabaseSync): void {
|
|
|
295
303
|
valid_to_revision TEXT REFERENCES revisions (id)
|
|
296
304
|
);
|
|
297
305
|
CREATE INDEX macros_name ON macros (space, name);
|
|
306
|
+
CREATE TABLE start_screens (
|
|
307
|
+
id TEXT PRIMARY KEY,
|
|
308
|
+
space TEXT NOT NULL DEFAULT 'c64' CHECK (space = 'c64'),
|
|
309
|
+
mode TEXT NOT NULL CHECK (mode IN (${list(START_SCREEN_MODES)})),
|
|
310
|
+
screen INTEGER NOT NULL CHECK (screen BETWEEN 0 AND 65535),
|
|
311
|
+
bitmap INTEGER CHECK (bitmap BETWEEN 0 AND 65535),
|
|
312
|
+
charset INTEGER CHECK (charset BETWEEN 0 AND 65535),
|
|
313
|
+
colours INTEGER CHECK (colours BETWEEN 0 AND 65535),
|
|
314
|
+
colour INTEGER CHECK (colour BETWEEN 0 AND 15),
|
|
315
|
+
border INTEGER NOT NULL CHECK (border BETWEEN 0 AND 15),
|
|
316
|
+
background INTEGER NOT NULL CHECK (background BETWEEN 0 AND 15),
|
|
317
|
+
comment TEXT CHECK (comment IS NULL OR length(comment) > 0),
|
|
318
|
+
origin TEXT NOT NULL CHECK (origin IN ('user', 'llm')),
|
|
319
|
+
valid_from_revision TEXT NOT NULL REFERENCES revisions (id),
|
|
320
|
+
valid_to_revision TEXT REFERENCES revisions (id),
|
|
321
|
+
CHECK ((mode = 'text') = (charset IS NOT NULL)),
|
|
322
|
+
CHECK ((mode = 'text') = (bitmap IS NULL)),
|
|
323
|
+
CHECK (colours IS NULL OR colour IS NULL),
|
|
324
|
+
CHECK ((mode = 'hires') = (colours IS NULL AND colour IS NULL))
|
|
325
|
+
);
|
|
326
|
+
CREATE INDEX start_screens_space ON start_screens (space);
|
|
298
327
|
CREATE TABLE macro_uses (
|
|
299
328
|
id TEXT PRIMARY KEY,
|
|
300
329
|
space TEXT NOT NULL DEFAULT 'c64' CHECK (${SPACE_CHECK}),
|
|
@@ -355,11 +384,12 @@ function createSchema(db: DatabaseSync): void {
|
|
|
355
384
|
CREATE VIEW current_releases AS SELECT * FROM releases WHERE valid_to_revision IS NULL;
|
|
356
385
|
CREATE VIEW current_macros AS SELECT * FROM macros WHERE valid_to_revision IS NULL;
|
|
357
386
|
CREATE VIEW current_macro_uses AS SELECT * FROM macro_uses WHERE valid_to_revision IS NULL;
|
|
387
|
+
CREATE VIEW current_start_screens AS SELECT * FROM start_screens WHERE valid_to_revision IS NULL;
|
|
358
388
|
`);
|
|
359
389
|
}
|
|
360
390
|
|
|
361
391
|
/** The version of the index this build makes. An index with another version is emptied and made again. */
|
|
362
|
-
export const INDEX_VERSION =
|
|
392
|
+
export const INDEX_VERSION = 10;
|
|
363
393
|
|
|
364
394
|
function indexVersion(db: DatabaseSync): number | undefined {
|
|
365
395
|
const hasMeta = db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'meta'").get();
|
package/src/knowledge/text.ts
CHANGED
|
@@ -185,6 +185,25 @@ export const TABLES: readonly TableSpec[] = [
|
|
|
185
185
|
sort: "start_address",
|
|
186
186
|
fields: [space, field("start", "start_address", "address"), field("end", "end_address", "address"), field("macro", "macro", "text"), field("args", "args", "text"), origin],
|
|
187
187
|
},
|
|
188
|
+
// The start screen of the program: the loader of the generated source shows it before the entry.
|
|
189
|
+
{
|
|
190
|
+
table: "start_screens",
|
|
191
|
+
file: "start_screen.jsonl",
|
|
192
|
+
sort: "screen",
|
|
193
|
+
fields: [
|
|
194
|
+
space,
|
|
195
|
+
field("mode", "mode", "text"),
|
|
196
|
+
field("screen", "screen", "address"),
|
|
197
|
+
field("bitmap", "bitmap", "address", true),
|
|
198
|
+
field("charset", "charset", "address", true),
|
|
199
|
+
field("colours", "colours", "address", true),
|
|
200
|
+
field("colour", "colour", "integer", true),
|
|
201
|
+
field("border", "border", "integer"),
|
|
202
|
+
field("background", "background", "integer"),
|
|
203
|
+
field("comment", "comment", "text", true),
|
|
204
|
+
origin,
|
|
205
|
+
],
|
|
206
|
+
},
|
|
188
207
|
// The program itself: its bytes, at most 64 to a row, so a changed byte changes one line.
|
|
189
208
|
{ table: "memory", file: "memory.jsonl", sort: "address", fields: [space, field("at", "address", "address"), field("bytes", "bytes", "hex"), origin] },
|
|
190
209
|
// Where the program starts, the machine state there, and the stages of its unpacker.
|
package/src/knowledge/write.ts
CHANGED
|
@@ -39,6 +39,9 @@ import {
|
|
|
39
39
|
RELEASE_COLUMNS,
|
|
40
40
|
releaseLabeled,
|
|
41
41
|
SWITCH_COLUMNS,
|
|
42
|
+
START_SCREEN_COLUMNS,
|
|
43
|
+
currentStartScreen,
|
|
44
|
+
startScreenRanges,
|
|
42
45
|
switchNamed,
|
|
43
46
|
coverageRuns,
|
|
44
47
|
resolveRevision,
|
|
@@ -58,6 +61,7 @@ import {
|
|
|
58
61
|
toRelease,
|
|
59
62
|
toSuppression,
|
|
60
63
|
toSwitch,
|
|
64
|
+
toStartScreen,
|
|
61
65
|
toSymbol,
|
|
62
66
|
type CommentRow,
|
|
63
67
|
type CoverageRun,
|
|
@@ -70,10 +74,11 @@ import {
|
|
|
70
74
|
type RegionRow,
|
|
71
75
|
type ReleaseRow,
|
|
72
76
|
type SuppressionRow,
|
|
77
|
+
type StartScreenRow,
|
|
73
78
|
type SwitchRow,
|
|
74
79
|
type SymbolRow,
|
|
75
80
|
} from "./read.ts";
|
|
76
|
-
import { CODE_REGION_TYPES, COMMENT_PLACEMENTS, EVIDENCE_KINDS, MAX_ELEMENT, MODULE_FILE, DEFAULT_SPACE, GENERATED_FILES, isGeneratedFile, isSemantic, MACRO_NAME, MACRO_PARAM, OFF_KINDS, RELEASE_DEFINE, RELEASE_LABEL, SWITCH_KINDS, SWITCH_NAME, NO_ELEMENT_TYPES, OPERAND_SELECTS, POINTER_KIND, REFERENCE_KINDS, REGION_TYPES, SYMBOL_KINDS, type CommentPlacement, type EvidenceKind, type OperandSelect, type Origin, type ReferenceKind, type RegionType, type Space, type SwitchKind, type SymbolKind } from "./schema.ts";
|
|
81
|
+
import { CODE_REGION_TYPES, COMMENT_PLACEMENTS, EVIDENCE_KINDS, MAX_ELEMENT, MODULE_FILE, DEFAULT_SPACE, GENERATED_FILES, isGeneratedFile, isSemantic, MACRO_NAME, MACRO_PARAM, OFF_KINDS, RELEASE_DEFINE, RELEASE_LABEL, START_SCREEN_MODES, START_SCREEN_SWITCH, SWITCH_KINDS, SWITCH_NAME, NO_ELEMENT_TYPES, OPERAND_SELECTS, POINTER_KIND, REFERENCE_KINDS, REGION_TYPES, SYMBOL_KINDS, type CommentPlacement, type EvidenceKind, type OperandSelect, type Origin, type ReferenceKind, type RegionType, type Space, type StartScreenMode, type SwitchKind, type SymbolKind } from "./schema.ts";
|
|
77
82
|
import { newRevisionId, rowId, sqlName } from "./text.ts";
|
|
78
83
|
|
|
79
84
|
/** What a change rests on: a coverage run, a test or another project file with its SHA-256, or a note. */
|
|
@@ -280,6 +285,12 @@ export class Change {
|
|
|
280
285
|
.run(this.#rowId(), row.space, row.label, row.file, row.sha256, row.base ? 1 : 0, row.comment ?? null, row.origin, this.id());
|
|
281
286
|
}
|
|
282
287
|
|
|
288
|
+
insertStartScreen(row: Omit<StartScreenRow, "revision">): void {
|
|
289
|
+
this.#db
|
|
290
|
+
.prepare("INSERT INTO start_screens (id, space, mode, screen, bitmap, charset, colours, colour, border, background, comment, origin, valid_from_revision) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
|
291
|
+
.run(this.#rowId(), row.space, row.mode, row.screen, row.bitmap ?? null, row.charset ?? null, row.colours ?? null, row.colour ?? null, row.border, row.background, row.comment ?? null, row.origin, this.id());
|
|
292
|
+
}
|
|
293
|
+
|
|
283
294
|
insertMacro(row: Omit<MacroRow, "revision">): void {
|
|
284
295
|
this.#db
|
|
285
296
|
.prepare("INSERT INTO macros (id, space, name, params, body, comment, origin, valid_from_revision) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
|
|
@@ -323,6 +334,7 @@ function describe(conflict: Conflict): string {
|
|
|
323
334
|
const place = (entry: ConflictRow) => {
|
|
324
335
|
if (entry.entity === "macro" || entry.entity === "switch") return entry.row.name;
|
|
325
336
|
if (entry.entity === "release") return entry.row.label;
|
|
337
|
+
if (entry.entity === "start-screen") return formatC64Address(entry.row.screen);
|
|
326
338
|
const row = entry.row as { address?: number; start?: number; end?: number; from?: number };
|
|
327
339
|
if (row.address !== undefined) return formatC64Address(row.address);
|
|
328
340
|
if (row.from !== undefined && entry.entity === "reference") return formatC64Address(row.from);
|
|
@@ -432,6 +444,7 @@ function renameStep(db: DatabaseSync, change: Change, origin: Origin, request: S
|
|
|
432
444
|
throw new Refusal("conflict", `The name ${request.name} already belongs to ${formatC64Address(owner.address)}. Rename or remove that symbol first.`);
|
|
433
445
|
}
|
|
434
446
|
if (switchNamed(db, request.name, space) !== undefined) throw new Refusal("conflict", `${request.name} is the name of a switch. Give the symbol another name.`);
|
|
447
|
+
if (request.name === START_SCREEN_SWITCH) throw new Refusal("conflict", `${START_SCREEN_SWITCH} is the switch of the start screen in the generated source. Give the symbol another name.`);
|
|
435
448
|
const release = request.name.startsWith(RELEASE_DEFINE) ? releaseLabeled(db, request.name.slice(RELEASE_DEFINE.length), space) : undefined;
|
|
436
449
|
if (release !== undefined) throw new Refusal("conflict", `${request.name} builds the release ${release.label}. Give the symbol another name.`);
|
|
437
450
|
if (existing !== undefined) change.close("symbols", "space = ? AND address = ?", space, request.address);
|
|
@@ -945,6 +958,7 @@ function checkSwitch(request: SwitchRequest): void {
|
|
|
945
958
|
checkSpace(request);
|
|
946
959
|
checkSwitchName(request.name);
|
|
947
960
|
if (request.name.startsWith(RELEASE_DEFINE)) throw new Refusal("invalid-input", `A switch name does not start with ${RELEASE_DEFINE}: the build of a release defines ${RELEASE_DEFINE}<label>.`);
|
|
961
|
+
if (request.name === START_SCREEN_SWITCH) throw new Refusal("invalid-input", `${START_SCREEN_SWITCH} is the switch of the start screen in the generated source. Give the switch another name.`);
|
|
948
962
|
checkOneOf(SWITCH_KINDS, request.kind, "kind");
|
|
949
963
|
if (request.default !== undefined && request.default !== 0 && request.default !== 1) throw new Refusal("invalid-input", "default must be 0 or 1.");
|
|
950
964
|
if (OFF_KINDS.includes(request.kind) && request.default === 1) {
|
|
@@ -1050,6 +1064,92 @@ function unreleaseStep(db: DatabaseSync, change: Change, _origin: Origin, reques
|
|
|
1050
1064
|
return { current: null };
|
|
1051
1065
|
}
|
|
1052
1066
|
|
|
1067
|
+
type StartScreenRequest = InSpace & { mode: StartScreenMode; screen: number; bitmap?: number; charset?: number; colours?: number; colour?: number; border: number; background: number; comment?: string };
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* The rules of the VIC-II for a start screen: the screen at a 1K step, the
|
|
1071
|
+
* bitmap at an 8K step and the charset at a 2K step, all in one 16K VIC bank,
|
|
1072
|
+
* and no part where the VIC-II reads the character ROM. The colours are RAM
|
|
1073
|
+
* that the loader reads with the I/O area in, so not in $d000-$dfff. Nothing is
|
|
1074
|
+
* in pages 0-3, because the loader writes the entry state there.
|
|
1075
|
+
*/
|
|
1076
|
+
function checkStartScreen(request: StartScreenRequest): void {
|
|
1077
|
+
checkSpace(request);
|
|
1078
|
+
if (spaceOf(request) !== DEFAULT_SPACE) throw new Refusal("invalid-input", "A start screen is only in the space c64.");
|
|
1079
|
+
checkOneOf(START_SCREEN_MODES, request.mode, "mode");
|
|
1080
|
+
checkAddress(request.screen, "screen");
|
|
1081
|
+
for (const key of ["bitmap", "charset", "colours"] as const) if (request[key] !== undefined) checkAddress(request[key], key);
|
|
1082
|
+
for (const key of ["border", "background", "colour"] as const) {
|
|
1083
|
+
const value = request[key];
|
|
1084
|
+
if (value !== undefined && (!Number.isInteger(value) || value < 0 || value > 15)) throw new Refusal("invalid-input", `${key} must be a colour from 0 to 15.`);
|
|
1085
|
+
}
|
|
1086
|
+
if (request.mode === "text") {
|
|
1087
|
+
if (request.charset === undefined || request.bitmap !== undefined) throw new Refusal("invalid-input", "A text start screen has a charset and no bitmap. Give --charset, for example '$1000' for the character ROM in VIC bank 0.");
|
|
1088
|
+
} else if (request.bitmap === undefined || request.charset !== undefined) {
|
|
1089
|
+
throw new Refusal("invalid-input", `A ${request.mode} start screen has a bitmap and no charset. Give --bitmap.`);
|
|
1090
|
+
}
|
|
1091
|
+
if (request.colours !== undefined && request.colour !== undefined) throw new Refusal("invalid-input", "Give the colour RAM as --colours or as --colour, not both.");
|
|
1092
|
+
const colourRam = request.colours !== undefined || request.colour !== undefined;
|
|
1093
|
+
if (request.mode === "hires" && colourRam) throw new Refusal("invalid-input", "A hires bitmap does not use the colour RAM. Remove --colours and --colour.");
|
|
1094
|
+
if (request.mode !== "hires" && !colourRam) throw new Refusal("invalid-input", `A ${request.mode} start screen uses the colour RAM. Give --colours with the address of its 1000 bytes, or --colour with one colour.`);
|
|
1095
|
+
const step = (value: number, size: number, what: string) => {
|
|
1096
|
+
if (value % size !== 0) throw new Refusal("invalid-input", `The VIC-II reads the ${what} only at a step of $${size.toString(16)}: ${formatC64Address(value)} is not at one.`);
|
|
1097
|
+
};
|
|
1098
|
+
step(request.screen, 0x400, "screen");
|
|
1099
|
+
if (request.bitmap !== undefined) step(request.bitmap, 0x2000, "bitmap");
|
|
1100
|
+
if (request.charset !== undefined) step(request.charset, 0x800, "charset");
|
|
1101
|
+
const bank = request.screen >> 14;
|
|
1102
|
+
for (const [what, value] of [["bitmap", request.bitmap], ["charset", request.charset]] as const) {
|
|
1103
|
+
if (value !== undefined && value >> 14 !== bank) throw new Refusal("invalid-input", `The ${what} at ${formatC64Address(value)} is not in the VIC bank of the screen (${formatC64Address(bank << 14)}-${formatC64Address((bank << 14) + 0x3fff)}).`);
|
|
1104
|
+
}
|
|
1105
|
+
for (const { what, range } of startScreenRanges(request)) {
|
|
1106
|
+
if (range.end > 0xffff) throw new Refusal("invalid-input", `The ${what} at ${formatC64Address(range.start)} goes past $ffff.`);
|
|
1107
|
+
if (range.start < 0x0400) throw new Refusal("invalid-input", `The ${what} at ${formatC64Address(range.start)} is in pages 0-3, where the loader writes the entry state.`);
|
|
1108
|
+
if (what === "colours") {
|
|
1109
|
+
if (range.start <= 0xdfff && range.end >= 0xd000) throw new Refusal("invalid-input", `The colours at ${formatC64Address(range.start)} are in $d000-$dfff, where the loader sees the I/O area. Give the RAM address of the 1000 colour bytes.`);
|
|
1110
|
+
continue;
|
|
1111
|
+
}
|
|
1112
|
+
// In VIC banks 0 and 2 the VIC-II reads the character ROM at $1000-$1fff of the bank.
|
|
1113
|
+
const relative = range.start & 0x3fff;
|
|
1114
|
+
if ((bank & 1) === 0 && relative <= 0x1fff && relative + (range.end - range.start) >= 0x1000) {
|
|
1115
|
+
throw new Refusal("invalid-input", `The ${what} at ${formatC64Address(range.start)} is where the VIC-II reads the character ROM ($1000-$1fff of VIC bank ${bank}). Only a text charset at $1000 or $1800 of the bank uses the ROM font.`);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
checkCommentText(request.comment, "A start screen comment");
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
function startScreenStep(db: DatabaseSync, change: Change, origin: Origin, request: StartScreenRequest): Step<StartScreenRow, StartScreenRow> {
|
|
1122
|
+
const space = spaceOf(request);
|
|
1123
|
+
const existing = currentStartScreen(db, space);
|
|
1124
|
+
const comment = request.comment === undefined ? existing?.comment : request.comment.trim();
|
|
1125
|
+
const row: Omit<StartScreenRow, "revision"> = {
|
|
1126
|
+
space,
|
|
1127
|
+
mode: request.mode,
|
|
1128
|
+
screen: request.screen,
|
|
1129
|
+
...(request.bitmap === undefined ? {} : { bitmap: request.bitmap }),
|
|
1130
|
+
...(request.charset === undefined ? {} : { charset: request.charset }),
|
|
1131
|
+
...(request.colours === undefined ? {} : { colours: request.colours }),
|
|
1132
|
+
...(request.colour === undefined ? {} : { colour: request.colour }),
|
|
1133
|
+
border: request.border,
|
|
1134
|
+
background: request.background,
|
|
1135
|
+
...(comment === undefined ? {} : { comment }),
|
|
1136
|
+
origin: origin as StartScreenRow["origin"],
|
|
1137
|
+
};
|
|
1138
|
+
const same = existing !== undefined && KEYS.start_screens.key(existing) === KEYS.start_screens.key({ ...row, origin: existing.origin, revision: "" });
|
|
1139
|
+
if (same && !confirms(existing.origin, origin)) return { current: existing };
|
|
1140
|
+
if (existing !== undefined) change.close("start_screens", "space = ?", space);
|
|
1141
|
+
change.insertStartScreen(row);
|
|
1142
|
+
const current = currentStartScreen(db, space)!;
|
|
1143
|
+
return existing !== undefined && existing.origin !== origin ? { current, previous: existing } : { current };
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
function unstartScreenStep(db: DatabaseSync, change: Change, _origin: Origin, request: InSpace): Step<null> {
|
|
1147
|
+
const space = spaceOf(request);
|
|
1148
|
+
if (currentStartScreen(db, space) === undefined) throw new Refusal("not-found", "The knowledge has no start screen.");
|
|
1149
|
+
change.close("start_screens", "space = ?", space);
|
|
1150
|
+
return { current: null };
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1053
1153
|
type MacroRequest = InSpace & { name: string; params?: string[]; body: string; comment?: string };
|
|
1054
1154
|
|
|
1055
1155
|
function checkMacroName(name: unknown, what = "A macro name"): void {
|
|
@@ -1290,6 +1390,17 @@ export function removeRelease(db: DatabaseSync, context: WriteContext, request:
|
|
|
1290
1390
|
return result(write(db, context, "remove-release", (change) => unreleaseStep(db, change, context.origin, request)));
|
|
1291
1391
|
}
|
|
1292
1392
|
|
|
1393
|
+
/** Writes the start screen of the program: the loader of the generated source shows it before the entry. */
|
|
1394
|
+
export function setStartScreen(db: DatabaseSync, context: WriteContext, request: StartScreenRequest): WriteResult<StartScreenRow, StartScreenRow> {
|
|
1395
|
+
checkStartScreen(request);
|
|
1396
|
+
return result(write(db, context, "set-start-screen", (change) => startScreenStep(db, change, context.origin, request)));
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
export function removeStartScreen(db: DatabaseSync, context: WriteContext, request: InSpace): WriteResult<null> {
|
|
1400
|
+
checkSpace(request);
|
|
1401
|
+
return result(write(db, context, "remove-start-screen", (change) => unstartScreenStep(db, change, context.origin, request)));
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1293
1404
|
/** Writes a macro of the generated source. */
|
|
1294
1405
|
export function setMacro(db: DatabaseSync, context: WriteContext, request: MacroRequest): WriteResult<MacroRow, MacroRow> {
|
|
1295
1406
|
checkMacro(request);
|
|
@@ -1490,6 +1601,12 @@ const KEYS = {
|
|
|
1490
1601
|
map: toRelease,
|
|
1491
1602
|
key: (row: ReleaseRow) => `${row.space}|${row.label}|${row.file}|${row.sha256}|${row.base}|${row.comment ?? ""}|${row.origin}`,
|
|
1492
1603
|
},
|
|
1604
|
+
start_screens: {
|
|
1605
|
+
columns: START_SCREEN_COLUMNS,
|
|
1606
|
+
map: toStartScreen,
|
|
1607
|
+
key: (row: StartScreenRow) =>
|
|
1608
|
+
`${row.space}|${row.mode}|${row.screen}|${row.bitmap ?? ""}|${row.charset ?? ""}|${row.colours ?? ""}|${row.colour ?? ""}|${row.border}|${row.background}|${row.comment ?? ""}|${row.origin}`,
|
|
1609
|
+
},
|
|
1493
1610
|
macros: { columns: MACRO_COLUMNS, map: toMacro, key: (row: MacroRow) => `${row.space}|${row.name}|${listText(row.params)}|${row.body}|${row.comment ?? ""}|${row.origin}` },
|
|
1494
1611
|
macro_uses: { columns: MACRO_USE_COLUMNS, map: toMacroUse, key: (row: MacroUseRow) => `${row.space}|${row.start}|${row.end}|${row.macro}|${listText(row.args)}|${row.origin}` },
|
|
1495
1612
|
suppressions: {
|
|
@@ -1555,6 +1672,10 @@ export function revert(db: DatabaseSync, context: WriteContext, request: { revis
|
|
|
1555
1672
|
change.insertRelease(spec.map(row as never) as ReleaseRow);
|
|
1556
1673
|
continue;
|
|
1557
1674
|
}
|
|
1675
|
+
if (table === "start_screens") {
|
|
1676
|
+
change.insertStartScreen(spec.map(row as never) as StartScreenRow);
|
|
1677
|
+
continue;
|
|
1678
|
+
}
|
|
1558
1679
|
if (table === "macro_uses") {
|
|
1559
1680
|
change.insertMacroUse(spec.map(row as never) as MacroUseRow);
|
|
1560
1681
|
continue;
|