Skip to navigation

Elite on the BBC Micro and NES

Charts: TT105

[NES version, Bank 0]

Name: TT105 [Show more] Type: Subroutine Category: Charts Summary: Draw crosshairs on the Short-range Chart, with clipping
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * TT103 calls TT105

Check whether the crosshairs are close enough to the current system to appear on the Short-range Chart, and if so, draw them.
.TT105 LDA QQ9 ; Set A = QQ9 - QQ0, the horizontal distance between the SEC ; crosshairs (QQ9) and the current system (QQ0) SBC QQ0 CMP #36 ; If the horizontal distance in A < 36, then the BCC TT179 ; crosshairs are close enough to the current system to ; appear in the Short-range Chart, so jump to TT179 to ; check the vertical distance CMP #233 ; If the horizontal distance in A < -23, then the BCC HideCrosshairs ; crosshairs are too far from the current system to ; appear in the Short-range Chart, so jump to ; HideCrosshairs to hide the crosshairs and return from ; the subroutine using a tail call .TT179 ASL A ; Set QQ19 = 104 + A * 4 ASL A ; CLC ; 104 is the x-coordinate of the centre of the chart, ADC #104 ; so this sets QQ19 to the screen pixel x-coordinate STA QQ19 ; of the crosshairs LDA QQ10 ; Set A = QQ10 - QQ1, the vertical distance between the SEC ; crosshairs (QQ10) and the current system (QQ1) SBC QQ1 CMP #38 ; If the vertical distance in A is < 38, then the BCC P%+6 ; crosshairs are close enough to the current system to ; appear in the Short-range Chart, so skip the next two ; instructions CMP #220 ; If the horizontal distance in A is < -36, then the BCC HideCrosshairs ; crosshairs are too far from the current system to ; appear in the Short-range Chart, so jump to ; HideCrosshairs to hide the crosshairs and return from ; the subroutine using a tail call ASL A ; Set QQ19+1 = 90 + A * 2 CLC ; ADC #90 ; 90 is the y-coordinate of the centre of the chart, STA QQ19+1 ; so this sets QQ19+1 to the screen pixel x-coordinate ; of the crosshairs LDA #8 ; Set QQ19+2 to 8 denote crosshairs of size 8 STA QQ19+2 ; Fall through into DrawCrosshairs to draw crosshairs of ; size 8 at the crosshairs coordinates