I like to hack saved game files. It’s just something I’ve done for many years now. I got into that kind of stuff back when I first started getting into computers.
I’ve hacked a lot of different games now. For a lot of different systems too. I’ve hacked many NES, SNES, Sega Genesis, N64, and PC games. One of the fun things about hacking a save file is learning how that game went about storing/writing the data of the game. A lot of games seem to go about it different ways. I think overall I’ve seen a pretty popular way of doing it, and some extremely random unoptimized way of doing it (or perhaps I never understood the reasoning behind their storage methods).
Item IDs
Any game that has Items uses Item IDs, some way of identifying which item the item is. Is this item a sword, a potion, or a key?
NES, SNES and Sega Genesis games are usually straight forward about how to do this. They usually only use 1 byte for the Item ID, and they use the full range. And almost always, 00 is used as the “Empty” spot in the Inventory. I’ve also seen 255 used as “Empty”. Like in Final Fantasy 3 (My favorite game, btw), there’s only 1 byte used for the Item ID, so there are only 255 items in the game. Imagine my surprise (and anger) when I learned that there was no Paladin Ring! I spent months trying to farm that ring. But the internet wasn’t around back then and the rumors insisted that the item was real and that it existed… Yea. It didn’t exist as I found out years later, from hacking all the items into the game. And for all those jerks out there insisting that the Paladin Ring is real… YOU’RE A JERK!
*Deep breath*
Anyways.
When it comes to PC Items, the ID always seems to be 4 bytes (signed or unsigned, who knows) values. In some games, it seems randomly generated. Just take a look at some of the Item IDs of Summoner:

Now I understand that I’m not seeing the full picture of the Item IDs, not having access to the code of such a great game, but still… why are the Item IDs so seemingly random? Why not just go 0 through number of items in the game and save time?
In other PC games, the Item ID starts at some value, then each item after that is a certain value more than the last item’s value. Take Recettear for example.
Worn Sword ID = 64
Rusty Dagger = 6464
Focus Staff = 12864
Wooden Bow = 19264
See the pattern? Now I have no idea what the next category of items is… but I bet I know it’s value: 25664.
Inventory Layout
Usually the layout I see with inventories in save files is this
[ItemA ID][ItemB ID][ItemC ID]… (after whole inventory listed) [ItemA Quantity][ItemB Quantity][ItemC Quantity]… (for every item)
That works really well. ESPECIALLY if you have a fixed inventory size (like a lot of old console games did back then). Usually console games like to have a set size for their save files (Because they have a specific layout of the save file).
Some games don’t have a quantity at all, but rather, just repeat the item ID over and over in the inventory for the quantity that you have. Super Mario RPG is an example of a game like that.
One of the more interesting ones I saw is how Lufia 2 does it’s inventory.. Each item is 2 bytes long, but there are less than 512 items in the game.. so although the lower byte is completely used, the 2nd byte is only ever 00 or 01… but this isn’t what makes Lufia 2′s inventory system neat. Lufia 2 also uses the higher byte to store the quantity of the item. It takes the quantity, doubles it, and adds it to the higher byte. So if you have an item who’s ID is 0×0100, (1 in hex, with little endian ordering), if you want 99 of that item, you take 99, double it to 198, convert 198 to hex (C6), and add that to the higher byte: 01C6. So that gives you 99 of 0100.
It can get confusing when your Item IDs aren’t clean looking to begin with.
Why… On… Earth…?
The last game I made a hack program for… had such a weird system for their items. You can have up to 15,000 items in your inventory. Instead of writing out Item ID, and then Item quantity… it just writes out the Item ID over and over and over until for as many of that item as you have. This makes the save file for that game HUGE. 17.8 MB. I don’t see too many save files that are in MB’s like this.
I honestly think out of all the systems, the most efficient is something that writes out the Item ID, and then a Quantity somewhere as well. That way your inventory only has to be big enough to hold as many items in the game that exist. So if you have 256 items (including “Empty” slots) in your game, and you can only hold 99 of each item at the most ever… You could store your whole inventory as 512 bytes. Efficient.
Recettear,… the game with the 17.8 MB save file, only has 538 items in it’s game. Being generous, you could use 8 bytes per item, a 4 byte ID, and a 4 byte quantity, and be able to hold farrrrrrrrrrrr more items with farrrrrrrrrrr less space. Instead it uses 4 byte ID, and no quantity, and pastes the ID over and over, capping at 15K items. That means at most you could have 27-ish of each item in the game (I did int division, so no remainder (15000/538 = 27)). That’s pathetic. Whereas with 8 bytes per item, 538 items… That’s 4,304 bytes, and it allows you to have BILLIONS of EACH item. Efficient. Okay. Rant over.
I’ve hacked a lot of different games now. For a lot of different systems too. I’ve hacked many NES, SNES, Sega Genesis, N64, and PC games. One of the fun things about hacking a save file is learning how that game went about storing/writing the data of the game. A lot of games seem to go about it different ways. I think overall I’ve seen a pretty popular way of doing it, and some extremely random unoptimized way of doing it (or perhaps I never understood the reasoning behind their storage methods).
Item IDs
Any game that has Items uses Item IDs, some way of identifying which item the item is. Is this item a sword, a potion, or a key?
NES, SNES and Sega Genesis games are usually straight forward about how to do this. They usually only use 1 byte for the Item ID, and they use the full range. And almost always, 00 is used as the “Empty” spot in the Inventory. I’ve also seen 255 used as “Empty”. Like in Final Fantasy 3 (My favorite game, btw), there’s only 1 byte used for the Item ID, so there are only 255 items in the game. Imagine my surprise (and anger) when I learned that there was no Paladin Ring! I spent months trying to farm that ring. But the internet wasn’t around back then and the rumors insisted that the item was real and that it existed… Yea. It didn’t exist as I found out years later, from hacking all the items into the game. And for all those jerks out there insisting that the Paladin Ring is real… YOU’RE A JERK!
*Deep breath*
Anyways.
When it comes to PC Items, the ID always seems to be 4 bytes (signed or unsigned, who knows) values. In some games, it seems randomly generated. Just take a look at some of the Item IDs of Summoner:

