-
Notifications
You must be signed in to change notification settings - Fork 9
CST Scene
File Structure fully deciphered!
Decompiling not guaranteed to be fully deciphered, need to play around with custom line type values.
The structure and basic language syntax for Cat Scenes are slightly over 20 years old now, as they existed in the original CatSystem (1) engine in the late 1990's.
Data Type | Value | Description |
---|---|---|
char[8] |
"CatScene" | File Signature |
uint32 |
CompressedSize | Compressed size of ScriptData (uncompressed when 0 ) |
uint32 |
DecompressedSize | Decompressed size of ScriptData |
byte[CompressedSize] | ScriptData | Zlib-compressed scene script contents |
Note: When CompressedSize is 0
, ScriptData is stored in its full uncompressed format. Read byte[DecompressedSize] instead. This occurs when compiling in mc.exe
with the /x
(-x
) flag.
Data Type | Value | Description |
---|---|---|
uint32 |
ScriptLength | Size of ScriptData excluding sizeof(Header)
|
uint32 |
InputCount | Number of Input Offsets |
uint32 |
OffsetTable | Offset to String Offset Table |
uint32 |
StringTable | Offset to String Table |
EntryCount = (StringTable - OffsetTable) / 4
These values can be calculated programmatically and are not necessary to read when parsing the file. They mark the offsets and indexes of the script line after every Input Flag
line and most likely aid the game engine in skipping.
N = InputCount
Data Type | Value | Description |
---|---|---|
uint32 |
OffsetNext | Offset from Index to line after next input |
uint32 |
Index | Index of line after input |
Position = sizeof(Header) + OffsetTable
N = EntryCount
Data Type | Value | Description |
---|---|---|
uint32 |
Offset | Offset of to String n |
The string table for script lines. Each line has a type that determines what it does, and content that is either used to parse a command or display a message or name.
Position = sizeof(Header) + StringTable + StringOffsets[n]
N = EntryCount
Data Type | Value | Description |
---|---|---|
byte |
0x01 | Byte before Type, hardcoded as 0x01
|
byte |
Type | Action performed by the line |
string | Content | Content of the line |
The 0x01
prefix byte could be some sort of count (like number of strings), or a reserved format planned for use in the future. Whatever the case, the engine only knows how to read and write 0x01
.
Line type names are accurate to internal usage, as they're always printed to the debug log in-game.
Name | Value | Description |
---|---|---|
Input | 0x02 |
Wait for input after message |
Page | 0x03 |
Novel page break and wait for input after message |
Message | 0x20 |
Display a message |
Name | 0x21 |
Set speaker of the message |
Command | 0x30 |
Perform any other command |
ScriptName | 0xF0 |
Sets the name of the source script file |
LineNumber | 0xF1 |
Marks the current line number in the source script file (as a string) |
Some things to note:
- ScriptName and LineNumber line types are debug information only. These are inserted by
mc.exe
when compiling with the/l
(-l
) flag. These can safely be skipped, however they do allow for some extended information when decompiling. - Input line types are the only one to use the flag
0x02
in their value, though it's also true that they have0x0_
for their most significant digit. - All message-related line types have
0x2_
for their most significant digit.