Wednesday, December 6, 2017

Hydrocity Zone intro area: the door

Our attention now turns to the two objects placed in the intro pool: the door and the button. The door is the mastermind here; all the button does is set one of the flags in the level trigger array, which in turn is monitored by the door object.


Before we get into detail regarding the door, however, I need to introduce something else entirely. Water tunnels are a level event exclusive to Hydrocity Zone: when players step into their area of effect, water tunnels override their X and Y velocity with preset values, although the player is still able to influence their own movement across one of the axes.
HCZ1_WaterTunLocs: dc.w    $E
        ; Min X, Min Y, Max X, Max Y, X Vel, Y Vel, Player can influence which axis (Clear = Y)
    dc.w   $380,  $580,  $5A0,  $5C0,  $3F0, $FFE0,     0
    dc.w   $5A0,  $560,  $A80,  $5C0,  $3F0, $FFF0,     0
    dc.w  $1400,  $A80, $15A0,  $AC0,  $400,     0,     0
    dc.w  $15A0,  $A40, $1960,  $AC0,  $400, $FFC0,     0
    dc.w  $1990,  $780, $19E0,  $7F0,     0, $FC00,  $100
    dc.w  $1990,  $7F0, $19F0,  $878, $FEC0, $FC00,  $100
    dc.w  $1990,  $878, $19F0,  $8FD,  $140, $FC00,  $100
    dc.w  $1990,  $8FD, $19F0,  $978, $FEC0, $FC00,  $100
    dc.w  $1990,  $978, $19F0,  $A10,  $100, $FC00,  $100
    dc.w  $1960,  $A10, $19D0,  $A80,  $300, $FD80,  $100
    dc.w  $2B00,  $800, $2C20,  $840,  $400,     0,     0
    dc.w  $2C20,  $7C0, $2EE0,  $840,  $400, $FFC0,     0
    dc.w  $2EE0,  $790, $2F50,  $800,  $300, $FD00,  $100
    dc.w  $2F00,  $700, $2F70,  $790,  $100, $FC00,  $100
    dc.w  $2F30,  $680, $2F70,  $700,     0, $FC00,  $100
These tunnels can be disabled programmatically by setting the flags at RAM address $F7C7: bit 0 for player 1, bit 1 for player 2. I bring this up because there are two water tunnels in the intro pool, one of which directly overlaps the button:


When the door object spawns, it sets the $F7C7 flags to prevent the players from getting sucked into the sealed tunnel. As soon as the the level trigger array takes on a non-zero value though, the door snaps open, clearing the $F7C7 flags and re-enabling water tunnels in the process.
loc_2FE28:
    move.b  #3,($FFFFF7C7).w
    move.l  #loc_2FE34,(a0)

loc_2FE34:
    tst.b   (Level_trigger_array).w
    beq.s   loc_2FE58
    move.b  #3,$22(a0)
    move.b  #1,$24(a0)
    move.l  #loc_2FE5E,(a0)
    move.b  #0,($FFFFF7C7).w
    move.b  #1,($FFFFF650).w

loc_2FE58:
    jmp     (Sprite_OnScreen_Test).l
Another thing it does is set the general purpose "animated palette flag" over at RAM address $F650. Within the context of Hydrocity Zone 1, what the flag does is speed up the stage's rotating water palette from once every eight frames...


...to once every frame, for use in the tunnel flooding animation that starts immediately after the door is opened.


There's an oversight here, however. In a Sonic and Tails game, Tails can open the door while Sonic is outside the water tunnel's area of effect. This speeds up the rotating palette all the same, except Sonic is then free to back out of the pool and catch the intro waterfall animating at a ludicrous speed.


If that's not good enough for you, don't worry. There's another oversight at play here.


Remember how the door disables water tunnels when it spawns? It doesn't actually re-enable them until we step on the button, so if we scroll both objects into view and then leave the area without touching the button (by taking the top path) then water tunnels will remain disabled. We can then take the long way around and enter the tunnel from the back side, because there is no rushing current to stop us.


Now, since we took the top path, the current dynamic resize routine is still 0, and so the background bricks take on their yellow coloring. Unfortunately, you can't go far enough left to trigger the switch to resize routine 2: attempting to go past one of the breakable bars instantly re-enables the water tunnel.

No comments:

Post a Comment