![]() |
Routines |
| Prev: 41524 | Up: Map | Next: 41629 |
|
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 144 to 147 and are all drawn in bright yellow (70).
This is used when a new game is started.
|
||||
| PlaceAmuletPieces | 41557 | LD IX,38910 | Point IX at the first amulet piece record at AmuletData. | |
| 41561 | LD A,(38549) | Fetch the random seed from RandomNumber. | ||
| 41564 | AND %00000111 | Keep only bits 0-2. | ||
| 41566 | LD L,A | Stash the set number in L. | ||
| 41567 | LD H,0 | Clear H. | ||
| 41569 | ADD HL,HL | Multiply the set number by four, as there are four rooms in each set. | ||
| 41570 | ADD HL,HL | |||
| 41571 | LD BC,41629 | Point BC at the sets of amulet piece rooms at Initialisation_Amulet. | ||
| 41574 | ADD HL,BC | Add the set offset to get the address of the chosen set of rooms. | ||
| 41575 | EX DE,HL | Point DE at the chosen set of rooms. | ||
|
There are four pieces of the amulet to collect.
|
||||
| 41576 | LD B,4 | Set the amulet piece counter in B to 4. | ||
| PlaceAmuletPieces_Loop | 41578 | PUSH BC | Stash the amulet piece counter on the stack. | |
| 41579 | LD A,B | Copy the amulet piece counter to A. | ||
| 41580 | ADD A,143 | Add 143 giving a sprite ID of 144 to 147. | ||
| 41582 | LD (IX+0),A | Set the sprite ID of the amulet piece. | ||
| 41585 | LD A,(DE) | Fetch the room for this amulet piece. | ||
| 41586 | INC DE | Move onto the next room in the set. | ||
| 41587 | LD (IX+1),A | Set the room of the amulet piece. | ||
|
Find the layout of the room, and from it the position of the piece.
|
||||
| 41590 | LD L,A | Use the room as the offset into the layout table. | ||
| 41591 | LD H,0 | Clear H. | ||
| 41593 | LD BC,24678 | Point BC at the layout table at Layout. | ||
| 41596 | ADD HL,BC | Add the layout table address to get the address of the layout number for the room. | ||
| 41597 | LD L,(HL) | Fetch the layout number. | ||
| 41598 | LD H,0 | Clear H. | ||
| 41600 | ADD HL,HL | Multiply the layout number by eight, as there are eight bytes of positions for each layout. | ||
| 41601 | ADD HL,HL | |||
| 41602 | ADD HL,HL | |||
| 41603 | LD BC,56428 | Point BC at the table of object positions at ObjectLocation. | ||
| 41606 | ADD HL,BC | Add the table address to get the first position for the layout. | ||
| 41607 | LD A,(HL) | Fetch the X position. | ||
| 41608 | INC HL | Move onto the Y position. | ||
| 41609 | LD (IX+3),A | Set the X position of the amulet piece. | ||
| 41612 | LD A,(HL) | Fetch the Y position. | ||
| 41613 | LD (IX+4),A | Set the Y position of the amulet piece. | ||
| 41616 | LD (IX+5),70 | Set the colour of the amulet piece to INK:YELLOW, PAPER:BLACK (BRIGHT). | ||
| 41620 | LD BC,12 | Set the size of an actor record in BC to 12. | ||
| 41623 | ADD IX,BC | Move onto the next actor record. | ||
| 41625 | POP BC | Restore the amulet piece counter from the stack. | ||
| 41626 | DJNZ PlaceAmuletPieces_Loop | Decrease the amulet piece counter by one and loop back to PlaceAmuletPieces_Loop until all four pieces have been placed. | ||
| 41628 | RET | Return. | ||
| Prev: 41524 | Up: Map | Next: 41629 |