Read the English 1.0 and Australian cartridges besides 1.1 (#84)
Checks / web (push) Failing after 19s
Private ROM checks / private-rom (push) Failing after 25m36s

PRET's crystal and crystal_au builds reproduce both retail cartridges,
and every label the profile pins keeps its address in all three;
check:reference now verifies that when the rebuilds are present. The
revision comes from the header. Revision 1.0's Battle Tower draws only
the first 21 trainers and picks its texts' gender from the name's sixth
character, checked against each cartridge. A native backup imports
across the three, which share every map, event and object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kawaandClaude Opus 5.5 committed 2026-10-17 16:12:00 +02:00
1 parent acdaf62eaa
commit 3c480a28f0
17 files changed
+317 -26

No files matched your search

+28 -6
View File
@@ -1,9 +1,30 @@
/** The English cartridges the port reads (src/game/rom/revision.ts), as
* PRET rebuilds them byte for byte. Their native saves are interchangeable:
* the three share every map, event and object. */
export const CRYSTAL_ROMS = [
{
name: "Pokémon Crystal · English US/Europe 1.1",
sha1: "f2f52230b536214ef7c9924f483392993e226cfb",
},
{
name: "Pokémon Crystal · English US/Europe 1.0",
sha1: "f4cd194bdee0d04ca4eac29e09b8e4e9d818c133",
},
{
name: "Pokémon Crystal · English Australia",
sha1: "a0fc810f1d4e124434f7be2c989ab5b5892ddf36",
},
] as const;
export const CRYSTAL_ROM = {
name: "Pokémon Crystal · English US/Europe 1.1",
sha1: "f2f52230b536214ef7c9924f483392993e226cfb",
...CRYSTAL_ROMS[0],
size: 2 * 1024 * 1024,
} as const;
/** The supported cartridge with this SHA-1, if any. */
export const supportedRom = (sha1: unknown) =>
CRYSTAL_ROMS.find((rom) => rom.sha1 === sha1);
export interface ValidatedRom {
bytes: Uint8Array;
sha1: string;
@@ -13,7 +34,7 @@ export interface ValidatedRom {
export async function validateRom(file: File): Promise<ValidatedRom> {
if (file.size !== CRYSTAL_ROM.size) {
throw new Error(
"Choose an uncompressed Pokémon Crystal English US/Europe 1.1 ROM (.gbc, 2 MiB).",
"Choose an uncompressed English Pokémon Crystal ROM (.gbc, 2 MiB).",
);
}
if (!globalThis.crypto?.subtle) {
@@ -26,10 +47,11 @@ export async function validateRom(file: File): Promise<ValidatedRom> {
const sha1 = Array.from(new Uint8Array(digest), (byte) =>
byte.toString(16).padStart(2, "0"),
).join("");
if (sha1 !== CRYSTAL_ROM.sha1) {
const rom = supportedRom(sha1);
if (!rom) {
throw new Error(
"This ROM is not the supported English US/Europe revision 1.1. Other languages, revisions, and modified ROMs are not supported yet.",
"This ROM is not a supported English Pokémon Crystal: US/Europe revision 1.0 or 1.1, or the Australian release. Other languages and modified ROMs are not supported yet.",
);
}
return { bytes: new Uint8Array(buffer), sha1, name: CRYSTAL_ROM.name };
return { bytes: new Uint8Array(buffer), sha1, name: rom.name };
}