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

New thanm spec format (also featuring th18 support) #86

Merged
merged 59 commits into from
Aug 15, 2022

Conversation

Priw8
Copy link
Member

@Priw8 Priw8 commented Mar 21, 2021

Replaces the spec format used by previous versions of thanm with a completely new one, using bison and flex for parsing. The format itself is similar to the one used by thecl. The old format support was completely removed, because due to some format changes it would not work properly anyway. Trying to use an old format spec file for ANM creation will result in the following message being displayed:

thanm: filename.spec: the spec file was made using an old version
of thanm and uses the old format, which is no longer supported.
Please use the old version of thanm to create the ANM file, and
re-dump it using this version.

Features of the new format:

  • new thecl-like syntax
  • anmmaps for defining mnemonic names
  • default values for numerous entry fields if they are not specified
  • automatically use width/height of the image if it's not specified
  • labels for jump instructions
  • refer to sprites/scripts by name; they get automatically changed to IDs when compiling
  • expressions (evaluated compile-time when possible, otherwise automatically uses ANM registers and appropriate operator instructions)
  • variables: can use the registers manually but can also declare named variables int myVar = 0; and they will automatically have a register assigned
  • global definitions: same as thecl, global someGlobal = 10;
  • timeof(labelname) offsetof(labelname), spriteof(spritename), scriptof(scriptname) operators: allow explicitly getting value of a symbol
  • directives:
    • #version n: set default version for all following entries to n
    • #include "filename.spec": include the given file
    • #anmmap "filename.anmm": load an anmmap
    • #symbol_prefix "prefix": explained below
  • the -s symbol-filename option can be used to export script name to ID mapping in the global definition format (to later be #included in ECL source files). The names can be prefixed using the name set by using the #symbol_prefix directive.

Priw8 added 30 commits February 14, 2020 18:02
Only dumping now. Recompiling will be added later.
Earlier, the struct used by the game itself was used for everything. This worked fine with the very simple dumping and recompiling, but in order to implement more features a better struct is needed, so thanm_instr_t was added.
Pretty large diff because of indentation change
Only tested with a very limited amount of (v8) ANM files so far, but for the ones it was tested with it recompiles perfecly byte-to-byte.
Did you know that some ANM files in IN have negative script IDs for whatever reason?
Some variable operations and conditional jumps
...and also warn on duplicate label declaration.
It allows specifying the default version for entries.
When writing custom ANMs, manually specifying things like THTXSize gets annoying quickly. Now many properties can be ommited to calculate it automatically (in fact, only filename is required now!)

...though, maybe it should be implemented in a different way than using a magic constant to indicate that default values should be set? Perhaps some additational bitmask property that would indicate which values should be generated from image properties?
Also fixed variables given as identifiers.
This makes things more consistent, since the quotes are not required for labels. Dumped label names were also changed to "offset%u".
Priw8 and others added 26 commits March 21, 2020 15:04
Allows exporting script name-id pairs when creating an ANM, with an optional prefix (specified with `#symbol_prefix` directive). Uses the `global <prefix><scriptName> = <id>;` format, which can be used by thecl/thanm (and thstd once it gets updated with features like #include and globaldefs)
The arguments printed here are the main program arguments, not specific option arguments, so putting `-s SYMBOLS` is confusing
To be fair using -s with old format doesn't make sense anyway, as it'll literally do nothing....
Also fixed an issue where a type mismatch would not get detected sometimes.
Fixing all signatures to align with [my findings here](https://exphp.github.io/thpages/#anm/ins).

(Note: the version of the website currently live misidentifies v7:102 as "drawRect" when it is actually "spriteRand", and mistakenly gives v8:436 an "SS" signature; the signatures in this commit are correct)
fix remaining signatures in v4 and v8 anm
Turns out that instructions don't refer to scripts by their ID, but by their index in the file, which is not always the same.

Why.
v2 is identical to v3 except that color is a single dword
fix ALL remaining anm signatures :D
I'll probably end up rewriting some of actual compilation code to fix it in a better way later...
It's pointless to have it: one of the most used formats was changed because it was wrong, so the old files would not compile anyway.
Has some issues because ins_439 in VD has a different format.

VD photo.anm now throws a bunch of warnings when recompiling, but it still works. It's the only workaround I could come up with, ideally in the future the game number gets passed as a command line parameter so that the proper ins_439 format can be used.
@DankRank DankRank added this to the thtk-13 milestone Apr 21, 2022
@DankRank DankRank self-assigned this Aug 15, 2022
@DankRank DankRank merged commit 1b9a005 into master Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants