![]() |
Routines |
| Prev: D3A9 | Up: Map | Next: D47A |
|
Used by the routine at MoveEntity.
Tests the entity against each of the other entities with TestEntityPair. A puff and a shot are not tested. A player skips puffs and sparkles, and a saucer skips shots. A disc, a free slot and a hidden entity are skipped. The direction bytes are 20 during the tests. Afterwards the low bytes of x and y, relative to the patched origins, replace them for TestEntityCells. The step in MoveEntityBack is removed for the tests and then put back.
|
||||||||
|
The direction bytes start at 20 so a hit during the tests has a neutral component. The type of this entity is patched into the skip below.
|
||||||||
| TestEntityCollisions | D3EB | LD A,$04 | Mark the entity as only touching. | |||||
| D3ED | LD ($DD4C),A | |||||||
| D3F0 | LD A,(IX+$00) | Remember this entity's type for the skips below. | ||||||
| D3F3 | LD ($D41F),A | |||||||
| D3F6 | CP $05 | A puff is not tested against the others. | ||||||
| D3F8 | JR Z,TestEntityCollisions_Finish | |||||||
| D3FA | CP $0E | A shot is not tested against the others. | ||||||
| D3FC | JR Z,TestEntityCollisions_Finish | |||||||
| D3FE | LD (IX+$18),$20 | Set both direction bytes to 20. | ||||||
| D402 | LD (IX+$19),$20 | |||||||
| D406 | XOR A | Clear the object flags and remove the move-back step. | ||||||
| D407 | LD ($DDE4),A | |||||||
| D40A | LD ($5CD8),A | |||||||
| D40D | LD B,$0C | There are 0C entities. | ||||||
| D40F | LD IY,$B540 | Start at the first entity. | ||||||
| TestEntityCollisions_Loop | D413 | PUSH BC | Remember how many entities remain. | |||||
| D414 | LD A,(IY+$00) | Skip an entity that is free. | ||||||
| D417 | AND A | |||||||
| D418 | JR Z,TestEntityCollisions_Next | |||||||
| D41A | CP $0C | Skip a disc. | ||||||
| D41C | JR Z,TestEntityCollisions_Next | |||||||
| D41E | LD A,$00 | The type patched above selects the next skips. | ||||||
| D420 | LD L,A | |||||||
| D421 | DEC A | |||||||
| D422 | JR NZ,TestEntityCollisions_Saucer | A player does not test a puff or a sparkle. | ||||||
| D424 | LD A,(IY+$00) | |||||||
| D427 | CP $05 | |||||||
| D429 | JR Z,TestEntityCollisions_Next | |||||||
| D42B | CP $0D | |||||||
| D42D | JR Z,TestEntityCollisions_Next | |||||||
| TestEntityCollisions_Saucer | D42F | LD A,L | A saucer does not test a shot. | |||||
| D430 | CP $09 | |||||||
| D432 | JR NZ,TestEntityCollisions_Frame | |||||||
| D434 | LD A,(IY+$00) | Skip the shot. | ||||||
| D437 | CP $0E | |||||||
| D439 | JR Z,TestEntityCollisions_Next | |||||||
| TestEntityCollisions_Frame | D43B | LD A,(IY+$01) | Read the other entity's frame. | |||||
| D43E | AND %11000000 | Use bits 6 and 7 of the frame. | ||||||
| D440 | JR NZ,TestEntityCollisions_Next | Skip an entity with either bit set. | ||||||
| D442 | PUSH IY | It is not tested against itself. | ||||||
| D444 | POP HL | |||||||
| D445 | PUSH IX | |||||||
| D447 | POP DE | |||||||
| D448 | AND A | Test the pair when the two entities differ. | ||||||
| D449 | SBC HL,DE | |||||||
| D44B | CALL NZ,TestEntityPair | |||||||
| TestEntityCollisions_Next | D44E | LD BC,$0026 | Move on to the next entity. | |||||
| D451 | ADD IY,BC | |||||||
| D453 | POP BC | Bring the count back. | ||||||
| D454 | DJNZ TestEntityCollisions_Loop | Repeat for the remaining entities. | ||||||
| TestEntityCollisions_Finish | D456 | LD DE,$0000 | Keep the low byte of x relative to the patched origin. | |||||
| D459 | LD H,(IX+$02) | |||||||
| D45C | LD L,(IX+$03) | |||||||
| D45F | AND A | |||||||
| D460 | SBC HL,DE | |||||||
| D462 | LD (IX+$18),L | |||||||
| D465 | LD DE,$0000 | Keep the low byte of y relative to the patched origin. | ||||||
| D468 | LD H,(IX+$05) | |||||||
| D46B | LD L,(IX+$06) | |||||||
| D46E | AND A | |||||||
| D46F | SBC HL,DE | |||||||
| D471 | LD (IX+$19),L | |||||||
| D474 | LD A,$2D | Put the step back into the move-back routine. | ||||||
| D476 | LD ($DDE4),A | |||||||
| D479 | RET | Return. | ||||||
| Prev: D3A9 | Up: Map | Next: D47A |