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 subroutineName: CheckForContact [Show more] Type: Subroutine Category: Car geometry Summary: Check to see if the object is close enough to the player car to make contactContext: 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
[X]
Subroutine GetObjectDistance (category: 3D objects)
Calculate the distance between an object and the player's car, for collision purposes
[X]
Label ccon1 is local to this routine
[X]
Variable collisionDriver in workspace Zero page
The number of the driver being hit by the player's car
[X]
Variable objectDistanceHi in workspace Zero page
The high byte of the distance to the current object
[X]
Variable objectDistanceLo in workspace Zero page
The low byte of the distance to the current object
[X]
Variable objectNumber in workspace Zero page
The object number of the four-part car we are drawing
[X]
Variable processContact in workspace Zero page
Another car is close enough to the player's car for us to process car-on-car contact