Skip to navigation


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 9: scale the steering by 1.88 * Section 22: scale the steering by 1.10 * Section 23: scale the steering by 1.10 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
.HookJoystick 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 #72 \ If the track section <> 72 (i.e. section 9), jump to BNE joys1 \ joys1 to keep checking LDY #248 \ Set Y = 248 so we scale the steering by 1.88 .joys1 CMP #184 \ If the track section = 184 (i.e. section 23), jump to BEQ joys2 \ joys2 to scale the steering by 1.10 CMP #176 \ If the track section <> 176 (i.e. section 22), jump to BNE joys3 \ joys3 to keep checking .joys2 LDY #190 \ Set Y = 190 so we scale the steering by 1.10 .joys3 TYA \ Set A = Y \ \ So A is 181, 190 or 248 JSR Multiply8x8 \ Set (A T) = A * U JMP joys4 \ Jump to part 2