Skip to navigation

Aviator on the BBC Micro

Drawing lines: DrawCanopyLine (Part 9 of 9)

Name: DrawCanopyLine (Part 9 of 9) [Show more] Type: Subroutine Category: Drawing lines Summary: If the line was clipped, draw a line from the clipped coordinates to the edge of the screen
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file

If the line has been clipped, this part reverses the line's direction in V and switches the start point at (R, S) to the other end of the line, before jumping to the start of the line-drawing routine to draw the reversed line.
.dlin65 LDA V \ Set A = V >> 1, setting the C flag to bit 0 of V LSR A BCS dlin66 \ If bit 0 if V is set, which means the line has been \ clipped by the ClipStartOfLine routine, jump to dlin66 RTS \ Otherwise bit 0 of V is clear and the line has not \ been clipped, so we return from the subroutine .dlin66 ASL A \ Shift A left so it contains V again EOR #%11000000 \ Flip bits 6 and 7 of V to reverse the dirction of the STA V \ line LDA xTemp1Lo \ Set (R, S) = (xTemp1Lo, yTemp1Lo), which we set to the STA R \ start coordinate of the clipped line in the LDA yTemp1Lo \ ClipStartOfLine routine STA S LDA #4 \ Set A = 4, to use as the value of W if bit 7 of V is \ set (i.e. when we step along the x-axis in a negative \ direction, to the left) BIT V \ If bit 7 of V is set, jump to dlin67 to skip the next BMI dlin67 \ instruction LDA #155 \ Set A = 155, to use as the value of W if bit 7 of V is \ clear (i.e. when we step along the x-axis in a \ positive direction, to the right) .dlin67 STA W \ Set W to the value in A (4 or 155), so W contains the \ x-coordinate for the edge of the screen in the step \ direction (i.e. 4 if we are stepping left, 155 if we \ are stepping right) LDA #0 \ Set A = 0, to use as the value of W if bit 6 of V is \ set (i.e. when we step along the y-axis in a negative \ direction, down the screen) BVS dlin68 \ If bit 6 of V is set, jump to dlin68 to skip the next \ instruction LDA #151 \ Set A = 151, to use as the value of W if bit 6 of V is \ clear (i.e. when we step along the y-axis in a \ positive direction, up the screen) .dlin68 STA G \ Set G to the value in A (0 or 151), so G contains the \ y-coordinate for the edge of the screen in the step \ direction (i.e. 0 if we are stepping down, 151 if we \ are stepping up) JMP DrawCanopyLine \ Jump up to DrawCanopyLine to draw the reversed line \ from (xTemp1Lo, yTemp1Lo) to the edge of the screen