A Creatures 2 COB file is just a collection of 'blocks' with a 'magic word' at the beginning.
magic word: 'cob2' (4 chars, no null terminator).
The blocks follow one another after the magic word. Every block is in the following format:
Type | Name | Description |
char[4] | type | The block type. Common types and their formats are listed below. |
unsigned int | size | The size of the data. |
char[size] | chunkdata | The data for this block. |
A COB reader must simply go through the file checking if it recognises the type of a specific block - if it does, then it must load it into memory, otherwise it can just skip the chunkdata using the 'size' variable and continue with the next block. This behaviour is recommended because several tools (including mine) sometimes actually add their own, special block types into COBs produced using them.
The three known blocks used by Creatures 2 itself are 'AGNT', 'FILE' and 'AUTH'. We will cover all of these in turn.
One thing to note is the format of the 'dependency' structure, used in the 'AGNT' block:
The simplest block is 'AUTH', which is the author information block. It is optional, Creatures 2 will inject your agent correctly without it being present. They basically allow people to "sign" their COBs.
The chunk data for 'AUTH' is in this format:
Type | Name | Description |
char | dayofcreation | The day the COB was created. |
char | monthofcreation | The month the COB was created. |
unsigned short | yearofcreation | The year the COB was created. |
char | version | The version of the COB. |
char | revision | The revision of the COB. |
char * | authorname | The name of the author. |
char * | authoremail | The e-mail of the author. |
char * | authorwwwurl | The URL of the author. |
char * | authorcomments | The authors comments on the COB. |
The block which actually defines an agent is the 'AGNT' block. This is quite a complex block :-)
The chunk data for 'AGNT' is in this format:
Type | Name | Description |
unsigned short | quantityleft | The amount of injections left. If this is 0xFFFF there is infinite injections. |
unsigned int | lastusage | The time of last usage. (the number of seconds elapsed since midnight Jan 1st 1970, coordinated universal time) |
unsigned int | reuseinterval | The number of seconds which must pass between injections. |
byte | expireday | The day on which this agent expires. |
byte | expiremonth | The month on which this agent expires. |
unsigned short | expireyear | The year on which this agent expires. |
unsigned int | reserved1 | Reserved, must be zero. |
unsigned int | reserved2 | Reserved, must be zero. |
unsigned int | reserved3 | Reserved, must be zero. |
char * | name | The name of the agent, a null-terminated string. |
char * | description | A description of the agent, a null-terminated string. |
char * | installscript | The installation script, a null-terminated string. |
char * | removalscript | The removal script, a null-terminated string. |
unsigned short | noevents | The number of events this agent has. |
char *[noevents] | events | The events as null-terminated strings. |
unsigned short | nodeps | The number of dependancies this agent has. |
dependancy[noevents] | deps | The dependancies. |
unsigned short | thumbnailwidth | The width of the thumbnail. |
unsigned short | thumbnailheight | The height of the thumbnail. |
unsigned short[thumbnailwidth * thumbnailheight] | thumbnail | The thumbnail, which must be in 565 format. |
The final block is the 'FILE' block, which allows you to include files inside the COB for automatic injection when an agent needs it. In order for a file to be installed for an agent, you must add its name and type to the agents dependency list in the 'agnt' block.
The chunk data for 'FILE' is in this format:
Type | Name | Description |
unsigned short | filetype | The type of the file. 0 is S16, 1 is WAV |
unsigned int | reserved | Reserved, must be zero. |
unsigned int | filesize | The length of the file. |
char * | filename | The filename, a null-terminated string. |
char[filesize] | data | The actual file data. |