Error while building and adding Jump Dash...

Discussion in 'Discussion and Q&A Archive' started by SirHacker, May 23, 2012.

Thread Status:
Not open for further replies.
  1. SirHacker

    SirHacker Newcomer In Limbo

    Joined:
    May 22, 2012
    Messages:
    17
    Hey! I'm back with my Jump Dash move, I was using this code...



    Code:
    
    Sonic_JumpDash:
    
      cmpi.w #-$400,$12(a0) ; is Sonic moving faster than -$400 upwards?
    
      bcs.s SoniC_JumpDash_ChkButton ; if yes, branch
    
    Sonic_JumpDash_ChkButton:
    
      andi.b #$10,d0  ; is B pressed?
    
      bne.w Sonic_JumpDash_Start ; if yes, branch
    
    Sonic_JumpDash_Start:
    
      move.w $100,d0  ; move $100 to d0
    
      btst #0,$22(a0) ; is sonic facing right?
    
      beq.s Sonic_JumpDash_Go ; if not, branch.
    
      neg.w d0  ; if he is, negate d0
    
    Sonic_Jumpdash_Go:
    
      move.w d0,$10  ; move sonic in air
    
      move.w $34,$1C(a0) ;set anim to jumpdash
    
    
    [/CODE]


    but when I use it, I get an error while building. Any Help?


    The error says:


    Illegal zero length short branch
     
    Last edited by a moderator: May 29, 2012
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    The question is, what is after "jsr (PlaySound_Special).l"? Once that routine is called, it will return back to after that instruction and continue, so if you do not have rts on the end, it may end up continuing into unknown places.


    Try either:



    Code:
            jsr    (PlaySound_Special).l ; play the jumpdash sound (spin release)
    
            rts


    Or:





    Code:
            jmp    (PlaySound_Special).l ; play the jumpdash sound (spin release)


    In addition, I see you have in your comments "; is Sonic moving faster than -$25 upwards?", your code is:





    Code:
            cmpi.w    #-$25,$12(a0) ; is Sonic moving faster than -$25 upwards?
    
            beq.s    Sonic_Jumpdash ; if not, branch

    The beq will branch if it is exactly -$25, not if slower, if you want it to branch if slower than -$25, try using bgt (branch on greater than) instead.
     
    Last edited by a moderator: May 23, 2012
  3. SirHacker

    SirHacker Newcomer In Limbo

    Joined:
    May 22, 2012
    Messages:
    17
    Thanks! I'll try that
     
    Last edited by a moderator: May 23, 2012
  4. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    you wrote "move.w d0,$400(a0)" and that's just totally wrong. The horizontal speed is in $10(a0) when a0 is Sonic's main address. I'm not even sure you can use relative addressing beyond -7F/+7F.
     
  5. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    You can. The displacement is actually a 16-bit value, signed word.


    It can be from -$8000 to $7FFF. Same applies to disp(pc) mode.


    A 8-bit displacement is only used by addressing modes disp(an,rn) and disp(pc,rn), it's range is -$80..$7F.
     
  6. SirHacker

    SirHacker Newcomer In Limbo

    Joined:
    May 22, 2012
    Messages:
    17
    Oh man... that's not good.

    Ok? Which one should I choose?


    EDIT: My opinion is that the line of code should be:



    Code:
    
    move.w $200,$10(a0) ; change Sonic's horizontal speed by $200
    
    
    [/CODE]


    EDIT 2: In the game, if i jumpdash, I glitch out and kill Sonic. Not good. I'll fix that!


    The code I tried worked.


    EDIT 3: I don't glitch out, but Sonic stops when he jumps. I still need help because of this.
     
    Last edited by a moderator: May 23, 2012
  7. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    415
    It should be...



    Code:
    
    move.w #$200,$10(a0) ; change Sonic's horizontal speed by $200
    
    



    It's quite a common error of the beginners, when they forget to put # before the numbers.

    # means that the value after it is immediate number, otherwise it will be treated as a memory address.



    Code:
    move.w $200,$10(a0)
    ... means: Move a word from memory address $200 to $10(a0).

    [/CODE]
     
  8. SirHacker

    SirHacker Newcomer In Limbo

    Joined:
    May 22, 2012
    Messages:
    17
    Now I get it!


    Disclamer: I used scrap code to do the 1st code.
     
Thread Status:
Not open for further replies.