Skip to navigation

Aviator on the BBC Micro

Drawing lines: DrawCanopyLine (Part 1 of 9)

Name: DrawCanopyLine (Part 1 of 9) [Show more] Type: Subroutine Category: Drawing lines Summary: Draw a line in the canopy view Deep dive: Line buffers
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawCanopyLine (Part 9 of 9) calls DrawCanopyLine * EraseCanopyLines calls DrawCanopyLine

The commentary in this routine is a work in progress. 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 U < T (shallow horizontal slope), bit 6 of V is clear (y-axis up) and bit 7 is set (x-axis left).
Arguments: R Start point x-coordinate S Start point y-coordinate T Relative magnitude of line's vector |x-delta| U Relative magnitude of line's vector |y-delta| V Direction of vector (T, U): * Bit 7 is the direction of the x-delta * Bit 6 is the direction of the y-delta * Bit 1 is set if this is the horizon line * Bit 0 is set if the line has been clipped Direction is like a clock, so positive (clear) is up and right W Max/min x-coordinate for the end of the line G Max/min y-coordinate for the end of the line xTemp1Lo The x-coordinate of the start of the line, if clipped yTemp1Lo The y-coordinate of the start of the line, if clipped
.DrawCanopyLine LDA R \ Set X = R / 4 LSR A \ LSR A \ so X is the number of the character block containing TAX \ pixel (R, S), as each character block is 4 pixels wide LDA S \ Set Y = S / 8 LSR A \ LSR A \ so Y is the number of the character row containing LSR A \ pixel (R, S), as each character row is 8 pixels high TAY CLC \ Set P = X-th byte of xLookupLo LDA xLookupLo,X \ + Y-th byte of yLookupLo ADC yLookupLo,Y \ = LO(X * 8) + LO(screen address) STA P LDA xLookupHi,X \ Set Q = X-th byte of xLookupHi ADC yLookupHi,Y \ + Y-th byte of yLookupHi STA Q \ = HI(X * 8) + HI(screen address) \ So (Q P) is the screen address of the pixel row \ containing pixel (R, S), out by 8 bytes for each row \ above or below the top of the dashboard LDA U \ If U < T, the line is a shallow horizontal slope, so CMP T \ jump down to dlin1 to draw the line BCC dlin1 JMP dlin41 \ Otherwise U >= T and the line is a steep vertical \ slope, so jump down to part 4 to draw the line