Bounce Sonic upwards when do the Homing Attack
Above the Touch_Enemy subroutine (Why here? because this is the nearest place of two subroutines will call this, Touch_Monitor and Touch_KillEnemy), add this:
and cancel the Homing Attack, because you hit the enemy/monitor.
How to: Fix the bug when "destroy a monitor" of Step 4, improve the code and Bounce Sonic upwards when destroy a monitor
Search for Touch_Monitor (the code that says what should happen if Sonic touches a monitor) and you'll find this:
Now replace this:
Why the "rts" has been commented?
Because below the Touch_Monitor subroutine is the HA_Bounceup subroutine, not needing call the HA_Bounceup. This to bounce Sonic upwards in Homing Attack when destroy a monitor.
Now, if the Sonic hit a monitor with the Homing Attack, the monitor will be destroyed immediately, improving the code.
The bug of Step 4 is fixed in HA_Bounceup, when the Homing Attack is cancelled.
How to: Fix the bug when "destroy a enemy" of Step 4 and Bounce Sonic upwards when destroy a enemy
Search for Touch_KillEnemy (the code that says what should happen if Sonic destroy a enemy) and you'll find this:
Below this code:
Above the Touch_Enemy subroutine (Why here? because this is the nearest place of two subroutines will call this, Touch_Monitor and Touch_KillEnemy), add this:
- Code:
; ---------------------------------------------------------------------------
; Subroutine to Bounce Sonic upwards in Homing Attack
; ---------------------------------------------------------------------------
HA_Bounceup:
tst.b ($FFFFFFD1).w ; is Sonic chasing some object?
beq.s HA_Bounceup_rts ; if not, branch
clr.b ($FFFFFFD1).w ; if yes, cancel the Homing Attack, clearing the number of frames Sonic can chasing the object
clr.w $10(a0) ; clear Sonic X-vel (stop sonic horizontally)
move.w #-$600,$12(a0) ; set -$600 for Y-velocity (move sonic upwards)
btst #6,$22(a0) ; is sonic underwater?
beq.s HA_Bounceup_Shoes ; if not, branch
move.w #-$320,$12(a0) ; set -$320 for underwater Y-velocity (move sonic upwards)
HA_Bounceup_Shoes:
tst.b ($FFFFFE2E).w ; does sonic has speed shoes?
beq.s HA_Bounceup_rts ; if not, branch
move.w #-$650,$12(a0) ; set -$650 for Y-velocity (move sonic upwards)
HA_Bounceup_rts:
rts
; ===========================================================================
and cancel the Homing Attack, because you hit the enemy/monitor.
How to: Fix the bug when "destroy a monitor" of Step 4, improve the code and Bounce Sonic upwards when destroy a monitor
Search for Touch_Monitor (the code that says what should happen if Sonic touches a monitor) and you'll find this:
- Code:
Touch_Monitor:
tst.w $12(a0) ; is Sonic moving upwards?
bpl.s loc_1AF1E ; if not, branch
move.w $C(a0),d0
subi.w #$10,d0
cmp.w $C(a1),d0
bcs.s locret_1AF2E
neg.w $12(a0) ; reverse Sonic's y-motion
move.w #-$180,$12(a1)
tst.b $25(a1)
bne.s locret_1AF2E
addq.b #4,$25(a1) ; advance the monitor's routine counter
rts
; ===========================================================================
loc_1AF1E:
cmpi.b #2,$1C(a0) ; is Sonic rolling/jumping?
bne.s locret_1AF2E
neg.w $12(a0) ; reverse Sonic's y-motion
addq.b #2,$24(a1) ; advance the monitor's routine counter
locret_1AF2E:
rts
- Code:
tst.b ($FFFFFFD1).w ; Sonic Homing Attack is chasing the monitor?
bne.s loc_1AF1E_bounce ; if yes, destroy the monitor
Now replace this:
- Code:
addq.b #2,$24(a1) ; advance the monitor's routine counter
locret_1AF2E:
rts
- Code:
loc_1AF1E_bounce:
addq.b #2,$24(a1) ; advance the monitor's routine counter
locret_1AF2E:
; rts
Why the "rts" has been commented?
Because below the Touch_Monitor subroutine is the HA_Bounceup subroutine, not needing call the HA_Bounceup. This to bounce Sonic upwards in Homing Attack when destroy a monitor.
Now, if the Sonic hit a monitor with the Homing Attack, the monitor will be destroyed immediately, improving the code.
The bug of Step 4 is fixed in HA_Bounceup, when the Homing Attack is cancelled.
How to: Fix the bug when "destroy a enemy" of Step 4 and Bounce Sonic upwards when destroy a enemy
Search for Touch_KillEnemy (the code that says what should happen if Sonic destroy a enemy) and you'll find this:
- Code:
Touch_KillEnemy:
bset #7,$22(a1)
moveq #0,d0
move.w ($FFFFF7D0).w,d0
addq.w #2,($FFFFF7D0).w ; add 2 to item bonus counter
cmpi.w #6,d0
bcs.s loc_1AF82
moveq #6,d0
loc_1AF82:
move.w d0,$3E(a1)
move.w Enemy_Points(pc,d0.w),d0
cmpi.w #$20,($FFFFF7D0).w ; have 16 enemies been destroyed?
bcs.s loc_1AF9C ; if not, branch
move.w #1000,d0 ; fix bonus to 10000
move.w #$A,$3E(a1)
loc_1AF9C:
bsr.w AddPoints
move.b #$27,0(a1) ; change object to points
move.b #0,$24(a1)
tst.w $12(a0)
bmi.s loc_1AFC2
move.w $C(a0),d0
cmp.w $C(a1),d0
bcc.s loc_1AFCA
neg.w $12(a0)
rts
Below this code:
- Code:
loc_1AF9C:
bsr.w AddPoints
- Code:
bsr.w HA_Bounceup ; Bounce Sonic upwards if is Homing Attack