player_routines.s 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. *************************************
  8. ****** UPDATE PLAYER *****
  9. *************************************
  10. update_player
  11. moveq #0,d0
  12. moveq #0,d1
  13. moveq #0,d2
  14. move.w maximum_velocity,d4
  15. move.w player_x_scaled,d0
  16. move.w player_y_scaled,d1
  17. move.w player_x_velocity,d2
  18. tst xdirec
  19. beq.s reduce_velocity
  20. tst xdirec
  21. bmi.s player_moving_left
  22. add.w #INCREASE_VELOCITY,d2
  23. cmp.w d4,d2
  24. ble.s update_x_pos
  25. move.w d4,d2
  26. bra.s update_x_pos
  27. player_moving_left
  28. sub.w #INCREASE_VELOCITY,d2
  29. neg.w d4
  30. cmp.w d4,d2
  31. bge.s update_x_pos
  32. move.w d4,d2
  33. bra.s update_x_pos
  34. reduce_velocity
  35. tst d2
  36. bpl.s reduce_by_sub
  37. add.w #DECREASE_VELOCITY,d2
  38. ble.s update_x_pos
  39. move.w #0,d2
  40. bra.s update_x_pos
  41. reduce_by_sub
  42. sub.w #DECREASE_VELOCITY,d2
  43. bge.s update_x_pos
  44. move.w #0,d2
  45. update_x_pos
  46. move.w d2,player_x_velocity
  47. add.w d2,d0
  48. move.w d0,player_x_scaled
  49. move.w d1,player_y_scaled
  50. divu #SCALE_FACTOR,d0
  51. move.w d0,player_x
  52. divu #SCALE_FACTOR,d1
  53. move.w d1,player_y
  54. rts
  55. *************************************
  56. ****** DISPLAY PLAYER *****
  57. *************************************
  58. display_player
  59. ***depeding on speed of player move legs
  60. moveq #0,d4
  61. move.w player_x_velocity,d4
  62. tst d4
  63. bpl.s ok_x_vel
  64. neg.w d4
  65. ok_x_vel
  66. divu #SCALE_FACTOR,d4
  67. move.w #7,d6
  68. sub.w d4,d6
  69. move.w player_frame,d5
  70. addq.w #1,player_timer
  71. cmp.w player_timer,d6
  72. bgt.s no_frame_update
  73. move.w #0,player_timer
  74. tst player_x_velocity
  75. beq.s frame_reset
  76. addq.w #1,d5
  77. cmp.w #PLAYER_FRAMES,d5
  78. blt.s no_frame_update
  79. frame_reset
  80. move.w #0,d5
  81. no_frame_update
  82. move.w d5,player_frame
  83. mulu #22*4*2,d5
  84. tst.w xdirec
  85. bne.s not_zeroed
  86. move.w lastx_direc,d0
  87. bra.s get_direction_graphics
  88. not_zeroed
  89. move.w xdirec,d0
  90. move.w d0,lastx_direc
  91. get_direction_graphics
  92. tst d0
  93. bmi.s player_going_left
  94. move.l #playerrightf1sp1,a0
  95. bra.s position_player
  96. player_going_left
  97. move.l #playerleftf1sp1,a0
  98. position_player
  99. add.l d5,a0
  100. move.w player_x,d0
  101. move.w player_y,d1
  102. move.w #PLAYER_HEIGHT,d2
  103. move.w d0,d3
  104. move.w d1,d4
  105. bsr position_any_sprite
  106. bset.b #ATTACH,3(a0)
  107. move.l a0,d0
  108. move.w d0,sprite0l
  109. swap d0
  110. move.w d0,sprite0h
  111. add.l #22*4,a0
  112. move.w d3,d0
  113. move.w d4,d1
  114. bsr position_any_sprite
  115. bset.b #ATTACH,3(a0)
  116. move.l a0,d0
  117. move.w d0,sprite1l
  118. swap d0
  119. move.w d0,sprite1h
  120. rts
  121. SCALE_FACTOR EQU 50
  122. player_x_scaled dc.w 0
  123. player_y_scaled dc.w 5000
  124. player_x dc.w 0
  125. player_y dc.w 0
  126. player_timer dc.w 0
  127. player_x_velocity dc.w 0
  128. player_y_velocity dc.w 0
  129. lastx_direc dc.w 1
  130. lasty_direc dc.w 0
  131. player_frame dc.w 0
  132. maximum_velocity dc.w 2*SCALE_FACTOR
  133. player_velocity_table
  134. *************************************
  135. ****** POSITION ANY SPRITE *****
  136. *************************************
  137. position_any_sprite
  138. *send in data in a0
  139. *x in d0
  140. *y in d1
  141. *height in d2
  142. gendo_other_mouse_stuff
  143. add.w #$81-1,d0 ;tricky positioning
  144. move.b #0,3(A0)
  145. asr.w #1,d0
  146. bcc.s genno_bit_set
  147. bset #0,3(a0)
  148. genno_bit_set
  149. move.b d0,1(a0)
  150. add.w #$2c,d1
  151. btst #8,d1
  152. beq.s gennot_vert_set
  153. bset #2,3(a0)
  154. gennot_vert_set
  155. move.b d1,(a0)
  156. add.w d2,d1
  157. btst #8,d1
  158. beq.s gennot_vstop_set
  159. bset #1,3(a0)
  160. gennot_vstop_set
  161. move.b d1,2(a0)
  162. rts