Aviator on the BBC Micro

# Drawing lines: DrawJoystickCross

```       Name: DrawJoystickCross                                       [Show more]
Type: Subroutine
Category: Drawing lines
Summary: Draw a cross in the joystick position display (indicator 8 or 10)
Context: See this subroutine in context in the source code
References: This subroutine is called as follows:
* UpdateIndicator (Part 14 of 15) calls DrawJoystickCross

This routine draws a cross, relative to a centre point of (80, 216), and with
a 3-pixel horizontal bar and a 5-pixel vertical bar.

Arguments:

A                    Drawing mode:

* 0 = Draw (using OR logic)

* 128 = Erase (using EOR logic)

xJoyCoord            The current joystick x-coordinate

yJoyCoord            The current joystick y-coordinate

.DrawJoystickCross

STA N                  \ Store the drawing mode in N

\ First we draw the 3-pixel horizontal line right from
\ (79 + x, 216 + y)

LDA yJoyCoord          \ Set H = yJoyCoord
STA H

LDA xJoyCoord          \ Set joyCoord = xJoyCoord + 79
CLC                    \
ADC #79                \ to get the x-coordinate of the left end of the
STA joyCoord           \ horizontal line at 79 + x

LDA #216               \ Set W = 216, the y-coordinate of the centre point, so
STA W                  \ we draw the line from a y-coordinate of 216 + y

LDA #0                 \ Set S = 0, to denote that joyCoord is the
STA S                  \ x-coordinate, so we draw the line from point
\ (joyCoord, H + W)

LDA #3                 \ Set T = 3, so we draw a horizontal 3-pixel line
STA T

LDA #1                 \ Set U = 1, so the line is 1 pixel high
STA U

JSR DrawOrthoLine      \ Draw the horizontal part of the cross, starting from
\ (79 + x, 216 + y) and drawing to the right for three
\ pixels

\ Now we draw the 5-pixel vertical line down from
\ (80 + x, 214 + y)

LDA xJoyCoord          \ Set H = xJoyCoord
STA H

LDA yJoyCoord          \ Set joyCoord = yJoyCoord + 214
CLC                    \
ADC #214               \ to get the y-coordinate of the top end of the vertical
STA joyCoord           \ line at 214 + y

LDA #80                \ Set W = 80, the x-coordinate of the centre point, so
STA W                  \ we draw the line from an x-coordinate of 80 + x

LDA #128               \ Set S = 128, to denote that joyCoord is the
STA S                  \ y-coordinate, so we draw the line from point
\ (H + W, joyCoord)

LDA #1                 \ Set T = 1, so the line is 1 pixel wide
STA T

LDA #5                 \ Set U = 5, so we draw a vertical 5-pixel line
STA U

JSR DrawOrthoLine      \ Draw the vertical part of the cross, starting from
\ (80 + x, 214 + y) and drawing down for five pixels

RTS                    \ Return from the subroutine
```