Author Topic: (PSX FF7) FIELD\*.DAT files...a few questions  (Read 10256 times)

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
(PSX FF7) FIELD\*.DAT files...a few questions
« on: 2012-07-29 21:21:21 »
I've managed to do quite a bit with Makou Reactor and Hack7, but there are still some things that I'm not quite sure of.

1. How does the flow of a FIELD file go? Does it start with group ID 0, and progress in order (depending on jumps and called scripts, of course)? Or does it always start with the 'main' group? Within each group, does it start with S0 - Init, then progress to S0 - Main? If no direction is given as to where it should go after that, does it just execute the next script in order?

2. I can change music within a particular field, but only that music that already loads. How would one go about forcing a field to load a different set of music, so you could then tell it to play one of these newly-loaded songs? For example, if I'd like to force the Temple of the Ancients to play Gold Saucer music, how would I go about that?

3. How would one go about forcing a field to load a different set of field models? For example, if I wanted to load Heidegger in Shinra Mansion, how would I go about that?


Note: I don't mind doing some of the work "manually", so if the only solution is unpacking files, replacing some of them with those from other files, repacking them, and jamming them back on the disc image, that's fine. Just a nudge in the right direction, and any details you may have, would be quite helpful. Thanks in advance.
« Last Edit: 2012-07-31 14:19:36 by Lazy Bastard »

myst6re

  • *
  • Posts: 642
  • Light King of the Savegame - Field Master - FF8.fr
    • View Profile
    • FF8.fr
Re: FIELD\*.DAT files...a few questions
« Reply #1 on: 2012-07-29 22:15:27 »
2. I can change music within a particular field, but only that music that already loads. How would one go about forcing a field to load a different set of music, so you could then tell it to play one of these newly-loaded songs? For example, if I'd like to force the Temple of the Ancients to play Gold Saucer music, how would I go about that?

I do not know. But I think the musics are launched via the AKAOs.

Vehek

  • *
  • Posts: 215
    • View Profile
Re: FIELD\*.DAT files...a few questions
« Reply #2 on: 2012-07-30 00:32:24 »
AKAO blocks contain all the sequence information. I believe that the PSX version uses that data, while the PC version only uses the frame ID. Since you're working on the PSX version, you'll need to completely replace the AKAO block in the field DAT with the AKAO block you want to use. Or so I think.

luksy

  • *
  • Posts: 375
    • View Profile
Re: FIELD\*.DAT files...a few questions
« Reply #3 on: 2012-07-30 01:08:15 »
1. The first script of every entity is called in order and ran until the first ret opcode (init), after which execution continues starting at the first entity again until the next ret (main), in order. Other scripts can be called by the init and main script if necessary. The only scripts that are run without being explicitly called are for field model interaction by talking or touching, and when you interact with line entities.

3. The field model filenames are held in the third section of the field file and are referenced in the script by an index.

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: FIELD\*.DAT files...a few questions
« Reply #4 on: 2012-07-30 19:44:11 »
Quote from: myst6re
I do not know. But I think the musics are launched via the AKAOs.

Quote from: Vehek
AKAO blocks contain all the sequence information. I believe that the PSX version uses that data, while the PC version only uses the frame ID. Since you're working on the PSX version, you'll need to completely replace the AKAO block in the field DAT with the AKAO block you want to use. Or so I think.

I've read that elsewhere as well, and I don't doubt it...but I'd imagine someone has done more digging than that. AKAO itself seems to only precede 'Play music #x', but from what I can see, AKAO sections simply aren't large enough to contain the entire songs themselves - where is the actual music data stored? If I knew that, I could figure out how it's being referenced, and modify that...or at the very least, replace entire songs with other songs where desired.


Quote from: luksy
1. The first script of every entity is called in order and ran until the first ret opcode (init), after which execution continues starting at the first entity again until the next ret (main), in order. Other scripts can be called by the init and main script if necessary. The only scripts that are run without being explicitly called are for field model interaction by talking or touching, and when you interact with line entities.

I assume by 'entity' you mean what Makou Reactor refers to as a 'group'. If so, thanks for the explanation. To clarify, when you say,
Quote
The first script of every entity is called in order and ran until the first ret opcode (init), after which execution continues starting at the first entity again until the next ret (main), in order.
...do you mean that, after the first 'return', execution continues starting completely over at the first script of the first 'group'? Or, as I suspect, do you mean that, after the first 'return', execution continues starting at the first script of the very next 'group'? Or...do you mean that, after the first 'return', execution continues at the very next script, within the same 'group'?


Quote from: luksy
3. The field model filenames are held in the third section of the field file and are referenced in the script by an index.

