Another important counting system is "binary". Binary has only two possible digits for each place value: 0 and 1. A binary digit is also called a "bit". In assembly syntax, bits are prefixed by "%".
A byte is made of eight "bits". Because a binary digit has two possible values, and a byte has 8 bits, this means there are 2⁸ possible values in a byte.
For example, a byte can consist of the following bits:
1001 0101. The first bit from the left is called "bit 7" and the final bit is called "bit 0". They are NOT called bits 0-7, nor bits 8-1. Here's an overview:
Bit 7654 3210
The table below shows a relatively easy way to memorize binary, as it displays a pattern.
Note that there is a space inbetween 4 bits for easier readability, although assemblers generally don't accept this syntax. Groups of 4 bits are called "nibbles" and for the purposes of this chapter, they are there to make binary easier to read, because one nibble corresponds to one digit in hexadecimal.
The SNES is capable of working with both 8-bit and 16-bit numbers. While 8-bit numbers are called a byte, 16-bit numbers are called a "word". They would look like they have 16 bits in binary (e.g.
10000101 11010101, which is
$85D5in hexadecimal). In the case of 16-bit numbers, the leftmost bit is called "bit 15" while the rightmost bit is called "bit 0":
1111 11 (read from top to bottom)
Bit 5432 1098 7654 3210
1000 0101 1101 0101
0000 0000 1001 0110
.... .... .... ....
Binary is immensely useful when you're giving a hex value multiple purposes, kind of like an on/off toggle for certain features. These bits are called "flags" and are generally used to save space in the working memory of games.
For example, you can divide a byte into 8 bits with each bit having a different meaning. Bit 7 could indicate that a level has rain or not. Bit 6 could indicate that a level layout is horizontal or vertical. Bit 5 could indicate that the level setting is during day or night, etc. This way you can compress information into a single byte. It would look like this in binary:
││└───── "Is daytime" flag
│└───── "Is horizontal level" flag
└───── "Is raining" flag
Finally, here's an overview of how to count up in decimal, hexadecimal and binary:
Sometimes, bits could be written inconsistently, like
110 0000. This makes the binary number harder to read, because the general convention is to write bits in groups of eight. In order to read them, you will need to add leading 0s to the digits until there are either 8 bits or 16 bits in total.
You can convert between decimal, hexadecimal and binary, by using Windows calculator's "programming" mode. There are also many calculators online which can do this. Assembly syntax accepts decimal and binary also, so you usually don't need to convert between decimal and hexadecimal.