THANM(1) | General Commands Manual | THANM(1) |
thanm
— Touhou
sprite archive tool
thanm |
[-Vfouv ] [[-l |
-x | -X |
-r | -c ]
version] [-m
anmmap]...
[-s symbols]
[archive [...]] |
The thanm
utility performs various actions
on sprite archives. The following commands are available:
thanm
-l
version [-fouv
]
[-m
anmmap]...
archivethanm
-x
version [-fouv
]
archive [file ...]thanm
-X
version [-fouv
]
archives...thanm
-r
version [-fouv
]
archive name
file-l
command.thanm
-c
version [-fuv
]
[-m
anmmap]...
[-s
symbols]
archive input-l
command. It will look for referenced image
files in the current directory.thanm
-V
These options are accepted:
-f
-f
option can be used to ignore certain
errors.-m
anmmap-m
option can be used to map ins_* to human
readable names.-s
symbols-s
option saves symbol ids to the
symbols file.-o
-o
option adds address information for ANM
instructions.-u
-u
option extracts each texture into a
separate file. When specified twice, x/y offset is ignored. See
IMAGE COMPOSITION for more
information.-v
-v
option increases verbosity of the output.
It can be specified multiple times.The thanm
utility exits with 0 on success,
1 on error.
Each texture in an ANM file has an associated source image
filename. By default thanm
creates textures by
cropping the source image according to the following parameters:
xOffset, yOffset,
THTXWidth, THTXHeight. When
extracting the textures, the process is reversed. However, because multiple
textures may come from a single source file, they have to be composed
together during extraction. Additionally, in either case, the textures have
to be converted to/from the appropriate format.
-c
) or replacing
(-r
):-x
and -X
):The -u
option extracts each texture into
its own file. It's important to also use the -u
option for listing (-l
), because
-c
relies on the alternative filenames being
specified in the spec file. Even with -u
the images
are cropped/padded when they have an offset. The -uu
option ignores the offset, thereby disabling cropping/padding.
In TH19, the textures are stored using PNG and JPEG
compression. thanm
tries to avoid recompression when
possible, so composition is only done when necessary. Uncompressed textures
(pre-TH19) are always composed, even if only to convert them to PNG. PNGs
are only composed only if there's a nonzero offset, or there are multiple
textures referencing the same image. Otherwise the file is copied directly,
without recompression (-uu
forces
this behavior). JPEGs are
never composed, but
it shouldn't be necessary either. If a JPEG has to be composed,
thanm
will issue a warning.
Anmmap files, which are added with the -m
option, consist of two kinds of lines: control lines (which start with
‘!
’), and mapping lines.
The file starts with
‘!anmmap
’ control line. The rest of
the control lines select the mapping that is being modified:
!ins_names
’!ins_signatures
’!gvar_names
’!gvar_types
’$
’ for integer,
‘%
’ for float)Mapping lines are always of form
When multiple mappings are specified for the same key or value, the most recent one has priority. For example:
123 foo 123 bar
will map ‘123
’ to
‘bar
’,
‘bar
’ to
‘123
’, and
‘foo
’ to
‘123
’. Note how the first reverse
mapping doesn't get removed.
A few files from TH12 and TH13 contain overlapping entries with different formats. Dumping and recreating these archives will not result in the same archives. The affected pixels seem to all have 0 for alpha though.
File names may not be properly sanitized when extracting. Furthermore, invalid data may not be properly handled. Do not operate on untrusted files.
September 3, 2023 | thtk |