Skip to navigation

Revs on the BBC Micro

Track geometry: GetSectionYawAngle

Name: GetSectionYawAngle [Show more] Type: Subroutine Category: Track geometry Summary: Calculate the difference in yaw angle between an object and the player
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * GetSectionAngles (Part 3 of 3) calls GetSectionYawAngle

This routine is typically used to calculate the difference in yaw angle between a track section and the player.
Arguments: Y Index from xVergeRight to store the difference in yaw angle between the object and the player (JJ II) The yaw angle of the object
Returns: xVergeRight The difference in the yaw angle between the object and the player (if Y points to the right verge) xVergeLeft The difference in the yaw angle between the object and the player (if Y points to the left verge) (L K) The distance between the object and the player's car A Contains the high byte of (L K) M The smaller yaw angle of the object, where 0 to 255 represents 0 to 45 degrees
.GetSectionYawAngle LDA II \ Set the following for the Y-th section: SEC \ SBC playerYawAngleLo \ xVergeRight = (JJ II) - playerYawAngle STA xVergeRightLo,Y \ \ starting with the low bytes LDA JJ \ And then the high bytes SBC playerYawAngleHi STA xVergeRightHi,Y JMP GetObjectDistance \ Set (L K) to the distance between the object and the \ player's car, with A set to L, returning from the \ subroutine using a tail call