My god, the explanation for level 7 alone is 1,500 words - this might turn out to be an epic. I just wanted to drop it here to show the kind of approach I'm taking... hopefully it makes more sense once I add the visuals
---------------------------
Level 7 and its weird doors
---------------------------
Level 7 of Repetition of Time is full of doors that don't behave in the way you would expect. In this area you're faced with open gates that you can't walk through, closed gates that you can walk through, and a particularly tricky level exit that has the same sort of Opposite Day behaviour. This is achieved through a particularly involved use of broken room links, combined with some replacement graphics, an arguable bug in the game and some sleight of hand with the level layout that forces the player to take a certain route without making it too obvious.
Once you've survived the very long gauntlet of falling platforms from the starting area on the right, you arrive in the main part of the level - and I'll have to zoom out here to help me explain what's going on. This apparently straightforward arrangement of rooms shifts around like a Rubik's Cube as you move through them, and I'm going to do my best to explain what's going on without anybody's head exploding. I've only got two dimensions to work with here, so I'll attempt to walk through it using the device of multiple different realities or parallel universes as popularized by Super Mario.
You begin this section in what we'll call the yellow reality. You climb over the wall from the right hand side and jump down, with the level layout ensuring that you can't leave this area once you've entered. From here, you have access to five rooms, numbered 9, 10, 11, 12, and 20, which almost all logically link to each other as you would expect. You're apparently free to travel between all of them, but the only way up to the top layer is through room 11. On the way, they'll run over this tile, which has an event ID that points to the exit and therefore opens it.
This is where the player encounters the first sign that things are a bit strange here. They will of course be tempted to dive through the open gate as soon as they see the exit opening, but will be surprised when they bonk their head against it. This is because the open gate is just a replacement graphic for one of the palace's tapestry tiles that isn't used anywhere else in the game - this is what the room looks like in the Apoplexy editor if you load it up without replacing any of the graphics. What the Prince is doing here is essentially running into a wall that's painted to look like an open gate, like so many coyotes chasing after roadrunners.
Eventually the player will give up on that and try exploring upwards. Again, the layout of the level comes into play here by placing this falling tile on the only route upwards - in doing so the game ensures that you must open the exit, and you must cause a broken tile on the right hand side, and both of these things are important for disguising the illusion as the rooms swap over each other.
When the player goes up to room 12 on the top and climbs down the other side of the wall, the first broken room link hits. Instead of pointing back to room 11 with the exit that they just opened, the lower exit from room 12 goes to room 13, which I'm designating as the blue reality. This is a second copy of the exit room that looks almost identical to the one that the player just left - complete with the broken tile on the right hand side, because there's no way to leave room 11 without knocking it down. The player will of course attempt to go through the exit, but will quickly find that the prince just jumps around infuriatingly in front of it. This door, too, is just a painting on the wall - a replaced background tile is responsible, which has been edited to look like an inviting open exit instead of an unremarkable background decoration.
Because the apparently open gate in the middle of the room is still a wall, the player's only option from here is to go to the left, into the space which is now occupied by room 15 in the blue reality. It's only once they drop down and go back to the right on the bottom layer that they return to room 10 and the yellow reality where they started once more, and are free to complete the whole confusing loop again.
Eventually, either by deduction or frustration, the player will be hit with a brainwave to try going through the closed gate in room 12 to see if the weird behaviour of gates and doors extends to it as well - and indeed, will find that this is a door that the player can climb straight through. As you might expect by now, this is another graphical replacement, but it's got an extra step to it. The previous replacements were easy enough because the player wouldn't notice the absence of one of the tapestries or that particular background wall decoration in-game, but the game has precious few walkable tiles available and giving up one of those for this one-off trick would be next to impossible. However, adding one more new graphic was possible without catastrophic levels of hackery due to the way that Prince of Persia's level graphics are stored.
The game has two different tile sets consisting of 72 tiles each - one for palace levels and the other for dungeons. The vast majority of the tiles are shared between both sets - the various floors, torches, windows and objects like spikes and choppers are all represented in the same place in each one. However, there are a couple of gaps in each one where the other tileset doesn't have a direct equivalent - the palace has several arch decorations and tapestries that are blank in the dungeon set, and the dungeon has one tile with a pile of bones that doesn't appear in the palace. This is what KingOfPersia took advantage of - he put a bones tile in this palace level, and added the necessary graphics to the palace DAT file where the game would try to look for the bones graphics, so that the game would draw them like a closed gate. Despite the tile's appearance, the game treats it just like a bones tile, so it thinks it's perfectly walkable just like its dungeon counterpart and so the player can go straight through it unimpeded.
So once you're through the gate, you enter a new room number 14 on the top left, and silently go into what I'm calling the magenta reality. This encompasses room 14 and replacements for all of the other rooms in this section, using slots 16, 17, 18, 20 and 24. From here, your route becomes more straightforward again because once you're in this reality, you can't get back out - these copies of the rooms all link back to each other logically, with the exception of room 14 itself where you can back to room 12 in the yellow reality before you pass the point of no return.
Therefore, the player is now free to make their way back to the exit, which has apparently now closed again - the closing tile that the player is forced over in room 14 drops a hidden gate at the top right of room 18 which the player can never reach, but seeing the closed exit door on their way back around in the third copy of the lower central room numbered 17 gives the player the impression that they've instead closed the exit, despite this not being possible in the game.
What's actually happening is that this is a second copy of the exit - remember that the exit that we opened in room 11 in the yellow reality was the first one, and the one that we saw in room 15 in the blue reality wasn't really an exit, just a background picture. The opening tile that we pressed in room 11 opened the exit, because the tile's event ID was linked to the exit - but understandably, Jordan Mechner never really deliberately defined what happened when a level had more than one exit like this one does. By coincidence, what happens is that all the exits on the level become usable, even though only the exit that the button points to is animated. Therefore, KingOfPersia has a perfect setup to make the player able to run through a closed exit - it's a bug in the game that happened to be there, and he built this entire mind-bending opposite land around that quirk.
There's just one last thing to address. This entire setup uses thirteen of the 24 available rooms, and the running and jumping section at the start of the level is two screens high and ten screens wide. Where did the room for those twenty extra screens come from? The answer is broken room links yet again - the obstacle course with all the falling platforms is ten screens wide, and all of the rooms point to one more single room as their bottom exit. This explains the apparent graphical glitches that I saw on the stream, with platforms falling on the right hand side of the pit being visible on the left. Ten rooms of jumping, one for the pit of death and thirteen for the madness at the end of the level brings the total to exactly 24.