Prince of Persia.dat
Prince of Persia DAT Files: The DAT File Format and How to Open Them
The 1989 game keeps its graphics, sounds, music and levels in a handful of DAT files. Fan-made tools read them, export the parts as ordinary files and write the changes back.
0x0000 The DAT file format of Prince of Persia: what the files contain
The DOS release of the 1989 game does not store its assets as thousands of loose files. It packs them into a few large containers with the extension .dat: PRINCE.DAT and KID.DAT sit beside the game, and LEVELS.DAT holds the level data. Each container bundles many resources, among them sprites, palettes, sound effects and music, and the game loads them by number at run time.
That makes the DAT file format the foundation of everything the modding scene built around the game: custom graphics, translated texts, new sounds and rearranged levels all start with taking a container apart and putting it back together.
0x0100 How to open a DAT file from the game
The DAT file format is not something a general-purpose program understands, and a text editor only shows noise. Knowing how to open a DAT file from the game means choosing between two kinds of tools:
- Resource editors. PR, a fan-made editor, exports the entries of a DAT file as ordinary BMP images, PAL palettes, WAV sounds and MIDI music, and imports the edited files back into the container.
- Ports and reimplementations. SDLPoP is a free, open-source reimplementation of the DOS game that reads the original data files, which makes it the usual way to test changes on a modern system.
The short version of how to open a DAT file from this game is to use a resource editor on a copy. Make a copy of the original container before touching it, edit the copy, and keep the file name unchanged so the game still finds it.
0x01C0 What is a DAT file? The short answer
Outside this game, a .dat extension says only that a file holds data. A word processor, a mail client, a backup tool and a hardware driver can each write a file ending in .dat, and the files have nothing in common except the name. Some are plain text, such as logs and settings. Some are the private database of one application. Some are containers like the ones above. The extension alone never identifies the DAT file format, so the reliable test is to look at the file itself.
Three checks, in this order, identify almost every unknown DAT file: where it came from, how it looks in a plain text editor, and its first bytes in a hex viewer. Many formats start with a fixed signature, and the table below lists the ones that turn up most often.
| First bytes (hex) | As text | Format | Where it comes from |
|---|---|---|---|
78 9F 3E 22 | x.>" | TNEF container | winmail.dat from Outlook |
50 4B 03 04 | PK | ZIP archive | Renamed archives, application packages |
1F 8B | (none) | gzip compressed data | Backups, exported data |
53 51 4C 69 74 65 | SQLite | SQLite database | Application data and caches |
25 50 44 46 | PDF document | Renamed downloads | |
89 50 4E 47 | .PNG | PNG image | Renamed images |
52 49 46 46 | RIFF | RIFF media (WAV, AVI) | Audio and video resources |
4D 5A | MZ | Windows executable | Renamed programs, installers |
0x0280 The winmail.dat case
The most common reason for a stray DAT file outside games is a message sent from Outlook in rich text format. Mail programs that do not understand Microsoft's Transport Neutral Encapsulation Format show the formatting and the attachments as one opaque file called winmail.dat. A TNEF extractor lists the message body and the original attachments and saves them one by one. Asking the sender to switch the message to plain text or HTML avoids the problem for good.
0x0300 Common mistakes with unknown DAT files
- Changing the extension to .txt or .zip and hoping the file turns readable.
- Saving an edited binary file from a text editor, which corrupts it.
- Running a conversion tool made for a different format.
- Opening a file from an unknown sender before checking its first bytes.
0x0380 Frequently asked questions
What are the Prince of Persia DAT files?
They are the resource containers of the DOS release. Files such as PRINCE.DAT and KID.DAT bundle the images, palettes, sounds and music the game loads, and LEVELS.DAT holds the level data.
How can the contents of a Prince of Persia DAT file be extracted?
A resource editor such as PR exports the entries as ordinary BMP, PAL, WAV and MIDI files and imports them back after editing. Work on a copy of the original file.
What is a .dat file in general?
A .dat file is a file whose extension says only that it holds data. The program that wrote it decides the contents, so the format has to be identified from where the file came from and from its first bytes.
Is a .dat file safe to open?
A data file does not run on its own, but a file can carry any name. Check where it came from, compare its first bytes with the table on this page and scan files from unknown senders before opening them in another program.
How can winmail.dat be opened on a phone or a Mac?
The file is a TNEF container created by Outlook. A TNEF extractor lists the attachments and the message text inside it. The simpler fix is to ask the sender to resend the message as plain text or HTML.