A Crystal’s Pony Guide to Data Structures, Part 1

It’s that time of year again, International Review Crystal’s Pony Tale Day to be exact, and I’ve decided to take a slightly different approach to things this time around. Honestly, I covered so much in my review last year that it would be pretty hard to even find new things about the game to talk about if I didn’t go a bit outside the box!

Thankfully, I recently finished a little side project of cramming a bunch of unnecessary achievements into Crystal’s Pony Tale, which has given me a rather unique view on the inner workings of the game (a view which will look fairly consistent from game to game) that I thought would make for an interesting article.

By the end of this, I’m hoping to shed light on a lot of information that could be very helpful to those looking into making video games themselves in the future, or those who are just interested in learning more about how games function.

Note: Due to the informative nature of the following, I will be linking a lot of technical keywords to their respective Wikipedia articles for those who wish to read about them in-depth, while also trying to explain them briefly but effectively in the article itself. So if you come across a link that looks like this: Crystal’s Pony Tale💡, check it out if it seems like something you’d be interested in learning more about!

An Introduction

Have you ever played a game and stopped to think to yourself:
“Where exactly do these items/collectibles go as I pick them up? How did the game even know where to put them where they are in the first place? How does the game remember how much experience my character has? And how does the game know that I beat that boss and should be allowed to enter the next level.”

Oh magical floating horseshoe, what secrets do you hold?

If you are most people, you probably just accepted that the coin that was once on the ground is now in the nicely displayed counter, those well-deserved experience points are now in the bar that is ever closer to hitting that next level up, and the boss was thoroughly beaten as you moved on to the next obstacle or challenge.

If you do actually want to know, however, I welcome you to join me on an adventure through the backstage of videogames known as the RAM, and I promise I am going to make this journey as Crystal’s Pony Tale-related as humanly possible.

Sadly, in this instance, RAM does not stand for “Rather Adorable Mammal”

Random-Access Memory💡

All things related to or using computers operate on the following concept: “temporarily put information we’ll need to use later in a specific spot, and retrieve/change that information as needed at that same spot later”. This is a bit of an over-simplification, but really not a bad way to explain how RAM works in general.

You might be thinking “so the game does just put the information in those counters and bars and just checks those very same counters and bars later!” Unfortunately, it is a little more complicated than that.

In actuality, that information is stored in Bits💡 joined together as Bytes💡 at various Addresses💡 in the memory.

“Woah, slow down!” you yell as I barrage you with a Multiple Light-bulb Link Combo, but fear not!
These 3 concepts are not really that hard to explain, and are much better explained together.

How Game Data Is Stored

Bits (shorthand for Binary💡 Digits) are those 0s and 1s you always hear people talking about with computers, although really it’s more accurate to think of them as the state of being off and the state of being on; the numbers were introduced to make them a little easier to understand to the human operating the computer.

Bytes are a collection of 8 Bits (there have been other sizes, but this is the standard and for sake of consistency the version I’ll be referring to), which makes it easier to differentiate things such as computed letters and computed colors for easy use.

Each of a Byte’s 8 Bits has a different value, as follows:

128 64  32  16  8   4   2   1
0   0   0   0   0   0   0   0

By adding the numbers above the 1’s in a Byte, you come up with your Byte’s value, ranging from 0 all the way to 255. If you are familiar with the concept of the “Kill screen”, the numbers 255 or 256 are probably familiar to you. This is actually 100% related to this concept, and I may write more on that a bit later.

The problem is, even though they are designed to break up the endless stream of Bits and make everything more readable, something like “00100110” (the binary code for ‘&’) and something like “00101010” (the binary code for ‘*’) probably don’t look different enough. As luck would have it, though, we have an even easier system to represent these collections of Bits, and that system is…

Hexadecimal. No, not the villain from ReBoot, but a clever system of 10 digits and 6 letters that can convey half a Byte in a single, easy to read character. The digits 0-9 act as they usually do, while letters A-F act as the numbers 10-15 in alphabetical order. It’s not too dissimilar from playing cards, where the Jack, Queen and King represent the numbers 11, 12 and 13 while not explicitly stating what number they are associated with. Why does it take two to make up a Byte? Let’s look at the values of the first 4 Bits (from the right) again:

8   4   2   1
0   0   0   0

