Gods Path Format

From ModdingWiki
Jump to navigation Jump to search

Some enemies in Gods fly along fixed, pre-recorded paths instead of reacting to the player. These paths are stored in PGOD0n.PAT, one file per world (n = 1-4). The files are compressed with PKWARE DCL Compression. Despite the extension they have nothing to do with instrument patches: "PAT" is short for path.

The file is loaded when sublevel A of a world starts and is used for both sublevels. Path enemies are started by event type 1 in the Gods Level Data Format, whose spawner record gives the path number, the number of enemies and the delay between them.

File format

The file is a directory of 50 entries followed by the path data.

Directory

50 entries of 8 bytes (400 bytes in total).

Data type Name Description
UINT32BE offset Offset left over from the Bitmap Brothers' tools, never used by the game. 0xFFFFFFFF marks an unused entry. (The game overwrites the first word with a memory pointer at load time.)
UINT16BE unused 0 or 0xFFFF
UINT16BE length Length of this path's data in bytes

The path data is stored in order straight after the directory, so path i starts at 400 + (sum of the lengths of all earlier entries). Unused entries (first word 0xFFFF) are skipped and take no space. Entries with a length of 0 are also empty. The file size is always 400 + (sum of all lengths).

File Used paths Size
PGOD01.PAT 38 5320
PGOD02.PAT 6 776
PGOD03.PAT 1 556
PGOD04.PAT 22 2818

Path data

A path starts with its starting position, in one of two forms:

Form Header Meaning
Absolute The bytes 23 45, then UINT16BE x, UINT16BE y Start at world position (x, y)
Relative UINT16BE x, UINT16BE y Start at (x, y) relative to the top-left corner of the screen

The rest of the path is one byte per step. The game moves the enemy one step every frame (15 per second). Each byte holds two signed 4-bit values:

Bits Meaning
7-4 Horizontal movement, -8 to +7 pixels (-8 is never used)
3-0 Vertical movement, -8 to +7 pixels (-8 is never used)

When the end of the path is reached, the enemy keeps repeating the last step until it leaves the screen, and is then removed.

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!)