Spring Jump part 2

Discussion in 'Discussion and Q&A Archive' started by warr1or2, Apr 3, 2011.

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

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    I want to update the spring jump in my hack to - instead of falling using the walking animation i want to use the one in this image


    http://images.wikia.com/sonic/images/2/2b/..._CD_Sprites.jpg 2nd row 7th sprite. I have the sprite ready.


    the CODE


    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||


    if _JUMPDASH_


    Sonic_SpringJump:


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


    bne.s Sonic_SJ_Rts ; if no, branch


    btst #7,$22(a0) ; was Jump Dash flag set?


    bne.s Sonic_SJ_Rts ; if yes, branch


    btst #iUp,(SonicControl|Held) ; ++ is Up being held?


    beq Sonic_SJ_Rts ; ++ if not, branch


    tpress A,(SonicControl) ; is A, B or C pressed?


    beq.w Sonic_SJ_Rts ; if not, branch


    bset #7,$22(a0) ; set Jump Dash flag


    move.w #$CC,d0 ; play JD sound


    jsr (PlaySound_Special).l ;


    move.w #-$800,$12(a0) ; set Jump Dash speed


    btst #10,$1C(a0) ; is sonic left?


    beq.s SJ_Move ; if yes, branch


    ;neg.w d0 ; if not, negate d0 (for jumping to the right)


    move.b #$13,$1e(a0) ; ++ use the spring animation


    bset #2,$22(a0) ; ++ clear the "jumping or rolling" flag


    move.w #$680,d2 ; clear Y-velocity


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


    beq.s Sonic_SJ_ChkShoes


    subi.w #$300,$10(a0) ; set speed to $600


    Sonic_SJ_ChkShoes:


    tst.b ($FFFFFE2E).w ; does Sonic have speed shoes?


    beq.s Sonic_SJ_ChkOrientation ; if not, branch


    addi.w #$200,$10(a0) ; set speed to $B00 or $500 if underwater


    Sonic_SJ_ChkOrientation:


    btst #0,$22(a0)


    beq.s Sonic_SJ_Rts


    neg.w $10(a0)


    SJ_Move:


    move.b #$10,$1C(a0)


    move.w #$800, $12 ; clear Y-velocity


    ;neg.w $12(a0)


    Sonic_SJ_Rts:


    rts


    endc


    ====


    what do i add to it? i know a "is sonic falling? BEQ.S if so branch" but what do I put before "(is it $ or #) 5E is sonic falling falling?
     
  2. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    You have to test the vertical velocity (in $12(a0), there's at least one mistake at the bottom of your code on the line with the comment "Clear Y-velocity") and branch according to the velocity's sign (positive or negative).


    Testing a word's sign is "tst.w" followed by the address to test (in this case $12(a0)).


    To branch according to the data's sign, you have to use either bmi (branch if negative) or bpl (branch if positive or zero). Don't forget the .w or .s depending on how far is the code you're branching to.


    Note that positive speed means Sonic is falling (coordinates and speeds are calculated from the top left corner).


    About $ and #:


    # means immediate data, so here what follows a # is used as numbers, not as an address.


    $ means the following value is hexadecimal.


    So when you're writing #$5E, it means "5E is immediate data in hexadecimal", if you write #5E, you get an error because E is not decimal, and if you write $5E, it will be seen as an address and will most likely fail.


    Therefore, every time you write a number meant to be used as a value for addition, subtraction, comparison, etc. you need to begin with a # followed by what identifies the numbering format (eg: nothing:decimal, $:hexadecimal, %:binary).
     
  3. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,870
    SpirituInsanum, you know what? You can have a point for that brilliant display =)


    Also "Megamix ftw!".
     
    HackGame likes this.
  4. OrdosAlpha

    OrdosAlpha RIGHT! Naebody move! Root Admin

    Joined:
    Aug 5, 2007
    Messages:
    1,793
    Location:
    Glasgow, Scotland
  5. Blazer

    Blazer Lurker Member

    Joined:
    Feb 22, 2009
    Messages:
    504
    Location:
    Earth...
  6. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    I used that "tst.w" with "$12 (a0)" and it killed it so i reverted back.

    I used the HOW-TO on Sonicretro with SonMapEd and *followed your guide Xero (*as of today) and now the animations I get is spring, fall, wait, and "hanging on to poll". I only wanted to have it as "spring, fall" (and everytime Sonic constantly hits a spring is those i mentioned, want it as - after sonic is using falling animation and hits the spring again, start animation over)
     
  7. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Have you tried this really easy way. First find out what frame your sprite is (check sonMAPED). Open sonic.asm in Anim folder, and go to the spring animation code. At the end, before the $FD, add the frame number to the end of the spring animation. Like so: SonAni_Spring: dc.b $2F, $40, $XX, $FE, 1, 0 replace xx with the sprite number, and replace FD with FE, 1,0. The number 1 is how many frames to repeat. I may be misunderstanding you completely so I do apologies.


    EDIT: There maybe a slight problem if it were actually the jump from the actuall spring, but because its a move you maybe fine, unless its spamable.
     
    Last edited by a moderator: Apr 4, 2011
  8. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    I knew what frame it was. It's $5E I said that I used SonMapEd and used the HOW-TO on it on Sonic retro. needing 2 frames, but no matter what I do i get 4. and yes i am changing sonic's spring animation to do this. the 4 frames i'm getting is 40, 5E (CD Falling Sprite) (needed), 4, 41 (not needed)


    here's what's being modded - SonAni_Spring: dc.b $2F, $40, $5E $FE, 2, $FF, $FF, $FF


    it's strange that the ones not needed ain't listed in SonAni_Spring. the 2, $FF, $FF, $FF i added myself to try to end this but failed
     
  9. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    You forgot a comma between $5E and $FE. I'm surprised you didn't get an error message there. Not sure that's the problem, but it probably doesn't help. :/


    By the way, the purpose of the sequences of $FF is explained in the 6th post of Xero's animation tutorial. You don't need them here.
     
  10. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    weird... could've sworn i put one there, well... thanks but now when he touches a spring constantly (I know not necessary) it's normal except that when he touches it again the animation LOOPS instead of starting over. I want it to stick with the falling animation till he hits it again.


    EDIT: It now sticks with the falling animation but doesn't start over. any way of making the animation start over when the spring is touched again?
     
  11. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,870
    At routine "Obj41_BounceUp:" clear ($FFFFD01D).w, the thing is, if 1C (the animation I.D.) matches 1D (last animation set I.D.), then it knows not to restart the animation.
     
  12. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    If you look back at my code, my code has $FE, 1, 0 so replace the $FF,$FF,$FF with that, and change the 1 to 2 if your repeating the last 2 frames. Also what SpirituInsanum said, you missed a comma between $5E and $FE.


    Edit: Ah forget it, markeyjester is right here.
     
    Last edited by a moderator: Apr 4, 2011
  13. Blazer

    Blazer Lurker Member

    Joined:
    Feb 22, 2009
    Messages:
    504
    Location:
    Earth...
    or what you can do hopfully to solve your problem is in his animation file, go to the line were the spring jump animation is, and right after $FD, place the animation number there (in my opinion, I recommend using a unused animation line, such as any of the warping animation lines for example.
     
  14. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    There are so many different solutions this is getting confusing ^^'


    @warr1or2: I'll sum it up xD


    1- If you want to use the Y velocity method, it would be far easier if you had a separate equivalent of the "objectfall" routine for Sonic only. Make a copy of "ObjectFall", rename that copy "SonicFall" (for example), replace branches/jumps to "ObjectFall" with branches/jumps to "SonicFall" in object 1's code (ie the Sonic object code), and in that new routine add a small part to:


    - test vertical speed (branch after this newly added part if it's negative)


    - check if the current animation is the "spring jump" animation (branch after the new part again if it isn't)


    - change the animation to the falling animation


    - original code continues after this (this is where you have to branch to when the conditions aren't met)


    It's a matter of 6 lines: one test, one branch, one comparison, one branch, one move, one branch target.


    2- If you want to use the animation method, find the spring animation, it originally branches to animation 0 when it's done (the $FD, 0), you can either


    - add your frame before this (the animation ends with $5E, $FD, 0)


    OR


    - add a new animation with the falling frames and branch to that one instead of animation 0.


    The first method, while not really complex, requires more changes than the second one. The second method is easier, but the animation frames will most likely change too early when water is involved.


    Also, it will look crappy when Sonic lands on platforms and solid objects until you fix that point as well.
     
  15. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    here's that code


    Obj41_BounceUp: ; XREF: Obj41_Up


    addq.b #2,$24(a0)


    addq.w #8,$C(a1)


    move.w $30(a0),$12(a1) ; move Sonic upwards


    bset #1,$22(a1)


    bclr #3,$22(a1)


    move.b #$10,$1C(a1) ; use "bouncing" animation


    move.b #2,$24(a1)


    bclr #3,$22(a0)


    clr.b $25(a0)


    move.w #$CC,d0


    jsr (PlaySound_Special).l ; play spring sound


    Obj41_AniUp: ; XREF: Obj41_Index


    lea (Ani_obj41).l,a1


    bra.w AnimateSprite


    are you referring to the clr.b?

    well the spring jump is fixed (may change it, unsure... well i'll do it anyway if i don't kill it again)
     
  16. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    I seem to have lost myself. Which changes the Animation to use?


    the code again


    ; ||||||||||||||| S U B R O U T I N E |||||||||||||||||||||||||||||||||||||||


    if _JUMPDASH_


    Sonic_SpringJump:


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


    bne.s Sonic_SJ_Rts ; if no, branch


    btst #7,$22(a0) ; was Jump Dash flag set? *


    bne.s Sonic_SJ_Rts ; if yes, branch


    btst #iUp,(SonicControl|Held) ; ++ is Up being held?


    beq Sonic_SJ_Rts ; ++ if not, branch


    tpress A,(SonicControl) ; is A, B or C pressed?


    beq.w Sonic_SJ_Rts ; if not, branch


    bset #7,$22(a0) ; set Jump Dash flag *


    move.w #$CC,d0 ; play JD sound


    jsr (PlaySound_Special).l ;


    move.w #-$800,$12(a0) ; set Jump Dash speed


    btst #10,$1C(a0) ; is sonic left?


    beq.s SJ_Move ; if yes, branch


    ;neg.w d0 ; if not, negate d0 (for jumping to the right)


    move.b #$13,$1e(a0) ; ++ use the spring animation *


    bset #2,$22(a0) ; ++ clear the "jumping or rolling" flag *


    move.w #$680,d2 ; clear Y-velocity


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


    beq.s Sonic_SJ_ChkShoes


    subi.w #$300,$10(a0) ; set speed to $600


    Sonic_SJ_ChkShoes:


    tst.b ($FFFFFE2E).w ; does Sonic have speed shoes?


    beq.s Sonic_SJ_ChkOrientation ; if not, branch


    addi.w #$200,$10(a0) ; set speed to $B00 or $500 if underwater


    Sonic_SJ_ChkOrientation:


    btst #0,$22(a0)


    beq.s Sonic_SJ_Rts


    neg.w $10(a0)


    SJ_Move:


    move.b #$10,$1C(a0)


    move.w #$800, $12 ; clear Y-velocity


    ;neg.w $12(a0)


    Sonic_SJ_Rts:


    rts


    endc


    ====


    * = I must've changed this several times


    _______________________________________________________________________________


    the animations


    SonAni_Walk: dc.b $FF, 8, 9, $A, $B, 6, 7, $FF


    SonAni_Run: dc.b $FF, $1E, $1F, $20, $21, $FF, $FF, $FF


    SonAni_Roll: dc.b $FE, $2E, $2F, $30, $31, $32, $FF, $FF


    SonAni_Roll2: dc.b $FE, $2E, $2F, $32, $30, $31, $32, $FF


    SonAni_Push: dc.b $FD, $45, $46, $47, $48, $FF, $FF, $FF


    SonAni_Wait: dc.b $17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 2, 2, 3, 4, $FE, 2, 0


    SonAni_Balance: dc.b $1F, $3A, $3B, $FF


    SonAni_LookUp: dc.b $3F, 5, $FF, 0


    SonAni_Duck: dc.b $3F, $39, $FF, 0


    SonAni_Warp1: dc.b $3F, $33, $FF, 0


    SonAni_Warp2: dc.b $3F, $34, $FF, 0


    SonAni_Warp3: dc.b $3F, $35, $FF, 0


    SonAni_Warp4: dc.b $3F, $36, $FF, 0


    SonAni_Stop: dc.b 7, $37, $38, $FF


    SonAni_Float1: dc.b 7, $3C, $3F, $FF


    SonAni_Float2: dc.b 7, $3C, $3D, $53, $3E, $54, $FF, 0


    SonAni_Spring: dc.b $2F, $40, $5E, $FF, 1


    SonAni_LZHang: dc.b 4, $41, $42, $FF


    SonAni_Leap1: dc.b $F, $43, $43, $43, $FE, 1


    SonAni_Leap2: dc.b $10, $43, $44, $44, $FE, 1, 0


    SonAni_Surf: dc.b $3F, $49, $FF, 0


    SonAni_Bubble: dc.b $B, $56, $56, $A, $B, $FD, 0, 0


    SonAni_Death1: dc.b $20, $4B, $FF, 0


    SonAni_Drown: dc.b $2F, $4C, $FF, 0


    SonAni_Death2: dc.b 3, $4D, $FF, 0


    SonAni_Shrink: dc.b 3, $4E, $4F, $50, $51, $52, 0, $FE, 1, 0


    SonAni_Hurt: dc.b 3, $55, $FF, 0


    SonAni_LZSlide: dc.b 7, $55, $57, $FF


    SonAni_Blank: dc.b $77, 0, $FD, 0


    SonAni_Float3: dc.b 3, $3C, $3D, $53, $3E, $54, $FF, 0


    SonAni_Float4: dc.b 3, $3C, $FD, 0


    SonAni_Spin_Dash: dc.b 0, $58, $59, $58, $5A, $58, $5B, $58, $5C, $58, $5D, $FF


    SonAni_Spring_Jump: dc.b $2F, $40, $5E, $FE, 1 (This one to use)


    even
     
  17. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    In S1 it's $1C.


    Content of the object status table can be seen here.


    You should make a copy or even print it.
     
  18. OrdosAlpha

    OrdosAlpha RIGHT! Naebody move! Root Admin

    Joined:
    Aug 5, 2007
    Messages:
    1,793
    Location:
    Glasgow, Scotland
    Use the code tags when posting M68K ASM please.
     
  19. warr1or2

    warr1or2 I AM CLG Member

    Joined:
    Apr 7, 2008
    Messages:
    408
    Location:
    Town Creek, AL
    got a little lost there. I changed the code for jumpdash to make it then changed it but forgot how.


    So move.b #$10 <- (now $20) ,$1C <- (animation change) (a0)


    now if I can take sonic 2's transformation sprite and make a transformation sequence (using springjump's code) then the super sonic variant will be finished
     
Thread Status:
Not open for further replies.