How to add new moves in Sonic 1

Discussion in 'Tutorials Archive' started by Ravenfreak, Aug 26, 2010.

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

    Ravenfreak Still hacking the 8-bit titles Member

    Joined:
    Feb 10, 2010
    Messages:
    410
    Location:
    O'Fallon, MO
    Copy pasta from SR (Yes I wrote this guide. xP):


    So you want to add a new move to your Sonic 1 hack but you don't know where to start? That's what this guide is for! This guide will cover the SVN disassembly. As an example for this guide, I'll give Sonic the ability to be invincible without having to destroy the monitor that contains the power-up. Okay to start, you want to open sonic.asm in your favorite text editor. (I recommend using ConTEXT, but you don't have to.) Next you want to find the word "Modes". This is what the code should look like:



    ; ---------------------------------------------------------------------------
    ; Modes for controlling Sonic


    ; ----------------------------------------------------------------------------------


    Sonic_MdNormal: ; XREF: Sonic_Modes


    bsr.w Sonic_Jump


    bsr.w Sonic_SlopeResist


    bsr.w Sonic_Move


    bsr.w Sonic_Roll


    bsr.w Sonic_LevelBound


    jsr SpeedToPos


    bsr.w Sonic_AnglePos


    bsr.w Sonic_SlopeRepel


    rts



    As you can see, these are Sonic's moves, and each are stored in subroutines.(It's like this in S2 & S3K also if you didn't know that.) So now, we are going to add the code to make Sonic invincible from the start! So right after Sonic_MdNormal add bsr.w Sonic_Invinc. (Remember, this is an example. You can name the label whatever you want and give Sonic any ability you want if you know how, but you must always have the correct operation, in this case bsr.w which stands for "branch to subroutine", otherwise you'll get build errors.)This is what the new code should look like:



    ; ---------------------------------------------------------------------------
    ; Modes for controlling Sonic


    ; ----------------------------------------------------------------------------------


    Sonic_MdNormal: ; XREF: Sonic_Modes


    bsr.w Sonic_Invinc


    bsr.w Sonic_Jump


    bsr.w Sonic_SlopeResist


    bsr.w Sonic_Move


    bsr.w Sonic_Roll


    bsr.w Sonic_LevelBound


    jsr SpeedToPos


    bsr.w Sonic_AnglePos


    bsr.w Sonic_SlopeRepel


    rts



    So that's a start, now you have to create the subroutine to give Sonic the new move. This is a very simple thing to do, first locate the _incObj folder. This is where each subroutine is located at. Scroll down until you see SonicJump.asm. Open it in a text editor, select the whole file and paste it to a blank template. This is what Sonic Jump.asm looks like:



    ; ---------------------------------------------------------------------------
    ; Subroutine allowing Sonic to jump


    ; ----------------------------------------------------------------------------------


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


    Sonic_Jump: ; XREF: Obj01_MdNormal; Obj01_MdRoll


    move.b (v_jpadpress2).w,d0


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


    beq.w locret_1348E ; if not, branch


    moveq #0,d0


    move.b obAngle(a0),d0


    addi.b #$80,d0


    bsr.w sub_14D48


    cmpi.w #6,d1


    blt.w locret_1348E


    move.w #$680,d2


    btst #6,obStatus(a0)


    beq.s loc_1341C


    move.w #$380,d2


    loc_1341C:


    moveq #0,d0


    move.b obAngle(a0),d0


    subi.b #$40,d0


    jsr (CalcSine).l


    muls.w d2,d1


    asr.l #8,d1


    add.w d1,obVelX(a0) ; make Sonic jump


    muls.w d2,d0


    asr.l #8,d0


    add.w d0,obVelY(a0) ; make Sonic jump


    bset #1,obStatus(a0)


    bclr #5,obStatus(a0)


    addq.l #4,sp


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


    clr.b $38(a0)


    sfx sfx_Jump ; play jumping sound


    move.b #$13,obWidth(a0)


    move.b #9,obHeight(a0)


    btst #2,obStatus(a0)


    bne.s loc_13490


    move.b #$E,obWidth(a0)


    move.b #7,obHeight(a0)


    move.b #id_Roll,obAnim(a0) ; use "jumping" animation


    bset #2,obStatus(a0)


    addq.w #5,obY(a0)


    locret_1348E:


    rts


    ; ===========================================================================


    loc_13490:


    bset #4,obStatus(a0)


    rts


    ; End of function Sonic_Jump



    Next, you want to change that to this:



    ; ---------------------------------------------------------------------------
    ; Subroutine to make Sonic Invincible from the start of the game


    ; ----------------------------------------------------------------------------------


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


    Sonic_Invinc:


    move.b #1,(v_invinc).w ; make Sonic invincible


    rts


    ; End of subroutine Sonic_Invinc



    Name the file Sonic Invincible.asm, and save it to the _incObj folder. So the subroutine is there, but you're not done yet. Open sonic.asm again if it's not already opened. Make a search for "Sonic Jump." You should see this:



    locret_13302:
    rts


    include "_incObj\Sonic LevelBound.asm"


    include "_incObj\Sonic Roll.asm"


    include "_incObj\Sonic Jump.asm"


    include "_incObj\Sonic JumpHeight.asm"


    include "_incObj\Sonic SlopeResist.asm"


    include "_incObj\Sonic RollRepel.asm"


    include "_incObj\Sonic SlopeRepel.asm"


    include "_incObj\Sonic JumpAngle.asm"


    include "_incObj\Sonic Floor.asm"


    include "_incObj\Sonic ResetOnFloor.asm"


    include "_incObj\Sonic (part 2).asm"


    include "_incObj\Sonic Loops.asm"


    include "_incObj\Sonic Animate.asm"


    include "_anim\Sonic.asm"


    include "_incObj\Sonic LoadGfx.asm"



    This tells the compiler to also include the files located in the folder. You must change this in order for it to build, otherwise it'll never find the move you added. xP After include "_incObj\Sonic Roll.asm", add this:



    include "_incObj\Sonic Animate.asm"



    Next, build your ROM and your new ability should work! Keep in mind that if you want to add an object with Sonic's new move, you should look at this guide written by Malevolence and MarkeyJester:http://info.sonicretro.org/SCHG_How-to:Work_with_Objects to set things up. Also this code does work, but it doesn't load the stars object because I didn't add the code that loads the objects since after all, it's an example. xP
     
  2. Hanoch

    Hanoch Well-Known Member Member

    Joined:
    Aug 3, 2008
    Messages:
    312
    Location:
    Israel
    If it doesn't have a button check, than its not a move. Its just adding something to sonic's routine gameplay.
     
Thread Status:
Not open for further replies.