Prev: C306 Up: Map Next: C397
C337: Handle Transformation
Handles the graphic numbers 5C to 5F, which are the legs of the player while the player transforms. Every fourth frame a different one of these graphics is chosen at random, and the sound of a transformation is played. When the number of steps has run out the player becomes human or wulf. If the player is killed during the transformation, the death sparkles start.
Input
IX Address of the legs of the player
HandleTransformation C337 CALL SetPixelAdjustments_Bricks11 Set the pixel adjustments of a transforming player.
C33A BIT 6,(IX+$0D) Jump to HandleTransformation_Step if not.
C33E JR Z,HandleTransformation_Step
C340 LD A,($5BC3) Fetch the flag that says the game has been completed from FinalAnimationFlag.
C343 AND A Test it.
C344 JR NZ,HandleTransformation_Step Jump to HandleTransformation_Step if it has been.
C346 JP StartDeathSparkles Start the death sparkles.
HandleTransformation_Step C349 LD A,($5BA2) Fetch the frame counter from FrameCounter.
C34C AND %00000011 Keep the lowest two bits.
C34E RET NZ Return unless it is one frame in four.
C34F CALL PlaySoundFromObjectNumber Play the sound of a transformation.
C352 DEC (IX+$10) Decrease the number of steps left.
C355 JR Z,HandleTransformation_Finish Jump to HandleTransformation_Finish when the transformation is done.
This entry point is used by the routine at StartTransformation.
Choose a graphic for the legs at random, and turn it round.
HandleTransformation_Flicker C357 LD A,R Fetch a random number from the refresh register.
C359 LD C,A Stash it in C.
C35A LD A,($5BA5) Fetch the second random seed from RandomSeed2.
C35D ADD A,C Add the random number.
C35E AND %00000011 Keep the lowest two bits.
C360 OR %01011100 Make it one of the graphic numbers 5C to 5F.
C362 CP (IX+$00) Compare it with the graphic of the legs.
C365 JR NZ,HandleTransformation_SetGraphic Jump to HandleTransformation_SetGraphic if it is different.
C367 XOR %00000001 Change to the other graphic of the pair.
HandleTransformation_SetGraphic C369 LD (IX+$00),A Set the graphic number of the legs.
C36C LD A,(IX+$07) Fetch the flags of the legs.
C36F XOR %01000000 Flip the sprite horizontally.
C371 LD (IX+$07),A Store the flags.
C374 JP SetWipeAndDrawFlags Flag the object to be wiped and drawn.
The transformation is over. Change the player from human to wulf, or from wulf to human.
HandleTransformation_Finish C377 LD A,($5BB1) Fetch the graphic number that the legs had before the transformation from TransformFlag.
C37A XOR %00100000 Change it from human to wulf, or back.
C37C LD (IX+$00),A Set the graphic number of the legs.
C37F ADD A,$10 Work out the graphic number of the top half.
C381 LD (IX+$20),A Set the graphic number of the top half.
C384 XOR A Clear A.
C385 LD ($5BB1),A Flag that the player is not transforming at TransformFlag.
C388 CALL SetPixelAdjustments_Legs Set the pixel adjustments of the legs.
C38B BIT 5,(IX+$00) Jump to HandleTransformation_Draw if not.
C38F JR Z,HandleTransformation_Draw
C391 DEC (IX+$13) Lower the pixel adjustment in Y by one.
HandleTransformation_Draw C394 JP SetWipeAndDrawFlags Flag the object to be wiped and drawn.
Prev: C306 Up: Map Next: C397