changeset 766:8a3b8e2ffa24

formats: Expose color_key on Anm0
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 30 Aug 2022 17:06:38 +0200
parents 2a5279168d5a
children ccb04468c5fa
files formats/src/th06/anm0.rs
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/formats/src/th06/anm0.rs
+++ b/formats/src/th06/anm0.rs
@@ -55,8 +55,12 @@ pub struct Anm0 {
     pub size: (u32, u32),
 
     /// Format of this ANM.
+    // TODO: use an enum for that.
     pub format: u32,
 
+    /// Color key, probably used for transparency.
+    pub color_key: u32,
+
     /// File name of the main image.
     pub png_filename: String,
 
@@ -168,14 +172,14 @@ declare_anm_instructions!{
 }
 
 fn parse_anm0(input: &[u8]) -> IResult<&[u8], Anm0> {
-    let (i, (num_sprites, num_scripts, _, width, height, format, _unknown1,
-             first_name_offset, _unused, second_name_offset, version, _unknown2,
-             _texture_offset, has_data, _next_offset, unknown3)) =
+    let (i, (num_sprites, num_scripts, _, width, height, format, color_key,
+             first_name_offset, _, second_name_offset, version, _,
+             _texture_offset, has_data, _next_offset, _)) =
         tuple((le_u32, le_u32, tag(b"\0\0\0\0"), le_u32, le_u32, le_u32, le_u32, le_u32,
-               le_u32, le_u32, le_u32, le_u32, le_u32, le_u32, le_u32, le_u32))(input)?;
+               tag(b"\0\0\0\0"), le_u32, le_u32, tag(b"\0\0\0\0"), le_u32, le_u32, le_u32,
+               tag(b"\0\0\0\0")))(input)?;
 
     assert_eq!(version, 0);
-    assert_eq!(unknown3, 0);
     assert_eq!(has_data, 0);
     let num_sprites = num_sprites as usize;
     let num_scripts = num_scripts as usize;
@@ -268,6 +272,7 @@ fn parse_anm0(input: &[u8]) -> IResult<&
     let anm0 = Anm0 {
         size: (width, height),
         format,
+        color_key,
         png_filename,
         alpha_filename,
         sprites,