![]() |
Routines |
| Prev: 41925 | Up: Map | Next: 42010 |
|
Handles a nastie which has finished appearing (sprite ID 6) by choosing which type of nastie it is going to be. The types are held in SpriteReference. At the start of the game only the first eight types are possible, but each amulet piece which has been collected makes two more types possible.
|
||||||||
|
Count off the nastie if it is not in the same room as the player.
|
||||||||
| HandlerChooseNastie | 41952 | LD A,(38659) | Fetch the room of the player from 38659. | |||||
| 41955 | CP (IX+1) | Jump to ExpireActor if the nastie is in a different room to the player. | ||||||
| 41958 | JP NZ,ExpireActor | |||||||
| 41961 | CALL StoreEntity | Remember the previous position of the nastie. | ||||||
|
Count the amulet pieces which have been collected.
|
||||||||
| 41964 | LD A,(38669) | Fetch the amulet pieces collected from 38669. | ||||||
| 41967 | LD C,0 | Clear the number of amulet pieces collected in C. | ||||||
| 41969 | LD B,4 | Set the amulet piece counter in B to 4. | ||||||
| HandlerChooseNastie_Loop | 41971 | RRCA | Rotate the flag for the next amulet piece into the carry flag. | |||||
| 41972 | JR NC,HandlerChooseNastie_Next | Jump to HandlerChooseNastie_Next if the amulet piece has not been collected. | ||||||
| 41974 | INC C | Count the amulet piece. | ||||||
| HandlerChooseNastie_Next | 41975 | DJNZ HandlerChooseNastie_Loop | Decrease the amulet piece counter by one and loop back to HandlerChooseNastie_Loop until all four pieces have been checked. | |||||
|
Work out how many types of nastie are possible: 8 plus twice the number of pieces collected.
|
||||||||
| 41977 | SLA C | Double the number of amulet pieces collected. | ||||||
| 41979 | LD A,C | Copy it to A. | ||||||
| 41980 | ADD A,8 | Add 8. | ||||||
| 41982 | LD C,A | Stash the number of nastie types possible in C. | ||||||
|
Choose a type at random, using the counter. If it is not one of the types which are possible then use only the first eight.
|
||||||||
| 41983 | LD A,(38547) | Fetch the low byte of the game timer from GameTimer. | ||||||
| 41986 | AND %00001111 | Keep only bits 0-3. | ||||||
| 41988 | CP C | Jump to HandlerChooseNastie_Type if the type is possible. | ||||||
| 41989 | JR C,HandlerChooseNastie_Type | |||||||
| 41991 | AND %00000111 | Keep only bits 0-2. | ||||||
| HandlerChooseNastie_Type | 41993 | LD C,A | Stash the type in C. | |||||
| 41994 | LD B,0 | Clear B. | ||||||
| 41996 | LD HL,42010 | Point HL at the table of nastie types at SpriteReference. | ||||||
| 41999 | ADD HL,BC | Add the type to get the address of the sprite ID. | ||||||
| 42000 | LD A,(HL) | Fetch the sprite ID for the type. | ||||||
| 42001 | LD (IX+0),A | Set the sprite ID of the nastie. | ||||||
| 42004 | CALL ChooseVelocity | Choose a velocity for the nastie. | ||||||
| 42007 | JP DisplayActor | Jump to DisplayActor to display the nastie. | ||||||
| Prev: 41925 | Up: Map | Next: 42010 |