Skip to navigation

Revs on the BBC Micro

Extra tracks: HookJoystick (Part 1 of 2)

Name: HookJoystick (Part 1 of 2) [Show more] Type: Subroutine Category: Extra tracks Summary: Apply enhanced joystick steering to specific track sections Deep dive: Secrets of the extra tracks Code hooks in the extra tracks
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * newContentHi calls HookJoystick * newContentLo calls HookJoystick

This routine is called from ProcessDrivingKeys to scale the steering in the following sections to make it easier to steer when using a joystick: * Section 8: scale the steering by 1.28 * Section 11: scale the steering by 1.37 * Section 26: scale the steering by 1.25 Specifically, the scaling is applied as follows: (A T)= scale_factor * x-axis ^ 2 which replaces this existing code in ProcessDrivingKeys: (A T)= x-axis^2
Arguments: U The joystick x-axis high byte A The joystick x-axis high byte Z flag Set if A= 0
.HookJoystick PHP \ Store the status flags and A on the stack, so we can PHA \ use them in the steering calculation LDY currentPlayer \ Set A to the track section number * 8 for the current LDA objTrackSection,Y \ player LDY #181 \ Set Y= 181 so by default we scale the steering by \ 1.00 CMP #88 \ If the track section <> 88 (i.e. section 11), jump to BNE joys1 \ joys1 to keep checking LDY #212 \ Set Y= 212 so we scale the steering by 1.37 .joys1 CMP #64 \ If the track section <> 64 (i.e. section 8), jump to BNE joys2 \ joys2 to keep checking LDY #205 \ Set Y= 205 so we scale the steering by 1.28 .joys2 CMP #208 \ If the track section <> 208 (i.e. section 26), jump to BNE joys3 \ joys3 to keep checking LDY #202 \ Set Y= 202 so we scale the steering by 1.25 .joys3 TYA \ Set A= Y \ \ So A is 181, 202, 205 or 212 JMP joys4 \ Jump to part 2 to scale the steering EQUB &B5, &B8 \ These bytes appear to be unused