From 60d672db7315f9a131cfb128a3a10b29ece10112 Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Fri, 19 Jan 2018 02:50:51 -0500 Subject: STARTREK: Fixes to file loading. The "numbered" files that I implemented can also use letters as the last character. --- engines/startrek/graphics.cpp | 5 +++++ engines/startrek/lzss.cpp | 10 ++++++++-- engines/startrek/startrek.cpp | 12 ++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp index e2ba26670c..8dcc43686e 100755 --- a/engines/startrek/graphics.cpp +++ b/engines/startrek/graphics.cpp @@ -89,6 +89,11 @@ void Graphics::drawImage(const char *filename) { uint16 width = (_vm->getPlatform() == Common::kPlatformAmiga) ? imageStream->readUint16BE() : imageStream->readUint16LE(); uint16 height = (_vm->getPlatform() == Common::kPlatformAmiga) ? imageStream->readUint16BE() : imageStream->readUint16LE(); + if (xoffset >= 320) + xoffset = 0; + if (yoffset >= 200) + yoffset = 0; + byte *pixels = (byte *)malloc(width * height); if (_egaMode && _egaData) { diff --git a/engines/startrek/lzss.cpp b/engines/startrek/lzss.cpp index 03aa6de8cd..2e04d08d38 100755 --- a/engines/startrek/lzss.cpp +++ b/engines/startrek/lzss.cpp @@ -23,9 +23,11 @@ * */ -#include "startrek/lzss.h" -#include "common/util.h" +#include "common/textconsole.h" #include "common/memstream.h" +#include "common/util.h" + +#include "startrek/lzss.h" namespace StarTrek { @@ -72,6 +74,10 @@ Common::SeekableReadStream *decodeLZSS(Common::SeekableReadStream *indata, uint3 } delete[] histbuff; + + if (outstreampos != uncompressedSize) + error("Size mismatch in LZSS decompression; expected %d bytes, got %d bytes", uncompressedSize, outstreampos); + return new Common::MemoryReadStream(outLzssBufData, uncompressedSize, DisposeAfterUse::YES); } diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 439feb6203..abb838365c 100755 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -100,7 +100,6 @@ Common::Error StarTrekEngine::run() { _gfx->setPalette("BRIDGE.PAL"); //_gfx->loadEGAData("BRIDGE.EGA"); _gfx->drawImage("DEMON5.BMP"); - //_gfx->drawImage("BRIDGE.BMP"); } if (getPlatform() == Common::kPlatformAmiga) @@ -134,6 +133,7 @@ Common::Error StarTrekEngine::run() { } Common::SeekableReadStream *StarTrekEngine::openFile(Common::String filename, int fileIndex) { + filename.toUppercase(); Common::String basename, extension; for (int i=filename.size()-1; ; i--) { @@ -216,9 +216,10 @@ Common::SeekableReadStream *StarTrekEngine::openFile(Common::String filename, in delete indexFile; if (!foundData) { - // Files with a number at the end are stored a bit differently; they are accessed - // based on a "base number". See if there's an earlier number that can be opened. - if (basename.lastChar() >= '1' && basename.lastChar() <= '9') { + // Files can be accessed "sequentially" if their filenames are the same except for + // the last character being incremented by one. + if ((basename.lastChar() >= '1' && basename.lastChar() <= '9') || + (basename.lastChar() >= 'B' && basename.lastChar() <= 'Z')) { basename.setChar(basename.lastChar()-1, basename.size()-1); return openFile(basename + "." + extension, fileIndex+1); } else @@ -252,6 +253,7 @@ Common::SeekableReadStream *StarTrekEngine::openFile(Common::String filename, in assert(fileCount == 1); // Sanity check... Common::SeekableReadStream *stream = dataFile->readStream(uncompressedSize); delete dataFile; + delete dataRunFile; return stream; } else { if (fileCount != 1) { @@ -271,7 +273,9 @@ Common::SeekableReadStream *StarTrekEngine::openFile(Common::String filename, in uint16 compressedSize = (getPlatform() == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE(); Common::SeekableReadStream *stream = decodeLZSS(dataFile->readStream(compressedSize), uncompressedSize); + delete dataFile; + delete dataRunFile; return stream; } -- cgit v1.2.3