diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/detection.cpp | 512 | ||||
-rw-r--r-- | engines/zvision/module.mk | 34 | ||||
-rw-r--r-- | engines/zvision/zork_avi_decoder.cpp | 100 | ||||
-rw-r--r-- | engines/zvision/zork_avi_decoder.h | 118 | ||||
-rw-r--r-- | engines/zvision/zork_raw.cpp | 376 | ||||
-rw-r--r-- | engines/zvision/zork_raw.h | 134 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 298 | ||||
-rw-r--r-- | engines/zvision/zvision.h | 188 |
8 files changed, 880 insertions, 880 deletions
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 62d834ac3f..5488ae5be4 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/module.mk b/engines/zvision/module.mk index 854ee0307c..3dd17a2f99 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -1,18 +1,18 @@ -MODULE := engines/zvision
-
-MODULE_OBJS := \
- detection.o \
- zvision.o \
- zork_avi_decoder.o \
- zork_raw.o
-
-MODULE_DIRS += \
- engines/zvision
-
-# This module can be built as a plugin
-ifeq ($(ENABLE_ZVISION), DYNAMIC_PLUGIN)
-PLUGIN := 1
-endif
-
-# Include common rules
+MODULE := engines/zvision + +MODULE_OBJS := \ + detection.o \ + zvision.o \ + zork_avi_decoder.o \ + zork_raw.o + +MODULE_DIRS += \ + engines/zvision + +# This module can be built as a plugin +ifeq ($(ENABLE_ZVISION), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules include $(srcdir)/rules.mk
\ No newline at end of file diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp index 2da524655b..4ceff48891 100644 --- a/engines/zvision/zork_avi_decoder.cpp +++ b/engines/zvision/zork_avi_decoder.cpp @@ -1,50 +1,50 @@ -/* 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 "common/scummsys.h"
-
-#include "common/stream.h"
-#include "audio/audiostream.h"
-
-#include "engines/zvision/zork_avi_decoder.h"
-#include "engines/zvision/zork_raw.h"
-
-namespace ZVision {
-
-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) {
- if (_audStream) {
- if (_wvInfo.tag == kWaveFormatZorkPCM) {
- assert(_wvInfo.size == 8);
- _audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, DisposeAfterUse::YES), DisposeAfterUse::YES);
- }
- } else {
- delete stream;
- }
-}
-
-} // End of namespace ZVision
+/* 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 "common/scummsys.h" + +#include "common/stream.h" +#include "audio/audiostream.h" + +#include "engines/zvision/zork_avi_decoder.h" +#include "engines/zvision/zork_raw.h" + +namespace ZVision { + +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) { + if (_audStream) { + if (_wvInfo.tag == kWaveFormatZorkPCM) { + assert(_wvInfo.size == 8); + _audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, DisposeAfterUse::YES), DisposeAfterUse::YES); + } + } else { + delete stream; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h index 5530d92ce4..1dff304894 100644 --- a/engines/zvision/zork_avi_decoder.h +++ b/engines/zvision/zork_avi_decoder.h @@ -1,59 +1,59 @@ -/* 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.
- *
- *
- */
-
-#ifndef ZORK_AVI_DECODER_H
-#define ZORK_AVI_DECODER_H
-
-#include "video/avi_decoder.h"
-
-namespace ZVision {
-
-class ZorkAVIDecoder : public Video::AVIDecoder {
-public:
- ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) :
- Video::AVIDecoder(soundType) {}
-
- virtual ~ZorkAVIDecoder() {}
-
-private:
- class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack {
- public:
- ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :
- Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {}
- virtual ~ZorkAVIAudioTrack() {}
-
- void queueSound(Common::SeekableReadStream *stream);
- };
-
- Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);
-
- private:
- // Audio Codecs
- enum {
- kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM)
- };
-};
-
-} // End of namespace ZVision
-
-#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. + * + * + */ + +#ifndef ZORK_AVI_DECODER_H +#define ZORK_AVI_DECODER_H + +#include "video/avi_decoder.h" + +namespace ZVision { + +class ZorkAVIDecoder : public Video::AVIDecoder { +public: + ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) : + Video::AVIDecoder(soundType) {} + + virtual ~ZorkAVIDecoder() {} + +private: + class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack { + public: + ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : + Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {} + virtual ~ZorkAVIAudioTrack() {} + + void queueSound(Common::SeekableReadStream *stream); + }; + + Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo); + + private: + // Audio Codecs + enum { + kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM) + }; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp index e008741e16..d920550bc7 100644 --- a/engines/zvision/zork_raw.cpp +++ b/engines/zvision/zork_raw.cpp @@ -1,188 +1,188 @@ -/* 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 "common/scummsys.h"
-
-#include "common/endian.h"
-#include "common/memstream.h"
-#include "common/textconsole.h"
-#include "common/util.h"
-
-#include "audio/audiostream.h"
-
-#include "engines/zvision/zork_raw.h"
-
-namespace ZVision {
-
-#pragma mark -
-#pragma mark --- RawZorkStream ---
-#pragma mark -
-
-/**
- * This is a stream, which allows for playing raw PCM data from a stream.
- */
-class RawZorkStream : public Audio::SeekableAudioStream {
-public:
- RawZorkStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
- : _rate(rate), _playtime(0, rate), _stream(stream, disposeStream), _endOfData(false), _buffer(0) {
- // Setup our buffer for readBuffer
- _buffer = new byte[kSampleBufferLength];
- assert(_buffer);
-
- // Calculate the total playtime of the stream
- _playtime = Audio::Timestamp(0, _stream->size() / 2 / 1, rate);
- }
-
- ~RawZorkStream() {
- delete[] _buffer;
- }
-
- int readBuffer(int16 *buffer, const int numSamples);
-
- bool isStereo() const { return true; }
- bool endOfData() const { return _endOfData; }
-
- int getRate() const { return _rate; }
- Audio::Timestamp getLength() const { return _playtime; }
-
- bool seek(const Audio::Timestamp &where);
-private:
- const int _rate; ///< Sample rate of stream
- Audio::Timestamp _playtime; ///< Calculated total play time
- Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from
- bool _endOfData; ///< Whether the stream end has been reached
-
- byte *_buffer; ///< Buffer used in readBuffer
- enum {
- /**
- * How many samples we can buffer at once.
- *
- * TODO: Check whether this size suffices
- * for systems with slow disk I/O.
- */
- kSampleBufferLength = 2048
- };
-
- /**
- * Fill the temporary sample buffer used in readBuffer.
- *
- * @param maxSamples Maximum samples to read.
- * @return actual count of samples read.
- */
- int fillBuffer(int maxSamples);
-};
-
-int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) {
- int samplesLeft = numSamples;
-
- while (samplesLeft > 0) {
- // Try to read up to "samplesLeft" samples.
- int len = fillBuffer(samplesLeft);
-
- // In case we were not able to read any samples
- // we will stop reading here.
- if (!len)
- break;
-
- // Adjust the samples left to read.
- samplesLeft -= len;
-
- // Copy the data to the caller's buffer.
- const byte *src = _buffer;
- while (len-- > 0) {
- if (*src < 128)
- *buffer++ = ((128 - *src) << 8) ^ 0x8000;
- else
- *buffer++ = (*src << 8) ^ 0x8000;
- src++;
- }
- }
-
- return numSamples - samplesLeft;
-}
-
-int RawZorkStream::fillBuffer(int maxSamples) {
- int bufferedSamples = 0;
- byte *dst = _buffer;
-
- // We can only read up to "kSampleBufferLength" samples
- // so we take this into consideration, when trying to
- // read up to maxSamples.
- maxSamples = MIN<int>(kSampleBufferLength, maxSamples);
-
- // We will only read up to maxSamples
- while (maxSamples > 0 && !endOfData()) {
- // Try to read all the sample data and update the
- // destination pointer.
- const int bytesRead = _stream->read(dst, maxSamples);
- dst += bytesRead;
-
- // Calculate how many samples we actually read.
- const int samplesRead = bytesRead;
-
- // Update all status variables
- bufferedSamples += samplesRead;
- maxSamples -= samplesRead;
-
- // We stop stream playback, when we reached the end of the data stream.
- // We also stop playback when an error occures.
- if (_stream->pos() == _stream->size() || _stream->err() || _stream->eos())
- _endOfData = true;
- }
-
- return bufferedSamples;
-}
-
-bool RawZorkStream::seek(const Audio::Timestamp &where) {
- _endOfData = true;
-
- if (where > _playtime)
- return false;
-
- const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames();
- _stream->seek(seekSample, SEEK_SET);
-
- // In case of an error we will not continue stream playback.
- if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size())
- _endOfData = false;
-
- return true;
-}
-
-#pragma mark -
-#pragma mark --- Raw stream factories ---
-#pragma mark -
-
-Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
- int rate,
- DisposeAfterUse::Flag disposeAfterUse) {
- assert(stream->size() % 2 == 0);
- return new RawZorkStream(rate, disposeAfterUse, stream);
-}
-
-Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- DisposeAfterUse::Flag disposeAfterUse) {
- return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES);
-}
-
-} // End of namespace ZVision
+/* 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 "common/scummsys.h" + +#include "common/endian.h" +#include "common/memstream.h" +#include "common/textconsole.h" +#include "common/util.h" + +#include "audio/audiostream.h" + +#include "engines/zvision/zork_raw.h" + +namespace ZVision { + +#pragma mark - +#pragma mark --- RawZorkStream --- +#pragma mark - + +/** + * This is a stream, which allows for playing raw PCM data from a stream. + */ +class RawZorkStream : public Audio::SeekableAudioStream { +public: + RawZorkStream(int rate, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream) + : _rate(rate), _playtime(0, rate), _stream(stream, disposeStream), _endOfData(false), _buffer(0) { + // Setup our buffer for readBuffer + _buffer = new byte[kSampleBufferLength]; + assert(_buffer); + + // Calculate the total playtime of the stream + _playtime = Audio::Timestamp(0, _stream->size() / 2 / 1, rate); + } + + ~RawZorkStream() { + delete[] _buffer; + } + + int readBuffer(int16 *buffer, const int numSamples); + + bool isStereo() const { return true; } + bool endOfData() const { return _endOfData; } + + int getRate() const { return _rate; } + Audio::Timestamp getLength() const { return _playtime; } + + bool seek(const Audio::Timestamp &where); +private: + const int _rate; ///< Sample rate of stream + Audio::Timestamp _playtime; ///< Calculated total play time + Common::DisposablePtr<Common::SeekableReadStream> _stream; ///< Stream to read data from + bool _endOfData; ///< Whether the stream end has been reached + + byte *_buffer; ///< Buffer used in readBuffer + enum { + /** + * How many samples we can buffer at once. + * + * TODO: Check whether this size suffices + * for systems with slow disk I/O. + */ + kSampleBufferLength = 2048 + }; + + /** + * Fill the temporary sample buffer used in readBuffer. + * + * @param maxSamples Maximum samples to read. + * @return actual count of samples read. + */ + int fillBuffer(int maxSamples); +}; + +int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) { + int samplesLeft = numSamples; + + while (samplesLeft > 0) { + // Try to read up to "samplesLeft" samples. + int len = fillBuffer(samplesLeft); + + // In case we were not able to read any samples + // we will stop reading here. + if (!len) + break; + + // Adjust the samples left to read. + samplesLeft -= len; + + // Copy the data to the caller's buffer. + const byte *src = _buffer; + while (len-- > 0) { + if (*src < 128) + *buffer++ = ((128 - *src) << 8) ^ 0x8000; + else + *buffer++ = (*src << 8) ^ 0x8000; + src++; + } + } + + return numSamples - samplesLeft; +} + +int RawZorkStream::fillBuffer(int maxSamples) { + int bufferedSamples = 0; + byte *dst = _buffer; + + // We can only read up to "kSampleBufferLength" samples + // so we take this into consideration, when trying to + // read up to maxSamples. + maxSamples = MIN<int>(kSampleBufferLength, maxSamples); + + // We will only read up to maxSamples + while (maxSamples > 0 && !endOfData()) { + // Try to read all the sample data and update the + // destination pointer. + const int bytesRead = _stream->read(dst, maxSamples); + dst += bytesRead; + + // Calculate how many samples we actually read. + const int samplesRead = bytesRead; + + // Update all status variables + bufferedSamples += samplesRead; + maxSamples -= samplesRead; + + // We stop stream playback, when we reached the end of the data stream. + // We also stop playback when an error occures. + if (_stream->pos() == _stream->size() || _stream->err() || _stream->eos()) + _endOfData = true; + } + + return bufferedSamples; +} + +bool RawZorkStream::seek(const Audio::Timestamp &where) { + _endOfData = true; + + if (where > _playtime) + return false; + + const uint32 seekSample = convertTimeToStreamPos(where, getRate(), isStereo()).totalNumberOfFrames(); + _stream->seek(seekSample, SEEK_SET); + + // In case of an error we will not continue stream playback. + if (!_stream->err() && !_stream->eos() && _stream->pos() != _stream->size()) + _endOfData = false; + + return true; +} + +#pragma mark - +#pragma mark --- Raw stream factories --- +#pragma mark - + +Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream, + int rate, + DisposeAfterUse::Flag disposeAfterUse) { + assert(stream->size() % 2 == 0); + return new RawZorkStream(rate, disposeAfterUse, stream); +} + +Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, + int rate, + DisposeAfterUse::Flag disposeAfterUse) { + return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, DisposeAfterUse::YES); +} + +} // End of namespace ZVision diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h index 3a938026d9..1de3b575ba 100644 --- a/engines/zvision/zork_raw.h +++ b/engines/zvision/zork_raw.h @@ -1,67 +1,67 @@ -/* 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.
- *
- */
-
-#ifndef ZVISION_ZORK_RAW_H
-#define ZVISION_ZORK_RAW_H
-
-#include "common/scummsys.h"
-#include "common/types.h"
-
-#include "common/list.h"
-
-
-namespace Common {
-class SeekableReadStream;
-}
-
-namespace ZVision {
-
-class SeekableAudioStream;
-
-/**
- * Creates an audio stream, which plays from the given buffer.
- *
- * @param buffer Buffer to play from.
- * @param size Size of the buffer in bytes.
- * @param rate Rate of the sound data.
- * @param disposeAfterUse Whether to free the buffer after use (with free!).
- * @return The new SeekableAudioStream (or 0 on failure).
- */
-Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size,
- int rate,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
-
-/**
- * Creates an audio stream, which plays from the given stream.
- *
- * @param stream Stream object to play from.
- * @param rate Rate of the sound data.
- * @param disposeAfterUse Whether to delete the stream after use.
- * @return The new SeekableAudioStream (or 0 on failure).
- */
-Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream,
- int rate,
- DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
-
-} // End of namespace ZVision
-
-#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. + * + */ + +#ifndef ZVISION_ZORK_RAW_H +#define ZVISION_ZORK_RAW_H + +#include "common/scummsys.h" +#include "common/types.h" + +#include "common/list.h" + + +namespace Common { +class SeekableReadStream; +} + +namespace ZVision { + +class SeekableAudioStream; + +/** + * Creates an audio stream, which plays from the given buffer. + * + * @param buffer Buffer to play from. + * @param size Size of the buffer in bytes. + * @param rate Rate of the sound data. + * @param disposeAfterUse Whether to free the buffer after use (with free!). + * @return The new SeekableAudioStream (or 0 on failure). + */ +Audio::SeekableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, + int rate, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + +/** + * Creates an audio stream, which plays from the given stream. + * + * @param stream Stream object to play from. + * @param rate Rate of the sound data. + * @param disposeAfterUse Whether to delete the stream after use. + * @return The new SeekableAudioStream (or 0 on failure). + */ +Audio::SeekableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream, + int rate, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 479bf2379a..5e83c47721 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -1,149 +1,149 @@ -/* 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 "common/scummsys.h"
-
-#include "common/config-manager.h"
-#include "common/debug.h"
-#include "common/debug-channels.h"
-#include "common/error.h"
-#include "common/system.h"
-#include "common/file.h"
-
-#include "engines/util.h"
-
-#include "zvision/zvision.h"
-#include "zvision/script_manager.h"
-#include "zvision/zfs_archive.h"
-
-#include "graphics/decoders/tga.h"
-
-#include "zvision/tests.h"
-
-namespace ZVision {
-
-ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
- // Put your engine in a sane state, but do nothing big yet;
- // in particular, do not load data from files; rather, if you
- // need to do such things, do them from run().
-
- // Do not initialize graphics here
-
- // However this is the place to specify all default directories
- const Common::FSNode gameDataDir(ConfMan.get("path"));
- SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4);
- SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4);
- SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4);
- SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx");
- SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr");
-
- // Here is the right place to set up the engine specific debug channels
- //DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel");
- //DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example");
-
- // Register random source
- _rnd = new Common::RandomSource("zvision");
-
- // Create managers
- _scriptManager = new ScriptManager();
-
- debug("ZVision::ZVision");
-}
-
-ZVision::~ZVision() {
- debug("ZVision::~ZVision");
-
- // Dispose of resources
- delete _scriptManager;
- delete _rnd;
-
- // Remove all of our debug levels
- DebugMan.clearAllDebugChannels();
-}
-
-void ZVision::initialize() {
- // Find zfs archive files
- Common::ArchiveMemberList list;
- SearchMan.listMatchingMembers(list, "*.zfs");
-
- // Register the file entries within the zfs archives with the SearchMan
- for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) {
- Common::String name = (*iter)->getName();
- ZfsArchive *archive = new ZfsArchive(name, (*iter)->createReadStream());
-
- SearchMan.add(name, archive);
- }
-
- //Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24); // ARGB8888
- Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); // RGB555
- initGraphics(640, 480, true, &format);
-
- _scriptManager->initialize();
-
- // Create debugger console. It requires GFX to be initialized
- _console = new Console(this);
-}
-
-Common::Error ZVision::run() {
- initialize();
-
- tests();
-
- // Main loop
- uint32 currentTime = _system->getMillis();
- uint32 lastTime = currentTime;
- const uint32 desiredFrameTime = 33; // ~30 fps
-
- while (!shouldQuit()) {
- processEvents();
-
- currentTime = _system->getMillis();
- uint32 deltaTime = currentTime - lastTime;
- lastTime = currentTime;
-
- updateScripts();
- updateAnimations(deltaTime);
-
- if (_needsScreenUpdate)
- {
- _system->updateScreen();
- }
-
- // Calculate the frame delay based off a desired frame rate
- int delay = desiredFrameTime - (currentTime - _system->getMillis());
- // Ensure non-negative
- delay = delay < 0 ? 0 : delay;
- _system->delayMillis(delay);
- }
-
- return Common::kNoError;
-}
-
-ScriptManager *ZVision::getScriptManager() const {
- return _scriptManager;
-}
-
-Common::RandomSource *ZVision::getRandomSource() const {
- return _rnd;
-}
-
-} // End of namespace ZVision
+/* 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 "common/scummsys.h" + +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/error.h" +#include "common/system.h" +#include "common/file.h" + +#include "engines/util.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" +#include "zvision/zfs_archive.h" + +#include "graphics/decoders/tga.h" + +#include "zvision/tests.h" + +namespace ZVision { + +ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { + // Put your engine in a sane state, but do nothing big yet; + // in particular, do not load data from files; rather, if you + // need to do such things, do them from run(). + + // Do not initialize graphics here + + // However this is the place to specify all default directories + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4); + SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4); + SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4); + SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx"); + SearchMan.addSubDirectoryMatching(gameDataDir, "znemscr"); + + // Here is the right place to set up the engine specific debug channels + //DebugMan.addDebugChannel(kZVisionDebugExample, "example", "this is just an example for a engine specific debug channel"); + //DebugMan.addDebugChannel(kZVisionDebugExample2, "example2", "also an example"); + + // Register random source + _rnd = new Common::RandomSource("zvision"); + + // Create managers + _scriptManager = new ScriptManager(); + + debug("ZVision::ZVision"); +} + +ZVision::~ZVision() { + debug("ZVision::~ZVision"); + + // Dispose of resources + delete _scriptManager; + delete _rnd; + + // Remove all of our debug levels + DebugMan.clearAllDebugChannels(); +} + +void ZVision::initialize() { + // Find zfs archive files + Common::ArchiveMemberList list; + SearchMan.listMatchingMembers(list, "*.zfs"); + + // Register the file entries within the zfs archives with the SearchMan + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String name = (*iter)->getName(); + ZfsArchive *archive = new ZfsArchive(name, (*iter)->createReadStream()); + + SearchMan.add(name, archive); + } + + //Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24); // ARGB8888 + Graphics::PixelFormat format = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); // RGB555 + initGraphics(640, 480, true, &format); + + _scriptManager->initialize(); + + // Create debugger console. It requires GFX to be initialized + _console = new Console(this); +} + +Common::Error ZVision::run() { + initialize(); + + tests(); + + // Main loop + uint32 currentTime = _system->getMillis(); + uint32 lastTime = currentTime; + const uint32 desiredFrameTime = 33; // ~30 fps + + while (!shouldQuit()) { + processEvents(); + + currentTime = _system->getMillis(); + uint32 deltaTime = currentTime - lastTime; + lastTime = currentTime; + + updateScripts(); + updateAnimations(deltaTime); + + if (_needsScreenUpdate) + { + _system->updateScreen(); + } + + // Calculate the frame delay based off a desired frame rate + int delay = desiredFrameTime - (currentTime - _system->getMillis()); + // Ensure non-negative + delay = delay < 0 ? 0 : delay; + _system->delayMillis(delay); + } + + return Common::kNoError; +} + +ScriptManager *ZVision::getScriptManager() const { + return _scriptManager; +} + +Common::RandomSource *ZVision::getRandomSource() const { + return _rnd; +} + +} // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index ac5796ad91..0053fe5a9e 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -1,96 +1,96 @@ -/* 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.
- *
- *
- */
-
-#ifndef ZVISION_H
-#define ZVISION_H
-
-#include "common/random.h"
-#include "common/events.h"
-
-#include "engines/engine.h"
-
-#include "zvision/script_manager.h"
-
-#include "gui/debugger.h"
-
-namespace ZVision {
-
-struct ZVisionGameDescription;
-class Console;
-
-// our engine debug channels
-enum {
- kZDebugExample = 1 << 0,
- kZDebugExample2 = 1 << 1
- // next new channel must be 1 << 2 (4)
- // the current limitation is 32 debug channels (1 << 31 is the last one)
-};
-
-class ZVision : public Engine {
-public:
- ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
- ~ZVision();
-
-private:
- Console *_console;
- const ZVisionGameDescription *_gameDescription;
-
- // We need random numbers
- Common::RandomSource *_rnd;
-
- ScriptManager *_scriptManager;
-
- // To prevent allocation every time we process events
- Common::Event _event;
-
- bool _needsScreenUpdate;
-
-public:
- uint32 getFeatures() const;
- Common::Language getLanguage() const;
- virtual Common::Error run();
- ScriptManager *getScriptManager() const;
- Common::RandomSource *getRandomSource() const;
-
-private:
- void initialize();
-
- void processEvents();
+/* 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. + * + * + */ + +#ifndef ZVISION_H +#define ZVISION_H + +#include "common/random.h" +#include "common/events.h" + +#include "engines/engine.h" + +#include "zvision/script_manager.h" + +#include "gui/debugger.h" + +namespace ZVision { + +struct ZVisionGameDescription; +class Console; + +// our engine debug channels +enum { + kZDebugExample = 1 << 0, + kZDebugExample2 = 1 << 1 + // next new channel must be 1 << 2 (4) + // the current limitation is 32 debug channels (1 << 31 is the last one) +}; + +class ZVision : public Engine { +public: + ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc); + ~ZVision(); + +private: + Console *_console; + const ZVisionGameDescription *_gameDescription; + + // We need random numbers + Common::RandomSource *_rnd; + + ScriptManager *_scriptManager; + + // To prevent allocation every time we process events + Common::Event _event; + + bool _needsScreenUpdate; + +public: + uint32 getFeatures() const; + Common::Language getLanguage() const; + virtual Common::Error run(); + ScriptManager *getScriptManager() const; + Common::RandomSource *getRandomSource() const; + +private: + void initialize(); + + void processEvents(); void onMouseDown(const Common::Point &pos); void onMouseMove(const Common::Point &pos); - void onKeyDown(uint16 keyCode);
-
- void updateScripts();
- void updateAnimations(uint32 detaTimeMillis);
-};
-
-// Example console class
-class Console : public GUI::Debugger {
-public:
- Console(ZVision *vm) {}
- virtual ~Console(void) {}
-};
-
-} // End of namespace ZVision
-
-#endif
+ void onKeyDown(uint16 keyCode); + + void updateScripts(); + void updateAnimations(uint32 detaTimeMillis); +}; + +// Example console class +class Console : public GUI::Debugger { +public: + Console(ZVision *vm) {} + virtual ~Console(void) {} +}; + +} // End of namespace ZVision + +#endif |