player_routines1.s 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. ****player specifics
  2. PLAYER_FRAMES EQU 2
  3. PLAYER_HEIGHT EQU 20
  4. ATTACH EQU 7
  5. INCREASE_VELOCITY EQU 15
  6. DECREASE_VELOCITY EQU 5
  7. PLAYER_DROP_VELOCITY EQU 15
  8. *************************************
  9. ****** UPDATE PLAYER *****
  10. *************************************
  11. update_player
  12. moveq #0,d0
  13. moveq #0,d1
  14. moveq #0,d2
  15. move.w maximum_velocity,d4
  16. move.w player_x_scaled,d0
  17. move.w player_y_scaled,d1
  18. move.w player_x_velocity,d2
  19. tst xdirec
  20. beq.s reduce_velocity
  21. tst xdirec
  22. bmi.s player_moving_left
  23. move.w #INCREASE_VELOCITY,d5
  24. tst d2
  25. bpl.s no_skid_right
  26. subq.w #5,d5
  27. no_skid_right
  28. add.w d5,d2
  29. cmp.w d4,d2
  30. ble.s update_x_pos
  31. move.w d4,d2
  32. bra.s update_x_pos
  33. player_moving_left
  34. move.w #INCREASE_VELOCITY,d5
  35. tst.w d2
  36. bmi.s no_skid_left
  37. subq.w #5,d5
  38. no_skid_left
  39. sub.w d5,d2
  40. neg.w d4
  41. cmp.w d4,d2
  42. bge.s update_x_pos
  43. move.w d4,d2
  44. bra.s update_x_pos
  45. reduce_velocity
  46. tst d2
  47. bpl.s reduce_by_sub
  48. add.w #DECREASE_VELOCITY,d2
  49. ble.s update_x_pos
  50. move.w #0,d2
  51. bra.s update_x_pos
  52. reduce_by_sub
  53. sub.w #DECREASE_VELOCITY,d2
  54. bge.s update_x_pos
  55. move.w #0,d2
  56. update_x_pos
  57. move.w d2,player_x_velocity
  58. add.w d2,d0
  59. move.w d0,player_x_scaled
  60. ***and now jump
  61. tst player_falling_flag
  62. bne player_falling
  63. tst start_jump
  64. bne.s doing_jump
  65. ****player not jumped yet
  66. tst.w fire
  67. bne do_jump_code
  68. tst player_landed
  69. beq done_jump
  70. move.w #0,player_landed
  71. bra done_jump
  72. do_jump_code
  73. tst player_landed
  74. bne done_jump
  75. move.w #0,player_falling_flag
  76. move.w #1,start_jump
  77. move.w #250,player_jump_velocity
  78. move.w #10,jump_decay
  79. move.w #6,default_jump
  80. move.w #0,player_fall_velocity
  81. bra.s player_still_holding_fire
  82. doing_jump
  83. tst fire
  84. bne.s player_still_holding_fire
  85. move.w #30,jump_decay
  86. tst default_jump
  87. bne.s player_still_holding_fire
  88. tst player_jump_velocity
  89. bpl.s player_still_holding_fire
  90. move.w #1,player_falling_flag
  91. bra.s player_falling
  92. player_still_holding_fire
  93. tst default_jump
  94. beq.s reached_min
  95. subq.w #1,default_jump
  96. reached_min
  97. move.w player_jump_velocity,d7
  98. sub.w d7,d1
  99. sub.w jump_decay,d7
  100. move.w d7,player_jump_velocity
  101. bgt.s have_not_reached_end_of_velocitys
  102. move.w #1,player_falling_flag
  103. have_not_reached_end_of_velocitys
  104. bra.s done_jump
  105. *** follwing will need to be called constantly
  106. *** but with extra info about blocks
  107. player_falling
  108. add.w #PLAYER_DROP_VELOCITY,player_fall_velocity
  109. cmp.w #6*SCALE_FACTOR,player_fall_velocity
  110. ble.s within_range
  111. move.w #6*SCALE_FACTOR,player_fall_velocity
  112. within_range
  113. add.w player_fall_velocity,d1
  114. cmp.w #128*SCALE_FACTOR,d1
  115. blt.s done_jump
  116. move.w #128*SCALE_FACTOR,d1
  117. move.w #0,start_jump
  118. move.w #0,player_falling_flag
  119. move.w #1,player_landed
  120. done_jump
  121. move.w d1,player_y_scaled
  122. divu #SCALE_FACTOR,d0
  123. move.w d0,player_x
  124. divu #SCALE_FACTOR,d1
  125. move.w d1,player_y
  126. move.w #$0f0,$dff180
  127. rts
  128. *************************************
  129. ****** DISPLAY PLAYER *****
  130. *************************************
  131. display_player
  132. ***depeding on speed of player move legs
  133. moveq #0,d4
  134. move.w player_x_velocity,d4
  135. tst d4
  136. bpl.s ok_x_vel
  137. neg.w d4
  138. ok_x_vel
  139. divu #SCALE_FACTOR,d4
  140. move.w #7,d6
  141. sub.w d4,d6
  142. move.w player_frame,d5
  143. addq.w #1,player_timer
  144. cmp.w player_timer,d6
  145. bgt.s no_frame_update
  146. move.w #0,player_timer
  147. tst player_x_velocity
  148. beq.s frame_reset
  149. addq.w #1,d5
  150. cmp.w #PLAYER_FRAMES,d5
  151. blt.s no_frame_update
  152. frame_reset
  153. move.w #0,d5
  154. no_frame_update
  155. move.w d5,player_frame
  156. mulu #22*4*2,d5
  157. tst.w xdirec
  158. bne.s not_zeroed
  159. move.w lastx_direc,d0
  160. bra.s get_direction_graphics
  161. not_zeroed
  162. move.w xdirec,d0
  163. move.w d0,lastx_direc
  164. get_direction_graphics
  165. tst d0
  166. bmi.s player_going_left
  167. move.l #playerrightf1sp1,a0
  168. bra.s position_player
  169. player_going_left
  170. move.l #playerleftf1sp1,a0
  171. position_player
  172. add.l d5,a0
  173. move.w player_x,d0
  174. move.w player_y,d1
  175. move.w #PLAYER_HEIGHT,d2
  176. move.w d0,d3
  177. move.w d1,d4
  178. bsr position_any_sprite
  179. bset.b #ATTACH,3(a0)
  180. move.l a0,d0
  181. move.w d0,sprite0l
  182. swap d0
  183. move.w d0,sprite0h
  184. add.l #22*4,a0
  185. move.w d3,d0
  186. move.w d4,d1
  187. bsr position_any_sprite
  188. bset.b #ATTACH,3(a0)
  189. move.l a0,d0
  190. move.w d0,sprite1l
  191. swap d0
  192. move.w d0,sprite1h
  193. rts
  194. SCALE_FACTOR EQU 50
  195. player_x_scaled dc.w 0
  196. player_y_scaled dc.w 128*SCALE_FACTOR
  197. player_x dc.w 0
  198. player_y dc.w 0
  199. player_fall_velocity dc.w 0
  200. default_jump dc.w 4
  201. player_falling_flag dc.w 0
  202. start_jump dc.w 0
  203. player_timer dc.w 0
  204. player_landed dc.w 0
  205. player_x_velocity dc.w 0
  206. player_y_velocity dc.w 0
  207. lastx_direc dc.w 1
  208. lasty_direc dc.w 0
  209. player_frame dc.w 0
  210. player_jump_velocity
  211. dc.w 300
  212. jump_decay
  213. dc.w 0
  214. maximum_velocity dc.w 2*SCALE_FACTOR
  215. jump_no_more
  216. dc.w 0
  217. *************************************
  218. ****** POSITION ANY SPRITE *****
  219. *************************************
  220. position_any_sprite
  221. *send in data in a0
  222. *x in d0
  223. *y in d1
  224. *height in d2
  225. gendo_other_mouse_stuff
  226. add.w #$81-1,d0 ;tricky positioning
  227. move.b #0,3(A0)
  228. asr.w #1,d0
  229. bcc.s genno_bit_set
  230. bset #0,3(a0)
  231. genno_bit_set
  232. move.b d0,1(a0)
  233. add.w #$2c,d1
  234. btst #8,d1
  235. beq.s gennot_vert_set
  236. bset #2,3(a0)
  237. gennot_vert_set
  238. move.b d1,(a0)
  239. add.w d2,d1
  240. btst #8,d1
  241. beq.s gennot_vstop_set
  242. bset #1,3(a0)
  243. gennot_vstop_set
  244. move.b d1,2(a0)
  245. rts