Frozen Screw Attack patch

Very first version published to my GitHub!  It’s in my sm-attack-frozen repo.

This patch makes it so that Samus can destroy frozen enemies using Screw Attack, unless they’re immune to screw attack.  Metroids keep their original behavior, since their AI is a bit weird, and possessor enemies are a bit glitchy too.  But hey, free code.

Super Metroid: hacking the frozen enemies

I’ve been messing around in the Super Metroid code.  My main goal is to make Screw Attack destroy frozen enemies, and for style points, not destroy them when landing on them from above.  I made a CPU trace of jumping into an enemy normally, and found that in the Samus/Enemy collision code, there’s a check so that if the enemy has a freeze timer (is frozen), then it just backs out and considers it “not a collision.”  For some reason, it also skips the freeze check for enemy $DAFF, a metroid without any AI.  Which probably means that enemy is unused and checking for it is useless.

Seems straightforward, but the Samus/enemy collision code doesn’t get run in normal use with a frozen enemy!  There’s another set of collision-checking code that checks frozen enemies, does its collision detection with Samus’ predicted position for the next frame, and adds the enemy to the “enemies that may interact with Samus” list if the enemy is frozen and a collision is predicted.  (I don’t have the trace in front of me, but IIRC, non-frozen enemies skip the entire collision detection.)

I painstakingly annotated a collision-detection and nothing interesting ever happened, because it turns out, that was the horizontal code and I was colliding vertically.  So I made the table-flip gesture (yay, wasting 45 minutes) and ragequit for the night, and now I get to do it all again tonight.