Friday, November 17, 2017

The missing animation

In his glitches and oversights series, GoldS shows us that when Tails carries Super Sonic into the Knuckles cutscene in Launch Base Zone 1, Sonic does some fancy air surfing. But what exactly is going on behind the scenes?

Well first off, Sonic is floating in mid-air because the cutscene sets Sonic's object_control attribute, in order to prevent him from jumping out of the teacup lift he usually rides in. This forces Tails to let go of Sonic, which normally triggers an obscure animation where Sonic frantically does mid-air crunches for some reason.


Now, player characters have around thirty-something animations each, and the first 31 are shared between all of them, using up IDs 0 through $1E. The "falling off Tails" animation is ID $22, making it a character-specific animation.

This makes sense considering that normally, Sonic is the only character who can be carried by Tails. However, if Sonic and Tails' Marble Garden Zone 2 boss is fought as Knuckles, Tails will carry Knuckles, and when he drops him, we can see that ID $22 corresponds to Knuckles' "getting up from glide-landing" animation:


Sonic doesn't have any special abilities like flying or climbing, so most of his character-specific animations are unused. Other than the "falling off Tails" animation, he only has the super transformation sequence, which was Sonic-exclusive until Sonic & Knuckles!
        dc.w byte_12C1C-AniSonic_       ; $1E  Unused
        dc.w byte_12CA4-AniSonic_       ; $1F  Super transformation
        dc.w byte_12C24-AniSonic_       ; $20  Unused
        dc.w byte_12C28-AniSonic_       ; $21  Unused
        dc.w byte_12C2C-AniSonic_       ; $22  Falling off Tails
        dc.w byte_12C32-AniSonic_       ; $23  Unused
Super Sonic goes a step further: his animation table ends at the super transformation sequence, leaving the "falling off Tails" animation dangling:
        dc.w byte_12C1C-AniSuperSonic_  ; $1E  Unused
        dc.w byte_12CA4-AniSuperSonic_  ; $1F  Super transformation

byte_12C7A:     dc.b  $FF,   1,   2,   3,   4,   5,   6,   7,   8, $FF
When an animation ID greater than $1F is requested, arbitrary bytes from Super Sonic's walking animation definition at byte_12C7A are interpreted as an offset to apply to the AniSuperSonic_ table at ROM address $12C3A. When the ID is $22, the bytes chosen are 4 and 5, which are interpreted as an offset of $405, causing the animation to be read all the way from ROM address $1303F!

This address is way beyond the end of Super Sonic's animation table: it actually goes right past the Sonic_Load_PLC and Tails_Carry_LoadPLC functions, past the animation code for Competition mode characters, and ends smack dab in the middle of Competition mode Sonic's idle animation.
                                                          |
                                                          V
byte_13038:     dc.b    7, $1B, $1B, $1B, $1B, $1B, $1B, $1B, $1B, $1C, $1C, $1C, $1C, $1C, $1C,
                dc.b  $1D, $1E, $1D, $1E, $1D, $1E, $1D, $1E, $1D, $1E, $FE, $10
If you recall how the animation system works, the first byte of each animation defines how many frames to wait before switching mapping frames, so this animation will wait $1B or 27 frames between each mapping frame. The frames the animation will display, on the other hand, are $1B... $1C... $1C... $1C...


...which is essentially a very bad tour of Sonic's diagonal ceiling walking frames.

7 comments:

  1. That obscure animation reminds me of the hanging animations from 2 and Mania. Anyway, does Tails have an animation $22?

    ReplyDelete
  2. "Most of his character-specific animations are unused." Unused as in simply blank right?

    ReplyDelete
    Replies
    1. They aren't blank, so I imagine 'unused' as in unused.

      Delete
    2. Not blank; they're actually well-defined, but most of them just make no sense. They might be holdovers from Sonic 2, admittedly I haven't checked.

      Delete
  3. In other words... it's just by chance that this didn't go even worse?

    ReplyDelete
    Replies
    1. Well, animation scripts are consumed byte-per-byte, so it's not like you could ever get into a situation where it would crash the game, I don't think. But it could have just as easily jumped into something that isn't an animation script and produced a much more confusing, possible endless animation.

      Delete
  4. But just *what* _are_ the undefined Sonic animations _supposed_ to be?

    dc.w byte_12C1C-AniSonic_ ; $1E Unused
    dc.w byte_12CA4-AniSonic_ ; $1F Super transformation
    dc.w byte_12C24-AniSonic_ ; $20 Unused
    dc.w byte_12C28-AniSonic_ ; $21 Unused
    dc.w byte_12C2C-AniSonic_ ; $22 Falling off Tails
    dc.w byte_12C32-AniSonic_ ; $23 Unused
    dc.w byte_12C1C-AniSuperSonic_ ; $1E Unused
    dc.w byte_12CA4-AniSuperSonic_ ; $1F Super transformation

    ReplyDelete