Prev: A234 Up: Map Next: A29D
A255: Place Amulet Pieces
Used by the routine at InitialisePlayer.
Sets up the four amulet pieces in AmuletData. The random seed in RandomNumber selects one of eight sets of four rooms (see Initialisation_Amulet) and each piece is put at the first position in the room's layout (see ObjectLocation). The pieces are numbered 90 to 93 and are all drawn in bright yellow (46).
This is used when a new game is started.
PlaceAmuletPieces A255 LD IX,$97FE Point IX at the first amulet piece record at AmuletData.
A259 LD A,($9695) Fetch the random seed from RandomNumber.
A25C AND %00000111 Keep only bits 0-2.
A25E LD L,A Stash the set number in L.
A25F LD H,$00 Clear H.
A261 ADD HL,HL Multiply the set number by four, as there are four rooms in each set.
A262 ADD HL,HL
A263 LD BC,$A29D Point BC at the sets of amulet piece rooms at Initialisation_Amulet.
A266 ADD HL,BC Add the set offset to get the address of the chosen set of rooms.
A267 EX DE,HL Point DE at the chosen set of rooms.
There are four pieces of the amulet to collect.
A268 LD B,$04 Set the amulet piece counter in B to 04.
PlaceAmuletPieces_Loop A26A PUSH BC Stash the amulet piece counter on the stack.
A26B LD A,B Copy the amulet piece counter to A.
A26C ADD A,$8F Add 8F giving a sprite ID of 90 to 93.
A26E LD (IX+$00),A Set the sprite ID of the amulet piece.
A271 LD A,(DE) Fetch the room for this amulet piece.
A272 INC DE Move onto the next room in the set.
A273 LD (IX+$01),A Set the room of the amulet piece.
Find the layout of the room, and from it the position of the piece.
A276 LD L,A Use the room as the offset into the layout table.
A277 LD H,$00 Clear H.
A279 LD BC,$6066 Point BC at the layout table at Layout.
A27C ADD HL,BC Add the layout table address to get the address of the layout number for the room.
A27D LD L,(HL) Fetch the layout number.
A27E LD H,$00 Clear H.
A280 ADD HL,HL Multiply the layout number by eight, as there are eight bytes of positions for each layout.
A281 ADD HL,HL
A282 ADD HL,HL
A283 LD BC,$DC6C Point BC at the table of object positions at ObjectLocation.
A286 ADD HL,BC Add the table address to get the first position for the layout.
A287 LD A,(HL) Fetch the X position.
A288 INC HL Move onto the Y position.
A289 LD (IX+$03),A Set the X position of the amulet piece.
A28C LD A,(HL) Fetch the Y position.
A28D LD (IX+$04),A Set the Y position of the amulet piece.
A290 LD (IX+$05),$46 Set the colour of the amulet piece to INK:YELLOW, PAPER:BLACK (BRIGHT).
A294 LD BC,$000C Set the size of an actor record in BC to 0C.
A297 ADD IX,BC Move onto the next actor record.
A299 POP BC Restore the amulet piece counter from the stack.
A29A DJNZ PlaceAmuletPieces_Loop Decrease the amulet piece counter by one and loop back to PlaceAmuletPieces_Loop until all four pieces have been placed.
A29C RET Return.
Prev: A234 Up: Map Next: A29D