Restore Sonic 1's Prototype Victory

Discussion in 'Tutorials' started by Iso Kilo, Nov 29, 2019.

  1. Iso Kilo

    Iso Kilo Sonic 1 Beta Researcher Member

    Joined:
    Oct 9, 2017
    Messages:
    176
    Location:
    Small Town in BC, Canada
    In pre-release screenshots of Sonic 1, it was shown that Sonic used to have a sort of victory animation during the results screen. However, it was scrapped in the final game, possibly because it looked a bit much like the way a certain rival character jumps.
    [​IMG]
    Thankfully, the animation was still left in the final, and it can be worked with.
    Step 1: Modifying the Signpost
    Most of the code surrounding Sonic's actions, the tally, and whatnot, are controlled by the signpost. So logically, most of the work to be had is there.
    First, go to Obj0D_Index and replace:
    Code:
            dc.w Obj0D_SonicRun-Obj0D_Index
    with:
    Code:
            dc.w GotThroughAct-Obj0D_Index
    Next, go to Obj0D_SonicRun and delete, or comment out all of this:
    Code:
    Obj0D_SonicRun:                ; XREF: Obj0D_Index
            tst.w    ($FFFFFE08).w    ; is debug mode    on?
            bne.w    locret_ECEE    ; if yes, branch
            btst    #1,($FFFFD022).w
            bne.s    loc_EC70
            move.b    #1,($FFFFF7CC).w ; lock    controls
            move.w    #$800,($FFFFF602).w ; make Sonic run to    the right
    
    loc_EC70:
            tst.b    ($FFFFD000).w
            beq.s    loc_EC86
            move.w    ($FFFFD008).w,d0
            move.w    ($FFFFF72A).w,d1
            addi.w    #$128,d1
            cmp.w    d1,d0
            bcs.s    locret_ECEE
    
    loc_EC86:
            addq.b    #2,$24(a0)
    Now if you were to build the ROM, the player can remain on screen after hitting the signpost, instead of running off to the right. But there's a bit of an issue, the player can still run off to the right if they wanted to. It's not necessarily a major issue, but it's still nice to fix. Just go to Obj0D_Touch and under:
    Code:
            bcs.s    locret_EBBA
            cmpi.w    #$20,d0        ; is Sonic within $20 pixels of    the signpost?
            bcc.s    locret_EBBA    ; if not, branch
    place:
    Code:
            move.b  #1,($FFFFF7AA).w ; Lock the screen
    This will now lock the right side of the screen, once you reach it. The next steps are to set up the victory animation itself.
    Directly below GotThroughAct insert this line:
    Code:
            move.b  #1,($FFFFXXXX).w ; Set victory animation flag
    It sets a flag that will be put to use later. Note that you'll have to select a RAM address for this flag, any unused one should do. Now we need to make sure that it gets cleared once the next level starts, or else Sonic will be constantly doing his victory animation after playing 1 level. The fix is pretty simple, in Level_ClrVars3, above:
    Code:
            cmpi.b    #1,($FFFFFE10).w ; is level LZ?
            bne.s    Level_LoadPal    ; if not, branch
            move.w    #$8014,(a6)
    Put a clear instruction for whatever RAM address you've chosen.

    Step 2: Making the Animation Work
    Thankfully, this part is the easiest. Simply go to Sonic_Jump and replace:
    Code:
            move.b    #2,$1C(a0)    ; use "jumping"    animation
    with:
    Code:
    Result_Check:
            tst.b   ($FFFFXXXX).w ; Has the victory animation flag been set?
            beq.s   NormalJump ; If not, branch
            move.b  #$13,$1C(a0) ; Play the victory animation
            bra.s   cont ; Continue
    NormalJump:
            move.b  #2,$1C(a0)    ; use "jumping"    animation
    cont:
    The logic of this works as so: If the victory flag has been set, use the victory animation when Sonic jumps, if not, use the normal jumping animation.

    Now, if everything has been done properly, you should have something like this:
    [​IMG]
     
    Last edited: Dec 2, 2019
    Nick46, MGHACKS, Bluestreak and 5 others like this.
  2. JoenickROS

    JoenickROS ROS is on hiatus. (...again) Member

    Joined:
    Feb 5, 2012
    Messages:
    922
    This has been up for a while so Im surprised no one pointed this out yet.
    Code:
    move.b  #1,($FFFFXXXX).w ; Set victory animation flag
    
    Result_Check:
           tst.w   ($FFFFXXXX).w ; Has the victory animation flag been set?
           beq.s   NormalJump ; If not, branch
    
    See the issue here?
     
  3. Iso Kilo

    Iso Kilo Sonic 1 Beta Researcher Member

    Joined:
    Oct 9, 2017
    Messages:
    176
    Location:
    Small Town in BC, Canada
    Edit, actually nevermind. The tst command checks if the source is zero. If the animation flag is zero then Sonic should branch to a normal jump. It works as intended.
    Edit 2, oh. I set it to a word.
     
  4. MGHACKS

    MGHACKS Hey there! Bet you didn't find me around Member

    Joined:
    Aug 7, 2019
    Messages:
    57
    Any reason why the victory animation is still there? Even after sorting out the RAM address, it still continues the animation. Can you be a bit specific about "Level_ClrVars3" for my understanding?
     
  5. Iso Kilo

    Iso Kilo Sonic 1 Beta Researcher Member

    Joined:
    Oct 9, 2017
    Messages:
    176
    Location:
    Small Town in BC, Canada
    The victory animation flag needs to be cleared just above the check for Labyrinth Zone.
     
    MGHACKS likes this.
  6. SoniMania2000

    SoniMania2000 Newcomer Trialist

    Joined:
    Saturday
    Messages:
    5
    It's astounding that people can do this!
     
  7. Bluestreak

    Bluestreak Lady in red, living in dread. Member

    Joined:
    Apr 1, 2016
    Messages:
    189
    Location:
    Eastwatch Island
    I'm new to this, so how should I write the clear instruction for the RAM address I decided to use for the victory animation? I'm using GitHub btw. The other parts I understood just fine.
     
  8. LoganTheSonicPlayer

    LoganTheSonicPlayer Rom Hacker Trialist

    Joined:
    Oct 27, 2015
    Messages:
    16
    Location:
    Bridge Zone
    Ok, so, there's two ways you can do it.

    The first one is moving 0 to the ram address:
    Code:
    move.b  #0,($FFFFXXXX).w
    However, there's a instruction made just for this, which, IIRC, is also quicker. This instruction is called clr (Clear). Using the above instruction as a guide, this should be the instruction you get for clearing the RAM address:
    Code:
    clr.b  ($FFFFXXXX).w
    Hopefully, that helps you with this guide.
     
    Iso Kilo likes this.
  9. Bluestreak

    Bluestreak Lady in red, living in dread. Member

    Joined:
    Apr 1, 2016
    Messages:
    189
    Location:
    Eastwatch Island
    Thank you! This will come in handy in the future.
     
    LoganTheSonicPlayer likes this.