Advertisement
Guest User

object 67

a guest
Jul 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.57 KB | None | 0 0
  1. ; ---------------------------------------------------------------------------
  2. ; Object 67 - disc that you run around (SBZ)
  3. ; ---------------------------------------------------------------------------
  4.  
  5. RunningDisc:
  6. moveq #0,d0
  7. move.b routine(a0),d0
  8. move.w Disc_Index(pc,d0.w),d1
  9. jmp Disc_Index(pc,d1.w)
  10. ; ===========================================================================
  11. Disc_Index: dc.w Disc_Main-Disc_Index
  12. dc.w Disc_Action-Disc_Index
  13.  
  14. disc_origX: equ $32 ; original x-axis position
  15. disc_origY: equ $30 ; original y-axis position
  16. ; ===========================================================================
  17.  
  18. Disc_Main: ; Routine 0
  19. addq.b #2,routine(a0) ;set routine
  20. move.l #Map_Disc,mappings(a0) ;set mappings
  21. move.w #$C344,art_tile(a0) ;set arttile
  22. move.b #4,render_flags(a0) ;ensure object is visible as a level object
  23. move.b #4,priority(a0) ;set priority
  24. move.b #8,width_pixels(a0) ;set object width variable
  25. move.w x_pos(a0),disc_origX(a0) ;save our original x_pos
  26. move.w y_pos(a0),disc_origY(a0) ;save our original y_pos
  27. move.b #$18,$34(a0) ;save $18 into object ram $34 (only used for visual code)
  28. move.b #$48,$38(a0) ;save $48 into object ram $38. $38(a0) is likely our circle radius/diameter.
  29. move.b subtype(a0),d1 ; get object type
  30. andi.b #$F,d1 ; read only the 2nd digit
  31. beq.s RunningDisc_typeis0 ; branch if 0
  32. move.b #$10,$34(a0) ;set different values!!!
  33. move.b #$38,$38(a0) ;this code is entirely unused! Always uses subtype $40
  34.  
  35. RunningDisc_typeis0:
  36. move.b subtype(a0),d1 ; get subtype
  37. andi.b #$F0,d1 ; read only the 1st digit. First digit appears to set the rolling direction...
  38. ext.w d1 ;extend subtype byte to a word (d1 might be uncleared, doecs this clear it?)
  39. asl.w #3,d1 ;bit shift left by 3 (for subtype $40, that's 0000 0000 0100 0000 to 0000 0010 0000 0000 or $200)
  40. move.w d1,$36(a0) ;save d1 (probably $200) into unused object ram at $36-$37. It's used as a quick check for our orientation.
  41. move.b status(a0),d0 ;copy object status bit table to d0
  42. ror.b #2,d0 ;roll bit table to the right twice (6,7,0,1,2,3,4,5)
  43. andi.b #$C0,d0 ;cut out the upper two bits (1100 0000), removing tails push/S1unused and Object specific flags
  44. move.b d0,angle(a0) ;copy remaining flags to our angle? (likely just repurposed scratch ram?)
  45.  
  46. Disc_Action: ; Routine 2
  47. bsr.w Disc_MoveSonic ;likely run player movement code based on original position
  48. bsr.w Disc_MoveSpot ;visually move actual object position around and render
  49. bra.w Disc_ChkDel ;Sonic 1 version of MarkObjGone
  50. ; ===========================================================================
  51.  
  52. Disc_MoveSonic:
  53. moveq #0,d2 ;clear d2
  54. move.b $38(a0),d2 ;move byte from object ram into d2 (this is $48 normally)
  55. move.w d2,d3 ;copy d2 to d3 as a word (upper word of d3 is dirty)
  56. add.w d3,d3 ;multiply d3 by 2 (so $90 normally)
  57. lea (MainCharacter).w,a1 ;load player ram address
  58. move.w x_pos(a1),d0 ;copy players x_pos to d0
  59. sub.w disc_origX(a0),d0 ;subtract our original x_pos from players x_pos (so get distance from)
  60. add.w d2,d0 ;add d2 ($90) to distance. $38(a0) is likely our circle radius/diameter.
  61. cmp.w d3,d0 ;is d0 (distance between player and our collision box?) d3 (size of our collision box?)
  62. bcc.s loc_155A8_RunningDisc ;if d3 is higher then or equal to d0, branch (so if player is not in our hitbox on x axis?)
  63.  
  64. ;appears to be same as above, but for y axis
  65. move.w y_pos(a1),d1 ;copy player y pos into d1
  66. sub.w disc_origY(a0),d1 ;subtract our original y_pos from players y_pos (get distance from)
  67. add.w d2,d1 ;add circle size to distance
  68. cmp.w d3,d1 ;is circle diameter greater then or equal to distance + circle radius?
  69. bcc.s loc_155A8_RunningDisc ;if greater then or equal, branch
  70. btst #1,status(a1) ;check if player is in the air
  71. beq.s loc_155B8 ;if not in the air, branch
  72. clr.b $3A(a0) ;clear object ram byte $3A (idk what $3A is yet)
  73. rts ;return to main routine
  74. ; ===========================================================================
  75.  
  76. ;appears to be a fail safe case for when the player isn't on our circle
  77. ;likely deactives disc run flag.
  78. loc_155A8_RunningDisc:
  79. tst.b $3A(a0) ;is $3A(a0) 0? (should be thus far, nothing has set it)
  80. beq.s locret_155B6 ;if it is 0, rts
  81. clr.b $38(a1) ;clear byte $38 in players code (flag that make player stick to surfaces!)
  82. clr.b $3A(a0) ;clear $3A(a0) (still not sure what sets this, or what it's for)
  83.  
  84. locret_155B6:
  85. rts
  86. ; ===========================================================================
  87.  
  88. loc_155B8:
  89. tst.b $3A(a0) ;is $3A(a0) 0?
  90. bne.s loc_155E2 ;if non-zero, branch
  91.  
  92. ;this code appears to prevent rolling? Still not sure, but it only runs when $3A is set.
  93. move.b #1,$3A(a0) ;set $3A(a0)!
  94. btst #2,status(a1) ;check if player is jumping or rolling
  95. bne.s loc_155D0 ;if not, branch
  96. clr.b anim(a1) ;set players animation to 0 (walking. Can we not roll?)
  97.  
  98. ;this appears to be where the cool stuff happens
  99. loc_155D0:
  100. bclr #5,status(a1) ;clear player pushing something flag
  101. move.b #1,next_anim(a1) ;set next animation to 1 (running)
  102. move.b #1,$38(a1) ;set $38 to 1 in player ram (sets the stick to surfaces flag!)
  103.  
  104. ;This controls the players speed on the circle.
  105. ;functions exactly as intended, the weirdness is not down here.
  106. loc_155E2:
  107. move.w inertia(a1),d0 ;get players inertia
  108. tst.w $36(a0) ;is $36(a0) 0 (should be $200 initially)
  109. bpl.s loc_15608 ;if result is positive, branch (goes to a different set of speed checks)?
  110.  
  111. ;this code is dependant on the value in $36(a0)
  112. ;this force the players inertia to be between -$400 and -$F00
  113. ;it works as intended, no problems here.
  114. cmpi.w #-$400,d0 ;is player inertia -$400? (minimum speed player can have on roller)
  115. ble.s loc_155FA ;if less then or equal, branch
  116. move.w #-$400,inertia(a1) ;set players inertia to -$400
  117. rts
  118. ; ===========================================================================
  119.  
  120. loc_155FA:
  121. cmpi.w #-$F00,d0 ;is player inertia -$F00 (maximum speed player can have on roller)
  122. bge.s locret_15606 ;if -$F00 is greater or equal to player inertia rts
  123. move.w #-$F00,inertia(a1) ;set players speed to -$f00
  124.  
  125. locret_15606:
  126. rts
  127. ; ===========================================================================
  128. ;this code is dependant on the value in $36(a0)
  129. ;should be what runs "first time"
  130. ;This is the same as the other speed checks, but for the other direction
  131. ;is $36 a flag for our roller direction!?
  132. loc_15608:
  133. cmpi.w #$400,d0 ;is player inertia positive $400?
  134. bge.s loc_15616
  135. move.w #$400,inertia(a1)
  136. rts
  137. ; ===========================================================================
  138.  
  139. loc_15616:
  140. cmpi.w #$F00,d0
  141. ble.s locret_15622
  142. move.w #$F00,inertia(a1)
  143.  
  144. locret_15622:
  145. rts
  146. ; ===========================================================================
  147.  
  148. ;code to move actual visible spot I think
  149. ;likely not important for our cause, seems to work just fine.
  150. Disc_MoveSpot:
  151. move.w $36(a0),d0
  152. add.w d0,angle(a0)
  153. move.b angle(a0),d0
  154. jsr (CalcSine).l
  155. move.w disc_origY(a0),d2
  156. move.w disc_origX(a0),d3
  157. moveq #0,d4
  158. move.b $34(a0),d4
  159. lsl.w #8,d4
  160. move.l d4,d5
  161. muls.w d0,d4
  162. swap d4
  163. muls.w d1,d5
  164. swap d5
  165. add.w d2,d4
  166. add.w d3,d5
  167. move.w d4,y_pos(a0)
  168. move.w d5,x_pos(a0)
  169. rts
  170. ; ===========================================================================
  171.  
  172. Disc_ChkDel:
  173. ;out_of_range.s RunningDisc_delete,disc_origX(a0)
  174. jsr MarkObjGone
  175. jmp (DisplaySprite).l
  176.  
  177. RunningDisc_delete:
  178. jmp (DeleteObject).l
  179.  
  180.  
  181. Map_Disc: include "mappings\sprite\Running Disc.asm"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement