Change Function of Big Ring (Sonic 1)

Discussion in 'Tutorials Archive' started by LucasMadword, Jul 20, 2015.

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

    LucasMadword That one nerd. You know the one. Member

    Joined:
    Jul 18, 2015
    Messages:
    29
    Hello! This is my first tutorial, so I thought I'd do one about modifying code of the Special Stage ring from Sonic 1. I'm using the 2005 Hivebrain Disassembler, so keep that in mind. 

    First, find the code that controls the Big Ring (Obj4B). We're first going to look at Obj4B_Main. So, search that in an editor and you will find this code:

    Obj4B_Main: ; XREF: Obj4B_Index
    move.l #Map_obj4B,4(a0)
    move.w #$2400,2(a0)
    ori.b #4,1(a0)
    move.b #$40,$19(a0)
    tst.b 1(a0)
    bpl.s Obj4B_Animate
    cmpi.b #6,($FFFFFE57).w ; do you have 6 emeralds?
    beq.w Obj4B_Delete ; if yes, branch
    cmpi.w #50,($FFFFFE20).w ; do you have at least 50 rings?
    bcc.s Obj4B_Okay ; if yes, branch
    rts
    Let's change this code so you can enter the ring at 25 rings. The line of code we need to change is cmpi.w #50,($FFFFFE20).w. So, let's change #50 to #25. We end up with:

    cmpi.w #25,($FFFFFE20).w ; do you have at least 25 rings?So, now let's change what the ring does. Let's make it so instead of taking you to the Special Stage, it plays a ring sound and then gives you ten rings. First, we need to comment out the lines that remove Sonic from the scene and the ones that take you to the special stage, as these aren't needed. Search up:

    Obj7C_Collect: ; XREF: Obj7C_ChkDel
    subq.b #1,$1E(a0)
    bpl.s locret_9F76
    move.b #1,$1E(a0)
    addq.b #1,$1A(a0)
    cmpi.b #8,$1A(a0) ; has animation finished?
    bcc.s Obj7C_End ; if yes, branch
    cmpi.b #3,$1A(a0) ; is 3rd frame displayed?
    bne.s locret_9F76 ; if not, branch
    movea.l $3C(a0),a1
    move.b #6,$24(a1) ; delete giant ring object (Obj4B)
    move.b #$1C,($FFFFD01C).w ; make Sonic invisible
    move.b #1,($FFFFF7CD).w ; stop Sonic getting bonuses
    clr.b ($FFFFFE2D).w ; remove invincibility
    clr.b ($FFFFFE2C).w ; remove shield

    locret_9F76:
    rts
    ; ===========================================================================

    Obj7C_End: ; XREF: Obj7C_Collect
    addq.b #2,$24(a0)
    move.w #0,($FFFFD000).w ; remove Sonic object
    addq.l #4,sp
    rts
    ; End of function Obj7C_CollectAnd comment out all of Obj7C_End (excluding the Obj7C_End: line), and the last 4 lines of Obj7C_Collect. This will now let you destroy the ring, and stay in the stage. Now let's make it so we can collect the 10 rings. So, search up Obj4B_PlaySnd.

    Obj4B_PlaySnd:
    move.w #$C3,d0
    jsr (PlaySound_Special).l ; play giant ring sound
    bra.s Obj4B_AnimateComment out the line jsr(PlaySound_Special.l), and add the following lines right before bra.s Obj4B_Animate:

    move.b #$B5,d0 ; play ring sound TPME
    addi.w #$A,($FFFFFE20).w ; add 10 rings to the number of rings you have
    ori.b #1,($FFFFFE1D).w ; update the ring counterYou should now be able to collect your 10 rings at the end of the stage, as long as you have 25 rings to start with! I hope you enjoyed this tutorial, and find use out of it!
     
  2. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    This sort of thing is very basic, and members have done a similar thing like this before, or even bigger edits with the big ring.  Saying that though, you making a tutorial to demonstrate how to edit the big ring, shows that you are getting a lot more confident working with ASM.  I'm glad to see that.  Keep it up!
     
  3. M.N.K.

    M.N.K. In the River of Darkness... Member

    Joined:
    Feb 22, 2009
    Messages:
    506
    Location:
    Earth...
    Like RHS said, this has been done countless times before as editing the code for the big ring is not all that hard, but I will say that this gives others that are new to ASM a basic Idea of how the big ring functions and how they can Customize the code for it so props for that.
     
    Last edited by a moderator: Jul 21, 2015
Thread Status:
Not open for further replies.