![]() |
Routines |
| Prev: 910A | Up: Map | Next: 917C |
|
Used by the routines at UpdateEnemies and CheckObjectHitByShot.
Works out the screen position of the object that was hit, and sets up the hit data used by CheckShotCollisions. Does nothing if the collision flag at A1D8 is clear.
|
||||
| FindHitPosition | 9143 | LD IY,($AD46) | Fetch the address of the object from CurrentObject. | |
| 9147 | LD L,(IY+$11) | Fetch its screen position into HL. | ||
| 914A | LD H,(IY+$12) | |||
| 914D | LD A,($5C29) | Fetch the value from 5C29 into E. | ||
| 9150 | LD E,A | |||
| 9151 | LD A,($A1D8) | Fetch the collision flag from A1D8 into D. | ||
| 9154 | LD D,A | |||
| 9155 | LD A,D | Copy it into A. | ||
| 9156 | DEC A | Subtract one. | ||
| 9157 | RET M | Return if it was zero. | ||
| 9158 | LD A,($A2FA) | Fetch the flag from SpriteVariables_RightEdge. | ||
| 915B | AND A | Test it. | ||
| 915C | LD A,L | Fetch the horizontal screen position. | ||
| 915D | JR Z,FindHitPosition_Clear | Jump to FindHitPosition_Clear if the flag is clear. | ||
| 915F | ADD A,E | Add the value from E. | ||
| 9160 | LD L,$08 | Set the horizontal screen position to 08. | ||
| 9162 | SUB L | Subtract it. | ||
| 9163 | LD E,A | Keep the result in E. | ||
| 9164 | JR FindHitPosition_Store | Jump to FindHitPosition_Store. | ||
| FindHitPosition_Clear | 9166 | ADD A,$17 | Add 17 to the horizontal screen position. | |
| 9168 | ADD A,E | Add the value from E. | ||
| 9169 | JR NC,FindHitPosition_Store | Jump to FindHitPosition_Store if there is no carry. | ||
| 916B | LD A,$EE | Otherwise use EE... | ||
| 916D | SUB L | ...less the horizontal screen position. | ||
| 916E | LD E,A | Keep the result in E. | ||
| FindHitPosition_Store | 916F | LD ($ABA4),HL | Store the position in CollisionBox. | |
| 9172 | LD ($ABA6),DE | Store the size in ABA6. | ||
| 9176 | LD A,H | Fetch the vertical screen position. | ||
| 9177 | SUB D | Subtract the collision flag. | ||
| 9178 | LD ($5C1E),A | Store the result in ScratchPair. | ||
| 917B | RET | Return. | ||
| Prev: 910A | Up: Map | Next: 917C |