Author Topic: Item format?  (Read 6235 times)

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Item format?
« on: 2004-07-18 15:56:42 »
I'm running into a problem where some entities are being expressed in two different ways. The biggest offenders are items.

The 319 items that are expressed with two bytes. This doesn't seem to be a problem, bit it appears that Squaresoft *REALLY* only wanted it to be expressed in one byte (Max 256 items), but at the last minute extended it in two different ways.

The inventory uses two bytes, the first being the item ID and the second being the amount, but depending on if the value is even or odd, tells what the item is and then they divide the amount by two to reach a "correct" inventory amount.

scene.bin also uses two bytes to express items that can be stolen or won after battle, however according to the documentaion I have it expicitly numbers the item from 0-318. Is that true? If so, then how do you express when you win more than one item after battle. (Or can you only steal one thing/win one thing from each monster)

Just want to keep the documentaion stright.

Qhimm

  • Founder
  • *
  • Posts: 1996
    • View Profile
    • Qhimm.com
Item format?
« Reply #1 on: 2004-07-18 16:10:01 »
From what I remember when working with FF7 memory, items can either be stored with ID and quantity as separate values, or combined into a single 16-bit value. In the latter case, the item ID would use up the 9 lower bits (0-511) and the quantity the upper 7 bits (0-127). Or it could be the other order, I don't remember exactly.

So when this 16-bit value is stored in memory, it becomes
Code: [Select]
Byte 1   Byte 2
xxxxxxxx yyyyyyyx

Where x would be the item ID (the x in the second byte being the most significant one, then the other 8 bits stored "normally" in byte 1) and y the item quantity.

Terence Fergusson

  • *
  • Posts: 262
    • View Profile
Item format?
« Reply #2 on: 2004-07-18 16:46:12 »
And yes, you can only ever win, steal or morph one item from any enemy.

EmperorSteele

  • *
  • Posts: 933
    • View Profile
Item format?
« Reply #3 on: 2004-07-18 18:34:19 »
However, some enemys you can steal from, then morph, AND win another item, to bootmost are just 2 out of 3 though.  Dunno if that ahs any relevance, but TFs comment made me think of that...

Terence Fergusson

  • *
  • Posts: 262
    • View Profile
Item format?
« Reply #4 on: 2004-07-18 18:43:11 »
Yes, but you never get to steal, say, 40 Hi-Potions at a time like you can in some FFs, hence, the game does not have to store quantity data with the enemies.

Cyberman

  • *
  • Posts: 1572
    • View Profile
Item format?
« Reply #5 on: 2004-07-19 15:29:28 »
Quote from: Terence Fergusson
Yes, but you never get to steal, say, 40 Hi-Potions at a time like you can in some FFs, hence, the game does not have to store quantity data with the enemies.

That's really interesting, now that I think about it, that obviously has to do with the way the engine is set up.  

Does anyone know if you can recieve more than just one of anything at a time in the game, because I don't think you can, it either gives you one, or repeateldly gives you one N times.  I don't ever remember getting multiples save at a store.

Cyb

Terence Fergusson

  • *
  • Posts: 262
    • View Profile
Item format?
« Reply #6 on: 2004-07-19 16:34:52 »
You can get multiples *fine* outside of battle.  Fort Condor is the perfect example.  It's just inside battles where it gets thorny.

Messiah99

  • *
  • Posts: 235
    • View Profile
Item format?
« Reply #7 on: 2004-07-20 08:41:30 »
Quote from: Terence Fergusson
You can get multiples *fine* outside of battle.  Fort Condor is the perfect example.  It's just inside battles where it gets thorny.

Example 2 would be the Junon parade, once when you get the TV ratings up and can get multiple potoins.

Darkdevil

  • *
  • Posts: 728
    • View Profile
    • Http://darkdevil177.5u.com
Item format?
« Reply #8 on: 2004-07-20 09:41:49 »
Come to think of it...I never remember getting more than one of an item from an enemy at once....But i do remember getting the same item twice from an enemy when stealing from it.

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Item format?
« Reply #9 on: 2004-07-20 09:46:11 »
I guess the question is, what format is the item in within scene.bin. is it 1-139? or is it 1-255 even/odd?

Terence Fergusson

  • *
  • Posts: 262
    • View Profile
Item format?
« Reply #10 on: 2004-07-20 10:08:16 »
The format for items is *ALWAYS* 0-319 (0x13F).  The only difference in the save data is that the quantity is compressed into the unused bits of the 2nd byte in the word.  (So it ends up using two bytes for every three that would otherwise be needed).

And since the ST-ITM command uses (xx, itemid (word), quantity (byte)), then the answer is: No, extra data is not compressed into the unneeded bits of item IDs in the scene files.

Darkdevil

  • *
  • Posts: 728
    • View Profile
    • Http://darkdevil177.5u.com
Item format?
« Reply #11 on: 2004-07-20 10:53:59 »
Now you see, I was gonna say 1-255 as 255 is the most of any item you can have (right?) But im nto gonna argue with a programmer ;)

Cyberman

  • *
  • Posts: 1572
    • View Profile
Item format?
« Reply #12 on: 2004-07-20 15:27:02 »
Quote from: Darkdevil
Now you see, I was gonna say 1-255 as 255 is the most of any item you can have (right?) But im nto gonna argue with a programmer ;)

I'm not sure what you are getting at?

In battle you can only recieve 1 item from the scene.bin data.  

That's what Terrance was saying.

However you can recieve multiples because the script engine can handle that outside it.

Cyb

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
Item format?
« Reply #13 on: 2004-07-22 07:01:05 »
each monster data in scene.bin has info about items that can be taken from it, its 2 bytes for each (morph, steal, win) i think it was 0xFFFF for no item.