Routines |
Prev: 58262 | Up: Map | Next: 58361 |
|
||||||||||||||||
Did the player press right?
|
||||||||||||||||
Controls_CheckRight | 58268 | CP 1 | Jump to Controls_CheckLeft if the player didn't press right (1). | |||||||||||||
58270 | JR NZ,Controls_CheckLeft | |||||||||||||||
Right movement checks for boundaries and the home box.
|
||||||||||||||||
MoveRight_Checks | 58272 | LD A,(55341) | A=*DestinationCursor_X_Position. | |||||||||||||
Can the player move right?
|
||||||||||||||||
58275 | CP 15 | If *DestinationCursor_X_Position is at or beyond the right-most boundary jump to *Handler_CursorMovement. | ||||||||||||||
58277 | 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:
|
||||||||||||||||
58280 | CP 2 | If *DestinationCursor_X_Position is not 2 (which confirms the player can't be inside the home box), jump to MoveRight. | ||||||||||||||
58282 | JR NZ,MoveRight | |||||||||||||||
If both the horizontal and the vertical co-ordinates are 2 then the player IS inside the home box.
|
||||||||||||||||
58284 | LD A,(55340) | Now compare *DestinationCursor_Y_Position with 2. | ||||||||||||||
58287 | CP 2 | |||||||||||||||
58289 | LD A,(55341) | Reload *DestinationCursor_X_Position into A. | ||||||||||||||
58292 | JR NZ,MoveRight | If *DestinationCursor_Y_Position is not 2 (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.
|
||||||||||||||||
58294 | ADD A,4 | Move *DestinationCursor_X_Position to 4 character blocks to the right. | ||||||||||||||
58296 | LD (55341),A | |||||||||||||||
58299 | INC (HL) | Update the tile ID the player will land on. | ||||||||||||||
58300 | LD A,0 | Write 0 to *PlayerCursor_Flag, the cursor is still inside the home box and so isn't drawn to the screen buffer just yet. | ||||||||||||||
58302 | LD (55349),A | |||||||||||||||
The player is leaving the home box, so reset the colour of the arrow.
|
||||||||||||||||
58305 | LD A,47 | A=INK: WHITE, PAPER: CYAN . | ||||||||||||||
58307 | CALL ColouriseHome | Call ColouriseHome. | ||||||||||||||
Animate the cursor leaving the home box.
|
||||||||||||||||
58310 | LD HL,55343 | HL=CurrentCursor_X_Position. | ||||||||||||||
58313 | 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.
|
||||||||||||||||
58314 | LD B,3 | Set a counter in B for 3 animation "frames". | ||||||||||||||
AnimateMoveRight_Loop | 58316 | PUSH BC | Stash the frame counter and horizontal position on the stack. | |||||||||||||
58317 | PUSH HL | |||||||||||||||
To demonstrate the three "frames" of movement:
So this is what is actually displayed:
|
||||||||||||||||
58318 | CALL Draw_Cursor | Call Draw_Cursor. | ||||||||||||||
58321 | CALL Home_DefaultAttributes | Call Home_DefaultAttributes. | ||||||||||||||
58324 | CALL Sound_Cursor | Call Sound_Cursor. | ||||||||||||||
Wait for the next frame.
|
||||||||||||||||
58327 | HALT | Halt operation (suspend CPU until the next interrupt). | ||||||||||||||
58328 | CALL Remove_PlayerCursorAttributes | Call Remove_PlayerCursorAttributes. | ||||||||||||||
58331 | POP HL | Restore the horizontal position and frame counter from the stack. | ||||||||||||||
58332 | POP BC | |||||||||||||||
58333 | INC (HL) | Move the cursor position right by one character block. | ||||||||||||||
58334 | DJNZ AnimateMoveRight_Loop | Decrease the frame counter by one and loop back to AnimateMoveRight_Loop until all 3 frames have played. | ||||||||||||||
Display the cursor in its final position.
|
||||||||||||||||
58336 | CALL Display_PlayerCursor | Call Display_PlayerCursor. | ||||||||||||||
Update the stored cursor positions.
|
||||||||||||||||
58339 | LD A,(55340) | Write *DestinationCursor_Y_Position to *StorageCursor_Y_Position. | ||||||||||||||
58342 | LD (55344),A | |||||||||||||||
58345 | LD A,(55341) | Write *DestinationCursor_X_Position to *StorageCursor_X_Position. | ||||||||||||||
58348 | LD (55345),A | |||||||||||||||
58351 | RET | Return. | ||||||||||||||
Normal right movement.
|
||||||||||||||||
MoveRight | 58352 | ADD A,4 | Move 4 character blocks right. | |||||||||||||
58354 | LD (55341),A | Update *DestinationCursor_X_Position. | ||||||||||||||
Update the tile ID the player has now landed on.
|
||||||||||||||||
58357 | INC (HL) | Increment *HL by one. | ||||||||||||||
58358 | JP Handler_CursorMovement | Jump to Handler_CursorMovement. |
Prev: 58262 | Up: Map | Next: 58361 |