Prev: E3F9 Up: Map Next: E47B
E454: Controls: Down
Used by the routine at Controls_CheckLeft.
Did the player press down?
Controls_CheckDown E454 CP $04 Jump to Controls_CheckUp if the player didn't press down (04).
E456 JR NZ,Controls_CheckUp
Down movement checks for boundaries and the home box.
MoveDown_Checks E458 LD A,($D82C) A=*DestinationCursor_Y_Position.
Can the player move down?
E45B CP $0F If *DestinationCursor_Y_Position is at or beyond the bottom-most boundary jump to Handler_CursorMovement.
E45D JP P,Handler_CursorMovement
Is the player inside the home box?
The game restricts this (i.e. this image would never happen), but to demonstrate - this is position 02/ 02:
cursor-02-02
E460 CP $02 If *DestinationCursor_Y_Position is not 02 (which confirms the player can't be inside the home box), jump to MoveDown.
E462 JR NZ,MoveDown
If both the horizontal and the vertical co-ordinates are 02 then the player IS inside the home box. The outcome is different to left and right though - the home box can only be exited by moving right. So for this "down" action, we treat the bottom side of the home box as another boundary and don't allow the player to move through it.
E464 LD A,($D82D) Now compare *DestinationCursor_X_Position with 02.
E467 CP $02
E469 JP Z,Handler_CursorMovement If *DestinationCursor_X_Position is 02 (which confirms that yes, the player is inside the home box), jump to Handler_CursorMovement to prevent the movement from happening.
Normal down movement.
E46C LD A,($D82C) Reload *DestinationCursor_Y_Position into A.
MoveDown E46F ADD A,$04 Move 04 rows down.
E471 LD ($D82C),A Update *DestinationCursor_Y_Position.
Update the tile ID the player has now landed on.
E474 LD A,(HL) Add 07 to *HL.
E475 ADD A,$07
E477 LD (HL),A
E478 JP Handler_CursorMovement Jump to Handler_CursorMovement.
Prev: E3F9 Up: Map Next: E47B