Skip to navigation

Drawing lines: TT15

[Apple II version]

Name: TT15 [Show more] Type: Subroutine Category: Drawing lines Summary: Draw a set of crosshairs
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * SIGHT calls TT15 * TT103 calls TT15 * TT105 calls TT15 * TT14 calls TT15

For all views except the Short-range Chart, the centre is drawn 24 pixels to the right of the y-coordinate given.
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
.TT15 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) 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 BIT QQ11 ; If bit 7 of QQ11 is set, then this this is the BMI TT84 ; Short-range Chart, so jump to TT84 to skip the ; following CMP #34 ; This is the Long-range Chart, so clip the x-coordinate BCS TT84 ; of the left edge of the crosshairs so that it is at LDA #34 ; least 34 (so it doesn't go off the left edge of the ; chart) .TT84 STA X1 ; Set X1 = A (the x-coordinate of the left edge of the ; crosshairs) LDA QQ19 ; Set A = crosshairs x-coordinate + crosshairs size + 2 CLC ; to get the x-coordinate of the right edge of the ADC #2 ; crosshairs ADC QQ19+2 BIT QQ11 ; If bit 7 of QQ11 is set, then this this is the BMI TT85 ; Short-range Chart, so jump to TT85 to skip the ; following CMP #224 ; This is the Long-range Chart, so clip the x-coordinate BCC TT85 ; of the right edge of the crosshairs so that it is no LDA #224 ; more than 224 (so it doesn't go off the right edge of ; the chart) .TT85 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 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 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 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 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 LDA #GCYB ; Otherwise this is the Long-range Chart, so we need to ; clip the crosshairs at a maximum y-coordinate of GCYB .TT87 STA Y2 ; Set Y2 = A (the y-coordinate of the bottom edge of the ; crosshairs) LDA QQ19 ; Set X1 = the x-coordinate of the centre of the STA X1 ; crosshairs JMP VLOIN ; Draw a vertical line from (X1, Y1) to (X1, 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