Jumpdash Problem.

Discussion in 'Discussion and Q&A Archive' started by OscillateNumInit, Nov 8, 2008.

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

    OscillateNumInit Newcomer Member

    Joined:
    Sep 16, 2008
    Messages:
    2
    OK, so I implemented this crude jumpdash function based on the spindash.


    The problem is that when I execute it, Sonic goes to the left and exceeds the camera, so he ends up warping to the end.



    tst.b $21(a0); is sonic in air?
    bne.w locret_134D2; if not, branch


    move.b ($FFFFF603).w,d0; read controller


    and.b #$70,d0 ; is A, B or C being pressed


    move.b #2,$1C(a0); set animation to roll


    move.w jdash_norm(pc,d0.w),$14(a0); get speed


    jdash_norm:


    dc.w $C00; 0


    dc.w $880; 1


    dc.w $900; 2


    dc.w $980; 3


    dc.w $A00; 4


    dc.w $A80; 5


    dc.w $B00; 6


    dc.w $B80; 7


    dc.w $C00; 8


    GetInertia:


    move.w $14(a0),d0; get inertia


    subi.w #$800,d0; subtract $800


    add.w d0,d0 ; double it


    andi.w #$1F00,d0; mask it against $1F00


    neg.w d0 ; negate it


    addi.w #$2000,d0; add $2000


    move.w d0,($FFFFEED0).w; move to $EED0


    btst #0,$22(a0); is sonic facing right?


    beq.s PlaySoundforJdash; if not, branch


    neg.w $14(a0) ; negate inertia


    PlaySoundforJdash:


    bset #2,$22(a0); set unused (in s1) flag


    move.w #$BC,d0 ; spin release sound


    jsr (PlaySound_Special).l; play it!


    StackPtr:


    addq.l #4,sp ; increase stack ptr


    cmpi.w #$60,($FFFFF73E).w


    beq.s loc6_1AD8C


    bcc.s loc6_1AD88


    addq.w #4,($FFFFF73E).w


    loc6_1AD88:


    subq.w #2,($FFFFF73E).w


    loc6_1AD8C:


    bsr.w Sonic_LevelBound


    bsr.w Sonic_AnglePos
     
    Last edited by a moderator: Feb 4, 2009
  2. Irixion

    Irixion Well-Known Member Member

    Joined:
    Aug 11, 2007
    Messages:
    670
    Location:
    Ontario, Canada
    This code 'throws' sonic, like he gets thrown in spindash. However I see no 'release' code, so the game continues throwing him until he reaches the end. :p


    Edit; i'd like to see that actually, can you post up a rom with this code in? :p
     
    Last edited by a moderator: Nov 17, 2008
  3. PsychoSk8r

    PsychoSk8r HighKnights Member

    Joined:
    Aug 9, 2007
    Messages:
    271
    Location:
    Birmingham, UK
    Huge bump I know, but it'll probably solve the problem, if you still have it.


    Assuming this is sonic 1:


    go to Obj01_MdJump2, and add above "bsr.w Sonic_JumpHeight"




    bsr.w Sonic_JumpDash


    bsr.w Sonic_JumpDash1



    Then find "; End of function Sonic_JumpHeight" and add below:




    Sonic_JumpDash:


    tst.w $12(a0) ; is Sonic moving upwards?


    beq.s endofjumpdash ; if not, branch


    cmpi.b #$13,$1C(a0) ; is sonic using "PUNCHAIR" animation?


    beq.w endofjumpdash ; if yes, branch


    cmpi.b #$0E,$1C(a0) ; is sonic using "JUMPDASH" animation?


    beq.w endofjumpdash ; if yes, branch


    cmpi.b #2,$1C(a0) ; is Sonic rolling/jumping?


    move.b ($FFFFF605).w,d0


    btst #2,($FFFFF602).w ; is left being pressed?


    beq.s endofjumpdash; if not, branch


    andi.b #$10,d0 ; is B button pressed?


    beq.s endofjumpdash; if not, branch


    move.w #$1200,($FFFFD014).w ; set Sonic's speed


    sub.w #$700,$10(a0) ; move Sonic left


    move.b #$0E,$1C(a0) ; use "bouncing" animation


    endofjumpdash:


    rts


    Sonic_JumpDash1: ;Jumpdash while facing right.


    tst.w $12(a0) ; is Sonic moving upwards?


    beq.s endofjumpdash1 ; if not, branch


    cmpi.b #$13,$1C(a0) ; is sonic using "PUNCHAIR" animation?


    beq.w endofjumpdash1 ; if yes, branch


    cmpi.b #$0E,$1C(a0) ; is sonic using "JUMPDASH" animation?


    beq.w endofjumpdash ; if yes, branch


    cmpi.b #2,$1C(a0) ; is Sonic rolling/jumping?


    move.b ($FFFFF605).w,d0


    btst #3,($FFFFF602).w ; is RIGHT being pressed?


    beq.s endofjumpdash1; if not, branch


    andi.b #$10,d0 ; is B button pressed?


    beq.s endofjumpdash1; if not, branch


    move.w #$1200,($FFFFD014).w ; set Sonic's speed


    add.w #$700,$10(a0) ; move Sonic right


    move.b #$0e,$1C(a0) ; use "bouncing" animation


    endofjumpdash1:


    rts
     
  4. c1owd

    c1owd Previously 'CarrascoZX0' Member

    Joined:
    Dec 13, 2008
    Messages:
    364
    Doesn't work... I got and error:

     
  5. PsychoSk8r

    PsychoSk8r HighKnights Member

    Joined:
    Aug 9, 2007
    Messages:
    271
    Location:
    Birmingham, UK
    It would help if you posted what lines the errors are reffering to. =P


    Also, remember I use Snasm68k, but show me the lines, and I'll see what I can do.
     
    Last edited by a moderator: Feb 5, 2009
  6. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I made a guide on how to fix the out of branch error. Click here!
     
  7. hyper

    hyper Newcomer Trialist

    Joined:
    Aug 25, 2008
    Messages:
    5
    Location:
    France, near Paris
    it's work just add


    bsr.w Sonic_JumpDash


    bsr.w Sonic_JumpDash1


    to : Obj01_MdJump and Obj01_MdJump2


    ok
     
  8. Hitaxas

    Hitaxas Retro 80's themed Paladins Twich streamer Member

    Joined:
    Aug 13, 2007
    Messages:
    167
    Time to 1-up PsychoSk8r's code.


    Code can be improved.



    Sonic_Jumpdash:; beginning of code

    jd1:; this code checks for flags and the c button (flags checked: if sonic's on the ground, If Sonic's in rolling animation, and the double jump flag)


    tst.b $21(a0) ; is doublejump Flag set?


    bne endofsonicjumpdash ; if yes, branch (stops sonic from being able to jumpdash multiple times at once)


    btst #1,$22(a0) ; check if Sonic is on the ground


    beq endofsonicjumpdash ; if so, branch (Stops Sonic from jumpdashing if he is simply trying to jump)


    cmpi.b #2,$1C(a0) ; is Sonic rolling/jumping?


    btst #5,($FFFFF605).w ; is button C pressed?


    beq jd2 ; branch to '+'


    jmp dashpower_under ; jump to continue jumpdash


    rts ; don't check '+'


    jd2:; this code checks for the B button


    btst #4,($FFFFF605).w ; is button B pressed?


    beq endofsonicjumpdash ; return if nothing is pressed


    jmp dashpower_under ; jump to continue jumpdash


    rts ; don't check 'dashpower_under'


    dashpower_under:; code for setting in water jumpdash speed


    cmpi.w #$800,$14(a0) ; check Sonic's inertia (not moving)


    btst #6,$22(a0) ; is Sonic underwater?


    beq dashpower_outof ; if not, branch


    move.w #$475,d0 ; Set dash power (In water speed)


    btst #0,$22(a0) ; is the orientation left?


    beq Jumpdash_Finish ; if facing right, do nothing


    neg.w d0 ; otherwise, negate d0 to switch direction of dash


    bra Jumpdash_Finish


    dashpower_outof:; code for setting out of water jumpdash speed


    move.w #$975,d0 ; Set dash power (Out of water speed)


    btst #0,$22(a0) ; is the orientation left?


    beq Jumpdash_Finish ; if facing right, do nothing


    neg.w d0 ; otherwise, negate d0 to switch direction of dash


    Jumpdash_Finish:; code for finishing move, actually sends sonic forward and sets double jump flag


    move.b #0,$12(a0) ; clear vert (Y) velocity


    move.w d0,$10(a0) ; move Sonic forward (X axis)


    move.b #0,$12(a0) ; clear vert (Y) velocity


    move.b #2,$1C(a0) ; use "rolling" animation


    move.b #1,$21(a0) ; Set Double Jump Flag


    move.b #$BC,d0 ; Set jumping Sound


    jsr (PlaySound_Special).l ; play jumping sound!


    endofsonicjumpdash:; ends the Jumpdash code


    rts ; cancel Jumpdash


    ; end of sonicdoublejump



    That's how it should handle. :p


    Although my code uses the jump/roll animation, so you will have to clear the doublejump flag at Sonic_Resetonfloor


    My version checks for an underwater flag, setting the dash speed lower if the player is. This is the version I wrote for SSD ages ago.


    If anyone uses this, please give me credit. :)
     
    Last edited by a moderator: Mar 12, 2009
Thread Status:
Not open for further replies.