Verify random battle and capture routines against the original engine
Checks / web (push) Canceled after 0s

This commit is contained in:
Sébastien QUEROL committed 2026-09-30 15:48:00 +02:00
1 parent be7575a4d0
commit 00972bad10
9 files changed
+978 -74

No files matched your search

+2 -39
View File
@@ -1,4 +1,4 @@
import { test, expect, type Page } from "@playwright/test";
import { test, expect } from "@playwright/test";
import { existsSync, readFileSync } from "node:fs";
import { CrystalAssets } from "../src/game/rom/assets";
import { BattleData } from "../src/game/battle/data";
@@ -14,44 +14,7 @@ import {
import { C } from "../src/game/battle/constants";
import { NATIVE_MAPS } from "../src/game/rom/profile";
import { calcStat, maxPP } from "../src/game/party/pokemon";
import { resolve } from "node:path";
const romPath = resolve(
process.env.CRYSTAL_ROM_PATH ??
"Pokemon - Crystal Version (UE) (V1.1) [C][!].gbc",
);
const symbolsPath = ".reference/pokecrystal/pokecrystal11.sym";
/** Banked addresses from the private PRET rebuild's symbol file. */
function loadSymbols() {
const symbols = new Map(
readFileSync(symbolsPath, "utf8")
.split("\n")
.flatMap((line) => {
const match = /^([0-9a-f]{2}):([0-9a-f]{4}) (\S+)$/.exec(line);
return match
? [[match[3], { bank: parseInt(match[1], 16), address: parseInt(match[2], 16) }] as const]
: [];
}),
);
return {
at: (name: string) => symbols.get(name)!.address,
routine: (name: string) => symbols.get(name)!,
};
}
/** Open the reference page and hand it the ROM through an isolated file
* input, without an HTTP ROM endpoint. */
async function openReference(page: Page) {
await page.goto("/reference.html");
await page.evaluate(() => {
const input = document.createElement("input");
input.type = "file";
input.id = "reference-fixture";
document.body.append(input);
});
await page.locator("#reference-fixture").setInputFiles(romPath);
}
import { romPath, symbolsPath, loadSymbols, openReference } from "./reference-fixture";
test("native decompression matches original GB assembly executing in the reference emulator", async ({
page,