What causes glitch worlds/levels in video games?

673 views

The most famous example of this is the minus world, but I find most older games have this glitch. Where the hex byte(s) support warping to more levels that exist in the game, you can warp to glitchy levels.

And there’s also those games where if you are able to go out of bounds enough, you can be met with a scrambled mess of blocks and enemies. Example: https://i.imgur.com/rjiKEmv.png

But why does all this happen? I know why you can access them, but what code in these games loads all of these glitchy levels and blocks rather than it going to a black screen?

In: Technology

Especially in older consoles, the code is written very compactly, with little extra space for extra information.

So, if something is done to overflow an expected value beyond it’s bounds, it creates unexpected results elsewhere, like changing sprites to the wrong location.

In Pokemon (GBA), if you name yourself certain ways and fly from one specific area to another, it spawns Pokemon that shouldn’t even exist, like MissingNo, because it uses the name data where there should be a list of available Pokemon to catch.

The following is *technically incorrect* but *conceptually correct* – simplified for ELI5 purposes.

Level data in, for example, a Mario game, looks like this:

AAAAAAAA
AAAAAAEA
AABBAABB
AACCAACC
AACCAACC
DDDDDDDD

Where A = empty space, B = top of a pipe, C = vertical pipe, and D = brick ground. E = empty space with a Koopa in it. All 24 letters have some different tile and/or enemy associated with them. (In reality games don’t use letters, but might use bytes with 256 values, or 2- or 4-byte pairings etc… but I’m simplifying things here)

(Also, obviously most Mario levels are way bigger than 8×6 tiles, but I’m not typing out more than that!)

When you enter a new level, the code says “OK, go to the 38,794th line in the code and read 6 lines starting there to get the level data.” But sometimes that “38,794” gets corrupted by some bug, and instead the program reads “OK, go to the 12,804th line of code and read 6 lines starting there to get the level data.” And what do we find at the 12,804th line of code?

THE_PRIN
CESS_IS_
IN_ANOTH
ER_CASTL
E.______
WELCOME_

Uh-oh, it’s actual text, meant to get displayed in another place. But our level-building routine doesn’t know that. It just sees letter-codes for various tiles. So it builds a level using those codes. T is a question block, H is the left side of a cloud, E is empty space with a Koopa…

The end result is a nonsensical jumble when viewed as a level.