Prev: 58361 Up: Map Next: 58491
58452: Controls: Down
Used by the routine at Controls_CheckLeft.
Did the player press down?
Controls_CheckDown 58452 CP 4 Jump to Controls_CheckUp if the player didn't press down (4).
58454 JR NZ,Controls_CheckUp
Down movement checks for boundaries and the home box.
MoveDown_Checks 58456 LD A,(55340) A=*DestinationCursor_Y_Position.
Can the player move down?
58459 CP 15 If *DestinationCursor_Y_Position is at or beyond the bottom-most boundary jump to Handler_CursorMovement.
58461 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 2/ 2:
cursor-02-02
58464 CP 2 If *DestinationCursor_Y_Position is not 2 (which confirms the player can't be inside the home box), jump to MoveDown.
58466 JR NZ,MoveDown
If both the horizontal and the vertical co-ordinates are 2 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.
58468 LD A,(55341) Now compare *DestinationCursor_X_Position with 2.
58471 CP 2
58473 JP Z,Handler_CursorMovement If *DestinationCursor_X_Position is 2 (which confirms that yes, the player is inside the home box), jump to Handler_CursorMovement to prevent the movement from happening.
Normal down movement.
58476 LD A,(55340) Reload *DestinationCursor_Y_Position into A.
MoveDown 58479 ADD A,4 Move 4 rows down.
58481 LD (55340),A Update *DestinationCursor_Y_Position.
Update the tile ID the player has now landed on.
58484 LD A,(HL) Add 7 to *HL.
58485 ADD A,7
58487 LD (HL),A
58488 JP Handler_CursorMovement Jump to Handler_CursorMovement.
Prev: 58361 Up: Map Next: 58491