The Sonic Center

Sonic Central => General Sonic => Topic started by: erockbrox on May 18, 2011, 12:37:30 am

Title: Sonic 2 Chemical Plant How the Pipes Work?
Post by: erockbrox on May 18, 2011, 12:37:30 am
I have been playing Sonic 2 for years. I grew up with the game as a kid but recently I've been trying to figure out how in the heck the pipes work in the Chemical Plant Zones. There are many places where a single entrance to a pipe will split into two different paths and what I need to know is how the game decides what path Sonic will take.

Is this a random element or can the player control what path Sonic will take once he goes into the pipe? Anyone know or have an idea. Thanks.

Oh, by the way I'm brand new here. This is my first post.
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: SadisticMystic on May 18, 2011, 12:41:38 am
It has to do with the parity of the seconds. If it's an odd number you'll go one way, if it's even you'll go the other.
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: EngiNerd on May 18, 2011, 08:22:31 am
You know, I've always wondered that ... thanks
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: Strong Bad on May 18, 2011, 04:02:24 pm
...you didn't know that?
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: Rusty Rom on May 18, 2011, 04:14:40 pm
Well, lemme explain it more precisely. At times finishing in 0,2,4,6 or 8 you go through one way; at times finishing in 1,3,5,7 or 9 you automatically go through the another way.
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: Thorn on May 19, 2011, 12:20:46 pm
Well, lemme explain it more precisely. At times finishing in 0,2,4,6 or 8 you go through one way; at times finishing in 1,3,5,7 or 9 you automatically go through the another way.

It has to do with the parity of the seconds. If it's an odd number you'll go one way, if it's even you'll go the other.

Romulo, how is your way more precise? It's literally the exact same thing.

However,
   move.b   (Timer_second).w,d2
   andi.b   #1,d2

might be more precise, as these two instructions are run in the code for the tube objects any time a tube is found to have more than one branch. The tube object gets the sequence of eight bits formed by the seconds value expressed in binary, then does a logical AND against the sequence of eight bits formed by the number 1 expressed in binary (still 1). This has the effect of creating the value 0 if the seconds value is even (since its bits necessarily end in 0) or 1 if the seconds value is odd (since its bits necessarily end in 1). This value is used later to determine the coordinates the player should be moved to.

Needlessly complex? Yes. Interesting? Probably not. But that is how you be more precise: by showing how the game checks the parity of the seconds.~
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: flyby on May 19, 2011, 07:09:00 pm
He's precisely defining what odd and even mean!
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: SonicandInuyasha on May 20, 2011, 12:57:54 am
Maybe if it's just me. But I really did not know or even care about this. I bet this zone so fast that I did not see that.
Title: Re: Sonic 2 Chemical Plant How the Pipes Work?
Post by: Strong Bad on May 20, 2011, 03:56:09 am
Maybe if it's just me. But I really did not know or even care about this. I bet this zone so fast that I did not see that.
You have green and blue stats on CP1&2.
Stop talking.