Skip to navigation

Revs on the BBC Micro

Extra tracks: HookFlattenHills (Part 3 of 3)

Name: HookFlattenHills (Part 3 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 flags the verge coordinate at index X as being visible on-screen, but only when the track section at the front of the segment buffer is one of sections 0 to 5.
.hill6 LDA objTrackSection+23 \ Set A to the number * 8 of the track section for the \ front segment of the track segment buffer CMP #48 \ If A >= 48, i.e. the front segment of the track BCS hill7 \ segment buffer is track section 6 or later, jump to \ hill7 to call CheckVergeOnScreen \ Otherwise we replace the call to CheckVergeOnScreen \ with the following, which clears bit 7 of V to flag \ the verge coordinate at index X as being visible \ on-screen LSR V \ Clear bit 7 of V RTS \ Return from the subroutine .hill7 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)