Chrono Cross Fieldscript

General Information[edit]

Chrono Cross[edit]

Fieldscript files are found inside room script.cpt files. Structurally, they consist of a header, an unknown section, and multiple entities.

Header

The header begins with 0x80 bytes of unknown function, a few of which will typically have non-zero values.

After this comes a 4-byte little-endian pointer which indicates the number of entities in the file.

Each entity then has its own 0x40-byte subheader. These consist of lists of up to 32 2-byte little-endian pointers, which indicate the positions of the various scripts making up the entity //relative to the end of the header// (not the beginning of the file). Since most entities have only four scripts, this tends to result in a fair amount of wasted space.

Unknown

After the header, there is a block of data whose use is not known. Its length is normally a multiple of 16 (0x10).

Entities

Entities can represent ~PCs, ~NPCs, the room itself, exits, or other random data such as the debug menu. Typically, an entity will have 4 scripts written in Fieldscript: INIT, UPDATE, ~ON_ACTION, and ~ON_COLLISION. (Occasionally, an object will have additional scripts or subroutines attached to it.)

INIT is the setup script.

UPDATE is of uncertain purpose. Only PC entities seem to do anything with it.

~ON_ACTION appears to be called when the entity's representation on the screen is addressed by pressing the talk/examine button. For ~NPCs, this script will typically activate their dialogue; for objects with descriptions, it may show the description; for other types of entities, it usually does nothing.

~ON_COLLISION appears to be called if the party walks into the entity's on-screen representation. For exits, this will typically transport the party to another room; for most other types of entities, it does nothing.

Subroutines are typically found at the end of an entity's data. They consist of unnamed script chunks reached by a JUMP() command of some sort and end with an ~OP_RETURN(). They will sometimes have what seems to be trailing unreachable data which resembles the unknown block between the file header and the entity definitions.

From: Modification