Difference between revisions of "G-Mode Save Station"

From A complete guide to Super Metroid speedrunning
Jump to: navigation, search
(Created page with "During G-Mode, the game behaves in some ways as though X-ray scope were still active. The most noticeable are that the game does not process PLMs or projectiles. Stepping...")
 
(Functioning)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
During [[G-Mode]], the game behaves in some ways as though X-ray scope were still active. The most noticeable are that the game does not process PLMs or projectiles. Stepping on a save station in G-Mode can execute a wide amount of code, most often crashing the game if done blindly, but can grant Samus items. This is used in the [[Glitched RBO]] world record route to obtain Gravity Suit.
+
During [[G-Mode]], the game behaves in some ways as though X-ray scope were still active. The most noticeable are that the game does not process PLMs or projectiles. Stepping on a save station in G-Mode, and subsequently activating X-Ray to leave G-Mode, can execute a wide amount of code, most often crashing the game if done blindly, but can grant Samus any item in the game. This is used in the [[Glitched RBO]] world record route to obtain Gravity Suit.
  
 
== Functioning ==
 
== Functioning ==
  
The game stores lists for each PLM, located in bank $84, of pointers to functions, and arguments for those functions. These are called instruction lists. There is a section of RAM from $1D27 through $1D76 where the game loads these pointers for running functions related to processing PLMs. For the save station, the pointer is loaded into $1D75 (probably because the game starts at the top of this range and works downwards. Since save rooms have two PLMs that are processed when entering the room: first the door, and then the save station. TODO: fact check this). In G-Mode PLMs aren't processed, and when Samus steps on the save station, $1D75 starts increasing by $02 every other frame, starting with whatever PLM instruction the game was last trying to execute. When entering a save room, $1D75 will contain $AFEC, which is the sleep instruction.
+
The game stores lists for each PLM, located in bank $84, of pointers to functions, and arguments for those functions. These are called instruction lists. There is a section of RAM from $1D27 through $1D76 where the game loads these pointers for running functions related to processing PLMs. For the save station, the pointer is loaded into $1D75 (the game starts at the top of this range and works downwards. Since save rooms have two PLMs that are processed when entering the room: first the door, and then the save station). In G-Mode PLMs aren't processed, and when Samus steps on the save station, $1D75 starts increasing by $02 every other frame, starting with whatever PLM instruction the game was last trying to execute. When entering a save room, $1D75 will contain $AFEC, which is a pointer to a sleep instruction (save station does nothing until Samus attempts to interact with it).
  
When X-Ray is activated, and G-Mode left, the game will look at whatever value is in $1D75, and interpret those two bytes as a location in bank $84. This means for items, you'll need to stop on a correct byte in order to be granted the item. Every item in the game has three variants: normal, hidden, and in a chozo orb, and either of these will work for obtaining the item. However, they are so far apart in the ROM that it is irrelevant. Therefore, using the one that appears first in the ROM (the normal, not hidden or orb variant) makes the most sense, since the game will either crash or do something else unexpected if X-Ray is not pressed in the two-frame window.
+
After stepping on a save station in G-Mode, and X-Ray is activated, and G-Mode left, the game will look at whatever value is in $1D75, and interpret those two bytes as a location of a pointer in bank $84. For collecting items, you'll need to stop on a correct byte in order to be granted the item (see list below). Every item in the game has three variants: normal, hidden, and in a chozo orb; and either of these will work for obtaining the item. However, the instruction lists for these variants are so far apart in the ROM that it is irrelevant. Therefore, using the one that appears first in the ROM (the normal, not hidden or orb variant) makes the most sense. The game will either crash or do something else unexpected if X-Ray is not pressed in the two-frame window. It can also matter how long the dash button is held down to activate X-Ray.
  
 +
It is also possible to spawn energy refill and map stations (though unusable as they will spawn too close to the floor, on the left tile of the bottom of the save station), Samus Eaters (Vileplumes), shot blocks, door caps, and basically any other PLM. It is also possible to execute a lot of other code, with mostly unknown or undocumented results (or most likely, a crash).
 +
 +
