Skip to navigation


Extra tracks: HookFlattenHills (Part 2 of 3)

Name: HookFlattenHills (Part 2 of 3) [Show more] Type: Subroutine Category: Extra tracks Summary: Flatten any hills in the verge buffer, calculate the hill height and track width, cut objects off at the hill height Deep dive: Secrets of the extra tracks Code hooks in the extra tracks
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file

This part of the routine sets the verge edge to being visible when the car is pointing along the track and the nose is pointing downwards.
.hill4 LDA playerHeading \ Set A to the player's heading along the track, which \ is an angle that represents the direction in which our \ car is facing with respect to the track, like this: \ \ 0 \ -32 | +32 Overhead view of car \ \ | / \ \ | / 0= looking straight ahead \ \|/ +64= looking sharp right \ -64 -----+----- +64 -64= looking sharp left \ /|\ \ / | \ \ / | \ \ -96 | +96 \ 128 \ \ An angle of 0 means our car is facing forwards along \ the track, while an angle of +32 means we are facing \ 45 degrees to the right of straight on, and an angle \ of 128 means we are facing backwards along the track JSR Absolute8Bit \ Set A= |A|, which reflects the angle into \ the right half of the above diagram: \ \ 0 \ | 32 \ | / \ | / \ |/ \ +----- 64 \ |\ \ | \ \ | \ \ | 96 \ 127 CMP #25 \ If A >= 25, then the car is pointing to a greater BCS hill5 \ angle than 25 to either side of dead ahead (i.e. it is \ pointing outside of the -24 to +24 field of view, or \ greater than 33 degrees either side of 0), so jump to \ hill5 to call CheckVergeOnScreen in the usual way LDA playerPitchAngle \ If the player's pitch angle is positive, which means BPL hill5 \ the car's nose is pointing up, above the horizontal, \ then jump to hill5 to call CheckVergeOnScreen in the \ usual way \ If we get here then the car nose is pointing downwards \ and the car is pointing straight along the track, \ within a -33 to +33 degree field of view JMP hill6 \ Jump to part 3 .hill5 JMP CheckVergeOnScreen \ Implement the call that we overwrote with the call to \ the hook routine, so we have effectively inserted the \ above code into the main game (the JMP ensures we \ return from the subroutine using a tail call)