I don't suppose you mean that the field model files themselves are contained within the .DAT files (.DAT files are quite small), so I assume you mean that the file names are explicitly mentioned...or do you mean that their LBAs are mentioned, in hex? If so, I assume these .DAT files are little-endian, like the various .BIN files FF7 uses? I'll do some digging with a hex editor later today.

Thanks very much for the information in general. Anything else that comes to mind would be much appreciated.
« Last Edit: 2012-07-30 19:50:01 by Lazy Bastard »

Vehek

  • *
  • Posts: 215
    • View Profile
Re: FIELD\*.DAT files...a few questions
« Reply #5 on: 2012-07-30 20:17:28 »
I've read that elsewhere as well, and I don't doubt it...but I'd imagine someone has done more digging than that. AKAO itself seems to only precede 'Play music #x', but from what I can see, AKAO sections simply aren't large enough to contain the entire songs themselves - where is the actual music data stored? If I knew that, I could figure out how it's being referenced, and modify that...or at the very least, replace entire songs with other songs where desired.
AKAO blocks aren't large enough? How large are the AKAO blocks you're looking at? What makes you think they aren't large enough?

Quote
I don't suppose you mean that the field model files themselves are contained within the .DAT files (.DAT files are quite small), so I assume you mean that the file names are explicitly mentioned...or do you mean that their LBAs are mentioned, in hex? If so, I assume these .DAT files are little-endian, like the various .BIN files FF7 uses? I'll do some digging with a hex editor later today.
luksy's mistaken. That's only true in the PC version. In the PSX version, NPC models are stored in the BSX files. I don't understand the documents about their structure well enough to explain how they work.

lasyan3

  • *
  • Posts: 76
    • View Profile
Re: FIELD\*.DAT files...a few questions
« Reply #6 on: 2012-07-30 20:20:24 »
I don't suppose you mean that the field model files themselves are contained within the .DAT files (.DAT files are quite small), so I assume you mean that the file names are explicitly mentioned...or do you mean that their LBAs are mentioned, in hex? If so, I assume these .DAT files are little-endian, like the various .BIN files FF7 uses? I'll do some digging with a hex editor later today.

You're right, the fields models themselves are not in the DAT but in the BSX files (and BCX files for the main characters). The information in DAT files is only indexes and some information to personnalize the models (like the light if I remember clearly).
In the BSX files, you'll also find the animations for the models (run, walk and all the animations used in the field).
More information in the wiki

luksy

  • *
  • Posts: 375
    • View Profile
Re: FIELD\*.DAT files...a few questions
« Reply #7 on: 2012-07-31 01:08:41 »
Quote
I assume by 'entity' you mean what Makou Reactor refers to as a 'group'. If so, thanks for the explanation. To clarify, when you say, ...do you mean that, after the first 'return', execution continues starting completely over at the first script of the first 'group'? Or, as I suspect, do you mean that, after the first 'return', execution continues starting at the first script of the very next 'group'? Or...do you mean that, after the first 'return', execution continues at the very next script, within the same 'group'?

Makou displays the first script (0) in two sections, init and main, although technically it's the same script. Execution starts at group 0 script 0 (init in Makou), once it hits a ret opcode it pauses and goes to the next group which does the same. After the last group it continues execution where it paused group 0 script 0 (main in Makou) and follows the same pattern as the init scripts, continuing each paused script 0 of each group in order again. Keep in mind calls to other scripts can be executed asynchronously though, so the precise runtime order can be hard or even impossible to determine for certain fields.

TouphScript takes advantage of the above and optionally strips out all the unused scripts in the game (spoiler: there are hundreds), but figuring out the execution sequence for changing things like line parameters for question windows is a bitch because some fields are all over the place when it comes to execution.

Quote
I don't suppose you mean that the field model files themselves are contained within the .DAT files (.DAT files are quite small), so I assume you mean that the file names are explicitly mentioned...or do you mean that their LBAs are mentioned, in hex? If so, I assume these .DAT files are little-endian, like the various .BIN files FF7 uses? I'll do some digging with a hex editor later today.

Yeah sorry as Vehek says anything I say applies to the PC version, I'd forgotten the DAT files are script only on the PSX. Luckily most of the time they're similar but not in this case.

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: FIELD\*.DAT files...a few questions
« Reply #8 on: 2012-07-31 14:19:09 »
Quote from: Vehek
AKAO blocks aren't large enough? How large are the AKAO blocks you're looking at? What makes you think they aren't large enough?

I'm looking at the FIELD\*.DAT files, which are less than 100KB each. Within an editor like Makou Reactor or Hack7, you can observe blocks of data labeled 'AKAO', but these are only a few bytes in size. They generally precede opcodes for music to be started or changed, and I assume they refer to what music is about to be started or changed...or which set of songs to load (as the existing music opcodes are already capable of referring to songs within a set of songs). In which file(s) are you looking at AKAO data? It sounds like you know the answer to one of my questions :)