Because $1D75 increases by two every frame (or every other frame if standing half on the save station PLM) and starts on an even address, it is only possible to execute instructions whose pointers exist at an even address.
 +
 +
{{#ev:youtube|SK9f3uXvFjs}}
 +
 +
== Executing ==
 +
 +
The save station platform is made of 2 blocks, the one on the right is solid, while the one on the left is the PLM block. There are two ways to stand on the save station platform to make the PLM value change: 
 +
 +
# land solely on the left block to make the PLM value advance by 2 every frame: AFEC, AFEE, AFF0, AFF2, AFF4, AFF6, ... 
 +
# land in the middle of the platform, which makes the PLM value advance by 2 every 2 frames: AFEC, AFEE, AFEE, AFF0, AFF0, AFF2, AFF2, AFF4, AFF4, AFF6, AFF6, ...
 +
 +
Given a certain wanted value, say E2F6, the number of values between that and AFEC is 330A, or 13066 in decimal. For 1), those values are covered twice per frame, so it takes 6533 frames to reach the address wanted, and it is a frame-perfect trick. For 2), it takes twice as long to reach that same value, 13066 frames, but it has a 2-frame window since the next frame would also have the same value. Landing in the proper position can be made easier using normalized movement, such as a buffered spin jump or using a bomb. 
 +
 +
To end G-mode and execute the value, X-ray must be activated. For case 1), the X-ray activation can be done right there on top of the block, and the correct value will be run provided the correct frame. For case 2), due to the collision oscillator and possibly other reasons, activating X-ray in the middle of the platform can execute the next value sometimes; therefore, it is recommended to jump out of the platform in the correct frame, and only then activate X-ray (alternatively, hold an angle in the correct frame, walk off the platform, and only then activate X-ray). To properly activate X-ray or jump, visual cues can be used, like auto-firing shots or using a timer; reaction time and input delay matter, which means going for some frames earlier.
 +
 +
Activating X-ray for exactly 4 frames can have unintended consequences, like spawning extra (including bad-transition) blocks out of bounds. For most uses, it is recommended to activate X-ray for more than 4 frames.
  
 
== Relevant Locations ==
 
== Relevant Locations ==
  
$1D27 through $1D75 in RAM, though $1D75 seems to be the relevant address.
+
In RAM, $1D27 through $1D76 are related to this glitch, though $1D75 seems to be the more relevant address. After entering the room, its value stays at 'AFEC' (hexadecimal).
 +
 
 +
=== Pointer locations for collecting items ===
 +
 
 +
When watching $1D75 in RAMwatch, it should contain the following location in order to obtain the item
 +
 
 +
<nowiki>
 +
Energy Tank    $E0B6
 +
Missile         $E0D6
 +
Super Missile  $E100
 +
Power Bomb      $E120
 +
Bomb $E152
 +
Charge Beam $E180
 +
Ice Beam $E1AE
 +
Hi-Jump Boots $E1DC
 +
Speed Booster $E20A
 +
Wave Beam $E238
 +
Spazer $E266
 +
Spring Ball $E294
 +
Varia Suit $E2C8
 +
Gravity Suit $E2F6
 +
Plasma Beam $E358
 +
Grapple Beam $E386
 +
Space Jump $E3B8
 +
Screw Attack $E3E6
 +
Morphing Ball $E414
 +
Reserve Tank $E442
 +
</nowiki>
 +
 
 +
=== Out of Bounds ===
 +
 
 +
Some of the values will promote big "block-shuffles", which effectively puts Samus OoB and spawns a bunch of different blocks. This can be used, for example, in [[Any% Glitched]]. Some of the earlier values that can be used for this are: B020, B022, and B024.
 +
 
 +
TODO: add other pointer locations that are known to at least do something other than crash, or potentially could do something useful.
 +
 
 +
== External Links ==
  
