Back when the first Sonic game was released in 1991, developers had to get extremely creative with console hardware. While we take physics for granted in games now, it was a tricky business making objects jump, fall and otherwise move correctly back then. These days, with the ability to dive into old ROMs for the likes of the Mega Drive, we can see exactly how ingenious these coders were.
The place you want to start is the Sonic Physics Guide over on Sonic Retro. This index page has links to sub-sections including the basics — running, jumping, rolling, etc. — through to the more complex — springs, underwater effects and so forth.
Take what sounds really simple — standing on a solid surface. But what happens if the surface isn't precisely flat? Not a problem in 2016 (or even 2006), but in the early 90s, the Sonic guys used "height masks" to differentiate... well, heights.
Basically, the Sonic character has two "sensors", A and B, which were linked to his left and right sides respectively. For Sonic to fall, both sensors had to report a "no contact" situation. By using two sensors, the developers could also detect when Sonic wasn't on flat ground, based on the height of the sensors relative to each other.
Any time the A or B sensors find a solid tile, they return the height of that tile. How is the height of the tile found? Each tile has a value associated with it that references a mask stored in memory. Each mask is simply an array of 16 height values that range from $00 to $10, and an angle value.
Here's what a height map might look like.
This method didn't always work however:
Unfortunately, there are a couple of annoying bugs in the original engine because of this method. If Sonic stands on a slanted ledge, one sensor will find no tile, and return a height of foot level. This causes Sonic to be set to the wrong position.
That explains the scenario in this image, which I'm sure anyone who's played the original Sonic games would remember.
All the sections are worth a read and can even be strangely nostalgic (like the above). It's really quite amazing what Sega was able to achieve decades ago.
Sonic Physics Guide [Sonic Retro]