Safari Zone exit glitch

From Glitch City Wiki
Jump to navigation Jump to search
PRAMA Initiative a également une page sur Safari Zone exit glitch.
Bulbapedia also has an article about Safari Zone exit glitch.

The Safari Zone exit glitch, commonly known as the Glitch City glitch is a glitch in Pokémon Red, Blue, and Yellow that happens when the player runs out of Safari Zone steps while being outside the Safari Zone. This changes the destination of the exit in the Safari Zone gate, causing the player to either step out of a certain building or into a wrong warp Glitch City.

In order to trigger this glitch, the player need to first escape the Safari Zone without resetting the "in Safari Zone" flag. There are two natural ways to do this, one exploiting a flaw in the map script of the Safari Zone entrance, and one exploiting the fact that poison can cause the player to black out in the overworld. The first method works in both Red/Blue and Yellow, while the poison-based method is fixed in Yellow, and thus only works in Red/Blue.

Being warped to the Safari Zone entrance while being outside the Safari Zone is an effect that can be exploited in itself, most notably for walking through walls (either with the ledge method or the museum guy method). The Glitch City can also be exploited for Glitch City RAM manipulation (Cut abuse).

Explanation

When the player performs this glitch, the memory address $D365 (the exit location for certain warps) is changed to something other than Fuchsia City (007) in a number of instances. It is normally the expected exit location, though flying to a place also updates D365 to the value of that location.

  1. When you fly to a place.
  2. When you enter a cave entrance/exit.
  3. When you enter the Summer Beach house (Yellow only).
  4. When you enter a gate.
  5. When you enter an Underground Path entrance/exit
  6. When you enter the Power Plant.
  7. When you enter the Pokémon Center on Route 4.
  8. When you go from one route to another (indoor places don't count as a second route). Though the change is not immediate, it happens when you are sent back to the Safari Zone gate.

Whenever the player enters the south warp of the Safari Zone gate, the game places the player in 'exit point' hex:04. For Fuchsia City, this is valid, and it has the player walk out of the Safari Zone building.

For other maps for D365, exit point hex:04 may also be valid, for example, after the player performs the Safari Zone exit glitch with Cerulean City they will step outside of the Bike Shop and no Glitch City will be caused. There may not be a valid exit point hex:04 for maps such as Sea Route 20 though, so the game may load a Glitch City after trying to use the invalid exit point data.

These Glitch Cities are not unique 'glitch areas', but rather glitchy versions of existing maps. This can be confirmed by tracking the memory address $D35E (the current map location) or viewing the Town Map; the location or location name will be the same as the location you were in before the PA called you to say your Safari Zone time was over.

Escaping from the Safari Zone

The reason steps 2–4 allows you to leave the Safari Zone without properly ending the Safari game is due to an oversight in the Safari Zone entrance overworld script.

In Gen I, the game keeps track of a script ID for almost every overworld map. The script ID indicates the "status" of that specific map (e.g. whether the player is being seen by a trainer), and determines the overworld script that runs every frame when the player is in that map. The piece of script responsible for asking the player "leave early?" when the player tries to do so is script #5 in the Safari Zone entrance. A "yes" answer would end the Safari game properly, make the player walk out, and change the script ID back to 0 (the initial state). A "no" answer is supposed to make the player return to the Safari Zone, and leave the script ID at 5 (so that the player is asked again if they try to leave again).

However, the script makes the player walk in both cases, and "player being forced to walk" is another status that needs to have its own script ID. Hence in both cases, the script ID is actually changed to 6, with the script ID that should come afterwards (either 0 or 5) stored in memory address $CF0D. When the auto walk ends, script #6 reads the value in memory address $CF0D and assigns it to the script ID.

The oversight is that moving up will return the player to the Safari Zone first, which is a separate map, so the Safari Zone entrance script ID is stuck at 6 until the player walks back out. Normally, the script correctly read out the value 5 from CF0D and everything is fine. But the value of CF0D is not saved with the save file, and reverts to 0 upon reset. Therefore the script will erroneously change the script ID to 0, allowing the player to get the welcome message by walking down to the desk, and answer "no" to leave.

End game warp outside of the Safari Zone

See also: https://github.com/pret/pokered/blob/bbb0e7e82deb6741f75a12b48f81076d92f5d9dc/engine/events/hidden_objects/safari_game.asm

Usually, entering the Safari Zone sets bit 0x7 (0x80) to $D790 ($D78F in Yellow). This flag is responsible for displaying the message that the Safari Zone game is over if the player has no remaining steps ($D70D-$D70E ($D70C-$D70D in Yellow)) and/or Safari Balls ($DA47 ($DA46 in Yellow)). It is also responsible for reducing the remaining steps in memory as the player walks around. Leaving the Safari game the normal way resets $D780/D78F, however since the script was reset to the welcome message it remains at 0x80. Furthermore, Game Freak decided not to check directly if the player is actually in the Safari Zone map, meaning as long as this flag is set and there are no Safari Balls and/or steps the player will warp back to the gate.

Steps

Step 1:

Enter the Safari Zone.

Step 2:

The player must then try to leave. When the man at the desk asks if them want to leave early, they should say no. The player's character will automatically walk back into the Safari Zone.

Step 3:

Once inside, the player must save the game.

Step 4:

The player should then restart their console, and attempt to leave the Safari Zone again. If the trick worked, the man at the desk should say what he normally says when players try to enter the Safari Zone. The player should, at this point, say no; they should then exit the gatehouse.

Step 5:

The player must then go somewhere else (outside of Fuchsia City), updating D365 (exit location) in one of the ways mentioned above in the explanation section and walk around for a while. After 500 steps, the PA will sound: "Ding-dong!" just as if the player were still in the Safari Zone. The player will then be returned to the Safari Zone building, regardless of where they were before.

Step 6:

When the player exits the gatehouse, they will find themselves walking out of a certain warp for the D365 map, or a Glitch City. All Glitch Cities differ based on the location you were when the time ran out, but going from one indoor map to another will not change the location.

Alternative method

In Pokémon Red and Blue, you can enter the Safari Zone with just a poisoned Pokémon (ideally one with Fly) and black out, to get the PA message out of the Safari Zone after you finish walking the remaining steps. This trick was patched in Pokémon Yellow[1], which makes the game think that you're no longer in the Safari Zone after you black out there.

See also

References