Actions

SCHG How-to

Retain Rings when returning at a Star Post

From Sonic Retro

(Original guide by Mercury) (Additional Step by Esrael)

When Sonic & Knuckles is locked on to Sonic 2, if Knuckles returns from a Special Stage, he'll still have the number of rings he had when he entered it. In addition, if he dies and respawns at a Star Post, he'll have the number of rings he did when he first hit it. This simple guide explains how to activate this in Sonic 2 alone.

Initial Change

(This guide refers to the Xenowhirl 2007 disassembly)

Go to Obj79_LoadData, and remove or comment out this line:

	clr.w	(Ring_count).w

(This command is 4278 FE20 in hex, at an offset of $1F37C in the ROM, if you wish to make the change in raw hex.) Now the player's rings won't be cleared out when respawning at a Star Post.

Additional Steps

(Contributed by Esrael) Now, there are a couple of issues that occur. First of which, if you had 100 or 200 rings prior to entering a special stage, you will receive an extra life (or two!) upon collecting another ring! This is an easy fix. Go back to where you commented out the first line above, that was supposed to clear your ring count. Below it, you'll see this line:

clr.b   (Extra_life_flags).w

Comment this line out. This clears the flag for extra lives per rings, and if that is cleared, and you get another ring, then you will receive an extra life.

Now, the second issue revolves around the fact that you not only retain rings at a Star Post after a Special Stage, but also after death. Knuckles in Sonic 2 does this, but perhaps that may have been a bug. We certainly don't want to reward death and failure with more rings... do we? Let's fix this.

First, let's create a new variable. Addresses $FFFFF100 through $FFFFF5FF are safe since they aren't used in Sonic 2. We then need to name it. That is very easy. Here's an example from Sonic 2 Delta:

Bonus_Stage_Flag equ $FFFFF48E ; Sonic 2 Delta Bonus Flag

You can use any other unused variable name, and any other free Ram Address that you'd like.

Now, let's set the new variable when entering a Special Stage from a Star Post: Insert "move.b #01, (YOUR VARIABLE NAME HERE).w in the following routine: (The example uses the S2 Delta example)

; loc_1F536:
Obj79_Star:
        move.b  collision_property(a0),d0
        beq.w   loc_1F554
        andi.b  #1,d0
        beq.s   +
        move.b  #1,($FFFFF7CD).w
        move.b  #$10,(Game_Mode).w ; => SpecialStage
        move.b  #01, (Bonus_Stage_Flag).w   ; <----- Insert this line to initialize our new variable
+
        clr.b   collision_property(a0)

and finally, insert the following lines in "Obj79_LoadData":

Obj79_LoadData:
        move.b  (Saved_Last_star_pole_hit).w,(Last_star_pole_hit).w
        move.w  (Saved_x_pos).w,(MainCharacter+x_pos).w
        move.w  (Saved_y_pos).w,(MainCharacter+y_pos).w                  
        move.w  (Saved_Ring_count).w,(Ring_count).w
        move.b  (Saved_Extra_life_flags).w,(Extra_life_flags).w

        tst.b   (Bonus_Stage_Flag).w   ; <----- Insert this line. This tests whether or not we just returned from a Bonus Stage.
        bne.s   Exit_Bonus_Stage     ; <----- Insert this line. If we did, this branches us ahead, skipping the ring & lives clear.

        clr.w   (Ring_count).w
        clr.b   (Extra_life_flags).w

Exit_Bonus_Stage:                    ; <----- Insert this line   
        clr.b   (Bonus_Stage_Flag).w   ; <----- Insert this line. This is how we clear the variable. Remember this.  

        move.l  (Saved_Timer).w,(Timer).w
        move.b  #59,(Timer_centisecond).w

Done, now your rings will be retained if you are returning from Special Stage. And remember, it's recommended to clear the variable before loading new level. Did you pay attention to that line I noted above??? If not, go look at the last example again.

Extra Step: Sonic 1 change

(Contributed by Watsonater) There is also a way to perform this in Sonic 1. If you're using the SVN Disassembly, go to Lamp_LoadInfo in .\_incObj\79 Lamppost.asm and remove the following line (or change it to a comment):

		clr.w	(v_rings).w

Now, in vanilla Sonic 1, there would be little reason to have this, unless you wanted to retain rings after a death... BUT, if you implemented a Bonus/Special Stage to be accessed through a lamppost, then there you go!

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Spin Dash Code and Add Spin Dash Speeds | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Add beta spindash to Sonic 2 | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version)
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs