![]() |
Routines |
| Prev: 28563 | Up: Map | Next: 28720 |
|
Used by the routine at Handler_ShipMovement.
Moves the player's ship one pixel to the right by shifting the ship graphic and updating the player position. Movement timing is controlled by the movement animation frame counter (counts down from 7 to 0).
|
||||
|
Check if the ship is already at the right edge (221) and whether this frame should perform a movement step.
|
||||
| Handler_MoveShip_Right | 28637 | POP AF | Restore the player position from the stack. | |
| 28638 | CP 221 | Compare the player position with 221. | ||
| 28640 | LD A,(26278) | Load the movement animation frame counter from MovementAnimationFrameCounter. | ||
| 28643 | JR NZ,MoveShipRight_UpdateCounter | Jump to MoveShipRight_UpdateCounter if the ship is not at the right edge. | ||
| 28645 | OR A | Jump to Handler_UpdateShipPosition if the movement animation frame counter is zero (skip movement while touching the edge). | ||
| 28646 | JR Z,Handler_UpdateShipPosition | |||
|
Decrement the movement animation frame counter, wrapping from 0 back to 7. Only when the counter wraps (value 7) is the player position updated.
|
||||
| MoveShipRight_UpdateCounter | 28648 | OR A | Jump to MoveShipRight_ResetCounter if the movement animation frame counter is zero (wrap to 7). | |
| 28649 | JR Z,MoveShipRight_ResetCounter | |||
| 28651 | DEC A | Decrease the movement animation frame counter by one. | ||
| 28652 | JR MoveShipRight_SaveCounter | Jump to MoveShipRight_SaveCounter. | ||
| MoveShipRight_ResetCounter | 28654 | LD A,7 | Load 7 into the movement animation frame counter. | |
| MoveShipRight_SaveCounter | 28656 | LD (26278),A | Write the updated counter back to *MovementAnimationFrameCounter. | |
|
Move the ship only when the counter has just wrapped (value 7).
|
||||
| 28659 | CP 7 | Compare the counter with 7. | ||
| 28661 | LD A,(26349) | Load the player position from PlayerAttributeBufferPosition. | ||
| 28664 | JR NZ,MoveShipRight_Setup | Jump to MoveShipRight_Setup if the counter is not 7 (no movement on this frame). | ||
| 28666 | INC A | Increment the player position by one (move right). | ||
| 28667 | LD (26349),A | Write the updated position to *PlayerAttributeBufferPosition. | ||
|
Prepare the screen position and animate the ship graphic by shifting pixels to the right.
|
||||
| MoveShipRight_Setup | 28670 | PUSH AF | Stash the ship position on the stack. | |
| 28671 | ADD A,2 | Add 2 to A to point to the rightmost ship column. | ||
| 28673 | LD L,A | Copy the screen column into L. | ||
| 28674 | LD B,2 | Set a height counter in B for 2 rows (ship height). | ||
|
Process each row of the ship graphic.
|
||||
| MoveShipRight_RowLoop | 28676 | PUSH BC | Stash the row counter and screen position on the stack. | |
| 28677 | PUSH HL | |||
| 28678 | LD B,8 | Set a line counter in B for 8 pixel lines. | ||
|
Process each pixel line in the current row.
|
||||
| MoveShipRight_LineLoop | 28680 | PUSH BC | Stash the line counter and screen position on the stack. | |
| 28681 | PUSH HL | |||
| 28682 | LD B,3 | Set a width counter in B for 3 bytes (ship width). | ||
|
Shift each byte of the ship graphic right by one pixel, propagating the carry between adjacent bytes.
|
||||
| MoveShipRight_ByteLoop | 28684 | SRL (HL) | Shift the byte at *HL right. | |
| 28686 | DEC HL | Move to the previous byte in the ship graphic. | ||
| 28687 | BIT 0,(HL) | Test bit 0 of the previous byte to see if a bit needs to carry. | ||
| 28689 | RES 0,(HL) | Clear bit 0 of that byte ready for the carry. | ||
| 28691 | INC HL | Move back to the current byte. | ||
| 28692 | JR Z,MoveShipRight_NextByte | Jump to MoveShipRight_NextByte if the width counter has reached zero (no carry to set). | ||
| 28694 | SET 7,(HL) | Set bit 7 of the current byte (propagate the carry from the left). | ||
| MoveShipRight_NextByte | 28696 | DEC HL | Move to the previous byte again. | |
| 28697 | DJNZ MoveShipRight_ByteLoop | Decrease the width counter by one and loop back to MoveShipRight_ByteLoop until the 3 bytes are shifted. | ||
|
Clean up after shifting the line.
|
||||
| 28699 | INC HL | Move to the next byte. | ||
| 28700 | RES 7,(HL) | Clear bit 7 of that byte (remove any overflow). | ||
| 28702 | POP HL | Restore the screen position from the stack. | ||
| 28703 | INC H | Move down one pixel line in the screen buffer. | ||
| 28704 | POP BC | Restore the line counter from the stack. | ||
| 28705 | DJNZ MoveShipRight_LineLoop | Decrease the line counter by one and loop back to MoveShipRight_LineLoop until all 8 lines are processed. | ||
|
Move to the next row and continue processing.
|
||||
| 28707 | POP HL | Restore the screen position from the stack. | ||
| 28708 | SET 5,L | Move to the next row position (set bit 5 of L, add 32). | ||
| 28710 | POP BC | Restore the row counter from the stack. | ||
| 28711 | DJNZ MoveShipRight_RowLoop | Decrease the row counter by one and loop back to MoveShipRight_RowLoop until both rows are processed. | ||
| 28713 | POP AF | Restore the ship position from the stack. | ||
| 28714 | CALL CheckCollision | Call the collision detection routine at CheckCollision. | ||
| 28717 | JP Handler_UpdateShipPosition | Jump to Handler_UpdateShipPosition. | ||
|
Continue on to Handler_UpdateShipPosition.
|
||||
| Prev: 28563 | Up: Map | Next: 28720 |