slice_line2.s 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. move.w #$80,d6
  37. lsr d4,d6 ;get pixel pos
  38. move.w d6,d4
  39. cmp.w d1,d0
  40. blt.s y_major
  41. x_major
  42. move.w d7,d5 ;x inc
  43. *get x step value
  44. divu d1,d0 ;divide deltax by deltay
  45. move.w d1,d7
  46. move.w d0,d2 ;get x step value
  47. subq.w #1,d2
  48. swap d0 ;error step
  49. move.w d1,d3
  50. lsr d3 ;error value
  51. neg d3
  52. subq.w #1,d1
  53. x_delta_loop
  54. move.w d2,d6 ;loop value
  55. add.w d0,d3
  56. blt.s x_step_loop
  57. addq.w #1,d6 ;extra pixel
  58. sub.w d7,d3 ;reset error value
  59. x_step_loop
  60. or.b d4,(a0) ;set pix
  61. tst.w d5 ;test x_direc
  62. bmi.s xgoing_left
  63. ror.b d4
  64. bge.s dont_inc_x_byte1
  65. addq.l #1,a0
  66. dont_inc_x_byte1
  67. dbra d6,x_step_loop
  68. add.l #BPR,a0
  69. dbra d1,x_delta_loop
  70. rts
  71. xgoing_left
  72. rol.b d4
  73. bcc.s dont_dec_x_byte1
  74. subq.l #1,a0
  75. dont_dec_x_byte1
  76. dbra d6,x_step_loop
  77. add.l #BPR,a0
  78. dbra d1,x_delta_loop
  79. rts
  80. y_major
  81. move.w d7,d5 ;get x inc
  82. *get x step value
  83. divu d0,d1 ;divide deltay by deltax
  84. move.w d0,d7
  85. move.w d1,d2 ;get x step value
  86. subq.w #1,d2
  87. swap d1 ;error step
  88. move.w d0,d3
  89. lsr d3 ;error value
  90. neg d3
  91. subq.w #1,d0
  92. y_delta_loop
  93. move.w d2,d6 ;loop value
  94. add.w d1,d3
  95. blt.s y_step_loop
  96. addq.w #1,d6 ;extra pixel
  97. sub.w d7,d3 ;reset error value
  98. y_step_loop
  99. or.b d4,(a0)
  100. add.l #BPR,a0
  101. dbra d6,y_step_loop
  102. tst d5
  103. bmi.s xgoing_left_y
  104. ror.b d4
  105. bge.s dont_inc_x_byte
  106. addq.l #1,a0
  107. dont_inc_x_byte
  108. dbra d0,y_delta_loop
  109. rts
  110. xgoing_left_y
  111. rol.b d4
  112. bcc.s dont_dec_x_byte
  113. subq.l #1,a0
  114. dont_dec_x_byte
  115. dbra d0,y_delta_loop
  116. rts
  117. draw_horiz_line
  118. rts
  119. draw_vert_line
  120. rts