Skip to navigation


Car geometry: CheckForContact

Name: CheckForContact [Show more] Type: Subroutine Category: Car geometry Summary: Check to see if the object is close enough to the player car to make contact
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * BuildRoadSign calls CheckForContact * GetObjectAngles calls via CheckForContact-2

Arguments: Y Contact is made if objectDistanceLo <= Y (J I) max(|x-delta|, |z-delta|) (H G) min(|x-delta|, |z-delta|) M The smaller yaw angle of the object, where 0 to 255 represents 0 to 45 degrees objectNumber The number of the object being checked for contact
Other entry points: CheckForContact-2 Set Y = 37, so we make contact if (L K) <= 37
LDY #37 \ Set Y = 37, so we make contact if (L K) <= 37 .CheckForContact JSR GetObjectDistance \ Set (L K) to the distance between the object and the \ player's car LDA L \ Set objectDistanceHi to the high byte of (L K) STA objectDistanceHi BNE ccon1 \ If objectDistanceHi is non-zero then the objects are \ too far apart for a collision, so jump to ccon1 to \ return from the subroutine CPY K \ If K > Y, then the objects are too far apart for a BCC ccon1 \ collision, this time in terms of the low byte of the \ distance, so jump to ccon1 to return from the \ subroutine \ If we get here then K <= Y, so the objects are close \ enough for a collision DEC processContact \ Decrement processContact so it is non-zero, so we \ check for contact between this car and the player's \ car in the ProcessContact routine LDA K \ Set (objectDistanceHi objectDistanceLo) = (L K) STA objectDistanceLo LDA objectNumber \ Store the number of the other object in STA collisionDriver \ collisionDriver, so we know who's crashing .ccon1 RTS \ Return from the subroutine