aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/zvision/detection.cpp512
-rw-r--r--engines/zvision/zork_avi_decoder.cpp94
-rw-r--r--engines/zvision/zork_avi_decoder.h2
-rw-r--r--engines/zvision/zvision.cpp68
4 files changed, 308 insertions, 368 deletions
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 5488ae5be4..62d834ac3f 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -1,256 +1,256 @@
-/* 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 "engines/advancedDetector.h"
-
-#include "common/translation.h"
-#include "common/savefile.h"
-#include "common/str-array.h"
-#include "common/system.h"
-
-#include "zvision/zvision.h"
-
-
-namespace ZVision {
-
-struct ZVisionGameDescription {
- ADGameDescription desc;
-};
-
-uint32 ZVision::getFeatures() const {
- return _gameDescription->desc.flags;
-}
-
-Common::Language ZVision::getLanguage() const {
- return _gameDescription->desc.language;
-}
-
-}
-
-static const PlainGameDescriptor zVisionGames[] = {
- {"zvision", "ZVision Game"},
- {"znemesis", "Zork Nemesis: The Forbidden Lands"},
- {"zgi", "Zork: Grand Inquisitor"},
- {0, 0}
-};
-
-
-namespace ZVision {
-
-static const ZVisionGameDescription gameDescriptions[] = {
-
- {
- // Zork Nemesis English version
- {
- "znemesis",
- 0,
- AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),
- Common::EN_ANY,
- Common::kPlatformDOS,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
- },
- },
-
- { AD_TABLE_END_MARKER }
-};
-
-} // End of namespace ZVision
-
-static const char *directoryGlobs[] = {
- "znemscr",
- 0
-};
-
-static const ExtraGuiOption ZVisionExtraGuiOption = {
- _s("Use original save/load screens"),
- _s("Use the original save/load screens, instead of the ScummVM ones"),
- "originalsaveload",
- false
-};
-
-class ZVisionMetaEngine : public AdvancedMetaEngine {
-public:
- ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
- _maxScanDepth = 2;
- _directoryGlobs = directoryGlobs;
- _singleid = "zvision";
- }
-
- virtual const char *getName() const {
- return "ZVision";
- }
-
- virtual const char *getOriginalCopyright() const {
- return "ZVision Activision (C) 1996";
- }
-
- virtual bool hasFeature(MetaEngineFeature f) const;
- virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
- virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
- SaveStateList listSaves(const char *target) const;
- virtual int getMaximumSaveSlot() const;
- void removeSaveState(const char *target, int slot) const;
- SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
-};
-
-bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
- return false;
- /*
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave) ||
- (f == kSavesSupportMetaInfo) ||
- (f == kSavesSupportThumbnail) ||
- (f == kSavesSupportCreationDate) ||
- (f == kSavesSupportPlayTime);
- */
-}
-
-/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
- return
- (f == kSupportsRTL) ||
- (f == kSupportsLoadingDuringRuntime) ||
- (f == kSupportsSavingDuringRuntime);
-}*/
-
-bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
- const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
- if (gd) {
- *engine = new ZVision::ZVision(syst, gd);
- }
- return gd != 0;
-}
-
-const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
- ExtraGuiOptions options;
- options.push_back(ZVisionExtraGuiOption);
- return options;
-}
-
-SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
- //Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- /*ZVision::ZVision::SaveHeader header;
- Common::String pattern = target;
- pattern += ".???";
-
- Common::StringArray filenames;
- filenames = saveFileMan->listSavefiles(pattern.c_str());
- Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/
-
- SaveStateList saveList;
-/* for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
- // Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
-
- if (slotNum >= 0 && slotNum <= 999) {
- Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
- if (in) {
- if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
- saveList.push_back(SaveStateDescriptor(slotNum, header.description));
- }
- delete in;
- }
- }
- }*/
-
- return saveList;
-}
-
-int ZVisionMetaEngine::getMaximumSaveSlot() const {
- return 999;
-}
-
-void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
- /*
- Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
- Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
-
- saveFileMan->removeSavefile(filename.c_str());
-
- Common::StringArray filenames;
- Common::String pattern = target;
- pattern += ".???";
- filenames = saveFileMan->listSavefiles(pattern.c_str());
- Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
-
- for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
- // Obtain the last 3 digits of the filename, since they correspond to the save slot
- int slotNum = atoi(file->c_str() + file->size() - 3);
-
- // Rename every slot greater than the deleted slot,
- if (slotNum > slot) {
- saveFileMan->renameSavefile(file->c_str(), filename.c_str());
- filename = ZVision::ZVision::getSavegameFilename(target, ++slot);
- }
- }
- */
-}
-
-SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
- /*
- Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
- Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
-
- if (in) {
- ZVision::ZVision::SaveHeader header;
- ZVision::ZVision::kReadSaveHeaderError error;
-
- error = ZVision::ZVision::readSaveHeader(in, true, header);
- delete in;
-
- if (error == ZVision::ZVision::kRSHENoError) {
- SaveStateDescriptor desc(slot, header.description);
-
- desc.setThumbnail(header.thumbnail);
-
- if (header.version > 0) {
- int day = (header.saveDate >> 24) & 0xFF;
- int month = (header.saveDate >> 16) & 0xFF;
- int year = header.saveDate & 0xFFFF;
-
- desc.setSaveDate(year, month, day);
-
- int hour = (header.saveTime >> 16) & 0xFF;
- int minutes = (header.saveTime >> 8) & 0xFF;
-
- desc.setSaveTime(hour, minutes);
-
- desc.setPlayTime(header.playTime * 1000);
- }
-
- return desc;
- }
- }
- */
-
- return SaveStateDescriptor();
-}
-
-#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
- REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
-#else
- REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
-#endif
+/* 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 "engines/advancedDetector.h"
+
+#include "common/translation.h"
+#include "common/savefile.h"
+#include "common/str-array.h"
+#include "common/system.h"
+
+#include "zvision/zvision.h"
+
+
+namespace ZVision {
+
+struct ZVisionGameDescription {
+ ADGameDescription desc;
+};
+
+uint32 ZVision::getFeatures() const {
+ return _gameDescription->desc.flags;
+}
+
+Common::Language ZVision::getLanguage() const {
+ return _gameDescription->desc.language;
+}
+
+}
+
+static const PlainGameDescriptor zVisionGames[] = {
+ {"zvision", "ZVision Game"},
+ {"znemesis", "Zork Nemesis: The Forbidden Lands"},
+ {"zgi", "Zork: Grand Inquisitor"},
+ {0, 0}
+};
+
+
+namespace ZVision {
+
+static const ZVisionGameDescription gameDescriptions[] = {
+
+ {
+ // Zork Nemesis English version
+ {
+ "znemesis",
+ 0,
+ AD_ENTRY1s("CSCR.ZFS", "88226e51a205d2e50c67a5237f3bd5f2", 2397741),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+ },
+
+ { AD_TABLE_END_MARKER }
+};
+
+} // End of namespace ZVision
+
+static const char *directoryGlobs[] = {
+ "znemscr",
+ 0
+};
+
+static const ExtraGuiOption ZVisionExtraGuiOption = {
+ _s("Use original save/load screens"),
+ _s("Use the original save/load screens, instead of the ScummVM ones"),
+ "originalsaveload",
+ false
+};
+
+class ZVisionMetaEngine : public AdvancedMetaEngine {
+public:
+ ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) {
+ _maxScanDepth = 2;
+ _directoryGlobs = directoryGlobs;
+ _singleid = "zvision";
+ }
+
+ virtual const char *getName() const {
+ return "ZVision";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "ZVision Activision (C) 1996";
+ }
+
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const;
+ SaveStateList listSaves(const char *target) const;
+ virtual int getMaximumSaveSlot() const;
+ void removeSaveState(const char *target, int slot) const;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+};
+
+bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return false;
+ /*
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate) ||
+ (f == kSavesSupportPlayTime);
+ */
+}
+
+/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}*/
+
+bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
+ if (gd) {
+ *engine = new ZVision::ZVision(syst, gd);
+ }
+ return gd != 0;
+}
+
+const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const {
+ ExtraGuiOptions options;
+ options.push_back(ZVisionExtraGuiOption);
+ return options;
+}
+
+SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
+ //Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ /*ZVision::ZVision::SaveHeader header;
+ Common::String pattern = target;
+ pattern += ".???";
+
+ Common::StringArray filenames;
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/
+
+ SaveStateList saveList;
+/* for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ if (slotNum >= 0 && slotNum <= 999) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+ if (in) {
+ if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
+ saveList.push_back(SaveStateDescriptor(slotNum, header.description));
+ }
+ delete in;
+ }
+ }
+ }*/
+
+ return saveList;
+}
+
+int ZVisionMetaEngine::getMaximumSaveSlot() const {
+ return 999;
+}
+
+void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
+ /*
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+
+ saveFileMan->removeSavefile(filename.c_str());
+
+ Common::StringArray filenames;
+ Common::String pattern = target;
+ pattern += ".???";
+ filenames = saveFileMan->listSavefiles(pattern.c_str());
+ Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 3 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 3);
+
+ // Rename every slot greater than the deleted slot,
+ if (slotNum > slot) {
+ saveFileMan->renameSavefile(file->c_str(), filename.c_str());
+ filename = ZVision::ZVision::getSavegameFilename(target, ++slot);
+ }
+ }
+ */
+}
+
+SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ /*
+ Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+ if (in) {
+ ZVision::ZVision::SaveHeader header;
+ ZVision::ZVision::kReadSaveHeaderError error;
+
+ error = ZVision::ZVision::readSaveHeader(in, true, header);
+ delete in;
+
+ if (error == ZVision::ZVision::kRSHENoError) {
+ SaveStateDescriptor desc(slot, header.description);
+
+ desc.setThumbnail(header.thumbnail);
+
+ if (header.version > 0) {
+ int day = (header.saveDate >> 24) & 0xFF;
+ int month = (header.saveDate >> 16) & 0xFF;
+ int year = header.saveDate & 0xFFFF;
+
+ desc.setSaveDate(year, month, day);
+
+ int hour = (header.saveTime >> 16) & 0xFF;
+ int minutes = (header.saveTime >> 8) & 0xFF;
+
+ desc.setSaveTime(hour, minutes);
+
+ desc.setPlayTime(header.playTime * 1000);
+ }
+
+ return desc;
+ }
+ }
+ */
+
+ return SaveStateDescriptor();
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(ZVISION)
+ REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine);
+#endif
diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp
index 9bcc163721..b0524c7d2f 100644
--- a/engines/zvision/zork_avi_decoder.cpp
+++ b/engines/zvision/zork_avi_decoder.cpp
@@ -29,97 +29,9 @@
namespace ZVision {
-// Redefinitions from avi_decoder.cpp
-#define ID_VIDS MKTAG('v','i','d','s')
-#define ID_TXTS MKTAG('t','x','t','s')
-#define ID_STRF MKTAG('s','t','r','f')
-#define ID_AUDS MKTAG('a','u','d','s')
-#define ID_MIDS MKTAG('m','i','d','s')
-
-// Copied off AVIDecoder::handleStreamHeader()
-void ZorkAVIDecoder::handleStreamHeader() {
- AVIStreamHeader sHeader;
- sHeader.size = _fileStream->readUint32LE();
- sHeader.streamType = _fileStream->readUint32BE();
-
- if (sHeader.streamType == ID_MIDS || sHeader.streamType == ID_TXTS)
- error("Unhandled MIDI/Text stream");
-
- sHeader.streamHandler = _fileStream->readUint32BE();
- sHeader.flags = _fileStream->readUint32LE();
- sHeader.priority = _fileStream->readUint16LE();
- sHeader.language = _fileStream->readUint16LE();
- sHeader.initialFrames = _fileStream->readUint32LE();
- sHeader.scale = _fileStream->readUint32LE();
- sHeader.rate = _fileStream->readUint32LE();
- sHeader.start = _fileStream->readUint32LE();
- sHeader.length = _fileStream->readUint32LE();
- sHeader.bufferSize = _fileStream->readUint32LE();
- sHeader.quality = _fileStream->readUint32LE();
- sHeader.sampleSize = _fileStream->readUint32LE();
-
- _fileStream->skip(sHeader.size - 48); // Skip over the remainder of the chunk (frame)
-
- if (_fileStream->readUint32BE() != ID_STRF)
- error("Could not find STRF tag");
-
- uint32 strfSize = _fileStream->readUint32LE();
- uint32 startPos = _fileStream->pos();
-
- if (sHeader.streamType == ID_VIDS) {
- BitmapInfoHeader bmInfo;
- bmInfo.size = _fileStream->readUint32LE();
- bmInfo.width = _fileStream->readUint32LE();
- bmInfo.height = _fileStream->readUint32LE();
- bmInfo.planes = _fileStream->readUint16LE();
- bmInfo.bitCount = _fileStream->readUint16LE();
- bmInfo.compression = _fileStream->readUint32BE();
- bmInfo.sizeImage = _fileStream->readUint32LE();
- bmInfo.xPelsPerMeter = _fileStream->readUint32LE();
- bmInfo.yPelsPerMeter = _fileStream->readUint32LE();
- bmInfo.clrUsed = _fileStream->readUint32LE();
- bmInfo.clrImportant = _fileStream->readUint32LE();
-
- if (bmInfo.clrUsed == 0)
- bmInfo.clrUsed = 256;
-
- if (sHeader.streamHandler == 0)
- sHeader.streamHandler = bmInfo.compression;
-
- AVIVideoTrack *track = new AVIVideoTrack(_header.totalFrames, sHeader, bmInfo);
-
- if (bmInfo.bitCount == 8) {
- byte *palette = const_cast<byte *>(track->getPalette());
- for (uint32 i = 0; i < bmInfo.clrUsed; i++) {
- palette[i * 3 + 2] = _fileStream->readByte();
- palette[i * 3 + 1] = _fileStream->readByte();
- palette[i * 3] = _fileStream->readByte();
- _fileStream->readByte();
- }
-
- track->markPaletteDirty();
- }
-
- addTrack(track);
- } else if (sHeader.streamType == ID_AUDS) {
- PCMWaveFormat wvInfo;
- wvInfo.tag = _fileStream->readUint16LE();
- wvInfo.channels = _fileStream->readUint16LE();
- wvInfo.samplesPerSec = _fileStream->readUint32LE();
- wvInfo.avgBytesPerSec = _fileStream->readUint32LE();
- wvInfo.blockAlign = _fileStream->readUint16LE();
- wvInfo.size = _fileStream->readUint16LE();
-
- // AVI seems to treat the sampleSize as including the second
- // channel as well, so divide for our sake.
- if (wvInfo.channels == 2)
- sHeader.sampleSize /= 2;
-
- addTrack(new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType));
- }
-
- // Ensure that we're at the end of the chunk
- _fileStream->seek(startPos + strfSize);
+Video::AVIDecoder::AVIAudioTrack *ZVision::ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) {
+ ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZVision::ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);
+ return (Video::AVIDecoder::AVIAudioTrack *)audioTrack;
}
void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {
diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h
index f6b2ca7977..5530d92ce4 100644
--- a/engines/zvision/zork_avi_decoder.h
+++ b/engines/zvision/zork_avi_decoder.h
@@ -45,7 +45,7 @@ private:
void queueSound(Common::SeekableReadStream *stream);
};
- void handleStreamHeader();
+ Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);
private:
// Audio Codecs
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index d291cabc70..1a72ea0e8c 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -61,6 +61,45 @@ ZVision::~ZVision() {
DebugMan.clearAllDebugChannels();
}
+// Taken from SCI
+void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
+ assert(bytesPerPixel == 1 || bytesPerPixel == 2);
+ const int newWidth = srcWidth * 2;
+ const int pitch = newWidth * bytesPerPixel;
+ const byte *srcPtr = src;
+
+ if (bytesPerPixel == 1) {
+ for (int y = 0; y < srcHeight; y++) {
+ for (int x = 0; x < srcWidth; x++) {
+ const byte color = *srcPtr++;
+ dst[0] = color;
+ dst[1] = color;
+ dst[newWidth] = color;
+ dst[newWidth + 1] = color;
+ dst += 2;
+ }
+ dst += newWidth;
+ }
+ } else if (bytesPerPixel == 2) {
+ for (int y = 0; y < srcHeight; y++) {
+ for (int x = 0; x < srcWidth; x++) {
+ const byte color = *srcPtr++;
+ const byte color2 = *srcPtr++;
+ dst[0] = color;
+ dst[1] = color2;
+ dst[2] = color;
+ dst[3] = color2;
+ dst[pitch] = color;
+ dst[pitch + 1] = color2;
+ dst[pitch + 2] = color;
+ dst[pitch + 3] = color2;
+ dst += 4;
+ }
+ dst += pitch;
+ }
+ }
+}
+
void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
if (!videoDecoder)
return;
@@ -75,32 +114,19 @@ void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
uint16 screenWidth = 640;//g_sci->_gfxScreen->getDisplayWidth();
uint16 screenHeight = 480;//g_sci->_gfxScreen->getDisplayHeight();
- //videoState.fileName.toLowercase();
+ bool zoom2x = true;
- /*if (screenWidth == 640 && width <= 320 && height <= 240 && ((videoState.flags & kDoubled))) {
+ if (zoom2x) {
width *= 2;
height *= 2;
pitch *= 2;
scaleBuffer = new byte[width * height * bytesPerPixel];
- }*/
+ }
uint16 x, y;
- // Sanity check...
- /*if (videoState.x > 0 && videoState.y > 0 && isVMD) {
- x = videoState.x;
- y = videoState.y;
-
- if (x + width > screenWidth || y + height > screenHeight) {
- // Happens in the Lighthouse demo
- warning("VMD video won't fit on screen, centering it instead");
- x = (screenWidth - width) / 2;
- y = (screenHeight - height) / 2;
- }
- } else {*/
- x = (screenWidth - width) / 2;
- y = (screenHeight - height) / 2;
- //}
+ x = (screenWidth - width) / 2;
+ y = (screenHeight - height) / 2;
bool skipVideo = false;
@@ -110,8 +136,7 @@ void playVideo(Video::VideoDecoder *videoDecoder /*, VideoState videoState*/) {
if (frame) {
if (scaleBuffer) {
- // TODO: Perhaps reuse the relevant function from SCI?
- //g_sci->_gfxScreen->scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
+ scale2x((byte *)frame->pixels, scaleBuffer, videoDecoder->getWidth(), videoDecoder->getHeight(), bytesPerPixel);
g_system->copyRectToScreen(scaleBuffer, pitch, x, y, width, height);
} else {
g_system->copyRectToScreen(frame->pixels, frame->pitch, x, y, width, height);
@@ -178,6 +203,9 @@ Common::Error ZVision::run() {
#if 1
// Image test
+
+ initGraphics(640, 480, true, &format);
+
if (f.open("zassets/castle/CB8EB11C.TGA")) {
Graphics::TGADecoder tga;
if (!tga.loadStream(f))