[Solved] Trying to add air roll to sonic 1 hivebrain

Discussion in 'Discussion and Q&A Archive' started by Ziro_, Aug 1, 2016.

  1. Ziro_

    Ziro_ Mentally Skewed Member

    Joined:
    Aug 1, 2016
    Messages:
    59
    Location:
    What are you a cop
    Thanks to everyone that replied to this thread and helped me with my issue.
    Using everyone's advice I was able to fix the issue I was having and I learned some new things.





    What is trying to be accomplished is I am trying to make it so sonic can roll in the air after falling down to the ground from a ledge when you press a, b, or c. Sonic Does not do anything when a b or c is pressed. I don't even know that much asm and created this based on how other moves were made in sonic 1.

    Here is the code:

    Code:
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    
    Sonic_AirRoll:   
         btst   #1,$22(a0)   ; is Sonic in the air?
         bne.s   @SpinCheck   ; if yes, branch
         rts           ; Game Over. In The Continue?
    @SpinCheck:
         cmpi.b   #2,$1C(a0)   ; is Sonic rolling/jumping?
         bne.s   @nope   ; if yes, branch
         tpress   A+B+C,(SonicControl)   ; A, B or C pressed?
         bne.s   @Aroll   ; if yes, branch
         rts         ; simulation is down reboot matrix
    @Aroll:
         move.b   #2,$1C(a0)   ; use "rolling"   animation
         rts           ; Try again for a quarter
    @nope:
         rts         ; insert witty reboot comment here
       
    ; End of function Sonic_AirRoll
     
    Last edited: Aug 2, 2016
  2. FireRat

    FireRat Do Not Interact With This User, Anywhere!!! Exiled

    Joined:
    Oct 31, 2009
    Messages:
    535
    You can INVERT your branches pointing to @nope so you avoid repeating the RTS, you can also set the same animation ID again so latter check is not necessary (the game will not go back to 0 unless you change this ID), and so far your issue (only assuming that code does not "work" (because there is no extra specified info) seem to be related to where you call Sonic_AirRoll instead.
     
  3. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    547
    Location:
    France
    And what is the problem, exactly?

    Have you put a "bsr.w Sonic_AirRoll" in the routine "Obj01_MdJump2" ?

    I also noticed that there isn't a flag or a check for this.
     
  4. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    955
    Isn't there a bitflag in the 'status' ($22) SST byte that indicates the player's rolling? That should be set along with Sonic's animation.

    Edit: According to the SCHG, it's bit 2.
     
    Last edited: Aug 1, 2016
    Ashuro likes this.
  5. TheStoneBanana

    TheStoneBanana banana Member

    Joined:
    Nov 27, 2013
    Messages:
    602
    Location:
    The Milky Way Galaxy
    Code:
    ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    
    Sonic_AirRoll:    
         btst    #1,$22(a0)   ; is Sonic in the air?
         beq.s   @nope   ; if not, branch
         move.b  ($FFFFF602).w,d0
         andi.b  #$70,d0     ; is button A, B or C pressed?
         beq.s   @nope   ; if not, branch
         move.b  #2,$1C(a0)   ; use "rolling"   animation
         bset   #2,$22(a0)   ; force Sonic to roll
    
    @nope:
         rts
    ; End of function Sonic_AirRoll
    
    Here's some slightly better code.
    Can you describe exactly what's going on, @ZiroGX2? Your post is a bit vague as to what's wrong.
     
    Painto and FireRat like this.
  6. AURORA☆FIELDS

    AURORA☆FIELDS so uh yes Member

    Joined:
    Oct 7, 2011
    Messages:
    760
    Code:
    Obj01_DoRoll:
            bset    #2,$22(a0)    ; set on air flag
            move.b    #$E,$16(a0)    ; set width of Sonic
            move.b    #7,$17(a0)    ; set height of Sonic
            move.b    #2,$1C(a0)    ; use "rolling"    animation
            addq.w    #5,$C(a0)    ; move Sonic downwards (since he now has smaller hitbox)
            move.w    #$BE,d0
            jsr    (PlaySound_Special).l ;    play rolling sound
            tst.w    $14(a0)        ; the last bit here forces Sonic to move forwards in rolling chunks
            bne.s    locret_133E8
            move.w    #$200,$14(a0)
    
    locret_133E8:
            rts
    The code you posted is really incomplete. It will not result in "actual" rolling. The thing I posted is just simply what Sonic 1 does when it enables rolling on ground. Use it wisely.
     
  7. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    955
    Oh, also, don't put the 'bsr' for Sonic_AirRoll in Obj01_MdJump2/Sonic_MdJump2. That subroutine's for when Sonic is in the air AND rolling. You'll want Obj01_MdJump/Sonic_MdJump, which is for when Sonic's in the air, and NOT rolling.