1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
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;
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
18 cpos = (pos += 2); // colormap
19 pos += 512; // skip colormap
20 while (opos < 320*200 && pos < size && csz > 0) {
21 local idx = data[pos++];
23 dest[opos++] = data[cpos+idx*2+0];
24 dest[opos++] = data[cpos+idx*2+1];
32 for (local f = 0; f < args.length; ++f) {
33 local fl = new File(args[f], "rb");
41 fl = new File(args[f], "wb");