Bank $84 instruction list locations for individual items. Note that the value shown at left is not the correct pointer address to watch for in RAM but the start of the list, nor is it the PLM ID number shown at right. The pointer to collect the item is near the end of each list and is $88F3 (pointer to the function $8488F3, which collects the item and displays the message box), followed by two bytes for the equipment value, and one byte for the message box number.
+
[[https://patrickjohnston.org/bank/84 Bank log for $84]]
  
    ;;; $E099: Instruction list - PLM $EED7 (energy tank) ;;;
+
[[https://youtu.be/SK9f3uXvFjs?si=FaQ7GGX3kjyH99Y4/bank/G-MODE Save Station Tutorial - Get the Gravity Suit]]
    ;;; $E0BE: Instruction list - PLM $EEDB (missile tank) ;;;
 
    ;;; $E0E3: Instruction list - PLM $EEDF (super missile tank) ;;;
 
    ;;; $E108: Instruction list - PLM $EEE3 (power bomb tank) ;;;
 
    ;;; $E12D: Instruction list - PLM $EEE7 (bombs) ;;;
 
    ;;; $E15B: Instruction list - PLM $EEEB (charge beam) ;;;
 
    ;;; $E189: Instruction list - PLM $EEEF (ice beam) ;;;
 
    ;;; $E1B7: Instruction list - PLM $EEF3 (hi-jump) ;;;
 
    ;;; $E1E5: Instruction list - PLM $EEF7 (speed booster) ;;;
 
    ;;; $E213: Instruction list - PLM $EEFB (wave beam) ;;;
 
    ;;; $E241: Instruction list - PLM $EEFF (spazer beam) ;;;
 
    ;;; $E26F: Instruction list - PLM $EF03 (spring ball) ;;;
 
    ;;; $E29D: Instruction - clear charge beam counter ;;;
 
    ;;; $E2A1: Instruction list - PLM $EF07 (varia suit) ;;;
 
    ;;; $E2D6: Instruction list - PLM $EF0B (gravity suit) ;;;
 
    ;;; $E30B: Instruction list - PLM $EF0F (x-ray scope) ;;;
 
    ;;; $E338: Instruction list - PLM $EF13 (plasma beam) ;;;
 
    ;;; $E366: Instruction list - PLM $EF17 (grapple beam) ;;;
 
    ;;; $E393: Instruction list - PLM $EF1B (space jump) ;;;
 
    ;;; $E3C1: Instruction list - PLM $EF1F (screw attack) ;;;
 
    ;;; $E3EF: Instruction list - PLM $EF23 (morph ball) ;;;
 
    ;;; $E41D: Instruction list - PLM $EF27 (reserve tank) ;;;
 
    ;;; $E44A: Instruction list - PLM $EF2B (energy tank, chozo orb) ;;;
 
    ;;; $E47C: Instruction list - PLM $EF2F (missile tank, chozo orb) ;;;
 
    ;;; $E4AE: Instruction list - PLM $EF33 (super missile tank, chozo orb) ;;;
 
    ;;; $E4E0: Instruction list - PLM $EF37 (power bomb tank, chozo orb) ;;;
 
    ;;; $E512: Instruction list - PLM $EF3B (bombs, chozo orb) ;;;
 
    ;;; $E54D: Instruction list - PLM $EF3F (charge beam, chozo orb) ;;;
 
    ;;; $E588: Instruction list - PLM $EF43 (ice beam, chozo orb) ;;;
 
    ;;; $E5C3: Instruction list - PLM $EF47 (hi-jump, chozo orb) ;;;
 
    ;;; $E5FE: Instruction list - PLM $EF4B (speed booster, chozo orb) ;;;
 
    ;;; $E63B: Instruction - FX Y velocity = FFE0h ;;;
 
    ;;; $E642: Instruction list - PLM $EF4F (wave beam, chozo orb) ;;;
 
    ;;; $E67D: Instruction list - PLM $EF53 (spazer beam, chozo orb) ;;;
 
    ;;; $E6B8: Instruction list - PLM $EF57 (spring ball, chozo orb) ;;;
 
    ;;; $E6F3: Instruction list - PLM $EF5B (varia suit, chozo orb) ;;;
 
    ;;; $E735: Instruction list - PLM $EF5F (gravity suit, chozo orb) ;;;
 
    ;;; $E777: Instruction list - PLM $EF63 (x-ray scope, chozo orb) ;;;
 
    ;;; $E7B1: Instruction list - PLM $EF67 (plasma beam, chozo orb) ;;;
 
    ;;; $E7EC: Instruction list - PLM $EF6B (grapple beam, chozo orb) ;;;
 
    ;;; $E826: Instruction list - PLM $EF6F (space jump, chozo orb) ;;;
 
    ;;; $E861: Instruction list - PLM $EF73 (screw attack, chozo orb) ;;;
 
    ;;; $E89C: Instruction list - PLM $EF77 (morph ball, chozo orb) ;;;
 
    ;;; $E8D7: Instruction list - PLM $EF7B (reserve tank, chozo orb) ;;;
 
    ;;; $E911: Instruction list - PLM $EF7F (energy tank, shot block) ;;;
 
    ;;; $E949: Instruction list - PLM $EF83 (missile tank, shot block) ;;;
 
    ;;; $E981: Instruction list - PLM $EF87 (super missile tank, shot block) ;;;
 
    ;;; $E9B9: Instruction list - PLM $EF8B (power bomb tank, shot block) ;;;
 
    ;;; $E9F1: Instruction list - PLM $EF8F (bombs, shot block) ;;;
 
    ;;; $EA32: Instruction list - PLM $EF93 (charge beam, shot block) ;;;
 
    ;;; $EA73: Instruction list - PLM $EF97 (ice beam, shot block) ;;;
 
    ;;; $EAB4: Instruction list - PLM $EF9B (hi-jump, shot block) ;;;
 
    ;;; $EAF5: Instruction list - PLM $EF9F (speed booster, shot block) ;;;
 
    ;;; $EB36: Instruction list - PLM $EFA3 (wave beam, shot block) ;;;
 
    ;;; $EB77: Instruction list - PLM $EFA7 (spazer beam, shot block) ;;;
 
    ;;; $EBB8: Instruction list - PLM $EFAB (spring ball, shot block) ;;;
 
    ;;; $EBF9: Instruction list - PLM $EFAF (varia suit, shot block) ;;;
 
    ;;; $EC41: Instruction list - PLM $EFB3 (gravity suit, shot block) ;;;
 
    ;;; $EC89: Instruction list - PLM $EFB7 (x-ray scope, shot block) ;;;
 
    ;;; $ECC9: Instruction list - PLM $EFBB (plasma beam, shot block) ;;;
 
    ;;; $ED0A: Instruction list - PLM $EFBF (grapple beam, shot block) ;;;
 
    ;;; $ED4A: Instruction list - PLM $EFC3 (space jump, shot block) ;;;
 
    ;;; $ED8B: Instruction list - PLM $EFC7 (screw attack, shot block) ;;;
 
    ;;; $EDCC: Instruction list - PLM $EFCB (morph ball, shot block) ;;;
 
    ;;; $EE0D: Instruction list - PLM $EFCF (reserve tank, shot block) ;;;
 

Latest revision as of 06:31, 18 April 2024

During G-Mode, the game behaves in some ways as though X-ray scope were still active. The most noticeable are that the game does not process PLMs or projectiles. Stepping on a save station in G-Mode, and subsequently activating X-Ray to leave G-Mode, can execute a wide amount of code, most often crashing the game if done blindly, but can grant Samus any item in the game. This is used in the Glitched RBO world record route to obtain Gravity Suit.

Functioning

The game stores lists for each PLM, located in bank $84, of pointers to functions, and arguments for those functions. These are called instruction lists. There is a section of RAM from $1D27 through $1D76 where the game loads these pointers for running functions related to processing PLMs. For the save station, the pointer is loaded into $1D75 (the game starts at the top of this range and works downwards. Since save rooms have two PLMs that are processed when entering the room: first the door, and then the save station). In G-Mode PLMs aren't processed, and when Samus steps on the save station, $1D75 starts increasing by $02 every other frame, starting with whatever PLM instruction the game was last trying to execute. When entering a save room, $1D75 will contain $AFEC, which is a pointer to a sleep instruction (save station does nothing until Samus attempts to interact with it).

After stepping on a save station in G-Mode, and X-Ray is activated, and G-Mode left, the game will look at whatever value is in $1D75, and interpret those two bytes as a location of a pointer in bank $84. For collecting items, you'll need to stop on a correct byte in order to be granted the item (see list below). Every item in the game has three variants: normal, hidden, and in a chozo orb; and either of these will work for obtaining the item. However, the instruction lists for these variants are so far apart in the ROM that it is irrelevant. Therefore, using the one that appears first in the ROM (the normal, not hidden or orb variant) makes the most sense. The game will either crash or do something else unexpected if X-Ray is not pressed in the two-frame window. It can also matter how long the dash button is held down to activate X-Ray.

It is also possible to spawn energy refill and map stations (though unusable as they will spawn too close to the floor, on the left tile of the bottom of the save station), Samus Eaters (Vileplumes), shot blocks, door caps, and basically any other PLM. It is also possible to execute a lot of other code, with mostly unknown or undocumented results (or most likely, a crash).

Because $1D75 increases by two every frame (or every other frame if standing half on the save station PLM) and starts on an even address, it is only possible to execute instructions whose pointers exist at an even address.

Executing

The save station platform is made of 2 blocks, the one on the right is solid, while the one on the left is the PLM block. There are two ways to stand on the save station platform to make the PLM value change: 

  1. land solely on the left block to make the PLM value advance by 2 every frame: AFEC, AFEE, AFF0, AFF2, AFF4, AFF6, ... 
  2. land in the middle of the platform, which makes the PLM value advance by 2 every 2 frames: AFEC, AFEE, AFEE, AFF0, AFF0, AFF2, AFF2, AFF4, AFF4, AFF6, AFF6, ...

Given a certain wanted value, say E2F6, the number of values between that and AFEC is 330A, or 13066 in decimal. For 1), those values are covered twice per frame, so it takes 6533 frames to reach the address wanted, and it is a frame-perfect trick. For 2), it takes twice as long to reach that same value, 13066 frames, but it has a 2-frame window since the next frame would also have the same value. Landing in the proper position can be made easier using normalized movement, such as a buffered spin jump or using a bomb. 

To end G-mode and execute the value, X-ray must be activated. For case 1), the X-ray activation can be done right there on top of the block, and the correct value will be run provided the correct frame. For case 2), due to the collision oscillator and possibly other reasons, activating X-ray in the middle of the platform can execute the next value sometimes; therefore, it is recommended to jump out of the platform in the correct frame, and only then activate X-ray (alternatively, hold an angle in the correct frame, walk off the platform, and only then activate X-ray). To properly activate X-ray or jump, visual cues can be used, like auto-firing shots or using a timer; reaction time and input delay matter, which means going for some frames earlier.

