Writing

Feed Software, technology, sysadmin war stories, and more.

Monday, December 31, 2012

Boundary conditions exploited by jump and fairy magic

I love finding boundary conditions which weren't handled properly in software. Now and then, I'll be going about my business and will see something which just doesn't seem to be right. Something about the way a piece of code works will make me wonder if they happened to plan for all possible contingencies.

Sometimes, it seems like one feature might not be fully compatible with the way something else works, and that it might be the path to triggering some wacky or strange behavior. When situations permit, I like to try these things to see what happens. This is how I managed to break that multi-disc CD changer way back when.

A couple of years after that happened, I was playing Zelda 2 on the original NES. It was unlike the original Zelda in that a significant part of the game happened in a side view, sort of like the Mario games. There was running and jumping, plus a bunch of places where you'd hit the end of an area and it would stop scrolling. Once you got to that point, you'd actually advance to the edge at which point it would flip to a new screen and start scrolling again.

About halfway through that game, you come to a town where the roofs are solid. By using "jump magic", you can jump high enough to land on one of them. Then you can work your way over and up until you're relatively high on the screen. The official reason for all of this is to drop down a chimney into a house. Normally, you'd just go in the front door, but this one was purposely locked to make it more interesting.

While doing this, I noticed you could actually jump all the way off the top of the screen. Granted, you wouldn't stay up there long due to the "gravity", but for a brief time, your character would be entirely off-screen. I wondered what would happen if I did something to stay up there so I could "explore" that area unseen.

As it turned out, that game had another kind of magic called "fairy". When you used it, you shrank down to the size of the fairies who inhabited bits of the game and refreshed your life. It had another interesting effect: if you switched it on, gravity stopped working on you. You'd float in midair and could move around with the joystick. You couldn't fly off-screen, however.

I figured out a way to have my cake and eat it too. All I had to do was get up on top of the tallest roof, then jump off screen. While off screen, I'd engage fairy magic and that would keep me from falling back into view. Then I'd be free to fly around and look for craziness. I did this and reached the edge of an area. Then I crossed over and things went nuts.

I dropped into a town which looked a lot like the one I had been in, but buildings kept jumping around. It would start scrolling normally, but then things would start painting on top of each other. Entering a house would drop me into another part of town instead of showing me the interior. This insanity continued as I moved around, but then I pushed it too far.

At some point, if you keep doing this, you emerge back on the world map in a spot you should normally never be able to reach. Since it's not supposed to be navigable, you're stuck and have to reset the game to get free. It seems my fun could only go so far.

I guess this sort of thing isn't a big deal any more, since it's trivial to find web pages and videos which describe and even demonstrate it. Still, at least I can feel special for discovering this way back in the day before this sort of thing was well known, right?