Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Generation I Glitch Discussion

What exactly is out of bounds? - Page 1

What exactly is out of bounds?

Posted by: TheUnReturned
Date: 2016-09-23 04:51:59
Stupid question but
Does out of bounds mean "out of the screen" or "out of the current loaded map" or what

Re: What exactly is out of bounds?

Posted by: Charmy
Date: 2016-09-23 06:19:50
The term "out of bounds" means you going out of the area you were supposed to be. Doing so in gen 1 will mostly crasg the game, due to a invalid map connection (to map FF). In gen 2, the game might crash, or corrupt some data.
Gen 3 won't allow you to go out of bounds. Gen 4 leads to the Mystery Zone, and gens 5 and 6 are unknown.
In some games, there are easter eggs out of bounds.

Re: What exactly is out of bounds?

Posted by: Yeniaul
Date: 2016-09-23 08:42:59

The term "out of bounds" means you going out of the area you were supposed to be. Doing so in gen 1 will mostly crasg the game, due to a invalid map connection (to map FF). In gen 2, the game might crash, or corrupt some data.
Gen 3 won't allow you to go out of bounds. Gen 4 leads to the Mystery Zone, and gens 5 and 6 are unknown.
In some games, there are easter eggs out of bounds.
I once got through crash tiles in Gen 1 without warping… I could still see the map I was SUPPOSED to be in, though. Trying to walk back IN crashed (suggesting it's not just a crash due to OOB, but specific tiles, pretty confirming the warp thing even though it doesn't need any more confirmation). I was over near Vermillion (is that right?) and Diglett's Cave. I just… walked out.

Re: What exactly is out of bounds?

Posted by: Krys3000
Date: 2016-09-23 09:30:02
In Gen I, some out of bounds zones reflects the content of WRAM. I'm not sure it was clearly investigated to understand why. But using Walk through walls glitch and the HM Cut, you can actually change WRAM content by cutting trees. This is the basis for GC-RAM manipulation. So yes, out of bounds can be useful! But if you just randomly go out of bounds you will indeed probably hit invalid maps and crash.

Re: What exactly is out of bounds?

Posted by: ISSOtm
Date: 2016-09-24 07:58:35
WARNING : The big post is approaching at full speed.
According to the data, it is known as "OOB EXPLANATION"

OoB is a very simple concept : it means being NOT in the usual area of gameplay ; by that, we mean "the area the developers intended you to be in." It's very common in games where the player moves somebody on-screen (Super Mario Bros., for example) but some games are free of it (Pac-Man).
OoB varies greatly between games. I'll first explain it for Pokémon R/B/Y, then in a more general way - the more you know. Disclaimer : this post contains : 0    tl;dr s.


OoB in Pokémon Gen 1

First, to define what "out of bounds" means, we need to define what "in bounds" means.
Kanto is divided into multiple regions, called "maps". Each map has an assigned ID, unique to said map. Any interior / floor is a map on its own (e.g. each floor of the Celadon Dept Store is a map ; Red's house is two maps : the kitchen and Red's room)
The overworld is composed of several maps (each having a different name in the Town Map), which are linked to eachother via map connections. A map connection is first an ID, then some data to "align" both maps.
Each map's got four connections, one per cardinal direction. When Red walks on exactly one "square" away from the map he is located in, the game reads map connection data to load the map he stepped into.
Please beware that what you see of a linked map is NOT the map, but a copy of it. We will call this copy the connection strip. Remember it for later.
Yet a map may not have all of these connections filled ; to mark a "void" connection, the game uses the ID 255 (there's a reason to that, I won't explain it here because this post is already too long. See our GB Programming wiki page for info on numerical systems).
Even though a connection towards map #255 is a "void" connection, the game may still use it as a valid connection and try to load that map. Because usually map connections with ID 255 are never triggered, the game doesn't bother to check if the validity of the connection's ID. What this means is, let's say Red is Cerulean City, and has the ability to walk through walls. If he exits the map to the north, the game will read data for the north map connection, and load Route 24. Route 24 has no map to the left, so the western map connection has ID is 255. Thus, if Red exits Route 24 to the left, the game will read the connection's data and load map 255. Right now, everything is fine - the map loads properly.
However, each map has a script that is ran during each frame ; trouble is, (almost) every invalid map tries to run code from a place where usually invalid code resides. And, unlucky for us, map 255's script causes a crash as soon as the music fadeout is over.

Why telling about this ? Because, now what Yeniaul said makes sense. It's standing on the connection that yields the crash.
Now, we wanna go out of bounds. Sure, it IS possible - and without crashing ! There are two methods : wrong warping and going out of bounds.
I'll cover the latter first, to clarify what the heck is going on out of bounds. You should definitely read that GB programming page, at least the numeral systems section.

