Retire glitch

From Glitch City Wiki
Bulbapedia also has an article about Retire glitch.

The Retire glitch (also known as the Pal Park Retire glitch) is a glitch derivative of Tweaking. It was documented by Ganix, formerly known as Cryo, on January 10, 2017.

RETIRE appearing in the void

By entering the void, then traveling through RAM until you enter Map 0x00FB (251) Pal Park, a mapscript will run. The player is granted a Menu, which has the RETIRE function on it, similarly to the Menu granted in the Great Marsh.

It also sets a flag that accounts for the Encounters, making sure you can only encounter wild Pokémon (on grass, water, cave and pond tiles) that you have transfered from gen 3. If none are present, you cannot encounter wild Pokémon. This does not apply to static battles (Drifloon, legendaries, berry trees).

The RETIRE glitch occurs when pressing the RETIRE function. The sourcecode shown was provided by Ganix.

int StartMenu_RETIRE(int wptr) {

 int wdata;
 int wmenu;
 int flagptr;
 wdata = GetOverworldDataAddress(wptr);
 wmenu = GetOverworldStruct(wptr);
 //-----------------------------------------------------------------------
 // Close the start menu
 //-----------------------------------------------------------------------
 Function_2035718(wmenu);
 Function_200ccf8(wmenu, 1);
 Function_201ac68(*wmenu, *(wmenu + 4));
 Function_2019178(wmenu);
 Function_20358a0(wptr);
 flagptr = LoadFlagAddress(*(wdata + 12));
 //-----------------------------------------------------------------------
 // Check if the Great Marsh flag (0x967) is set.
 //-----------------------------------------------------------------------
 if (CheckFlag(flagptr, 0x967))
 {
   //---------------------------------------------------------------------
   // When script 0x2275 is run, it asks if you want to exit Great Marsh.
   //
   // Answering YES clears flag 0x967 and quits the Safari game.
   //---------------------------------------------------------------------
   RunScript(wptr, 0x2275u, 0);
 }
 //-----------------------------------------------------------------------
 // Pal Park's flags SHOULD have been explicitly checked here, but the
 // fact that they weren't is why the RETIRE glitch is possible.
 //-----------------------------------------------------------------------
 else
 {
   //---------------------------------------------------------------------
   // While script 0x2275 references a defined script number, lower
   // numbers such as this reference scripts relative to the current map's
   // script runtime.
   //
   // scripts in runtime from a map then goes to a defined script. This means 
   // that the script is based on what map you use the menu in, and what the  
   // 4th script is.
   //---------------------------------------------------------------------
   RunScript(wptr, 4, 0);
 }
 free(wmenu);
 return 0;

}

It first checks for flag 0x0967, a flag set when entering the Great Marsch, if set, it runs script 0x2275 and asks to leave the Safari Zone.

Otherwise, it runs the 4th script in runtime. In normal circumstances it cannot be used outside of Pal Park's Map, where it would be:

       Script 4:
           Fanfare 1500 
           Lockall 
           Message 8                 "Would you like to retire?"
           Yesnobox 32780 
           CloseMsgOnKeyPress 
           If 32780 0 
           CheckLR 1 func_2 
           Releaseall 
           End 

with func_2 being

       Func 2:
           Setvar 16627 2 
           Releaseall 
           Goto func_1 
           End 

And func_1 being

       Func 1:
           StopGreatMarsh 1 
           Fadescreen 6 1 0 0 
           Resetscreen 
           Warp 393 0 7 7 1 
           Fadescreen 6 1 1 0 
           Resetscreen 
           Killscript 

In this case, pressing YES would warp you to Map 0x0189 (393).

Once out of bounds, you can use it in any map you'd like, running 4th script in runtime in any Map.

A year later an alternative was found by glitchologist Aera (yem), called alt-RETIRE. By transfering 6 Pokémon from gen 3 and being in Pal Park mode, then catching all 6, the game would run 3rd script un runtime.

    Script 3:
           Fanfare 1500 
           Lockall 
           Fanfare 1521 
           Setvarhero 0 
           Message 5                 "Ding-dong!
                                      Congratulations!
                                      \v0103\z0000 has successfully
                                      caught the stocked Pokémon!"
           PlaySound 1002 
           Soundfr 1158 
           Fadedef 
           CloseMsgOnKeyPress 
           Releaseall 
           Setvar 16627 1 
           Goto func_1 
           End 

with func_1 (still) being

   FUNCTIONS:
       Func 1:
           StopGreatMarsh 1 
           Fadescreen 6 1 0 0 
           Resetscreen 
           Warp 393 0 7 7 1 
           Fadescreen 6 1 1 0 
           Resetscreen 
           Killscript 

Since the flag set by the mapscript made the game ignore all encountertables to only encounter the transfered Pokémon, this meant you could call 3rd script in runtime too. At the time, it wasn't quite that useful since it was limited to areas where we could find grass/water, and a small area in the void called 'Black Sinnoh', where these tiles are naturally read from RAM.

A year later the glitchologist RETIRE found a way to manipulate tiles in the void, allowing to write any tile by chaining gfx set changes (by opening menus in specific maps) and for specific tiles manipulating ASLR too. Now you could call 3rd script in runtime in any map.

The glitch is most known for its use in the Hall of Origin, which allows for the player to battle Arceus.

This article or section is a stub. You can help Glitch City Wiki by expanding it.