Skip to navigation


Version analysis of TT15

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

Code variations between these versions are shown below.

Name: TT15 Type: Subroutine Category: Drawing lines Summary: Draw a set of crosshairs
For all views except the Short-range Chart, the centre is drawn 24 pixels to the right of the y-coordinate given.

Code variation 1 of 15A variation in the comments only

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

The crosshairs are drawn in colour 3, which is white in the chart view and cyan elsewhere. We can draw them in the current colour by calling the TT15b entry point.

Arguments: QQ19 The pixel x-coordinate of the centre of the crosshairs QQ19+1 The pixel y-coordinate of the centre of the crosshairs QQ19+2 The size of the crosshairs

Code variation 2 of 15A variation in the comments only

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

Other entry points: TT15b Draw the crosshairs in the current colour
.TT15

Code variation 3 of 15Related to the screen mode

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

LDA #CYAN \ Send a #SETCOL CYAN command to the I/O processor to JSR DOCOL \ switch to colour 3, which is white in the chart view \ and cyan elsewhere .TT15b

Code variation 4 of 15Related to the Master version

The Master version uses variables to define the size of the Long-range Chart.

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

LDA #24 \ Set A to 24, which we will use as the minimum \ screen indent for the crosshairs (i.e. the minimum \ distance from the top-left corner of the screen)
LDA #GCYT \ Set A to GCYT, which we will use as the minimum \ screen indent for the crosshairs (i.e. the minimum \ distance from the top-left corner of the screen)

Code variation 5 of 15A variation in the labels only

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

LDX QQ11 \ If the current view is not the Short-range Chart, BPL P%+4 \ which is the only view with bit 7 set, then skip the \ following instruction LDA #0 \ This is the Short-range Chart, so set A to 0, so the \ crosshairs can go right up against the screen edges
LDX QQ11 \ If the current view is not the Short-range Chart, BPL TT178 \ which is the only view with bit 7 set, then jump to \ TT178 to skip the following instruction LDA #0 \ This is the Short-range Chart, so set A to 0, so the \ crosshairs can go right up against the screen edges .TT178
 STA QQ19+5             \ Set QQ19+5 to A, which now contains the correct indent
                        \ for this view

 LDA QQ19               \ Set A = crosshairs x-coordinate - crosshairs size
 SEC                    \ to get the x-coordinate of the left edge of the
 SBC QQ19+2             \ crosshairs

Code variation 6 of 15Related to the Master version

In the Master version, the horizontal crosshair doesn't overlap the left border of the Short-range Chart, while it does in the other versions.

This variation is blank in the Master version.

BCS TT84 \ If the above subtraction didn't underflow, then A is \ positive, so skip the next instruction LDA #0 \ The subtraction underflowed, so set A to 0 so the \ crosshairs don't spill out of the left of the screen
.TT84

Code variation 7 of 15A variation in the labels only

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

\ In the following, the authors have used XX15 for \ temporary storage. XX15 shares location with X1, Y1, \ X2 and Y2, so in the following, you can consider \ the variables like this: \ \ XX15 is the same as X1 \ XX15+1 is the same as Y1 \ XX15+2 is the same as X2 \ XX15+3 is the same as Y2 \ \ Presumably this routine was written at a different \ time to the line-drawing routine, before the two \ workspaces were merged to save space STA XX15 \ Set XX15 (X1) = A (the x-coordinate of the left edge \ of the crosshairs)
STA X1 \ Set X1 = A (the x-coordinate of the left edge of the \ crosshairs)
 LDA QQ19               \ Set A = crosshairs x-coordinate + crosshairs size
 CLC                    \ to get the x-coordinate of the right edge of the
 ADC QQ19+2             \ crosshairs

Code variation 8 of 15A variation in the labels only

This variation is blank in the Master version.

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

BCC P%+4 \ If the above addition didn't overflow, then A is \ correct, so skip the next instruction LDA #255 \ The addition overflowed, so set A to 255 so the \ crosshairs don't spill out of the right of the screen \ (as 255 is the x-coordinate of the rightmost pixel \ on-screen)
BCC TT85 \ If the above addition didn't overflow, then A is \ correct, so jump to TT85 to skip the next instruction LDA #255 \ The addition overflowed, so set A to 255 so the \ crosshairs don't spill out of the right of the screen \ (as 255 is the x-coordinate of the rightmost pixel \ on-screen) .TT85

