Prev: CD0D Up: Map Next: CD70
CD16: Run Pentagram Stone
The handler of the object types 90 to 94, which are the five stones that have to be put on the pentagram. A stone can be picked up and dropped by the player, and falls like any other object, which is done by RunFallingObject_MoveFallingObject.
In the room of the pentagram (room 52), once it has been revealed by CheckObjectsCollected, a stone moves by itself instead. It is steered along x and y to the place that it has on the pentagram, which is one of the five pairs of positions at StonePlacesOnPentagram, with one for each of the stones, and it is not affected by gravity. When it gets there, it changes into the type that is 08 higher, which is a stone that is alight, and one is added to the count of stones in place. The game is won when the fifth is in place.
Input
IX Object record
Fall under gravity unless the pentagram is revealed.
RunPentagramStone CD16 CALL SetSpriteOffset_Minus16_Minus8 Call SetSpriteOffset_Minus16_Minus8 to set the offsets of the sprite.
CD19 LD A,($A777) Fetch the room that the player is in.
CD1C CP $52 Jump to RunFallingObject_MoveFallingObject if it is not room 52, to be moved by gravity.
CD1E JP NZ,RunFallingObject_MoveFallingObject
CD21 LD A,($A70F) Fetch the flag for the pentagram having been revealed.
CD24 AND A Jump to RunFallingObject_MoveFallingObject if it has not been, to be moved by gravity.
CD25 JP Z,RunFallingObject_MoveFallingObject
Steer the stone to its place on the pentagram.
CD28 LD A,(IX+$00) Fetch the type of the stone.
CD2B AND %00000111 Keep the type without its highest five bits, which makes the number of the stone.
CD2D ADD A,A Double it, to make the offset of its place on the pentagram.
CD2E LD L,A Put the offset in HL.
CD2F LD H,$00
CD31 LD DE,$D562 Take the table of the places, StonePlacesOnPentagram.
CD34 ADD HL,DE Add the offset to the table.
CD35 LD A,(HL) Fetch the x position of the place and store it in the record of the stone.
CD36 LD (IX+$15),A
CD39 INC HL Move on to the y position.
CD3A LD A,(HL) Fetch the y position of the place and store it in the record of the stone.
CD3B LD (IX+$16),A
CD3E CALL SteerTowardsTarget Call SteerTowardsTarget to set the speeds along x and y towards the place.
CD41 CALL ApplyGravityAndMove_Move Call ApplyGravityAndMove_Move to move the stone, without gravity.
CD44 LD A,(IX+$01) Fetch the x position of the stone and take off that of the place.
CD47 SUB (IX+$15)
CD4A LD C,A Put the result in C.
CD4B LD A,(IX+$02) Fetch the y position of the stone and take off that of the place.
CD4E SUB (IX+$16)
CD51 OR C Combine the differences, and jump to FinishObjectMove if the stone is not there yet.
CD52 JP NZ,FinishObjectMove
Light the stone when it is in place.
CD55 LD A,(IX+$00) Set the new type, which is 08 more than the old, in C.
CD58 ADD A,$08
CD5A LD C,A
CD5B LD A,(IX+$00) Fetch the old type of the stone.
CD5E CALL ChangeObjectType Call ChangeObjectType to change the type of the stone, and that of its entry in the object store.
CD61 LD A,($A74B) Add one to the count of stones that are in place.
CD64 INC A
CD65 LD ($A74B),A
CD68 CP $05 Jump to ShowVictoryScreen to show the victory screen if there are five.
CD6A JP NC,ShowVictoryScreen
CD6D JP FinishObjectMove Jump to FinishObjectMove to finish.
Prev: CD0D Up: Map Next: CD70