Skip to content

LIP file format

Gong Xian edited this page Mar 19, 2024 · 12 revisions

Within each disc is a file in the ADVDATA directory, LIPSYNC*.LIP. Disc 1 contains LIPSYNC1.LIP, disc 2 contains LIPSYNC2.LIP, disc 3 contains LIPSYNC3.LIP.

The LIPSYNC files consist of lines of dialogue from the script, a string of commands to control lip movements of on-screen characters, and an offset table containing addresses to the lines of dialogue.

Header

The first 12 bytes consist of the following:

Offset Length Description
0x0 4 The signature 41 4C 50 44, or ALPD in ASCII
0x4 4 File size from the end of this value to the padding after the last line of dialogue, starting after the first 8 bytes
0x8 4 Number of lines of dialogue

Offset Table

Following the header is an offset table. The offset table is a sequence of triplets of 4-byte values consisting of the following:

Offset Length Description
0x0 4 An index for a voice file in the VOICE.AFS archive
0x4 4 An offset for a line of dialogue, minus 8
0x8 4 An offset for the corresponding lip movement commands, minus 8

Each offset is 8 bytes before the data being pointed to. For example, in LIPSYNC1.LIP, the first offset for dialogue in the table is 0x6A00. The first line of dialogue is located at 0x6A08. This is followed by the offset for the lip movement command sequence which is listed as 0x6A1B, placing the sequence at 0x6A23.

Dialogue and Lip Movement

As with the dialogue script files, the dialogue strings are encoded in Shift-JIS and null-terminated. Immediately following the dialogue are the lip movement commands, which are also null-terminated. Dialogue in the script files does not have a 1:1 correspondence to the LIP files; there are slight differences between them such as extra punctuation. Text in the LIP files has precedence over the normal script versions. Replacing text for voiced lines in the script files appears to have no effect in-game.

Lip movement commands are a single digit, 1-6. These will change the on-screen lip movement to one of six positions for one frame, and repeated digits will maintain that position for that many frames (hence the long strings of 6, typically closed lips, used as beats). Digit 7 causes one character of text to be written, but no characters are drawn until another digit 1-6 is read. The closing byte 00 must be on a 1-byte alignment to properly terminate the commands.

End of File and Padding

The final lip movement command sequence is padded with 40 40 to fit a 4-byte alignment. This is followed by the signature 50 4F 46 30, or POF0.

Following this is a 4-byte value for the length of the padding of repeating 42 41 bytes, until the signature 45 4F 46 43 00 00 00 00, or EOFC followed by 4 00 bytes. The reasons for this padding are unknown, as is why its length is specified beforehand.

The final two padding bytes in LIPSYNC1.LIP is 00 00 rather than 42 41. The reason for this is unknown.

LIPSYNC File Statistics

File Data Length Number of Entries First Index Padding Length
LIPSYNC1.LIP 290864 2261 3000, 0xBB8 4524, 0x11AC
LIPSYNC2.LIP 309408 2054 8000, 0x1F40 4268, 0x10AC
LIPSYNC3.LIP 233484 1486 37, 0x25 2972, 0xB9C