![]() |
Routines |
| Prev: B21C | Up: Map | Next: B267 |
|
The handler for a block which moves east and west (object 42), and the code shared with HandleBlockMovingNorthSouth. The block follows a target that swings over 20 frames from FrameCounter. Neighbouring blocks are out of step because the low byte of the object address is added in. It moves by 01 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 | B224 | CALL PlaySoundFromXPosition | Call PlaySoundFromXPosition. | |||||
| B227 | LD HL,$0109 | Set HL to 0109. | ||||||
|
This entry point is used by the routine at HandleBlockMovingNorthSouth.
Change the later instructions to use the chosen axis.
|
||||||||
| HandleBlockMoving | B22A | LD A,H | Write H to B24B. | |||||
| B22B | LD ($B24B),A | |||||||
| B22E | LD A,L | Write L to B25C. | ||||||
| B22F | LD ($B25C),A | |||||||
| B232 | CALL SetPixelAdjustments | Call SetPixelAdjustments. | ||||||
|
Work out a target from 00 to 0F.
|
||||||||
| B235 | PUSH IX | Copy IX to BC (using the stack). | ||||||
| B237 | POP BC | |||||||
| B238 | LD A,C | Fetch the low byte and move bit 5 to bit 4. | ||||||
| B239 | RRCA | |||||||
| B23A | AND %00010000 | Keep bit 4. | ||||||
| B23C | LD C,A | Keep it in C. | ||||||
| B23D | LD A,($5B02) | Fetch FrameCounter. | ||||||
| B240 | ADD A,C | Add the difference between neighbouring objects. | ||||||
| B241 | BIT 4,A | Jump to HandleBlockMoving_Target if bit 4 is clear. | ||||||
| B243 | JR Z,HandleBlockMoving_Target | |||||||
| B245 | CPL | Invert it. | ||||||
| HandleBlockMoving_Target | B246 | AND %00001111 | Keep bits 0 to 3. | |||||
| B248 | LD C,A | Keep the target in C. | ||||||
|
Set a speed of 01 towards the target.
|
||||||||
| HandleBlockMoving_Compare | B249 | LD A,(IX+$01) | Fetch the position along the chosen axis. | |||||
| B24C | ADD A,$08 | Add 08. | ||||||
| B24E | AND %00001111 | Keep bits 0 to 3. | ||||||
| B250 | CP C | Jump to SetWipeAndDrawFlags if the block is at the target. | ||||||
| B251 | JP Z,SetWipeAndDrawFlags | |||||||
| B254 | LD A,$01 | Set the speed to 01. | ||||||
| B256 | JR C,HandleBlockMoving_SetSpeed | Jump to HandleBlockMoving_SetSpeed if the block is below the target. | ||||||
| B258 | NEG | Make the speed negative. | ||||||
|
Set that speed, cancel gravity, and move the block.
|
||||||||
| HandleBlockMoving_SetSpeed | B25A | LD (IX+$09),A | Set the speed along the chosen axis. | |||||
| B25D | LD (IX+$0B),$01 | Write 01 as the speed along the z axis. | ||||||
| B261 | CALL ApplyGravityAndMove | Call ApplyGravityAndMove. | ||||||
| B264 | JP SetWipeAndDrawFlags | Jump to SetWipeAndDrawFlags. | ||||||
|
View the equivalent code in;
|
||||||||
| Prev: B21C | Up: Map | Next: B267 |