Prev: AC3C Up: Map Next: AD51
AD0D: Checks for hazard collisions
Called continuously.
All six hazard slots are walked, skipping unused ones. A slot whose flags are $FF is also skipped while the high byte of its lateral distance is non-zero, meaning it is too far to the side to be hit this frame. Otherwise, if the hazard is within a distance of 20 and check_collision says it was hit, the slot's own hit handler is called - though not if the flags have already been set to $FF by an earlier hit.
Used by the routine at read_map.
check_hazard_collisions AD0D LD A,($A221) Return if the inhibit_collision_detection flag is set
AD10 AND A
AD11 RET NZ
Iterate over all hazards.
AD12 LD IX,$A188 Point IX at hazards[0]
AD16 LD DE,$0014 Stride of hazards is 20 bytes
AD19 LD B,$06 6 iterations
chc_loop AD1B RLC (IX+$00) If the hazard is not active continue to next one
AD1F JR NC,chc_continue
AD21 EXX Bank
Push address of the end of the loop on the stack so any RETs below will return there.
AD22 LD HL,$AD4B Load address of chc_unbank_continue
AD25 PUSH HL Stack it
AD26 LD A,(IX+$0F) A = IX[15] + 1 -- a delay of some sort used for hits
AD29 INC A
AD2A JR NZ,chc_check_distance Jump if non-zero
Otherwise it was zero (IX[15] was $FF => unused/unset?)
AD2C LD A,(IX+$11) A = IX[17] -- read min lane?
AD2F AND A Set flags
AD30 RET NZ End this iteration if non-zero
chc_check_distance AD31 LD A,(IX+$01) A = IX[1] -- buffer offset/distance
AD34 CP $14 End this iteration if distance >= 20 -- too far away?
AD36 RET NC
Distance is < 20.
AD37 LD D,$00 Initialise D
AD39 CALL check_collision Call check_collision (returns D)
AD3C LD A,D End this iteration if no collision
AD3D AND A
AD3E RET Z
There was a collision.
AD3F LD A,(IX+$0F) A = IX[15] + 1 -- increment delay
AD42 INC A
AD43 RET Z End this iteration if zero
AD44 LD L,(IX+$0B) Load address of hit handler into HL
AD47 LD H,(IX+$0C)
AD4A JP (HL) Jump to it (it will return to the next instr)
chc_unbank_continue AD4B EXX Unbank
chc_continue AD4C ADD IX,DE Move to next hazard
AD4E DJNZ chc_loop Loop
AD50 RET Return
Prev: AC3C Up: Map Next: AD51