If you add all those numbers together, you get none other than 15, which is the highest Hexadecimal goes with the F letter. Additionally, any number from 0 to 15 can be created from combinations of these 4 digits. So say you had an A in Hexadecimal, that means you’d be trying to get a combination of those numbers that makes 10. It’d end up looking like this:

8   4   2   1
1   0   1   0


In the same way you add new Bits to the left to get higher numbers inside a Byte, by adding a new Hexadecimal digit to the left of the first one, it picks up its next 4 Bits right where the last one left off:

128 64  32  16
0   0   0   0

You would still fill these 0’s and 1’s in as you would if you were trying to make up 15 on the first one, however their values are now worth drastically more and are added in the same way (F0 in Hexadecimal is 240, a whole 225 higher than F by itself!). Hexadecimal is definitely something that takes time to learn, but if you want to become more familiar with it, I’d recommend using a Hexadecimal to Decimal Calculator to try various combinations of Hexadecimal digits out for yourself!

Finally, an Address is simply where in the RAM the Byte(s) in question are stored, and like the name implies, you can think of it as similar to the street address for a house. If you want to send information to a person, you could send it to their address and they will receive it, and if you needed information, you would be able to find them at their address to get it from them. RAM is the same way, you provide an Address (written out in Hexadecimal) and the computer visits that Address to either send or receive the data it needs. Also, in a similar manner to how street addresses go up in number as you go further down a street, the RAM Address is the number of Bytes the computer needs to move from the very first Byte in order to find the Byte(s) it needs, so it is a higher number as the data it needs is stored further and further down.

If RAM was represented as this Farm, the data for Cows would currently be stored in the Barn Address, the data for Hay in the Loft Address and the data for Pony at the Cart Address

How The Data Is Used

Now that we’ve gotten through the joy of how all that data is stored, let’s go on to what it actually means. If you have a grasp of how the values of Hexidecimal work, this is actually pretty easy.

Whole Numbers

Firstly, let’s take a look at data that is just stored as whole numbers (also known as Integers💡), it’s the easiest to look for when exploring game data as it’s constantly changing and as the player, you typically know what you currently have. From Mario’s Coins to Sonic’s Rings to Crystal’s Keys and Horseshoes, as you pick up these objects, the Byte’s value will increase, and as you use and lose them, they decrease.

In the below video, I have tools open that will allow you to watch the RAM values the game is using live; take special note of the value highlighted in the top left window as Horseshoes are gathered throughout the clip:

You’ll notice that while the top-right value and in-game counter go up normally, the highlighted Byte in the RAM goes from 09 to 0A, all the way to 10. This is an example of a Hexadecimal number that can’t be contained in one digit, so it has to make use of the second digit for 16.

True Or False?

In games, there are a lot of things the game needs to know at any given moment that can’t really be counted like the previous value type could. Things like “Can Mario jump right now?”, “Is Sonic spinning and can therefore defeat enemies?”, “Has the player talked to the NPCs that allow them to progress in the story?”

Is Crystal currently neighing? It’s more likely than you’d think

These are often called “flags” or “conditions”, but the real term for these kinds of values is Booleans💡. In a lot of ways, a Boolean is not that different from a single Bit, as it has the same state of being off and state of being on, but because each condition has to be separated so the computer doesn’t get them mixed up, they get an entire Byte to themselves.

Because of this, the only way you’ll ever seen a Boolean in data is:
00 = False
01 = True

Using the “Can the player jump” example from earlier, let’s take a look at that exact flag as found in Crystal’s Pony Tale:

You’ll notice that as long as Crystal is in the air, the highlighted digit is 00, and while she’s on the ground, it’s 01.

These Booleans are what prevent players (or try to, in some cases) from just jumping nonstop into space. In Crystal’s Pony Tale specifically, there are also Booleans for whether or not a player has found each Crystal, rescued each pony, whether or not Crystal is walking, and even whether the game has been started or not. If you ever do anything in a game that progresses the story, chances are there are Booleans to thank for it!

To Be Continued

While I haven’t even fully scratched the surface on all the types of data out there, I think this is a pretty solid start while not being too overwhelming. In the next edition, I’ll talk about more of the types out there, as well as how to crack your favorite retro games open to find all this data for yourself!

What do you think of this post?
  • Hop! 

One Comment

  1. A round of applause for a fascinating piece

Leave a Reply

Your email address will not be published. Required fields are marked *