Main Menu

Glitches

References/Resources

Affiliates

Technical

Search Wiki

Toolbox

Saffron Gym glitch
 Page | Discussion | View source | History

From Glitch City Laboratories

Jump to: navigation, search
Miscellaneous glitches of Pokémon Red and Blue and Pokémon Yellow

Amazing Man (Red and Blue only) | Cable Club escape glitch | Celadon looping map trick | Champion Blue music muting glitch | Coastal Flooding | Confusion and Substitute glitch | Cooltrainer move | Cycling based glitch maps | Escape sprite handling glitch | Evolve without an evolutionary stone (Red and Blue only) | Evolving Raichu (Red and Blue only) | Expanded item pack | Expanded Pokédex | Focus Energy glitch | Get stuck in a wall | Ghost Bicycle glitch | Glitch encounter system | Glitch City RAM Manipulation | Infinite Blaine Door | Introduction Nidorino glitch (Red and Blue only) | Invisible PCs (Red and Blue only) | Invisible tree glitch | Item stack duplication glitch | Mute the music in the Pokémon League | Partial trapping move link battle glitch | Pokémon Tower Pokédex glitch | PP underflow glitches | Recovery move glitch | Rival's effect | See a Ghost without a Silph Scope | Selfdestruct and Substitute glitch | Silph Co. PC Glitch | Slot machine glitch | Stand on a tree | Statue behavior glitch (Red and Blue only) | Super effective move AI flaw (Red and Blue only) | Super Glitch | Surf down glitch | Swift miss glitch | Transform assumption glitch | Transform Empty Move Glitch | Trick Zone | Vending machine purchase glitch | Walk around with only fainted Pokémon (Red and Blue only) | Walking lag glitch | Walk on water through Surf | Walking Pikachu happiness glitch (Yellow only) | Wild appeared! | ZZAZZ Glitch

(view, talk, edit)
Please note that this glitch only exists in the Japanese versions of the game, or is otherwise a glitch
Japan.gif
from a Pokémon game which was only released in Japan.

The Saffron Gym glitch (Japanese: ヤマブキジムのバグ, Yamabuki Gym Bug[1]) is a glitch that only happens in Pokémon Red and Green. It was fixed in Japanese Blue, Pocket Monsters Pikachu, and the localizations.

This glitch manifests itself in two different ways:

  • If the player loses to a trainer in Saffron Gym, the game will act as if the player won when the player re-enters the gym.
  • If the player wins against a trainer in Saffron Gym, there is a frame window in which the player can talk to the trainer to restart the fight.

Both phenomena are caused by the same problem in the map script of Saffron Gym.

Loss becomes victory

The text box that appears after triggering this glitch with Sabrina.

After losing to a trainer in Saffron Gym, if the player returns to the gym, the game will act as if the player just won the fight. This means that that trainer cannot be fought again, and if talked to, they will say the line of dialog that normally appears after defeating them or defeating the gym. Furthermore, if that trainer is Sabrina:

  • When the player re-enters the gym, the game will immediately print the line of dialog that normally appears after winning the battle and exiting to the overworld (about the Marsh Badge letting Pokémon up to level 70 obey the player).
  • The player will receive TM46 (Psywave) and the Marsh Badge.
  • None of the trainers in the gym will fight the player, as if the player has defeated the gym.
  • The player's name will show on the statue at the front of the gym.

The prize money lost is not affected by this glitch.

YouTube video by ChickasaurusGL

Infinite rematch exploit


After winning against a trainer in Saffron Gym, if the player presses A during the first overworld frame, then the trainer will say their pre-battle dialog, and the fight will start again. This can be repeated indefinitely. However, to continue exploiting this glitch, the player must win every fight, because otherwise the first part of this glitch will trigger and prevent the player from fighting the same trainer again.

A very easy way to achieve this is by clearing the last in-fight text box (which states how much money the player has won) with the B button, then immediately starting holding A. This A press will be processed on the earliest frame possible, triggering this glitch.

Doing this with any trainer other than Sabrina will result in glitch meta-map script activation, because talking to a normal trainer not yet beaten increments the meta-map script ID by 2, and the ID is never reset to 0 since meta-map script 2 (EndTrainerBattle) is never executed. Sabrina is the only exception because her pre-battle dialog explicitly sets the meta-map script ID to 3 (special script for ending the gym leader battle), so it will work the same way no matter how many times the player fights her.

YouTube video by Exarion

Explanation

When the player enters a gym, or returns to its overworld map from a battle, on the first overworld frame the game loads the names of the city and the gym leader to be shown on the gym statue. This is done by a function call in the gym's map script.[2] However, in Japanese Red and Green only, and in Saffron Gym only, this "call" instruction is erroneously replaced by a "jp" instruction. This means that, on the first overworld frame, the meta-map script is skipped.

Normally, the meta-map script ID immediately after a trainer battle in the gym is either 2 (EndTrainerBattle) or 3 (special script for ending the gym leader battle), and both serve some important purposes:

  • If the player won, the meta-map script will set the flag for beating the trainer. In the case of the gym leader battle, it will also give out the badge and TM award, and set the flags for beating the gym and for beating everyone else in the gym.
  • No matter whether the player won or lost, the meta-map script will reset the meta-map script ID to 0, so that it would not execute again.

Therefore it is important that this meta-map script executes before the player can talk to the trainer again or death-warp away. In particular, when the player blacks out, the game executes the map script for exactly one more overworld frame, precisely for this purpose.

However, due to the flaw in the map script of Saffron Gym, it fails to call the meta-map script the first time. Therefore:

  • If the player won, the player gets the chance to talk to the same trainer again before the meta-map script sets the "trainer beaten" flag. Therefore the player can rematch trainers indefinitely.
  • If the player lost, the player will death-warp away before the meta-map script could reset to 0. Since the meta-map script determines whether the player lost by checking whether wIsInBattle is 0xFF, and wIsInBattle is reset to 0 after the player death-warps, the next time the player enters the gym, the meta-map script will execute and erroneously believe that the player has won.

Trivia

  • Even though the "loss becomes victory" part of this glitch has been known since as early as 2014[3], the "infinite rematch exploit" part was only discovered in 2019, when a speedrunner named Zweiteturm accidentally fought Sabrina twice on a JP Red Classic run.
  • The discovery of the infinite rematch exploit gave rise to the speedrun category "Sabrina%", where the goal is simply to beat Sabrina 100 times.[4]

References