Routines |
Prev: E396 | Up: Map | Next: E3F9 |
|
||||||||||||||||
Did the player press right?
|
||||||||||||||||
Controls_CheckRight | E39C | CP $01 | Jump to Controls_CheckLeft if the player didn't press right (01). | |||||||||||||
E39E | JR NZ,Controls_CheckLeft | |||||||||||||||
Right movement checks for boundaries and the home box.
|
||||||||||||||||
MoveRight_Checks | E3A0 | LD A,($D82D) | A=*DestinationCursor_X_Position. | |||||||||||||
Can the player move right?
|
||||||||||||||||
E3A3 | CP $0F | If *DestinationCursor_X_Position is at or beyond the right-most boundary jump to *Handler_CursorMovement. | ||||||||||||||
E3A5 | 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:
|
||||||||||||||||
E3A8 | CP $02 | If *DestinationCursor_X_Position is not 02 (which confirms the player can't be inside the home box), jump to MoveRight. | ||||||||||||||
E3AA | JR NZ,MoveRight | |||||||||||||||
If both the horizontal and the vertical co-ordinates are 02 then the player IS inside the home box.
|
||||||||||||||||
E3AC | LD A,($D82C) | Now compare *DestinationCursor_Y_Position with 02. | ||||||||||||||
E3AF | CP $02 | |||||||||||||||
E3B1 | LD A,($D82D) | Reload *DestinationCursor_X_Position into A. | ||||||||||||||
E3B4 | JR NZ,MoveRight | If *DestinationCursor_Y_Position is not 02 (which confirms the player can't be inside the home box), jump to MoveRight. | ||||||||||||||
Else the player is inside the home box, so the treatment of the cursor isn't quite so simple.
|
||||||||||||||||
E3B6 | ADD A,$04 | Move *DestinationCursor_X_Position to 04 character blocks to the right. | ||||||||||||||
E3B8 | LD ($D82D),A | |||||||||||||||
E3BB | INC (HL) | Update the tile ID the player will land on. | ||||||||||||||
E3BC | LD A,$00 | Write 00 to *PlayerCursor_Flag, the cursor is still inside the home box and so isn't drawn to the screen buffer just yet. | ||||||||||||||
E3BE | LD ($D835),A | |||||||||||||||
The player is leaving the home box, so reset the colour of the arrow.
|
||||||||||||||||
E3C1 | LD A,$2F | A=INK: WHITE, PAPER: CYAN . | ||||||||||||||
E3C3 | CALL ColouriseHome | Call ColouriseHome. | ||||||||||||||
Animate the cursor leaving the home box.
|
||||||||||||||||
E3C6 | LD HL,$D82F | HL=CurrentCursor_X_Position. | ||||||||||||||
E3C9 | INC (HL) | Move the cursor position right by one character block. | ||||||||||||||
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.
|
||||||||||||||||
E3CA | LD B,$03 | Set a counter in B for 03 animation "frames". | ||||||||||||||
AnimateMoveRight_Loop | E3CC | PUSH BC | Stash the frame counter and horizontal position on the stack. | |||||||||||||
E3CD | PUSH HL | |||||||||||||||
To demonstrate the three "frames" of movement:
So this is what is actually displayed:
|
||||||||||||||||
E3CE | CALL Draw_Cursor | Call Draw_Cursor. | ||||||||||||||
E3D1 | CALL Home_DefaultAttributes | Call Home_DefaultAttributes. | ||||||||||||||
E3D4 | CALL Sound_Cursor | Call Sound_Cursor. | ||||||||||||||
Wait for the next frame.
|
||||||||||||||||
E3D7 | HALT | Halt operation (suspend CPU until the next interrupt). | ||||||||||||||
E3D8 | CALL Remove_PlayerCursorAttributes | Call Remove_PlayerCursorAttributes. | ||||||||||||||
E3DB | POP HL | Restore the horizontal position and frame counter from the stack. | ||||||||||||||
E3DC | POP BC | |||||||||||||||
E3DD | INC (HL) | Move the cursor position right by one character block. | ||||||||||||||
E3DE | DJNZ AnimateMoveRight_Loop | Decrease the frame counter by one and loop back to AnimateMoveRight_Loop until all 03 frames have played. | ||||||||||||||
Display the cursor in its final position.
|
||||||||||||||||
E3E0 | CALL Display_PlayerCursor | Call Display_PlayerCursor. | ||||||||||||||
Update the stored cursor positions.
|
||||||||||||||||
E3E3 | LD A,($D82C) | Write *DestinationCursor_Y_Position to *StorageCursor_Y_Position. | ||||||||||||||
E3E6 | LD ($D830),A | |||||||||||||||
E3E9 | LD A,($D82D) | Write *DestinationCursor_X_Position to *StorageCursor_X_Position. | ||||||||||||||
E3EC | LD ($D831),A | |||||||||||||||
E3EF | RET | Return. | ||||||||||||||
Normal right movement.
|
||||||||||||||||
MoveRight | E3F0 | ADD A,$04 | Move 04 character blocks right. | |||||||||||||
E3F2 | LD ($D82D),A | Update *DestinationCursor_X_Position. | ||||||||||||||
Update the tile ID the player has now landed on.
|
||||||||||||||||
E3F5 | INC (HL) | Increment *HL by one. | ||||||||||||||
E3F6 | JP Handler_CursorMovement | Jump to Handler_CursorMovement. |
Prev: E396 | Up: Map | Next: E3F9 |