![]() |
Routines |
| Prev: 6EF8 | Up: Map | Next: 6F93 |
|
Used by the routine at Handler_ShipMovement.
Handles moving the player's ship left by animating the ship graphic and updating the ship position. The movement is frame-based, controlled by the movement animation frame counter.
|
||||
|
Check if the ship is at the left edge of the screen and if movement should be skipped this frame.
|
||||
| Handler_MoveShip_Left | 6F43 | POP AF | Restore the player position from the stack. | |
| 6F44 | CP $C0 | Jump to MoveShipLeft_Animate if the player position is not at the left edge (C0). | ||
| 6F46 | JR NZ,MoveShipLeft_Animate | |||
| 6F48 | LD A,($66A6) | Jump to Handler_UpdateShipPosition if the movement animation frame counter at *MovementAnimationFrameCounter is equal to 03 (skip movement this frame). | ||
| 6F4B | CP $03 | |||
| 6F4D | JR Z,Handler_UpdateShipPosition | |||
|
The ship is at the left edge, so load the player position to prepare for animation.
|
||||
| 6F4F | LD A,($66ED) | Load the low byte of the player position from PlayerAttributeBufferPosition into L. | ||
|
Set up the screen position and animate the ship graphic by shifting pixels left.
|
||||
| MoveShipLeft_Animate | 6F52 | LD L,A | Load L with the low byte of the player position. | |
| 6F53 | LD B,$02 | Set a height counter in B for 02 rows (the ship height). | ||
|
Process each row of the ship graphic, shifting all pixels left by one position.
|
||||
| MoveShipLeft_RowLoop | 6F55 | PUSH BC | Stash the row counter and screen position on the stack. | |
| 6F56 | PUSH HL | |||
| 6F57 | LD B,$08 | Set a line counter in B (08 lines in a UDG). | ||
|
Process each pixel line within the current row.
|
||||
| MoveShipLeft_LineLoop | 6F59 | PUSH BC | Stash the line counter and screen position on the stack. | |
| 6F5A | PUSH HL | |||
| 6F5B | LD B,$03 | Set a width counter in B for 03 bytes (the ship width). | ||
|
Shift each byte of the ship graphic left by one pixel, propagating the carry bit between bytes to create smooth scrolling.
|
||||
| MoveShipLeft_ByteLoop | 6F5D | SLA (HL) | Shift the byte at *HL left by one bit. | |
| 6F5F | INC HL | Move to the next byte in the ship graphic. | ||
| 6F60 | BIT 7,(HL) | Test bit 7 of the next byte to check if a bit was carried over. | ||
| 6F62 | DEC HL | Move back to the previous byte. | ||
| 6F63 | JR Z,MoveShipLeft_NextByte | Jump to MoveShipLeft_NextByte if bit 7 was not set (no carry). | ||
| 6F65 | SET 0,(HL) | Set bit 0 of the current byte (propagate the carry from the previous byte). | ||
| MoveShipLeft_NextByte | 6F67 | INC HL | Move to the next byte in the ship graphic. | |
| 6F68 | DJNZ MoveShipLeft_ByteLoop | Decrease the width counter by one and loop back to MoveShipLeft_ByteLoop until all 03 bytes are shifted. | ||
|
Clean up after shifting the bytes in this line.
|
||||
| 6F6A | DEC HL | Move back to the last byte. | ||
| 6F6B | RES 0,(HL) | Reset bit 0 of the last byte (clear any overflow). | ||
| 6F6D | POP HL | Restore the screen position from the stack. | ||
| 6F6E | INC H | Move down one pixel line in the screen buffer. | ||
| 6F6F | POP BC | Restore the line counter from the stack. | ||
| 6F70 | DJNZ MoveShipLeft_LineLoop | Decrease the line counter by one and loop back to MoveShipLeft_LineLoop until all 08 lines have been processed. | ||
|
Move to the next row and continue processing.
|
||||
| 6F72 | POP HL | Restore the screen position from the stack. | ||
| 6F73 | SET 5,L | Move to the next row position (set bit 5 of L, add 20). | ||
| 6F75 | POP BC | Restore the row counter from the stack. | ||
| 6F76 | DJNZ MoveShipLeft_RowLoop | Decrease the row counter by one and loop back to MoveShipLeft_RowLoop until both rows are processed. | ||
|
Update the movement animation frame counter. The counter cycles from 00 to 07 and the ship position is only updated when the counter completes a full cycle (wraps from 07 to 00).
|
||||
| 6F78 | LD A,($66A6) | Jump to MoveShipLeft_ResetCounter if the movement animation frame counter at *MovementAnimationFrameCounter is equal to 07 (wrap to 00). | ||
| 6F7B | CP $07 | |||
| 6F7D | JR Z,MoveShipLeft_ResetCounter | |||
| 6F7F | INC A | Increment the movement animation frame counter. | ||
| 6F80 | JR MoveShipLeft_UpdatePosition | Jump to MoveShipLeft_UpdatePosition. | ||
| MoveShipLeft_ResetCounter | 6F82 | XOR A | Reset the movement animation frame counter to 00 (complete cycle). | |
| MoveShipLeft_UpdatePosition | 6F83 | LD ($66A6),A | Write the updated movement animation frame counter to *MovementAnimationFrameCounter. | |
| 6F86 | OR A | Test if the counter is zero (movement frame complete). | ||
| 6F87 | LD A,($66ED) | Load the player position from PlayerAttributeBufferPosition. | ||
| 6F8A | JR NZ,MoveShipLeft_SavePosition | Jump to MoveShipLeft_SavePosition if the counter is not zero (don't move position yet). | ||
|
The movement animation frame counter has completed a cycle, so update the ship position.
|
||||
| 6F8C | DEC A | Decrease the player position by one (move ship left). | ||
| MoveShipLeft_SavePosition | 6F8D | LD ($66ED),A | Write the updated player position to *PlayerAttributeBufferPosition. | |
| 6F90 | CALL CheckCollision | Call the collision detection routine at CheckCollision. | ||
|
Continue on to Handler_UpdateShipPosition.
|
||||
| Prev: 6EF8 | Up: Map | Next: 6F93 |