Jump to content

Meta-map script activation: Difference between revisions

→‎Activation: Added some explanation... that maybe is too long and should belong on a separate page.
>Torchickens
>Bbbbbbbbba
(→‎Activation: Added some explanation... that maybe is too long and should belong on a separate page.)
Line 22:
The glitch can be pulled off by three variations of the [[Trainer escape glitch]].
 
The first one involves setting up a "death -warp", returning to the original location to rematch the Trainer and defeating them without flashing the start menu.
 
The second one involves talking to an NPC on the original route while encounters are disabled and defeating them.
 
The third one involves forcing an encounter with an unbeaten Trainer on the original route through '"text box matching'". Text box matching basically forces the game to load the equivalent text box for the last text box in memory, and have that text box trigger a Trainer encounter.
 
The glitch map [[map 0xFE (English Yellow)|map 0xFE in English Yellow]] will set up glitch scripts on various maps, many of which will freeze the game.
Line 32:
A glitch script may also be activated by manipulating items in the expanded stored items pack. This is possible with the [[expanded items pack|dry underflow glitch]] with storage box items.
 
=== Example procedure (death -warp method) ===
# Encounter a Pokémon in the grass in the sight of the last Trainer in Viridian CityForest (closest to ViridianPewter City) in Viridian Forest.
# Black out in the wild encounter (e.g. by poison). The "!" will appear but you will return to the last Pokémon Center without battling the Trainer.
# Return to Viridian Forest without opening the start menu (it is also best to avoid any text box to make sure the upcoming battle begins).
Line 88:
 
For example, item 100's quantity controls the map script for Route 8 (address D601 in Red/Blue, D600 in Yellow). Though a quantity of 1 for this item will set up a Special-stat encounter (as if activating the Trainer escape glitch), out of bounds values are glitch scripts associated with this glitch.
 
=== Triggering mechanism with the Trainer escape glitch ===
With the Trainer escape glitch, a text box always pop up before the special encounter happens. That is usually the Start menu, either because the player has been in a non-glitched area with trainers, or because the player has flashed the Start menu beforehand. However, by viewing a text box in an area without trainers ("text box ID matching"), or by not viewing a text box at all (usually with the death-warp method), the text box that pops up can be something else. In particular, it may belong to a trainer.
 
A trainer's text box is special: It executes a script that behaves differently according to whether the trainer has been defeated, and whether the trainer saw the player. In particular, if the trainer hasn't been defeated, and bit 0 of $CD60 isn't set, then the text box itself is responsible for starting the fight and adjusting the meta-map script ID. Normally, the meta-map script ID would be 0 (CheckFightingMapTrainers), and the text box advances it by 2, so that it becomes 2 (EndTrainerBattle, which should be executed after the fight).
 
Of course, when the Trainer escape glitch is active, everything becomes a mess. First, the meta-map script ID is already 1 (DisplayEnemyTrainerTextAndStartBattle), so the text box sets it to 3 (usually already out of bounds). Furthermore, if this text box itself is displayed by the meta-map script, DisplayEnemyTrainerTextAndStartBattle, then the script will increase the meta-map script ID again to 4. All of this happens before the fight (which will always be against the trainer, since the text box sets the enemy data, overwriting any special stats/attack stages last encountered) actually begins.
 
What happens after the fight will depend on what the meta-map script ID 4 (or 3 if the trainer is talked to directly) points to. For example, in the Viridian Forest, meta-map script ID 4 points to ViridianForestText2, which is a piece of text script:
 
ViridianForestText2:
TX_ASM ; 08
ld hl, ViridianForestTrainerHeader0 ; 21 42 51
call TalkToTrainer ; CD CC 31
jp TextScriptEnd ; C3 D7 24
 
Here TX_ASM is a byte of 0x08 that signifies script in text. When this pointer is executed as a meta-map script, the game tries to interpret the 0x08 itself as code instead, which leads to:
 
ld [$4221], sp ; 08 21 42
ld d, c ; 51
call TalkToTrainer ; CD CC 31
jp TextScriptEnd ; C3 D7 24
 
The first instruction does nothing since it tries to write to the ROM, and the second instruction also doesn't do much, since TalkToTrainer only cares about the register hl, whose value is still ViridianForestText2. This leads to more nonsense interpretation for the same piece of data, this time as a trainer header.
 
db $08 ; bit of "trainer beaten" event flag
db $21 ; trainer's view range
dw $5142 ; address of "trainer beaten" event flag
dw $CCCD ; pointer to text before battle
dw $C331 ; pointer to text when talked to after defeated
dw $24D7 ; pointer to text when defeated
 
Hence the game checks "bit 8 of $5142" (i.e. bit 0 of $5143) to see whether this "trainer" has been defeated. Since address $5143 is on the switchable portion of the ROM, and the function to manipulate flag arrays is on bank 3, this actually checks $5143 on bank 3, which is some completely unrelated data. Anyway, the flag value turns out to be 0, so another fight begins, and the meta-map script ID advances yet again to 6. (The fight is still against the same trainer, since on this code path, the trainer class and the roster number depends on the "last text box ID", and TalkToTrainer itself never changes this ID.)
 
After this second fight, meta-map script ID 6 is executed, which points to ViridianForestText4. This is pretty much the same thing, except that $5142 (ViridianForestTrainerHeader0) changes to $515A (ViridianForestTrainerHeader2), and this "trainer" is actually already fought, so this script just displays the "text when talked to after defeated". The "text" ends up triggering an error trap, displaying as something like "0 ERROR.", with the text box closing without an input. Furthermore, since this text is displayed on a glitched code path, the game actually stays in "overworld mode", where the tilemap buffer isn't copied to the VRAM every frame, and all text boxes are invisible. However, displaying this text still takes time, and it's displayed on every overworld frame as long as the player isn't in the middle of a step, resulting in a "walking lag". (The text box can be seen by mashing the Start button to bring up the Start menu.)
 
== Map 0xFE corruption ==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.