Activating X-ray for exactly 4 frames can have unintended consequences, like spawning extra (including bad-transition) blocks out of bounds. For most uses, it is recommended to activate X-ray for more than 4 frames.

Relevant Locations

In RAM, $1D27 through $1D76 are related to this glitch, though $1D75 seems to be the more relevant address. After entering the room, its value stays at 'AFEC' (hexadecimal).

Pointer locations for collecting items

When watching $1D75 in RAMwatch, it should contain the following location in order to obtain the item

Energy Tank     $E0B6
Missile	        $E0D6
Super Missile   $E100
Power Bomb      $E120
Bomb 		$E152
Charge Beam 	$E180
Ice Beam	$E1AE
Hi-Jump Boots 	$E1DC
Speed Booster	$E20A
Wave Beam	$E238
Spazer		$E266
Spring Ball	$E294
Varia Suit	$E2C8
Gravity Suit	$E2F6
Plasma Beam	$E358
Grapple Beam	$E386
Space Jump	$E3B8
Screw Attack	$E3E6
Morphing Ball	$E414
Reserve Tank	$E442

Out of Bounds

Some of the values will promote big "block-shuffles", which effectively puts Samus OoB and spawns a bunch of different blocks. This can be used, for example, in Any% Glitched. Some of the earlier values that can be used for this are: B020, B022, and B024.

TODO: add other pointer locations that are known to at least do something other than crash, or potentially could do something useful.

External Links

[Bank log for $84]

[Save Station Tutorial - Get the Gravity Suit]