Advertisement
LilPinkus

Untitled

Jun 22nd, 2019
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. Explanation of many things, some directly related to interesting things, others not.
  2. ------------------------------------------------------------------------------------
  3.  
  4. When you use your hookshot, the game will move the hookshot forward, then check for collisions with tiles every frame.
  5.  
  6. At the start of tile collision detection, it checks if $03A4,X (X = hookshot slot) is nonzero, and in that case it will check the opposite layer of where Link currently is.
  7.  
  8. $03A4,X should actually always remain zero. It's not a feature that is in vanilla, but probably leftover code for some feature or testing that was done during development. As we know, in no case can you interact with a different layer using hookshot with normal playthrough.
  9.  
  10. Completely unrelated to all of this, the boomerang has a timer ($031B,X - X = boom slot) it uses to figure out when to change the animation of the boomerang. The animation index can be found in $039F,X (X = boom slot). Basically this memory is set to either 3 (for red boom) or 2 (for blue boom), then decrements to 0, before going back to 2 or 3 again. The way it figures out if it's 2 or 3 is by looking at $0394,X (X = boom slot), which in a way decides if this is a blue or red boom.
  11.  
  12. Ok. So the hook clip works by putting the boom into slot 5-9, and then hooking from slot 0-4.
  13.  
  14. If we use slot 3 for hookshot and 8 for boom as en example:
  15.  
  16. - The boom will cycle $039F,X = $039F+8 = $03A7. It decrements this value every frame. Then if it's < 0, it sets it back to 2 or 3, depending on if it's a red/blue boom.
  17. - The hookshot tiledetection code will look at $03A4,X = $03A4+3 = $03A7 to decide whether it should use the opposite layer of Link or not for tile collision. That's the same address.
  18.  
  19. At the very start of using the hookshot in this example, it will zero out $03A7.
  20. The next frame, the boom will set it to either 2 or 3 (depends on blue or red boom, or more technically, depending on $0394,X)
  21. Since this will make $03A7 nonzero, the hookshot will do tile collision detection in the wrong layer this frame. So even if there's a wall right in front of you, if that wall is not present in the opposite layer, it won't stop.
  22. This goes on until the boom sets $03A7 to 0, which should happen after 3 or 4 frames. Once it's set to 0, the tile collision detection checks the correct layer. If a chest happens to be close to the hookshot, it will detect a hit and drag Link to it.
  23.  
  24. One other note is that $0394,X (the one that determines the cycle for red vs blue boom) can sometimes be set to strange values, since we're indexing it out of bounds by putting the boom in a high slot. In some of these cases (boom in slot 9 or red boom in slot 7 and 8 at least), the value found is a negative one. In this particular case (for example boom in slot 9, hook in slot 4) $03A4,X (or specifically in this example, $03A8) will be non-zero for all frames. The boom will decrement the "animation index" and see that it's a negative number, then set it back to a negative number again, due to $0394,X being the wrong value. In this case, the hookshot will purely do tile collision from the invalid layer. It will go past any walls in your current layer, and collide with anything in the opposite layer.
  25.  
  26. (However sometimes it doesn't and I'm still trying to figure it out.)
  27. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement