]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Expose image lead-in in public struct.
authorNick Bowler <nbowler@draconx.ca>
Thu, 2 Jan 2014 01:33:18 +0000 (20:33 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 23 Jan 2014 03:12:17 +0000 (22:12 -0500)
Since we've finally defined the meaning of this value it makes sense to
expose it to the user.  This eliminates another need for lbx_img_getinfo,
but maintain the old functionality there for now.

src/gui/lbxgui.c
src/image.c
src/image.h

index 9afcaa85e69b6f67e812a16fb18179b6b7da576a..bb9e5e5664459c2ce9b06249f204adf55f80bb44 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  2ooM: The Master of Orion II Reverse Engineering Project
  *  Graphical tool for inspecting LBX archives.
- *  Copyright (C) 2010 Nick Bowler
+ *  Copyright (C) 2010, 2014 Nick Bowler
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -100,12 +100,12 @@ static void tick(void *p, double delta)
                elapsed -= seconds_per_frame;
 
                if (++newframe >= image->frames) {
-                       if (!info.looping) {
+                       if (image->leadin == image->frames - 1) {
                                gtk_toggle_button_set_active(play, FALSE);
                                break;
                        }
 
-                       newframe = info.loopstart;
+                       newframe = image->leadin;
                }
        }
 
index 764f2bedfd1720ea3ac4496232547968112b9370..e0ee129c1dcd3dc3b047ed792be8036dabc086a3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 2ooM: The Master of Orion II Reverse Engineering Project
  * Library for working with LBX image files.
- * Copyright © 2006-2011, 2013 Nick Bowler
+ * Copyright © 2006-2011, 2013-2014 Nick Bowler
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -43,7 +43,7 @@ struct lbx_image_priv {
        struct lbx_image pub;
 
        unsigned short wtf, flags;
-       unsigned char  wtf2, leadin;
+       unsigned char  wtf2;
        unsigned short palstart, palcount;
 
        const struct lbx_file_ops *fops;
@@ -77,13 +77,19 @@ static struct lbx_image_priv *lbx_img_init(unsigned char hdr[static HDR_LEN])
                .wtf        = unpack_16_le(hdr+4),
                .pub.frames = hdr[6],
                .wtf2       = hdr[7],
-               .leadin     = hdr[8],
+               .pub.leadin = hdr[8],
                .pub.chunk  = hdr[9],
                .flags      = unpack_16_le(hdr+10),
 
                .currentframe = -1,
        };
 
+       if (img->flags & FLAG_OVERWRITE)
+               img->pub.chunk = 1;
+
+       if (img->flags & FLAG_LOOPING)
+               img->pub.leadin = 0;
+
        return img;
 }
 
@@ -115,7 +121,7 @@ struct lbx_image *lbx_img_open(void *f, const struct lbx_file_ops *fops,
         */
        _lbx_assert(img->wtf  == 0); /* version? */
        _lbx_assert(img->wtf2 == 0); /* very likely is simply reserved. */
-       _lbx_assert(img->pub.frames > img->leadin);
+       _lbx_assert(img->pub.frames > img->pub.leadin);
        _lbx_assert(!(img->flags & ~FLAG_ALL));
 
        /* Read all offsets.  Should be merged with identical code in lbx.c */
@@ -490,8 +496,8 @@ void lbx_img_getinfo(struct lbx_image *pub, struct lbx_imginfo *info)
        if (img->flags & FLAG_LOOPING) {
                info->loopstart = 0;
                info->looping   = 1;
-       } else if (img->leadin != pub->frames - 1) {
-               info->loopstart = img->leadin;
+       } else if (img->pub.leadin != pub->frames - 1) {
+               info->loopstart = img->pub.leadin;
                info->looping   = 1;
        }
 }
index 2057a423e85d035b49e5a34faf5cdb6bd62f2a79..0a8dc99c6d1de95d631a9f5d6c22ae57863f363d 100644 (file)
@@ -7,7 +7,7 @@ struct lbx_file_ops;
 
 struct lbx_image {
        unsigned short width, height;
-       unsigned char frames, chunk;
+       unsigned char frames, chunk, leadin;
 };
 
 struct lbx_colour {