.clip5 LDA V \ If either bit 7 or bit 6 of V are set, but not both, ASL A \ then if we EOR them we will get a 1, so this jumps to EOR V \ clip6 if this is the case BMI clip6 \ If we get here then bits 6 and 7 of V are the same, so \ the line slope is up-right or down-left, i.e. / LDA #0 \ Set WW = 0, so bit 7 is clear STA WW LDA R \ Set (UU TT) = (RR R) + (SS S) CLC \ ADC S \ starting with the low bytes STA TT LDA RR \ And then the high bytes ADC SS STA UU LDA TT \ Set (UU TT) = (UU TT) - 159 SEC \ SBC #159 \ starting with the low bytes STA TT LDA UU \ And then the high bytes, so we now have: SBC #0 \ STA UU \ (UU TT) = start_x + start_y - 159 JMP clip7 .clip6 \ If we get here then bits 6 and 7 of V are different, \ so the line slope is up-right or down-left, i.e. \ LDA #%10000000 \ Set WW = %10000000, so bit 7 is set STA WW LDA S \ Set (UU TT) = (SS S) - (RR R) SEC \ SBC R \ starting with the low bytes STA TT LDA SS \ And then the high bytes, so now we have: SBC RR \ STA UU \ (UU TT) = start_y - start_x .clip7 BPL clip8 \ If (UU TT) is positive, jump to clip8 LDA #0 \ Set (UU TT) = 0 - (UU TT) SEC \ SBC TT \ starting with the low bytes STA TT LDA #0 \ And then the high bytes, so (UU TT) is now positive, SBC UU \ so: STA UU \ \ (UU TT) = |UU TT| \ = |start_x + start_y - 159| if slope is / \ |start_y - start_x| if slope is \ .clip8 LDA T \ Set (Q P) = (I T) + (J U) CLC \ ADC U \ starting with the low bytes STA P LDA I \ And then the high bytes, so: ADC J \ STA Q \ (Q P) = |x-delta| + |y-delta| LDA P \ Set (Q P) = (Q P) + 2 CLC \ ADC #2 \ starting with the low bytes STA P BCC clip9 \ If the addition didn't overflow, jump to clip9 to \ skip the following instruction INC Q \ Increment the high byte in QName: ClipStartOfLine (Part 2 of 5) [Show more] Type: Subroutine Category: Drawing lines Summary: Work out the deltas depending on the direction of slopeContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
If slope is / (UU TT) = |start_x + start_y - 159| Clear bit 7 of WW If slope is \ (UU TT) = |start_y - start_x| Set bit 7 of WW (Q P) = |x-delta| + |y-delta| + 2
[X]
Label clip6 is local to this routine
[X]
Label clip7 is local to this routine
[X]
Label clip8 is local to this routine
[X]
Label clip9 in subroutine ClipStartOfLine (Part 3 of 5)