slice_line.s 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. **************************************
  2. *** DRAW SLICE LINE ***
  3. **************************************
  4. Draw_Slice_Line
  5. *send x1,y1,x2,y2 in d0,d1,d2,d3
  6. *bitmap in a0
  7. ext.l d0
  8. ext.l d1
  9. *make copies
  10. move.w d0,d4
  11. move.w d1,d5
  12. move.w #-1,d7
  13. sub.w d2,d0 ;deltax
  14. beq draw_horiz_line
  15. bpl.s do_y ;is line going left to right
  16. neg.w d0 ;make deltax positive
  17. move.w #1,d7 ;xinc
  18. do_y
  19. sub.w d3,d1 ;deltay
  20. beq draw_vert_line
  21. bmi.s line_going_down
  22. neg.w d7 ;neg xinc
  23. move.w d2,d4 ;swap x start value
  24. move.w d3,d5 ;swap y start value
  25. bra.s test_major
  26. line_going_down
  27. neg.w d1 ;make y delta positive
  28. test_major
  29. *Calculate start position in bitmap
  30. mulu #BPR,d5
  31. move.w d4,d6
  32. lsr.w #3,d6
  33. add.w d6,d5
  34. add.l d5,a0 ;start pos
  35. andi.w #$7,d4 ;start pixel pos
  36. neg.w d4
  37. add.w #7,d4
  38. cmp.w d1,d0
  39. blt.s y_major
  40. x_major
  41. move.w d7,d5 ;x inc
  42. *get x step value
  43. divu d1,d0 ;divide deltax by deltay
  44. move.w d1,d7
  45. move.w d0,d2 ;get x step value
  46. subq.w #1,d2
  47. swap d0 ;error step
  48. move.w d1,d3
  49. lsr d3 ;error value
  50. neg d3
  51. subq.w #1,d1
  52. x_delta_loop
  53. move.w d2,d6 ;loop value
  54. add.w d0,d3
  55. blt.s x_step_loop
  56. addq.w #1,d6 ;extra pixel
  57. sub.w d7,d3 ;reset error value
  58. x_step_loop
  59. bset d4,(a0) ;set pix
  60. sub.w d5,d4 ;add direction to x
  61. bge.s not_dropped_left
  62. addq.l #1,a0
  63. moveq.w #7,d4
  64. dbra d6,x_step_loop
  65. add.l #BPR,a0
  66. dbra d1,x_delta_loop
  67. rts
  68. not_dropped_left
  69. cmp.w #8,d4
  70. bne.s do_xloop
  71. subq.l #1,a0
  72. clr.w d4
  73. do_xloop
  74. dbra d6,x_step_loop
  75. finished_x_loop
  76. add.l #BPR,a0
  77. dbra d1,x_delta_loop
  78. rts
  79. y_major
  80. move.w d7,d5 ;get x inc
  81. *get x step value
  82. divu d0,d1 ;divide deltay by deltax
  83. move.w d0,d7
  84. move.w d1,d2 ;get x step value
  85. subq.w #1,d2
  86. swap d1 ;error step
  87. move.w d0,d3
  88. lsr d3 ;error value
  89. neg d3
  90. subq.w #1,d0
  91. y_delta_loop
  92. move.w d2,d6 ;loop value
  93. add.w d1,d3
  94. blt.s y_step_loop
  95. addq.w #1,d6 ;extra pixel
  96. sub.w d7,d3 ;reset error value
  97. y_step_loop
  98. bset d4,(a0)
  99. add.l #BPR,a0
  100. dbra d6,y_step_loop
  101. sub.w d5,d4 ;add x
  102. bge.s y_x_not_dropped
  103. addq.l #1,a0
  104. moveq.w #7,d4
  105. dbra d0,y_delta_loop
  106. rts
  107. y_x_not_dropped
  108. cmp.w #8,d4
  109. bne.s do_y_loop
  110. subq.l #1,a0
  111. clr.w d4
  112. do_y_loop
  113. dbra d0,y_delta_loop
  114. rts
  115. draw_horiz_line
  116. rts
  117. draw_vert_line
  118. rts