Prev: 51611 Up: Map Next: 51813
51702: Check if Maroc is moving through an open doorway
Door has been identified as OPEN.
Because door positions vary when open depending on the wall section they sit in, the next routine adjusts the doorway exit point, based on the open door's graphic position.
After this adjustment has been made the collision detection routine at 57301 is used to determine if Maroc is moving through the doorway.
51702 LD A,(60079) Door graphic's horizontal position offset
51705 CP 248
51707 JR Z,51717 The only door frame with this value offset is the back wall open door
51709 CP 232
51711 JR Z,51721 The only door frame with this value offset is the right wall open door
51713 LD A,248 Horizontal pixel offset for left wall open door left wall open door (-8 pixels)
51715 JR 51723
51717 LD A,12 Horizontal pixel offset for the back wall open door (+12 pixels)
51719 JR 51723
51721 LD A,8 Horizontal pixel offset for the right wall open door (+8 pixels)
Add the adjusted offset to door horizontal pixel position
51723 LD B,A Get the pixel offset for this door's exit/entry point
51724 LD A,(60115) Get the door's horizontal pixel position
51727 ADD A,B Add the pixel offset
51728 LD D,A Store in the D register - used for the horizontal 'hit box' for collision check in CALL at 51737 (to 57301)
51729 LD A,(60114) Get the door's vertical pixel position
51732 SUB 8 Small (-8 pixel) vertical adjustment
51734 LD E,A Store in E register - used for the vertical 'hit box' for collision check in CALL at 51737 (to 57301)
51735 LD C,0 Collision type = 0 - this is the collision/event ID for checks against Maroc's position
51737 CALL 57301 Check for collision
51740 CP 0 A register returned with 1 = collision, 0 = no collision
51742 JR NZ,51762 If there's a collision, skip the next few instructions
No collision detected on that check
51744 LD A,E Retrieve previously adjusted horizontal pixel check position
51745 SUB 4 Make a further small (-4 more pixels) horizontal adjustment
51747 LD E,A Store back in E register (horizontal 'hit box' check)
51748 LD A,(60115) Door vertical pixel position
51751 LD D,A Retrieve vertical 'hit box' pixel position from D register
51752 LD C,0 Collision type = 0 - this is the collision/event ID for checks against Maroc's position
51754 CALL 57301 Check for collision
51757 CP 0
51759 JP Z,51958 No collision, can jump out of routine here
Collision detected - Maroc is within range of the open door. Check he's actually moving towards it.
51762 LD A,(60079) Retrieve door graphic's horizontal pixel graphic offset
51765 CP 248 Offset for the back wall open door
51767 JR Z,51788
51769 CP 232 Offset for the right wall open door
51771 LD A,(60164) Get Maroc's horizontal movement speed as it'll need to be evaluated for left and right wall doors
51774 JR Z,51803
Door is a left wall open door. Check Maroc's horizontal movement:
51776 CP 0 Is Maroc moving left or right?
51778 JP Z,51958 If not, skip out of this routine
51781 CP 128
51783 JP NC,51958 Skip out of this routine if Maroc is moving right
51786 JR 51813 ...otherwise Maroc is moving left, so send him through the doorway
Door is a back wall open door. Check Maroc's vertical movement:
51788 LD A,(60165) Maroc's vertical movement speed
51791 CP 0 Is Maroc moving up or down?
51793 JP Z,51958 If not, skip out of this routine
51796 CP 128
51798 JP NC,51958 Skip out of this routine if Maroc is moving down
51801 JR 51813 ...otherwise Maroc is moving upwards, so send him through the doorway
Door is a right wall open door. Check Maroc's horizontal movement:
51803 CP 0 Is Maroc moving left or right?
51805 JP Z,51958 If not, skip out of this routine
51808 CP 128
51810 JP C,51958 Skip out of this routine if Maroc is moving left
...otherwise Maroc is moving right, so send him through the doorway (continue to the next routine)
Prev: 51611 Up: Map Next: 51813