Now I understand that I’m not seeing the full picture of the Item IDs, not having access to the code of such a great game, but still… why are the Item IDs so seemingly random? Why not just go 0 through number of items in the game and save time?
In other PC games, the Item ID starts at some value, then each item after that is a certain value more than the last item’s value. Take Recettear for example.
Worn Sword ID = 64
Rusty Dagger = 6464
Focus Staff = 12864
Wooden Bow = 19264
See the pattern? Now I have no idea what the next category of items is… but I bet I know it’s value: 25664.
Inventory Layout
Usually the layout I see with inventories in save files is this
[ItemA ID][ItemB ID][ItemC ID]… (after whole inventory listed) [ItemA Quantity][ItemB Quantity][ItemC Quantity]… (for every item)
That works really well. ESPECIALLY if you have a fixed inventory size (like a lot of old console games did back then). Usually console games like to have a set size for their save files (Because they have a specific layout of the save file).
Some games don’t have a quantity at all, but rather, just repeat the item ID over and over in the inventory for the quantity that you have. Super Mario RPG is an example of a game like that.
One of the more interesting ones I saw is how Lufia 2 does it’s inventory.. Each item is 2 bytes long, but there are less than 512 items in the game.. so although the lower byte is completely used, the 2nd byte is only ever 00 or 01… but this isn’t what makes Lufia 2′s inventory system neat. Lufia 2 also uses the higher byte to store the quantity of the item. It takes the quantity, doubles it, and adds it to the higher byte. So if you have an item who’s ID is 0×0100, (1 in hex, with little endian ordering), if you want 99 of that item, you take 99, double it to 198, convert 198 to hex (C6), and add that to the higher byte: 01C6. So that gives you 99 of 0100.
It can get confusing when your Item IDs aren’t clean looking to begin with.
Why… On… Earth…?
The last game I made a hack program for… had such a weird system for their items. You can have up to 15,000 items in your inventory. Instead of writing out Item ID, and then Item quantity… it just writes out the Item ID over and over and over until for as many of that item as you have. This makes the save file for that game HUGE. 17.8 MB. I don’t see too many save files that are in MB’s like this.
I honestly think out of all the systems, the most efficient is something that writes out the Item ID, and then a Quantity somewhere as well. That way your inventory only has to be big enough to hold as many items in the game that exist. So if you have 256 items (including “Empty” slots) in your game, and you can only hold 99 of each item at the most ever… You could store your whole inventory as 512 bytes. Efficient.
Recettear,… the game with the 17.8 MB save file, only has 538 items in it’s game. Being generous, you could use 8 bytes per item, a 4 byte ID, and a 4 byte quantity, and be able to hold farrrrrrrrrrrr more items with farrrrrrrrrrr less space. Instead it uses 4 byte ID, and no quantity, and pastes the ID over and over, capping at 15K items. That means at most you could have 27-ish of each item in the game (I did int division, so no remainder (15000/538 = 27)). That’s pathetic. Whereas with 8 bytes per item, 538 items… That’s 4,304 bytes, and it allows you to have BILLIONS of EACH item. Efficient. Okay. Rant over.








