.HookJoystick LDY currentPlayer \ Set A to the track section number * 8 for the current LDA objTrackSection,Y \ player LDY #181 \ Set Y = 181 so we scale the steering by 1.00 CMP #32 \ If the track section <> 32 (i.e. section 4), jump to BNE joys1 \ joys1 to skip the following instruction LDY #240 \ The player is in track section 4, so set Y = 240 to \ scale the steering by 1.76 .joys1 TYA \ Set A = Y \ \ So A is 240 if this is track section 4, or 181 for all \ other sections JSR Multiply8x8 \ Set (A T) = A * U \ = A * x-axis STA U \ Set U = A \ = high byte of A * x-axis JSR Multiply8x8 \ Set (A T) = A * U \ = A * A \ = (A * x-axis) ^ 2 ASL T \ Set (A T) = (A T) * 2 ROL A \ = 2 * (A * x-axis) ^ 2 \ So for A = 240 (track section 4) we have: \ \ (A T) = 2 * (240/256 * x-axis) ^ 2 \ = 2 * (0.938 * x-axis) ^ 2 \ = 1.76 * x-axis ^ 2 \ \ and for A = 181 (all other sections) we have: \ \ (A T) = 2 * (181/256 * x-axis) ^ 2 \ = 2 * (0.707 * x-axis) ^ 2 \ = 1.00 * x-axis ^ 2 RTS \ Return from the subroutineName: HookJoystick [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 tracksContext: 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 make it easier to steer round the Druids hairpin bend when using a joystick. If this is track section 4, set: (A T) = 1.76 * x-axis ^ 2 otherwise set: (A T) = x-axis ^ 2 The latter is the same as the existing game code, so this hook only affects track section 4.
Arguments: U The joystick x-axis high byte
[X]
Configuration variable Multiply8x8 = &0C00
[X]
Configuration variable T = &0074
[X]
Configuration variable U = &0075
[X]
Configuration variable currentPlayer = &006F
[X]
Label joys1 is local to this routine
[X]
Configuration variable objTrackSection = &06E8