Advertisement
vladikcomper

Sonic Winter Adventures - Boss Code Sample

Jun 3rd, 2012
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ===============================================================
  2. ; GHZ MidBoss Object
  3. ; ===============================================================
  4.  
  5. Xpos = 8
  6. Ypos = $C
  7.  
  8. ; ---------------------------------------------------------------
  9.  
  10. Obj_GHZ_MidBoss:
  11.     move.b  #4,render(a0)
  12.     move.w  #$43AA,art(a0)
  13.     move.l  #???,maps(a0)   ; use ??? mappings
  14.     move.b  #$20,visible_width(a0)
  15.     move.b  #$16,height(a0)
  16.     move.l  #GHZ_MidBoss_Idle,obj(a0)
  17.  
  18. ; ===============================================================
  19. ; ---------------------------------------------------------------
  20. ; The ??? sits still waiting while Sonic passes it
  21. ; ---------------------------------------------------------------
  22.  
  23. GHZ_MidBoss_Idle:
  24.     cmpi.b  #4,LvlEventsRoutine
  25.     beq.s   GHZ_MidBoss_ToBounceSequence
  26.  
  27.     ; Make idle ??? solid
  28.     moveq   #$1C,d1
  29.     moveq   #$16,d2
  30.     moveq   #$19,d3
  31.     move.w  Xpos(a0),d4
  32.     jsr SolidObject
  33.  
  34. ; ===============================================================
  35. ; ---------------------------------------------------------------
  36. ; Subroutine to display the ??? and apply rolling
  37. ; ---------------------------------------------------------------
  38.  
  39. rotframe = $26      ; .w    Rotation frame ($100..$3FF)
  40. rotspeed = $28      ; .w    Rotation speed
  41.  
  42. GHZ_MidBoss_RotDisplay:
  43.  
  44.     ; apply rotation speed
  45.     move.w  rotspeed(a0),d0
  46.     add.w   d0,rotframe(a0)
  47.  
  48.     ; make sure the frame is within 1..3 range
  49.     move.b  rotframe(a0),d0
  50.     andi.b  #%11,d0
  51.     bne.s   @0
  52.     moveq   #1,d0
  53. @0  move.b  d0,rotframe(a0)
  54.  
  55.     ; display a frame
  56.     btst.b  #0,LevelTimer+1 ; even = 'rotframe'
  57.     beq.s   @1      ;  odd = $00
  58.     moveq   #0,d0
  59. @1  move.b  d0,frame(a0)
  60.     jmp DisplaySprite
  61.  
  62. ; ---------------------------------------------------------------
  63. ; Subroutine to stop the ??? rolling
  64. ; ---------------------------------------------------------------
  65.  
  66. GHZ_MidBoss_StopRotate:
  67.     cmpi.b  #1,rotframe(a0)
  68.     bne.s   @Quit
  69.     clr.w   rotspeed(a0)
  70. @Quit   rts
  71.  
  72. ; ===============================================================
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. ; ===============================================================
  86. ; ---------------------------------------------------------------
  87. ; The ??? bounces through the boss arena
  88. ; ---------------------------------------------------------------
  89.  
  90. ; For bouncing sequence
  91. CamBaseX = $2600
  92. CamBaseY = $300
  93.  
  94. bouncespeed = $14
  95.  
  96. GHZ_MidBoss_ToBounceSequence:
  97.     move.l  #GHZ_MidBoss_BounceSequence,obj(a0)
  98.  
  99. GHZ_MidBoss_BounceSequence:
  100.     ; Scroll Camera
  101.     move.w  CamXpos,d1      ; d1 = CamXPos
  102.     cmpi.w  #CamBaseX+$300,d1   ; camera stops at this point
  103.     beq.s   @Bounce_ToChkBoundary   ; and objects goes to new routine...
  104.     addq.w  #1,CamRightBound    ; scroll camera right
  105.     cmpi.w  #CamBaseX+$40,d1
  106.     beq.s   @Setup???  
  107.     bhi.s   @Bounce_Process
  108.     rts
  109.  
  110. ; ---------------------------------------------------------------
  111. @Setup???:
  112.     ; Setup bouncing ???
  113.     move.b  #$81,touch(a0)      ; it hurts
  114.     move.w  #CamBaseX,Xpos(a0)
  115.     move.w  #CamBaseY+$40,Ypos(a0)
  116.     move.w  #$170,XVel(a0)
  117.     move.w  #$40,rotspeed(a0)
  118.     move.w  #-$7C0,bouncespeed(a0)
  119.     bra.s   @Bounce_Process
  120.  
  121. ; ---------------------------------------------------------------
  122. @Bounce_ToChkBoundary:
  123.     move.l  #@Bounce_ChkBoundary,obj(a0)
  124.  
  125. @Bounce_ChkBoundary:
  126.     ; Check if ??? reached it's destination place
  127.     cmpi.w  #CamBaseX+$440-$28,Xpos(a0) ; has the ??? reached stop point?
  128.     bcs.s   @Bounce_Process         ; not yet...
  129.     clr.w   Xvel(a0)            ; stop the ???
  130.     move.l  #@Bounce_StopRotate,obj(a0)
  131.    
  132. @Bounce_StopRotate:
  133.     bsr GHZ_MidBoss_StopRotate
  134.  
  135. @Bounce_Process:
  136.     ; Make ??? fall
  137.     jsr ObjectFall
  138.  
  139.     ; Check if the ??? collided with the floor
  140.     jsr ObjHitFloor
  141.     tst.w   d1
  142.     bpl GHZ_MidBoss_RotDisplay
  143.     add.w   d1,Ypos(a0)
  144.     moveq   #$FFFFFFBD,d0
  145.     jsr PlaySound_Special
  146.  
  147.     ; Check if the ??? should stop (bounce weaker and weaker)
  148.     move.w  bouncespeed(a0),d0  ; d0 = BounceSpeed
  149.     tst.w   Xvel(a0)
  150.     bne.s   @1          ; not yet...
  151.     move.w  d0,d1
  152.     asr.w   #2,d1           ; d1 = BounceSpeed / 4
  153.     sub.w   d1,d0
  154.     move.w  d0,bouncespeed(a0)  ; save new BounceSpeed
  155.     cmpi.w  #-$200,d0       ; is speed too fucking small?
  156.     bge.s   GHZ_MidBoss_ToIntro ; yes, we're done!
  157.  
  158. @1  move.w  d0,Yvel(a0)
  159.     bra GHZ_MidBoss_RotDisplay
  160.  
  161.  
  162. ; ===============================================================
  163. ; ---------------------------------------------------------------
  164. ; Boss battle beings!
  165. ; ---------------------------------------------------------------
  166.  
  167. timer = $38 ; .w
  168.  
  169. GHZ_MidBoss_ToIntro:
  170.     moveq   #$FFFFFFE0,d0       ; Fade out music
  171.     jsr PlaySound_Special
  172.     move.w  #3*60,timer(a0)     ; Setup timer
  173.     move.l  #GHZ_MidBoss_Intro,obj(a0)
  174.  
  175. GHZ_MidBoss_Intro:                                  
  176.     jsr ObjectTimer
  177.     bne GHZ_MidBoss_RotDisplay  ; no timer
  178.     moveq   #$FFFFFF9C,d0       ; Play boss music
  179.     jsr PlaySound
  180.     move.l  #GHZ_MidBoss_RotDisplay,obj(a0)
  181.     bra GHZ_MidBoss_RotDisplay
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement