Routines |
Prev: E39C | Up: Map | Next: E454 |
Used by the routine at Controls_CheckRight.
|
||||||||||||||||||||
Did the player press left?
|
||||||||||||||||||||
Controls_CheckLeft | E3F9 | CP $02 | Jump to Controls_CheckDown if the player didn't press left (02). | |||||||||||||||||
E3FB | JR NZ,Controls_CheckDown | |||||||||||||||||||
Left movement checks for boundaries and the home box.
|
||||||||||||||||||||
MoveLeft_Checks | E3FD | LD A,($D82D) | A=*DestinationCursor_X_Position. | |||||||||||||||||
Can the player move left?
|
||||||||||||||||||||
E400 | CP $05 | If *DestinationCursor_X_Position is at or beyond the left-most boundary jump to *Handler_CursorMovement. | ||||||||||||||||||
E402 | JP M,Handler_CursorMovement | |||||||||||||||||||
Is the player about to enter the home box?
This is position 06/ 02:
|
||||||||||||||||||||
E405 | CP $06 | If *DestinationCursor_X_Position is not 06 (which confirms the player can't be beside the home box), jump to MoveLeft. | ||||||||||||||||||
E407 | JR NZ,MoveLeft | |||||||||||||||||||
If the horizontal co-ordinate is 06 and the vertical co-ordinate is 02 then the player IS beside the home box.
|
||||||||||||||||||||
E409 | LD A,($D82C) | Now compare *DestinationCursor_Y_Position with 02. | ||||||||||||||||||
E40C | CP $02 | |||||||||||||||||||
E40E | LD A,($D82D) | Reload *DestinationCursor_X_Position into A. | ||||||||||||||||||
E411 | JR NZ,MoveLeft | If *DestinationCursor_Y_Position is not 02 (which confirms the player can't be beside the home box), jump to MoveLeft. | ||||||||||||||||||
Else the player is entering the home box, so the treatment of the cursor isn't quite so simple.
|
||||||||||||||||||||
E413 | SUB $04 | Move *DestinationCursor_X_Position to 04 character blocks to the left. | ||||||||||||||||||
E415 | LD ($D82D),A | |||||||||||||||||||
E418 | DEC (HL) | Update the tile ID the player will land on. | ||||||||||||||||||
E419 | CALL Remove_PlayerCursor | Call Remove_PlayerCursor. | ||||||||||||||||||
Animate the cursor entering the home box.
|
||||||||||||||||||||
E41C | LD HL,$D82F | HL=CurrentCursor_X_Position. | ||||||||||||||||||
Each valid direction moves the cursor one-cursor-width character blocks and rather than simply jump the whole way, the game auto-moves one character block at a time until the cursor reaches it's destination.
I've called these "frames" here, but it's the same cursor just moving between positions, there are no differently stored frames.
|
||||||||||||||||||||
E41F | LD B,$04 | Set a counter in B for 04 animation "frames". | ||||||||||||||||||
E421 | CP $02 | Jump to MoveLeft_Checks if A is equal to 02. | ||||||||||||||||||
E423 | JR Z,MoveLeft_Checks | |||||||||||||||||||
AnimateMoveLeft_Loop | E425 | PUSH BC | Stash the frame counter and horizontal position on the stack. | |||||||||||||||||
E426 | PUSH HL | |||||||||||||||||||
To demonstrate the four "frames" of movement:
So this is what is actually displayed:
|
||||||||||||||||||||
E427 | CALL Draw_Cursor | Call Draw_Cursor. | ||||||||||||||||||
E42A | CALL Home_DefaultAttributes | Call Home_DefaultAttributes. | ||||||||||||||||||
E42D | CALL Sound_Cursor | Call Sound_Cursor. | ||||||||||||||||||
Wait for the next frame.
|
||||||||||||||||||||
E430 | HALT | Halt operation (suspend CPU until the next interrupt). | ||||||||||||||||||
E431 | CALL Remove_PlayerCursorAttributes | Call Remove_PlayerCursorAttributes. | ||||||||||||||||||
E434 | POP HL | Restore the horizontal position and frame counter from the stack. | ||||||||||||||||||
E435 | POP BC | |||||||||||||||||||
E436 | DEC (HL) | Move the cursor position left by one character block. | ||||||||||||||||||
E437 | DJNZ AnimateMoveLeft_Loop | Decrease the frame counter by one and loop back to AnimateMoveLeft_Loop until all 04 frames have played. | ||||||||||||||||||
Mark that the cursor is now inside the home box.
|
||||||||||||||||||||
E439 | LD A,$00 | Write 00 to *PlayerCursor_Flag. | ||||||||||||||||||
E43B | LD ($D835),A | |||||||||||||||||||
Update the stored cursor positions.
|
||||||||||||||||||||
E43E | LD A,($D82C) | Write *DestinationCursor_Y_Position to *StorageCursor_Y_Position. | ||||||||||||||||||
E441 | LD ($D830),A | |||||||||||||||||||
E444 | LD A,($D82D) | Write *DestinationCursor_X_Position to *StorageCursor_X_Position. | ||||||||||||||||||
E447 | LD ($D831),A | |||||||||||||||||||
E44A | RET | Return. | ||||||||||||||||||
Normal left movement.
|
||||||||||||||||||||
MoveLeft | E44B | SUB $04 | Move 04 character blocks left. | |||||||||||||||||
E44D | LD ($D82D),A | Update *DestinationCursor_X_Position. | ||||||||||||||||||
Update the tile ID the player has now landed on.
|
||||||||||||||||||||
E450 | DEC (HL) | Decrease *HL by one. | ||||||||||||||||||
E451 | JP Handler_CursorMovement | Jump to Handler_CursorMovement. |
Prev: E39C | Up: Map | Next: E454 |