|
| 1 | +# Event DAT Structures |
| 2 | + |
| 3 | +This file contains information related to the structure of the event / cutscene DAT files. |
| 4 | + |
| 5 | +# Structure / Layout |
| 6 | + |
| 7 | +```cpp |
| 8 | +typedef signed char int8_t; |
| 9 | +typedef short int16_t; |
| 10 | +typedef int int32_t; |
| 11 | +typedef unsigned char uint8_t; |
| 12 | +typedef unsigned short uint16_t; |
| 13 | +typedef unsigned int uint32_t; |
| 14 | +typedef unsigned int uintptr_t; |
| 15 | + |
| 16 | +struct eventheader_t |
| 17 | +{ |
| 18 | + uint32_t BlockCount; // Event block count. |
| 19 | + uint32_t BlockSizes[BlockCount]; // Event block size table. |
| 20 | +}; |
| 21 | + |
| 22 | +struct eventblock_t |
| 23 | +{ |
| 24 | + uint32_t Actornumber; // Entity Server Id |
| 25 | + uint32_t TagCount; // Event count. |
| 26 | + uint16_t TagOffset[TagCount]; // Event offset table. |
| 27 | + uint16_t EvectExecNum[TagCount]; // Event id table. |
| 28 | + uint32_t ImedCount; // Event immediate data count. |
| 29 | + uint32_t ImidData[ImedCount]; // Event immediate data table. |
| 30 | + uint32_t EventDataSize; // Event data size. |
| 31 | + |
| 32 | + // Event data. (4 byte aligned.) |
| 33 | + if (EventDataSize % 4 == 0) |
| 34 | + uint8_t EventData[EventDataSize]; |
| 35 | + else |
| 36 | + uint8_t EventData[EventDataSize + (4 - EventDataSize % 4)]; |
| 37 | +}; |
| 38 | + |
| 39 | +struct eventdat_t |
| 40 | +{ |
| 41 | + eventheader_t Header <optimize=false>; |
| 42 | + eventblock_t Blocks[Header.BlockCount] <optimize=false, comment=IdToStr>; |
| 43 | +}; |
| 44 | + |
| 45 | +/** |
| 46 | + * Converts a block actor number to a string for the comment row. |
| 47 | + * |
| 48 | + * @param {eventblock_t&} block - The event block. |
| 49 | + * @return {string} The entity id string. |
| 50 | + */ |
| 51 | +string IdToStr(eventblock_t& block) |
| 52 | +{ |
| 53 | + string s; |
| 54 | + SPrintf(s, "Entity: %08X", block.Actornumber); |
| 55 | + return s; |
| 56 | +} |
| 57 | + |
| 58 | +eventdat_t dat; |
| 59 | +``` |
| 60 | +
|
| 61 | +**Notes:** |
| 62 | +
|
| 63 | + * _Structures are designed to be used with 010 Editor and do not reflect valid C/C++ code._ |
| 64 | + * _Names of structure members are based on the information dumped from the publicly available PS2 beta discs DWARF information._ |
| 65 | +
|
| 66 | +# Structure Information |
| 67 | +
|
| 68 | +Event DAT files contain event / cutscene information for an entire zone. When the game is compiled, all scripts for each zone are compiled down and bundled into per-zone files that contain all information related to a given zones events. When this is done, each event script is processed and packaged into separate blocks that make up the full event file. |
| 69 | +
|
| 70 | +The `eventdat_t` object holds the two main structures. |
| 71 | +
|
| 72 | +The `eventheader_t` object holds basic header information that defines the data blocks within the file. `BlockCount` tells the client how many blocks are within the file, while `BlockSizes` is an array holding the size of each block in the file as the block sizes are not static. |
| 73 | +
|
| 74 | +The `eventblock_t` object holds the information specific to a given entities event information. Including zone/player specific events which is given the id `0x7FFFFFFF` within the event VM. Below is an explaination of each field in this structure. |
| 75 | +
|
| 76 | +## `Actornumber` |
| 77 | +
|
| 78 | +The entity server id that the given event block belongs to. |
| 79 | +
|
| 80 | + * `0x7FFFFFFF` represents player/zone events not directly connected to any specific entity in the zone. |
| 81 | +
|
| 82 | +_This field may also be referred to as `EntityServerId` to align to other reversed information._ |
| 83 | +
|
| 84 | +## `TagCount` |
| 85 | +
|
| 86 | +The number of events the block contains. |
| 87 | +
|
| 88 | +_This field may also be referred to as `EventCount` to align to other reversed information._ |
| 89 | +
|
| 90 | +## `TagOffset` |
| 91 | +
|
| 92 | +The array of event offsets where each event starts within the `EventData` byte code. |
| 93 | +
|
| 94 | +_This field may also be referred to as `EventOffsets` to align to other reversed information._ |
| 95 | +
|
| 96 | +## `EvectExecNum` |
| 97 | +
|
| 98 | +The array of event ids. |
| 99 | +
|
| 100 | +_This field may also be referred to as `EventIds` to align to other reversed information._ |
| 101 | +
|
| 102 | +## `ImedCount` |
| 103 | +
|
| 104 | +The number of immediate data entries the block contains. |
| 105 | +
|
| 106 | +_This field may also be referred to as `ReferenceCount` to align to other reversed information._ |
| 107 | +
|
| 108 | +## `ImidData` |
| 109 | +
|
| 110 | +The table of immediate data entries that the event can reference. This is extra data that can be used with various opcodes that will not fit into the byte code and is instead referenced by index into this table. (This can be things like other event ids, item ids, string ids for DAT string lookups, etc.) |
| 111 | +
|
| 112 | +_This field may also be referred to as `ReferenceData` to align to other reversed information._ |
| 113 | +
|
| 114 | +## `EventDataSize` |
| 115 | +
|
| 116 | +The raw size of the event byte code data. |
| 117 | +
|
| 118 | +## `EventData` |
| 119 | +
|
| 120 | +The table of byte code data. This holds all of the byte code for every event this block contains. The data is 4 byte aligned, however the `EventDataSize` holds the true unaligned size. |
| 121 | +
|
| 122 | +The byte code data is stored in the order the scripts were compiled and bundled into the `TagOffset` table. |
| 123 | +
|
| 124 | +_You can determine the size of each events byte code by using the `TagOffset` list as a start and stop point for each entry, with the last entries size being the rest of the remaining data._ |
| 125 | +
|
| 126 | +--- |
| 127 | +
|
| 128 | +_This data is current as of Feb. 28, 2022 retail client._ |
0 commit comments