From ba19b133bf87936dc606dd994f56f433a278b768 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 1 Jan 2014 20:33:18 -0500 Subject: [PATCH] liblbx: Expose image lead-in in public struct. 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 | 6 +++--- src/image.c | 18 ++++++++++++------ src/image.h | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/gui/lbxgui.c b/src/gui/lbxgui.c index 9afcaa8..bb9e5e5 100644 --- a/src/gui/lbxgui.c +++ b/src/gui/lbxgui.c @@ -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; } } diff --git a/src/image.c b/src/image.c index 764f2be..e0ee129 100644 --- a/src/image.c +++ b/src/image.c @@ -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; } } diff --git a/src/image.h b/src/image.h index 2057a42..0a8dc99 100644 --- a/src/image.h +++ b/src/image.h @@ -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 { -- 2.43.0