Read the English 1.0 and Australian cartridges besides 1.1 (#84)
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:
1 parent
acdaf62eaa
commit
3c480a28f0
17 files changed
+317
-26
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import type { RomReader } from "./reader";
|
||||
|
||||
/** The cartridges the port reads, as PRET builds them (`make crystal`,
|
||||
* `crystal11` and `crystal_au`): the English US/Europe revisions 1.0 and
|
||||
* 1.1, and the Australian release, which is 1.1 with the Game Corners'
|
||||
* gambling texts rewritten. All three keep every label the port reads at the
|
||||
* same address; only the routines `romRevision` callers check differ. */
|
||||
export type Revision = "1.0" | "1.1" | "au";
|
||||
|
||||
/** The revision from the cartridge header (rgbfix's -i and -n): game code
|
||||
* BYTU for the Australian release, else BYTE with mask ROM version 0 or 1. */
|
||||
export function romRevision(r: RomReader): Revision {
|
||||
const code = String.fromCharCode(r.byte(0x13f), r.byte(0x140), r.byte(0x141), r.byte(0x142));
|
||||
if (code === "BYTU") return "au";
|
||||
if (code !== "BYTE") throw new Error("Unknown cartridge game code.");
|
||||
return r.byte(0x14c) === 0 ? "1.0" : "1.1";
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { JOHTO, RAM, WRAM } from "../rom/profile";
|
||||
import { maxPP, validPartyMon, type PartyMon } from "../party/pokemon";
|
||||
import type { PokemonData } from "../rom/pokemon";
|
||||
import { DIRECTION_ORDER, type Direction } from "../world/types";
|
||||
import { romRevision } from "../rom/revision";
|
||||
import { readFixedString, readString } from "./text";
|
||||
import type { Gen, SpecialContext } from "./special-context";
|
||||
|
||||
@@ -51,6 +52,8 @@ const MON_STRUCT = 48,
|
||||
NICKNAMED_MON = MON_STRUCT + 11;
|
||||
/** BattleTowerTrainers' entries: a 10-character name and the class. */
|
||||
const TRAINER_ENTRY = 11;
|
||||
/** NAME_LENGTH_JAPANESE (constants/text_constants.asm). */
|
||||
const NAME_LENGTH_JAPANESE = 6;
|
||||
const HP_UP = 0x1a,
|
||||
CALCIUM = 0x1f,
|
||||
LUCKY_PUNCH = 0x1e,
|
||||
@@ -206,7 +209,10 @@ function sample(
|
||||
* others and none of the last two trainers' species. */
|
||||
export function loadOpponent(c: SpecialContext, bt: BattleTowerState): BattleTowerOpponent {
|
||||
const r = c.reader;
|
||||
const trainer = sample(c, BATTLE_TOWER.uniqueTrainers, (index) => bt.trainers.includes(index));
|
||||
// BUG (Crystal 1.0): masked and compared with BATTLETOWER_NUM_UNIQUE_MON,
|
||||
// so only the first 21 trainers are drawn.
|
||||
const trainers = romRevision(r) === "1.0" ? BATTLE_TOWER.uniqueMons : BATTLE_TOWER.uniqueTrainers;
|
||||
const trainer = sample(c, trainers, (index) => bt.trainers.includes(index));
|
||||
bt.trainers[bt.beaten] = trainer;
|
||||
const entry = JOHTO.BattleTowerTrainers + trainer * TRAINER_ENTRY;
|
||||
// Copied to wOTPlayerName with a "@" after its ten bytes: ZABOROWSKI
|
||||
@@ -251,7 +257,14 @@ export const battleTowerSprite = (c: SpecialContext, trainerClass: number) =>
|
||||
* player lost) and 3 (the player won) reuse it. Returns the text. */
|
||||
export function battleTowerText(c: SpecialContext, bt: BattleTowerState, which: 1 | 2 | 3) {
|
||||
const r = c.reader;
|
||||
const trainerClass = bt.opponent?.trainerClass ?? 0;
|
||||
// BUG (Crystal 1.0): the sixth character of wBT_OTName stands in for
|
||||
// wBT_OTTrainerClass as the index into BTTrainerClassGenders.
|
||||
const trainerClass =
|
||||
romRevision(r) === "1.0"
|
||||
? bt.opponent
|
||||
? r.byte(JOHTO.BattleTowerTrainers + bt.opponent.trainer * TRAINER_ENTRY + NAME_LENGTH_JAPANESE - 1)
|
||||
: 0
|
||||
: (bt.opponent?.trainerClass ?? 0);
|
||||
const female = r.byte(JOHTO.BTTrainerClassGenders + ((trainerClass - 1) & 0xff)) !== 0;
|
||||
const table = female ? JOHTO.BTFemaleTrainerTexts : JOHTO.BTMaleTrainerTexts;
|
||||
if (which === 1) {
|
||||
|
||||
Reference in new issue
Block a user