How to change Sonic's Jumpheight, Top Speed, Acceleration and Deceleration

Discussion in 'Tutorials Archive' started by DanielHall, Aug 3, 2010.

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

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    This guide is for the newcomer learning ASM. This was one of the first things I taught my friend when I first taught him.


    HOW TO CHANGE SONIC'S JUMPHEIGHT:


    SONIC 1:


    Go to Sonic_Jump (Surprisingly enough not Sonic_Jumpheight.) And take a look at this:




    Sonic_Jump: ; XREF: Obj01_MdNormal; Obj01_MdRoll


    move.b ($FFFFF603).w,d0


    andi.b #$70,d0 ; is A, B or C pressed?


    beq.w locret_1348E ; if not, branch


    moveq #0,d0


    move.b $26(a0),d0


    addi.b #$80,d0


    bsr.w sub_14D48


    cmpi.w #6,d1


    blt.w locret_1348E


    move.w #$680,d2 < Change 680 to any value. Changing it to a higher number makes Sonic jump higher.


    btst #6,$22(a0)


    beq.s loc_1341C


    move.w #$380,d2 < Controls the height of the jump for underwater



    SONIC 2:




    Sonic_Jump:


    move.b (Ctrl_1_Press_Logical).w,d0


    andi.b #$70,d0 ; is A, B or C pressed?


    beq.w return_1AAE6 ; if not, return


    moveq #0,d0


    move.b angle(a0),d0


    addi.b #$80,d0


    bsr.w CalcRoomOverHead


    cmpi.w #6,d1 ; does Sonic have enough room to jump?


    blt.w return_1AAE6 ; if not, branch


    move.w #$680,d2 < Same as in the Sonic 1 section


    tst.b (Super_Sonic_flag).w


    beq.s +


    move.w #$800,d2 ; set higher jump speed if super


    +


    btst #6,status(a0) ; Test if underwater


    beq.s +


    move.w #$380,d2 ; set lower jump speed if under









    TOP SPEED, ACCELERATION AND DECELERATION:



    Go to Obj01_Main:




    Obj01_Main: ; XREF: Obj01_Index


    addq.b #2,$24(a0)


    move.b #$13,$16(a0)


    move.b #9,$17(a0)


    move.l #Map_Sonic,4(a0)


    move.w #$780,2(a0)


    move.b #2,$18(a0)


    move.b #$18,$19(a0)


    move.b #4,1(a0)


    move.w #$600,($FFFFF760).w ; Sonic's top speed < change this


    move.w #$C,($FFFFF762).w ; Sonic's acceleration < change this


    move.w #$80,($FFFFF764).w ; Sonic's deceleration < change this



    FOR UNDERWATER:




    Obj01_InWater:


    move.w ($FFFFF646).w,d0


    cmp.w $C(a0),d0 ; is Sonic above the water?


    bge.s Obj01_OutWater ; if yes, branch


    bset #6,$22(a0)


    bne.s locret_12D80


    bsr.w ResumeMusic


    move.b #$A,($FFFFD340).w ; load bubbles object from Sonic's mouth


    move.b #$81,($FFFFD368).w


    move.w #$300,($FFFFF760).w ; change Sonic's top speed < change this


    move.w #6,($FFFFF762).w ; change Sonic's acceleration < change this


    move.w #$40,($FFFFF764).w ; change Sonic's deceleration < change this



    SONIC 2:


    Go to Obj01_init:




    Obj01_Init:


    addq.b #2,routine(a0) ; => Obj01_Control


    move.b #$13,y_radius(a0) ; this sets Sonic's collision height (2*pixels)


    move.b #9,x_radius(a0)


    move.l #Mapunc_Sonic,mappings(a0)


    move.b #2,priority(a0)


    move.b #$18,width_pixels(a0)


    move.b #4,render_flags(a0)


    move.w #$600,(Sonic_top_speed).w ; set Sonic's top speed < change this


    move.w #$C,(Sonic_acceleration).w ; set Sonic's acceleration < change this


    move.w #$80,(Sonic_deceleration).w ; set Sonic's deceleration < change this



    For Underwater:




    Obj01_InWater:


    move.w (Water_Level_1).w,d0


    cmp.w y_pos(a0),d0 ; is Sonic above the water?


    bge.s Obj01_OutWater ; if yes, branch


    bset #6,status(a0) ; set underwater flag


    bne.s return_1A18C ; if already underwater, branch


    movea.l a0,a1


    bsr.w ResumeMusic


    move.b #$A,(Object_RAM+$2080).w ; load Obj0A (sonic's breathing bubbles) at $FFFFD080


    move.b #$81,(Object_RAM+$2080+subtype).w


    move.l a0,(Object_RAM+$2080+$3C).w


    move.w #$300,(Sonic_top_speed).w < change this


    move.w #6,(Sonic_acceleration).w < change this


    move.w #$40,(Sonic_deceleration).w < change this
     
    Last edited by a moderator: Aug 3, 2010
  2. clarisonic1

    clarisonic1 Well-Known Member Member

    Joined:
    Jul 6, 2010
    Messages:
    106
    Is there a way to make sonic use his walking animation at his normal top speed and use his final running animation at a faster speed? I didn't want to do this, I just want to know if it's possible.
     
  3. DanielHall

    DanielHall Well-Known Member Member

    Joined:
    Jan 18, 2010
    Messages:
    860
    Location:
    North Wales
    Yeah, but i think that needs a few checks using code.
     
  4. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    Please can you put the asm in a code box


    Code:
    like this
    
     
  5. theocas

    theocas #! Member

    Joined:
    Apr 10, 2010
    Messages:
    375
    Nice to see you're getting good at ASM and write your own tutorials. A good idea would be to create an equate at the top of the code and all references to the jump height could be changed by changing one line of code. As mentioned before, please surround your code with asm tags.
     
  6. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    A nice beginners tutorial, I'm glad to see basic stuff like this here, it'll open the eyes to many new-comers I'm sure.

    Yes sir, right away sir... oh wait, who are you again? have a nice day sir.
     
  7. liamsonichacker

    liamsonichacker Mad Level Skillz ;) Member

    Joined:
    May 29, 2009
    Messages:
    50
    Location:
    Leicester, UK
    Thank you, you want some credit in my hack? :)
     
  8. Pokepunch

    Pokepunch That guy who posts on occasion Member

    Joined:
    Aug 7, 2009
    Messages:
    270
    Location:
    UK
    I said please :(
     
  9. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    I was about to flame liamsonichacker for bumping a one year old topic, but this really gave me the rest. I couldn't resist but laugh, hard.
     
Thread Status:
Not open for further replies.