![]() |
Routines |
| Prev: D3EB | Up: Map | Next: D5AD |
|
Used by the routine at TestEntityCollisions.
Tests whether two entities overlap on x, then y, then z, using TestOverlap. The three extents are fields 0B 0C and 0D. The y test and the z test move IX so that those extents sit at the displacement the test reads. An overlap is stored at OverlapDistances for x, DDD1 for y and DDD3 for z. A puff with no width flags then scores, from the table at ScoreTable, and becomes a sparkle. A whirler meeting the player, a spider and a shot all burst. A shot is then removed. A pickup is collected with CollectItem, and the player is moved clear with HandleOverlap_Compare.
|
||||||||||
| TestEntityPair | D47A | LD H,(IY+$02) | Fetch the other entity's x coordinate. | |||||||
| D47D | LD L,(IY+$03) | |||||||||
| D480 | LD D,(IX+$02) | Fetch this entity's x coordinate. | ||||||||
| D483 | LD E,(IX+$03) | |||||||||
| D486 | LD C,(IY+$0B) | Fetch the other entity's x extent. | ||||||||
| D489 | LD B,(IX+$0B) | Fetch this entity's x extent. | ||||||||
| D48C | CALL TestOverlap | Test the two x ranges. | ||||||||
| D48F | RET NC | Return if the x ranges do not overlap. | ||||||||
| D490 | INC L | Remember the x overlap. | ||||||||
| D491 | LD ($DDCF),HL | |||||||||
| D494 | LD H,(IY+$05) | Fetch the other entity's y coordinate. | ||||||||
| D497 | LD L,(IY+$06) | |||||||||
| D49A | LD D,(IX+$05) | Fetch this entity's y coordinate. | ||||||||
| D49D | LD E,(IX+$06) | |||||||||
| D4A0 | LD C,(IY+$0C) | Fetch the other entity's y extent. | ||||||||
| D4A3 | LD B,(IX+$0C) | Fetch this entity's y extent. | ||||||||
| D4A6 | INC IX | Aim the test at the y extent. | ||||||||
| D4A8 | CALL TestOverlap | Test the two y ranges. | ||||||||
| D4AB | DEC IX | Restore the entity address. | ||||||||
| D4AD | RET NC | Return if the y ranges do not overlap. | ||||||||
| D4AE | INC L | Remember the y overlap. | ||||||||
| D4AF | LD ($DDD1),HL | |||||||||
| D4B2 | LD H,(IY+$08) | Fetch the other entity's z coordinate. | ||||||||
| D4B5 | LD L,(IY+$09) | |||||||||
| D4B8 | LD D,(IX+$08) | Fetch this entity's z coordinate. | ||||||||
| D4BB | LD E,(IX+$09) | |||||||||
| D4BE | PUSH IX | Aim the test at the z extent. | ||||||||
| D4C0 | LD BC,$FFFA | |||||||||
| D4C3 | ADD IX,BC | |||||||||
| D4C5 | LD C,(IY+$0D) | Fetch the other entity's z extent. | ||||||||
| D4C8 | LD B,(IX+$13) | Fetch this entity's z extent. | ||||||||
| D4CB | CALL TestOverlap | Test the two z ranges. | ||||||||
| D4CE | POP IX | Restore the entity address. | ||||||||
| D4D0 | RET NC | Return if the z ranges do not overlap. | ||||||||
| D4D1 | INC L | Remember the z overlap. | ||||||||
| D4D2 | LD ($DDD3),HL | |||||||||
|
A puff whose width flags are clear scores and becomes a sparkle.
|
||||||||||
| D4D5 | LD A,(IY+$16) | Leave this reward unless the width flags are clear. | ||||||||
| D4D8 | AND $F0 | |||||||||
| D4DA | JR NZ,TestEntityPair_0 | |||||||||
| D4DC | LD A,(IY+$00) | Score only when the other entity is a puff. | ||||||||
| D4DF | CP $05 | |||||||||
| D4E1 | JR NZ,TestEntityPair_0 | |||||||||
| D4E3 | LD A,(IX+$00) | Use this entity's type as an index into the score table. | ||||||||
| D4E6 | ADD A,A | |||||||||
| D4E7 | LD HL,$D5BB | Take the score table. | ||||||||
| D4EA | CALL AddToAddress | Look the score up. | ||||||||
| D4ED | LD B,(HL) | Read the score. | ||||||||
| D4EE | INC HL | |||||||||
| D4EF | LD C,(HL) | |||||||||
| D4F0 | CALL AddScore | Add the score. | ||||||||
| D4F3 | CALL StartBurst | Start a burst. | ||||||||
| D4F6 | LD (IY+$00),$0D | Turn the puff into a sparkle. | ||||||||
| D4FA | LD (IY+$01),$00 | Clear the sparkle's frame. | ||||||||
| D4FE | LD (IY+$17),$08 | Set the sparkle's height to 08. | ||||||||
| D502 | LD (IY+$23),$04 | Set the sparkle's countdown to 04. | ||||||||
|
Nothing else happens while the countdown timer is running. The other entity is in IY.
|
||||||||||
| TestEntityPair_0 | D506 | LD A,($A2DF) | Return while the countdown timer is running. | |||||||
| D509 | AND A | |||||||||
| D50A | RET NZ | |||||||||
| D50B | LD A,(IY+$16) | Read the other entity's width byte. | ||||||||
| D50E | AND %11110000 | Use the countdown nibble. | ||||||||
| D510 | JR NZ,TestEntityPair_Spider | Skip the whirler test when that nibble is set. | ||||||||
| D512 | LD A,(IY+$00) | Read the other entity's type. | ||||||||
| D515 | DEC A | The other entity is the player. | ||||||||
| D516 | JR NZ,TestEntityPair_Whirler | |||||||||
| D518 | LD A,(IX+$00) | A whirler bursts the player. | ||||||||
| D51B | CP $11 | |||||||||
| D51D | JR NZ,TestEntityPair_Spider | |||||||||
| D51F | JR TestEntityPair_Burst | Burst them. | ||||||||
| TestEntityPair_Whirler | D521 | CP $10 | The other entity is a whirler. | |||||||
| D523 | JR NZ,TestEntityPair_Spider | |||||||||
| D525 | LD A,(IX+$00) | This entity is the player. | ||||||||
| D528 | DEC A | |||||||||
| D529 | JR NZ,TestEntityPair_Spider | Leave the pair when it is not. | ||||||||
| TestEntityPair_Burst | D52B | CALL StartBurst | Burst the other entity. | |||||||
| D52E | CALL BurstOtherEntity | Finish bursting it. | ||||||||
| TestEntityPair_Spider | D531 | LD A,(IY+$00) | A spider bursts. | |||||||
| D534 | CP $10 | |||||||||
| D536 | CALL Z,StartBurst | |||||||||
| D539 | LD A,(IY+$00) | A shot bursts and is removed. | ||||||||
| D53C | CP $0E | |||||||||
| D53E | JR NZ,TestEntityPair_Pickup | |||||||||
| D540 | CALL StartBurst | Burst the shot. | ||||||||
| D543 | LD (IY+$00),$00 | Remove the shot. | ||||||||
| D547 | LD (IY+$01),$80 | Hide what remains of it. | ||||||||
| TestEntityPair_Pickup | D54B | LD A,(IY+$00) | A pickup is collected. | |||||||
| D54E | CP $0F | |||||||||
| D550 | CALL Z,CollectItem | |||||||||
| D553 | LD A,(IX+$00) | The player is moved clear of the overlap. | ||||||||
| D556 | DEC A | |||||||||
| D557 | JP Z,HandleOverlap_Compare | |||||||||
| D55A | CP $0E | A shot is collected from the other side. | ||||||||
| D55C | JR NZ,TestEntityPair_Clear | |||||||||
| D55E | PUSH IY | Swap the two entities. | ||||||||
| D560 | PUSH IX | |||||||||
| D562 | POP IY | |||||||||
| D564 | POP IX | |||||||||
| D566 | CALL CollectItem | Collect the item. | ||||||||
| D569 | PUSH IY | Swap the two entities back. | ||||||||
| D56B | PUSH IX | |||||||||
| D56D | POP IY | |||||||||
| D56F | POP IX | |||||||||
| TestEntityPair_Clear | D571 | XOR A | Clear the handled flag. | |||||||
| D572 | LD ($D5A4),A | |||||||||
| D575 | LD HL,($DDD3) | Reduce the z overlap by one. | ||||||||
| D578 | DEC L | |||||||||
| D579 | LD ($DDD3),HL | |||||||||
| D57C | LD HL,($DDCF) | Reduce the x overlap by two. | ||||||||
| D57F | DEC L | |||||||||
| D580 | DEC L | |||||||||
| D581 | LD ($DDCF),HL | |||||||||
| D584 | LD HL,($DDD1) | Reduce the y overlap by two. | ||||||||
| D587 | DEC L | |||||||||
| D588 | DEC L | |||||||||
| D589 | LD ($DDD1),HL | |||||||||
| D58C | LD C,(IX+$1F) | Remember the flags and field 1F. | ||||||||
| D58F | LD B,(IX+$1E) | |||||||||
| D592 | PUSH BC | |||||||||
| D593 | CALL HandleOverlap_Compare | Move the entity clear of the overlap. | ||||||||
| D596 | POP BC | Bring the saved values back. | ||||||||
| D597 | LD (IX+$1F),C | Restore field 1F. | ||||||||
| D59A | LD A,B | Use bit 6 of the saved flags. | ||||||||
| D59B | AND $40 | |||||||||
| D59D | OR (IX+$1E) | Keep that bit in the flags. | ||||||||
| D5A0 | LD (IX+$1E),A | |||||||||
| D5A3 | LD A,$00 | Return unless the patched kind is 0B. | ||||||||
| D5A5 | CP $0B | |||||||||
| D5A7 | RET NZ | |||||||||
| D5A8 | LD A,(IY+$00) | Return unless the other entity is the player. | ||||||||
| D5AB | DEC A | |||||||||
| D5AC | RET NZ | |||||||||
|
Continue on to BurstOtherEntity.
|
||||||||||
| Prev: D3EB | Up: Map | Next: D5AD |