How to add Water Skimming

Discussion in 'Approved' started by vladikcomper, Dec 28, 2009.

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

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    382
    Location:
    Russia
    How to add Water Skimming in Sonic 1


    Water skimming was first seen in Sonic 2 for SMS, it also appeared in Sonic 3 for SMD, but worked a little different. Due to LZ levels in Sonic 1 aren't designed for fast walkthrough, 8-bit Sonic 2 Water Skimming would suit better. So it will work this way:


    [​IMG]


    Adding this ability is quite easy.


    Find Obj_MdJump2 label, so you'll see something like this:



    Obj01_MdJump2: ; XREF: Obj01_Modes
    bsr.w Sonic_JumpHeight


    bsr.w Sonic_ChgJumpDir


    bsr.w Sonic_LevelBound


    jsr ObjectFall


    btst #6,$22(a0)


    beq.s loc_12EA6


    subi.w #$28,$12(a0)



    Append it with the following code:



    move.w $10(a0),d0 ; move Sonic's X-velocity to d0
    tst.w d0 ; is his speed positive? (is he running to the right?)


    bpl.s Obj01_MdJump2_Abs ; if yes, branch


    neg.w d0 ; otherwise negate it


    Obj01_MdJump2_Abs:


    cmpi.w #$250,d0 ; if Sonic speed less than $250?


    blt.s loc_12EA6 ; if yes, branch


    move.w $C(a0),d0 ; move sonic's Y-position to d0


    sub.w ($FFFFF646).w,d0 ; sub the water height from it


    cmpi.w #$F,d0 ; is Sonic slightly in the water?


    bgt.s loc_12EA6 ; if not, branch


    subi.w #$90,$12(a0) ; jump out of water



    That's all. Build your ROM and try new ability!


    Please correct me if you've noticed grammar or lexical mistakes in this text.
     
    Last edited by a moderator: Dec 28, 2009
    Nat The Porcupine likes this.
  2. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,398
    Location:
    Northern Germany
    For someone who says he knows ASM bad you are pretty good at it.



    move.w $10(a0),d0 ; move Sonic's X-velocity to d0
    tst.w d0 ; is his speed positive? (is he running to the right?)


    bpl.s Obj01_MdJump2_Abs ; if yes, branch


    neg.w d0 ; otherwise negate it


    Obj01_MdJump2_Abs:


    cmpi.w #$250,d0 ; if Sonic speed less than $250?


    blt.s loc_12EA6 ; if yes, branch


    move.w $C(a0),d0 ; move sonic's Y-position to d0


    sub.w ($FFFFF646).w,d0 ; sub the water height from it


    cmpi.w #$F,d0 ; is Sonic slightly in the water?


    bgt.s loc_12EA6 ; if not, branch


    subi.w #$90,$12(a0) ; jump out of water



    I was bored and commented it. =P
     
  3. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    382
    Location:
    Russia
    I forgot to mention that my phrase "...I know ASM bad..." has expired already ;)

    Thanks for commenting.


    I wanted to comment it too, but was too lazy. I've even forgotten to fix some bugs.
     
  4. MarkeyJester

    MarkeyJester ! % # @ Member

    Joined:
    Jun 27, 2009
    Messages:
    2,725
    That's very impressive, I like the fact that you actually know how to program this stuff unlike everyone else on this damn forum, whom of which burst in here asking for help every 5 minutes.


    Great work though, non the-less =)
     
  5. OrdosAlpha

    OrdosAlpha RIGHT! Naebody move! Administrator

    Joined:
    Aug 5, 2007
    Messages:
    1,780
    Location:
    Glasgow, Scotland
    Hmm... Interesting, might give this a try.
     
  6. hfdshdgfhgn

    hfdshdgfhgn fdsgfdgfhgfds Member

    Joined:
    Dec 28, 2009
    Messages:
    89
    Wait, shouldn't this be in Sourcecode exchange?
     
  7. amphobius

    amphobius spreader of the pink text Member

    Joined:
    Feb 24, 2008
    Messages:
    971
    Location:
    United Kingdom
    I believe not--this is a tutorial on how to add something.
     
  8. Selbi

    Selbi Plug in, baby. Retired Staff

    Joined:
    Jul 20, 2008
    Messages:
    2,398
    Location:
    Northern Germany
    Well actually it's both, tutorial and source code guide, because it's a 100% c/p guide, without explaining (except for the comments). There should be at least a link in the exchange forum.
     
  9. liamsonichacker

    liamsonichacker Mad Level Skillz ;) Member

    Joined:
    May 29, 2009
    Messages:
    50
    Location:
    Leicester, UK
    EDIT: Remove this post please :p
     
    Last edited by a moderator: Sep 12, 2011
  10. liamsonichacker

    liamsonichacker Mad Level Skillz ;) Member

    Joined:
    May 29, 2009
    Messages:
    50
    Location:
    Leicester, UK
    If I may would I be able to change this line;


    bpl.s Obj01_MdJump2_Abs ; if yes, branch


    To this line;


    bpl.s Sonic_Move ; if yes, branch


    Would it work the same?
     
    Last edited by a moderator: Sep 12, 2011
  11. vladikcomper

    vladikcomper Well-Known Member Member

    Joined:
    Dec 2, 2009
    Messages:
    382
    Location:
    Russia
    Don't ask, try it! It's so easy to check it out.


    If this works as you planned, it will be a great discovery for the Sonic Hacking Community.
     
Thread Status:
Not open for further replies.