Author Topic: FF7 (Both PSX and PC) event script format  (Read 2745 times)

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
FF7 (Both PSX and PC) event script format
« on: 2004-06-26 20:14:53 »
Here you guys go I hope it's useful, it might be wrong....

Code: [Select]

Halkun's script doo-bob with lotsa help from lasyan3 and FIce.


The script on FF7 is exactly the same between the PSX and PC versions. The
headers are the only thing that different. They just tell you how to
find the data, and once that is found, the are exatly the same. Here's how
you get to the script in both the PC and PSX versions. Then the last part
is the generic scripting accessor and how to universally extarct the
script from both versions.

THE PC VERSION:

The scripts are found in the files within flevel.lgp. For those who know
how to access data in the field files, it's the first block...

for those who don't, it's easy. After decompressing the field file you have
to find the first block, to quote fice's doc...

-----
The first two bytes of each (decompressed) field file are blank (zero).
The next four bytes is an integer indicating how many sections are present in
the file.
Then a number of 4-byte integers follow, giving the starting offset for each
section.

All field files should contain 9 sections; it's what FF7 expects.

So, normally you'll find:

00              Blank                   2 bytes
0009            NumSections             4 bytes
????            Section 1 location      4 bytes
????            Section 2 location      4 bytes
etc.            etc.                    etc.

-------------------

The jump to the first section will give you a 4 byte number. I think this is
how long the section is, I'm really not to sure, after that is the beginning of
the script section....

THE PSX VERSION: (from lasyan3)

The PSX script is contained in the DAT file, it is compressed with LZS
compression. After it's decompressed, here is the header format for that..


First, we have 28 unused bytes (in fact, they are used by the PSX, it's a list
of 7 2-bytes values which refer to a place in the RAM). So each time you'll
find a value which is an adress in the file, you'll have to add 28 to
it in order to find the right position in the file (or else you can simply
remove the first 28 bytes of the file).

Note: the first byte in the header is byte 0.

------------------------------------
halkun: THE REST OF THE SCRIPT FORMAT IS EXACTLY THE SAME
The rule of thumb is, if you want to access the PSX version of the script,
start at an offset of +0x1c. If you want to access the PC version, start at
an offset of +2e
------------------------------------

byte 00 : unknown
byte 01 : number of sections
byte 02 : unknown
byte 03 & 04 : adress of the pointer's table for the dialogs
byte 05 : number of data areas
byte 06 to 14 : unknown
                                                                               
byte 15 to 15+number of unknown_names*8-1 : unknown names (8 bytes each)

byte 15+number of unknown_names*8 to 15+(number of unknown_names+number
 of sections)*8-1 : name of each section (8 bytes each)

byte 15+(number of unknown_names+number of sections)*8 to 15+
(number of unknown_names+number of sections)*8+number of data areas*4-1: data
areas pointers (4 bytes each)
                                                                               
length of the header : 15 + (number of unknown_names+number of sections)*8+
number of data areas*4

********************EVENTS PART********************
Here we have all of the pointers tables, one for each section. Pointers are 2
bytes length, like all of the pointers we can find in a DAT file.  Each table
has a length of 64 bytes, which means a section can have 32 scripts max. Each
pointer refers to the first command of the current script.  The section number
N begins at the offset header_length+N*64.  Note: the only way to retrieve the
length of a script is to substract the position of the next script to the
position of the current script.

********************DIALOGS PART********************
Right after the last script of the last section, we find the pointer's table
of the dialogs.  The first 2 bytes show the number of dialogs in the file, so
you can deduct the length of the table: number_of_dialogs*2.  After these 2
bytes we have the pointers for each dialog. Be aware that the pointers are
relative to the table, which means you must add the position of the table to
each pointer in order to find the right position of the dialog.  The dialogs
begin right after the table, and the code 255 means the end of the dialog.

Note: some <<hidden>> dialogs are not referenced in the table!

********************END PART********************

lasyan3

  • *
  • Posts: 76
    • View Profile
FF7 (Both PSX and PC) event script format
« Reply #1 on: 2004-06-26 22:54:55 »
Hehe, this is perfect, but you write "Lasyan2" at the beginning of the psx version :wink:  (and without capital letter please, I know, I am annoying  :lol: )
Edit: Thanks!

Cyberman

  • *
  • Posts: 1572
    • View Profile
FF7 (Both PSX and PC) event script format
« Reply #2 on: 2004-06-27 03:02:56 »
actually lasyan3 you are pretty patient compared to most people :)

<see Orsqual> ;) :)
Cyb

Cyberman

  • *
  • Posts: 1572
    • View Profile
The 'unknown' names
« Reply #3 on: 2004-06-27 17:01:38 »
Halkun I can give you a heads up on those unknown names, they are ussually VERY related to what's in the  file. The first one appears to be the author who made the file, you'll also note it has some information names about what's in the file I believe these are references to the orignal files.  Things like Cloud Tifa Jecy item etc appear in there as well as item etc.  Thus I think these are likely variable name references for the kernal engine is my guess.  You will notice in other parts of the PSX DAT file that the authors name in the original will appear again after the conversation text section ussually.

Anyhow that information is there for a reason as the PSX version is quite the minimalist design unlike the PC.

Cyb