Retain Rings when returning at a Star Post
From Sonic Retro
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.
(This guide refers to the Xenowhirl 2007 disassembly)
Go to Obj79_LoadData, and remove or comment out this line:
(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.
(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:
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):
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!
|Retain Rings when returning at a Star Post]]