Skip to navigation

Revs on the BBC Micro

3D objects: GetObjYawAngle (Part 3 of 4)

Name: GetObjYawAngle (Part 3 of 4) [Show more] Type: Subroutine Category: 3D objects Summary: Calculate yaw angle for when |x-delta| = |z-delta| Deep dive: Pitch and yaw angles
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.rotn9 \ If we get here, then: \ \ * VV is the high byte of x-delta \ \ * GG is the high byte of z-delta \ \ * |x-delta| = |z-delta| LDA #255 \ Set M = 255, to represent a yaw angle of 45 degrees STA M LDA #0 \ Set II = 0 to use as the low byte for the final yaw STA II \ angle BIT VV \ If x-delta is positive, jump to rotn11 BPL rotn11 \ If we get here then x-delta is negative BIT GG \ If z-delta is positive, jump to rotn10 BPL rotn10 \ If we get here then both x-delta and z-delta are \ negative LDA #&A0 \ Set (JJ II) = -96 * 256 STA JJ RTS \ Return from the subroutine .rotn10 \ If we get here then x-delta is negative and y-delta \ is positive LDA #&E0 \ Set (JJ II) = -32 * 256 STA JJ RTS \ Return from the subroutine .rotn11 \ If we get here then x-delta is positive BIT GG \ If z-delta is positive, jump to rotn12 BPL rotn12 \ If we get here then x-delta is positive and y-delta \ is negative LDA #&60 \ Set (JJ II) = 96 * 256 STA JJ RTS \ Return from the subroutine .rotn12 \ If we get here then both x-delta and z-delta are \ positive LDA #&20 \ Set (JJ II) = 32 * 256 STA JJ RTS \ Return from the subroutine