Showing posts with label Carnival Night Zone. Show all posts
Showing posts with label Carnival Night Zone. Show all posts

Wednesday, November 22, 2017

Unused graphics: shattered lightbulb

Carnival Night Zone is also home to some unused button sprites. However, unlike the ones in Angel Island Zone, these have fully programmed objects associated with them, which can even be placed in the level using debug mode!


The only two buttons in the entire level, which control the lights in act 2, simply use the same generic button sprite seen elsewhere in the game. I guess the developers didn't want Knuckles to have a different button for just this one level.

Speaking of the lights in act 2, the area where Knuckles kills them features a unique object which isn't placed anywhere else in the stage: a pair of lightbulbs, seemingly for decoration. Peeking into the object's art file, though, reveals it has a second frame of animation, in which the lightbulb has shattered!


That's not even the shocking part, though. The lightbulb object actually contains logic which causes it to shatten when it becomes submerged in water!

Given the placement of the objects, along with the fact that the water rises once Knuckles presses the button, I think it's fair to assume that originally the button would raise the water high enough to shatter the lightbulbs, causing the lights to go out. Here's a video illustrating what that may have looked like, as well as the unused button graphics:


Note how Knuckles becomes discolored once the water level crosses over his sprite. This is because his palette is only loaded to the normal palette slot and not the water palette slot, and it could have contributed to the scene being altered for the final version of the game.

Tuesday, September 19, 2017

Wall running woes, part 2

In standalone Sonic 3, the design flaws in the level collision code are even more pronounced than in Sonic & Knuckles. While running on the ceiling, or a wall on the left side, level collisions are completely ignored, so you'll sail right through solid parts of the level. Obviously, this can easily cause you to become irreparably stuck in a wall- er, I mean, watch out for Dr. Robotnik's diabolical traps.


Unfortunately, although otherwise quite welcome, the changes to the algorithm in Sonic & Knuckles caused a breaking change in one of the Competition stages. (left: Sonic 3 alone; right: Sonic 3 & Knuckles)


In Sonic 3 & Knuckles, you can no longer backtrack through the loop in Desert Palace after you cross it. The reason for this becomes evident once we open up the level in SonLVL and take a gander at the collision data:


The loop is comprised entirely of blocks solid from all sides! The only reason the thing worked in the first place was due to Sonic 3's lax attitude while running on left-hand side walls. Changing the collision on the walkway threading the loop from fully solid to top-only would fix this issue.

Thursday, September 14, 2017

Can't catch me if I'm already gone

Like Hydrocity Zone, Carnival Night Zone too features a one-way obstacle you wouldn't expect to fall back through, but which the layout accounts for anyway. This time, it's the hover fans scattered throughout both acts of the level.


In the above scenario, when you take damage over a row of fans, they won't catch you, and you'll fall into an otherwise empty room. There's a red spring in the corner to make sure you can get back out, which is kind of overkill, considering you can get within range of the fans simply by jumping.

I don't know what they were so worried about, because if you do this close to the bottom of the stage, you'll fall straight into Knuckles' path, where you'll likely get stuck anyway due to all the Knuckles-only breakable walls.

As for why it happens: although the fans are part of the level's blocks much like the water slides in Hydrocity Zone, they actually have no collision and are instead controlled by invisible objects placed directly over them. In turn, these objects don't affect the player when their routine counter is set to 4 or above. Previously, we saw how routines 6 and above are used when the player has died; routine 4 occurs when the player is falling back from taking damage.
sub_31E96:
    ...
    cmpi.b  #4,5(a1)
    bhs.w   locret_31F2E
    tst.b   $2E(a1)
    bne.s   locret_31F2E
    ...
I'm not sure why the object behaves that way, but there you go.

Something similar happens in Flying Battery Zone, where none of the screen event code runs if the player is dead. This leads to some visual weirdness if you save yourself from death by entering debug mode: since the screen events aren't running, the foreground plane isn't redrawn as you move around the stage.


This one I can explain: the screen event code is responsible for checking whether you're inside or outside the ship, and triggering all the different effects, such as loading palettes, changing backgrounds and doing the necessary level layout modifications. It does this by loading player 1's X and Y coordinates into the d0 and d1 registers upfront and comparing them against a bunch of different ranges.
FBZ1_ScreenEvent:
    cmpi.b  #6,($FFFFB005).w
    blo.s   loc_5242E
    rts                                     ; Don't do any special events while Sonic is dying
; ---------------------------------------------------------------------------

