Routines |
Prev: 58268 | Up: Map | Next: 58452 |
Used by the routine at Controls_CheckRight.
|
||||||||||||||||||||
Did the player press left?
|
||||||||||||||||||||
Controls_CheckLeft | 58361 | CP 2 | Jump to Controls_CheckDown if the player didn't press left (2). | |||||||||||||||||
58363 | JR NZ,Controls_CheckDown | |||||||||||||||||||
Left movement checks for boundaries and the home box.
|
||||||||||||||||||||
MoveLeft_Checks | 58365 | LD A,(55341) | A=*DestinationCursor_X_Position. | |||||||||||||||||
Can the player move left?
|
||||||||||||||||||||
58368 | CP 5 | If *DestinationCursor_X_Position is at or beyond the left-most boundary jump to *Handler_CursorMovement. | ||||||||||||||||||
58370 | JP M,Handler_CursorMovement | |||||||||||||||||||
Is the player about to enter the home box?
This is position 6/ 2:
|
||||||||||||||||||||
58373 | CP 6 | If *DestinationCursor_X_Position is not 6 (which confirms the player can't be beside the home box), jump to MoveLeft. | ||||||||||||||||||
58375 | JR NZ,MoveLeft | |||||||||||||||||||
If the horizontal co-ordinate is 6 and the vertical co-ordinate is 2 then the player IS beside the home box.
|
||||||||||||||||||||
58377 | LD A,(55340) | Now compare *DestinationCursor_Y_Position with 2. | ||||||||||||||||||
58380 | CP 2 | |||||||||||||||||||
58382 | LD A,(55341) | Reload *DestinationCursor_X_Position into A. | ||||||||||||||||||
58385 | JR NZ,MoveLeft | If *DestinationCursor_Y_Position is not 2 (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.
|
||||||||||||||||||||
58387 | SUB 4 | Move *DestinationCursor_X_Position to 4 character blocks to the left. | ||||||||||||||||||
58389 | LD (55341),A | |||||||||||||||||||
58392 | DEC (HL) | Update the tile ID the player will land on. | ||||||||||||||||||
58393 | CALL Remove_PlayerCursor | Call Remove_PlayerCursor. | ||||||||||||||||||
Animate the cursor entering the home box.
|
||||||||||||||||||||
58396 | LD HL,55343 | 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.
|
||||||||||||||||||||
58399 | LD B,4 | Set a counter in B for 4 animation "frames". | ||||||||||||||||||
58401 | CP 2 | Jump to MoveLeft_Checks if A is equal to 2. | ||||||||||||||||||
58403 | JR Z,MoveLeft_Checks | |||||||||||||||||||
AnimateMoveLeft_Loop | 58405 | PUSH BC | Stash the frame counter and horizontal position on the stack. | |||||||||||||||||
58406 | PUSH HL | |||||||||||||||||||
To demonstrate the four "frames" of movement:
So this is what is actually displayed:
|
||||||||||||||||||||
58407 | CALL Draw_Cursor | Call Draw_Cursor. | ||||||||||||||||||
58410 | CALL Home_DefaultAttributes | Call Home_DefaultAttributes. | ||||||||||||||||||
58413 | CALL Sound_Cursor | Call Sound_Cursor. | ||||||||||||||||||
Wait for the next frame.
|
||||||||||||||||||||
58416 | HALT | Halt operation (suspend CPU until the next interrupt). | ||||||||||||||||||
58417 | CALL Remove_PlayerCursorAttributes | Call Remove_PlayerCursorAttributes. | ||||||||||||||||||
58420 | POP HL | Restore the horizontal position and frame counter from the stack. | ||||||||||||||||||
58421 | POP BC | |||||||||||||||||||
58422 | DEC (HL) | Move the cursor position left by one character block. | ||||||||||||||||||
58423 | DJNZ AnimateMoveLeft_Loop | Decrease the frame counter by one and loop back to AnimateMoveLeft_Loop until all 4 frames have played. | ||||||||||||||||||
Mark that the cursor is now inside the home box.
|
||||||||||||||||||||
58425 | LD A,0 | Write 0 to *PlayerCursor_Flag. | ||||||||||||||||||
58427 | LD (55349),A | |||||||||||||||||||
Update the stored cursor positions.
|
||||||||||||||||||||
58430 | LD A,(55340) | Write *DestinationCursor_Y_Position to *StorageCursor_Y_Position. | ||||||||||||||||||
58433 | LD (55344),A | |||||||||||||||||||
58436 | LD A,(55341) | Write *DestinationCursor_X_Position to *StorageCursor_X_Position. | ||||||||||||||||||
58439 | LD (55345),A | |||||||||||||||||||
58442 | RET | Return. | ||||||||||||||||||
Normal left movement.
|
||||||||||||||||||||
MoveLeft | 58443 | SUB 4 | Move 4 character blocks left. | |||||||||||||||||
58445 | LD (55341),A | Update *DestinationCursor_X_Position. | ||||||||||||||||||
Update the tile ID the player has now landed on.
|
||||||||||||||||||||
58448 | DEC (HL) | Decrease *HL by one. | ||||||||||||||||||
58449 | JP Handler_CursorMovement | Jump to Handler_CursorMovement. |
Prev: 58268 | Up: Map | Next: 58452 |