fixed one warning from GCC 4.7.0
[awish.git] / tools / unvpi.bob
blob1878e1e24036123b74366d18fc3bbe361a15b02c
1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2  * Understanding is not required. Only obedience.
3  *
4  * This program is free software. It comes without any warranty, to
5  * the extent permitted by applicable law. You can redistribute it
6  * and/or modify it under the terms of the Do What The Fuck You Want
7  * To Public License, Version 2, as published by Sam Hocevar. See
8  * http://sam.zoy.org/wtfpl/COPYING for more details. */
9 define unpackVPI (fl) {
10   local pos, opos, cpos, size = fl.size, data = fl.readBuf(size), dest;
11   //
12   if (size >= 320*200) return data;
13   pos = opos = cpos = 0;
14   dest = new String(320*200);
15   while (opos < 320*200 && pos+2 <= size) {
16     local csz = data[pos]+256*data[pos+1]; // picture chunk size
17     //
18     cpos = (pos += 2); // colormap
19     pos += 512; // skip colormap
20     while (opos < 320*200 && pos < size && csz > 0) {
21       local idx = data[pos++];
22       //
23       dest[opos++] = data[cpos+idx*2+0];
24       dest[opos++] = data[cpos+idx*2+1];
25       --csz;
26     }
27   }
28   return dest;
32 for (local f = 0; f < args.length; ++f) {
33   local fl = new File(args[f], "rb");
34   //
35   if (fl) {
36     local upk;
37     //
38     writeln(args[f]);
39     upk = unpackVPI(fl);
40     fl.close();
41     fl = new File(args[f], "wb");
42     fl.write(upk);
43     fl.close();
44   }