Revs on the BBC Micro

# Extra tracks: HookJoystick (Part 3 of 3)

```       Name: HookJoystick (Part 3 of 3)                              [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: No direct references to this subroutine in this source file

.joys6

\ By this point, Y contains the scale factor to apply to
\ the steering, which is one of the following values:
\
\   * 181 for a scale factor of 1.00
\
\   * 195 for a scale factor of 1.16
\
\   * 220 for a scale factor of 1.48

TYA                    \ Set A = Y
\
\ So A is 181, 195 or 220

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 = 220 we have:
\
\   (A T) = 2 * (220/256 * x-axis) ^ 2
\         = 2 * (0.859 * x-axis) ^ 2
\         = 1.48 * x-axis ^ 2
\
\ and for A = 195 we have:
\
\   (A T) = 2 * (195/256 * x-axis) ^ 2
\         = 2 * (0.762 * x-axis) ^ 2
\         = 1.16 * x-axis ^ 2
\
\ and for A = 181 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 subroutine
```