Prev: 49926 Up: Map Next: 50071
49975: Handle Transformation
Handles the graphic numbers 92 to 95, 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 49975 CALL SetPixelAdjustments_Bricks11 Set the pixel adjustments of a transforming player.
49978 BIT 6,(IX+13) Jump to HandleTransformation_Step if not.
49982 JR Z,HandleTransformation_Step
49984 LD A,(23491) Fetch the flag that says the game has been completed from FinalAnimationFlag.
49987 AND A Test it.
49988 JR NZ,HandleTransformation_Step Jump to HandleTransformation_Step if it has been.
49990 JP StartDeathSparkles Start the death sparkles.
HandleTransformation_Step 49993 LD A,(23458) Fetch the frame counter from FrameCounter.
49996 AND %00000011 Keep the lowest two bits.
49998 RET NZ Return unless it is one frame in four.
49999 CALL PlaySoundFromObjectNumber Play the sound of a transformation.
50002 DEC (IX+16) Decrease the number of steps left.
50005 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 50007 LD A,R Fetch a random number from the refresh register.
50009 LD C,A Stash it in C.
50010 LD A,(23461) Fetch the second random seed from RandomSeed2.
50013 ADD A,C Add the random number.
50014 AND %00000011 Keep the lowest two bits.
50016 OR %01011100 Make it one of the graphic numbers 92 to 95.
50018 CP (IX+0) Compare it with the graphic of the legs.
50021 JR NZ,HandleTransformation_SetGraphic Jump to HandleTransformation_SetGraphic if it is different.
50023 XOR %00000001 Change to the other graphic of the pair.
HandleTransformation_SetGraphic 50025 LD (IX+0),A Set the graphic number of the legs.
50028 LD A,(IX+7) Fetch the flags of the legs.
50031 XOR %01000000 Flip the sprite horizontally.
50033 LD (IX+7),A Store the flags.
50036 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 50039 LD A,(23473) Fetch the graphic number that the legs had before the transformation from TransformFlag.
50042 XOR %00100000 Change it from human to wulf, or back.
50044 LD (IX+0),A Set the graphic number of the legs.
50047 ADD A,16 Work out the graphic number of the top half.
50049 LD (IX+32),A Set the graphic number of the top half.
50052 XOR A Clear A.
50053 LD (23473),A Flag that the player is not transforming at TransformFlag.
50056 CALL SetPixelAdjustments_Legs Set the pixel adjustments of the legs.
50059 BIT 5,(IX+0) Jump to HandleTransformation_Draw if not.
50063 JR Z,HandleTransformation_Draw
50065 DEC (IX+19) Lower the pixel adjustment in Y by one.
HandleTransformation_Draw 50068 JP SetWipeAndDrawFlags Flag the object to be wiped and drawn.
Prev: 49926 Up: Map Next: 50071