![]() |
Routines |
| Prev: DC3F | Up: Map | Next: DD61 |
|
Used by the routine at TestGroupObjects.
Moves an entity off the overlap whose axis is the smallest of the three held at OverlapDistances. The x axis is handled by HandleOverlapFirst and the y axis by HandleOverlapSecond. On z, a player under a flagged block changes frame, the difference is planted for TestEntityCells, and the vertical speed pushes the entity clear. A saucer sets the high byte of its vertical speed to 02 first.
|
||||||||||
|
The smallest overlap chooses the axis. A saucer is pushed up before the choice is made.
|
||||||||||
| HandleOverlap | DC6A | LD A,(IX+$00) | A saucer sets its vertical speed. | |||||||
| DC6D | CP $09 | |||||||||
| DC6F | JR NZ,HandleOverlap_Compare | |||||||||
| DC71 | LD (IX+$12),$02 | Set the high byte of the vertical speed to 02. | ||||||||
|
This entry point is used by the routine at TestEntityPair.
|
||||||||||
| HandleOverlap_Compare | DC75 | LD A,($DDCF) | Read the x overlap. | |||||||
| DC78 | LD B,A | |||||||||
| DC79 | LD A,($DDD1) | Compare it with the y overlap. | ||||||||
| DC7C | CP B | |||||||||
| DC7D | JP NC,HandleOverlapFirst | Handle x when it is the smaller overlap. | ||||||||
| DC80 | LD B,A | Keep the y overlap. | ||||||||
| DC81 | LD A,($DDD3) | Compare it with the z overlap. | ||||||||
| DC84 | CP B | |||||||||
| DC85 | JP NC,HandleOverlapSecond | Handle y when it is the smaller overlap. | ||||||||
|
This entry point is used by the routine at HandleOverlapFirst.
The z overlap is the smallest. A player whose block has the top flag set takes frame 02 and the sides of the block choose the push.
|
||||||||||
| HandleOverlap_Vertical | DC88 | LD A,(IX+$00) | Remember the type. | |||||||
| DC8B | LD ($D5A4),A | |||||||||
| DC8E | DEC A | Only the player changes frame. | ||||||||
| DC8F | JR NZ,HandleOverlap_Frame | |||||||||
| DC91 | LD A,($5CD8) | Read the object's flags. | ||||||||
| DC94 | RLA | Change the frame when the top flag is set. | ||||||||
| DC95 | JR NC,HandleOverlap_Frame | |||||||||
| DC97 | LD A,(IX+$01) | Use the top three bits of the frame. | ||||||||
| DC9A | AND $E0 | |||||||||
| DC9C | OR %00000010 | Set the frame number to 02. | ||||||||
| DC9E | LD (IX+$01),A | Keep that frame. | ||||||||
| DCA1 | CALL SetEntitySize | Measure the sprite. | ||||||||
| HandleOverlap_Frame | DCA4 | BIT 5,(IX+$01) | Move straight on when bit 5 of the frame is set. | |||||||
| DCA8 | JP NZ,HandleOverlap_Move | |||||||||
| DCAB | LD D,(IX+$02) | Fetch the x coordinate. | ||||||||
| DCAE | LD E,(IX+$03) | |||||||||
| DCB1 | LD HL,($D6E4) | Fetch the near x edge. | ||||||||
| DCB4 | XOR A | Subtract the entity's x from the edge. | ||||||||
| DCB5 | INC A | |||||||||
| DCB6 | SBC HL,DE | |||||||||
| DCB8 | JR Z,HandleOverlap_SizeX | The entity is on the edge. | ||||||||
| DCBA | JR NC,HandleOverlap_Push | Push back when the entity is past the edge. | ||||||||
| HandleOverlap_SizeX | DCBC | LD A,(IY+$02) | Scale the object's byte up to a size along x. | |||||||
| DCBF | ADD A,A | |||||||||
| DCC0 | ADD A,A | |||||||||
| DCC1 | ADD A,A | |||||||||
| DCC2 | ADD A,A | |||||||||
| DCC3 | AND %01110000 | Use bits 4-6 of that byte. | ||||||||
| DCC5 | ADD A,$10 | Add 10 to make the size. | ||||||||
| DCC7 | LD C,A | |||||||||
| DCC8 | LD B,$00 | |||||||||
| DCCA | ADD HL,BC | Add the size to the difference. | ||||||||
| DCCB | LD A,L | The push stays small when x is still inside the extent. | ||||||||
| DCCC | CP (IX+$0B) | |||||||||
| DCCF | LD A,$02 | The small push is 02. | ||||||||
| DCD1 | JR C,HandleOverlap_Push | Double the push and test y when x is clear. | ||||||||
| DCD3 | ADD A,A | Double the push. | ||||||||
| DCD4 | LD D,(IX+$05) | Fetch the y coordinate. | ||||||||
| DCD7 | LD E,(IX+$06) | |||||||||
| DCDA | LD HL,($D6F5) | Subtract the entity's y from the near edge. | ||||||||
| DCDD | SBC HL,DE | |||||||||
| DCDF | JR Z,HandleOverlap_SizeY | The entity is on the edge. | ||||||||
| DCE1 | JR NC,HandleOverlap_Push | Push back when the entity is past the edge. | ||||||||
| HandleOverlap_SizeY | DCE3 | LD A,(IY+$02) | Read the object's byte. | |||||||
| DCE6 | ADD A,A | Double that byte. | ||||||||
| DCE7 | AND %01110000 | Use bits 4-6. | ||||||||
| DCE9 | ADD A,$10 | Add 10 to make the size. | ||||||||
| DCEB | LD C,A | |||||||||
| DCEC | ADD HL,BC | Add the size to the difference. | ||||||||
| DCED | LD A,L | The push stays 08 when y is still inside the extent. | ||||||||
| DCEE | CP (IX+$0C) | |||||||||
| DCF1 | LD A,$08 | The push is 08. | ||||||||
| DCF3 | JR NC,HandleOverlap_Move | Move the entity when y is clear. | ||||||||
| HandleOverlap_Push | DCF5 | LD B,A | Keep the push. | |||||||
| DCF6 | LD A,L | Read the low byte of the difference. | ||||||||
| DCF7 | BIT 7,A | Jump to HandleOverlap_Step to keep a negative difference. | ||||||||
| DCF9 | JR NZ,HandleOverlap_Step | |||||||||
| DCFB | NEG | Force the difference negative. | ||||||||
| HandleOverlap_Step | DCFD | LD ($D8C0),A | Give that step to the turn. | |||||||
| DD00 | LD A,($D83D) | Read the hit already planted. | ||||||||
| DD03 | AND A | A second hit becomes FF. | ||||||||
| DD04 | JR Z,HandleOverlap_Hit | |||||||||
| DD06 | LD B,$FF | A second hit is FF. | ||||||||
| HandleOverlap_Hit | DD08 | LD A,B | Plant the hit for TestEntityCells. | |||||||
| DD09 | LD ($D83D),A | |||||||||
|
A positive z overlap clears the vertical speed. A negative one sets it, and a saucer is left alone. The byte at DD4C is patched by TestGroupObjects: zero clears the low byte of the speed, and 04 skips that clear.
|
||||||||||
| HandleOverlap_Move | DD0C | LD HL,($DDD3) | Fetch the z overlap. | |||||||
| DD0F | PUSH IX | Remember the entity. | ||||||||
| DD11 | LD DE,$0006 | Move on to the vertical speed. | ||||||||
| DD14 | ADD IX,DE | |||||||||
| DD16 | XOR A | Clear the fraction of x. | ||||||||
| DD17 | LD (IX+$04),A | |||||||||
| DD1A | BIT 7,H | A negative overlap pushes the entity up. | ||||||||
| DD1C | JR NZ,HandleOverlap_0 | |||||||||
| DD1E | LD (IX+$0C),A | Clear the vertical speed. | ||||||||
| DD21 | LD (IX+$0D),A | |||||||||
| DD24 | CALL MoveEntityBack | Move the entity back. | ||||||||
| DD27 | JR HandleOverlap_4 | Join the restore. | ||||||||
| HandleOverlap_0 | DD29 | LD A,(IX-$06) | A saucer is not pushed up. | |||||||
| DD2C | CP $09 | |||||||||
| DD2E | JR Z,HandleOverlap_2 | |||||||||
| DD30 | LD A,($5CD8) | Read the object's flags. | ||||||||
| DD33 | RLA | The push is FD when the top flag is set. | ||||||||
| DD34 | LD A,$FD | |||||||||
| DD36 | JR C,HandleOverlap_1 | |||||||||
| DD38 | INC A | Otherwise the push is FF. | ||||||||
| DD39 | INC A | |||||||||
| HandleOverlap_1 | DD3A | LD (IX+$0C),A | Use that as the vertical speed. | |||||||
| DD3D | LD (IX+$0D),A | |||||||||
| HandleOverlap_2 | DD40 | SET 7,(IX+$18) | Set bit 7 of the vertical speed and clear bit 6. | |||||||
| DD44 | RES 6,(IX+$18) | |||||||||
| DD48 | CALL MoveEntityBack | Move the entity back. | ||||||||
| HandleOverlap_3 | DD4B | JR HandleOverlap_3 | Clear the low byte of the speed when the entity is inside. | |||||||
| DD4D | LD (IX+$19),$00 | Clear the low byte of the vertical speed. | ||||||||
| HandleOverlap_4 | DD51 | POP IX | Restore the entity. | |||||||
| DD53 | LD A,(IX+$08) | Snap z up when its top byte is zero. | ||||||||
| DD56 | AND A | |||||||||
| DD57 | RET NZ | |||||||||
| DD58 | LD (IX+$08),$01 | Set the top of z to one. | ||||||||
| DD5C | LD (IX+$09),$00 | Clear the middle byte of z. | ||||||||
| DD60 | RET | Return. | ||||||||
| Prev: DC3F | Up: Map | Next: DD61 |