I put it off as long as feasible, but with the x-ray climb, I really need to write a walkthrough or something, since everyone will be wondering how everything works. So here it is.
A bit of warning, though. There's a *lot* of brainwork involved in this. You basically have to understand how the game works in order to understand how traveling outside of rooms works. If you happen to program, you'll probably have a good headstart on understanding a lot of this.
I'll be doing everything in hexadecimal unless otherwise noted, since those numbers are usually easier to work with in the game. In case you don't know how to use other number bases, I'll explain it here.
Hexadecimal follows the same rules and everything as decimal (the system almost everyone uses). The only difference is that hexadecimal counts 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10. So '10' in hexadecimal is 16 in decimal. If you do '10 - 1', you get F, or 15 in decimal.
In hexadecimal, 8 * 2 is 10, and 5 * 2 is A. They still mean 'sixteen' and 'ten' in decimal, they're just written in a different form. 5 * 10 is 50, but that '10' means sixteen, and that '50' means eighty.
This form is useful, because computers can easily work with powers of two, and programmers for older systems tend to make use of that.
Now, for the game.
First off, I'm sure you're used to navigating while inside rooms. You can bring up the map by pressing pause, and see where you are exactly.
A few key points of interest: The top left of the room is considered to be the 'origin' (coord 0,0) by the game. Right and down are positive, left and up are negative. And the map assumes that you are at a positive coordinate, making it do weird things when you go left or up that I'll explain later.
Next... Let's explain Samus's position real quick.
Samus's x and y coords are stored as 2 bytes each: XX Y Z. XX is the screen, Y is the block, and Z is the pixel. For these purposes, the pixel isn't much use, so we'll just look at the screen and block.
The screen can go anywhere from 00 to FF. There are no checks on it to make sure it's reasonable, or inside the room, or anything.
You can group both the screen and block together (XXY) to look at blocks, since 10 blocks = 1 screen and XX screens = XX0 blocks. At times it may be convenient to think of it just as XX screens and Y blocks, though. I'll alternate often, depending on what I'm doing.
If you've programmed much before, you should know about overflowing: When the game reaches the biggest number it can hold and tries to add to it, it will just go back to 0. Samus's position is the same. The game will count FFD, FFE, FFF, 000, 001. Subtracting to below 0 yields very large numbers. And again, there are no checks or anything to make sure Samus's position makes sense. I'll explain the impact of that later.
The game calculates what block Samus is touching by turning the x and y coord into a single value, the nth block of the room. The blocks are stored in ram, starting at the top left of the room and going right then down, just like how you'd read a book. To calculate what block Samus is at, it takes her Y position, multiplies it by the width of the room, then adds that to her X position. So, if Samus just came out a door and was at, say, (4,9) in a room that is only one screen wide (10 blocks), the game would calculate Samus to be at the (9*10)+4 block, or 94th block.
The game will continue to use this formula, even when Samus isn't inside the room. So let's say, for some reason, Samus is exactly one screen to the right. Her position would be (14,9), and the game would calculate her to be at the A4th block. This is the same result as if Samus were at (4,A), a single row down. By moving right past the room, Samus has in effect moved down a block, and assumably has her feet stuck in the ground.
If you move right again another screen, Samus will move down another block. Every whole room Samus moves right, everything shifts up a block.
Brown is the original room, blue are repeats, and green is stuff just below the room. Will explain that later.
Each colored block shows the corresponding block in the original room. Enemies do not repeat from room to room; unless you're in the original room, you *cannot* interact with enemies. This includes the Wrecked Ship and Lower Norfair chozo statues, but their hands are solid, Samus's ship (solid, but can't get inside it), moving platforms, and other things I'm probably forgetting to mention.
PLMs, however, *do* repeat. These include doors (all colors), items, scroll blocks (not that they matter), and other things I'm probably forgetting.
Now, what happens when Samus goes below a room? The game will continue to use the formula to calculate what blocks Samus is in contact with. This means that it will start trying to read from data *past* the room as normal blocks. So I better explain the layout, first. Sections are color-coded arbitrarily, don't take them to mean anything. I've tried to size the images according to what you'll normally see.
Here we have the original room you were in. Nothing special.
This is the space immediately below the room. It contains all the BTS data for the room. Since each block is two bytes, and each bts for each block is a single byte, this is always exactly 1/2 as tall as the original room.
If the room has a custom background, this area will be here. Otherwise, it's absorbed by the area below. Backgrounds take the same space as the original room.
I'd estimate about 1 in 4 rooms has a custom background. They're not rare, but don't expect it to be there.
This part is just solid blocks. No passing.
Every time you enter a room, the first 50 (decimal) screens worth of data is overwritten by solid blocks. The game then loads the room and the extra data (bts and background) into the first 50 screens. The size of this section is then 50-(size of room*3/2), or 50-(size of room*5/2) if it has a custom background.
Note that it is perfectly ok for the bts and background data to overflow past the 50th screen. In this case, this section doesn't exist, and any excess of the bts and/or background is simply cut off; they will *not* overwrite the next area.
This is the bts data for the room. This is what the game actually checks when it wants the bts of a block. That's why it's fine if the room is so big that there's no space for the bts in the green part; the game doesn't use that data. I don't know why it bothers to write it there.
This area is always the same size: 25 (decimal) screens, half the size of the maximum room. Unlike the room, however, this data is not cleared whenever you enter a new room.
That means that this data will have leftovers from previous rooms. So, if you travel through a huge room, you'll likely find leftover bts values from that room in the ram (unless you travelled through an even larger room since then).
Next is the background data. Same story as bts data, with only two differences:
1) The area for the background data is twice as large, the same size as the area for the normal room data.
2) It's always composed of air.
Because it's so nondescript, I'll rarely say anything about it. It's just there, a bunch of empty space. In fact, I'm not even accounting it in the images to the right; it would be twice the size of the light blue region, but I think that's a waste of space.
This is the last part of the room. It's uninitialized data. The game *NEVER* writes to this data. So as to what's there... different emulators say different things. I haven't had a chance to check what the SNES says, and I don't even know if what the SNES says will be consistent. Maybe it's virtually random. In any case, it's only a mere 3 screens worth of data. This pic is greatly oversized (about 6 times too big, relatively) just for convenience.
And this is the original room... again. Except even if you actually get to it, you won't be in the original room, but a copy of it.
There's more to it than just a simple loop like this looks like. It'll get pretty confusing before long. >_>
Think of this section as explaining what's *available* to be used as room data. Not all of it necessarily will be used; many rooms don't even reach below the red (solid block) section.
To back track and review a bit, Samus's position is stored as X and Y coords, capable of keeping track of up to FFF blocks (or FF screens). So when you travel right FF screens, everything will be greatly shifted up: Divide the screens traveled by the width of the room and round down to calculate how many blocks up the room has shifted. If you put two and two together, when you head right one more screen, everything will be shifted back down to where it was normally located, because Samus's screen position overflows from FF to 00. And of course, when you head left past 00 screens, everything shifts up greatly.
Going down is more complex, unfortunately. Due to a quirk in the programming, the highest nybble of Samus's y-position is chopped off when calculating what blocks she's in contact with. In simpler terms, Samus's Y position will seem to have a max of FF blocks, or only F screens. Samus's actual position *will* retain up to FFF, so you can only interact with enemies when you're in the actual room, but if you travel 10 screens up or down, you will seem to be in the exact same room you were in earlier.
Now, to try and tie this all together. As far as blocks are concerned, Samus's Y position will only go up to FF blocks, but her X position can go up to FFF blocks. Since the game converts the two to a single block's position, you can multiply the Y position by the width of the room in blocks (just 10 * the number of screens). The farthest block Samus can reach is then (FF*Width)+FFF. Divide the answer by 100 to get the farthest screen Samus can reach. The wider the room, the farther Samus can go.
Or, don't add the FFF, and you can see how far Samus can go just by traveling up or down.
Looking back at the list of available data for the game, you can calculate that narrow rooms (3 or less screens wide) won't reach below the solid blocks (red section) just by travelling vertically. So if you try and go up, you're going to just land in a bunch of solid blocks. Unless the room is really tall and overwrites it all.
Ok, I think I'm good to break out some largescale examples now.
These examples are *very* general guidelines, and exceptions are common. I'm not trying to make these very detailed or accurate, I'm just trying to convey a general idea of what's going on.
This is your typical small room. Anything from 1x1 rooms to about 3x4 fits into this.
You have your original room that you start in. Below it is a small amount of space formed by the bts data. No background data in this image. Solid blocks below that. As you move right, you end up in a copy of the room shifted up a block. Note that the green and red also shift up. After traveling far enough right, in fact, there is no more of the copy or even the bts data below the room, it's just solid blocks. Traveling left thus results in running into a solid wall, and if you travel up, you wind up in solid blocks because the room isn't very wide.
The top left may be open space, though, if you're in a room 3 screens wide. Good luck getting to it, although it's not entirely impossible.
Small rooms are very often dead-ends as far as out-of-room travel is concerned. There are various tricks to try and get past them, though.
Here we have a medium-long width room. Around 5-8 screens wide fits into this category.
Again, moving to the right will eventually shift the solid blocks up past the room. Note that in this case, however, there is open space above the room. By traveling far to the right, it's possible to get from just below the room to on top of it. The light blue space also usually offers several room transitions, so if you know where they are, you can pick and choose how you exit the room.
These rooms are very useful for out-of-room travel.
This is an unusual case... if you have a ridiculously tall (but not very wide) room, there is very little red out there. However, since most of the green will just be repeats, you don't actually have a very wide variety of bts blocks.
It's better than a small room, but it isn't really that useful.
These rooms are fun. :) Basically, a room that's appreciably wide and tall (something like 5x5), so it takes up almost all the solid blocks and gives easy access between different sections.
If you can get outside one of these rooms, you can enter just about any door at any height you like. Very handy. The only thing you need to worry about is hitting random transition blocks while running through the bts data.
In some large rooms, it's possible to go as high or as low as you like, and trigger an x-ray space/time glitch.
With some of the widest rooms in the game, you start seeing weird things. Well. Even weirder things, I guess I should say.
If you're in a wide enough room, you will find an unusually placed repeat of the room when you travel far enough down (or just a bit up). This is because the game reaches so far that the block lookup overflows before Samus's position does, and starts over with the start of the room. In this pic, the pink is that repeat.
Technically, there should be a thin layer of black on top of the pink (to represent the uninitialized data), but I figured I'd keep the pic as simple as reasonable.
Also, note that the repeat doesn't have to be horizontally aligned with the original room. In fact, it's unlikely that it will be. As far as I know, though, there are no rooms in the game that are wide enough to reach *past* the copy of the room, so this pic is kind of an exageration. There are a few rooms that manage to reach the copy of the room, so if you go up above the room, you'll find yourself in the middle of a copy of the room.