Skip to navigation

Revs on the BBC Micro

Car geometry: CompareCarSegments

Name: CompareCarSegments [Show more] Type: Subroutine Category: Car geometry Summary: Calculate the distance between two cars, in terms of segments and progress with the current segment Deep dive: Placing cars on the track
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessOvertaking (Part 1 of 3) calls CompareCarSegments

Extends the distance calculation in CompareSegments by rounding the segment numbers used in the calculations, depending on the cars' progress within their current segments.
Arguments: X The number of driver X Y The number of driver Y
.CompareCarSegments LDA carProgress,Y \ Set the C flag according to the subtraction: SEC \ SBC carProgress,X \ carProgress for driver ahead \ - carProgress for this driver \ \ The progress figures act like a fractional byte \ in the subtraction at the start of the following \ routine, though because only the C flag is kept, they \ only serve to round the result to the nearest integer, \ rather than giving a full 24-bit result \ Fall through into CompareSegments to calculate the \ distance between the two cars, rounding the result \ according to the difference in the cars' progress \ values