don't click here

Wall Recoil Porting Tutorial

Discussion in 'Engineering & Reverse Engineering' started by Twilight, Jul 16, 2008.

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

    Twilight

    Member
    51
    0
    6
    Michigan
    A Sonic the Hedgehog hack
    Here is a tutorial that I made on how to port the wall recoil from Sonic the Hedgehog 2 early prototype to Sonic the Hedgehog:


    How to port the Wall Recoil to Sonic 1

    Basic Tutorial by Twilight

    Version 1.0


    This is my first contribution to Sonic Retro. Before following this tutorial, refer to Qjimbo's guide on how to set up a Sonic the Hedgehog disassembly. Also, check out his basic ASM tutorial on how to port the spindash from the early prototype of Sonic the Hedgehog 2 to Sonic the Hedgehog. Both of those contain download links to recommended tools that I'll be using in this tutorial. Once you've set up the disassembly and the tools, read on.

    Alright, let's get started. Open up sonic1.asm and Sonic 2 (Early prototype).asm in ConText. In sonic1.asm, search for "Obj01_MdNormal:". You should get this:

    http://www.hostdump.com/host/out.php/i3326...j01MdNormal.gif


    From there, scroll down until you get to loc_13024:

    http://www.hostdump.com/host/out.php/i33274_loc13024.gif


    In Sonic 2 (Early prototype).asm, find "loc_FE8E:":

    http://www.hostdump.com/host/out.php/i33280_locFE8E.gif


    Compare loc_13024 with loc_FE8E. Loc_FE8E has two extra lines, which are:

    cmpi.w #$600,$10(a0)
    bge.s Sonic_WallRecoil

    Paste these lines in loc_13024 in sonic1.asm, after beq.s loc_13060.


    You should end up with this:

    http://www.hostdump.com/host/out.php/i33288_cmpi.w.gif


    Now, there's another area of code that you need to paste: the actual code for the Wall Recoil. In Sonic 2 (Early prototype).asm, search for "Sonic_WallRecoil:":

    http://www.hostdump.com/host/out.php/i3329...cWallRecoil.gif


    Copy this:

    http://www.hostdump.com/host/out.php/i3329...lightedcode.gif


    Paste it in sonic1.asm, overwriting this:

    http://www.hostdump.com/host/out.php/i33295_SonicMove.gif


    Now, you should see this:

    http://www.hostdump.com/host/out.php/i33298_finalcode.gif


    Save it, build it, and test it. Let's see....

    http://www.hostdump.com/host/out.php/i3330...ecoilingame.gif


    It's using the incorrect animation!


    Change it to this:

    http://www.hostdump.com/host/out.php/i3330...edanimation.gif


    Now, it should work properly. You have just ported the wall recoil to Sonic the Hedgehog. This concludes my tutorial.


    What do you think of it?
     
  2. Spanner

    Spanner

    I used to do things... Member
    3,364
    182
    43
    United Kingdom
    I wish I knew...
    Couldn't you just post the code with the
    Code (ASM):
    1.  tags?
    2. The wall recoil's been ported in a few hacks including Sonic 1 Remastered, I might port it to my Sonic 2 hack later.
    3. Also, gif sucks.
     
  3. Twilight

    Twilight

    Member
    51
    0
    6
    Michigan
    A Sonic the Hedgehog hack
    I know. I just thought I should post it, because I haven't seen a tutorial on it yet and I figured out how to do it myself. The reason why the images are in .gif format is because the image host I used doesn't support that many image formats. Yes, I can post the code in ASM tags:

    Code (Text):
    1. loc_13024:
    2.         move.b  $26(a0),d0
    3.         add.b   d1,d0
    4.         move.w  d0,-(sp)
    5.         bsr.w   Sonic_WalkSpeed
    6.         move.w  (sp)+,d0
    7.         tst.w   d1
    8.         bpl.s   locret_1307C
    9.         asl.w   #8,d1
    10.         addi.b  #$20,d0
    11.         andi.b  #$C0,d0
    12.         beq.s   loc_13078
    13.         cmpi.b  #$40,d0
    14.         beq.s   loc_13066
    15.         cmpi.b  #$80,d0
    16.         beq.s   loc_13060
    17.         cmpi.w  #$600,$10(a0)
    18.         bge.s   Sonic_WallRecoil
    19.         add.w   d1,$10(a0)
    20.         bset    #5,$22(a0)
    21.         move.w  #0,$14(a0)
    22.         rts
    23. ; ===========================================================================
    24.  
    25. loc_13060:
    26.         sub.w   d1,$12(a0)
    27.         rts
    28. ; ===========================================================================
    29.  
    30. loc_13066:
    31.         sub.w   d1,$10(a0)
    32.         bset    #5,$22(a0)
    33.         move.w  #0,$14(a0)
    34.         rts
    35. ; ===========================================================================
    36.  
    37. loc_13078:
    38.         add.w   d1,$12(a0)
    39.  
    40. locret_1307C:
    41.         rts
    42. ; ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    43. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
    44.  
    45. Sonic_WallRecoil:       ; CODE XREF: Sonic_Move+180j
    46.                 ; Sonic_Move+1A0j
    47.         move.b  #4,$24(a0)
    48.         bsr.w   Sonic_ResetOnFloor
    49.         bset    #1,$22(a0)
    50.         move.w  #$FE00,d0
    51.         tst.w   $10(a0)
    52.         bpl.s   Sonic_WallRecoil_Right
    53.         neg.w   d0
    54.  
    55. Sonic_WallRecoil_Right:     ; CODE XREF: Sonic_Move+1D2j
    56.         move.w  d0,$10(a0)
    57.         move.w  #$FC00,$12(a0)
    58.         move.w  #0,$14(a0)
    59.         move.b  #$1A,$1C(a0)
    60.         move.b  #1,$25(a0)
    61.         move.w  #$A3,d0; '£'
    62.         jsr (PlaySound_Special).l
    63.         rts
    64. ; End of function Sonic_Move
     
  4. MKAmeX

    MKAmeX

    Member
    279
    0
    16
    California
    Needlemouse, Sonic Boom, Graphic Design
    Awesome! I was trying to port this, but my ASM skills suck, thanks! =D
     
  5. Actually, the GIF format is pretty good for compressing text on a plain background... these GIFs in particular actually suck because they were made from JPGs, so they inherited all the crappy compression artifacts and the overall blurriness.

    About the wall recoil thing, I don't really like it. Losing control of Sonic for a few seconds just because he ran into a wall can get frustrating very quickly. Unless the level layouts are well designed enough to keep that from happening all the time, so I'm curious as to how the hackers will handle that.
     
Thread Status:
Not open for further replies.