2011-02-20 02:12:35 -05: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "base/plugins.h"
|
|
|
|
#include "base/version.h"
|
|
|
|
#include "common/archive.h"
|
|
|
|
#include "common/config-manager.h"
|
2018-05-07 17:12:07 -04:00
|
|
|
#include "common/debug-channels.h"
|
2011-02-20 02:12:35 -05:00
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/macresman.h"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
#include "engines/util.h"
|
|
|
|
#include "video/qt_decoder.h"
|
|
|
|
|
2018-02-21 21:06:57 -05:00
|
|
|
#include "startrek/filestream.h"
|
2011-02-20 02:12:35 -05:00
|
|
|
#include "startrek/lzss.h"
|
|
|
|
#include "startrek/startrek.h"
|
|
|
|
|
|
|
|
namespace StarTrek {
|
|
|
|
|
|
|
|
StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
|
2018-05-07 17:12:07 -04:00
|
|
|
DebugMan.addDebugChannel(kDebugSound, "sound", "Sound");
|
|
|
|
|
2018-03-10 22:47:52 -05:00
|
|
|
_gfx = nullptr;
|
|
|
|
_sound = nullptr;
|
|
|
|
_macResFork = nullptr;
|
|
|
|
_room = nullptr;
|
2018-05-07 16:40:13 -04:00
|
|
|
|
2018-05-08 22:48:40 -04:00
|
|
|
_clockTicks = 0;
|
|
|
|
|
2018-05-07 16:40:13 -04:00
|
|
|
_musicEnabled = true;
|
|
|
|
_sfxEnabled = true;
|
2018-05-08 22:48:40 -04:00
|
|
|
_word_467a6 = true;
|
|
|
|
_musicWorking = true;
|
|
|
|
_sfxWorking = true;
|
|
|
|
_finishedPlayingSpeech = false;
|
|
|
|
|
|
|
|
_mouseControllingShip = false;
|
|
|
|
_keyboardControlsMouse = true;
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
StarTrekEngine::~StarTrekEngine() {
|
|
|
|
delete _gfx;
|
|
|
|
delete _sound;
|
|
|
|
delete _macResFork;
|
2018-03-10 22:47:52 -05:00
|
|
|
|
|
|
|
delete _room;
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error StarTrekEngine::run() {
|
|
|
|
_gfx = new Graphics(this);
|
|
|
|
_sound = new Sound(this);
|
|
|
|
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh) {
|
|
|
|
_macResFork = new Common::MacResManager();
|
|
|
|
if (!_macResFork->open("Star Trek Data"))
|
|
|
|
error("Could not load Star Trek Data");
|
|
|
|
assert(_macResFork->hasDataFork() && _macResFork->hasResFork());
|
|
|
|
}
|
|
|
|
|
|
|
|
initGraphics(320, 200);
|
2018-03-11 19:22:24 -04:00
|
|
|
|
|
|
|
initializeEventsAndMouse();
|
2011-02-20 02:12:35 -05:00
|
|
|
|
|
|
|
// Test graphics/music:
|
|
|
|
|
|
|
|
// Music Status:
|
|
|
|
// DOS Full: Adlib and MT-32 Sounds supported
|
|
|
|
// DOS Demo: Adlib and MT-32 Sounds supported
|
|
|
|
// Amiga: Sound effects supported
|
|
|
|
// Macintosh: MIDI and sound effects playable, format not handled.
|
|
|
|
|
|
|
|
// Graphics Status:
|
|
|
|
// DOS/Amiga/Macintosh/Demo Graphics: 100%
|
|
|
|
// Judgment Rites Backgrounds supported too
|
|
|
|
// EGA not supported
|
|
|
|
#if 1
|
2018-03-10 22:47:52 -05:00
|
|
|
_room = new Room(this, "DEMON0");
|
2011-02-20 02:12:35 -05:00
|
|
|
if (getGameType() == GType_ST25) {
|
2018-02-23 02:11:40 -05:00
|
|
|
_gfx->loadPalette("PALETTE");
|
2018-02-22 21:10:09 -05:00
|
|
|
_gfx->loadPri("DEMON0.PRI");
|
|
|
|
_gfx->redrawScreen();
|
2011-02-20 02:12:35 -05:00
|
|
|
|
2018-05-07 16:40:13 -04:00
|
|
|
_sound->loadMusicFile("GROUND");
|
2011-02-20 02:12:35 -05:00
|
|
|
} else {
|
|
|
|
_gfx->drawBackgroundImage("BRIDGE.BGD");
|
|
|
|
}
|
2018-02-23 16:48:12 -05:00
|
|
|
|
|
|
|
// Sprite tests
|
|
|
|
|
|
|
|
// Draw mode 0
|
|
|
|
Sprite *spr = new Sprite;
|
|
|
|
_gfx->addSprite(spr);
|
2018-02-24 13:59:08 -05:00
|
|
|
spr->bitmap = _gfx->loadBitmap("MWALKE00");
|
2018-02-23 16:48:12 -05:00
|
|
|
spr->drawPriority = 1;
|
2018-02-24 21:48:06 -05:00
|
|
|
spr->pos.x = 150;
|
2018-02-25 02:01:02 -05:00
|
|
|
spr->pos.y = 100;
|
2018-02-23 16:48:12 -05:00
|
|
|
spr->drawMode = 0;
|
|
|
|
|
|
|
|
// Draw mode 2 (translucent background)
|
|
|
|
spr = new Sprite;
|
|
|
|
_gfx->addSprite(spr);
|
2018-02-24 13:59:08 -05:00
|
|
|
spr->bitmap = _gfx->loadBitmap("KWALKS00");
|
2018-02-23 16:48:12 -05:00
|
|
|
spr->drawPriority = 1;
|
2018-02-25 02:18:02 -05:00
|
|
|
spr->pos.x = 230;
|
|
|
|
spr->pos.y = 100;
|
2018-02-23 16:48:12 -05:00
|
|
|
spr->drawMode = 2;
|
|
|
|
|
2018-02-25 02:01:02 -05:00
|
|
|
/*
|
2018-02-23 16:48:12 -05:00
|
|
|
// Draw mode 3 (text)
|
|
|
|
spr = new Sprite;
|
|
|
|
_gfx->addSprite(spr);
|
2018-02-24 13:59:08 -05:00
|
|
|
spr->bitmap = SharedPtr<Bitmap>(new TextBitmap(8*8,8*8));
|
2018-02-23 16:48:12 -05:00
|
|
|
for (int i=0;i<8*8;i++)
|
|
|
|
spr->bitmap->pixels[i] = 0x40+i;
|
2018-02-24 21:48:06 -05:00
|
|
|
spr->pos.x = 8*10;
|
|
|
|
spr->pos.y = 50;
|
2018-02-23 16:48:12 -05:00
|
|
|
spr->textColor = 0xb3;
|
|
|
|
spr->drawMode = 3;
|
|
|
|
|
2018-02-24 13:59:08 -05:00
|
|
|
// initTextSprite function
|
|
|
|
spr = new Sprite;
|
|
|
|
int x=0,y=0;
|
|
|
|
_gfx->initTextSprite(&x, &y, 0xb3, 3, false, spr);
|
2018-02-24 21:48:06 -05:00
|
|
|
spr->pos.y = 150;
|
2018-02-25 02:01:02 -05:00
|
|
|
*/
|
2018-02-24 13:59:08 -05:00
|
|
|
|
|
|
|
|
2018-05-08 22:48:40 -04:00
|
|
|
while (true) {
|
|
|
|
_gfx->showOptionsMenu(0, 0);
|
|
|
|
}
|
2018-03-10 22:47:52 -05:00
|
|
|
_gfx->showText(&Graphics::readTextFromRdf, 0x2220, 150, 160, 0xb3, 0, 10, 0);
|
2011-02-20 02:12:35 -05:00
|
|
|
|
|
|
|
while (!shouldQuit()) {
|
2018-03-11 19:22:24 -04:00
|
|
|
pollSystemEvents();
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2018-03-11 19:22:24 -04:00
|
|
|
Room *StarTrekEngine::getRoom() {
|
|
|
|
return _room;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StarTrekEngine::pollSystemEvents() {
|
2018-02-24 13:59:08 -05:00
|
|
|
Common::Event event;
|
2018-03-11 19:22:24 -04:00
|
|
|
TrekEvent trekEvent;
|
2018-02-24 13:59:08 -05:00
|
|
|
|
|
|
|
while (_eventMan->pollEvent(event)) {
|
2018-03-11 19:22:24 -04:00
|
|
|
trekEvent.mouse = event.mouse;
|
|
|
|
trekEvent.kbd = event.kbd;
|
|
|
|
|
2018-02-24 13:59:08 -05:00
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_QUIT:
|
|
|
|
_system->quit();
|
|
|
|
break;
|
2018-03-11 19:22:24 -04:00
|
|
|
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
|
|
|
trekEvent.type = TREKEVENT_MOUSEMOVE;
|
|
|
|
addEventToQueue(trekEvent);
|
|
|
|
break;
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
trekEvent.type = TREKEVENT_LBUTTONDOWN;
|
|
|
|
addEventToQueue(trekEvent);
|
|
|
|
break;
|
2018-02-24 13:59:08 -05:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-02-25 02:01:02 -05:00
|
|
|
_gfx->drawAllSprites();
|
2018-02-24 13:59:08 -05:00
|
|
|
|
|
|
|
_system->delayMillis(1000/60);
|
|
|
|
}
|
|
|
|
|
2018-05-06 04:13:10 -04:00
|
|
|
void StarTrekEngine::playSoundEffectIndex(int index) {
|
2018-05-07 16:40:13 -04:00
|
|
|
switch(index) {
|
|
|
|
case 0x04:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("tricorde");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x05:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("STDOOR1");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x06:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("PHASSHOT");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x07:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playMidiTrack(index);
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x08:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("TRANSDEM");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x09:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("TRANSMAT");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x0a:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("TRANSENE");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x10: // Menu selection sound
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playMidiTrack(index);
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x22:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("HAILING");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x24:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("PHASSHOT");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x25:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("PHOTSHOT");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x26:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("HITSHIEL");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x27:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playMidiTrack(index);
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x28:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("REDALERT");
|
|
|
|
break;
|
2018-05-07 16:40:13 -04:00
|
|
|
case 0x29:
|
2018-05-06 04:13:10 -04:00
|
|
|
_sound->playSoundEffect("WARP");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-03-11 19:22:24 -04:00
|
|
|
}
|
|
|
|
|
2018-05-07 16:40:13 -04:00
|
|
|
void StarTrekEngine::playSpeech(const Common::String &filename) {
|
|
|
|
_sound->playSpeech(filename.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StarTrekEngine::stopPlayingSpeech() {
|
|
|
|
_sound->stopPlayingSpeech();
|
|
|
|
}
|
|
|
|
|
2018-03-11 19:22:24 -04:00
|
|
|
void StarTrekEngine::updateClockTicks() {
|
|
|
|
// TODO (based on DOS interrupt 1A, AH=0; read system clock counter)
|
|
|
|
|
|
|
|
_clockTicks = 0;
|
2018-03-10 22:47:52 -05:00
|
|
|
}
|
|
|
|
|
2018-02-24 13:59:08 -05:00
|
|
|
SharedPtr<FileStream> StarTrekEngine::openFile(Common::String filename, int fileIndex) {
|
2018-01-19 02:50:51 -05:00
|
|
|
filename.toUppercase();
|
2018-05-04 20:32:08 -04:00
|
|
|
Common::String basename, extension;
|
|
|
|
|
2018-02-21 21:06:57 -05:00
|
|
|
bool bigEndian = getPlatform() == Common::kPlatformAmiga;
|
|
|
|
|
2018-05-04 20:32:08 -04:00
|
|
|
for (int i=filename.size()-1; ; i--) {
|
|
|
|
if (filename[i] == '.') {
|
|
|
|
basename = filename;
|
|
|
|
extension = filename;
|
|
|
|
basename.replace(i, filename.size()-i, "");
|
|
|
|
extension.replace(0, i+1, "");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-20 02:12:35 -05:00
|
|
|
// The Judgment Rites demo has its files not in the standard archive
|
|
|
|
if (getGameType() == GType_STJR && (getFeatures() & GF_DEMO)) {
|
|
|
|
Common::File *file = new Common::File();
|
|
|
|
if (!file->open(filename.c_str()))
|
|
|
|
error ("Could not find file \'%s\'", filename.c_str());
|
2018-02-24 13:59:08 -05:00
|
|
|
return SharedPtr<FileStream>(new FileStream(file, bigEndian));
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *indexFile = 0;
|
|
|
|
|
|
|
|
if (getPlatform() == Common::kPlatformAmiga) {
|
|
|
|
indexFile = SearchMan.createReadStreamForMember("data000.dir");
|
|
|
|
if (!indexFile)
|
|
|
|
error ("Could not open data000.dir");
|
|
|
|
} else if (getPlatform() == Common::kPlatformMacintosh) {
|
|
|
|
indexFile = _macResFork->getResource("Directory");
|
|
|
|
if (!indexFile)
|
|
|
|
error("Could not find 'Directory' resource in 'Star Trek Data'");
|
|
|
|
} else {
|
|
|
|
indexFile = SearchMan.createReadStreamForMember("data.dir");
|
|
|
|
if (!indexFile)
|
|
|
|
error ("Could not open data.dir");
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 indexOffset = 0;
|
|
|
|
bool foundData = false;
|
|
|
|
uint16 fileCount = 1;
|
|
|
|
uint16 uncompressedSize = 0;
|
|
|
|
|
|
|
|
while (!indexFile->eos() && !indexFile->err()) {
|
|
|
|
Common::String testfile;
|
|
|
|
for (byte i = 0; i < 8; i++) {
|
|
|
|
char c = indexFile->readByte();
|
|
|
|
if (c)
|
|
|
|
testfile += c;
|
|
|
|
}
|
|
|
|
testfile += '.';
|
2018-05-04 20:32:08 -04:00
|
|
|
|
2011-02-20 02:12:35 -05:00
|
|
|
for (byte i = 0; i < 3; i++)
|
|
|
|
testfile += indexFile->readByte();
|
2018-05-04 20:32:08 -04:00
|
|
|
|
|
|
|
if (getFeatures() & GF_DEMO && getPlatform() == Common::kPlatformDOS) {
|
2011-02-20 02:12:35 -05:00
|
|
|
indexFile->readByte(); // Always 0?
|
|
|
|
fileCount = indexFile->readUint16LE(); // Always 1
|
|
|
|
indexOffset = indexFile->readUint32LE();
|
|
|
|
uncompressedSize = indexFile->readUint16LE();
|
|
|
|
} else {
|
|
|
|
if (getPlatform() == Common::kPlatformAmiga)
|
|
|
|
indexOffset = (indexFile->readByte() << 16) + (indexFile->readByte() << 8) + indexFile->readByte();
|
|
|
|
else
|
|
|
|
indexOffset = indexFile->readByte() + (indexFile->readByte() << 8) + (indexFile->readByte() << 16);
|
|
|
|
|
|
|
|
if (indexOffset & (1 << 23)) {
|
|
|
|
fileCount = (indexOffset >> 16) & 0x7F;
|
|
|
|
indexOffset = indexOffset & 0xFFFF;
|
2018-05-04 20:32:08 -04:00
|
|
|
assert(fileCount > 1);
|
2011-02-20 02:12:35 -05:00
|
|
|
} else {
|
|
|
|
fileCount = 1;
|
|
|
|
}
|
|
|
|
}
|
2018-05-04 20:32:08 -04:00
|
|
|
|
2011-02-20 02:12:35 -05:00
|
|
|
if (filename.matchString(testfile)) {
|
|
|
|
foundData = true;
|
|
|
|
break;
|
2018-02-21 21:06:57 -05:00
|
|
|
}
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
2018-05-04 20:32:08 -04:00
|
|
|
|
2011-02-20 02:12:35 -05:00
|
|
|
delete indexFile;
|
2018-05-04 20:32:08 -04:00
|
|
|
|
|
|
|
if (!foundData) {
|
2018-01-19 02:50:51 -05:00
|
|
|
// 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')) {
|
2018-05-04 20:32:08 -04:00
|
|
|
basename.setChar(basename.lastChar()-1, basename.size()-1);
|
|
|
|
return openFile(basename + "." + extension, fileIndex+1);
|
|
|
|
} else
|
|
|
|
error ("Could not find file \'%s\'", filename.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fileIndex >= fileCount)
|
|
|
|
error("Tried to access file index %d for file '%s' which doesn't exist.", fileIndex, filename.c_str());
|
2011-02-20 02:12:35 -05:00
|
|
|
|
|
|
|
Common::SeekableReadStream *dataFile = 0;
|
2018-02-21 21:06:57 -05:00
|
|
|
Common::SeekableReadStream *dataRunFile = 0; // FIXME: Amiga & Mac need this implemented
|
2011-02-20 02:12:35 -05:00
|
|
|
|
|
|
|
if (getPlatform() == Common::kPlatformAmiga) {
|
|
|
|
dataFile = SearchMan.createReadStreamForMember("data.000");
|
|
|
|
if (!dataFile)
|
|
|
|
error("Could not open data.000");
|
|
|
|
} else if (getPlatform() == Common::kPlatformMacintosh) {
|
|
|
|
dataFile = _macResFork->getDataFork();
|
|
|
|
if (!dataFile)
|
|
|
|
error("Could not get 'Star Trek Data' data fork");
|
|
|
|
} else {
|
|
|
|
dataFile = SearchMan.createReadStreamForMember("data.001");
|
|
|
|
if (!dataFile)
|
|
|
|
error("Could not open data.001");
|
2018-05-04 20:32:08 -04:00
|
|
|
dataRunFile = SearchMan.createReadStreamForMember("data.run");
|
|
|
|
if (!dataFile)
|
|
|
|
error("Could not open data.run");
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
2018-05-04 20:32:08 -04:00
|
|
|
|
|
|
|
if (getFeatures() & GF_DEMO && getPlatform() == Common::kPlatformDOS) {
|
2011-02-20 02:12:35 -05:00
|
|
|
assert(fileCount == 1); // Sanity check...
|
|
|
|
Common::SeekableReadStream *stream = dataFile->readStream(uncompressedSize);
|
|
|
|
delete dataFile;
|
2018-01-19 02:50:51 -05:00
|
|
|
delete dataRunFile;
|
2018-02-24 13:59:08 -05:00
|
|
|
return SharedPtr<FileStream>(new FileStream(stream, bigEndian));
|
2011-02-20 02:12:35 -05:00
|
|
|
} else {
|
2018-05-04 20:32:08 -04:00
|
|
|
if (fileCount != 1) {
|
|
|
|
dataRunFile->seek(indexOffset);
|
|
|
|
|
|
|
|
indexOffset = dataRunFile->readByte() + (dataRunFile->readByte() << 8) + (dataRunFile->readByte() << 16);
|
|
|
|
//indexOffset &= 0xFFFFFE;
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < fileIndex; i++) {
|
|
|
|
uint16 size = dataRunFile->readUint16LE();
|
|
|
|
indexOffset += size;
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
|
|
|
}
|
2018-05-04 20:32:08 -04:00
|
|
|
dataFile->seek(indexOffset);
|
|
|
|
|
|
|
|
uncompressedSize = (getPlatform() == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE();
|
|
|
|
uint16 compressedSize = (getPlatform() == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE();
|
|
|
|
|
|
|
|
Common::SeekableReadStream *stream = decodeLZSS(dataFile->readStream(compressedSize), uncompressedSize);
|
2018-01-19 02:50:51 -05:00
|
|
|
|
2018-05-04 20:32:08 -04:00
|
|
|
delete dataFile;
|
2018-01-19 02:50:51 -05:00
|
|
|
delete dataRunFile;
|
2018-02-24 13:59:08 -05:00
|
|
|
return SharedPtr<FileStream>(new FileStream(stream, bigEndian));
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
2018-02-21 21:06:57 -05:00
|
|
|
|
2011-02-20 02:12:35 -05:00
|
|
|
// We should not get to this point...
|
|
|
|
error("Could not find data for \'%s\'", filename.c_str());
|
2018-02-21 21:06:57 -05:00
|
|
|
|
2018-02-24 13:59:08 -05:00
|
|
|
return SharedPtr<FileStream>();
|
2011-02-20 02:12:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void StarTrekEngine::playMovie(Common::String filename) {
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
playMovieMac(filename);
|
|
|
|
else
|
|
|
|
error("Interplay MVE not yet supported");
|
|
|
|
}
|
|
|
|
|
|
|
|
void StarTrekEngine::playMovieMac(Common::String filename) {
|
|
|
|
// Swap to 16bpp mode
|
|
|
|
initGraphics(512, 384, NULL);
|
|
|
|
|
|
|
|
Video::QuickTimeDecoder *qtDecoder = new Video::QuickTimeDecoder();
|
|
|
|
|
|
|
|
if (!qtDecoder->loadFile(filename))
|
|
|
|
error("Could not open '%s'", filename.c_str());
|
|
|
|
|
|
|
|
bool continuePlaying = true;
|
|
|
|
|
|
|
|
qtDecoder->start();
|
|
|
|
|
|
|
|
while (!qtDecoder->endOfVideo() && !shouldQuit() && continuePlaying) {
|
|
|
|
if (qtDecoder->needsUpdate()) {
|
|
|
|
const ::Graphics::Surface *frame = qtDecoder->decodeNextFrame();
|
|
|
|
|
|
|
|
if (frame) {
|
|
|
|
::Graphics::Surface *convertedFrame = frame->convertTo(_system->getScreenFormat());
|
|
|
|
_system->copyRectToScreen(convertedFrame->getPixels(), convertedFrame->pitch, 0, 0, convertedFrame->w, convertedFrame->h);
|
|
|
|
_system->updateScreen();
|
|
|
|
convertedFrame->free();
|
|
|
|
delete convertedFrame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Event event;
|
|
|
|
while (g_system->getEventManager()->pollEvent(event))
|
|
|
|
if (event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE)
|
|
|
|
continuePlaying = false;
|
|
|
|
|
|
|
|
g_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete qtDecoder;
|
|
|
|
|
|
|
|
// Swap back to 8bpp mode
|
|
|
|
initGraphics(320, 200);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace StarTrek
|