Sonic 1 github: Bug with Water Shield Bounce

Discussion in 'Discussion & Q&A' started by Red2010 is now, Feb 7, 2024.

Tags:
  1. Red2010 is now

    Red2010 is now Newcomer Member

    Joined:
    Apr 24, 2023
    Messages:
    19
    Location:
    Somewhere in Spain
    I recently started bringing some features for my hack (Sonic encore)

    Let's go straight to what matters. Following the guide that Clownacy made a little less than 4 years ago, I tried to bring the elemental shields from Sonic 3. The fire and lightning shields work the same but the one I have problems with is the water shield one.

    What would be its "skeleton" works well but the rebound part...uff

    I could summarize the entire error but a gif is enough

    [​IMG]
    I tried to apply the solution that clownacy uses in the first part of its guide but nothing

    Just in case I'll share the "SonicOnResetFloor" and "Sonic Floor" routines

    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine to    reset Sonic's mode when he lands on the floor
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    Sonic_ResetOnFloor:
            btst    #4,obStatus(a0)
            beq.s    loc_137AE
            nop   
            nop   
            nop   
    
    loc_137AE:
            bclr    #5,obStatus(a0)
            bclr    #1,obStatus(a0)
            bclr    #4,obStatus(a0)
            btst    #2,obStatus(a0)
            beq.s    loc_137E4
            bclr    #2,obStatus(a0)
            move.b    #$13,obHeight(a0)
            move.b    #9,obWidth(a0)
            move.b    #id_Walk,obAnim(a0) ; use running/walking animation
            subq.w    #5,obY(a0)
    
    loc_137E4:
            move.b    #0,$3C(a0)
            move.w    #0,(v_itembonus).w
            tst.b    double_jump_flag(a0)
            beq.s    locret_12230
    ;        tst.b    character_id(a0)
    ;        bne.s    loc_1222A
    ;        tst.b    (Super_Sonic_Knux_flag).w
    ;        bne.s    loc_1222A
    ;        btst    #Status_BublShield,status_secondary(a0)
    ;        beq.s    loc_1222A
            bsr.s    BubbleShield_Bounce
    
    loc_1222A:
            move.b    #0,double_jump_flag(a0)
    
    locret_12230:
            rts
    ; End of function Sonic_ResetOnFloor
    
    ; =============== S U B R O U T I N E =======================================
    
    
    BubbleShield_Bounce:
            movem.l    d1-d2,-(sp)
            move.w    #$780,d2
            btst    #6,status(a0)
            beq.s    loc_12246
            move.w    #$400,d2
    
    loc_12246:
            moveq    #0,d0
            move.b    angle(a0),d0
            subi.b    #$40,d0
            jsr    (CalcSine).l
            muls.w    d2,d1
            asr.l    #8,d1
            add.w    d1,x_vel(a0)
            muls.w    d2,d0
            asr.l    #8,d0
            add.w    d0,y_vel(a0)
            movem.l    (sp)+,d1-d2
            bset    #1,status(a0)
            bclr    #5,status(a0)
            move.b    #1,$3C(a0)
            clr.b    $38(a0)
            move.b    #$E,y_radius(a0)
            move.b    #7,x_radius(a0)
            move.b    #2,anim(a0)
            bset    #2,status(a0)
            move.b    y_radius(a0),d0
            subi.b    #$13,d0
            ext.w    d0
    ;        tst.b    (Reverse_gravity_flag).w
    ;        beq.s    loc_122AA
    ;        neg.w    d0
    
    ;loc_122AA:
            sub.w    d0,y_pos(a0)
    ;        move.b    #2,(Shield+anim).w
    ;        move.w    #sfx_BubbleAttack,d0
    ;        jmp    (Play_SFX).l
            rts   
    ; End of fuction BubbleShield_Bounce
    Code:
    ; ---------------------------------------------------------------------------
    ; Subroutine for Sonic to interact with    the floor after    jumping/falling
    ; ---------------------------------------------------------------------------
    
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    Sonic_Floor:
            move.w    obVelX(a0),d1
            move.w    obVelY(a0),d2
            jsr    (CalcAngle).l
            move.b    d0,($FFFFFFEC).w
            subi.b    #$20,d0
            move.b    d0,($FFFFFFED).w
            andi.b    #$C0,d0
            move.b    d0,($FFFFFFEE).w
            cmpi.b    #$40,d0
            beq.w    loc_13680
            cmpi.b    #$80,d0
            beq.w    loc_136E2
            cmpi.b    #$C0,d0
            beq.w    loc_1373E
            bsr.w    Sonic_HitWall
            tst.w    d1
            bpl.s    loc_135F0
            sub.w    d1,obX(a0)
            move.w    #0,obVelX(a0)
    
    loc_135F0:
            bsr.w    sub_14EB4
            tst.w    d1
            bpl.s    loc_13602
            add.w    d1,obX(a0)
            move.w    #0,obVelX(a0)
    
    loc_13602:
            bsr.w    Sonic_HitFloor
            move.b    d1,($FFFFFFEF).w
            tst.w    d1
            bpl.s    locret_1367E
            move.b    obVelY(a0),d2
            addq.b    #8,d2
            neg.b    d2
            cmp.b    d2,d1
            bge.s    loc_1361E
            cmp.b    d2,d0
            blt.s    locret_1367E
    
    loc_1361E:
            add.w    d1,obY(a0)
            move.b    d3,obAngle(a0)
            bsr.w    Sonic_ResetOnFloor
            move.b    #id_Walk,obAnim(a0)
            move.b    d3,d0
            addi.b    #$20,d0
            andi.b    #$40,d0
            bne.s    loc_1365C
            move.b    d3,d0
            addi.b    #$10,d0
            andi.b    #$20,d0
            beq.s    loc_1364E
            asr    obVelY(a0)
            bra.s    loc_13670
    ; ===========================================================================
    
    loc_1364E:
            move.w    #0,obVelY(a0)
            move.w    obVelX(a0),obInertia(a0)
            bsr.w    Sonic_ResetOnFloor
            rts   
    ; ===========================================================================
    
    loc_1365C:
            move.w    #0,obVelX(a0)
            cmpi.w    #$FC0,obVelY(a0)
            ble.s    loc_13670
            move.w    #$FC0,obVelY(a0)
    
    loc_13670:
            move.w    obVelY(a0),obInertia(a0)
            tst.b    d3
            bpl.s    locret_1367E
            neg.w    obInertia(a0)
    
    locret_1367E:
            rts   
    ; ===========================================================================
    
    loc_13680:
            bsr.w    Sonic_HitWall
            tst.w    d1
            bpl.s    loc_1369A
            sub.w    d1,obX(a0)
            move.w    #0,obVelX(a0)
            move.w    obVelY(a0),obInertia(a0)
            rts   
    ; ===========================================================================
    
    loc_1369A:
            bsr.w    Sonic_DontRunOnWalls
            tst.w    d1
            bpl.s    loc_136B4
            sub.w    d1,obY(a0)
            tst.w    obVelY(a0)
            bpl.s    locret_136B2
            move.w    #0,obVelY(a0)
    
    locret_136B2:
            rts   
    ; ===========================================================================
    
    loc_136B4:
            tst.w    obVelY(a0)
            bmi.s    locret_136E0
            bsr.w    Sonic_HitFloor
            tst.w    d1
            bsr.w    Sonic_ResetOnFloor
            bpl.s    locret_136E0
            add.w    d1,obY(a0)
            move.b    d3,obAngle(a0)
            move.b    #id_Walk,obAnim(a0)
            move.w    #0,obVelY(a0)
            move.w    obVelX(a0),obInertia(a0)
    
    locret_136E0:
            rts   
    ; ===========================================================================
    
    loc_136E2:
            bsr.w    Sonic_HitWall
            tst.w    d1
            bpl.s    loc_136F4
            sub.w    d1,obX(a0)
            move.w    #0,obVelX(a0)
    
    loc_136F4:
            bsr.w    sub_14EB4
            tst.w    d1
            bpl.s    loc_13706
            add.w    d1,obX(a0)
            move.w    #0,obVelX(a0)
    
    loc_13706:
            bsr.w    Sonic_DontRunOnWalls
            tst.w    d1
            bpl.s    locret_1373C
            sub.w    d1,obY(a0)
            move.b    d3,d0
            addi.b    #$20,d0
            andi.b    #$40,d0
            bne.s    loc_13726
            move.w    #0,obVelY(a0)
            rts   
    ; ===========================================================================
    
    loc_13726:
            move.b    d3,obAngle(a0)
            bsr.w    Sonic_ResetOnFloor
            move.w    obVelY(a0),obInertia(a0)
            tst.b    d3
            bpl.s    locret_1373C
            neg.w    obInertia(a0)
    
    locret_1373C:
            rts   
    ; ===========================================================================
    
    loc_1373E:
            bsr.w    sub_14EB4
            tst.w    d1
            bpl.s    loc_13758
            add.w    d1,obX(a0)
            move.w    #0,obVelX(a0)
            move.w    obVelY(a0),obInertia(a0)
            rts   
    ; ===========================================================================
    
    loc_13758:
            bsr.w    Sonic_DontRunOnWalls
            tst.w    d1
            bpl.s    loc_13772
            sub.w    d1,obY(a0)
            tst.w    obVelY(a0)
            bpl.s    locret_13770
            move.w    #0,obVelY(a0)
    
    locret_13770:
            rts   
    ; ===========================================================================
    
    loc_13772:
            tst.w    obVelY(a0)
            bmi.s    locret_1379E
            bsr.w    Sonic_HitFloor
            tst.w    d1
            bpl.s    locret_1379E
            add.w    d1,obY(a0)
            move.b    d3,obAngle(a0)
            bsr.w    Sonic_ResetOnFloor
            move.b    #id_Walk,obAnim(a0)
            move.w    #0,obVelY(a0)
            move.w    obVelX(a0),obInertia(a0)
    
    locret_1379E:
            rts   
    ; End of function Sonic_Floor
    Any help will be welcome

    (And for those who ask. Yes, I tried to follow the delta guide but failed at everything)
     
  2. Alegamer700

    Alegamer700 Newcomer Member

    Joined:
    Jun 14, 2021
    Messages:
    14
    Location:
    Somewhere in South America
    Try to change locret_12230 to loc_1222A
    Edit: Also, if you don't mind, I can help you with any problems you have. Now Im on vacations so im not that busy
     
    Last edited: Feb 8, 2024
    Hame likes this.
  3. Red2010 is now

    Red2010 is now Newcomer Member

    Joined:
    Apr 24, 2023
    Messages:
    19
    Location:
    Somewhere in Spain
    The solution you proposed does solve something...but it doesn't do the bounce and it makes the other shields activate when you press the control

    And because of my position as a trialist, this will be the last message for some time (I should put my discord profile but whatever).