Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ===========================================================================
- ; ---------------------------------------------------------------------------
- ; Object 86 - energy balls (FZ)
- ; ---------------------------------------------------------------------------
- Obj86: ; XREF: Obj_Index
- moveq #0,d0
- move.b $24(a0),d0
- move.w Obj86_Index(pc,d0.w),d0
- jmp Obj86_Index(pc,d0.w)
- ; ===========================================================================
- Obj86_Index: dc.w Obj86_Main-Obj86_Index ; $00
- dc.w Obj86_Generator-Obj86_Index ; $02
- dc.w Obj86_MakeBalls-Obj86_Index ; $04
- dc.w Obj86_WaitBalls-Obj86_Index ; $06
- dc.w Obj86_EnergyBall-Obj86_Index ; $08
- ; ===========================================================================
- Obj86_Main: ; XREF: Obj86_Index
- move.w #$2588,8(a0)
- move.w #$53C,$C(a0)
- move.w #$300,2(a0)
- move.l #Map_obj86,4(a0)
- move.b #0,$1C(a0)
- move.b #3,$18(a0)
- move.b #8,$17(a0)
- move.b #8,$16(a0)
- move.b #4,1(a0)
- bset #7,1(a0)
- addq.b #2,$24(a0) ; => "Obj86_Generator"
- ; ===========================================================================
- Obj86_Generator: ; XREF: Obj86_Index
- ; Check if generator should explode (when boss defeated)
- movea.l $34(a0),a1 ; load FZ boss object
- cmpi.b #6,$34(a1) ; is FZ boss at routine #6?
- bne.s @0 ; if not, branch
- move.b #$3F,(a0) ; replace generator with explosion
- move.b #0,$24(a0)
- jmp DisplaySprite
- ;loc_1A850:
- @0 move.b #0,$1C(a0) ; use animation #0
- tst.b $29(a0) ; create balls flag set?
- beq.s Obj86_ProcessGenerator ; if not, branch
- addq.b #2,$24(a0) ; => "Obj86_MakeBalls"
- move.b #1,$1C(a0) ; use animation #1
- move.b #$3E,$28(a0)
- ;loc_1A86C:
- Obj86_ProcessGenerator:
- ; Make generator solid
- move.w #$13,d1
- move.w #8,d2
- move.w #$11,d3
- move.w 8(a0),d4
- jsr SolidObject
- ; Check if generator should be deleted (when Sonic goes too far from it)
- move.w ($FFFFD008).w,d0 ; d0 = Sonic.X
- sub.w 8(a0),d0 ; d0 = Sonic.X - Obj.X
- bmi.s Obj86_Animate ; if Sonic's on left side from generator, branch
- subi.w #$140,d0 ; d0 = Sonic.X - Obj.X - 320
- bmi.s Obj86_Animate ; if Sonic hasn't gone too far from generator, branch
- tst.b 1(a0) ; is generator out of screen?
- bpl.w Obj84_Delete ; if yes, delete it
- ;loc_1A89A:
- Obj86_Animate:
- ; Animate generator
- lea Ani_obj86(pc),a1
- jsr AnimateSprite
- jmp DisplaySprite
- ; ===========================================================================
- Obj86_MakeBalls: ; XREF: Obj86_Index
- tst.b $29(a0) ; have the balls been created?
- beq.w @WaitBalls ; if yes, branch
- clr.b $29(a0) ; set that the balls are created
- add.w $30(a0),d0
- andi.w #$1E,d0
- adda.w d0,a2
- addq.w #4,$30(a0)
- clr.w $32(a0) ; clear current ball number
- moveq #3,d2
- Obj86_Loop:
- ; Create an energy ball
- jsr SingleObjLoad2 ; create new object
- bne.w @WaitBalls ; if couldn't create, branch
- move.b #$86,(a1)
- move.w 8(a0),8(a1) ; copy x-pos
- move.w #$53C,$C(a1) ; set y-pos
- move.b #8,$24(a1) ; => "Obj86_EnergyBall"
- move.w #$2300,2(a1)
- move.l #Map_obj86a,4(a1)
- move.b #$C,$16(a1)
- move.b #$C,$17(a1)
- move.b #0,$20(a1)
- move.b #3,$18(a1)
- move.w #$3E,$28(a1)
- move.b #4,1(a1)
- bset #7,1(a1)
- move.l a0,$34(a1) ; save parent object's address
- jsr (RandomNumber).l
- move.w $32(a0),d1 ; d1 = BallNumber
- muls.w #-$4F,d1 ; d1 = BallNumber * (-$4F)
- addi.w #$2578,d1 ; d1 = BallNumber * (-$4F) + GeneratorXPos
- andi.w #$1F,d0 ; d0 = 0..$1F (Random Number)
- subi.w #$10,d0 ; d0 = 0..$1F - $10
- add.w d1,d0 ; d1 = BallNumber * (-$4F) + GeneratorXPos + 0..$1F - $10
- move.w d0,$30(a1) ; set it as TargetPos
- addq.w #1,$32(a0)
- move.w $32(a0),$38(a0)
- dbf d2,Obj86_Loop ; repeat sequence 3 more times
- ;loc_1A954:
- @WaitBalls:
- ; Wait until all balls take their position
- tst.w $32(a0) ; have all the balls moved to it's position?
- bne.s @0 ; if not, branch
- addq.b #2,$24(a0) ; => "Obj86_WaitBalls"
- @0 bra.w Obj86_ProcessGenerator
- ; ===========================================================================
- ;loc_1A962: ; XREF: Obj86_Index
- Obj86_WaitBalls:
- move.b #2,$1C(a0) ; use animation #2
- tst.w $38(a0) ; have all the balls gone?
- bne.s @0 ; if not, branch
- move.b #2,$24(a0) ; => "Obj86_Generator"
- movea.l $34(a0),a1
- move.w #-1,$32(a1)
- @0 bra.w Obj86_ProcessGenerator
- ; ===========================================================================
- ;loc_1A982: ; XREF: Obj86_Index
- Obj86_EnergyBall:
- moveq #0,d0
- move.b $25(a0),d0
- move.w Obj86_Index2(pc,d0.w),d0
- jsr Obj86_Index2(pc,d0.w)
- lea Ani_obj86a(pc),a1
- jsr AnimateSprite
- jmp DisplaySprite
- ; ===========================================================================
- Obj86_Index2: dc.w @SetSpeeds-Obj86_Index2
- dc.w @MoveToPosition-Obj86_Index2
- dc.w @MoveToSonic-Obj86_Index2
- ; ===========================================================================
- ;loc_1A9A6: ; XREF: Obj86_Index2
- @SetSpeeds:
- move.w $30(a0),d0 ; d0 = TargetPos
- sub.w 8(a0),d0 ; d0 = TargetPos - StartPos
- asl.w #4,d0 ; d0 = (TargetPos - StartPos) / 16
- move.w d0,$10(a0) ; Xvel = (TargetPos - StartPos) / 16
- move.w #$B4,$28(a0) ; set timer to #180 (3 seconds)
- addq.b #2,$25(a0) ; => "@MoveToPosition"
- rts
- ; ===========================================================================
- ;loc_1A9C0: ; XREF: Obj86_Index2
- @MoveToPosition:
- tst.w $10(a0) ; has the ball stopped?
- beq.s @0 ; if yes, branch
- jsr SpeedToPos ; move ball to its position
- move.w 8(a0),d0 ; d0 = CurrentPos
- sub.w $30(a0),d0 ; d0 = CurrentPos - TargetPos
- bcc.s @0 ; if ball hasn't reached TagetPos, branch
- clr.w $10(a0) ; stop the ball
- add.w d0,8(a0) ; fix X-position
- movea.l $34(a0),a1 ; load generator object
- subq.w #1,$32(a1) ; mark this ball moved to its position
- @0 move.b #0,$1C(a0) ; use animation #0
- subq.w #1,$28(a0)
- bne.s @1
- addq.b #2,$25(a0) ; => "@MoveToSonic"
- move.b #1,$1C(a0) ; use animation #1
- move.b #$9A,$20(a0)
- move.w #$B4,$28(a0) ; set timer to #180 (3 seconds)
- moveq #0,d0
- move.w ($FFFFD008).w,d0 ; d0 = Sonic.X
- sub.w 8(a0),d0 ; d0 = Sonic.X - Obj.X
- move.w d0,$10(a0) ; make ball move towards Sonic
- move.w #$140,$12(a0) ; make ball go down
- @1 rts
- ; ===========================================================================
- ;loc_1AA1E: ; XREF: Obj86_Index2
- @MoveToSonic:
- jsr SpeedToPos ; move ball
- cmpi.w #$5E0,$C(a0) ; has the ball gone down the floor?
- bcc.s @DeleteBall ; if yes, branch
- subq.w #1,$28(a0) ; check timer
- beq.s @DeleteBall ; if timer over, branch
- rts
- @DeleteBall:
- movea.l $34(a0),a1 ; load generator object
- subq.w #1,$38(a1) ; make the ball as gone
- bra.w Obj84_Delete
- ; ===========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement