Prev: B544 Up: Map Next: B58B
B566: Handle Ending Sparkles
Handles one of the sparkles that fly off the blocks when the cauldron room is shown at the end of the game. A sparkle rises until it is high enough, in one of four diagonal directions that depend on the part of the room it is in, and then flies at the player.
Input
IX Address of the sparkle object
Rise until the sparkle is high enough, then fly at the player.
HandleEndingSparkles B566 CALL SetPixelAdjustments_Sparkle Set the pixel adjustments for a sparkle.
B569 LD A,(IX+$03) Fetch the height of the sparkle.
B56C CP $A4 Jump to SendSparkleAtPlayer if it has reached the top.
B56E JR NC,SendSparkleAtPlayer
Pick a diagonal from the part of the room the sparkle is in.
B570 LD (IX+$0B),$03 Make the sparkle rise at a speed of 03.
B574 LD A,(IX+$01) Fetch the X coordinate of the sparkle.
B577 RLCA Rotate bit 7 into bit 0.
B578 AND %00000001 Keep only that bit.
B57A LD L,A Stash it in L.
B57B LD A,(IX+$02) Fetch the Y coordinate of the sparkle.
B57E AND %10000000 Keep bit 7 of it.
B580 OR L Add the bit from the X coordinate.
B581 RLCA Rotate the two bits into bits 0 and 1.
B582 AND %00000011 Keep only those two bits.
B584 LD L,A Use them as the number of the entry of the direction table.
B585 LD BC,$B58B Point BC at SparkleDirectionTable.
B588 JP RunGame_JumpToHandler Jump to the routine for the direction.
Prev: B544 Up: Map Next: B58B