Going out of bounds

Let's start with a simple example. Activate Walk Through Walls (via cheat codes or glitches), go to Sea Route 19 and stand here.
[img]http://glitchcity.info/w/images/f/f4/GCRM_entry_point.png[/img]
Now, you're going to move left until Red is in front of some water. Do not go into the water. This will put you on the left edge of the map. Taking a single step left will have you leave the map on the left.
Now, what's west of Sea Route 19 ? Sea Route 20 ! So, going left will surely take you to Sea Route 20. Okay, walk left. You didn't crash, because you ARE in Sea Route 20.
However, you are out of bounds. Why ? Because of the connection. You see, the northern edge of Sea Route 20 is much lower than the northern edge of Sea Route 19. To accomodate, when transitioning, the game adds / subtracts a number to Red's position, so he will be properly placed on the newly loaded map ; ie his position in the new map will be the same as his position relative to the connection strip.
So, if Red was above the strip in Sea Route 19, he will be above Sea Route 20 !
Note that if Red is just above the strip, he will end up on the northern connection when he enters Sea Route 20… so you get a crash.
Otherwise, you are truly out of bounds ! And now, the serious stuff begins.

Where am I ?
This will also answer Krys' post. And it's quite simple - you just need to understand the basics of memory.
Now, like all game data, map terrain is stored in ROM, whose #1 attribute is that it can't be edited. However, the game needs to apply some modifications to the "basic" map, such as when cutting trees. To do so, the game copies the map to RAM, and edits that copy at will. This copy is also used for rendering - note that connection strips differ here, as they are rendered from ROM.
Copy this : the game uses some RAM values as map data. Do you copy ? It is vital to understand the following.
The game uses Red's position to keep track of which memory address he is "standing on", for collision checks and such. When his position is valid, he stands on one of the memory addresses allocated to the copy of the map. However, when out of bounds, Red goes past this memory region… and the game still reads RAM values as map data, even when said data is not supposed to be interpreted as map data.
To recap : when Red goes out of bounds, the game interprets data past the memory region map data resides in.
To make an analogy, you are controlling a camera for a film. You can scroll around to film different parts of the background ("in-bounds") but if you go too far, you will begin filming the backstage, and it will still be interpreted as a background.
Do you follow ? Good. Now I'm going to correct Krys :

In Gen I, some out of bounds zones reflects the content of WRAM.

That's inexact, because it's not à zone that reflects WRAM content, it's literally the game reading non-map-formatted WRAM and interpreting it as map-formatted WRAM.


Out of bounds in general
Out of bounds greatly differs between games, but usually there are two categories : 2D games and 3D games.
What I described in section "Where am I ?" is a pretty common theme for 2D games - exceptions exist, though.
3D games are much more varied when it comes to out-of-bounds. The first example that comes to my mind is Super Mario 64 and Super Mario 64 DS. The collision is 100% different in both games - even though it seems not. SM64 is very restrictive when it comes to out-of-bounds (the player cannot voluntarily go out of the map, and if they do anyways, it's instant-kill fer ya). SM64DS doesn't prevent player from going out of the map, and has very different wall behavior.
OoB is very complex because it is different in every game (I'd say, mostly 3D games).


Wow, this was a pain to type on my phone (my French autocorrect makes it a hassle), but I hop I was clear. Ask for questions below if you want - I'll try to answer.

Re: What exactly is out of bounds?

Posted by: Yeniaul
Date: 2016-09-24 09:50:53
Well… GG. That's a highly-detailed explanation. Better than I could've explained it.
Oh, and thanks. :D

Re: What exactly is out of bounds?

Posted by: SatoMew
Date: 2016-09-25 13:00:46
That's a very neat insight, ISSOtm. Thanks  :)

Re: What exactly is out of bounds?

Posted by: ISSOtm
Date: 2016-09-27 08:40:02
If anyone wants more explanations like this one, I'm buffed.
MY BODY IS READY

Re: What exactly is out of bounds?

Posted by: Max
Date: 2016-09-28 07:54:46
"Out of bounds" also has a specific meaning when talking about programming. In this context something is out of bounds when a number is outside the expected range, or when an array index exceeds the array's allocated size.

For example if you were storing a number of pokémon in your party and the number exceeded six, you could say the number is out of bounds. Then if you use that number as an index to an array of pokémon data, accessing array indices over six would be considered out of bounds (and would start reading pokémon data from the trainer names, then nick names, then pokédex data).

Re: What exactly is out of bounds?

Posted by: ISSOtm
Date: 2016-09-29 05:17:43
Yes, I forgot that part of the concept. It still matches the more general idea of "out of bounds" being "outside of normal range / expectations". I think that's a literal - and pretty accurate - definition.