Pokémon Red any% speedrun route

From Glitch City Wiki
Jump to navigation Jump to search

The current Pokémon Red any% speedrun route is based on the SRAM glitch. The bulk of the run is a series of carefully designed swaps in both the expanded party and the item pack, which end up warping the player to the Hall of Fame (more precisely, running the part of the Hall of Fame script that displays the player's party and Trainer information, and then jumps to the credits).

Short as it is, the route uses a single luck manipulation for a desirable Trainer ID, which is used to spell out a ROM address as the current map script. This luck manipulation is not essential to this category, since the player can also get the byte values needed from other memory regions. However, doing this luck manipulation is the fastest strategy due to the following reasons:

  • By RTA timing rules, the timer starts only on the last time the player selects "New Game". Therefore any time spent on Trainer ID manipulation won't count towards the run, which is a decisive advantage over having to use in-game actions to manipulate data.
  • If the timing rules were changed to include the Trainer ID manipulation, then RTA runners would be incentivized to do a "TAS manipulation" which achieves the same goal of manipulating a certain Trainer ID much faster, but involves some frame-level precise inputs. With how short the run is, such a strategy would be viable (though probably unfun for runners), and again be faster than using in-game actions to manipulate data.

The content of this page is based on the route guide on speedrun.com. Details unrelated to glitches/manipulations (i.e. for time saving only) are omitted.

Preparations

  • If there is an existing save file, clear it by pressing Up + Select + B on the title screen.
    • This is especially important for this category, since this category relies on performing a partial save with the SRAM glitch, and if there is an existing save file, the party data from that save file will be carried over to the new game. It is possible that with some carefully crafted party data, one can beat the game slightly faster by RTA timing rules, since the time used to craft that party data won't be counted. However, this is obviously against the spirit of the category, so the category rule disallows such runs by making the save file clear mandatory.
  • Manipulate for a Trainer ID of 0x64C2 (25794).
  • Name the player character RED, and the rival JOHN (both preset names).
    • Later in the run, the rival's name will be swapped into a segment of the player's item pack, which the player will need to scroll through. Among the preset names, "JOHN" causes the least lag.[1]

Save corruption

  • Perform the SRAM glitch.
  • Take 1 step down after reloading the game.
    • This changes another variable (wYBlockCoord) that the player will later need to scroll through as an item, and ends up saving several frames.[1]
  • Open the Pokémon menu. Due to the SRAM glitch, the player should have an expanded party of 255 Pokémon. Do the following swaps:
    • 11 -> 12 (i.e. swap the 11th Pokémon with the 12th Pokémon)
    • 13 -> 10
  • Open the item pack (without fully closing the Start menu). The current item count should be 16, allowing the player to swap:
    • Slot 1 (Gold Teeth) -> Slot 5 (#j. x38)
    • Slot 3 (Gold Teeth) -> Slot 13 (#j. x1, 1 below Great Ball x0)
  • Open the Pokémon menu again (again without fully closing the Start menu), and swap:
    • 17 -> 22
    • 23 -> 18
  • Close the menu. The player will be warped to the Hall of Fame.

Explanation

The table below shows the effects of the swaps in the most relevant memory region. For simplicity, in the "initial value" columns, only a few bytes that are needed to explain the route are shown. Numbers in the "swaps #1" and "swaps #2" columns correspond to numbers in the "nickname" column, and shows how the memory blocks are rearranged after each Pokémon swap. Shaded cells in the "initial value" columns indicate item slots that are involved in the item swaps, and texts with corresponding colors are the actual values that are there when the swaps happen.

Address Main data OT name Nickname Initial value Swaps #1 Swaps #2 Comments
$D16B – $D2F6 1–9 (From $D273)
1–12
(From $D2B5)
1–6
All 0xFF after the SRAM glitch Mostly unchanged All species bytes 1 involved are near the start of this region
$D2F7 – $D301 10 13 7 7 4 4 4
$D302 – $D30C 14 8 8 20 20 20
$D30D – $D317 15 9 9 21 21 21
$D318 – $D322 16 10 00 FF 00 00 00 00 10 17 17 17 Byte 6 ($D31D): the item count
$D323 – $D32D 11 17 11 00 00 00 00 00 00 00 00 00 00 00 16 16 12 12
$D32E – $D338 18 12 00 00 00 00 00 00 00 00 00 00 00 15 15 15 10
$D339 – $D343 19 13 17 22 22 22
$D344 – $D34E 20 14 18 18 18 18
$D34F – $D359 12 21 15 00 01 64 11 11 11 11 Byte 11 ($D359): the high byte of the Trainer ID
$D35A – $D364 22 16 C2 00 26 12 12 16 16 Byte 1 ($D35A): the low byte of the Trainer ID; byte 5 ($D35E): the current map ID
$D365 – $D36F 23 17 10 40 CF 40 B0 40 13 13 10 15 Byte 6–11: data, text, and script pointers (for Red's house 2F)
$D370 – $D37A 24 18 14 14 14 23
$D37B – $D385 13 25 19 19 7 7 7
$D386 – $D390 26 20 20 8 8 8
$D391 – $D39B 27 21 21 9 9 9
$D39C – $D3A6 28 22 22 10 13 13
$D3A7 – $D3B1 14 29 23 23 23 23 14
$D3B2 – $D3BC 30 24 24 24 24 24
$D3BD – $D3C7 31 25 25 25 25 25
$D3C8 – $D3D2 32 26 26 26 26 26

As an example of how to use this table, consider the value of $D36E – $D36F (the map script pointer) after all these swaps. This corresponds to the last two bytes in the row labeled "$D365 – $D36F", or "17" in the "nicknames" column (below we will call it "row 17" for short). In the intersection of this row and the last column of "swaps #2" is the number "15", which indicates that after all the swaps, the initial values that are in row 15 are swapped into row 17, and the last two bytes there are "01 64". However, the "01" is also involved in an item swap, so it should be swapped with the similarly colored byte, "C2" in row 16. Therefore, the final value of the map script pointer is "C2 64", or $64C2 in small endian.

The address $64C2 is in the banked section of the ROM, and the bank value is determined by the current map ID[2]. By a similar process, we can see that after all the swaps, the value of $D35E (the current map ID) becomes 0xCF, which means Silph Co. 2F, the map data of which is in ROM bank $16, the same bank as the Hall of Fame room. Therefore, after closing the Start menu, the game jumps to $16:64C2, which is near the beginning of the function HallofFameRoomScript2, and starts displaying the Hall of Fame team (which thankfully respects the 0xFF party terminator instead of the party count, so with the party data consisting mostly of 0xFF bytes, just displays no Pokémon). Even though this entry point messes up the stack somewhat, at the end of HallofFameRoomScript2 the game jumps to Init, which resets the stack, so everything works fine afterwards.

YouTube video

YouTube video by Pokeguy84


Trivia

  • In the TAS version of this route, an extra swap (4 -> 13) is done so that the number of Pokémon caught in the Pokédex is 64 instead of 96, which results in a shorter Prof. Oak's evaluation that doesn't need an input to clear. While by RTA timing this only saves a few frames and wouldn't be worthwhile, since traditionally TAS timing ends on the last input, this manipulation allows the movie to end as soon as the Start menu is closed, saving quite a few seconds by TAS timing[1].

References