# WindThunder ANI_FILE V1.0 Format #

All animations in WindThunder's *Heroine Anthem I&II* are stored in the
proprietary ANI_FILE format. Their extension is usually .APS, .000 or

## File Format ##

The ANI_FILE format is a running format designed to be streamed
and played in real time. It's a little reminiscent of the ANI-JPEG
format that never really caught on.

The format begins with a similar header to the AMP_FILE format used
for still graphics, but rather than specifying two file sizes, it
specifies a file count. For ‘x' iterations, the game flies through
the images stored in the ANI_FILE. Each image begins with a little
endian long file size.

At the end of the file, after all the images, is a data footer
controlling the image's animation. The format of this footer is
currently unknown.

<pre>ID Tag: 'ANI_FILE V1.0' [14 bytes, string]
Image width [4 bytes, long]
Image height [4 bytes, long]
File count [4 bytes, long]
(file loop)
  File size [4 bytes, long]
(end loop)

## Proof of Concept ##

A proof of concept to extract an ANI_FILE to a series of images and
a data chunk of the footer is included below:

<pre class="line-numbers"><code class="language-php">$filename = '001_2b.aps';
$fd = fopen($filename, 'rb');
if(rtrim(fread($fd,14)) != "ANI_FILE V1.0") die;
$imgwidth = unpack('V*', fread($fd, 4));
$imgheight = unpack('V*', fread($fd, 4));
$count = unpack('V*',fread($fd, 4));
for($i=0; $i< $count; $i++) {
  $filesize = unpack('V*', fread($fd, 4));
  $fo = fopen($filename.'.$i', 'w');
  fputs($fo, fread($fd, $filesize));
$fo = fopen($filename.'.dat', "w");
fputs($fo, fread($fd, filesize($filename)-ftell($fo)));

Copyright (c) 2005 Derrick Sobodash. Some Rights Reserved.

This work is licensed under a CC Attribution-ShareAlike 4.0 International
License (http://creativecommons.org/licenses/by-sa/4.0/).