+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test correct decoding of various images in mainmenu.lbx
+# Copyright © 2013 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "$srcdir/tests/util/test-init.sh" || exit 99
+
+test x"${MOO2DATA+set}" = x"set" ||
+ skip_all_ "test requires original data files"
+dx_create_testdir
+
+plan_ 10
+
+check_image_() {
+ dx_pam_header "$1" > "$1.sh" || return
+ . "./$1.sh" || return
+
+ tail -n +"$ENDHDR" "$1" > "$1.px" || return
+ echo "$2 $1.px" > "$1.md5" || return
+ $MD5SUM -c "$1.md5"
+}
+
+check_image() {
+ if $HAVE_MD5SUM; then
+ command_ok_ "$1" check_image_ "$1" "$2"
+ else
+ skip_ "$1"
+ fi
+}
+
+command_ok_ "unpacking fonts.lbx" $LBXTOOL -xf "$MOO2DATA/fonts.lbx"
+command_ok_ "unpacking mainmenu.lbx" $LBXTOOL -xf "$MOO2DATA/mainmenu.lbx"
+
+command_ok_ "decoding mainmenu.lbx.021" \
+ $LBXIMG -F pam --output-prefix test0 -df mainmenu.lbx.021
+check_image "test0.000.pam" 848e33a0addc6e9acdc4fee6cbd56639
+
+command_ok_ "decoding mainmenu.lbx.007" \
+ $LBXIMG -F pam --output-prefix test1 --palette fonts.lbx.006 \
+ -df mainmenu.lbx.007
+check_image "test1.000.pam" f301ffcc1a2faa3a0aa68514784012ec
+
+command_ok_ "decoding mainmenu.lbx.000" \
+ $LBXIMG -F pam --output-prefix test2 --palette fonts.lbx.006 \
+ -df mainmenu.lbx.000
+check_image "test2.000.pam" 7c3b347e03d42cd7bd1597f9dd58594e
+check_image "test2.015.pam" 2a66f4c30ca315cc061606b27cef4adf
+check_image "test2.049.pam" 848e33a0addc6e9acdc4fee6cbd56639