loc_5242E:
    lea     FBZ1_LayoutModRange(pc),a1
    move.w  ($FFFFB010).w,d0
    move.w  ($FFFFB014).w,d1
    move.w  ($FFFFEED2).w,d2
    jmp     loc_52442(pc,d2.w)
; ---------------------------------------------------------------------------

loc_52442:
    bra.w   FBZ1SE_Normal
; ---------------------------------------------------------------------------
    bra.w   FBZ1SE_LayoutMod1
; ---------------------------------------------------------------------------
    bra.w   FBZ1SE_LayoutMod2
; ---------------------------------------------------------------------------
    ...
If this code ran while during the death animation, the player could potentially enter one of those ranges while falling off the screen, causing the background to change while the camera is stuck where the player originally died. The simplest solution is to check for routine 6 or above before doing anything, and although it fudges up debug mode a bit, it has no visible effect when the camera freezes normally.

Tuesday, September 12, 2017

That sinking feeling

It's worth pointing out that the only thing preventing the quirk we saw last time from occurring with completely solid level blocks is wall collision: as you may recall, whether a block is solid from the top or from other directions is determined by two separate flags, and the associated behavior is also defined separately. As such, just like top-only blocks, if you're in the air and have any upward momentum, you will not register any collision with the top of fully solid blocks.

Ordinarily, this isn't an issue, because the player will always be falling when they touch the ground. The problem occurs when a level event sets the solid background flag and begins scrolling the background plane upward. In this scenario, it is possible for the floor to rise faster than the player, and since the player is moving upward, no collision is registered.


This can happen during the rising sand sequences in Sandopolis Zone, as well as directly after the Carnival Night Zone act 1 boss, since during this sequence, the foreground plane contains the boss' breakable blocks, where as the entirety of the shaft, including the floor below, is part of the rising background plane.

It doesn't happen in Marble Garden Zone because the player gets pushed up along with the background plane, even in mid-air, and it also doesn't happen at the very end of Flying Battery Zone because there's an invisible solid object rising along with the long floor beam.

Thursday, August 24, 2017

Hide your shame

Reader muteKi pointed out something interesting over at my post on level sizes. By default, Carnival Night Zone 2 has an unusually low ceiling:
;                       xstart  xend    ystart  yend    ; Level
                dc.w    $0,     $6000,  $580,   $1000   ; CNZ2
The reason for the lower ceiling is to keep you from going back up the shaft and reaching the innards of the act 1 boss scroll, which are replicated in the act 2 layout for some reason. This would be trivial to do by say, climbing up the shaft walls as Knuckles.


However, something was still bugging me. I was sure you could go up there somehow. So I checked my disassembly of standalone Sonic 3, and sure enough, what do you know:
;                       xstart  xend    ystart  yend    ; Level
                dc.w    $0,     $6000,  $0,     $1000   ; CNZ2
The ceiling is completely unlocked in standalone Sonic 3. The addition of Knuckles as a playable character is likely the reason why this was changed. Even so, if you select Sonic and Tails, use the act 1 signpost to reveal the thunder barrier monitor hidden in the floor, then have Tails carry Sonic up as high as possible, and finally use the barrier to do a double jump, you can just barely get the camera outside the shaft. It's not enough to get Sonic up there, though.


While investigating this, I noticed the level size for Launch Base Zone 2 is also different between games. Here's what it looks like in Sonic & Knuckles:
;                       xstart  xend    ystart  yend    ; Level
                dc.w    $0,     $6000,  $0,     $B20    ; LBZ2
And here's what it looks like in Sonic 3:
;                       xstart  xend    ystart  yend    ; Level
                dc.w    $0,     $6000,  $0,     $1000   ; LBZ2
In Sonic 3, the level's pants are down, so if you go all the way to the bottom, you can see where the background plane ends and also get a good look at the level's sewers. This was fixed in Sonic & Knuckles due to Knuckles' route through the stage making this pretty evident.


It's not really an issue in Sonic 3 because Sonic and Tails never go low enough to actually see it. Once again, the level size was changed due to the addition of Knuckles as playable character.

Tuesday, August 1, 2017

The same, but different

Alright, one final detail about breakable walls. Did you ever notice that the Knuckles walls from Carnival Night Zone end up reappearing much later in the game, in Sandopolis Zone?


What's interesting about this bit of graphics reuse is that a) it's only between these two, seemingly arbitrary levels, and b) the graphics actually aren't reused at all! Although the sprite mappings are shared between the two levels, the art is not, and the two sprites actually look a bit different from one another.


The reason for the art discrepancy becomes evident when you realize these sprites are not using the player palette or the enemy palette like other common objects: they're using the main level colors in line 2! No wonder they look slightly different, considering the two levels have such distinct color schemes.