![]() |
Routines |
| Prev: 45596 | Up: Map | Next: 45671 |
|
The handler for a block which moves east and west (object 66), and the code shared with HandleBlockMovingNorthSouth. The block follows a target that swings over 32 frames from FrameCounter. Neighbouring blocks are out of step because the low byte of the object address is added in. It moves by 1 each frame, with gravity cancelled out.
The axis is chosen by changing the operands of HandleBlockMoving_Compare and HandleBlockMoving_SetSpeed.
|
||||||||
|
Choose the x axis.
|
||||||||
| HandleBlockMovingEastWest | 45604 | CALL PlaySoundFromXPosition | Call PlaySoundFromXPosition. | |||||
| 45607 | LD HL,265 | Set HL to 265. | ||||||
|
This entry point is used by the routine at HandleBlockMovingNorthSouth.
Change the later instructions to use the chosen axis.
|
||||||||
| HandleBlockMoving | 45610 | LD A,H | Write H to 45643. | |||||
| 45611 | LD (45643),A | |||||||
| 45614 | LD A,L | Write L to 45660. | ||||||
| 45615 | LD (45660),A | |||||||
| 45618 | CALL SetPixelAdjustments | Call SetPixelAdjustments. | ||||||
|
Work out a target from 0 to 15.
|
||||||||
| 45621 | PUSH IX | Copy IX to BC (using the stack). | ||||||
| 45623 | POP BC | |||||||
| 45624 | LD A,C | Fetch the low byte and move bit 5 to bit 4. | ||||||
| 45625 | RRCA | |||||||
| 45626 | AND %00010000 | Keep bit 4. | ||||||
| 45628 | LD C,A | Keep it in C. | ||||||
| 45629 | LD A,(23298) | Fetch FrameCounter. | ||||||
| 45632 | ADD A,C | Add the difference between neighbouring objects. | ||||||
| 45633 | BIT 4,A | Jump to HandleBlockMoving_Target if bit 4 is clear. | ||||||
| 45635 | JR Z,HandleBlockMoving_Target | |||||||
| 45637 | CPL | Invert it. | ||||||
| HandleBlockMoving_Target | 45638 | AND %00001111 | Keep bits 0 to 3. | |||||
| 45640 | LD C,A | Keep the target in C. | ||||||
|
Set a speed of 1 towards the target.
|
||||||||
| HandleBlockMoving_Compare | 45641 | LD A,(IX+1) | Fetch the position along the chosen axis. | |||||
| 45644 | ADD A,8 | Add 8. | ||||||
| 45646 | AND %00001111 | Keep bits 0 to 3. | ||||||
| 45648 | CP C | Jump to SetWipeAndDrawFlags if the block is at the target. | ||||||
| 45649 | JP Z,SetWipeAndDrawFlags | |||||||
| 45652 | LD A,1 | Set the speed to 1. | ||||||
| 45654 | JR C,HandleBlockMoving_SetSpeed | Jump to HandleBlockMoving_SetSpeed if the block is below the target. | ||||||
| 45656 | NEG | Make the speed negative. | ||||||
|
Set that speed, cancel gravity, and move the block.
|
||||||||
| HandleBlockMoving_SetSpeed | 45658 | LD (IX+9),A | Set the speed along the chosen axis. | |||||
| 45661 | LD (IX+11),1 | Write 1 as the speed along the z axis. | ||||||
| 45665 | CALL ApplyGravityAndMove | Call ApplyGravityAndMove. | ||||||
| 45668 | JP SetWipeAndDrawFlags | Jump to SetWipeAndDrawFlags. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: 45596 | Up: Map | Next: 45671 |