Quote from: lasyan3
You're right, the fields models themselves are not in the DAT but in the BSX files (and BCX files for the main characters). The information in DAT files is only indexes and some information to personnalize the models (like the light if I remember clearly).
In the BSX files, you'll also find the animations for the models (run, walk and all the animations used in the field).
More information in the wiki

Thanks; I need to get around to using Micky's tool to dig around in those, or even Akari's work for Q-Gears.


Quote from: luksy
Makou displays the first script (0) in two sections, init and main, although technically it's the same script. Execution starts at group 0 script 0 (init in Makou), once it hits a ret opcode it pauses and goes to the next group which does the same. After the last group it continues execution where it paused group 0 script 0 (main in Makou) and follows the same pattern as the init scripts, continuing each paused script 0 of each group in order again. Keep in mind calls to other scripts can be executed asynchronously though, so the precise runtime order can be hard or even impossible to determine for certain fields.

That's quite an interesting execution cycle. Thanks very much for the details.


Quote from: luksy
Yeah sorry as Vehek says anything I say applies to the PC version, I'd forgotten the DAT files are script only on the PSX. Luckily most of the time they're similar but not in this case.

No problem; I should have specified that I was using the PSX version, anyway :)  I've edited the thread title.

Vehek

  • *
  • Posts: 215
    • View Profile
Re: FIELD\*.DAT files...a few questions
« Reply #9 on: 2012-07-31 18:47:38 »
I'm looking at the FIELD\*.DAT files, which are less than 100KB each. Within an editor like Makou Reactor or Hack7, you can observe blocks of data labeled 'AKAO', but these are only a few bytes in size.
Are you talking about the script opcodes? If you are, then we're talking about different things. I'm talking about the text 'AKAO' actually appearing in field files as viewed by a hex editor. If you look at the "tutorials/sounds" section in Makou Reactor, the entries marked "Sound" are the AKAO blocks.

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: (PSX FF7) FIELD\*.DAT files...a few questions
« Reply #10 on: 2012-07-31 19:06:11 »
Quote from: Vehek
Are you talking about the script opcodes?

Yes.


Quote from: Vehek
I'm talking about the text 'AKAO' actually appearing in field files as viewed by a hex editor. If you look at the "tutorials/sounds" section in Makou Reactor, the entries marked "Sound" are the AKAO blocks.

When you say 'field files', are you still talking about .DAT files? If so, these files are very small, and I don't think entire scores of music could be stored within them. I'm familiar with the Tutorials/Sounds section of Makou Reactor, but I assume that data merely references the actual music data, which is stored elsewhere.

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: (PSX FF7) FIELD\*.DAT files...a few questions
« Reply #11 on: 2012-08-01 01:45:24 »
Hmm..it appears I've somehow missed this information:

http://wiki.qhimm.com/FF7/PSX/Sound/AKAO_frames

So, instead of storing the actual music somewhere, it generates it on the fly based on various pre-recorded sounds, and specifications for tempo, reverberation, pitch, channel, simulated instrument, volume...loop time....that's a completely different music system than I'd envisioned, heh.

OK, then these .DAT files very like DO contain the entire AKAO data for various songs (MINI\ASERI2.SND, the Battle Arena song, is only 6KB in size). I assumed that compressed, likely strangely encoded, music files would be stored somewhere, probably jammed into another file like KERNEL.BIN.

Jenova's Witness

  • Right Wing Safety Squads
  • *
  • Posts: 471
  • I ♥ SCIENCE
    • View Profile
.
« Reply #12 on: 2012-08-01 05:17:36 »
.
« Last Edit: 2015-11-16 09:59:47 by Jenova's Witness »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: (PSX FF7) FIELD\*.DAT files...a few questions
« Reply #13 on: 2012-08-02 16:28:53 »
OK, so I've mapped out what data is AKAO data per decompressed FIELD\*.DAT file, but what is the data immediately after the AKAO data? Also, I can see that the script text, etc, is all before the AKAO data, and I see that, according to the wiki, the first 28 bytes of the DAT file comprise the header...but does anyone have a general guide to which sections of data start/end where? It would be nice to avoid re-inventing the wheel...

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: (PSX FF7) FIELD\*.DAT files...a few questions
« Reply #14 on: 2012-08-03 17:56:13 »
Quote from: Lazy Bastard
OK, so I've mapped out what data is AKAO data per decompressed FIELD\*.DAT file, but what is the data immediately after the AKAO data? Also, I can see that the script text, etc, is all before the AKAO data, and I see that, according to the wiki, the first 28 bytes of the DAT file comprise the header...but does anyone have a general guide to which sections of data start/end where? It would be nice to avoid re-inventing the wheel...

Never mind; myst6re pointed me in the right direction.