Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About the CST format #2

Open
AtomCrafty opened this issue Oct 17, 2020 · 1 comment
Open

About the CST format #2

AtomCrafty opened this issue Oct 17, 2020 · 1 comment
Labels
information Information or knowledge of formats and tools

Comments

@AtomCrafty
Copy link
Collaborator

Hey, thanks for compiling all of this information in one place! It's been very useful.

I thought I'd share some of my own findings about the CST format, but unfortunately the wiki seems to be read-only.

What you call the "Input Offset Table" is actually the list of script blocks.

Conceptually, a CatScene script consists of a number of blocks, where each block contains one or more lines.
Blocks are not only used for skipping, they are also essential so how saving and loading works.
It is not possible to create a save state in the middle of a block, just between them.
When you save while a block is being executed and load the resulting save file, the entire block will start from the beginning.

When debug mode is enabled and you open the "Messages" window, what you are seeing is actually a list of script blocks you can jump to. So if a block contains multiple message lines (even if they are not consecutive), they will be displayed as one concatenated string.

I've also created a a formal definition of the binary format:
https://github.com/AtomCrafty/TriggersTools.CatSystem2/wiki/cst.ksy

While disassembling the script compiler (mc.exe), I've discovered some more facts:

  • You can terminate any line with a backslash to concatenate it with the next line.
    This also works in the middle of a command, not just in messages (only one script line will be generated).

  • If the first character in a line is a backslash, the line will be treated as a message instead of a command.

  • The compiler supports several (case insensitive) command line flags, some of which are undocumented:
    -u or /u only overwrite scripts if the .txt file is newer than the .cst file
    -l or /l write source file and line number information to the .cst script
    -x or /x skips the compression step and writes an uncompressed .cst script
    -d or /d appears to do nothing
    Flags only apply to file names specified after the flag.

  • The line type is actually just a single byte value, the byte before it is hardcoded to 0x01.

  • There are two more line types that are not currently listed on the wiki page;
    ScriptName (0xF0) and LineNo (0xF1). They are only emitted when the -l flag is set.

@trigger-segfault trigger-segfault added the information Information or knowledge of formats and tools label Oct 20, 2020
@trigger-segfault
Copy link
Owner

trigger-segfault commented May 9, 2021

Finally got to adding the line type 0x01 prefix byte knowledge into the wiki CST Scene page. I am speed

Now to add the debug line types. Nearly forgot about those.

Edit: And done, along with the potential for uncompressed files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
information Information or knowledge of formats and tools
Projects
None yet
Development

No branches or pull requests

2 participants