Nifflas' Support Forum
Released Games => Knytt Stories => Topic started by: Polana on June 25, 2012, 22:36:37
-
Hi,
I always wonder, why there 255 tilesets, 255 gradients, 255 banks of objects, etc. in the editor. Why not 250 or 300 or some other "round" number ? Is it something in the program ?
-
there are 256, because it goes from 0 to 255.
256 is a value that in the computer world is called a byte. You have a value that has 256 unique possibilities, so you can use one byte per item to keep it the most simple. Otherwise, you have to combine 2 bytes and that involves math. True, also more possibilities, but also a bigger file.
Also: http://256.com/256.html
-
Actually, it's 256 distinct numbers because "0" is a number, too.
A computer uses binary digits, 1 and 0. If you have 1 byte = 8 bits, your smallest binary number is 0000 0000, and your biggest number is 1111 1111 (=>2^8-1, or 255 in decimal systems).
So the index system in the editor uses a single byte to store indices.
300 in decimal becomes 1 0010 1100 in binary. It would have 9 bits instead of 8, but you can't just take single additional bits from your memory, because your memory is organized in bytes. You would need two bytes to handle a number as big as 300.
Then again with two bytes, you would have 65536(=2^16) different numbers. Altough you could force your program to reject numbers that are bigger than 300, there would be no logical reason to restrict it to 300
And 250 becomes 1111 1010. My computer doesn't think it's a "round" number :^^:
Edit:LPChip beat me to it :(
-
If you look closely you will find this kind of limitation in many other games, like the 255 rupee limit in The Legend of Zelda. 8-bit videogames are a great example because they often struggled with memory problems.
-
Thank you.
How could I forgot about zero! With 256 it makes perfect sense. I should think more before I ask about something.
-
Actually, it reminds me quite a lot of 256 colours. Even though it seems a bit off-topic, they both seem very similar.
-
Actually, it reminds me quite a lot of 256 colours. Even though it seems a bit off-topic, they both seem very similar.
It is. 256 (and 255, for that matter) is a very common number in computing, for the exact reason LPChip mentioned.