How could some classic Sonic zones be both wrap-around and partially underwater?

In Sonic The Hedgehog, some levels wrapped around from top to bottom. Some levels also have water in them. What confuses me is that a few levels have both. The bottom wraps around to the top, so the notions of up and down become relative, yet part of the map is underwater.

For a good example of such a zone, consider Labyrinth Zone 3 from Sonic 1, which features both an infinite water slide at the beginning and an upward-climbing rising-water chase-scene doom gauntlet boss fight at the end, in which the water rises up about 1.5 times the actual height of the map.

Can anyone explain how they made this work? Is there a "bottom" to the underwater area somewhere, cleverly manipulated so that it is never visible on screen? Or is there something more interesting going on?


Solution 1:

The level tiles vertically, that's why you fall through and come at the same spot again. You can clearly see this in your zone example that if you take the slide down and hit the bottom of the map that you will simply return at the top and go back. The water is programmed to just fall through, the engine just loads the upper and lower part each time you see the split.

As for the underwater zone, there is solid rock at the top causing the water to just stay in place.

Implementation wise, they insert a water flow(s) which cause a horizontal water line (limited by walls) and make those parts under it consist of water; the whole bottom of the level is not made of water.

In the following image, the red arrows are the water lines. Everything below it is water.

If you don't remember the level well, check this speed run which takes the slide and visits the bottom.

Note that it displays water across the walls, it's an animation as drawing it to the walls is too complex.