Thursday, July 6, 2017

The holdover boss flash

Launch Base Zone 1's boss flash is undoubtedly the strangest in the entire game. Rather than flashing the dark colors of the boss, it flashes the white color of the enemy palette, which not only looks weird, but also causes the entire HUD and any dropped rings to flicker as well.


It only gets stranger once you get to the code, which is unlike any other boss.
BossFlash:
    lea     ($FFFFFC22).w,a1
    moveq   #0,d0
    tst.w   (a1)
    bne.s   loc_84FA0
    move.w  #$EEE,d0

loc_84FA0:
    move.w  d0,(a1)
    rts
Here's what this does: it tests the current word value of RAM address $FC22, which corresponds to the second color of the enemy palette. If it's currently zero (black), it's set to $EEE (white), otherwise it's set to zero (black).

But why the second color? Turns out, this is leftover code from Sonic 2.


In Sonic 2, the second color of the enemy palette is black, which is the darkest color of a boss. Sonic 3 rearranged the palette, and it's only through sheer coincidence that the above code continues to work: because the starting color is no longer black, the function's duty cycle is reversed, causing it to stop while the color is still white, which now happens to be the right color to keep once the flash ends.

1 comment:

  1. I do take interest with how it looks like the text is being struck out.

    ReplyDelete