Guest User

Untitled

a guest
Feb 15th, 2009
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ---------------------------------------------------------------------------
  2. ; Object 60 - Orbinaut enemy (LZ, SLZ, SBZ)
  3. ; ---------------------------------------------------------------------------
  4.  
  5. Obj60: ; XREF: Obj_Index
  6. moveq #0,d0
  7. move.b $24(a0),d0
  8. move.w Obj60_Index(pc,d0.w),d1
  9. jmp Obj60_Index(pc,d1.w)
  10. ; ===========================================================================
  11. Obj60_Index: dc.w Obj60_Main-Obj60_Index
  12. dc.w Obj60_ChkSonic-Obj60_Index
  13. dc.w Obj60_Display-Obj60_Index
  14. dc.w Obj60_MoveOrb-Obj60_Index
  15. dc.w Obj60_ChkDel2-Obj60_Index
  16. ; ===========================================================================
  17.  
  18. Obj60_Main: ; XREF: Obj60_Index
  19. move.l #Map_obj60,4(a0) ; mappings
  20. move.w #$429,2(a0) ; SBZ specific code art and palette (sonic's palette)
  21. cmpi.b #5,($FFFFFE10).w ; check if level is SBZ
  22. beq.s loc_11D02 ; if it isn't, branch
  23. move.w #$2429,2(a0) ; SLZ specific code
  24.  
  25. loc_11D02:
  26. cmpi.b #1,($FFFFFE10).w ; check if level is LZ
  27. bne.s loc_11D10 ; if not, branch
  28. move.w #$467,2(a0) ; LZ specific code
  29.  
  30. loc_11D10:
  31. ori.b #4,1(a0) ; use playfield coordinates
  32. move.b #4,$18(a0) ; sprite priority
  33. move.b #$B,$20(a0) ; collision
  34. move.b #$C,$19(a0) ; width in pixels
  35. moveq #0,d2 ; clear d2
  36. lea $37(a0),a2 ; load an address in a2
  37. movea.l a2,a3 ; copy it into a3
  38. addq.w #1,a2 ; add 1 to the address in a2
  39. moveq #3,d1 ; set number of orbs to create (it happens once then does it 3 more times)
  40.  
  41. Obj60_MakeOrbs:
  42. bsr.w SingleObjLoad2 ; load another object
  43. bne.s loc_11D90 ; if there is no free "space" (it failed), cancel ( use SingleObjLoad2 when you think that all the slots before the current object are occupied)
  44. addq.b #1,(a3) ; add 1 to a counter (used to tell how many objects are loaded to tell how many objects to delete)
  45. move.w a1,d5 ; move a1 to d5 (a1 is the address of the free object slot found by singleobjload2)
  46. subi.w #-$3000,d5 ; -$3000 = $D000, which is the start of the object RAM
  47. lsr.w #6,d5 ; dividing d5 by 1 lsh 6 ($40, also the size of all objects), getting the size of the object
  48. andi.w #$7F,d5 ; checks if everything is able to happen (isn't really needed)
  49. move.b d5,(a2)+ ; store index of spiked object
  50. move.b 0(a0),0(a1) ; load spiked orb object
  51. move.b #6,$24(a1) ; set routine counter for orbs (skip to Obj60_MoveOrb on the next frame)
  52. move.l 4(a0),4(a1) ; copy mappings
  53. move.w 2(a0),2(a1) ; copy palette and art location
  54. ori.b #4,1(a1) ; use playfield coordinates
  55. move.b #4,$18(a1) ; sprite priority
  56. move.b #8,$19(a1) ; width in pixels
  57. move.b #3,$1A(a1) ; animation frame
  58. move.b #$98,$20(a1) ; collision (harm)
  59. move.b d2,$26(a1) ; angle
  60. addi.b #$40,d2 ; add $40 to the angle (90 degrees)
  61. move.l a0,$3C(a1) ; stores the address of the parent object
  62. dbf d1,Obj60_MakeOrbs ; repeat sequence 3 more times
  63.  
  64. loc_11D90:
  65. moveq #1,d0 ; changes the way the orbs rotate (set to a higher number to make the orbs go faster)
  66. btst #0,$22(a0) ; test if going left, if not, change the way of the rotation
  67. beq.s Obj60_Move
  68. neg.w d0 ; switch to make it go right
  69.  
  70. Obj60_Move:
  71. move.b d0,$36(a0) ; set the speed at which the orbs rotate
  72. move.b $28(a0),$24(a0) ; if type is 02, skip the firing rountine
  73. addq.b #2,$24(a0) ; add 2 to routine counter
  74. move.w #-$40,$10(a0) ; move orbinaut to the left
  75. btst #0,$22(a0) ; is orbinaut reversed?
  76. beq.s locret_11DBC ; if not, branch
  77. neg.w $10(a0) ; move orbinaut to the right
  78.  
  79. locret_11DBC:
  80. rts
  81. ; ===========================================================================
  82.  
  83. Obj60_ChkSonic: ; XREF: Obj60_Index
  84. move.w ($FFFFD008).w,d0 ; put Sonic's X position in d0
  85. sub.w 8(a0),d0 ; subtract the orbinaut's X position
  86. bcc.s loc_11DCA ; if d0 is greater or equal to 0, branch
  87. neg.w d0 ; make d0 positive
  88.  
  89. loc_11DCA:
  90. cmpi.w #$A0,d0 ; is Sonic within $A0 pixels of orbinaut?
  91. bcc.s Obj60_Animate ; if not, branch
  92. move.w ($FFFFD00C).w,d0 ; put Sonic's Y position in d0
  93. sub.w $C(a0),d0 ; subtract the orbitnaut's Y position
  94. bcc.s loc_11DDC ; if d0 is greater or equal to 0, branch
  95. neg.w d0 ; if not, make it positive
  96.  
  97. loc_11DDC:
  98. cmpi.w #$50,d0 ; is Sonic within $50 pixels of orbinaut?
  99. bcc.s Obj60_Animate ; if not, branch
  100. tst.w ($FFFFFE08).w ; is debug mode on?
  101. bne.s Obj60_Animate ; if yes, branch
  102. move.b #1,$1C(a0) ; use "angry" animation
  103.  
  104. Obj60_Animate:
  105. lea (Ani_obj60).l,a1 ; load it's animation
  106. bsr.w AnimateSprite
  107. bra.w Obj60_ChkDel ; check if it should be deleted
  108. ; ===========================================================================
  109.  
  110. Obj60_Display: ; XREF: Obj60_Index
  111. bsr.w SpeedToPos ; makes the sprite catch up to where it should be (according to the code)
  112.  
  113. Obj60_ChkDel: ; XREF: Obj60_Animate
  114. move.w 8(a0),d0 ; move the orbinaut's X position into d0
  115. andi.w #$FF80,d0 ; $FF80 = %1111111110000000 (checks if it's offscreen)
  116. move.w ($FFFFF700).w,d1 ; put plane A x-position into d1
  117. subi.w #$80,d1 ; subtract $80 from d1
  118. andi.w #$FF80,d1 ; checks if offscreen
  119. sub.w d1,d0 ; subtract d1 from d0
  120. cmpi.w #$280,d0 ; compare d0 to $280
  121. bhi.w Obj60_ChkGone ; branch if greater than $280
  122. bra.w DisplaySprite ; display an object when a0 is the RAM
  123. ; ===========================================================================
  124.  
  125. Obj60_ChkGone: ; XREF: Obj60_ChkDel
  126. lea ($FFFFFC00).w,a2 ; respawn index
  127. moveq #0,d0 ; make d0 the value of #0
  128. move.b $23(a0),d0 ; gets the index
  129. beq.s loc_11E34 ; if 0, branch
  130. bclr #7,2(a2,d0.w) ; if d0 == 1, then it clears bit 7 at $FFFFFC03
  131.  
  132. loc_11E34:
  133. lea $37(a0),a2 ; puts $37(a0) into a2
  134. moveq #0,d2 ; clears d2
  135. move.b (a2)+,d2 ; puts the number of orbs loaded into d2
  136. subq.w #1,d2 ; subtracts 1 from d2 (to use with dvf)
  137. bcs.s Obj60_Delete ; if the value is negative, branch
  138.  
  139. loc_11E40:
  140. moveq #0,d0 ; clears d0
  141. move.b (a2)+,d0 ; get the index of the orb in the SST
  142. lsl.w #6,d0 ; multiply by $40
  143. addi.l #$FFD000,d0 ; add the start of the SST - now we have the address of the orb
  144. movea.l d0,a1 ; put that address in a1
  145. bsr.w DeleteObject2 ; delete the orb
  146. dbf d2,loc_11E40 ; process the next orb, if there's one
  147.  
  148. Obj60_Delete:
  149. bra.w DeleteObject ; delete the orbinaut now
  150. ; ===========================================================================
  151.  
  152. Obj60_MoveOrb: ; XREF: Obj60_Index
  153. movea.l $3C(a0),a1 ; get the parent orbinaut
  154. cmpi.b #$60,0(a1) ; is it still an orbinaut?
  155. bne.w DeleteObject ; if not, delete the orb
  156. cmpi.b #2,$1A(a1) ; does the orbinaut use the "angry" frame?
  157. bne.s Obj60_Circle ; if not, branch
  158. cmpi.b #$40,$26(a0) ; is the angle of the orb $40?
  159. bne.s Obj60_Circle ; if not, branch
  160. addq.b #2,$24(a0) ; increase routine counter
  161. subq.b #1,$37(a1) ; subtract 1 from the number of orbs around the orbinaut
  162. bne.s Obj60_FireOrb ; if there are orbs left, branch
  163. addq.b #2,$24(a1) ; increase the orbinaut's routine counter
  164.  
  165. Obj60_FireOrb:
  166. move.w #-$200,$10(a0) ; move orb to the left (quickly)
  167. btst #0,$22(a1) ; is the orbinaut facing left?
  168. beq.s Obj60_Display2 ; if yes, branch
  169. neg.w $10(a0) ; move orb to the right (quickly)
  170.  
  171. Obj60_Display2:
  172. bra.w DisplaySprite
  173. ; ===========================================================================
  174.  
  175. Obj60_Circle: ; XREF: Obj60_MoveOrb
  176. move.b $26(a0),d0 ; get the angle of the orb
  177. jsr (CalcSine).l ; get the sine and cosine
  178. asr.w #4,d1 ; multiply d1 by $10
  179. add.w 8(a1),d1 ; add the X position of the orbinaut
  180. move.w d1,8(a0) ; use that as the new X position
  181. asr.w #4,d0 ; multiply d0 by $10
  182. add.w $C(a1),d0 ; add the Y position of the orbinaut
  183. move.w d0,$C(a0) ; use that as the new Y position
  184. move.b $36(a1),d0 ; get the rotation speed
  185. add.b d0,$26(a0) ; add that to the angle
  186. bra.w DisplaySprite ; display the orb
  187. ; ===========================================================================
  188.  
  189. Obj60_ChkDel2: ; XREF: Obj60_Index
  190. bsr.w SpeedToPos ; move the object
  191. tst.b 1(a0) ; test the render flags
  192. bpl.w DeleteObject ; if the object is offscreen, delete it
  193. bra.w DisplaySprite ; if it isn't, display it
  194. ; ===========================================================================
  195. Ani_obj60:
  196. include "_anim\obj60.asm"
  197.  
  198. ; ---------------------------------------------------------------------------
  199. ; Sprite mappings - Orbinaut enemy (LZ, SLZ, SBZ)
  200. ; ---------------------------------------------------------------------------
  201. Map_obj60:
  202. include "_maps\obj60.asm"
RAW Paste Data