Elite on the BBC Micro and NES

# Version analysis of TT128

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

```       Name: TT128
Type: Subroutine
Category: Drawing circles
Summary: Draw a circle on a chart
Deep dive: Drawing circles

Draw a circle with the centre at (QQ19, QQ19+1) and radius K.

Arguments:

QQ19                 The x-coordinate of the centre of the circle

QQ19+1               The y-coordinate of the centre of the circle

K                    The radius of the circle

.TT128

LDA QQ19               \ Set K3 = the x-coordinate of the centre
STA K3

LDA QQ19+1             \ Set K4 = the y-coordinate of the centre
STA K4

```

Code variation 1 of 3Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

```CassetteFlight, Docked, 6502SP, ElectronMaster LDX #0                 \ Set the high bytes of K3(1 0) and K4(1 0) to 0
STX K4+1
STX K3+1

\STX LSX                \ This instruction is commented out in the original
\ source

INX                    \ Set LSP = 1 to reset the ball line heap
STX LSP

LDX #2                 \ Set STP = 2, the step size for the circle
STX STP
LDX #0                 \ Set the high bytes of K3(1 0) and K4(1 0) to 0
STX K4+1
STX K3+1

INX                    \ Set LSP = 1 to reset the ball line heap
STX LSP

LDX #2                 \ Set STP = 2, the step size for the circle
STX STP
STZ K4+1               \ Set the high bytes of K3(1 0) and K4(1 0) to 0
STZ K3+1

LDX #1                 \ Set LSP = 1 to reset the ball line heap
STX LSP

INX                    \ Set STP = 2, the step size for the circle
STX STP
```

Code variation 2 of 3Related to the screen mode

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

Tap on a block to expand it, and tap it again to revert.

```Master6502SP LDA #RED               \ Switch to colour 2, which is red in the chart view
STA COL
LDA #RED               \ Send a #SETCOL RED command to the I/O processor to
JSR DOCOL              \ switch to colour 2, which is red in the chart view
```

Code variation 3 of 3Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

```CassetteDocked, 6502SP, MasterFlight, Electron JSR CIRCLE2            \ Call CIRCLE2 to draw a circle with the centre at
\ (K3(1 0), K4(1 0)) and radius K

\LDA #&FF               \ These instructions are commented out in the original
\STA LSX                \ source

RTS                    \ Return from the subroutine
JMP CIRCLE2            \ Jump to CIRCLE2 to draw a circle with the centre at
\ (K3(1 0), K4(1 0)) and radius K, returning from the
\ subroutine using a tail call
JSR CIRCLE2            \ Call CIRCLE2 to draw a circle with the centre at
\ (K3(1 0), K4(1 0)) and radius K

RTS                    \ Return from the subroutine
```