Prev: A796 Up: Map Next: A81C
A7E2: Test One Hit
Compare one actor's box against the current laser pulse.
Input
HL Actor slot
Build the actor hit-box from its world X and Y.
TestOneHit A7E2 INC HL Move onto the actor world X.
A7E3 INC HL
A7E4 EX DE,HL Switch the actor pointer into DE.
A7E5 LD A,(DE) Fetch the world X.
A7E6 INC DE Move onto the high byte.
A7E7 LD C,A Copy the low byte into C.
A7E8 LD A,(DE) Fetch the high byte.
A7E9 INC DE Move onto the Y.
A7EA LD B,A Copy the high byte into B.
A7EB LD HL,$0090 HL=0090.
A7EE ADD HL,BC Add the box offset.
Compare that box against the current laser pulse.
A7EF LD BC,($607A) Fetch Jetman_Position.
A7F3 LD A,C Copy the low byte into A.
A7F4 ADD A,(IX+$02) Add pulse 01.
A7F7 LD C,A Copy the sum into C.
A7F8 LD A,B Copy the high byte into A.
A7F9 ADC A,$00 Add the carry.
A7FB LD B,A Copy it into B.
A7FC AND A Clear the carry flag.
A7FD SBC HL,BC Subtract the pulse world X.
Return if the pulse is outside the hit-box horizontally.
A7FF LD A,H Fetch the high byte of the difference.
A800 AND %00011111 Keep only bits 0-4.
A802 RET NZ Return if they are on different screens.
A803 LD A,L Fetch the low byte.
A804 CP $20 Return if it is at least 20.
A806 RET NC
Return if the pulse misses the actor vertically.
A807 LD A,(DE) Fetch the actor Y.
A808 ADD A,$04 Add 04.
A80A SUB (IX+$01) Subtract the beam Y.
A80D CP $18 Return if the pulse missed.
A80F RET NC
Mark the actor as exploding and consume the pulse.
A810 EX DE,HL Switch the actor pointer into HL.
A811 LD BC,$000C Point HL at the explode flag.
A814 ADD HL,BC
A815 SET 0,(HL) Set bit 0 of the explode flag.
A817 RES 2,(IX+$02) Reset bit 2 of pulse 01.
A81B RET Return.
Prev: A796 Up: Map Next: A81C