@henols/c64-re-tools 2.6.0-rc.1 → 2.6.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/package.json
CHANGED
|
@@ -273,7 +273,7 @@ The start screen:
|
|
|
273
273
|
- `verified: true`: the check ran `loader.prg` to its jump to the entry. There, the memory, $00/$01, the registers and the VIC-II are equal to the entry state. The raster line and the CIA values are also equal. An interrupt can run right at the entry, as in the original program.
|
|
274
274
|
- `limits`: each CIA value that the loader cannot set as it was at the entry. An old capture has no CIA values. Then capture the program again at its entry point.
|
|
275
275
|
- `startScreen`: with a start screen, `shown: true` when the VIC-II had the values of the start screen, and `waits: true` when the start screen waited without a key. `wait` and `continue` are the addresses of the wait and of the code after it. The check sets the PC to `continue`, and then runs the loader to its jump.
|
|
276
|
-
- `packed`: `packedBytes` and `unpackedBytes` of the packed form.
|
|
276
|
+
- `packed`: `packedBytes` and `unpackedBytes` of the packed form. With a start screen of a captured stage, this is the packed program in `loader.prg`.
|
|
277
277
|
- `stage`: the show stage of a start screen of a captured stage. It has the `space` of the stage and the address of the show `code`. It also has the `bytes` of the stage in `loader.prg`, the `stash` copies, `packedBytes` and `unpackedBytes`. `startScreen.stage` names the space.
|
|
278
278
|
- When the check of `loader.prg` cannot run, the script does not write `loader.prg`. The `loader.prg` of an earlier run stays as it was. `loader.asm` is new. `reason` tells why the check did not run.
|
|
279
279
|
- `kept`: when the result has no new `loader.prg`, the path of the `loader.prg` of an earlier run. That file is not of this source.
|
|
@@ -295,13 +295,17 @@ Do these actions when `verified` is `false`:
|
|
|
295
295
|
|
|
296
296
|
Often the loading stage of a program shows a picture that is not in memory at the entry. Then the knowledge has the picture in a captured stage: a space such as `bank1`. `--stage` of the start screen names that space. `--call` names a routine of the stage, for example the routine that starts the loading tune.
|
|
297
297
|
|
|
298
|
-
|
|
298
|
+
The loader then always has the packed form, and the start screen is a program of its own in front of it:
|
|
299
299
|
|
|
300
|
-
1. Exomizer
|
|
301
|
-
2.
|
|
302
|
-
3.
|
|
303
|
-
4.
|
|
304
|
-
5. It
|
|
300
|
+
1. Exomizer packs the program with the copier. This is the packed loader.
|
|
301
|
+
2. Exomizer packs the packed loader, the bytes of the stage and the show code into `loader.prg`.
|
|
302
|
+
3. When `loader.prg` starts, Exomizer unpacks these parts. The program stays packed. The bytes of the packed loader under the stage go to a stash in free memory.
|
|
303
|
+
4. The show code shows the start screen with `start_screen.asm`. With a call, it sets $01 to $37, starts the interrupts and calls the routine.
|
|
304
|
+
5. It waits for a key or a fire button, as the start screen in the program does.
|
|
305
|
+
6. It stops the interrupts and the sound, and it stops the screen. It sets the CIA timers as RUN leaves them.
|
|
306
|
+
7. It copies the stash back to the packed loader. Then it starts the packed loader, which unpacks the program over the start screen.
|
|
307
|
+
|
|
308
|
+
The program is packed while the screen shows. Thus the picture and the tune have more free memory.
|
|
305
309
|
|
|
306
310
|
- `loader.prg` has only the bytes of the stage that the start screen uses. These are the screen, the bitmap, the charset and the colours. With a call, they are also each byte of the stage that is not free from the call, as in "The free ranges". A call thus needs the coverage of the stage.
|
|
307
311
|
- The patches of the stage are in at the defaults of their switches. Thus a patch under a switch can remove the text of a crack from the picture.
|
|
@@ -465,6 +465,8 @@ export interface LoaderInput {
|
|
|
465
465
|
config?: boolean;
|
|
466
466
|
/** The start screen of the knowledge: the copier shows it after the copies. */
|
|
467
467
|
startScreen?: StartScreenRow;
|
|
468
|
+
/** Always the packed form: the show stage of a start screen from a captured stage holds the packed program while it shows the screen. */
|
|
469
|
+
packed?: boolean;
|
|
468
470
|
}
|
|
469
471
|
|
|
470
472
|
/** The checks of a start screen against the program and the entry state. Refuses by name. */
|
|
@@ -549,6 +551,7 @@ export function planLoader(input: LoaderInput): LoaderPlan {
|
|
|
549
551
|
const codeSize = COPIER_CODE_SIZE + (state.vic === undefined ? 0 : VIC_SIZE) + ciaSize + (screen === undefined ? 0 : START_SCREEN_SIZES[screen.colourMode]);
|
|
550
552
|
const copierImage = at;
|
|
551
553
|
const end = copierImage + codeSize + COPY_ENTRY * plain.length + 2 - 1;
|
|
554
|
+
if (input.packed === true) return planPacked(input, blocks, cia, codeSize, screen, "The start screen of a captured stage shows while the program is still packed.");
|
|
552
555
|
// The end can be past $ffff, which is no address.
|
|
553
556
|
if (end > LOAD_LIMIT) return planPacked(input, blocks, cia, codeSize, screen, `The plain loader would end ${end > 0xffff ? "past $ffff" : `at ${formatC64Address(end)}`}, after ${formatC64Address(LOAD_LIMIT)}: loading it would write the I/O area.`);
|
|
554
557
|
// The CIA part and the start screen take room from the copy table in the copier's pages.
|
|
@@ -832,7 +835,7 @@ export async function packLoader(main: Uint8Array, copier: Uint8Array, plan: Loa
|
|
|
832
835
|
}
|
|
833
836
|
|
|
834
837
|
/** What Exomizer packs in the packed form: the loaded ranges of the build of main.asm from $0400, and the build of loader.asm. */
|
|
835
|
-
|
|
838
|
+
function packedParts(main: Uint8Array, copier: Uint8Array, plan: Pick<LoaderPlan, "loaded">): Array<{ start: number; body: Uint8Array }> {
|
|
836
839
|
// The unpacker uses pages 0-3; the copier writes them. The leftovers between the loaded ranges are not packed.
|
|
837
840
|
const program = prgRange(main);
|
|
838
841
|
const ranges = plan.loaded.flatMap((range) => {
|
|
@@ -43,7 +43,6 @@ import {
|
|
|
43
43
|
COPIER_SOURCE,
|
|
44
44
|
LOADER_JUMP,
|
|
45
45
|
loaderLimits,
|
|
46
|
-
packedParts,
|
|
47
46
|
packLoader,
|
|
48
47
|
packParts,
|
|
49
48
|
planLoader,
|
|
@@ -853,8 +852,9 @@ async function buildSource(knowledge: SourceKnowledge, options: SourceOptions) {
|
|
|
853
852
|
config: hasConfigFile(laid),
|
|
854
853
|
macros: laid.macros.length > 0,
|
|
855
854
|
header: options.loaderHeader ?? [],
|
|
856
|
-
// A start screen of a stage shows before the loader, in the show stage: the copier has none.
|
|
855
|
+
// A start screen of a stage shows before the loader, in the show stage, while the program is still packed: the copier has none.
|
|
857
856
|
...(knowledge.startScreen === undefined || knowledge.startScreen.stage !== undefined ? {} : { startScreen: knowledge.startScreen }),
|
|
857
|
+
...(knowledge.startScreen?.stage === undefined ? {} : { packed: true }),
|
|
858
858
|
});
|
|
859
859
|
} catch (error) {
|
|
860
860
|
if (!isRefusal(error)) throw error;
|
|
@@ -989,14 +989,15 @@ interface BuiltStage {
|
|
|
989
989
|
* assembles start_screen_stage.asm and packs it with the loader as the loader
|
|
990
990
|
* is in memory before it starts. Refuses by name.
|
|
991
991
|
*/
|
|
992
|
-
async function buildStage(files: Array<{ name: string; text: string }>, laid: Layout,
|
|
992
|
+
async function buildStage(files: Array<{ name: string; text: string }>, laid: Layout, program: PackedLoader, row: StartScreenRow, values: ReadonlyMap<string, number>, header: string[], mark: string): Promise<BuiltStage> {
|
|
993
993
|
const stage = await stageBytes(row);
|
|
994
|
-
|
|
994
|
+
// The packed program, as RUN would start it: its unpacker unpacks it over the start screen after the wait.
|
|
995
|
+
const inner: StagePart[] = [{ start: 0x0801, body: program.program.subarray(2) }];
|
|
995
996
|
const screen = startScreenPlan(row);
|
|
996
997
|
const input: StageInput = {
|
|
997
998
|
inner,
|
|
998
|
-
innerStart:
|
|
999
|
-
innerPort:
|
|
999
|
+
innerStart: 0x080d,
|
|
1000
|
+
innerPort: 0x37,
|
|
1000
1001
|
stage,
|
|
1001
1002
|
row,
|
|
1002
1003
|
plan: screen,
|
|
@@ -1191,11 +1192,11 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
|
|
|
1191
1192
|
const { jump, copierSource, expected, startScreen } = loaderBuilt;
|
|
1192
1193
|
const copierBuild = loaderBuilt.program;
|
|
1193
1194
|
const fileByte = (address: number) => copierBuild[2 + address - (loader.packed?.start ?? 0x0801)]!;
|
|
1194
|
-
// A start screen of a captured stage: the show stage
|
|
1195
|
+
// A start screen of a captured stage: the show stage holds the packed program, as a cracktro holds the game.
|
|
1195
1196
|
const stageRow = knowledge.startScreen?.stage === undefined ? undefined : knowledge.startScreen;
|
|
1196
1197
|
// The packed form: Exomizer packs the build of main.asm with the copier. Without Exomizer, or when its check fails, there is no new loader.prg.
|
|
1197
1198
|
let packed: PackedLoader | undefined;
|
|
1198
|
-
if (loader.packed !== undefined
|
|
1199
|
+
if (loader.packed !== undefined) {
|
|
1199
1200
|
try {
|
|
1200
1201
|
packed = await packLoader(loaderMain.program, copierBuild, loader, localToolContext());
|
|
1201
1202
|
} catch (error) {
|
|
@@ -1206,7 +1207,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
|
|
|
1206
1207
|
let stage: BuiltStage | undefined;
|
|
1207
1208
|
if (stageRow !== undefined) {
|
|
1208
1209
|
try {
|
|
1209
|
-
stage = await buildStage(files, laid,
|
|
1210
|
+
stage = await buildStage(files, laid, packed!, stageRow, loaderValues, loaderHeader, GENERATED_LINE);
|
|
1210
1211
|
} catch (error) {
|
|
1211
1212
|
if (!isRefusal(error)) throw error;
|
|
1212
1213
|
return { output: { ...output, loader: notVerified({ reason: `The show stage of the start screen from ${stageRow.stage} cannot be built. ${error.message}` }) }, removed, failed: true };
|
|
@@ -1222,7 +1223,7 @@ async function generate(call: Call): Promise<{ output: Record<string, unknown>;
|
|
|
1222
1223
|
writeFileSync(resolveProjectPath(checkPath), program);
|
|
1223
1224
|
// The unpack runs before the copier, or before the show stage, which then starts the loader.
|
|
1224
1225
|
const unpackFrames = (cycles: number | undefined) => (cycles === undefined ? LOADER_FRAMES : RUN_LIMIT_FRAMES + Math.ceil(cycles / PAL_FRAME_CYCLES));
|
|
1225
|
-
const copierFrames =
|
|
1226
|
+
const copierFrames = packed === undefined ? RUN_LIMIT_FRAMES : unpackFrames(packed.cycles);
|
|
1226
1227
|
// The check compares the bytes of the screen of the stage: a routine of the stage can change its other bytes.
|
|
1227
1228
|
const stageByte = (address: number) => {
|
|
1228
1229
|
const part = stage!.parts.find((item) => address >= item.start && address < item.start + item.body.length)!;
|