draw.s 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. ********************************************************************************
  2. * oo oo *
  3. * \( )/ Bullfrog Demo \( )/ *
  4. * ^ ^^ ^ Drawing ^ ^^ ^ *
  5. ********************************************************************************
  6. ;All draw routines in here please.
  7. _draw_all
  8. jsr _draw_blocks
  9. jsr _draw_collectables
  10. jsr _draw_bad_guys
  11. jsr _draw_score
  12. jsr _lives_left
  13. ; jsr _draw_logo
  14. move.w man_x,d0 ;x position
  15. asr.w #FOUR,d0 ;scale position
  16. move.w man_y,d1 ;y position
  17. asr.w #FOUR,d1 ;scale position
  18. move.w man_frame,d2 ;sprite to draw
  19. asr.w #FOUR,d2 ;slow down animation speed
  20. lea _man,a1 ;gfx data
  21. jsr _simple_draw
  22. rts
  23. ********************************************************************************
  24. _draw_blocks
  25. * Therefore a2 points at map data
  26. * d3,d4 is position inside map
  27. * d0,d1 is position on screen
  28. move.l map_pointer,a2 ;point a2 at the map data
  29. move.w #12-1,d4 ;number of lines -1.
  30. move.w #0,d0 ;start x
  31. move.w #0,d1 ;start y
  32. .loop_y
  33. move.w #20-1,d3 ;number of columns -1.
  34. .loop_x
  35. move.b (a2)+,d2 ;pick up first byte of data
  36. beq.s .next ;if zero dont draw anything
  37. sub.w #1,d2 ;subtract 1 to get correct block
  38. jsr _block_draw ;and draw it
  39. .next
  40. add.w #1,d0 ;increase x position
  41. dbra d3,.loop_x ;subtract 1 from columns and loop
  42. move.w #0,d0 ;move to left side
  43. add.w #1,d1 ;and increase y position
  44. dbra d4,.loop_y ;sub 1 from rows and loop
  45. rts
  46. ********************************************************************************
  47. ;very simple interface for tutorial
  48. ;d0,d1 x,y pos d2 sprite no and a1 points at data
  49. _simple_draw
  50. movem.l a0-a6/d0-d7,-(sp)
  51. mulu #240,d2
  52. adda.l d2,a1
  53. moveq.w #24,d2 ;sprite height
  54. move.l _w_screen,a0
  55. jsr _s16_draw ;d0=x,d1=y,d2=height,a0=screen,a1=data
  56. movem.l (sp)+,a0-a6/d0-d7
  57. rts
  58. ********************************************************************************
  59. ;very simple blockdraw routine.
  60. ;d0 = x/16, d1 = y/16, d2 = block,
  61. _block_draw
  62. movem.l a0-a6/d0-d7,-(sp) ;save all registers
  63. move.l _w_screen,a0 ;point at screen
  64. lea _blocks,a1 ;point at block data
  65. asl.w #TWO,d0 ;find x position on screen
  66. asl.w #SIXTEEN,d1 ;find y position on screen
  67. mulu #SCREEN_WIDTH,d1 ;move down that no. of lines
  68. adda.l d1,a0 ;point at y
  69. adda.l d0,a0 ;point at x
  70. mulu #128,d2 ;find start of block to draw
  71. adda.l d2,a1 ;and move to it.
  72. moveq.w #16-1,d2 ;sprite height
  73. .loop
  74. movem.w (a1)+,d3/d4/d5/d6 ;pick up all data
  75. move.w d3,d7
  76. or.w d4,d7
  77. or.w d5,d7
  78. or.w d6,d7
  79. not.w d7
  80. and.w d7,(a0)
  81. or.w d3,(a0) ;plane one
  82. and.w d7,PLANE_SIZE(a0)
  83. or.w d4,PLANE_SIZE(a0) ;plane two
  84. and.w d7,PLANE_SIZE*2(a0)
  85. or.w d5,PLANE_SIZE*2(a0) ;plane three
  86. and.w d7,PLANE_SIZE*2(a0)
  87. or.w d6,PLANE_SIZE*3(a0) ;plane four
  88. lea SCREEN_WIDTH(a0),a0 ;move to next line
  89. dbra d2,.loop ;loop around 16 times
  90. movem.l (sp)+,a0-a6/d0-d7 ;restore all registers
  91. rts
  92. ********************************************************************************
  93. _draw_collectables
  94. lea _objects,a2
  95. move.w #MAX_OBJECTS-1,d7
  96. .loop
  97. tst.w OBJ_ON(a2)
  98. beq.s .next
  99. movem.w OBJ_TO_DRAW(a2),d0/d1/d2
  100. move.l _w_screen,a0
  101. lea _collect,a1
  102. mulu #SCREEN_WIDTH,d1
  103. adda.w d1,a0
  104. asr.w #EIGHT,d0
  105. adda.w d0,a0
  106. mulu #128,d2
  107. adda.w d2,a1
  108. move.w #16-1,d0
  109. ; move.l _w_screen,a0
  110. ; lea _collect,a1
  111. .draw_loop
  112. movem.w (a1)+,d1/d2/d3/d4
  113. move.w d1,(a0)
  114. move.w d2,PLANE_SIZE(a0)
  115. move.w d3,PLANE_SIZE*2(a0)
  116. move.w d4,PLANE_SIZE*3(a0)
  117. lea SCREEN_WIDTH(a0),a0
  118. dbra d0,.draw_loop
  119. .next
  120. lea OBJ_SIZE(a2),a2
  121. dbra d7,.loop
  122. rts
  123. ********************************************************************************
  124. _draw_score
  125. lea _score_text,a0
  126. move.l #0,d0
  127. move.w score,d0
  128. ; ext.l d0
  129. move.w #5,d1
  130. adda.l #7,a0
  131. jsr _to_alpha
  132. move.w #1,d0
  133. move.w #192,d1
  134. lea _score_text,a2
  135. jsr _draw_font
  136. rts
  137. ********************************************************************************
  138. *pass x block, pixal perfect y, a2 points to text to print
  139. _draw_font
  140. mulu #SCREEN_WIDTH,d1
  141. .begin
  142. move.b (a2)+,d2 ;look at letter
  143. beq.s .finished
  144. cmp.b #32,d2
  145. beq.s .next
  146. ext.w d2
  147. sub.w #33,d2
  148. lea _font,a1
  149. asl.w #EIGHT,d2
  150. adda.w d2,a1
  151. move.l _w_screen,a0
  152. adda.w d1,a0
  153. adda.w d0,a0
  154. move.w #8-1,d3
  155. .draw_loop
  156. move.b (a1)+,(a0)
  157. lea SCREEN_WIDTH(a0),a0
  158. dbra d3,.draw_loop
  159. .next
  160. add.w #1,d0
  161. bra.s .begin
  162. .finished
  163. rts
  164. ********************************************************************************
  165. _draw_bad_guys
  166. lea _bad_guys,a0
  167. moveq.w #MAX_BADDIES,d3
  168. .loop
  169. tst.w BAD_ON(a0)
  170. beq.s .next
  171. movem.w BAD_TO_DRAW(a0),d0/d1/d2
  172. movem.l a0-a6/d0-d7,-(sp)
  173. lea _bad,a1
  174. mulu #160,d2
  175. adda.l d2,a1
  176. moveq.w #16,d2 ;sprite height
  177. move.l _w_screen,a0
  178. jsr _s16_draw ;d0=x,d1=y,d2=height,a0=screen,a1=data
  179. movem.l (sp)+,a0-a6/d0-d7
  180. .next
  181. lea BAD_SIZE(a0),a0
  182. dbra d3,.loop
  183. rts
  184. ********************************************************************************
  185. _lives_left
  186. move.w #272,d0 ;x position
  187. move.w #176,d1 ;y position
  188. move.w #MAN_STATIONARY,d2 ;sprite to draw
  189. asr.w #FOUR,d2
  190. lea _man,a1 ;gfx data
  191. move.w #1,d3
  192. sub.w game_over,d3
  193. blt.s .nothing_to_draw
  194. .loop
  195. jsr _simple_draw
  196. add.w #16,d0
  197. dbra d3,.loop
  198. .nothing_to_draw
  199. rts
  200. ********************************************************************************