Prev: 42902 Up: Map Next: 43036
42978: 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 42978 INC HL Move onto the actor world X.
42979 INC HL
42980 EX DE,HL Switch the actor pointer into DE.
42981 LD A,(DE) Fetch the world X.
42982 INC DE Move onto the high byte.
42983 LD C,A Copy the low byte into C.
42984 LD A,(DE) Fetch the high byte.
42985 INC DE Move onto the Y.
42986 LD B,A Copy the high byte into B.
42987 LD HL,144 HL=0144.
42990 ADD HL,BC Add the box offset.
Compare that box against the current laser pulse.
42991 LD BC,(24698) Fetch Jetman_Position.
42995 LD A,C Copy the low byte into A.
42996 ADD A,(IX+2) Add pulse 1.
42999 LD C,A Copy the sum into C.
43000 LD A,B Copy the high byte into A.
43001 ADC A,0 Add the carry.
43003 LD B,A Copy it into B.
43004 AND A Clear the carry flag.
43005 SBC HL,BC Subtract the pulse world X.
Return if the pulse is outside the hit-box horizontally.
43007 LD A,H Fetch the high byte of the difference.
43008 AND %00011111 Keep only bits 0-4.
43010 RET NZ Return if they are on different screens.
43011 LD A,L Fetch the low byte.
43012 CP 32 Return if it is at least 32.
43014 RET NC
Return if the pulse misses the actor vertically.
43015 LD A,(DE) Fetch the actor Y.
43016 ADD A,4 Add 4.
43018 SUB (IX+1) Subtract the beam Y.
43021 CP 24 Return if the pulse missed.
43023 RET NC
Mark the actor as exploding and consume the pulse.
43024 EX DE,HL Switch the actor pointer into HL.
43025 LD BC,12 Point HL at the explode flag.
43028 ADD HL,BC
43029 SET 0,(HL) Set bit 0 of the explode flag.
43031 RES 2,(IX+2) Reset bit 2 of pulse 1.
43035 RET Return.
Prev: 42902 Up: Map Next: 43036