Code Types are the way we tell the Switch's CFW what we want it to do in regards to cheats. It's important to note that there are 2 CFW commonly used, SXOS and Atmosphere. At this time the SXOS team has not published an update in over a year and a half, so for all intent and purposes this can be considered a dead CFW (especially since most of the team is either in jail or has court orders forbidding them from working on it). It is important to note that because of this, SXOS only supports a limited amount of Code Types, but Atmosphere supports all of them. As you are just starting out, you will probably be using only basic Code Types, so both CFWs will be able to use them. As you get better, you will want to use the more advance Code Types which only Atmosphere supports. Some SXOS users complain about this, so as a cheat creator, you will need to understand this. Honestly though, people that are still clinging to SXOS are just being stubborn, as there is no chance that SXOS will be updated. So if they want to play the latest games or use better cheat codes, they will need to switch to Atmosphere.
You probably already know how to put cheats on your switch, but it is still important to review the information (which can be found here). Code Types are groups of 8 character blocks. Each Code type will have a different encoding which will change what is required in each set, or how many sets there are, but every set will be 8 characters long. I will break down Code Type 0x0 as an example so you can understand how they are written, then we will go through each one for what it is commonly used for. This is what is displayed on the web page:
The Encoding is what I will be focusing on. Every Code Type has a different encoding but with several similarities. The letters in the encoding will need to be replaced based on the information we have gathered when finding the values we want to create cheats for. Below the encoding will explain what those letters represent and provide a guide on what values are valid.
0TMR00AA AAAAAAAA VVVVVVVV (VVVVVVVV)
The first character is what Code Type it is. In this case it is 0, telling us that it is a Code Type 0x0. The second character is T, which represents how many bytes we are going to replace. So if we found a U32 value, we will want to replace T with 4 (remember 8 bits make 1 byte). The third character is M, which represents what memory region we want to write to. In this case the only valid numbers will be 0, 1, 2, 3, with 0 (MAIN) or 1 (HEAP) being the most common. I have only heard of a handful of games that use 2 (ALIAS) and none that have 3 (true ASLR), but that may change in the future. The fourth character is R, which represents what register we are using for our code. This can be any single hexadecimal number between 0x0 and 0xF. Some cheat creators use this as a calling card. For example, for most of the codes I create, I try to use 0xD. Unfortunately, several cheat creators have found that sometimes a specific register will not work for a specific code in a specific game in a specific region, so if you know you got everything right, and the code is still not working, try changing the register. The fifth and sixth characters are 0, which means they are left blank on purpose. Characters 7-16 are A, which represents the Offset to be added from our memory region's start. This will allow us to target the specific address that we got when we found our value. The remaining characters are V, which represents the Value we want to write to memory. This number is in hexadecimal so if you want to write 0d99, you would need to write 00000063.The Vs inside of the () are optional and don't need to be written, as they are for 64-bit values. If you are writing to 8-bytes, you will need to fill in those Vs in order for the code to work. Now let's go over each of the Code Types and what it is commonly used for. Follow along on the website and see if you can figure out some uses for them.
Code Type Descriptions:
Code Type 0x0: Store Static Value to Memory
This code type will constantly write a value to a static memory address. So for example, we could use this for our Apple Gems to constantly write 0d999 to it.
Code Type 0x1: Begin Conditional Block
This code type is commonly used like an IF statement in most programming languages. This allows the cheat creator to create codes that respond to certain criteria. For example, you could create an hp code that when you have less than 20% hp, this code would set your hp to 100%. This would give the player the feeling of accomplishing something without invincibility, while also allowing the game to force kill the player when needed (I'm sure you have played a game where a boss is invincible and the story wants you to die, this type of code can still allow that to happen).
Code Type 0x2: End Conditional Block
This code type ends any conditional block, like code types 0x1, 0x8, or 0xC0. Not to programmers, this can also be used as an ELSE statement.
Code Type 0x3: Start/End Loop
This is a simple Loop operation. It will repeat whatever is inside of the loop as many times as you set it. Very useful when you need to write something multiple times in a pattern. I will demonstrate this when we do our Gems code.
Code Type 0x4: Load Register with Static Value
This can be used if you need to manually set a value (for example to do Arithmetic to)
Code Type 0x5: Load Register with Memory Value
These are how most code creators write out their pointer instructions
Code Type 0x6: Store Static Value to Register Memory Address
This is how cheat creators write a value to a pointer address written with code type 0x5
Code Type 0x7: Legacy Arithmetic
This is our method of doing math, it has been upgraded to code type 0x9 which has more functionality.
Code Type 0x8: Begin Keypress Conditional Block
This is the code type we use for using button presses to activate codes. Only codes inside the of the block will activate while the button is pressed. At the end you will need a Code Type 0x2 to end the block. You can use codes after the Code Type 0x2 for an “OFF” code.
Code Type 0x9: Perform Arithmetic
This is the method of performing math based on registers. As you can see, it has more functions (namely logical) available than Code Type 0x7.
Code Types 0xA to 0xF
These code types are not commonly used, but generally speaking they are more powerful versions of the previous code types or are just special cases.