Let’s Make: Traffic Department 2192 – Part 12

Assets - Analyzing Dialogue Files

There's a dialogue file for each of the three episodes: DIALOGUE.DAT, DIALOGU2.DAT and DIALOGU3.DAT. The archive also contains modified dialogue for the clean version for each episode (SAFEDIA?.DAT) which work exact the same way. Like the Map files, we're only going to figure out how these dialogue files work so we can incorporate these data in to our engine with minimal modification.

Dialogue File Format

Dialogue files are made up of ASCII text with each line ending in the classic combo CR/LF (0x0D 0x0A). The key is interpreting each line. Each character of a line may be either plain text or a control code that provides a signal similar to how markup languages alter interpretation of a text stream. These are the control characters we're interested in:

First Byte Second Byte Usage
0x01 0x01-0x04 Sets up a character in the scene. The second by identifyies the number of the actor, the third byte is the sprite frame reference in the Faces file. The remaining part of the line is their name as displayed centered at the bottom of the sprite.
0x02 0x01 Signals a new line of dialogue. The third byte is the character code identified in the set up. Speaker could swap depending on the codes provided
0x03 N/A Single byte line that seems to trigger the start of the scene.
0x04 N/A Another single byte line that seems to end scene processing, but isn't quite the end of the scene
0x05 N/A Indicates a pause in the dialogue where the player has to push a button to continue the scene
0x06 0x01-0xFF Signals the start of a new scene. Second byte is the unique scene number
0x64 N/A End of dialogue scene

Dialogue File Usage

We'll load the dialogue files as-is in to our game. We'll have to build an interpreter that matches the encoding identified above.


Dialogue Loader in Python

We used the following script to analyze the dialogue files in the video: