Prev: 57947 Up: Map Next: 58032
57990: Collision check between creature missile and Maroc's shielding barrier
Used by the routine at 53403.
Called from 53475 if byte 7 or 8 of missile data (27868/60317) is repelled by the active spell effect
Collision detection for SHIELD, PROTECT, DEFENCE and AMULET vs missile/bolt spells.
Because the shield effect flickers to Maroc's left and right, his 'hit boxes' are slightly wider than normal to accommodate this (vertical = 24 pixels at 58007, horizontal 48 pixels at 58018)
57990 LD A,(60116) High byte of missile horizontal co-ordinate
57993 CP 0 This byte is 0 if the item is visible on-screen
57995 JR NZ,58029 If not, jump to the end of this routine
Missile is on-screen. First a horizontal co-ordinate collision check:
57997 LD A,(60114) Graphic's vertical pixel position
58000 LD C,A Copy to C register
58001 LD A,(60097) Maroc's vertical (Y-axis) screen position
58004 ADD A,12 Move the target centre down 12 pixels (towards the bottom of Maroc's sprite). The vertical 'hit box' of 24 pixels will extend upwards from here
58006 SUB C Subtract the missile's vertical position
58007 CP 24 Is the missile within 24 pixels from this vertical position?
58009 JR NC,58029 If margin is >=24 pixels, it's missed vertically so no need to run the horizontal check
Horizontal check is within 'hit box'. Next, a vertical co-ordinate collision check:
58011 LD A,(60115) Graphic's horizontal pixel position
58014 LD C,A Copy to C register
58015 LD A,140 Maroc's horizontal pixel position on screen doesn't change - this pixel position is at the barrier just to the right hand size of Maroc's sprite. The horizontal 'hit box' of 48 pixels extends to the left from here
58017 SUB C Subtract the missile's horizontal pixel position
58018 CP 48 Is the missile within 48 pixels from this horizontal position?
58020 JR NC,58029 If it's outside this range, no collision
The missile has collided with Maroc while he's protected by his shielding spell:
58022 LD A,8
58024 LD (60246),A Set the sound effect duration affecting length of 'crunching' sound as the missile strikes Maroc & his shield (duration = 8)
This also acts as a non-zero collision flag value, indicating a positive collision check
58027 JR 58031 ...and skip the next instruction, jump straight to RET
No collision detected
58029 LD A,0 Collision check flag value = 0 (no collision)
58031 RET
Prev: 57947 Up: Map Next: 58032