Prev: 38245 Up: Map Next: 38313
38269: Check Doorway
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 88 across and 104 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.
Input
IX The entity
CheckDoorway 38269 PUSH DE Stash DE on the stack.
38270 LD B,0 B=0 (the count).
38272 LD HL,(24093) HL=*CurrentRoom_Width (the width in L and the height in H).
38275 INC L Increment the width.
38276 INC H Increment the height.
38277 LD E,(IX+3) Fetch the X position of the entity.
38280 LD D,(IX+4) Fetch the Y position of the entity.
38283 LD A,E Fetch the X position.
38284 SUB 88 Subtract 88 to get the distance from the centre of the floor.
38286 JP P,CheckDoorway_X Jump to CheckDoorway_X if the result is positive.
38289 NEG Negate it, to make the distance positive.
CheckDoorway_X 38291 CP L Jump to CheckDoorway_Y if the entity is within the width of the floor.
38292 JR C,CheckDoorway_Y
38294 INC B Increment the count of axes that it is beyond.
CheckDoorway_Y 38295 LD A,D Fetch the Y position.
38296 SUB 104 Subtract 104 to get the distance from the centre of the floor.
38298 JP P,CheckDoorway_Compare Jump to CheckDoorway_Compare if the result is positive.
38301 NEG Negate it, to make the distance positive.
CheckDoorway_Compare 38303 CP H Jump to CheckDoorway_Finish if the entity is within the height of the floor.
38304 JR C,CheckDoorway_Finish
38306 INC B Increment the count of axes that it is beyond.
CheckDoorway_Finish 38307 LD A,B Fetch the count.
38308 LD (24109),A Update the doorway flag in InDoorway.
38311 POP DE Restore DE from the stack.
38312 RET Return.
Prev: 38245 Up: Map Next: 38313