Bresenham ALGORITHM
I've built a memory·mapped VGA interface using the SX 48.· I've implemented many video functions such as Sprites, draw pixel, and draw box but the line has got me stumped. Does anyone know how to implement a line using the Bresenham ALGORITHM or otherwise?· Thanks!
Post Edited (mxg331) : 5/23/2009 12:28:41 AM GMT
Post Edited (mxg331) : 5/23/2009 12:28:41 AM GMT

Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
' Variables used by graphics subroutines cnt VAR Byte cnt2 VAR Byte x1 VAR Byte x2 VAR Byte y1 VAR Byte y2 VAR Byte color VAR Byte Line SUB 4 Line: ' (x1,y1,x2,y2) ; Set color before calling x1 = __PARAM1 y1 = __PARAM2 x2 = __PARAM3 - x1 y2 = __PARAM4 - y1 IF x2 >= y2 THEN cnt2 = x2 >> 1 FOR cnt = 0 TO x2 PutPixel x1, y1, color INC x1 IF cnt2 >= y2 THEN cnt2 = cnt2 - y2 ELSE cnt2 = cnt2 - y2 cnt2 = cnt2 + x2 INC y1 ENDIF NEXT ELSE cnt2 = y2 >> 1 FOR cnt = 0 TO y2 PutPixel x1, y1, color INC y1 IF cnt2 >= x2 THEN cnt2 = cnt2 - x2 ELSE cnt2 = cnt2 - x2 cnt2 = cnt2 + y2 INC x1 ENDIF NEXT ENDIF x2 = x1 y2 = y1 RETURNBean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...
·