play_anim.s 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. ; include nfa.i
  2. *****************************************************************************
  3. _play_anim ; a4-> animation buffer ,a5->loop back point, d0 = 'INIT' to start anim
  4. cmp.l #'INIT',d0
  5. bne.s .not_init
  6. move.l (a4)+,a5 frames, noloop
  7. bsr.s _first_frame
  8. move.l #'FRM2',d0
  9. rts
  10. .not_init
  11. cmp.l #'FRM2',d0
  12. bne.s .not_frame2
  13. bsr _d2w
  14. bsr _next_frame
  15. move.l a5,d0
  16. tst.w d0
  17. beq.s .loop
  18. .noloop
  19. sub.l a5,a5
  20. clr.w d0
  21. swap d0
  22. rts
  23. .loop
  24. move.l a4,a5 loop back point
  25. move.l d0,d1
  26. swap d1
  27. move.w d1,d0 loop count in d0 twice
  28. rts
  29. .not_frame2
  30. cmp.l #'STOP',d0
  31. bne.s .normal_frame
  32. rts
  33. .normal_frame
  34. move.l d0,-(sp) i have actually got to use the stack!
  35. bsr _next_frame
  36. move.l (sp)+,d0
  37. subq.w #1,d0
  38. cmp.w #1,d0
  39. bne.s .end
  40. swap d0
  41. tst.w d0 does it loop?
  42. bne.s .isloop
  43. move.l #'STOP',d0
  44. ; bsr _d2w
  45. rts
  46. .isloop
  47. move.w d0,d1
  48. swap d0
  49. move.w d1,d0
  50. move.l a5,a4
  51. .end
  52. rts
  53. *****************************************************************************
  54. _first_frame
  55. bsr _use_anim_pal
  56. move.l _w_screen,a0
  57. moveq #256-(A_SCREEN_HEIGHT-1),d7
  58. neg.b d7
  59. .lineloop
  60. moveq #A_PLANES-1,d5
  61. .planeloop
  62. moveq #A_SCREEN_WIDTH,d6
  63. .another_groinal_overlay
  64. moveq #0,d0
  65. move.b (a4)+,d0
  66. bmi.s .byte_run
  67. .normal_data
  68. sub.w d0,d6 count down
  69. subq.w #1,d6
  70. .ndloop
  71. move.b (a4)+,(a0)+
  72. dbra d0,.ndloop
  73. tst.w d6
  74. beq.s .plane_done
  75. bra.s .another_groinal_overlay
  76. .byte_run
  77. neg.b d0
  78. sub.w d0,d6
  79. subq.w #1,d6
  80. move.b (a4)+,d1
  81. .brloop
  82. move.b d1,(a0)+
  83. dbra d0,.brloop
  84. tst.w d6
  85. bne.s .another_groinal_overlay
  86. .plane_done
  87. lea A_SCREEN_WIDTH*(A_SCREEN_HEIGHT-1)(a0),a0
  88. dbra d5,.planeloop
  89. adda.l #A_SCREEN_WIDTH-A_PLANES*A_SCREEN_WIDTH*A_SCREEN_HEIGHT,a0
  90. dbra d7,.lineloop
  91. rts
  92. *****************************************************************************
  93. _d2w
  94. move.w #A_SCREEN_WIDTH*A_SCREEN_HEIGHT*A_PLANES/4-1,d1
  95. move.l _d_screen,a0
  96. move.l _w_screen,a1
  97. .cloop
  98. move.l (a0)+,(a1)+
  99. dbra d1,.cloop
  100. rts
  101. *****************************************************************************
  102. _use_anim_pal ; a4-> palette
  103. move.l _copper_list,a1
  104. move.l _copper_list+4,a2
  105. move.w #$180,d0
  106. .a1loop
  107. cmp.w (a1)+,d0
  108. bne.s .a1loop
  109. .a2loop
  110. cmp.w (a2)+,d0
  111. bne.s .a2loop
  112. moveq #1<<A_PLANES-1,d1
  113. .loop
  114. move.w (a4)+,d0
  115. move.w d0,(a1)
  116. move.w d0,(a2)
  117. addq.l #4,a1
  118. addq.l #4,a2
  119. dbra d1,.loop
  120. rts
  121. *****************************************************************************
  122. _next_frame
  123. move.l _w_screen,a0
  124. moveq #A_SCREEN_WIDTH,d2 for moving down a line
  125. moveq #A_PLANES-1,d7
  126. .ploop
  127. cmpi.b #-1,(A4)
  128. bne.s .this_plane_used
  129. addq.l #1,a4
  130. bra.s .no_plane
  131. .this_plane_used
  132. moveq #A_SCREEN_WIDTH-1,d6
  133. .xloop
  134. move.l a0,a3 screen pointer for this column
  135. moveq #0,d5
  136. move.b (a4)+,d5
  137. beq.s .next_column
  138. subq.w #1,d5
  139. .yloop
  140. moveq #0,d0
  141. move.b (a4)+,d0
  142. bgt.s .skip_ops
  143. beq.s .same_ops
  144. .unique_ops
  145. andi.w #%1111111,d0
  146. subq.w #1,d0
  147. .unique_loop
  148. move.b (a4)+,(a3)
  149. adda.w d2,a3
  150. dbra d0,.unique_loop
  151. dbra d5,.yloop
  152. bra.s .next_column
  153. .same_ops
  154. moveq #0,d4
  155. move.b (a4)+,d4
  156. subq.w #1,d4
  157. move.b (a4)+,d3
  158. .sameloop
  159. move.b d3,(a3)
  160. adda.w d2,a3 move down a line
  161. dbra d4,.sameloop
  162. dbra d5,.yloop
  163. bra.s .next_column
  164. .skip_ops
  165. add.w d0,d0 for lookup
  166. adda.w .offsets(pc,d0.w),a3 skip
  167. dbra d5,.yloop
  168. .next_column
  169. addq.l #1,a0
  170. dbra d6,.xloop
  171. .next_plane
  172. lea A_SCREEN_WIDTH*(A_SCREEN_HEIGHT-1)(a0),a0
  173. dbra d7,.ploop
  174. rts
  175. .no_plane
  176. lea A_SCREEN_WIDTH*A_SCREEN_HEIGHT(a0),a0
  177. dbra d7,.ploop
  178. rts
  179. .offsets
  180. dct set 0
  181. rept A_SCREEN_HEIGHT
  182. dc.w dct
  183. dct set dct+A_SCREEN_WIDTH
  184. endr
  185. *****************************************************************************