Code variation 9 of 15A variation in the labels only

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

STA XX15+2 \ Set XX15+2 (X2) = A (the x-coordinate of the right \ edge of the crosshairs) LDA QQ19+1 \ Set XX15+1 (Y1) = crosshairs y-coordinate + indent CLC \ to get the y-coordinate of the centre of the ADC QQ19+5 \ crosshairs STA XX15+1
STA X2 \ Set X2 = A (the x-coordinate of the right edge of the \ crosshairs) LDA QQ19+1 \ Set Y1 = crosshairs y-coordinate + indent to get the CLC \ y-coordinate of the centre of the crosshairs ADC QQ19+5 STA Y1

Code variation 10 of 15Related to Elite's use of the Tube

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

JSR HLOIN \ Draw a horizontal line from (X1, Y1) to (X2, Y1), \ which will draw from the left edge of the crosshairs \ to the right edge, through the centre of the \ crosshairs
JSR HLOIN3 \ Call HLOIN3 to draw a line from (X1, Y1) to (X2, Y1)
STA XX15+3 \ Set XX15+3 (Y2) = crosshairs y-coordinate + indent JSR LL30 \ Draw a line from (X1, Y1) to (X2, Y2), where Y1 = Y2, \ which will draw from the left edge of the crosshairs \ to the right edge, through the centre of the \ crosshairs
 LDA QQ19+1             \ Set A = crosshairs y-coordinate - crosshairs size
 SEC                    \ to get the y-coordinate of the top edge of the
 SBC QQ19+2             \ crosshairs

 BCS TT86               \ If the above subtraction didn't underflow, then A is
                        \ correct, so skip the next instruction

 LDA #0                 \ The subtraction underflowed, so set A to 0 so the
                        \ crosshairs don't spill out of the top of the screen

.TT86

Code variation 11 of 15A variation in the labels only

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

CLC \ Set XX15+1 (Y1) = A + indent to get the y-coordinate ADC QQ19+5 \ of the top edge of the indented crosshairs STA XX15+1
CLC \ Set Y1 = A + indent to get the y-coordinate of the top ADC QQ19+5 \ edge of the indented crosshairs STA Y1
 LDA QQ19+1             \ Set A = crosshairs y-coordinate + crosshairs size
 CLC                    \ + indent to get the y-coordinate of the bottom edge
 ADC QQ19+2             \ of the indented crosshairs
 ADC QQ19+5

Code variation 12 of 15Related to the Master version

The Master version uses variables to define the size of the Long-range Chart.

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

CMP #152 \ If A < 152 then skip the following, as the crosshairs BCC TT87 \ won't spill out of the bottom of the screen
CMP #GCYB \ If A < GCYB then skip the following, as the crosshairs BCC TT87 \ won't spill out of the bottom of the screen
 LDX QQ11               \ A >= 152, so we need to check whether this will fit in
                        \ this view, so fetch the view type

 BMI TT87               \ If this is the Short-range Chart then the y-coordinate
                        \ is fine, so skip to TT87

Code variation 13 of 15Related to the Master version

The bottom border of the Long-range Chart is one pixel lower down the screen in the Master version than in the other versions, and it uses variables to define the chart size, so the crosshair-clipping code is slightly different too.

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

LDA #151 \ Otherwise this is the Long-range Chart, so we need to \ clip the crosshairs at a maximum y-coordinate of 151
LDA #GCYB \ Otherwise this is the Long-range Chart, so we need to \ clip the crosshairs at a maximum y-coordinate of GCYB
.TT87

Code variation 14 of 15A variation in the labels only

This variation is blank in the Master version.

STA XX15+3 \ Set XX15+3 (Y2) = A (the y-coordinate of the bottom \ edge of the crosshairs) LDA QQ19 \ Set XX15 (X1) = the x-coordinate of the centre of the STA XX15 \ crosshairs STA XX15+2 \ Set XX15+2 (X2) = the x-coordinate of the centre of \ the crosshairs

Code variation 15 of 15A variation in the labels only

This variation is blank in the Master version.

JMP LL30 \ Draw a vertical line from (X1, Y1) to (X2, Y2), which \ will draw from the top edge of the crosshairs to the \ bottom edge, through the centre of the crosshairs, \ and returning from the subroutine using a tail call