![]() |
Routines |
| Prev: CB45 | Up: Map | Next: CBE9 |
|
Used by the routine at BlockMovement.
Brings the speed in X of an object closer to zero until it does not run into any other object. If the object does run into another, the objects may destroy each other: bit 7 of the flags in byte 0D of an object means that it destroys whatever it runs into, bit 5 means that it destroys whatever runs into it, and bit 6 means that the object is destroyed. An object that can be moved is pushed along at the same speed in X.
|
||||||||||||||||||
|
Test each object, then slow the X speed if they overlap.
|
||||||||||||||||||
| BlockMovementInX | CB9A | LD IY,$5C08 | Point IY at the first object in the table, ObjectsTable. | |||||||||||||||
| CB9E | LD B,$28 | Set the number of objects to 28. | ||||||||||||||||
| BlockMovementInX_Next | CBA0 | CALL TestObjectSolid | Test whether the object is present and not ignored. | |||||||||||||||
| CBA3 | JR Z,BlockMovementInX_Advance | Jump to BlockMovementInX_Advance if it is not. | ||||||||||||||||
| CBA5 | CALL TestOverlapInY | Test whether the objects overlap in Y. | ||||||||||||||||
| CBA8 | JR NC,BlockMovementInX_Advance | Jump to BlockMovementInX_Advance if they do not. | ||||||||||||||||
| CBAA | CALL TestOverlapInZ | Test whether the objects overlap in Z. | ||||||||||||||||
| CBAD | JR NC,BlockMovementInX_Advance | Jump to BlockMovementInX_Advance if they do not. | ||||||||||||||||
| BlockMovementInX_Test | CBAF | CALL TestOverlapInX | Test whether the objects overlap in X after the move. | |||||||||||||||
| CBB2 | JR NC,BlockMovementInX_Advance | Jump to BlockMovementInX_Advance if they do not. | ||||||||||||||||
| CBB4 | SET 0,(IX+$0C) | Flag the object as blocked in X. | ||||||||||||||||
| CBB8 | LD A,(IX+$0D) | Fetch the flags of the object and move the bit that it destroys what it hits into bit 6. | ||||||||||||||||
| CBBB | RRCA | |||||||||||||||||
| CBBC | AND %01000000 | Keep the bit that flags the other object as destroyed. | ||||||||||||||||
| CBBE | OR (IY+$0D) | Set it in the flags of the other object, if the object destroys what it runs into. | ||||||||||||||||
| CBC1 | LD (IY+$0D),A | |||||||||||||||||
| CBC4 | RLCA | Move the bit that the other object destroys what it hits into bit 6. | ||||||||||||||||
| CBC5 | AND %01000000 | Keep the bit that flags the object as destroyed. | ||||||||||||||||
| CBC7 | OR (IX+$0D) | Set it in the flags of the object, if the other object destroys what runs into it. | ||||||||||||||||
| CBCA | LD (IX+$0D),A | |||||||||||||||||
| CBCD | BIT 2,(IY+$07) | Jump to BlockMovementInX_Slow if the other object cannot be moved. | ||||||||||||||||
| CBD1 | JR Z,BlockMovementInX_Slow | |||||||||||||||||
| CBD3 | LD A,(IX+$09) | Fetch the speed in X of the object. | ||||||||||||||||
| CBD6 | LD (IY+$09),A | Give it to the other object. | ||||||||||||||||
| BlockMovementInX_Slow | CBD9 | LD A,C | Fetch the speed in X. | |||||||||||||||
| CBDA | CALL BringSpeedCloserToZero | Bring it closer to zero. | ||||||||||||||||
| CBDD | LD C,A | Store it. | ||||||||||||||||
| CBDE | RET Z | Return if it is zero. | ||||||||||||||||
| CBDF | JR BlockMovementInX_Test | Jump to BlockMovementInX_Test to test it again. | ||||||||||||||||
| BlockMovementInX_Advance | CBE1 | LD DE,$0020 | Set DE to the size of an object. | |||||||||||||||
| CBE4 | ADD IY,DE | Point IY at the next object. | ||||||||||||||||
| CBE6 | DJNZ BlockMovementInX_Next | Jump to BlockMovementInX_Next until all of the objects have been tested. | ||||||||||||||||
| CBE8 | RET | Return. | ||||||||||||||||
| Prev: CB45 | Up: Map | Next: CBE9 |