![]() |
Routines |
| Prev: 9565 | Up: Map | Next: 95A9 |
|
Used by the routine at ControlPlayer.
Counts how many of the two axes an entity is beyond the edge of the floor of the room. The floor is centred on 58 across and 68 down, and on each axis it extends one more than the width in CurrentRoom_Width or the height in CurrentRoom_Height from the centre. The count is written to InDoorway, which is zero when the entity is not in a doorway.
|
||||||||
| CheckDoorway | 957D | PUSH DE | Stash DE on the stack. | |||||
| 957E | LD B,$00 | B=00 (the count). | ||||||
| 9580 | LD HL,($5E1D) | HL=*CurrentRoom_Width (the width in L and the height in H). | ||||||
| 9583 | INC L | Increment the width. | ||||||
| 9584 | INC H | Increment the height. | ||||||
| 9585 | LD E,(IX+$03) | Fetch the X position of the entity. | ||||||
| 9588 | LD D,(IX+$04) | Fetch the Y position of the entity. | ||||||
| 958B | LD A,E | Fetch the X position. | ||||||
| 958C | SUB $58 | Subtract 58 to get the distance from the centre of the floor. | ||||||
| 958E | JP P,CheckDoorway_X | Jump to CheckDoorway_X if the result is positive. | ||||||
| 9591 | NEG | Negate it, to make the distance positive. | ||||||
| CheckDoorway_X | 9593 | CP L | Jump to CheckDoorway_Y if the entity is within the width of the floor. | |||||
| 9594 | JR C,CheckDoorway_Y | |||||||
| 9596 | INC B | Increment the count of axes that it is beyond. | ||||||
| CheckDoorway_Y | 9597 | LD A,D | Fetch the Y position. | |||||
| 9598 | SUB $68 | Subtract 68 to get the distance from the centre of the floor. | ||||||
| 959A | JP P,CheckDoorway_Compare | Jump to CheckDoorway_Compare if the result is positive. | ||||||
| 959D | NEG | Negate it, to make the distance positive. | ||||||
| CheckDoorway_Compare | 959F | CP H | Jump to CheckDoorway_Finish if the entity is within the height of the floor. | |||||
| 95A0 | JR C,CheckDoorway_Finish | |||||||
| 95A2 | INC B | Increment the count of axes that it is beyond. | ||||||
| CheckDoorway_Finish | 95A3 | LD A,B | Fetch the count. | |||||
| 95A4 | LD ($5E2D),A | Update the doorway flag in InDoorway. | ||||||
| 95A7 | POP DE | Restore DE from the stack. | ||||||
| 95A8 | RET | Return. | ||||||
| Prev: 9565 | Up: Map | Next: 95A9 |