ASM to Sega Genesis Platform

Would you like to react to this message? Create an account in a few clicks or log in to continue.
ASM to Sega Genesis Platform

All about assembly programming in the Sega Genesis console.


3 posters

    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    avatar
    OuricoDoido
    Admin


    Mensagens : 46
    Data de inscrição : 2011-01-09
    Current Project : Sonic Open Source Project

    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards Empty Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    Post  OuricoDoido Tue Jan 25, 2011 7:37 pm

    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:
    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

    ; ===========================================================================
    This subroutine is used to bounce up the Sonic when Hit a enemy or monitor, the speed is set depending on whether Sonic is with the speed shoes or underwater;
    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   
    Below the text "Touch_Monitor:", add these lines:
    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   
    to this:
    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
    Add this line:
    Code:
          bsr.w   HA_Bounceup   ; Bounce Sonic upwards if is Homing Attack
    Now bounce Sonic upwards in Homing Attack when destroy a enemy, and in the HA_Bounceup subroutine the Homing Attack will be cleared to correct the bug of Step 4.
    Green Snake
    Green Snake


    Mensagens : 2185
    Data de inscrição : 2012-04-07
    Localização : I do not even know
    Current Project : nope

    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards Empty Re: Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    Post  Green Snake Sun May 19, 2013 11:30 am

    Jdpense
    Jdpense


    Mensagens : 100567
    Data de inscrição : 2014-08-21

    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards Empty Re: Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    Post  Jdpense Thu Dec 27, 2018 11:03 am

    Just an annual year bump! Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy bounce bounce bounce bounce bounce affraid Basketball cheers bom drunken Basketball cheers bom drunken cherry sunny Sleep
    Green Snake
    Green Snake


    Mensagens : 2185
    Data de inscrição : 2012-04-07
    Localização : I do not even know
    Current Project : nope

    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards Empty Re: Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    Post  Green Snake Wed Sep 04, 2019 1:44 pm

    Green Snake
    Green Snake


    Mensagens : 2185
    Data de inscrição : 2012-04-07
    Localização : I do not even know
    Current Project : nope

    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards Empty Re: Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    Post  Green Snake Wed Sep 04, 2019 1:51 pm


    Sponsored content


    Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards Empty Re: Homing Attack in Sonic 1 - Step 6 - Bounce Sonic upwards

    Post  Sponsored content


      Current date/time is Sat Jul 27, 2024 12:33 am