![]() |
Routines |
| Prev: 6C53 | Up: Map | Next: 6CA5 |
|
Used by the routines at Handler_RedBird, Handle_Butterfly, CheckCarEggCollision, HandlerFrog01_CheckEggCollision, Check_Hazard_Collision, Handler_UFO, Handle_Plane_Bomb and Handler_Balloon.
Checks if an egg overlaps with a sprite by comparing their positions. The egg is assumed to be 10 pixels wide and 10 pixels tall, while the target point is offset by 04 pixels in X and 06 pixels in Y to check against the centre of the target sprite.
|
||||||||||||||
|
First check horizontal overlap. The egg's centre point (X + 04) is compared against the sprite's horizontal range.
|
||||||||||||||
| CheckEggCollision | 6C85 | LD A,(IY+$00) | Load B with the egg's X position (from *IY+00) + 04 (offset to the egg's centre). | |||||||||||
| 6C88 | ADD A,$04 | |||||||||||||
| 6C8A | LD B,A | |||||||||||||
| 6C8B | LD A,(IX+$00) | Load A with the sprite's X position (from *IX+00). | ||||||||||||
| 6C8E | CP B | Compare with the egg's centre X position. | ||||||||||||
| 6C8F | CCF | Complement the carry flag. | ||||||||||||
| 6C90 | RET C | Return if the sprite is to the right of the egg (no overlap; carry is set). | ||||||||||||
|
Sprite is to the left so check if its right edge reaches the egg's centre.
|
||||||||||||||
| 6C91 | ADD A,$10 | Add 10 to the sprite's X position (add sprite width). | ||||||||||||
| 6C93 | CP B | Compare this with the egg's centre X position. | ||||||||||||
| 6C94 | RET C | Return (with; carry clear meaning a collision, and carry set meaning no collision). | ||||||||||||
|
The two overlap horizontally; now check vertical overlap. The egg's centre point (Y + 06) is compared against the sprite's vertical range.
|
||||||||||||||
| 6C95 | LD A,(IY+$01) | Load B with the egg's Y position (from *IY+01) + 06 (offset to the egg's centre). | ||||||||||||
| 6C98 | ADD A,$06 | |||||||||||||
| 6C9A | LD B,A | |||||||||||||
| 6C9B | LD A,(IX+$01) | Load A with the sprite's Y position (from *IX+01). | ||||||||||||
| 6C9E | CP B | Compare this with the egg's centre Y position. | ||||||||||||
| 6C9F | CCF | Complement the carry flag. | ||||||||||||
| 6CA0 | RET C | Return if the sprite is below the egg (no overlap; carry is set). | ||||||||||||
|
Sprite is above so check if its bottom edge reaches the egg's centre.
|
||||||||||||||
| 6CA1 | ADD A,$10 | Add 10 to the sprite's Y position (add sprite height). | ||||||||||||
| 6CA3 | CP B | Compare this with the egg's centre Y position. | ||||||||||||
| 6CA4 | RET | Return (with; carry clear meaning a collision, and carry set meaning no collision). | ||||||||||||
| Prev: 6C53 | Up: Map | Next: 6CA5 |