A Link to the Past
Shelf Shift
Shelf shift or dungeon ID swap is a trick involving the throne room door that normally moves Link between Hyrule Castle and the Sewers. The game considers these two as separate dungeons, and walking through this door updates a value in the game's memory to change the dungeon from Hyrule Castle to Sewers. With the use of glitches, players can access this door from dungeons other than the intended Hyrule Castle and Sewer pairing, allowing them to manipulate what dungeon the game considers Link to be in.
Technical explanation
When Link walks through the north door in the throne room in Hyrule Castle, the game exclusive-ORs the dungeon ID by 2 to get a new dungeon ID. Hyrule Castle's dungeon ID is 2, and 2 xor 2 == 0, so the new dungeon ID will be 0, which is the ID for the Sewers. This is the only door in the underworld that's capable of changing the dungeon that Link is in.
Through using glitches, Link can access this door from other dungeons, and when he walks through it, the same process will take place. Because there are an even number of dungeons, dungeons' IDs are even numbers, and the IDs increase linearly, every dungeon is effectively "paired" with another dungeon. Hyrule Castle is paired with the Sewers for example. 2 xor 2 == 0 and 0 xor 2 == 2. Turtle Rock has dungeon ID 24. 24 xor 2 == 26, and 26 is the dungeon ID for Ganon's Tower. 26 xor 2 == 24, so TR and GT are another pairing.
There's a wrinkle with cave state. If Link is in a cave or house, his dungeon ID will be 0xFF, or 255 in decimal. If the player is in a cave and then uses glitches to reach the throne room door, using the door will set the dungeon ID to 0xFD, a value that was never meant to occur. This is known as xor cave or fd state, and more information can be found about it on the cave state page.
Pairs
- Hyrule Castle and Sewers
- Eastern Palace and Desert Palace
- Castle Tower and Swamp Palace
- Palace of Darkness and Misery Mire
- Skull Woods and Ice Palace
- Tower of Hera and Thieves' Town
- Turtle Rock and Ganon's Tower
- Regular cave and XOR cave
Applications in swordless speedruns
In all dungeon speedruns that don't collect a sword, Miser Mire must be completed without the use of the Ether Medallion. Ether can be collected without a sword, but it (and any of the other medallions) cannot be used without a sword. There is no known way to overcome this constraint, and the only way to enter Misery Mire from the overworld is to use Ether to unlock it.
The solution to this problem is to shelf shift starting from Palace of Darkness, which is Mire's throne room door pair. This will allow the player to obtain the Misery Mire crystal without ever needing to enter the dungeon from the overworld.
