User:Bbbbbbbbba/SRAM glitch/Timing ananlysis

From Glitch City Wiki
Jump to navigation Jump to search

This is a detailed analysis of the timings involved in the SRAM glitch.

Sequence of events

The following sequence omits some details that take much less than 1 frame, and thus have a negligible effect on the timings. (As a WIP, this list may not contain all events that do have a non-negligible effect.)

  • The player presses A to the "Yes/No" dialog box with the prompt "Would you like to SAVE the game?"
  • After receiving the input, the game delays for 15 frames before actually exiting the menu.[1]
  • The "Yes/No" dialog box disappears.
  • On Yellow, the game delays unconditionally for 10 frames here.[2]
  • The game checks whether there is an existing valid save file according to the wSaveFileStatus variable.
    • If there is, the game checks whether the Trainer ID in the save file is different from the current one, which for some reason involves checking the checksum of the save file[3] (which should have already been checked when first trying to load the save file).
    • If the game determines that the save file is from a different playthrough, then it displays another "Yes/No" dialog box with the prompt "The older file will be erased to save. Okay?". After the player presses A to this dialog box, there is again a 15 frame delay before the dialog box disappears.
  • The game calls three functions, each saving a part of the game.
    • The first function saves everything except the party data, and checksums the save file.
    • The second function saves the current box data, and checksums the save file. (This actually does nothing here because the current box data is already saved by the first function.)
    • The third function saves the party data, the Pokédex data, and (in Yellow) Pikachu's happiness and mood, and checksums the save file.
  • The text changes to "Now saving..." (Red/Blue) or "Saving..." (Yellow).
    • On Red/Blue the "Now saving..." text is displayed with PlaceString and appears instantly, but on Yellow the "Saving..." text is printed with PrintText and thus text delay applies.
  • The game delays for 120 (Red/Blue) or 128 (Yellow) frames doing nothing.
  • The game prints the "<Player> saved the game!" text.

YouTube videos

On Pokémon Blue:

YouTube video by stringflow


On Pokémon Yellow:

YouTube video by stringflow


References