Telefang 1 Item Prices/Inventory.

Discuss anything related to hacking ROMs of the Telefang games here.
Post Reply
Blaziken257
Posts: 983
Joined: Fri Dec 22, 2006 11:52 am

Re: Telefang 1 Item Prices/Inventory.

Post by Blaziken257 »

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...
User avatar
andwhyisit
Site Admin
Posts: 1197
Joined: Fri Dec 14, 2007 9:24 pm

Re: Telefang 1 Item Prices/Inventory.

Post by andwhyisit »

Well we could figure out what the others were if we could edit a shop's inventory. That might be something for me to check out later on.
IIMarckus(imported)
Posts: 27
Joined: Tue Dec 25, 2007 4:30 pm

Re: Telefang 1 Item Prices/Inventory.

Post by IIMarckus(imported) »

The sprite data for the first mart is located around offset 0x14C9A0. A group of bytes such as 14 32 01 would make the item (14) gun (01) appear at coords 3×2 (32).

There are 0x42 valid items. Note that 0x00 is a valid item, not a separator or null, meaning these go from 0x00 to 0x41.
Blaziken257
Posts: 983
Joined: Fri Dec 22, 2006 11:52 am

Re: Telefang 1 Item Prices/Inventory.

Post by Blaziken257 »

I kinda understand this... is the first byte of the three always 14? When I try different numbers, it disappears. So is there any other use for this byte?

The other two bytes make sense though. For a reference of item index numbers, look here (this is also used for other things like evolution, experience, and treasure chests):

http://www.datacrystal.org/wiki/Keitai_Denjuu_Telefang:Notes

And the coordinate thing looks like it uses the same format as warps and treasure chests, so that's easy to figure out too.

One very weird thing, though, is that there seems to be a duplicate copy of the data around $18E7F. Why would it be listed twice? I tried editing this duplicate data, but nothing happened. I do know that all other shops besides the first one rotate their items from time to time, with two different sets of items that they sell, so maybe this is the data when it rotates out? That's my only guess.

(As a side note, does anybody know what triggers shops to rotate their items? It seems to happen a lot to me when I buy a lot of a given item in a store, but not always.)
User avatar
Sanqui
Posts: 736
Joined: Sun Dec 16, 2007 12:25 am

Re: Telefang 1 Item Prices/Inventory.

Post by Sanqui »

Their items rotate? o:
Blaziken257
Posts: 983
Joined: Fri Dec 22, 2006 11:52 am

Re: Telefang 1 Item Prices/Inventory.

Post by Blaziken257 »

By rotate I mean they switch out their items and replace them with four others. Then at one point, the shop will switch them back, so it's basically a two-way cycle.

Anyway, I found something else weird. The fourth byte (after the byte that determines a coordinate) also has an effect on the sprite itself. It's all cosmetic, and doesn't affect the item. Basically, if you change it from somewhere between 00-03, it takes the sprite of whatever other item has this value. Like, if you change it from 00 to 01, it will have the same sprite as the second item. Changing it to 02 will have the sprite of the third item, and so on.

If you make it so it's 04 or above, though, it changes to some random sprite. Sometimes it's a sprite with a weird color palette, other times it's a garbled mess. When I changed $14C9BD to 10, I got this:

Image

Additionally, when I went near the sprite, the item name and price text boxes kept flashing, which probably means there's some lag going on.

Also, what's with the four bytes in between each item? Is there room for 8 items or something?
Post Reply