mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-06 01:31:39 +00:00
TRECISION: BM files are always little-endian
This commit is contained in:
parent
f25b899e1d
commit
2ffcd00393
@ -24,6 +24,7 @@
|
||||
#include "common/str.h"
|
||||
#include "common/substream.h"
|
||||
#include "common/memstream.h"
|
||||
#include "common/file.h"
|
||||
#include "trecision/trecision.h"
|
||||
#include "trecision/fastfile.h"
|
||||
#include "trecision/video.h"
|
||||
@ -93,13 +94,28 @@ Common::SeekableReadStream *FastFile::createReadStreamForMember(const Common::St
|
||||
if (!_stream)
|
||||
return nullptr;
|
||||
|
||||
Common::SeekableReadStream *stream = nullptr;
|
||||
const FileEntry *entry = getEntry(name);
|
||||
if (entry) {
|
||||
uint32 size = (entry + 1)->offset - entry->offset;
|
||||
return new Common::SeekableSubReadStream(_stream, entry->offset, entry->offset + size);
|
||||
if (entry->offset + size < _stream->size()) {
|
||||
// Load data from fast file
|
||||
stream = new Common::SeekableSubReadStream(_stream, entry->offset, entry->offset + size);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
if (!stream) {
|
||||
// Load data from external file
|
||||
Common::File *file = new Common::File();
|
||||
if (file->open(name)) {
|
||||
stream = file;
|
||||
} else {
|
||||
delete file;
|
||||
}
|
||||
}
|
||||
if (!stream) {
|
||||
warning("FastFile - %s not found", name.c_str());
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
void FastFile::decompress(const unsigned char *src, uint32 srcSize, unsigned char *dst, uint32 decompSize) {
|
||||
|
@ -85,6 +85,10 @@ void TrecisionEngine::loadAll() {
|
||||
|
||||
data->skip(620); // actions (unused)
|
||||
|
||||
// TODO: Amiga hack
|
||||
if (isAmiga())
|
||||
dataNl.seek(0x3DB62);
|
||||
|
||||
int numFileRef = data->readSint32();
|
||||
data->skip(numFileRef * (12 + 4)); // fileRef name + offset
|
||||
|
||||
@ -137,7 +141,7 @@ void TrecisionEngine::read3D(const Common::String &filename) {
|
||||
_renderer->setClipping(0, TOP, MAXX, AREA + TOP);
|
||||
}
|
||||
|
||||
void TrecisionEngine::readObject(Common::SeekableReadStreamEndian *stream, uint16 objIndex, uint16 objectId) {
|
||||
void TrecisionEngine::readObject(Common::SeekableReadStream *stream, uint16 objIndex, uint16 objectId) {
|
||||
SObject *obj = &_obj[objectId];
|
||||
|
||||
if (obj->isModeFull()) {
|
||||
@ -147,7 +151,7 @@ void TrecisionEngine::readObject(Common::SeekableReadStreamEndian *stream, uint1
|
||||
delete[] _objPointers[objIndex];
|
||||
_objPointers[objIndex] = new uint16[size];
|
||||
for (uint32 i = 0; i < size; ++i)
|
||||
_objPointers[objIndex][i] = stream->readUint16();
|
||||
_objPointers[objIndex][i] = stream->readUint16LE();
|
||||
|
||||
_graphicsMgr->updatePixelFormat(_objPointers[objIndex], size);
|
||||
}
|
||||
@ -155,15 +159,15 @@ void TrecisionEngine::readObject(Common::SeekableReadStreamEndian *stream, uint1
|
||||
if (obj->isModeMask()) {
|
||||
obj->readRect(stream);
|
||||
|
||||
uint32 size = stream->readUint32();
|
||||
uint32 size = stream->readUint32LE();
|
||||
delete[] _objPointers[objIndex];
|
||||
_objPointers[objIndex] = new uint16[size];
|
||||
for (uint32 i = 0; i < size; ++i)
|
||||
_objPointers[objIndex][i] = stream->readUint16();
|
||||
_objPointers[objIndex][i] = stream->readUint16LE();
|
||||
|
||||
_graphicsMgr->updatePixelFormat(_objPointers[objIndex], size);
|
||||
|
||||
size = stream->readUint32();
|
||||
size = stream->readUint32LE();
|
||||
delete[] _maskPointers[objIndex];
|
||||
_maskPointers[objIndex] = new uint8[size];
|
||||
for (uint32 i = 0; i < size; ++i)
|
||||
@ -173,7 +177,7 @@ void TrecisionEngine::readObject(Common::SeekableReadStreamEndian *stream, uint1
|
||||
refreshObject(objectId);
|
||||
}
|
||||
|
||||
void TrecisionEngine::readObj(Common::SeekableReadStreamEndian *stream) {
|
||||
void TrecisionEngine::readObj(Common::SeekableReadStream *stream) {
|
||||
if (!_room[_curRoom]._object[0])
|
||||
return;
|
||||
|
||||
@ -196,7 +200,7 @@ void TrecisionEngine::readExtraObj2C() {
|
||||
if (!_room[_curRoom]._object[32])
|
||||
return;
|
||||
|
||||
Common::SeekableReadStreamEndian *ff = readEndian(_dataFile.createReadStreamForMember("2c2.bm"));
|
||||
Common::SeekableReadStream *ff = _dataFile.createReadStreamForMember("2c2.bm");
|
||||
|
||||
for (uint16 objIndex = PATCHOBJ_ROOM2C; objIndex < MAXOBJINROOM; objIndex++) {
|
||||
const uint16 objectId = _room[_curRoom]._object[objIndex];
|
||||
@ -213,7 +217,7 @@ void TrecisionEngine::readExtraObj41D() {
|
||||
if (!_room[_curRoom]._object[32])
|
||||
return;
|
||||
|
||||
Common::SeekableReadStreamEndian *ff = readEndian(_dataFile.createReadStreamForMember("41d2.bm"));
|
||||
Common::SeekableReadStream *ff = _dataFile.createReadStreamForMember("41d2.bm");
|
||||
for (uint16 objIndex = PATCHOBJ_ROOM41D; objIndex < MAXOBJINROOM; objIndex++) {
|
||||
const uint16 objectId = _room[_curRoom]._object[objIndex];
|
||||
if (!objectId)
|
||||
|
@ -47,11 +47,11 @@ void SRoom::syncGameStream(Common::Serializer &ser) {
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
void SObject::readRect(Common::SeekableReadStreamEndian *stream) {
|
||||
_rect.left = stream->readUint16();
|
||||
_rect.top = stream->readUint16();
|
||||
_rect.setWidth(stream->readUint16());
|
||||
_rect.setHeight(stream->readUint16());
|
||||
void SObject::readRect(Common::SeekableReadStream *stream) {
|
||||
_rect.left = stream->readUint16LE();
|
||||
_rect.top = stream->readUint16LE();
|
||||
_rect.setWidth(stream->readUint16LE());
|
||||
_rect.setHeight(stream->readUint16LE());
|
||||
}
|
||||
|
||||
void SObject::syncGameStream(Common::Serializer &ser) {
|
||||
|
@ -63,7 +63,7 @@ struct SObject {
|
||||
uint8 _ninv; // ptr inventory
|
||||
uint16 _anim;
|
||||
|
||||
void readRect(Common::SeekableReadStreamEndian *stream);
|
||||
void readRect(Common::SeekableReadStream *stream);
|
||||
void setFlagDone(bool on) { if (on) _flag |= kObjFlagDone; else _flag &= ~kObjFlagDone; }
|
||||
void setFlagExamine(bool on) { if (on) _flag |= kObjFlagExamine; else _flag &= ~kObjFlagExamine; }
|
||||
void setFlagExtra(bool on) { if (on) _flag |= kObjFlagExtra; else _flag &= ~kObjFlagExtra; }
|
||||
|
@ -54,6 +54,12 @@ TrecisionEngine::TrecisionEngine(OSystem *syst, const ADGameDescription *desc) :
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "AUTORUN");
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "DATA");
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "FMV");
|
||||
// Amiga version loads data files from directories
|
||||
if (isAmiga()) {
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "NLDATA.CD0");
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "NLSPEECH.CD0");
|
||||
SearchMan.addSubDirectoryMatching(gameDataDir, "NLANIM.CDX");
|
||||
}
|
||||
|
||||
_curRoom = 0;
|
||||
_oldRoom = 0;
|
||||
@ -376,8 +382,15 @@ void TrecisionEngine::readLoc() {
|
||||
|
||||
_graphicsMgr->clearScreenBufferTop();
|
||||
|
||||
Common::String filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
|
||||
Common::SeekableReadStreamEndian *picFile = readEndian(_dataFile.createReadStreamForCompressedMember(filename));
|
||||
Common::String filename;
|
||||
Common::SeekableReadStreamEndian *picFile;
|
||||
if (isAmiga()) {
|
||||
filename = Common::String::format("%s.bm", _room[_curRoom]._baseName);
|
||||
picFile = readEndian(_dataFile.createReadStreamForMember(filename));
|
||||
} else {
|
||||
filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
|
||||
picFile = readEndian(_dataFile.createReadStreamForCompressedMember(filename));
|
||||
}
|
||||
|
||||
SObject bgInfo;
|
||||
bgInfo.readRect(picFile);
|
||||
@ -427,8 +440,15 @@ void TrecisionEngine::redrawRoom() {
|
||||
}
|
||||
}
|
||||
|
||||
Common::String filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
|
||||
Common::SeekableReadStreamEndian *picFile = readEndian(_dataFile.createReadStreamForCompressedMember(filename));
|
||||
Common::String filename;
|
||||
Common::SeekableReadStreamEndian *picFile;
|
||||
if (isAmiga()) {
|
||||
filename = Common::String::format("%s.bm", _room[_curRoom]._baseName);
|
||||
picFile = readEndian(_dataFile.createReadStreamForMember(filename));
|
||||
} else {
|
||||
filename = Common::String::format("%s.cr", _room[_curRoom]._baseName);
|
||||
picFile = readEndian(_dataFile.createReadStreamForCompressedMember(filename));
|
||||
}
|
||||
|
||||
SObject bgInfo;
|
||||
bgInfo.readRect(picFile);
|
||||
|
@ -135,8 +135,8 @@ class TrecisionEngine : public Engine {
|
||||
bool canPlayerInteract();
|
||||
|
||||
// Objects
|
||||
void readObj(Common::SeekableReadStreamEndian *stream);
|
||||
void readObject(Common::SeekableReadStreamEndian *stream, uint16 objIndex, uint16 objectId);
|
||||
void readObj(Common::SeekableReadStream *stream);
|
||||
void readObject(Common::SeekableReadStream *stream, uint16 objIndex, uint16 objectId);
|
||||
|
||||
char *_textArea;
|
||||
uint16 _curScriptFrame[10];
|
||||
|
Loading…
Reference in New Issue
Block a user