Skip to navigation

Aviator on the BBC Micro

Drawing lines: DrawCanopyLine (Part 7 of 9)

Name: DrawCanopyLine (Part 7 of 9) [Show more] Type: Subroutine Category: Drawing lines Summary: Modify the line drawing routine for a steep vertical slope
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file

The code in this routine is modified by the ModifyDrawRoutine routine, and by the DrawCanopyLine routine itself. The default code (i.e. the unmodified version in the source) is run when: * Bit 7 of V is clear, so we step along the x-axis in a positive direction, i.e. to the right * Bit 6 of V is clear, so we step along the y-axis in a positive direction, i.e. up the screen
.dlin41 \ If we get here then the line is a steep vertical slope BIT V \ If bit 6 of V is set, jump to dlin42 to step along the BVS dlin42 \ y-axis in a negative direction, i.e. down the screen \ If we get here then bit 6 of V is clear, so we step \ along the y-axis in a positive direction, i.e. up the \ screen, which we implement by modifying the routine's \ code LDA #&98 \ Modify the following instruction at dlin53: STA dlin53 \ \ TYA -> TYA \ \ i.e. set it back to the default LDA #&88 \ Modify the following instruction at dlin54: STA dlin54 \ \ DEY -> DEY \ \ i.e. set it back to the default LDA #&C8 \ Modify the following instruction at dlin37: STA dlin55+1 \ \ ADC #&C8 -> ADC #&C8 \ \ i.e. set it back to the default LDA #&FE \ Modify the following instruction at dlin38: STA dlin56+1 \ \ ADC #&FE -> ADC #&FE \ \ i.e. set it back to the default LDA #7 \ Set J = 7 STA J \ \ So J contains the y-coordinate of the bottom of the \ screen, flipped to match screen memory (so higher \ values of the y-coordinate are lower down the screen) BNE dlin43 \ Jump to dlin43 to skip the code modifications for the \ other value of bit 6 (this BNE is effectively a JMP as \ A is never zero) .dlin42 \ If we get here then bit 6 of V is set, so we step \ along the y-axis in a negative direction, i.e. down \ the screen, which we implement by modifying the \ routine's code, setting it back to the default LDA #&C8 \ Modify the following instruction at dlin53: STA dlin53 \ \ TYA -> INY LDA #&98 \ Modify the following instruction at dlin54: STA dlin54 \ \ DEY -> TYA LDA #&38 \ Modify the following instruction at dlin37: STA dlin55+1 \ \ ADC #&C8 -> ADC #&38 LDA #1 \ Modify the following instruction at dlin38: STA dlin56+1 \ \ ADC #&FE -> ADC #1 LDA #160 \ Set J = 160 STA J \ \ So J contains the y-coordinate of the end of the line, \ flipped to match screen memory (so higher values of \ the y-coordinate are lower down the screen) .dlin43 BIT V \ If bit 7 of V is set, jump to dlin44 to step along the BMI dlin44 \ x-axis in a negative direction, i.e. to the left \ If we get here then bit 7 of V is clear, so we step \ along the x-axis in a positive direction, i.e. to the \ right, which we implement by modifying the routine's \ code, setting it back to the default LDA #&1D \ Modify the following instruction at dlin52: STA dlin52+1 \ \ BCS dlin57 -> BCS dlin57 \ \ i.e. set it back to the default LDA W \ Set I = W + 1 CLC ADC #1 STA I JMP dlin45 \ Jump to dlin45 to skip the code modifications for the \ other value of bit 7 .dlin44 \ If we get here then bit 7 of V is set, so we step \ along the x-axis in a negative direction, i.e. to the \ left, which we implement by modifying the routine's \ code LDA #&3F \ Modify the following instruction at dlin52: STA dlin52+1 \ \ BCS dlin57 -> BCS dlin61 LDA W \ Set I = W - 1 SEC SBC #1 STA I