scummvm/engines/dragons/dragonimg.cpp

70 lines
2.3 KiB
C++
Raw Normal View History

/* 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.
*
*/
2020-02-06 22:00:33 +00:00
#include "common/memstream.h"
2020-02-05 12:16:21 +00:00
#include "dragons/dragonimg.h"
#include "dragons/bigfile.h"
namespace Dragons {
2020-02-07 14:25:30 +00:00
DragonImg::DragonImg(BigfileArchive *bigfileArchive) {
uint32 fileSize;
byte *iptData = bigfileArchive->load("dragon.ipt", fileSize);
Common::SeekableReadStream *iptReadStream = new Common::MemoryReadStream(iptData, fileSize, DisposeAfterUse::YES);
_count = fileSize / 4;
2019-03-01 09:04:38 +00:00
_imgData = bigfileArchive->load("dragon.img", fileSize);
Common::SeekableReadStream *imgReadStream = new Common::MemoryReadStream(_imgData, fileSize, DisposeAfterUse::NO);
2020-02-07 14:25:30 +00:00
_imgObjects = new Img[_count];
2020-02-07 13:43:18 +00:00
for (int i = 0; i < _count; i++) {
imgReadStream->seek(iptReadStream->readUint32LE());
_imgObjects[i].x = imgReadStream->readUint16LE();
_imgObjects[i].y = imgReadStream->readUint16LE();
_imgObjects[i].w = imgReadStream->readUint16LE();
_imgObjects[i].h = imgReadStream->readUint16LE();
_imgObjects[i].layerNum = imgReadStream->readUint16LE();
_imgObjects[i].field_a = imgReadStream->readUint16LE();
_imgObjects[i].field_c = imgReadStream->readUint16LE();
_imgObjects[i].field_e = imgReadStream->readUint16LE();
2019-03-01 09:04:38 +00:00
_imgObjects[i].data = _imgData + imgReadStream->pos();
}
2019-03-01 09:04:38 +00:00
delete iptReadStream;
delete imgReadStream;
}
2020-02-07 14:25:30 +00:00
DragonImg::~DragonImg() {
2019-03-01 09:04:38 +00:00
delete _imgData;
2020-05-04 10:35:06 +00:00
delete[] _imgObjects;
}
2020-02-07 14:25:30 +00:00
Img *DragonImg::getImg(uint32 iptId) {
iptId &= 0xffff;
assert(iptId < _count);
return &_imgObjects[iptId];
}
} // End of namespace Dragons