2011-06-10 05:45:18 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on original Soltys source code
|
|
|
|
* Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon
|
|
|
|
*/
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
#include "cge/bitmap.h"
|
2011-06-27 08:57:58 +00:00
|
|
|
#include "cge/vga13h.h"
|
2011-07-20 23:56:40 +00:00
|
|
|
#include "cge/cge_main.h"
|
2011-06-11 07:33:17 +00:00
|
|
|
#include "common/system.h"
|
2011-07-18 16:05:57 +00:00
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-06-10 20:57:09 +00:00
|
|
|
namespace CGE {
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-09-16 21:54:08 +00:00
|
|
|
Bitmap::Bitmap(CGEEngine *vm, const char *fname) : _m(NULL), _v(NULL), _map(0), _vm(vm) {
|
2011-08-19 17:48:49 +00:00
|
|
|
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%s)", fname);
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-07-19 06:42:58 +00:00
|
|
|
char pat[kMaxPath];
|
2011-07-01 23:02:14 +00:00
|
|
|
forceExt(pat, fname, ".VBM");
|
2011-06-13 09:57:24 +00:00
|
|
|
|
2011-09-17 08:54:50 +00:00
|
|
|
if (_vm->_resman->exist(pat)) {
|
|
|
|
EncryptedStream file(_vm, pat);
|
2011-09-11 21:57:55 +00:00
|
|
|
if (file.err())
|
|
|
|
error("Unable to find VBM [%s]", fname);
|
|
|
|
if (!loadVBM(&file))
|
2011-06-13 09:57:24 +00:00
|
|
|
error("Bad VBM [%s]", fname);
|
2011-08-19 17:48:49 +00:00
|
|
|
} else {
|
2011-06-13 09:57:24 +00:00
|
|
|
error("Bad VBM [%s]", fname);
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-17 05:57:36 +00:00
|
|
|
Bitmap::Bitmap(CGEEngine *vm, uint16 w, uint16 h, uint8 *map) : _w(w), _h(h), _m(map), _v(NULL), _map(0), _b(NULL), _vm(vm) {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, map)", w, h);
|
2011-06-13 09:57:24 +00:00
|
|
|
if (map)
|
2011-06-30 06:30:23 +00:00
|
|
|
code();
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// following routine creates filled rectangle
|
|
|
|
// immediately as VGA video chunks, in near memory as fast as possible,
|
|
|
|
// especially for text line real time display
|
2011-09-16 21:54:08 +00:00
|
|
|
Bitmap::Bitmap(CGEEngine *vm, uint16 w, uint16 h, uint8 fill)
|
2011-06-29 14:13:17 +00:00
|
|
|
: _w((w + 3) & ~3), // only full uint32 allowed!
|
2013-04-17 05:57:36 +00:00
|
|
|
_h(h), _m(NULL), _map(0), _b(NULL), _vm(vm) {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(%d, %d, %d)", w, h, fill);
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
uint16 dsiz = _w >> 2; // data size (1 plane line size)
|
2011-06-13 09:57:24 +00:00
|
|
|
uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
|
2011-06-29 14:13:17 +00:00
|
|
|
uint16 psiz = _h * lsiz; // - last gape, but + plane trailer
|
|
|
|
uint8 *v = new uint8[4 * psiz + _h * sizeof(*_b)];// the same for 4 planes
|
2011-06-13 09:57:24 +00:00
|
|
|
// + room for wash table
|
2011-07-25 14:04:45 +00:00
|
|
|
assert(v != NULL);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
2011-08-19 12:54:34 +00:00
|
|
|
*(uint16 *) v = TO_LE_16(kBmpCPY | dsiz); // data chunk hader
|
2011-06-13 09:57:24 +00:00
|
|
|
memset(v + 2, fill, dsiz); // data bytes
|
2011-08-19 12:54:34 +00:00
|
|
|
*(uint16 *)(v + lsiz - 2) = TO_LE_16(kBmpSKP | ((kScrWidth / 4) - dsiz)); // gap
|
2011-07-03 05:32:27 +00:00
|
|
|
|
|
|
|
// Replicate lines
|
|
|
|
byte *destP;
|
|
|
|
for (destP = v + lsiz; destP < (v + psiz); destP += lsiz)
|
|
|
|
Common::copy(v, v + lsiz, destP);
|
|
|
|
|
2011-08-19 12:54:34 +00:00
|
|
|
*(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16
|
2011-07-03 05:32:27 +00:00
|
|
|
|
2011-08-19 17:48:49 +00:00
|
|
|
// Replicate planes
|
2011-07-03 05:32:27 +00:00
|
|
|
for (destP = v + psiz; destP < (v + 4 * psiz); destP += psiz)
|
|
|
|
Common::copy(v, v + psiz, destP);
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
HideDesc *b = (HideDesc *)(v + 4 * psiz);
|
2011-07-20 23:56:40 +00:00
|
|
|
b->_skip = (kScrWidth - _w) >> 2;
|
2011-07-18 16:05:57 +00:00
|
|
|
b->_hide = _w >> 2;
|
2011-07-03 05:41:07 +00:00
|
|
|
|
|
|
|
// Replicate across the entire table
|
2011-07-30 22:52:35 +00:00
|
|
|
for (HideDesc *hdP = b + 1; hdP < (b + _h); hdP++)
|
2011-07-03 05:41:07 +00:00
|
|
|
*hdP = *b;
|
2012-09-26 02:17:31 +00:00
|
|
|
|
2011-07-18 16:05:57 +00:00
|
|
|
b->_skip = 0; // fix the first entry
|
2011-06-29 14:13:17 +00:00
|
|
|
_v = v;
|
|
|
|
_b = b;
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
2013-04-17 05:57:36 +00:00
|
|
|
Bitmap::Bitmap(CGEEngine *vm, const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL), _map(0), _b(NULL), _vm(vm) {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(1, kCGEDebugBitmap, "Bitmap::Bitmap(bmp)");
|
2011-06-29 14:13:17 +00:00
|
|
|
uint8 *v0 = bmp._v;
|
2011-08-19 14:04:10 +00:00
|
|
|
if (!v0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0);
|
|
|
|
uint16 siz = vsiz + _h * sizeof(HideDesc);
|
|
|
|
uint8 *v1 = new uint8[siz];
|
|
|
|
assert(v1 != NULL);
|
|
|
|
memcpy(v1, v0, siz);
|
|
|
|
_b = (HideDesc *)((_v = v1) + vsiz);
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 21:13:12 +00:00
|
|
|
Bitmap::~Bitmap() {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(6, kCGEDebugBitmap, "Bitmap::~Bitmap()");
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-07-12 06:02:18 +00:00
|
|
|
free(_m);
|
2011-07-12 05:24:20 +00:00
|
|
|
delete[] _v;
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
2011-09-11 20:24:40 +00:00
|
|
|
Bitmap &Bitmap::operator=(const Bitmap &bmp) {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(1, kCGEDebugBitmap, "&Bitmap::operator =");
|
2012-07-04 21:36:11 +00:00
|
|
|
if (this == &bmp)
|
|
|
|
return *this;
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
uint8 *v0 = bmp._v;
|
|
|
|
_w = bmp._w;
|
|
|
|
_h = bmp._h;
|
|
|
|
_m = NULL;
|
2011-07-12 05:24:20 +00:00
|
|
|
_map = 0;
|
2012-07-04 21:36:11 +00:00
|
|
|
_vm = bmp._vm;
|
2011-08-13 07:16:15 +00:00
|
|
|
delete[] _v;
|
2011-08-19 14:04:10 +00:00
|
|
|
|
|
|
|
if (v0 == NULL) {
|
2011-06-29 14:13:17 +00:00
|
|
|
_v = NULL;
|
2011-08-19 14:04:10 +00:00
|
|
|
} else {
|
2011-06-29 14:13:17 +00:00
|
|
|
uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0;
|
|
|
|
uint16 siz = vsiz + _h * sizeof(HideDesc);
|
2011-11-27 07:40:12 +00:00
|
|
|
uint8 *v1 = new uint8[siz];
|
2011-07-25 14:04:45 +00:00
|
|
|
assert(v1 != NULL);
|
2011-06-13 09:57:24 +00:00
|
|
|
memcpy(v1, v0, siz);
|
2011-06-29 14:13:17 +00:00
|
|
|
_b = (HideDesc *)((_v = v1) + vsiz);
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
|
|
|
return *this;
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
2011-09-15 05:58:31 +00:00
|
|
|
char *Bitmap::forceExt(char *buf, const char *name, const char *ext) {
|
|
|
|
strcpy(buf, name);
|
|
|
|
char *dot = strrchr(buf, '.');
|
|
|
|
if (dot)
|
|
|
|
*dot = '\0';
|
|
|
|
strcat(buf, ext);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2011-07-30 22:52:35 +00:00
|
|
|
BitmapPtr Bitmap::code() {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(1, kCGEDebugBitmap, "Bitmap::code()");
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-07-12 05:24:20 +00:00
|
|
|
if (!_m)
|
2011-12-08 07:04:41 +00:00
|
|
|
return NULL;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-08-19 14:04:10 +00:00
|
|
|
uint16 cnt;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-07-12 05:24:20 +00:00
|
|
|
if (_v) { // old X-map exists, so remove it
|
|
|
|
delete[] _v;
|
|
|
|
_v = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (true) { // at most 2 times: for (V == NULL) & for allocated block;
|
|
|
|
uint8 *im = _v + 2;
|
|
|
|
uint16 *cp = (uint16 *) _v;
|
|
|
|
int bpl;
|
|
|
|
|
|
|
|
if (_v) { // 2nd pass - fill the hide table
|
2011-08-19 14:04:10 +00:00
|
|
|
for (uint16 i = 0; i < _h; i++) {
|
2011-07-18 16:05:57 +00:00
|
|
|
_b[i]._skip = 0xFFFF;
|
|
|
|
_b[i]._hide = 0x0000;
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
2011-07-12 05:24:20 +00:00
|
|
|
}
|
|
|
|
for (bpl = 0; bpl < 4; bpl++) { // once per each bitplane
|
|
|
|
uint8 *bm = _m;
|
2011-07-19 06:42:58 +00:00
|
|
|
bool skip = (bm[bpl] == kPixelTransp);
|
2011-07-12 05:24:20 +00:00
|
|
|
uint16 j;
|
|
|
|
|
|
|
|
cnt = 0;
|
2011-08-19 14:04:10 +00:00
|
|
|
for (uint16 i = 0; i < _h; i++) { // once per each line
|
2011-07-12 05:24:20 +00:00
|
|
|
uint8 pix;
|
|
|
|
for (j = bpl; j < _w; j += 4) {
|
|
|
|
pix = bm[j];
|
2011-07-19 06:42:58 +00:00
|
|
|
if (_v && pix != kPixelTransp) {
|
2011-07-18 16:05:57 +00:00
|
|
|
if (j < _b[i]._skip)
|
|
|
|
_b[i]._skip = j;
|
2011-07-12 05:24:20 +00:00
|
|
|
|
2011-07-18 16:05:57 +00:00
|
|
|
if (j >= _b[i]._hide)
|
|
|
|
_b[i]._hide = j + 1;
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
2011-07-19 06:42:58 +00:00
|
|
|
if ((pix == kPixelTransp) != skip || cnt >= 0x3FF0) { // end of block
|
|
|
|
cnt |= (skip) ? kBmpSKP : kBmpCPY;
|
2011-07-12 05:24:20 +00:00
|
|
|
if (_v)
|
2012-02-22 22:18:50 +00:00
|
|
|
WRITE_LE_UINT16(cp, cnt); // store block description uint16
|
2011-07-12 05:24:20 +00:00
|
|
|
|
|
|
|
cp = (uint16 *) im;
|
|
|
|
im += 2;
|
2011-07-19 06:42:58 +00:00
|
|
|
skip = (pix == kPixelTransp);
|
2011-07-12 05:24:20 +00:00
|
|
|
cnt = 0;
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
2011-08-19 22:40:44 +00:00
|
|
|
if (!skip) {
|
2011-07-12 05:24:20 +00:00
|
|
|
if (_v)
|
|
|
|
*im = pix;
|
2011-07-25 14:04:45 +00:00
|
|
|
im++;
|
2011-07-12 05:24:20 +00:00
|
|
|
}
|
2011-07-25 14:04:45 +00:00
|
|
|
cnt++;
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
|
|
|
|
2011-07-12 05:24:20 +00:00
|
|
|
bm += _w;
|
2011-07-20 23:56:40 +00:00
|
|
|
if (_w < kScrWidth) {
|
2011-07-12 05:24:20 +00:00
|
|
|
if (skip) {
|
2011-07-20 23:56:40 +00:00
|
|
|
cnt += (kScrWidth - j + 3) / 4;
|
2011-07-12 05:24:20 +00:00
|
|
|
} else {
|
2011-07-19 06:42:58 +00:00
|
|
|
cnt |= kBmpCPY;
|
2011-07-12 05:24:20 +00:00
|
|
|
if (_v)
|
2012-02-22 22:18:50 +00:00
|
|
|
WRITE_LE_UINT16(cp, cnt);
|
2011-07-12 05:24:20 +00:00
|
|
|
|
|
|
|
cp = (uint16 *) im;
|
|
|
|
im += 2;
|
|
|
|
skip = true;
|
2011-07-20 23:56:40 +00:00
|
|
|
cnt = (kScrWidth - j + 3) / 4;
|
2011-07-12 05:24:20 +00:00
|
|
|
}
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
2011-07-12 05:24:20 +00:00
|
|
|
}
|
|
|
|
if (cnt && ! skip) {
|
2011-07-19 06:42:58 +00:00
|
|
|
cnt |= kBmpCPY;
|
2011-06-29 14:13:17 +00:00
|
|
|
if (_v)
|
2012-02-22 22:18:50 +00:00
|
|
|
WRITE_LE_UINT16(cp, cnt);
|
2011-07-12 05:24:20 +00:00
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
cp = (uint16 *) im;
|
|
|
|
im += 2;
|
|
|
|
}
|
2011-06-29 14:13:17 +00:00
|
|
|
if (_v)
|
2012-02-22 22:18:50 +00:00
|
|
|
WRITE_LE_UINT16(cp, kBmpEOI);
|
2011-07-12 05:24:20 +00:00
|
|
|
cp = (uint16 *) im;
|
|
|
|
im += 2;
|
|
|
|
}
|
|
|
|
if (_v)
|
|
|
|
break;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-07-12 05:24:20 +00:00
|
|
|
uint16 sizV = (uint16)(im - 2 - _v);
|
|
|
|
_v = new uint8[sizV + _h * sizeof(*_b)];
|
2011-07-25 14:04:45 +00:00
|
|
|
assert(_v != NULL);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-07-12 05:24:20 +00:00
|
|
|
_b = (HideDesc *)(_v + sizV);
|
|
|
|
}
|
|
|
|
cnt = 0;
|
2011-08-19 14:04:10 +00:00
|
|
|
for (uint16 i = 0; i < _h; i++) {
|
2011-07-18 16:05:57 +00:00
|
|
|
if (_b[i]._skip == 0xFFFF) { // whole line is skipped
|
2011-07-20 23:56:40 +00:00
|
|
|
_b[i]._skip = (cnt + kScrWidth) >> 2;
|
2011-07-12 05:24:20 +00:00
|
|
|
cnt = 0;
|
|
|
|
} else {
|
2011-07-18 16:05:57 +00:00
|
|
|
uint16 s = _b[i]._skip & ~3;
|
|
|
|
uint16 h = (_b[i]._hide + 3) & ~3;
|
|
|
|
_b[i]._skip = (cnt + s) >> 2;
|
|
|
|
_b[i]._hide = (h - s) >> 2;
|
2011-07-20 23:56:40 +00:00
|
|
|
cnt = kScrWidth - h;
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-12 05:24:20 +00:00
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
return this;
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
2011-07-12 05:24:20 +00:00
|
|
|
bool Bitmap::solidAt(int16 x, int16 y) {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(6, kCGEDebugBitmap, "Bitmap::solidAt(%d, %d)", x, y);
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
if ((x >= _w) || (y >= _h))
|
2011-06-13 09:57:24 +00:00
|
|
|
return false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-08-19 14:04:10 +00:00
|
|
|
uint8 *m = _v;
|
|
|
|
uint16 r = static_cast<uint16>(x) % 4;
|
|
|
|
uint16 n0 = (kScrWidth * y + x) / 4;
|
|
|
|
uint16 n = 0;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
while (r) {
|
|
|
|
uint16 w, t;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-08-19 12:54:34 +00:00
|
|
|
w = READ_LE_UINT16(m);
|
2011-06-13 09:57:24 +00:00
|
|
|
m += 2;
|
|
|
|
t = w & 0xC000;
|
|
|
|
w &= 0x3FFF;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
switch (t) {
|
2011-07-19 06:42:58 +00:00
|
|
|
case kBmpEOI:
|
2011-06-29 14:13:17 +00:00
|
|
|
r--;
|
2011-07-19 06:42:58 +00:00
|
|
|
case kBmpSKP:
|
2011-06-13 09:57:24 +00:00
|
|
|
w = 0;
|
|
|
|
break;
|
2011-07-19 06:42:58 +00:00
|
|
|
case kBmpREP:
|
2011-06-13 09:57:24 +00:00
|
|
|
w = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m += w;
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
while (true) {
|
|
|
|
uint16 w, t;
|
|
|
|
|
2011-08-19 12:54:34 +00:00
|
|
|
w = READ_LE_UINT16(m);
|
2011-06-13 09:57:24 +00:00
|
|
|
m += 2;
|
|
|
|
t = w & 0xC000;
|
|
|
|
w &= 0x3FFF;
|
|
|
|
|
|
|
|
if (n > n0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
n += w;
|
|
|
|
switch (t) {
|
2011-07-19 06:42:58 +00:00
|
|
|
case kBmpEOI:
|
2011-06-13 09:57:24 +00:00
|
|
|
return false;
|
2011-07-19 06:42:58 +00:00
|
|
|
case kBmpSKP:
|
2011-06-13 09:57:24 +00:00
|
|
|
w = 0;
|
|
|
|
break;
|
2011-07-19 06:42:58 +00:00
|
|
|
case kBmpREP:
|
|
|
|
case kBmpCPY:
|
2011-06-13 09:57:24 +00:00
|
|
|
if (n - w <= n0 && n > n0)
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
2011-07-19 06:42:58 +00:00
|
|
|
m += ((t == kBmpREP) ? 1 : w);
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-11 21:57:55 +00:00
|
|
|
bool Bitmap::loadVBM(EncryptedStream *f) {
|
2011-07-20 12:22:56 +00:00
|
|
|
debugC(5, kCGEDebugBitmap, "Bitmap::loadVBM(f)");
|
2011-07-18 16:05:57 +00:00
|
|
|
|
2011-06-13 09:57:24 +00:00
|
|
|
uint16 p = 0, n = 0;
|
2011-09-11 21:57:55 +00:00
|
|
|
if (!f->err())
|
2011-06-30 06:30:23 +00:00
|
|
|
f->read((uint8 *)&p, sizeof(p));
|
2011-08-19 12:55:44 +00:00
|
|
|
p = FROM_LE_16(p);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-09-11 21:57:55 +00:00
|
|
|
if (!f->err())
|
2011-06-30 06:30:23 +00:00
|
|
|
f->read((uint8 *)&n, sizeof(n));
|
2011-08-19 12:55:44 +00:00
|
|
|
n = FROM_LE_16(n);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-09-11 21:57:55 +00:00
|
|
|
if (!f->err())
|
2011-06-30 06:30:23 +00:00
|
|
|
f->read((uint8 *)&_w, sizeof(_w));
|
2011-08-19 12:55:44 +00:00
|
|
|
_w = FROM_LE_16(_w);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-09-11 21:57:55 +00:00
|
|
|
if (!f->err())
|
2011-06-30 06:30:23 +00:00
|
|
|
f->read((uint8 *)&_h, sizeof(_h));
|
2011-08-19 12:55:44 +00:00
|
|
|
_h = FROM_LE_16(_h);
|
2011-06-13 09:57:24 +00:00
|
|
|
|
2011-09-11 21:57:55 +00:00
|
|
|
if (!f->err()) {
|
2011-06-13 09:57:24 +00:00
|
|
|
if (p) {
|
2011-09-17 15:17:22 +00:00
|
|
|
if (_vm->_bitmapPalette) {
|
2011-07-01 08:04:21 +00:00
|
|
|
// Read in the palette
|
2011-07-30 22:52:35 +00:00
|
|
|
byte palData[kPalSize];
|
|
|
|
f->read(palData, kPalSize);
|
2012-09-26 02:17:31 +00:00
|
|
|
|
2011-07-01 08:04:21 +00:00
|
|
|
const byte *srcP = palData;
|
2011-07-30 22:52:35 +00:00
|
|
|
for (int idx = 0; idx < kPalCount; idx++, srcP += 3) {
|
2011-09-17 15:17:22 +00:00
|
|
|
_vm->_bitmapPalette[idx]._r = *srcP;
|
|
|
|
_vm->_bitmapPalette[idx]._g = *(srcP + 1);
|
|
|
|
_vm->_bitmapPalette[idx]._b = *(srcP + 2);
|
2011-07-01 08:04:21 +00:00
|
|
|
}
|
2011-06-27 08:57:58 +00:00
|
|
|
} else
|
2011-09-11 21:57:55 +00:00
|
|
|
f->seek(f->pos() + kPalSize);
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
2011-06-09 06:20:53 +00:00
|
|
|
}
|
2011-07-10 07:56:29 +00:00
|
|
|
if ((_v = new uint8[n]) == NULL)
|
2011-06-13 09:57:24 +00:00
|
|
|
return false;
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-09-11 21:57:55 +00:00
|
|
|
if (!f->err())
|
2011-06-30 06:30:23 +00:00
|
|
|
f->read(_v, n);
|
2011-06-09 06:20:53 +00:00
|
|
|
|
2011-06-29 14:13:17 +00:00
|
|
|
_b = (HideDesc *)(_v + n - _h * sizeof(HideDesc));
|
2011-09-11 21:57:55 +00:00
|
|
|
return (!f->err());
|
2011-06-13 09:57:24 +00:00
|
|
|
}
|
2011-06-28 22:35:21 +00:00
|
|
|
|
2011-06-10 20:57:09 +00:00
|
|
|
} // End of namespace CGE
|