Changes

Jump to navigation Jump to search

FF7/Field

10,488 bytes added, 21:40, 20 March 2005
Fairly unorganised
== Important Files ==

{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
! style="background:rgb(0,255,0)" align="center" | PSX Version
! style="background:rgb(0,255,0)" align="center" | PC Version
|-
|style="background:rgb(0,255,0)" | /FIELD/*.DAT
|style="background:rgb(0,255,0)" | /DATA/FIELD/FLEVEL.LGP
|-
|style="background:rgb(0,255,0)" | /FIELD/*.MIM
|style="background:rgb(0,255,0)" | /DATA/FIELD/CHAR.LGP
|-
|style="background:rgb(0,255,0)" | /FIELD/*.MIM
|style="background:rgb(0,255,0)" | /DATA/FIELD/CHAR.LGP
|-
|style="background:rgb(0,255,0)" | /FIELD/*.BSX
|style="background:rgb(0,255,0)" |  
|}

== Field Overview ==

The field module is the core of the game to which everything else is spawned. It is tied very closely with the kernel and contains many low-level calls to it. The field system also contains a self-contained bytecode language called commonly called "Field Script". The field module is responsible for the following:

- The loading and parsing of the field files
- The display of the 2D background ands related special effects
- The display of 3D elements in the field such as the camera, perspective and and entities
- The running of the Field Script to display events and to get user input
- The on-demand loading of other modules when needed

The Field module loads modular "Field Files". In the PC version, the Field File is a single file with nine sections. In the PSX version, there are three files with the same name but with different extensions that do the same thing. The three files are MIM (Mutiple Image Maps, or the backgrounds), DAT (Field Script Data), and BSX (3D data).

The following snapshot of the PSX's VRAM demonstrates the background field files in various stages of assembly.

The backgrounds are actually 16x16 blocks that are loaded into VRAM and then assembled into the video buffer every frame. The system allows for layers to obscure the 3D entities using a simple painter's algorithm.

In this particular field file, there are six cached sections of background data. Also notice the bright green patches that don't show up in in the video buffer. This was to show where a lower layer of 2D data was to be covered by a higher layer. The bright green is for debug purposes. During development, if any bright green showed up, it meant that your upper layer had a "hole" in it that a 3D entity could be seen through.

When the PSX version of FF7 is ran in higher resolutions via emulation with texture filtering on, often the lower layers will "bleed" outside the upper layer and make artifacts. This was also the reason why the field files were not re-rendered for the PC version of the game. It would of required "re-cutting" the layers again in the higher resolution.

Another last thing to note is in the middle of the bottom texture cache there are a sea of eyes. These blink at random times and reflect the random blinking of the characters in the game.

== Field Format (PC) ==

=== General PC Field File Format ===

Field files are always found in FLEVEL.LGP. They are always [[FF7/LZS format|LZS]] compressed.

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.

=== PC Field File Header ===

{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
! style="background:rgb(204,204,204)" align="center" | Offset
! style="background:rgb(204,204,204)" align="center" | Size
! style="background:rgb(204,204,204)" align="center" | Description
! style="background:rgb(204,204,204)" align="center" | Section Data
|-
|style="background:rgb(255,255,255)" | 0x00
|style="background:rgb(255,255,255)" | 2 bytes
|style="background:rgb(255,255,255)" | Blank
|style="background:rgb(255,255,255)" | Always 0x00
|-
|style="background:rgb(255,255,255)" | 0x02
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Number of Sections
|style="background:rgb(255,255,255)" | Always 0x0009
|-
|style="background:rgb(255,255,255)" | 0x06
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Pointer to Section 1
|style="background:rgb(255,255,255)" | [[FF7/Field/Field Script & Dialog|Field Script & Dialog]]
|-
|style="background:rgb(255,255,255)" | 0x0A
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Pointer to Section 2
|style="background:rgb(255,255,255)" | [[FF7/Field/Camera Matrix|Camera Matrix]]
|-
|style="background:rgb(255,255,204)" | 0x0E
|style="background:rgb(255,255,204)" | 4 bytes
|style="background:rgb(255,255,204)" | Pointer to Section 3
|style="background:rgb(255,255,204)" | Unknown (Model Loader?)
|-
|style="background:rgb(255,255,255)" | 0x12
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Pointer to Section 4
|style="background:rgb(255,255,255)" | [[FF7/Field/Palette|Palette]]
|-
|style="background:rgb(255,255,255)" | 0x16
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Pointer to Section 5
|style="background:rgb(255,255,255)" | [[FF7/Field/Walkmesh|Walkmesh]]
|-
|style="background:rgb(255,255,204)" | 0x1A
|style="background:rgb(255,255,204)" | 4 bytes
|style="background:rgb(255,255,204)" | Pointer to Section 6
|style="background:rgb(255,255,204)" | Unknown
|-
|style="background:rgb(255,255,255)" | 0x1E
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Pointer to Section 7
|style="background:rgb(255,255,255)" | [[FF7/Field/Encounter|Encounter]]
|-
|style="background:rgb(255,255,204)" | 0x22
|style="background:rgb(255,255,204)" | 4 bytes
|style="background:rgb(255,255,204)" | Pointer to Section 8
|style="background:rgb(255,255,204)" | Unknown
|-
|style="background:rgb(255,255,255)" | 0x26
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Pointer to Section 9
|style="background:rgb(255,255,255)" | [[FF7/Field/Background|Background]]
|-
|style="background:rgb(255,255,255)" | 0x2A
|style="background:rgb(255,255,255)" | 4 bytes
|style="background:rgb(255,255,255)" | Where Pointer to Section 1 points to
|style="background:rgb(255,255,255)" | Length of Section 1
|-
|style="background:rgb(255,255,255)" | 0x2E
|style="background:rgb(255,255,255)" | Varies
|style="background:rgb(255,255,255)" | Start of Section 1 data. Continues for the<br />number of bytes specified in Section Length
|style="background:rgb(255,255,255)" | Field Script...
|}

Each section generally starts with a four byte integer indicating the length of the section. You could just work this out by comparing offsets (how much space until the next section/end of file, etc) but FF7 stores the length at the start of the section anyway. After that the actual data follows. So the first bit of data for a section is actually 4 bytes after the point given in the section header (since the first four bytes are actually the length marker).

To examine each section, please navigate using the links in the table above.

== Field Format (PSX) ==

=== PSX DAT Format ===

The PSX script is contained in the DAT file, it is compressed with [[FF7/LZS format|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.

=== PSX MIM Format ===

=== PSX BCX Format ===

== Event Scripting ==

== Script commands ==

The event scripting language for FF7 has 246 commands that have a wide array of functions. For a complete listing of the commands, opcodes, arguments and descriptions, please refer to the [[FF7/Opcodes|opcodes]] section.

== Movies ==

== The 3D Overlay ==

== Data Organization ==

== "A" Field Animation Files for PC by [[User:Mirex|Mirex]] ==

Each animation file holds one character animation ( run, walk or some other). Some characters have more animation files. Animation is set of frames, in each frame are stored bone rotations.

-- animation file contents --

{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
! style="background:rgb(204,204,204)" align="center" | Name
! style="background:rgb(204,204,204)" align="center" | Size in bytes
|-
|style="background:rgb(255,255,255)" | header
|style="background:rgb(255,255,255)" align="center" | 24
|-
|style="background:rgb(255,255,255)" | unknown
|style="background:rgb(255,255,255)" align="center" | 12
|-
|style="background:rgb(255,255,255)" | frames
|style="background:rgb(255,255,255)" align="center" | frames_count * frame
|}

-- one frame, size is (bones * 12 + 24) --

unknown 24 bytes = 6 floats
rotations bones * 12 bytes = bones * 3 floats

{| border="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="center"
! style="background:rgb(204,204,204)" align="center" | Name
! style="background:rgb(204,204,204)" align="center" | Size
|-
|style="background:rgb(255,255,255)" | unknown
|style="background:rgb(255,255,255)" align="center" | 24 = 6 floats
|-
|style="background:rgb(255,255,255)" | rotations
|style="background:rgb(255,255,255)" align="center" | bones * 12 bytes = bones * 3 floats
|}

header structure, 24 bytes

struct {
unsigned long x1;
unsigned long frames_count;
unsigned long bones_count;
unsigned long x2, x3, x4;
} anim_head;

I understand only two values from the header, 'frames_count' which is number of animation frames and 'bones_count' which is suprisingly number of animated bones.

If you want to load all possible animations for the model (even animations of different models) then check if animation file has same number of bones as current model.

After header there is 12 bytes of data that are unknown to me. It could be some center of the coordinate system or anything.

Frame starts with 6 floats (unknown), followed by rotations for each bone. Rotations are stored as 3 floats (float is 4byte floating-point number).

Navigation menu