Skip to navigation


Drawing lines: DrawOrthoLine

Name: DrawOrthoLine [Show more] Type: Subroutine Category: Drawing lines Summary: Draw an orthogonal line (i.e. vertical or horizontal)
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawIndicatorBar calls DrawOrthoLine * DrawJoystickCross calls DrawOrthoLine * DrawIndicatorBar calls via EraseOrthoLine

Arguments: S Defines the starting coordinate for the line: * 0 = (joyCoord, H + W) * 128 = (H + W, joyCoord) H + W Coordinate of the start of the line (it doesn't matter how this value is split between H and W as only the sum is used) joyCoord Coordinate of the start of the line T Horizontal width/length of line U Vertical width/length of line N Drawing mode: * 0 = Draw (using OR logic) * 128 = Erase (using EOR logic)
Other entry points: EraseOrthoLine Use the value of G instead of H (so the coordinate is G + W) and always use EOR Logic to draw the line (which will erase it if it is already on-screen)
.DrawOrthoLine LDA H \ Set A = H JMP dort1 \ Jump to dort1 to draw the orthogonal line and skip the \ code for the EraseOrthoLine entry point .EraseOrthoLine LDA #128 \ Set N = 128 so the line is drawn with EOR logic, which STA N \ erases the line if it is already on-screen LDA G \ Set A = G .dort1 CLC \ Set A = A + W ADC W BIT S \ If bit 7 of S is set, jump down to dort2 BMI dort2 STA J \ Set J = A LDA joyCoord \ Set I = joyCoord STA I \ We now have (I, J) = (joyCoord, A + W) JMP dort3 \ Jump down to dort3 .dort2 STA I \ Set I = A LDA joyCoord \ Set J = joyCoord STA J \ We now have (I, J) = (A + W, joyCoord) .dort3 LDA #0 \ Set V = 0 so the line is drawn in a positive direction STA V \ for both axes JSR DrawVectorLine \ Draw/erase a line from (I, J) as a vector (T, U) with \ direction V RTS \ Return from the subroutine