Friday, January 5, 2018

Flying Battery enemies in S3A, part 2

It's not just Flying Battery Zone 2 that has cool stuff lying around in its object layout. Act 1's layout has an object with ID $8F placed at coordinates $2EE0, $5E0:
FBZ1_Sprites:   dc.w   $80,   $80,     0, $2EE0, $85E0, $8F00, $FFFF,     0,     0
Now, what do you imagine we'll find if we look up object ID $8F, or 143 in the master object list?
    dc.l Obj_LBZ_EndBoss            ; 140
    dc.l Obj_CNZEndBoss             ; 141
    dc.l Obj_CNZMiniboss            ; 142
    dc.l Obj_AA_1_FBZ1_Boss         ; 143
    dc.l Delete_Current_Sprite      ; 144
    dc.l Delete_Current_Sprite      ; 145
    dc.l Delete_Current_Sprite      ; 146
Okay, that probably wasn't much of a surprise if you happened to watch the video I linked to in my previous post. That's right, it's the boss of Flying Battery Zone 1, Gapsule:

In my video, I mentioned how the only difference between the S3A version of Gapsule and the one in Sonic & Knuckles lies in its color: the S3A version uses a slightly different shade of black from every other capsule in the stage.

Unfortunately, I made a slight faux pas while talking about Gapsule's button: I mentioned how its colors are also slightly different, using a dark tan around its edges rather than the light tan that every other capsule in the game uses.

Check this out, though. Here is the palette used by every other capsule in the game: the player palette:

Now, here's the palette that Gapsule uses, which is loaded over the level's regular enemy palette:

Do you see it? If you force the button to use Gapsule's palette instead of the player palette, then its edges become dark tan instead of light tan. The button simply uses a different palette line between S3A and Sonic & Knuckles.

Reader Silver Sonic 1992 asks:
Also, why is there a copy of the FBZ Gapsule boss in the disassembly labelled as unused? Is there anything special about it?
Let me elaborate. Way down at the bottom the S&K disassembly, there's a duplicate of Gapsule's art directly before the remaining Flying Battery Zone bosses; all three of them Nemesis-compressed. As the label notes, this copy of the art is unused: there are no other references to it anywhere in the disassembly.
ArtNem_FBZMinibossUnused: binclude "Levels/FBZ/Nemesis Art/Miniboss Unused.bin"
ArtNem_FBZ2Subboss:       binclude "Levels/FBZ/Nemesis Art/Act 2 Subboss.bin"
ArtNem_FBZEndBoss:        binclude "Levels/FBZ/Nemesis Art/End Boss.bin"
So what's the deal? Let's look at an excerpt of Gapsule's init code from S3A:
    move.l  #loc_4C9CA,$34(a0)
    moveq   #$5E,d0
    jsr     (Load_PLC).l
    lea     Pal_FBZMiniboss(pc),a1
    jsr     (PalLoad_Line1).l
In S3A, the Nemesis art is neither a duplicate nor is it unused. As part of its setup, the boss performs a PLC request for PLC $5E, which happens to fall right inbetween the PLCs for Carnival Night Zone and Icecap Zone's act 1 bosses, and contains a reference to the Nemesis-compressed Gapsule art.
    dc.w 1
    dc.l ArtNem_CNZMiniboss
    dc.w $A5C0
    dc.l ArtNem_BossExplosion
    dc.w $A000
    dc.w 4
    dc.l ArtNem_FBZMiniboss
    dc.w $A5C0
    dc.l ArtNem_EggCapsule
    dc.w $89C0
    dc.l ArtNem_BossExplosion
    dc.w $A000
    dc.l ArtNem_Squirrel
    dc.w $85C0
    dc.l ArtNem_BlueFlicky
    dc.w $8800
    dc.w 1
    dc.l ArtNem_ICZMiniboss
    dc.w $9520
    dc.l ArtNem_BossExplosion
    dc.w $A000
In Sonic & Knuckles, this was changed so Gapsule's art is instead stored in KosM format, most likely because Nemesis decompression isn't fast enough to display the boss immediately as it scrolls into view.
    move.l  #loc_6EF14,$34(a0)
    lea     (PLC_83D64).l,a1
    jsr     (Load_PLC_Raw).l
    lea     (ArtKosM_FBZMiniboss).l,a1
    move.w  #-$5A40,d2
    jsr     (Queue_Kos_Module).l
    lea     Pal_FBZMiniboss(pc),a1
    jsr     (PalLoad_Line1).l
As a result, PLC $5E was neutered pretty hard, and the reference to the Nemesis-compressed Gapsule art removed...
    dc.w 0
    dc.l ArtNem_BossExplosion
    dc.w $A000
...except apparently, the developers forgot to remove the art itself from the build. Whoops.

Bonus chatter: Here are some PAR codes that allow you to place the unused Flying Battery Zone objects using debug mode. First, these two force every level to use FBZ's debug list:
Then, these replace some of the objects in FBZ's debug list with the three unused bosses:

GapsuleLaser bossAct 2 boss


  1. Replies
    1. Actually, now that I think about it, is there any limit to the number of entries that can be in a debug list? I'm curious as to whether I can make it so I can place everything in debug mode using a single list (or rather, the same list duplicated for each level).

    2. Well, the lookup code uses word addressing, which I think is signed, and each offset in the list is also word-sized, so I think we're looking at an upper limit of 16,384 entries. So uh, you probably could, yeah.

  2. This comment has been removed by the author.

  3. Do any of the other S&K zones have objects in their debug lists?

    1. Mushroom Valley Zone has a bunch of extra spring variations, but apart from that, they all just have the default set of ring, monitor, collision changers, springs and spikes.

  4. Is there some sort of "default Ring Layout" if a level has no ring data?

    Like, in both S3A and S3C 0408, levels with no proper ring data seems to default to having some rings near the top left corner of the level (fairly noticeable in Doomsday on S3C 0408).

    I felt someone at TCRF jumped to the wrong conclusion by looking at the ring layout in FBZ and going "this level must have used a different layout" IMO.

    1. The one with a bunch of rings in a horizontal line, right? Yeah, that's a weird one.

      No, there's no such thing as a "default ring layout" in the game, but I wouldn't be surprised if every level was originally created with the exact same preset layouts before receiving proper ones.

  5. The Game Crashes when I try to spawn any of these bosse. What should I do?

  6. is there a way to load other bosses for sonic 3