clipsprite32.s 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. .globl ClipSprite32
  2. .text
  3. .even
  4. ClipSprite32:
  5. movem.l %d3-%d7,-(%a7)
  6. tst.w %d1
  7. bge.s .L__cs32_1
  8. add.w %d1,%d2
  9. asl.w #2,%d1
  10. suba.w %d1,%a0
  11. moveq #0,%d1
  12. .L__cs32_1:
  13. move.w %d1,%d3
  14. add.w %d2,%d1
  15. sub.w #128,%d1
  16. ble.s .L__cs32_2
  17. sub.w %d1,%d2
  18. .L__cs32_2:
  19. move.w %d3,%d1
  20. mulu.w #30,%d1
  21. adda.w %d1,%a1
  22. move.w %d0,%d1
  23. move.w %d0,%d5
  24. asr.w #4,%d1
  25. add.w %d1,%d1
  26. adda.w %d1,%a1
  27. and.w #15,%d0
  28. moveq #16,%d6 | 2
  29. sub.w %d0,%d6 | 2
  30. moveq #-1,%d4
  31. lsl.w %d6,%d4
  32. moveq #-1,%d3
  33. lsr.l %d0,%d3
  34. tst.w %d5
  35. bge.s .L__cs32_3
  36. swap %d3
  37. clr.w %d3
  38. swap %d3
  39. cmp.w #-16,%d5
  40. bge.s .L__cs32_3
  41. moveq #0,%d3
  42. cmp.w #-32,%d5
  43. bgt.s .L__cs32_3
  44. .L__cs32_rts:
  45. movem.l (%a7)+,%d3-%d7
  46. rts
  47. .L__cs32_3:
  48. cmp.w #240-32,%d5
  49. ble.s .L__cs32_4
  50. moveq #0,%d4
  51. cmp.w #240-16,%d5
  52. blt.s .L__cs32_4
  53. clr.w %d3
  54. cmp.w #240,%d5
  55. bge.s .L__cs32_rts
  56. .L__cs32_4:
  57. move.l %d3,%d6
  58. move.w %d4,%d7
  59. not.l %d6
  60. not.w %d7
  61. move.l %d6,.L__cs32_leftmaskdropoff+2
  62. move.w 2(%a7),%d5
  63. subq.w #2,%d5
  64. bne.s .L__cs32_notand
  65. move.l %d6,%d3
  66. move.w %d7,%d4
  67. .L__cs32_notand:
  68. lea -26(%a1),%a1
  69. .L__cs32_loop:
  70. subq.w #1,%d2
  71. blt.s .L__cs32_rts
  72. lea 26(%a1),%a1
  73. move.l (%a0)+,%d1
  74. ror.l %d0,%d1
  75. move.l %d1,%d6
  76. swap %d6
  77. tst.w %d5
  78. beq.s .L__cs32_Am
  79. and.l %d3,%d1 |left side
  80. and.w %d4,%d6 |right side
  81. cmpi.w #-1,%d5
  82. beq.s .L__cs32_Om
  83. bgt.s .L__cs32_Rm
  84. |XOR
  85. eor.l %d1,(%a1)+
  86. eor.w %d6,(%a1)
  87. bra.s .L__cs32_loop
  88. .L__cs32_Rm: |RPLC
  89. .L__cs32_leftmaskdropoff:
  90. and.l #0xDEED,(%a1)
  91. or.l %d1,(%a1)+
  92. and.w %d7,(%a1)
  93. or.w %d6,(%a1)
  94. bra.s .L__cs32_loop
  95. .L__cs32_Om: |OR
  96. or.l %d1,(%a1)+
  97. or.w %d6,(%a1)
  98. bra.s .L__cs32_loop
  99. .L__cs32_Am: |AND
  100. or.l %d3,%d1 |left side
  101. or.w %d4,%d6 |right side
  102. and.l %d1,(%a1)+
  103. and.w %d6,(%a1)
  104. bra.s .L__cs32_loop
  105. | This one works, but uses 2 longword operations, where 1 longword + 1 word operations are enough.
  106. /*
  107. .xdef ClipSprite32
  108. .text
  109. ClipSprite32:
  110. movem.l %d3-%d7,-(%a7)
  111. tst.w %d1
  112. bge.s .L__cs32_nonegY
  113. add.w %d1,%d2
  114. asl.w #2,%d1
  115. suba.w %d1,%a0
  116. moveq #0,%d1
  117. .L__cs32_nonegY:
  118. move.w %d1,%d3
  119. add.w %d2,%d1
  120. sub.w #128,%d1
  121. ble.s .L__cs32_nooverY
  122. sub.w %d1,%d2
  123. .L__cs32_nooverY:
  124. move.w %d3,%d1
  125. mulu.w #30,%d1
  126. adda.w %d1,%a1
  127. move.w %d0,%d1
  128. move.w %d0,%d5
  129. asr.w #4,%d1
  130. add.w %d1,%d1
  131. adda.w %d1,%a1
  132. and.w #15,%d0
  133. move.w %d0,%d6
  134. eor.w #31,%d6
  135. addq.w #1,%d6
  136. moveq #-1,%d4
  137. lsl.l %d6,%d4
  138. moveq #-1,%d3
  139. lsr.l %d0,%d3
  140. tst.w %d5
  141. bge.s .L__cs32_nonegX
  142. swap %d3
  143. clr.w %d3
  144. swap %d3
  145. cmp.w #-16,%d5
  146. bge.s .L__cs32_nonegX
  147. moveq #0,%d3
  148. cmp.w #-32,%d5
  149. bgt.s .L__cs32_nonegX
  150. .L__cs32_rts:
  151. movem.l (%a7)+,%d3-%d7
  152. rts
  153. .L__cs32_nonegX:
  154. cmp.w #240-32,%d5
  155. ble.s .L__cs32_nooverX
  156. moveq #0,%d4
  157. cmp.w #240-16,%d5
  158. blt.s .L__cs32_nooverX
  159. clr.w %d3
  160. cmp.w #240,%d5
  161. bge.s .L__cs32_rts
  162. .L__cs32_nooverX:
  163. move.l %d3,%d6
  164. move.l %d4,%d7
  165. not.l %d6
  166. not.l %d7
  167. move.l %d6,.L__cs32_leftmaskdropoff+2
  168. move.w 4+5*4(%a7),%d5
  169. subq.w #2,%d5
  170. bne.s .L__cs32_notand
  171. move.l %d6,%d3
  172. move.l %d7,%d4
  173. .L__cs32_notand:
  174. lea -26(%a1),%a1
  175. .L__cs32_loop:
  176. subq.w #1,%d2
  177. blt.s .L__cs32_rts
  178. lea 26(%a1),%a1
  179. move.l (%a0)+,%d1
  180. ror.l %d0,%d1
  181. move.l %d1,%d6
  182. tst.w %d5
  183. beq.s .L__cs32_Am
  184. and.l %d3,%d1 |left side
  185. and.l %d4,%d6 |right side
  186. cmpi.w #-1,%d5
  187. beq.s .L__cs32_Om
  188. bgt.s .L__cs32_Rm
  189. |XOR
  190. eor.l %d1,(%a1)+
  191. eor.l %d6,(%a1)
  192. bra.s .L__cs32_loop
  193. .L__cs32_Rm: |RPLC
  194. .L__cs32_leftmaskdropoff:
  195. and.l #0xDEED,(%a1)
  196. or.l %d1,(%a1)+
  197. and.l %d7,(%a1)
  198. or.l %d6,(%a1)
  199. bra.s .L__cs32_loop
  200. .L__cs32_Om: |OR
  201. or.l %d1,(%a1)+
  202. or.l %d6,(%a1)
  203. bra.s .L__cs32_loop
  204. .L__cs32_Am: |AND
  205. or.l %d3,%d1 |left side
  206. or.l %d4,%d6 |right side
  207. and.l %d1,(%a1)+
  208. and.l %d6,(%a1)
  209. bra.s .L__cs32_loop
  210. */