Re: Telefang 1 Item Prices/Inventory.
Posted: Mon Apr 06, 2009 6:28 am
While I still haven't found the data for the items that shops carry, I have found the data for the prices for each item. It's rather simple once you find the data. The data starts at $2E872, and there are two bytes for each item -- basically a 16-bit integer. I'm not sure where the data ends -- more on this later. As far as I know, the order follows the order that the items are stored in the game, like so:
Flamethrower
Gun
Revolver
Bazooka
Machine Gun
Missile
Bomb
Gatling Gun
Sabre
Drill
Jet Engine
Propeller Engine
Shuriken
Battery
Archery Set
Microwave
Iron
Mixer
Telephone
Antenna
Spanner
Saw
Chainsaw
Beam Gun
Axe
Screwdriver
Screw
Spring
Gear
Telecard
Lance
Crane
Army Knife
Sickle
Computer
Laptop
Hammer
Syringe
Camera
Video Camera
Frypan
Pencil
Tire
Gas Tank
Faucet
Bucket
Vacuum
Mouse
Key
Game Machine
Plush
Comic BonBon
Scooter
Titalium
Lunatium
Giamond
Round Medal
Titanyum
Mod Pass 1
Mod Pass 2
Mod Pass 3
Experimental Pass 1
Experimental Pass 2
Experimental Pass 3
I have sampled a few addresses, and confirmed that $2E874-$2E875 is the gun's price, $2E8DC-$2E8DD is the Titalium's price, and $2E8DE-$2E8DF is the Lunatium's price. Which all fits into place.
Also, I know that the last six items can't be bought, but it's included here for completeness sake, and you'll see why I listed them later...
Also, a couple of notes:
- As with many other numerical values that are two bytes long, prices are little endian. This means that bytes are in reverse order, with the least significant byte first. For example, 1000 in decimal is 03 E8 in hex, but in the ROM, the bytes are reversed, so it's stored as E8 03 (for an example, look at bytes $2E8E0-$2E8E1, which is the price for Giamond, which is 1000Ch). Don't let this confuse you!
- I found that if you set a price to 0, you can never buy the item. You'll be told that you don't have enough Chiru to buy the item, which doesn't make sense. So make sure the price is at least 1.
- If you price an item to a 5-digit number (i.e. 10000Ch or higher), then only the last 4 digits will appear on the screen when you are looking at the item, though this doesn't affect the price itself. So to eliminate confusion, only set prices to 9999Ch or less.
- If have enough money and you try to buy an item above 32768 Chiru (or buy multiple items that add up to 32768 Chiru), the game will have trouble subtracting and set your Chiru to 65000 (the cap set by the game), regardless of what you had before buying the items. I think this glitch is related to signed integers. I think that anything higher than 32768 actually loops to -32768 or something like that (even though it doesn't show this in the game), and when you try to buy a really expensive item, it's subtracting a negative number (and therefore adding). And of course, you get so much money that you will always end up getting 65000. Therefore, never set the price of an item to above 32768 Chiru (it shouldn't be above 9999 due to the above point anyway). Also, make sure that in any given area, it isn't possible to spend more than 32768 Chiru at once.
- Even though it isn't possible to buy an item above 65535 Chiru, it is possible to do this when buying multiple items at once (if you make the prices high enough). If this happens, the value will overflow and loop to 0 (in other words, it'll be reduced mod 65535). So for example, if you buy multiple items and they add up to 65600, you will be paying 64 Chiru instead of 65600. So don't make your items too expensive.
Finally, you'd think the data would end at $2E8E5, since this byte is one of the bytes for the price of Titanyum, the last item that you can buy at a shop. But the weird thing is, there seems to be other values that are 16-bit integers. You can tell because nearly all these numbers are round. For example, $2E8E6-2E8E7 is 96 00 = $0096 = 150. $2E8E8-$2E8E9 is C8 00 = $00C8 = 200. You'd think there would only be six of these for the mod/experimental passes (did the programmers initially intend that you can buy the items?), but no. There's even more after that! Do you think there are items that were planned but never used, or are these bytes for some other purpose that we don't know about? This is worth digging into...
Flamethrower
Gun
Revolver
Bazooka
Machine Gun
Missile
Bomb
Gatling Gun
Sabre
Drill
Jet Engine
Propeller Engine
Shuriken
Battery
Archery Set
Microwave
Iron
Mixer
Telephone
Antenna
Spanner
Saw
Chainsaw
Beam Gun
Axe
Screwdriver
Screw
Spring
Gear
Telecard
Lance
Crane
Army Knife
Sickle
Computer
Laptop
Hammer
Syringe
Camera
Video Camera
Frypan
Pencil
Tire
Gas Tank
Faucet
Bucket
Vacuum
Mouse
Key
Game Machine
Plush
Comic BonBon
Scooter
Titalium
Lunatium
Giamond
Round Medal
Titanyum
Mod Pass 1
Mod Pass 2
Mod Pass 3
Experimental Pass 1
Experimental Pass 2
Experimental Pass 3
I have sampled a few addresses, and confirmed that $2E874-$2E875 is the gun's price, $2E8DC-$2E8DD is the Titalium's price, and $2E8DE-$2E8DF is the Lunatium's price. Which all fits into place.
Also, I know that the last six items can't be bought, but it's included here for completeness sake, and you'll see why I listed them later...
Also, a couple of notes:
- As with many other numerical values that are two bytes long, prices are little endian. This means that bytes are in reverse order, with the least significant byte first. For example, 1000 in decimal is 03 E8 in hex, but in the ROM, the bytes are reversed, so it's stored as E8 03 (for an example, look at bytes $2E8E0-$2E8E1, which is the price for Giamond, which is 1000Ch). Don't let this confuse you!
- I found that if you set a price to 0, you can never buy the item. You'll be told that you don't have enough Chiru to buy the item, which doesn't make sense. So make sure the price is at least 1.
- If you price an item to a 5-digit number (i.e. 10000Ch or higher), then only the last 4 digits will appear on the screen when you are looking at the item, though this doesn't affect the price itself. So to eliminate confusion, only set prices to 9999Ch or less.
- If have enough money and you try to buy an item above 32768 Chiru (or buy multiple items that add up to 32768 Chiru), the game will have trouble subtracting and set your Chiru to 65000 (the cap set by the game), regardless of what you had before buying the items. I think this glitch is related to signed integers. I think that anything higher than 32768 actually loops to -32768 or something like that (even though it doesn't show this in the game), and when you try to buy a really expensive item, it's subtracting a negative number (and therefore adding). And of course, you get so much money that you will always end up getting 65000. Therefore, never set the price of an item to above 32768 Chiru (it shouldn't be above 9999 due to the above point anyway). Also, make sure that in any given area, it isn't possible to spend more than 32768 Chiru at once.
- Even though it isn't possible to buy an item above 65535 Chiru, it is possible to do this when buying multiple items at once (if you make the prices high enough). If this happens, the value will overflow and loop to 0 (in other words, it'll be reduced mod 65535). So for example, if you buy multiple items and they add up to 65600, you will be paying 64 Chiru instead of 65600. So don't make your items too expensive.
Finally, you'd think the data would end at $2E8E5, since this byte is one of the bytes for the price of Titanyum, the last item that you can buy at a shop. But the weird thing is, there seems to be other values that are 16-bit integers. You can tell because nearly all these numbers are round. For example, $2E8E6-2E8E7 is 96 00 = $0096 = 150. $2E8E8-$2E8E9 is C8 00 = $00C8 = 200. You'd think there would only be six of these for the mod/experimental passes (did the programmers initially intend that you can buy the items?), but no. There's even more after that! Do you think there are items that were planned but never used, or are these bytes for some other purpose that we don't know about? This is worth digging into...