Friday, December 1, 2017

Press F to Pay Respects

Unlike the Gumball Machine stage, the Rolling Jump bonus stage doesn't use random number generation to determine the subtype of spawned gumballs. Instead, it uses the item ball object's vertical position to pick a pool of gumball types, and then the actual type is selected from that pool based on the two lowest bits of the stage's overall frame counter.

This means that each item ball in the stage will only ever produce a predefined set of four gumball types, but the player can influence which of those actually spawns by delaying the frame in which they touch the object.
byte_1E4484:    dc.b    1,   3,   1,   3    ; 0-$FF
                dc.b    8,   3,   8,   5    ; $100-$1FF (unused)
                dc.b    1,   3,   6,   4    ; $200-$2FF
                dc.b    1,   7,   6,   5    ; $300-$3FF
                dc.b    8,   6,   4,   3    ; $400-$4FF
                dc.b    4,   3,   4,   5    ; $500-$5FF
                dc.b    8,   4,   5,   3    ; $600-$6FF
                dc.b    7,   3,   8,   3    ; $700-$7FF
                dc.b    6,   5,   6,   7    ; $800-$8FF
                dc.b    4,   3,   7,   5    ; $900-$9FF
                dc.b    6,   4,   6,   4    ; $A00-$AFF
                dc.b    7,   3,   3,   5    ; $B00-$BFF
                dc.b    4,   3,   4,   6    ; $C00-$CFF (unused)
                dc.b    3,   4,   3,   7    ; $D00-$DFF
                dc.b    4,   3,   4,   3    ; $E00-$EFF (unused)
                dc.b    4,   3,   4,   3    ; $F00-$FFF (unused)
Note that due to the stage's layout, several of these vertical ranges do not actually contain any item balls, rendering the associated type pool unused. Also note that relative to the Gumball Machine stage, all the subtypes are shifted forward by one, so for example, the two item balls at the very top of the stage have a 50% chance of spawning a 1-Up Ball or a Ring Ball, and since subtype 2 is missing entirely, no item ball will ever spawn a Replace Ball.


So what happens if you force the subtype of the gumball object to zero? Well, it turns out the Rolling Jump bonus stage has an unused gumball type of its own: the F Ball.


What does the F stand for? We can only speculate. Maybe it stood for Fast Ball, and it would have increased the speed of the rising trap at the bottom of the stage, as a sort of antithesis to the helpful Replace Ball from the Gumball Machine stage. Both of them are green, after all.
loc_4A3AC:
    moveq   #$7B,d0
    jsr     (Play_Sound_2).l
    rts
In reality, though, both the F Ball and the Replace Ball use the same item collection routine, which does nothing except play the bumper sound effect.

4 comments:

  1. Is the S ball in the Rolling Jump Bonus Stage too, as it seems to be told on Sonic Retro or TCRF, or is it limited to just the Gumball Bonus Stage?

    ReplyDelete
    Replies
    1. For subtypes beyond the Ring Ball, the object in the Rolling Jump stage simply runs the collection routines for the Gumball Machine stage. However, it doesn't use the animation data from that stage, it just takes the subtype and uses it to pull each individual mapping frame in order.

      So subtype 9 would invoke the S ball collection routine, and it would also use the dark S ball frame, because that's the frame that comes after the Thunder Ball frame.

      Meanwhile, subtype $A would use the bright S ball frame, and it would try to read the first two bytes of the 1-Up collection routine code as an offset to the item collection jump table, because that table only has nine entries.

      This is likely to crash the game, since it appears to jump right into a table containing initial speed values for the pieces of the door that Knuckles punches through during the long Hidden Palace Zone cutscene.

      Delete
    2. That leads me to a question: How are cutscenes done in the game? Are they just pre-recorded button presses that override player controls combined with forced animation frames?

      Delete
    3. That is a very vague question. If you're talking about cutscenes which take control away from the player, then yes, they generally just feed artifical controller input into the player object, and manipulate their speed values to make them stop on a dime.

      Cutscene Knuckles isn't a player object though, it's a regular object which is programmed to move and animate in a predefined way.

      Delete