Gods Demo Format

From ModdingWiki
Jump to navigation Jump to search

When Gods is left idle on the title screen it plays demos. These are not videos but recordings of joystick input, which the game plays back as if a player were holding the controls. They are stored in six files, PJOYL1.DAT, PJOYG1.DAT, PJOYL2.DAT, PJOYG2.DAT, PJOYL3.DAT and PJOYG3.DAT, played in that order. The files are compressed with PKWARE DCL Compression.

The two kinds of file start in different places:

File Decompressed size Starts at What happens
PJOYL1.DAT 844 Title menu Selects "Begin quest" and plays world 1
PJOYG1.DAT 405 World 1, sublevel B Gameplay
PJOYL2.DAT 2229 Title menu Enters the password L2 and plays world 2
PJOYG2.DAT 524 World 2, sublevel B Gameplay
PJOYL3.DAT 1621 Title menu Enters the password L3 and plays world 3
PJOYG3.DAT 889 World 3, sublevel B Gameplay

L followed by a world number is a shortcut password that only works during a demo.

The PJOYG recordings start from a fixed position that is built into the game, not stored in the file:

File Hero start (x, y) Camera (x, y)
PJOYG1.DAT 3424, 608 3296, 512
PJOYG2.DAT 160, 960 160, 832
PJOYG3.DAT 96, 80 0, 0

The hero is also given a fixed set of weapons for the demo.

File format

The file has no header. It is simply one byte per game frame, followed by an end marker.

Bit Meaning
0 Up
1 Down
2 Left
3 Right
4-6 Always 0
7 Fire

The last byte of every file is 0xFF, which ends the demo. Real input can never produce this value, because bits 4-6 are always clear. There is no length field and no bounds check, so a file without the end marker will read past its end.

Pressing fire on a real joystick or keyboard also ends the demo.

The game contains unused code to record demos in this format, which is presumably how the files were made.

Source code

From re-gods, the open-source HTML5 port:

Credits

This file format was reverse engineered by VorticonCmdr. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)