Prev: 27667 Up: Map Next: 27849
27805: Check Collision
CheckCollision 27805 LD A,(26259) Return if Flag_Shield is active.
27808 OR A
27809 RET NZ
27810 LD HL,(26349) Load the player attribute position from PlayerAttributeBufferPosition.
27813 LD B,2 Set a counter in B for 2 rows to check.
CheckCollision_RowLoop 27815 PUSH BC Stash the row counter and attribute position on the stack.
27816 PUSH HL
27817 LD B,3 Set a counter in B for 3 columns to check.
CheckCollision_ColumnLoop 27819 LD A,(HL) Load the attribute at this position.
27820 OR A Skip this position if the attribute is INK:BLACK, PAPER:BLACK (empty space).
27821 JR Z,CheckCollision_NextColumn
27823 CP 70 Skip this position if the attribute is INK:YELLOW, PAPER:BLACK (BRIGHT) (player ship).
27825 JR Z,CheckCollision_NextColumn
27827 CP 7 Skip this position if the attribute is INK:WHITE, PAPER:BLACK (white/ background).
27829 JR Z,CheckCollision_NextColumn
See Immunity.
Collision detected - trigger player death.
27831 LD A,1 Set Flag_Collision to 1.
27833 LD (26276),A
27836 POP AF Discard the saved positions from the stack.
27837 POP AF
27838 RET Return.
Move to the next attribute.
CheckCollision_NextColumn 27839 INC HL Move to the next attribute position (right one column).
27840 DJNZ CheckCollision_ColumnLoop Loop back to CheckCollision_ColumnLoop until all 3 columns are checked.
27842 POP HL Restore the starting attribute position for this row.
27843 SET 5,L Move down one row (set bit 5 of L = add 32).
27845 POP BC Restore the row counter and loop back to CheckCollision_RowLoop until both rows are checked.
27846 DJNZ CheckCollision_RowLoop
27848 RET Return.
Prev: 27667 Up: Map Next: 27849