2019-01-22 11:11:00 +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.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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.
|
2019-01-22 11:11:00 +00:00
|
|
|
|
|
|
|
* 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
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-01-22 11:11:00 +00:00
|
|
|
*
|
|
|
|
*/
|
2019-02-02 12:42:01 +00:00
|
|
|
#include "common/memstream.h"
|
2020-02-05 12:16:21 +00:00
|
|
|
#include "dragons/dragonobd.h"
|
2022-04-16 11:25:51 +00:00
|
|
|
#include "dragons/bigfile.h"
|
2019-01-22 11:11:00 +00:00
|
|
|
|
|
|
|
namespace Dragons {
|
|
|
|
|
|
|
|
DragonOBD::DragonOBD(BigfileArchive *bigfileArchive) {
|
2019-02-02 12:42:01 +00:00
|
|
|
uint32 size;
|
2022-04-16 11:25:51 +00:00
|
|
|
byte *optData = bigfileArchive->load("dragon.opt", size);
|
|
|
|
_optReadStream = new Common::MemoryReadStream(optData, size, DisposeAfterUse::YES);
|
2019-05-19 10:30:58 +00:00
|
|
|
|
2022-04-16 11:25:51 +00:00
|
|
|
byte *sptData = bigfileArchive->load("dragon.spt", size);
|
|
|
|
_sptReadStream = new Common::MemoryReadStream(sptData, size, DisposeAfterUse::YES);
|
2019-02-02 12:42:01 +00:00
|
|
|
|
2022-04-16 11:25:51 +00:00
|
|
|
_data = bigfileArchive->load("dragon.obd", _dataSize);
|
2019-01-22 11:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
byte *DragonOBD::getObdAtOffset(uint32 offset) {
|
|
|
|
assert(_data);
|
|
|
|
assert(offset < _dataSize);
|
|
|
|
return &_data[offset];
|
|
|
|
}
|
|
|
|
|
|
|
|
DragonOBD::~DragonOBD() {
|
|
|
|
if (_data) {
|
|
|
|
delete _data;
|
|
|
|
}
|
2020-02-07 14:25:30 +00:00
|
|
|
delete _optReadStream;
|
|
|
|
delete _sptReadStream;
|
2019-02-02 12:42:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
byte *DragonOBD::getFromOpt(uint32 index) {
|
2020-02-07 14:25:30 +00:00
|
|
|
_optReadStream->seek(index * 8);
|
|
|
|
return getObdAtOffset(_optReadStream->readUint32LE());
|
2019-01-22 11:11:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-19 10:30:58 +00:00
|
|
|
byte *DragonOBD::getFromSpt(uint32 index) {
|
2020-02-07 14:25:30 +00:00
|
|
|
_sptReadStream->seek(index * 4);
|
|
|
|
return getObdAtOffset(_sptReadStream->readUint32LE());
|
2019-05-19 10:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 11:11:00 +00:00
|
|
|
} // End of namespace Dragons
|