Types of Storage
There are three important types of storage we will be focusing on. You have your Solid Storage, RAM, and CPU Registers. Solid Storage are devices like Hard Drives, Solid State Drives, or Memory Cards. For the Switch, we are going to focus on the Micro SD Card (or just SD Card for shortness) for Solid Storage. This is the primary storage method for your Switch that maintains the information stored regardless if power is available or not. You can turn off your Switch and take the SD Card out, but you won't lose any information on the SD Card. This will allow us to keep files between game sessions or device restarts. This is known as Non-Volatile Memory or Non-Volatile Storage. The big draw back of this type of storage is that it is generally slow when compared to the others types of storage. We will not go into much detail about this storage method except to explain the how and where of cheat files.
Next is RAM (or Random Access Memory), and it's function is to provide fast access to the game data. Generally, when you see a loading screen, it is because the game is loading information from Solid Storage and placing it in RAM. That is also why some games don't have any loading screens, or very fast loading screen, because the game is small enough to fit the entire game into RAM. RAM is where we will focus 90% of our time while creating cheats. We will want to find a value (let's say player's money) and then change it so that the game thinks we have more money than we actual did. This storage is physically limited inside the Switch. We can't pull it out and put more in (at least for now). If we turn off the console, we lose all the information that was in RAM. This is known as Volatile Memory. Once it loses power the information in the memory is gone. So this isn't viable for long term storage. You should be able to see the trend of the faster the storage is, the more volatile the storage is, and that is doubly so with the last type of storage.
Lastly we have CPU Registers. This is memory that is physically inside the CPU. It is incredibly fast, practically instantaneous. RAM on the other hand takes as little as 3 milliseconds, and Solid Storage can take several seconds. The disadvantage of CPU Registers is that the storage is VERY small (can be as small as a single byte of information), so it can only store enough information to process instructions (things that happen in game, like the player moving). We will be ignoring CPU Registers entirely in this guide, and will only cover it in the Advanced Guide (to be released at a future date).
Integer Value Types
Now that we have discussed how storage is organized, we need to talk about how computers store information in storage. We will start with Integers, which is another way of saying a whole number (no fractions or decimal points here!). Look at the numbers below:
10 10 10
All the same number, right? Except they are not. These are in a different Base numbers (I know that I am cheating but it is for a purpose). Everyone should be familiar with Base10, which is what most of the world uses. Numbers go from 0 to 9 and each position is a multiple of 10. 578 can be broken down as 5 x 100 + 7 x 10 + 8 x 1. How computers work is based on if power is present or not, ON or OFF. These are represented with 0 being OFF, and 1 being ON. So the computer can't understand a number like 5, because it is not ON or OFF. Computers use what is known as a Base2 system (commonly referred to as Binary) where each position is called a bit, and bits are grouped together in sets of 8, known as a byte. Here is an example:
Since Base10 uses each digit position as a multiple of 10, you should recognize that Base2 uses each digit as a multiple of 2. This looks like this for the number 5:
Now the largest number 1 Byte of information that can be stored in Base2 is 255:
Now as you can tell, this isn't very efficient. 255 = 1111 1111, that's a lot of bits to display the same amount of information. What if we grouped that information and used a different Base, that could save some time! If we take a Base2 Byte (remember, that's 8 bits) and we group them in 2 sets of 4 bits (as you may have notice I have been doing), we create 2 groups of 16 possible numbers:
So now we could have a 16 possible number bit, which would be Base16. This is the base principle of computer storage. This is commonly known as Hexadecimal, and is expresses with the numbers 0 through 9, and the letters A, B, C, D, E, and F. Here is a table to explain:
Now if we group Hexadecimal into 8 Bits we get the following:
This gives us a max value of 4,294,967,295. Now that is a large number with only 8 bytes. So a quick review. Base2 (Binary) has a max value of 255 in one Byte (8 bits). Base10 (Decimal) has a max value of 99,999,999 in one Byte. Now computers can only use Binary, they don't understand Decimal or Hexadecimal. So why do we need to know it? The short answer is efficiency. Instead of looking at 1111 1110 1010 0110 1001 1100 0000 0010 (4 Bytes of information, or 32-bits), we can translate that into Hexadecimal and group that together to get a single memory address (we will go into this more later).
I suggest you practice this a little, just to get used to how the numbers interact with each other. You don't need to memorize any of this because most advanced calculators have a “Programmer” mode (Including Windows 10's calculator). If you don't have an advanced calculator, or Windows 10, you can find plenty of browser based calculators online so you can pick one you like. You may see Octal or Base8 but you will not need it for the Nintendo Switch cheats.
It can be very confusing to use 3 different base numbers sets, so programmers tend to use simple methods so that way other programmers (and cheat creators) will know what kind of number they are using. We leave Decimal alone, so if you see 491, it is safe to assume that it means 491, but I have seen people us 0d, so 0d491 is also a possibility. With Binary we simple put 0 in front of the binary number. So the decimal number 7 turns into 0b111. With Hexadecimal we put 0x in front of the number. So decimal 536 turns into 0x218. Now you may have noticed that we have only talked about Positive Numbers! What about Negative Numbers? Well, I hate that you asked but I will explain. We have been talking about Unsigned Integers. These numbers can only be positive. The simple answer here is that a Signed Integers is only able to hold 1/2 the positive values that an Unsigned Integer can. As an example, let's take a Byte of Binary. Instead of the 1st value being worth 128, it now becomes the identifier of if the value is positive or negative (0 being positive and 1 being negative)
This you should now recognize as 84. How about this one:
This is -58. This isn't terribly important as the software we will be using for searches does most of this for you. It is important to understand what it can look like when we get to the intermediate level code searching. If you are interested in learning more about this, we use Two's Complement or a google search for what type of value type you are looking for, like Two's Complement Hexadecimal, and you will find people who can explain it better than myself. We are almost done, we still have 3 more types of values stored in memory.
Other Memory Value Types
The next 3 Value Types are called Boolean, Float, and String. Boolean is a simple yes or no value express as 0 or 1 (Yes is 1, while No is 0). This is usually used by develops to “flag” if a player had completed something, viewed a cut scene, beat a boss, collected a piece of lore, or many other pieces of information. This is usually something we won't be able to search for by itself, but very useful to know when looking through the memory of the game, or editing a save game. The other simple Value Type is a String. A String is any text saved in memory, so things like the Player's Name. These are usually stored in Hexadecimal, but can still be found through creative searches.
Now for Float values. Let's say the developer needs a way to store part of a whole number, like 4.5. A Float is how they could save this information in memory. A Float is any value that isn't a whole number (and sometimes whole numbers too, more on this later). A Float is 32 bits (4 Bytes) that is expressed in Scientific Notation. If you see any number that has a decimal point, or a bar (like a health or stamina bar), it will usually be a Float. Now some of you who have studied software development may be saying “Wait, what about the other data types!”. Well, one, we don't need to worry about them as either they are extremely uncommon, or not searchable and two, thank you for reading this guide, let me know if I made any mistakes. Now, we are here to learn how to make cheats, and cheats require us to find values in memory to edit or freeze.
Now that we have covered what types of memory are, and how information is stored, let's go over how a game is loaded into memory. Current Nintendo Switches have 4 GB of RAM. The Switch Operating System takes some of the RAM, along with anything else running in the background (system modules or certain Home brew apps). This will usually leave us with about 3.4 GB to load the game with. The core component of the game is the MAIN. This is your .exe equivalent on a PC. The MAIN stores all the instructions on how the game is played and how to load more information into RAM when needed (to play a cut scene or change the music). Most of the time, you will not find values in the MAIN, but it can happen. We will cover the MAIN more in the intermediate and expert guides. The second section of memory is called HEAP. HEAP is where most of the information about the game is actually stored. Things like Player Health, Energy Level, Item counts, or other character's stats are all things that could be in the HEAP. MAIN + HEAP covers about 95% of the game's memory, while the remaining 5% is what I'll call OTHER. OTHER is very rarely a concern for us as cheat creators, but it is something to keep in mind. We will now cover what Software you will need to get started.