From bb035967442df0f9cb7de3e3da3d73ce2f4ce5d2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 11 May 2008 23:16:50 +0000 Subject: - Renamed KyraEngine to KyraEngine_v1 - kyra.* -> kyra_v1.* - scene.cpp -> scene_v1.cpp svn-id: r32044 --- engines/kyra/debugger.cpp | 2 +- engines/kyra/debugger.h | 6 +- engines/kyra/detection.cpp | 6 +- engines/kyra/gui.cpp | 4 +- engines/kyra/gui.h | 10 +- engines/kyra/gui_hof.cpp | 18 +- engines/kyra/gui_lok.cpp | 2 +- engines/kyra/gui_mr.cpp | 10 +- engines/kyra/gui_v2.cpp | 2 +- engines/kyra/kyra.cpp | 400 ----------------------------------------- engines/kyra/kyra.h | 272 ---------------------------- engines/kyra/kyra_hof.cpp | 12 +- engines/kyra/kyra_lok.cpp | 10 +- engines/kyra/kyra_lok.h | 8 +- engines/kyra/kyra_mr.cpp | 12 +- engines/kyra/kyra_v1.cpp | 400 +++++++++++++++++++++++++++++++++++++++++ engines/kyra/kyra_v1.h | 272 ++++++++++++++++++++++++++++ engines/kyra/kyra_v2.cpp | 2 +- engines/kyra/kyra_v2.h | 4 +- engines/kyra/module.mk | 4 +- engines/kyra/resource.cpp | 2 +- engines/kyra/resource.h | 10 +- engines/kyra/saveload.cpp | 18 +- engines/kyra/scene.cpp | 383 --------------------------------------- engines/kyra/scene_lok.cpp | 2 +- engines/kyra/scene_v1.cpp | 383 +++++++++++++++++++++++++++++++++++++++ engines/kyra/scene_v2.cpp | 2 +- engines/kyra/screen.cpp | 6 +- engines/kyra/screen.h | 6 +- engines/kyra/screen_v2.cpp | 2 +- engines/kyra/screen_v2.h | 2 +- engines/kyra/script.cpp | 4 +- engines/kyra/script.h | 7 +- engines/kyra/script_tim.cpp | 2 +- engines/kyra/script_tim.h | 6 +- engines/kyra/sequences_hof.cpp | 2 +- engines/kyra/sound.cpp | 24 +-- engines/kyra/sound.h | 16 +- engines/kyra/sound_adlib.cpp | 2 +- engines/kyra/sound_lok.cpp | 4 +- engines/kyra/sound_towns.cpp | 4 +- engines/kyra/staticres.cpp | 6 +- engines/kyra/text.cpp | 4 +- engines/kyra/text.h | 6 +- engines/kyra/timer.cpp | 4 +- engines/kyra/timer.h | 6 +- engines/kyra/timer_lok.cpp | 2 +- engines/kyra/vqa.cpp | 2 +- engines/kyra/vqa.h | 6 +- engines/kyra/wsamovie.cpp | 8 +- engines/kyra/wsamovie.h | 12 +- 51 files changed, 1200 insertions(+), 1199 deletions(-) delete mode 100644 engines/kyra/kyra.cpp delete mode 100644 engines/kyra/kyra.h create mode 100644 engines/kyra/kyra_v1.cpp create mode 100644 engines/kyra/kyra_v1.h delete mode 100644 engines/kyra/scene.cpp create mode 100644 engines/kyra/scene_v1.cpp (limited to 'engines/kyra') diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp index 932f5aa7dd..0d170dbf05 100644 --- a/engines/kyra/debugger.cpp +++ b/engines/kyra/debugger.cpp @@ -36,7 +36,7 @@ namespace Kyra { -Debugger::Debugger(KyraEngine *vm) +Debugger::Debugger(KyraEngine_v1 *vm) : ::GUI::Debugger() { _vm = vm; diff --git a/engines/kyra/debugger.h b/engines/kyra/debugger.h index 7b1d870daa..7cdfa26e93 100644 --- a/engines/kyra/debugger.h +++ b/engines/kyra/debugger.h @@ -30,18 +30,18 @@ namespace Kyra { -class KyraEngine; +class KyraEngine_v1; class KyraEngine_LoK; class KyraEngine_v2; class KyraEngine_HoF; class Debugger : public ::GUI::Debugger { public: - Debugger(KyraEngine *vm); + Debugger(KyraEngine_v1 *vm); virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; bool cmd_setScreenDebug(int argc, const char **argv); bool cmd_loadPalette(int argc, const char **argv); diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 2b272fd7d7..6a11ca9a34 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -22,7 +22,7 @@ * $Id$ */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_lok.h" #include "kyra/kyra_hof.h" #include "kyra/kyra_mr.h" @@ -524,7 +524,7 @@ bool KyraMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common SaveStateList KyraMetaEngine::listSaves(const char *target) const { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); - Kyra::KyraEngine::SaveHeader header; + Kyra::KyraEngine_v1::SaveHeader header; Common::String pattern = target; pattern += ".???"; @@ -540,7 +540,7 @@ SaveStateList KyraMetaEngine::listSaves(const char *target) const { if (slotNum >= 0 && slotNum <= 999) { Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); if (in) { - if (Kyra::KyraEngine::readSaveHeader(in, header) == Kyra::KyraEngine::kRSHENoError) + if (Kyra::KyraEngine_v1::readSaveHeader(in, header) == Kyra::KyraEngine_v1::kRSHENoError) saveList.push_back(SaveStateDescriptor(slotNum, header.description, *file)); delete in; } diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 407be7a73a..96ea233025 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -33,7 +33,7 @@ namespace Kyra { -GUI::GUI(KyraEngine *kyra) +GUI::GUI(KyraEngine_v1 *kyra) : _vm(kyra), _screen(kyra->screen()), _text(kyra->text()) { _menuButtonList = 0; @@ -339,7 +339,7 @@ int GUI::getNextSavegameSlot() { #pragma mark - -MainMenu::MainMenu(KyraEngine *vm) : _vm(vm), _screen(0) { +MainMenu::MainMenu(KyraEngine_v1 *vm) : _vm(vm), _screen(0) { _screen = _vm->screen(); _nextUpdate = 0; _system = g_system; diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h index 8023cc4810..1361bdb399 100644 --- a/engines/kyra/gui.h +++ b/engines/kyra/gui.h @@ -26,7 +26,7 @@ #ifndef KYRA_GUI_H #define KYRA_GUI_H -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "common/ptr.h" #include "common/array.h" @@ -135,7 +135,7 @@ class TextDisplayer; class GUI { public: - GUI(KyraEngine *vm); + GUI(KyraEngine_v1 *vm); virtual ~GUI() {} // button specific @@ -154,7 +154,7 @@ public: void processHighlights(Menu &menu, int mouseX, int mouseY); protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; Screen *_screen; TextDisplayer *_text; @@ -196,7 +196,7 @@ class Movie; class MainMenu { public: - MainMenu(KyraEngine *vm); + MainMenu(KyraEngine_v1 *vm); virtual ~MainMenu() {} struct Animation { @@ -219,7 +219,7 @@ public: void init(StaticData data, Animation anim); int handle(int dim); private: - KyraEngine *_vm; + KyraEngine_v1 *_vm; Screen *_screen; OSystem *_system; diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp index 12e4065ec6..d60b353de3 100644 --- a/engines/kyra/gui_hof.cpp +++ b/engines/kyra/gui_hof.cpp @@ -23,7 +23,7 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_hof.h" #include "kyra/screen.h" #include "kyra/wsamovie.h" @@ -827,10 +827,10 @@ void GUI_HoF::drawSliderBar(int slider, const uint8 *shape) { int position = 0; if (_vm->gameFlags().isTalkie) { - position = _vm->getVolume(KyraEngine::kVolumeEntry(slider)); + position = _vm->getVolume(KyraEngine_v1::kVolumeEntry(slider)); } else { if (slider < 2) - position = _vm->getVolume(KyraEngine::kVolumeEntry(slider)); + position = _vm->getVolume(KyraEngine_v1::kVolumeEntry(slider)); else if (slider == 2) position = (_vm->_configWalkspeed == 3) ? 97 : 2; else if (slider == 3) @@ -900,7 +900,7 @@ int GUI_HoF::audioOptions(Button *caller) { restorePage1(_vm->_screenBuffer); backUpPage1(_vm->_screenBuffer); - if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine::kVolumeSpeech) == 2)) { + if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine_v1::kVolumeSpeech) == 2)) { _vm->_configVoice = 0; choiceDialog(0x1D, 0); } @@ -978,7 +978,7 @@ int GUI_HoF::gameOptionsTalkie(Button *caller) { if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) { _vm->_configVoice = 1; - _vm->setVolume(KyraEngine::kVolumeSpeech, 75); + _vm->setVolume(KyraEngine_v1::kVolumeSpeech, 75); choiceDialog(0x1E, 0); } @@ -1054,10 +1054,10 @@ int GUI_HoF::sliderHandler(Button *caller) { int oldVolume = 0; if (_vm->gameFlags().isTalkie) { - oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button)); + oldVolume = _vm->getVolume(KyraEngine_v1::kVolumeEntry(button)); } else { if (button < 2) - oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button)); + oldVolume = _vm->getVolume(KyraEngine_v1::kVolumeEntry(button)); else if (button == 2) oldVolume = (_vm->_configWalkspeed == 3) ? 97 : 2; else if (button == 3) @@ -1092,7 +1092,7 @@ int GUI_HoF::sliderHandler(Button *caller) { _vm->_configVoice = 1; } - _vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume); + _vm->setVolume(KyraEngine_v1::kVolumeEntry(button), newVolume); switch (button) { case 0: @@ -1112,7 +1112,7 @@ int GUI_HoF::sliderHandler(Button *caller) { } } else { if (button < 2) { - _vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume); + _vm->setVolume(KyraEngine_v1::kVolumeEntry(button), newVolume); if (button == 0) lastMusicCommand = _vm->_lastMusicCommand; else diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp index 844574c5be..feacde683c 100644 --- a/engines/kyra/gui_lok.cpp +++ b/engines/kyra/gui_lok.cpp @@ -544,7 +544,7 @@ void GUI_LoK::setupSavegames(Menu &menu, int num) { for (int i = startSlot; i < num; ++i) menu.item[i].enabled = 0; - KyraEngine::SaveHeader header; + KyraEngine_v1::SaveHeader header; for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); i++) { if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header))) { strncpy(savenames[i], header.description.c_str(), 31); diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp index 74f6451e28..d0a39df0b2 100644 --- a/engines/kyra/gui_mr.cpp +++ b/engines/kyra/gui_mr.cpp @@ -1444,7 +1444,7 @@ int GUI_MR::gameOptions(Button *caller) { if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) { _vm->_configVoice = 1; - _vm->setVolume(KyraEngine::kVolumeSpeech, 75); + _vm->setVolume(KyraEngine_v1::kVolumeSpeech, 75); choiceDialog(0x1E, 0); } @@ -1597,7 +1597,7 @@ int GUI_MR::audioOptions(Button *caller) { restorePage1(_vm->_screenBuffer); backUpPage1(_vm->_screenBuffer); - if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine::kVolumeSpeech) == 2)) { + if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine_v1::kVolumeSpeech) == 2)) { _vm->_configVoice = 0; choiceDialog(0x1D, 0); } @@ -1620,7 +1620,7 @@ int GUI_MR::sliderHandler(Button *caller) { assert(button >= 0 && button <= 3); - int oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button)); + int oldVolume = _vm->getVolume(KyraEngine_v1::kVolumeEntry(button)); int newVolume = oldVolume; if (caller->index >= 24 && caller->index <= 27) @@ -1648,7 +1648,7 @@ int GUI_MR::sliderHandler(Button *caller) { _vm->_configVoice = 1; } - _vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume); + _vm->setVolume(KyraEngine_v1::kVolumeEntry(button), newVolume); switch (button) { case 0: @@ -1685,7 +1685,7 @@ void GUI_MR::drawSliderBar(int slider, const uint8 *shape) { int x = menuX + _sliderBarsPosition[slider*2+0] + 10; int y = menuY + _sliderBarsPosition[slider*2+1]; - int position = _vm->getVolume(KyraEngine::kVolumeEntry(slider)); + int position = _vm->getVolume(KyraEngine_v1::kVolumeEntry(slider)); position = MAX(2, position); position = MIN(97, position); diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 6ee6b1e4a5..2819c4f077 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -451,7 +451,7 @@ void GUI_v2::setupSavegameNames(Menu &menu, int num) { if (_isSaveMenu && _savegameOffset == 0) startSlot = 1; - KyraEngine::SaveHeader header; + KyraEngine_v1::SaveHeader header; Common::InSaveFile *in; for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); ++i) { if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header)) != 0) { diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp deleted file mode 100644 index e35e91731d..0000000000 --- a/engines/kyra/kyra.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/* 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. - * - * $URL$ - * $Id$ - * - */ - -#include "common/config-manager.h" - -#include "sound/mididrv.h" -#include "sound/mixer.h" - -#include "kyra/kyra.h" -#include "kyra/sound.h" -#include "kyra/resource.h" -#include "kyra/screen.h" -#include "kyra/text.h" -#include "kyra/timer.h" -#include "kyra/script.h" -#include "kyra/debugger.h" - -namespace Kyra { - -KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags) - : Engine(system), _flags(flags) { - _res = 0; - _sound = 0; - _text = 0; - _staticres = 0; - _timer = 0; - _emc = 0; - _debugger = 0; - - _gameSpeed = 60; - _tickLength = (uint8)(1000.0 / _gameSpeed); - - _quitFlag = false; - - _speechFile = ""; - _trackMap = 0; - _trackMapSize = 0; - _lastMusicCommand = -1; - _curSfxFile = _curMusicTheme = -1; - - _gameToLoad = -1; - - memset(_flagsTable, 0, sizeof(_flagsTable)); - - // sets up all engine specific debug levels - Common::addSpecialDebugLevel(kDebugLevelScriptFuncs, "ScriptFuncs", "Script function debug level"); - Common::addSpecialDebugLevel(kDebugLevelScript, "Script", "Script interpreter debug level"); - Common::addSpecialDebugLevel(kDebugLevelSprites, "Sprites", "Sprite debug level"); - Common::addSpecialDebugLevel(kDebugLevelScreen, "Screen", "Screen debug level"); - Common::addSpecialDebugLevel(kDebugLevelSound, "Sound", "Sound debug level"); - Common::addSpecialDebugLevel(kDebugLevelAnimator, "Animator", "Animator debug level"); - Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level"); - Common::addSpecialDebugLevel(kDebugLevelGUI, "GUI", "GUI debug level"); - Common::addSpecialDebugLevel(kDebugLevelSequence, "Sequence", "Sequence debug level"); - Common::addSpecialDebugLevel(kDebugLevelMovie, "Movie", "Movie debug level"); - Common::addSpecialDebugLevel(kDebugLevelTimer, "Timer", "Timer debug level"); - - system->getEventManager()->registerRandomSource(_rnd, "kyra"); -} - -::GUI::Debugger *KyraEngine::getDebugger() { - return _debugger; -} - -int KyraEngine::init() { - registerDefaultSettings(); - - // Setup mixer - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); - - if (!_flags.useDigSound) { - // We prefer AdLib over native MIDI, since our AdLib playback code is much - // more mature than our MIDI player. For example we are missing MT-32 support - // and it seems our MIDI playback code has threading issues (see bug #1506583 - // "KYRA1: Crash on exceeded polyphony" for more information). - int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/); - - if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) { - // TODO: currently we don't support the PC98 sound data, - // but since it has the FM-Towns data files, we just use the - // FM-Towns driver - if (_flags.gameID == GI_KYRA1) - _sound = new SoundTowns(this, _mixer); - else - _sound = new SoundTowns_v2(this, _mixer); - } else if (midiDriver == MD_ADLIB) { - _sound = new SoundAdlibPC(this, _mixer); - assert(_sound); - } else { - bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); - - MidiDriver *driver = MidiDriver::createMidi(midiDriver); - assert(driver); - if (native_mt32) - driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); - - SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver); - _sound = soundMidiPc; - assert(_sound); - soundMidiPc->hasNativeMT32(native_mt32); - - // Unlike some SCUMM games, it's not that the MIDI sounds are - // missing. It's just that at least at the time of writing they - // are decidedly inferior to the Adlib ones. - if (ConfMan.getBool("multi_midi")) { - SoundAdlibPC *adlib = new SoundAdlibPC(this, _mixer); - assert(adlib); - - _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); - assert(_sound); - } - } - } - - if (_sound) - _sound->updateVolumeSettings(); - - _res = new Resource(this); - assert(_res); - _res->reset(); - _staticres = new StaticResource(this); - assert(_staticres); - if (!_staticres->init()) - error("_staticres->init() failed"); - if (!screen()->init()) - error("screen()->init() failed"); - _timer = new TimerManager(this, _system); - assert(_timer); - setupTimers(); - _emc = new EMCInterpreter(this); - assert(_emc); - - setupOpcodeTable(); - readSettings(); - - if (ConfMan.hasKey("save_slot")) { - _gameToLoad = ConfMan.getInt("save_slot"); - if (!saveFileLoadable(_gameToLoad)) - _gameToLoad = -1; - } - - _lang = 0; - Common::Language lang = Common::parseLanguage(ConfMan.get("language")); - - if (_flags.gameID == GI_KYRA2 || _flags.gameID == GI_KYRA3) { - switch (lang) { - case Common::EN_ANY: - case Common::EN_USA: - case Common::EN_GRB: - _lang = 0; - break; - - case Common::FR_FRA: - _lang = 1; - break; - - case Common::DE_DEU: - _lang = 2; - break; - - case Common::JA_JPN: - _lang = 3; - break; - - default: - warning("unsupported language, switching back to English"); - _lang = 0; - break; - } - } - - return 0; -} - -KyraEngine::~KyraEngine() { - for (Common::Array::iterator i = _opcodes.begin(); i != _opcodes.end(); ++i) - delete *i; - _opcodes.clear(); - - delete _res; - delete _staticres; - delete _sound; - delete _text; - delete _timer; - delete _emc; - delete _debugger; -} - -void KyraEngine::quitGame() { - debugC(9, kDebugLevelMain, "KyraEngine::quitGame()"); - _quitFlag = true; - // Nothing to do here -} - -Common::Point KyraEngine::getMousePos() const { - Common::Point mouse = _eventMan->getMousePos(); - - if (_flags.useHiResOverlay) { - mouse.x >>= 1; - mouse.y >>= 1; - } - - return mouse; -} - -void KyraEngine::setMousePos(int x, int y) { - if (_flags.useHiResOverlay) { - x <<= 1; - y <<= 1; - } - _system->warpMouse(x, y); -} - -int KyraEngine::setGameFlag(int flag) { - _flagsTable[flag >> 3] |= (1 << (flag & 7)); - return 1; -} - -int KyraEngine::queryGameFlag(int flag) const { - return ((_flagsTable[flag >> 3] >> (flag & 7)) & 1); -} - -int KyraEngine::resetGameFlag(int flag) { - _flagsTable[flag >> 3] &= ~(1 << (flag & 7)); - return 0; -} - -void KyraEngine::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { - while (_system->getMillis() < timestamp && !_quitFlag) { - if (timestamp - _system->getMillis() >= 10) - delay(10, update, isMainLoop); - } -} - -void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) { - _system->delayMillis(amount); -} - -void KyraEngine::delayWithTicks(int ticks) { - delay(ticks * _tickLength); -} - -void KyraEngine::registerDefaultSettings() { - if (_flags.gameID != GI_KYRA3) - ConfMan.registerDefault("cdaudio", (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)); -} - -void KyraEngine::readSettings() { - _configWalkspeed = ConfMan.getInt("walkspeed"); - _configMusic = 0; - - if (!ConfMan.getBool("music_mute")) { - _configMusic = 1; - if (_flags.gameID != GI_KYRA3 && ConfMan.getBool("cdaudio") && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) - _configMusic = 2; - } - _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; - - if (_sound) { - _sound->enableMusic(_configMusic); - _sound->enableSFX(_configSounds); - } - - bool speechMute = ConfMan.getBool("speech_mute"); - bool subtitles = ConfMan.getBool("subtitles"); - - if (!speechMute && subtitles) - _configVoice = 2; // Voice & Text - else if (!speechMute && !subtitles) - _configVoice = 1; // Voice only - else - _configVoice = 0; // Text only - - setWalkspeed(_configWalkspeed); -} - -void KyraEngine::writeSettings() { - bool speechMute, subtitles; - - ConfMan.setInt("walkspeed", _configWalkspeed); - ConfMan.setBool("music_mute", _configMusic == 0); - if (_flags.gameID != GI_KYRA3) - ConfMan.setBool("cdaudio", _configMusic == 2); - ConfMan.setBool("sfx_mute", _configSounds == 0); - - switch (_configVoice) { - case 0: // Text only - speechMute = true; - subtitles = true; - break; - case 1: // Voice only - speechMute = false; - subtitles = false; - break; - default: // Voice & Text - speechMute = false; - subtitles = true; - break; - } - - if (_sound) { - if (!_configMusic) - _sound->beginFadeOut(); - _sound->enableMusic(_configMusic); - _sound->enableSFX(_configSounds); - } - - ConfMan.setBool("speech_mute", speechMute); - ConfMan.setBool("subtitles", subtitles); - - ConfMan.flushToDisk(); -} - -bool KyraEngine::speechEnabled() { - return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2); -} - -bool KyraEngine::textEnabled() { - return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2); -} - -inline int convertValueToMixer(int value) { - value -= 2; - return (value * Audio::Mixer::kMaxMixerVolume) / 95; -} - -inline int convertValueFromMixer(int value) { - return (value * 95) / Audio::Mixer::kMaxMixerVolume + 2; -} - -void KyraEngine::setVolume(kVolumeEntry vol, uint8 value) { - switch (vol) { - case kVolumeMusic: - ConfMan.setInt("music_volume", convertValueToMixer(value)); - break; - - case kVolumeSfx: - ConfMan.setInt("sfx_volume", convertValueToMixer(value)); - break; - - case kVolumeSpeech: - ConfMan.setInt("speech_volume", convertValueToMixer(value)); - break; - } - - // Resetup mixer - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); - if (_sound) - _sound->updateVolumeSettings(); -} - -uint8 KyraEngine::getVolume(kVolumeEntry vol) { - switch (vol) { - case kVolumeMusic: - return convertValueFromMixer(ConfMan.getInt("music_volume")); - break; - - case kVolumeSfx: - return convertValueFromMixer(ConfMan.getInt("sfx_volume")); - break; - - case kVolumeSpeech: - if (speechEnabled()) - return convertValueFromMixer(ConfMan.getInt("speech_volume")); - else - return 2; - break; - } - - return 2; -} - -} // End of namespace Kyra - diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h deleted file mode 100644 index 66ecb2704c..0000000000 --- a/engines/kyra/kyra.h +++ /dev/null @@ -1,272 +0,0 @@ -/* 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. - * - * $URL$ - * $Id$ - * - */ - -#ifndef KYRA_KYRA_H -#define KYRA_KYRA_H - -#include "engines/engine.h" - -#include "common/array.h" -#include "common/events.h" - -#include "kyra/script.h" - -namespace Common { -class InSaveFile; -class OutSaveFile; -} // end of namespace Common - -class KyraMetaEngine; - -namespace Kyra { - -struct GameFlags { - Common::Language lang; - Common::Platform platform; - - bool isDemo : 1; - bool useAltShapeHeader : 1; // alternative shape header (uses 2 bytes more, those are unused though) - bool isTalkie : 1; - bool useHiResOverlay : 1; - bool useDigSound : 1; - - byte gameID; -}; - -enum { - GI_KYRA1 = 0, - GI_KYRA2 = 1, - GI_KYRA3 = 2 -}; - -struct AudioDataStruct { - const char * const *_fileList; - const int _fileListLen; - const void * const _cdaTracks; - const int _cdaNumTracks; -}; - -// TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable -// in the future we maybe merge some flags and/or create new ones -enum kDebugLevels { - kDebugLevelScriptFuncs = 1 << 0, // prints debug output of o#_* functions - kDebugLevelScript = 1 << 1, // prints debug output of "EMCInterpreter" functions - kDebugLevelSprites = 1 << 2, // prints debug output of "Sprites" functions - kDebugLevelScreen = 1 << 3, // prints debug output of "Screen" functions - kDebugLevelSound = 1 << 4, // prints debug output of "Sound" functions - kDebugLevelAnimator = 1 << 5, // prints debug output of "ScreenAnimator" functions - kDebugLevelMain = 1 << 6, // prints debug output of common "KyraEngine(_v#)" functions && "TextDisplayer" functions - kDebugLevelGUI = 1 << 7, // prints debug output of "KyraEngine*" gui functions - kDebugLevelSequence = 1 << 8, // prints debug output of "SeqPlayer" functions - kDebugLevelMovie = 1 << 9, // prints debug output of movie specific funtions - kDebugLevelTimer = 1 << 10 // prints debug output of "TimerManager" functions -}; - -enum kMusicDataID { - kMusicIntro = 0, - kMusicIngame, - kMusicFinale -}; - -class Screen; -class Resource; -class Sound; -class Movie; -class TextDisplayer; -class StaticResource; -class TimerManager; -class Debugger; - -class KyraEngine : public Engine { -friend class Debugger; -friend class ::KyraMetaEngine; -friend class GUI; -public: - KyraEngine(OSystem *system, const GameFlags &flags); - virtual ~KyraEngine(); - - ::GUI::Debugger *getDebugger(); - - bool quit() const { return _quitFlag; } - - uint8 game() const { return _flags.gameID; } - const GameFlags &gameFlags() const { return _flags; } - - // access to Kyra specific functionallity - Resource *resource() { return _res; } - virtual Screen *screen() = 0; - virtual TextDisplayer *text() { return _text; } - Sound *sound() { return _sound; } - StaticResource *staticres() { return _staticres; } - TimerManager *timer() { return _timer; } - - uint32 tickLength() const { return _tickLength; } - - Common::RandomSource _rnd; - - // input - void setMousePos(int x, int y); - Common::Point getMousePos() const; - - // config specific - bool speechEnabled(); - bool textEnabled(); - - enum kVolumeEntry { - kVolumeMusic = 0, - kVolumeSfx = 1, - kVolumeSpeech = 2 - }; - - // volume reaches from 2 to 97 - void setVolume(kVolumeEntry vol, uint8 value); - uint8 getVolume(kVolumeEntry vol); - - // quit handling - virtual void quitGame(); - - // game flag handling - int setGameFlag(int flag); - int queryGameFlag(int flag) const; - int resetGameFlag(int flag); - - // sound - virtual void snd_playTheme(int file, int track); - virtual void snd_playSoundEffect(int id, int volume=0xFF); - virtual void snd_playWanderScoreViaMap(int command, int restart); - virtual void snd_playVoiceFile(int id) = 0; - virtual bool snd_voiceIsPlaying(); - virtual void snd_stopVoice(); - - // delay functionallity - virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false); - virtual void delay(uint32 millis, bool update = false, bool isMainLoop = false); - virtual void delayWithTicks(int ticks); - -protected: - virtual int go() = 0; - virtual int init(); - - // quit Handling - bool _quitFlag; - - // intern - Resource *_res; - Sound *_sound; - TextDisplayer *_text; - StaticResource *_staticres; - TimerManager *_timer; - EMCInterpreter *_emc; - Debugger *_debugger; - - // config specific - virtual void registerDefaultSettings(); - virtual void readSettings(); - virtual void writeSettings(); - - uint8 _configWalkspeed; - - int _configMusic; - bool _configSounds; - uint8 _configVoice; - - // game speed - virtual bool skipFlag() const = 0; - virtual void resetSkipFlag(bool removeEvent = true) = 0; - - uint16 _tickLength; - uint16 _gameSpeed; - - // timer - virtual void setupTimers() = 0; - - virtual void setWalkspeed(uint8 speed) = 0; - - // detection - GameFlags _flags; - int _lang; - - // opcode - virtual void setupOpcodeTable() = 0; - Common::Array _opcodes; - - // game flags - uint8 _flagsTable[100]; // TODO: check this value - - // sound - Common::String _speechFile; - - int _curMusicTheme; - int _curSfxFile; - int16 _lastMusicCommand; - - const int8 *_trackMap; - int _trackMapSize; - - // pathfinder - virtual int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize); - int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end); - int getFacingFromPointToPoint(int x, int y, int toX, int toY); - int getOppositeFacingDirection(int dir); - void changePosTowardsFacing(int &x, int &y, int facing); - int getMoveTableSize(int *moveTable); - virtual bool lineIsPassable(int x, int y) = 0; - - static const int8 _addXPosTable[]; - static const int8 _addYPosTable[]; - - // save/load - int _gameToLoad; - - const char *getSavegameFilename(int num); - bool saveFileLoadable(int slot); - - struct SaveHeader { - Common::String description; - uint32 version; - byte gameID; - uint32 flags; - - bool originalSave; // savegame from original interpreter - bool oldHeader; // old scummvm save header - }; - - enum kReadSaveHeaderError { - kRSHENoError = 0, - kRSHEInvalidType = 1, - kRSHEInvalidVersion = 2, - kRSHEIoError = 3 - }; - - static kReadSaveHeaderError readSaveHeader(Common::InSaveFile *file, SaveHeader &header); - - Common::InSaveFile *openSaveForReading(const char *filename, SaveHeader &header); - Common::OutSaveFile *openSaveForWriting(const char *filename, const char *saveName) const; -}; - -} // End of namespace Kyra - -#endif - diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index 5a2d36d612..f1b74a7bdb 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -23,7 +23,7 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_hof.h" #include "kyra/screen.h" #include "kyra/resource.h" @@ -182,7 +182,7 @@ int KyraEngine_HoF::init() { assert(_screen); _screen->setResolution(); - KyraEngine::init(); + KyraEngine_v1::init(); initStaticResource(); _debugger = new Debugger_HoF(this); @@ -1526,7 +1526,7 @@ void KyraEngine_HoF::snd_playSoundEffect(int track, int volume) { else if (_flags.platform == Common::kPlatformPC) // TODO ?? Maybe there is a way to let users select whether they want // voc, midi or adl sfx (even though it makes no sense to choose anything but voc). - KyraEngine::snd_playSoundEffect(track); + KyraEngine_v1::snd_playSoundEffect(track); } #pragma mark - @@ -1954,7 +1954,7 @@ void KyraEngine_HoF::playTim(const char *filename) { #pragma mark - void KyraEngine_HoF::registerDefaultSettings() { - KyraEngine::registerDefaultSettings(); + KyraEngine_v1::registerDefaultSettings(); // Most settings already have sensible defaults. This one, however, is // specific to the Kyra engine. @@ -1985,13 +1985,13 @@ void KyraEngine_HoF::writeSettings() { ConfMan.set("language", Common::getLanguageCode(_flags.lang)); - KyraEngine::writeSettings(); + KyraEngine_v1::writeSettings(); } void KyraEngine_HoF::readSettings() { int talkspeed = ConfMan.getInt("talkspeed"); _configTextspeed = (talkspeed*95)/255 + 2; - KyraEngine::readSettings(); + KyraEngine_v1::readSettings(); } } // end of namespace Kyra diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index 175a635157..6ab2db5492 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -47,7 +47,7 @@ namespace Kyra { KyraEngine_LoK::KyraEngine_LoK(OSystem *system, const GameFlags &flags) - : KyraEngine(system, flags) { + : KyraEngine_v1(system, flags) { _skipFlag = false; _seq_Forest = _seq_KallakWriting = _seq_KyrandiaLogo = _seq_KallakMalcolm = @@ -156,7 +156,7 @@ int KyraEngine_LoK::init() { assert(_screen); _screen->setResolution(); - KyraEngine::init(); + KyraEngine_v1::init(); _sprites = new Sprites(this, _system); assert(_sprites); @@ -994,7 +994,7 @@ void KyraEngine_LoK::checkAmuletAnimFlags() { #pragma mark - void KyraEngine_LoK::registerDefaultSettings() { - KyraEngine::registerDefaultSettings(); + KyraEngine_v1::registerDefaultSettings(); // Most settings already have sensible defaults. This one, however, is // specific to the Kyra engine. @@ -1015,7 +1015,7 @@ void KyraEngine_LoK::readSettings() { else _configTextspeed = 2; // Fast - KyraEngine::readSettings(); + KyraEngine_v1::readSettings(); } void KyraEngine_LoK::writeSettings() { @@ -1038,7 +1038,7 @@ void KyraEngine_LoK::writeSettings() { ConfMan.setInt("talkspeed", talkspeed); - KyraEngine::writeSettings(); + KyraEngine_v1::writeSettings(); } } // end of namespace Kyra diff --git a/engines/kyra/kyra_lok.h b/engines/kyra/kyra_lok.h index fe742a1da9..eed2f71ab0 100644 --- a/engines/kyra/kyra_lok.h +++ b/engines/kyra/kyra_lok.h @@ -23,10 +23,10 @@ * */ -#ifndef KYRA_KYRA_V1_H -#define KYRA_KYRA_V1_H +#ifndef KYRA_KYRA_LOK_H +#define KYRA_KYRA_LOK_H -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/script.h" #include "kyra/screen_lok.h" #include "kyra/gui_lok.h" @@ -104,7 +104,7 @@ struct BeadState { int16 tableIndex; }; -class KyraEngine_LoK : public KyraEngine { +class KyraEngine_LoK : public KyraEngine_v1 { friend class MusicPlayer; friend class Debugger_LoK; friend class Animator_LoK; diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 6eca24fe98..f53192d68a 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -23,7 +23,7 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_mr.h" #include "kyra/screen_mr.h" #include "kyra/wsamovie.h" @@ -205,7 +205,7 @@ int KyraEngine_MR::init() { assert(_screen); _screen->setResolution(); - KyraEngine::init(); + KyraEngine_v1::init(); _debugger = new Debugger_v2(this); assert(_debugger); @@ -214,7 +214,7 @@ int KyraEngine_MR::init() { assert(_soundDigital); if (!_soundDigital->init()) error("_soundDigital->init() failed"); - KyraEngine::_text = _text = new TextDisplayer_MR(this, _screen); + KyraEngine_v1::_text = _text = new TextDisplayer_MR(this, _screen); assert(_text); _gui = new GUI_MR(this); assert(_gui); @@ -1509,7 +1509,7 @@ void KyraEngine_MR::resetSkipFlag(bool removeEvent) { void KyraEngine_MR::registerDefaultSettings() { debugC(9, kDebugLevelMain, "KyraEngine_MR::registerDefaultSettings()"); - KyraEngine::registerDefaultSettings(); + KyraEngine_v1::registerDefaultSettings(); // Most settings already have sensible defaults. This one, however, is // specific to the Kyra engine. @@ -1542,12 +1542,12 @@ void KyraEngine_MR::writeSettings() { ConfMan.setBool("skip_support", _configSkip); ConfMan.setBool("helium_mode", _configHelium); - KyraEngine::writeSettings(); + KyraEngine_v1::writeSettings(); } void KyraEngine_MR::readSettings() { debugC(9, kDebugLevelMain, "KyraEngine_MR::readSettings()"); - KyraEngine::readSettings(); + KyraEngine_v1::readSettings(); _configStudio = ConfMan.getBool("studio_audience"); _configSkip = ConfMan.getBool("skip_support"); diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp new file mode 100644 index 0000000000..8109ab0e26 --- /dev/null +++ b/engines/kyra/kyra_v1.cpp @@ -0,0 +1,400 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#include "common/config-manager.h" + +#include "sound/mididrv.h" +#include "sound/mixer.h" + +#include "kyra/kyra_v1.h" +#include "kyra/sound.h" +#include "kyra/resource.h" +#include "kyra/screen.h" +#include "kyra/text.h" +#include "kyra/timer.h" +#include "kyra/script.h" +#include "kyra/debugger.h" + +namespace Kyra { + +KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) + : Engine(system), _flags(flags) { + _res = 0; + _sound = 0; + _text = 0; + _staticres = 0; + _timer = 0; + _emc = 0; + _debugger = 0; + + _gameSpeed = 60; + _tickLength = (uint8)(1000.0 / _gameSpeed); + + _quitFlag = false; + + _speechFile = ""; + _trackMap = 0; + _trackMapSize = 0; + _lastMusicCommand = -1; + _curSfxFile = _curMusicTheme = -1; + + _gameToLoad = -1; + + memset(_flagsTable, 0, sizeof(_flagsTable)); + + // sets up all engine specific debug levels + Common::addSpecialDebugLevel(kDebugLevelScriptFuncs, "ScriptFuncs", "Script function debug level"); + Common::addSpecialDebugLevel(kDebugLevelScript, "Script", "Script interpreter debug level"); + Common::addSpecialDebugLevel(kDebugLevelSprites, "Sprites", "Sprite debug level"); + Common::addSpecialDebugLevel(kDebugLevelScreen, "Screen", "Screen debug level"); + Common::addSpecialDebugLevel(kDebugLevelSound, "Sound", "Sound debug level"); + Common::addSpecialDebugLevel(kDebugLevelAnimator, "Animator", "Animator debug level"); + Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level"); + Common::addSpecialDebugLevel(kDebugLevelGUI, "GUI", "GUI debug level"); + Common::addSpecialDebugLevel(kDebugLevelSequence, "Sequence", "Sequence debug level"); + Common::addSpecialDebugLevel(kDebugLevelMovie, "Movie", "Movie debug level"); + Common::addSpecialDebugLevel(kDebugLevelTimer, "Timer", "Timer debug level"); + + system->getEventManager()->registerRandomSource(_rnd, "kyra"); +} + +::GUI::Debugger *KyraEngine_v1::getDebugger() { + return _debugger; +} + +int KyraEngine_v1::init() { + registerDefaultSettings(); + + // Setup mixer + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); + + if (!_flags.useDigSound) { + // We prefer AdLib over native MIDI, since our AdLib playback code is much + // more mature than our MIDI player. For example we are missing MT-32 support + // and it seems our MIDI playback code has threading issues (see bug #1506583 + // "KYRA1: Crash on exceeded polyphony" for more information). + int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB/* | MDT_PREFER_MIDI*/); + + if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) { + // TODO: currently we don't support the PC98 sound data, + // but since it has the FM-Towns data files, we just use the + // FM-Towns driver + if (_flags.gameID == GI_KYRA1) + _sound = new SoundTowns(this, _mixer); + else + _sound = new SoundTowns_v2(this, _mixer); + } else if (midiDriver == MD_ADLIB) { + _sound = new SoundAdlibPC(this, _mixer); + assert(_sound); + } else { + bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); + + MidiDriver *driver = MidiDriver::createMidi(midiDriver); + assert(driver); + if (native_mt32) + driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); + + SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver); + _sound = soundMidiPc; + assert(_sound); + soundMidiPc->hasNativeMT32(native_mt32); + + // Unlike some SCUMM games, it's not that the MIDI sounds are + // missing. It's just that at least at the time of writing they + // are decidedly inferior to the Adlib ones. + if (ConfMan.getBool("multi_midi")) { + SoundAdlibPC *adlib = new SoundAdlibPC(this, _mixer); + assert(adlib); + + _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); + assert(_sound); + } + } + } + + if (_sound) + _sound->updateVolumeSettings(); + + _res = new Resource(this); + assert(_res); + _res->reset(); + _staticres = new StaticResource(this); + assert(_staticres); + if (!_staticres->init()) + error("_staticres->init() failed"); + if (!screen()->init()) + error("screen()->init() failed"); + _timer = new TimerManager(this, _system); + assert(_timer); + setupTimers(); + _emc = new EMCInterpreter(this); + assert(_emc); + + setupOpcodeTable(); + readSettings(); + + if (ConfMan.hasKey("save_slot")) { + _gameToLoad = ConfMan.getInt("save_slot"); + if (!saveFileLoadable(_gameToLoad)) + _gameToLoad = -1; + } + + _lang = 0; + Common::Language lang = Common::parseLanguage(ConfMan.get("language")); + + if (_flags.gameID == GI_KYRA2 || _flags.gameID == GI_KYRA3) { + switch (lang) { + case Common::EN_ANY: + case Common::EN_USA: + case Common::EN_GRB: + _lang = 0; + break; + + case Common::FR_FRA: + _lang = 1; + break; + + case Common::DE_DEU: + _lang = 2; + break; + + case Common::JA_JPN: + _lang = 3; + break; + + default: + warning("unsupported language, switching back to English"); + _lang = 0; + break; + } + } + + return 0; +} + +KyraEngine_v1::~KyraEngine_v1() { + for (Common::Array::iterator i = _opcodes.begin(); i != _opcodes.end(); ++i) + delete *i; + _opcodes.clear(); + + delete _res; + delete _staticres; + delete _sound; + delete _text; + delete _timer; + delete _emc; + delete _debugger; +} + +void KyraEngine_v1::quitGame() { + debugC(9, kDebugLevelMain, "KyraEngine_v1::quitGame()"); + _quitFlag = true; + // Nothing to do here +} + +Common::Point KyraEngine_v1::getMousePos() const { + Common::Point mouse = _eventMan->getMousePos(); + + if (_flags.useHiResOverlay) { + mouse.x >>= 1; + mouse.y >>= 1; + } + + return mouse; +} + +void KyraEngine_v1::setMousePos(int x, int y) { + if (_flags.useHiResOverlay) { + x <<= 1; + y <<= 1; + } + _system->warpMouse(x, y); +} + +int KyraEngine_v1::setGameFlag(int flag) { + _flagsTable[flag >> 3] |= (1 << (flag & 7)); + return 1; +} + +int KyraEngine_v1::queryGameFlag(int flag) const { + return ((_flagsTable[flag >> 3] >> (flag & 7)) & 1); +} + +int KyraEngine_v1::resetGameFlag(int flag) { + _flagsTable[flag >> 3] &= ~(1 << (flag & 7)); + return 0; +} + +void KyraEngine_v1::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { + while (_system->getMillis() < timestamp && !_quitFlag) { + if (timestamp - _system->getMillis() >= 10) + delay(10, update, isMainLoop); + } +} + +void KyraEngine_v1::delay(uint32 amount, bool update, bool isMainLoop) { + _system->delayMillis(amount); +} + +void KyraEngine_v1::delayWithTicks(int ticks) { + delay(ticks * _tickLength); +} + +void KyraEngine_v1::registerDefaultSettings() { + if (_flags.gameID != GI_KYRA3) + ConfMan.registerDefault("cdaudio", (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)); +} + +void KyraEngine_v1::readSettings() { + _configWalkspeed = ConfMan.getInt("walkspeed"); + _configMusic = 0; + + if (!ConfMan.getBool("music_mute")) { + _configMusic = 1; + if (_flags.gameID != GI_KYRA3 && ConfMan.getBool("cdaudio") && (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)) + _configMusic = 2; + } + _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1; + + if (_sound) { + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + } + + bool speechMute = ConfMan.getBool("speech_mute"); + bool subtitles = ConfMan.getBool("subtitles"); + + if (!speechMute && subtitles) + _configVoice = 2; // Voice & Text + else if (!speechMute && !subtitles) + _configVoice = 1; // Voice only + else + _configVoice = 0; // Text only + + setWalkspeed(_configWalkspeed); +} + +void KyraEngine_v1::writeSettings() { + bool speechMute, subtitles; + + ConfMan.setInt("walkspeed", _configWalkspeed); + ConfMan.setBool("music_mute", _configMusic == 0); + if (_flags.gameID != GI_KYRA3) + ConfMan.setBool("cdaudio", _configMusic == 2); + ConfMan.setBool("sfx_mute", _configSounds == 0); + + switch (_configVoice) { + case 0: // Text only + speechMute = true; + subtitles = true; + break; + case 1: // Voice only + speechMute = false; + subtitles = false; + break; + default: // Voice & Text + speechMute = false; + subtitles = true; + break; + } + + if (_sound) { + if (!_configMusic) + _sound->beginFadeOut(); + _sound->enableMusic(_configMusic); + _sound->enableSFX(_configSounds); + } + + ConfMan.setBool("speech_mute", speechMute); + ConfMan.setBool("subtitles", subtitles); + + ConfMan.flushToDisk(); +} + +bool KyraEngine_v1::speechEnabled() { + return _flags.isTalkie && (_configVoice == 1 || _configVoice == 2); +} + +bool KyraEngine_v1::textEnabled() { + return !_flags.isTalkie || (_configVoice == 0 || _configVoice == 2); +} + +inline int convertValueToMixer(int value) { + value -= 2; + return (value * Audio::Mixer::kMaxMixerVolume) / 95; +} + +inline int convertValueFromMixer(int value) { + return (value * 95) / Audio::Mixer::kMaxMixerVolume + 2; +} + +void KyraEngine_v1::setVolume(kVolumeEntry vol, uint8 value) { + switch (vol) { + case kVolumeMusic: + ConfMan.setInt("music_volume", convertValueToMixer(value)); + break; + + case kVolumeSfx: + ConfMan.setInt("sfx_volume", convertValueToMixer(value)); + break; + + case kVolumeSpeech: + ConfMan.setInt("speech_volume", convertValueToMixer(value)); + break; + } + + // Resetup mixer + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); + if (_sound) + _sound->updateVolumeSettings(); +} + +uint8 KyraEngine_v1::getVolume(kVolumeEntry vol) { + switch (vol) { + case kVolumeMusic: + return convertValueFromMixer(ConfMan.getInt("music_volume")); + break; + + case kVolumeSfx: + return convertValueFromMixer(ConfMan.getInt("sfx_volume")); + break; + + case kVolumeSpeech: + if (speechEnabled()) + return convertValueFromMixer(ConfMan.getInt("speech_volume")); + else + return 2; + break; + } + + return 2; +} + +} // End of namespace Kyra + diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h new file mode 100644 index 0000000000..076c6bbd54 --- /dev/null +++ b/engines/kyra/kyra_v1.h @@ -0,0 +1,272 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_KYRA_V1_H +#define KYRA_KYRA_V1_H + +#include "engines/engine.h" + +#include "common/array.h" +#include "common/events.h" + +#include "kyra/script.h" + +namespace Common { +class InSaveFile; +class OutSaveFile; +} // end of namespace Common + +class KyraMetaEngine; + +namespace Kyra { + +struct GameFlags { + Common::Language lang; + Common::Platform platform; + + bool isDemo : 1; + bool useAltShapeHeader : 1; // alternative shape header (uses 2 bytes more, those are unused though) + bool isTalkie : 1; + bool useHiResOverlay : 1; + bool useDigSound : 1; + + byte gameID; +}; + +enum { + GI_KYRA1 = 0, + GI_KYRA2 = 1, + GI_KYRA3 = 2 +}; + +struct AudioDataStruct { + const char * const *_fileList; + const int _fileListLen; + const void * const _cdaTracks; + const int _cdaNumTracks; +}; + +// TODO: this is just the start of makeing the debug output of the kyra engine a bit more useable +// in the future we maybe merge some flags and/or create new ones +enum kDebugLevels { + kDebugLevelScriptFuncs = 1 << 0, // prints debug output of o#_* functions + kDebugLevelScript = 1 << 1, // prints debug output of "EMCInterpreter" functions + kDebugLevelSprites = 1 << 2, // prints debug output of "Sprites" functions + kDebugLevelScreen = 1 << 3, // prints debug output of "Screen" functions + kDebugLevelSound = 1 << 4, // prints debug output of "Sound" functions + kDebugLevelAnimator = 1 << 5, // prints debug output of "ScreenAnimator" functions + kDebugLevelMain = 1 << 6, // prints debug output of common "KyraEngine(_v#)" functions && "TextDisplayer" functions + kDebugLevelGUI = 1 << 7, // prints debug output of "KyraEngine*" gui functions + kDebugLevelSequence = 1 << 8, // prints debug output of "SeqPlayer" functions + kDebugLevelMovie = 1 << 9, // prints debug output of movie specific funtions + kDebugLevelTimer = 1 << 10 // prints debug output of "TimerManager" functions +}; + +enum kMusicDataID { + kMusicIntro = 0, + kMusicIngame, + kMusicFinale +}; + +class Screen; +class Resource; +class Sound; +class Movie; +class TextDisplayer; +class StaticResource; +class TimerManager; +class Debugger; + +class KyraEngine_v1 : public Engine { +friend class Debugger; +friend class ::KyraMetaEngine; +friend class GUI; +public: + KyraEngine_v1(OSystem *system, const GameFlags &flags); + virtual ~KyraEngine_v1(); + + ::GUI::Debugger *getDebugger(); + + bool quit() const { return _quitFlag; } + + uint8 game() const { return _flags.gameID; } + const GameFlags &gameFlags() const { return _flags; } + + // access to Kyra specific functionallity + Resource *resource() { return _res; } + virtual Screen *screen() = 0; + virtual TextDisplayer *text() { return _text; } + Sound *sound() { return _sound; } + StaticResource *staticres() { return _staticres; } + TimerManager *timer() { return _timer; } + + uint32 tickLength() const { return _tickLength; } + + Common::RandomSource _rnd; + + // input + void setMousePos(int x, int y); + Common::Point getMousePos() const; + + // config specific + bool speechEnabled(); + bool textEnabled(); + + enum kVolumeEntry { + kVolumeMusic = 0, + kVolumeSfx = 1, + kVolumeSpeech = 2 + }; + + // volume reaches from 2 to 97 + void setVolume(kVolumeEntry vol, uint8 value); + uint8 getVolume(kVolumeEntry vol); + + // quit handling + virtual void quitGame(); + + // game flag handling + int setGameFlag(int flag); + int queryGameFlag(int flag) const; + int resetGameFlag(int flag); + + // sound + virtual void snd_playTheme(int file, int track); + virtual void snd_playSoundEffect(int id, int volume=0xFF); + virtual void snd_playWanderScoreViaMap(int command, int restart); + virtual void snd_playVoiceFile(int id) = 0; + virtual bool snd_voiceIsPlaying(); + virtual void snd_stopVoice(); + + // delay functionallity + virtual void delayUntil(uint32 timestamp, bool updateGameTimers = false, bool update = false, bool isMainLoop = false); + virtual void delay(uint32 millis, bool update = false, bool isMainLoop = false); + virtual void delayWithTicks(int ticks); + +protected: + virtual int go() = 0; + virtual int init(); + + // quit Handling + bool _quitFlag; + + // intern + Resource *_res; + Sound *_sound; + TextDisplayer *_text; + StaticResource *_staticres; + TimerManager *_timer; + EMCInterpreter *_emc; + Debugger *_debugger; + + // config specific + virtual void registerDefaultSettings(); + virtual void readSettings(); + virtual void writeSettings(); + + uint8 _configWalkspeed; + + int _configMusic; + bool _configSounds; + uint8 _configVoice; + + // game speed + virtual bool skipFlag() const = 0; + virtual void resetSkipFlag(bool removeEvent = true) = 0; + + uint16 _tickLength; + uint16 _gameSpeed; + + // timer + virtual void setupTimers() = 0; + + virtual void setWalkspeed(uint8 speed) = 0; + + // detection + GameFlags _flags; + int _lang; + + // opcode + virtual void setupOpcodeTable() = 0; + Common::Array _opcodes; + + // game flags + uint8 _flagsTable[100]; // TODO: check this value + + // sound + Common::String _speechFile; + + int _curMusicTheme; + int _curSfxFile; + int16 _lastMusicCommand; + + const int8 *_trackMap; + int _trackMapSize; + + // pathfinder + virtual int findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize); + int findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end); + int getFacingFromPointToPoint(int x, int y, int toX, int toY); + int getOppositeFacingDirection(int dir); + void changePosTowardsFacing(int &x, int &y, int facing); + int getMoveTableSize(int *moveTable); + virtual bool lineIsPassable(int x, int y) = 0; + + static const int8 _addXPosTable[]; + static const int8 _addYPosTable[]; + + // save/load + int _gameToLoad; + + const char *getSavegameFilename(int num); + bool saveFileLoadable(int slot); + + struct SaveHeader { + Common::String description; + uint32 version; + byte gameID; + uint32 flags; + + bool originalSave; // savegame from original interpreter + bool oldHeader; // old scummvm save header + }; + + enum kReadSaveHeaderError { + kRSHENoError = 0, + kRSHEInvalidType = 1, + kRSHEInvalidVersion = 2, + kRSHEIoError = 3 + }; + + static kReadSaveHeaderError readSaveHeader(Common::InSaveFile *file, SaveHeader &header); + + Common::InSaveFile *openSaveForReading(const char *filename, SaveHeader &header); + Common::OutSaveFile *openSaveForWriting(const char *filename, const char *saveName) const; +}; + +} // End of namespace Kyra + +#endif + diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 1e1a30dec8..b2c44981ec 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -29,7 +29,7 @@ namespace Kyra { -KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc) : KyraEngine(system, flags), _desc(desc) { +KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc) : KyraEngine_v1(system, flags), _desc(desc) { memset(&_sceneAnims, 0, sizeof(_sceneAnims)); memset(&_sceneAnimMovie, 0, sizeof(_sceneAnimMovie)); diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index 484e044ac7..f487799744 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -26,7 +26,7 @@ #ifndef KYRA_KYRA_V2_H #define KYRA_KYRA_V2_H -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/gui.h" #include "kyra/wsamovie.h" @@ -53,7 +53,7 @@ struct ActiveItemAnim { class Screen_v2; -class KyraEngine_v2 : public KyraEngine { +class KyraEngine_v2 : public KyraEngine_v1 { friend class Debugger_v2; friend class GUI_v2; public: diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 2a0e2adf41..b027459613 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -16,7 +16,7 @@ MODULE_OBJS := \ items_v2.o \ items_hof.o \ items_mr.o \ - kyra.o \ + kyra_v1.o \ kyra_lok.o \ kyra_v2.o \ kyra_hof.o \ @@ -26,7 +26,7 @@ MODULE_OBJS := \ saveload_lok.o \ saveload_hof.o \ saveload_mr.o \ - scene.o \ + scene_v1.o \ scene_lok.o \ scene_v2.o \ scene_hof.o \ diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index b2564221fc..58756ca430 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -36,7 +36,7 @@ namespace Kyra { -Resource::Resource(KyraEngine *vm) : _loaders(), _map(), _vm(vm) { +Resource::Resource(KyraEngine_v1 *vm) : _loaders(), _map(), _vm(vm) { initializeLoaders(); } diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index f414cacee8..843b0b423d 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -36,7 +36,7 @@ #include "common/stream.h" #include "common/ptr.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_hof.h" namespace Kyra { @@ -88,7 +88,7 @@ protected: class Resource { public: - Resource(KyraEngine *vm); + Resource(KyraEngine_v1 *vm); ~Resource(); bool reset(); @@ -122,7 +122,7 @@ protected: LoaderList _loaders; ResFileMap _map; - KyraEngine *_vm; + KyraEngine_v1 *_vm; }; // TODO?: maybe prefix all things here with 'kKyra1' instead of 'k' @@ -239,7 +239,7 @@ class StaticResource { public: static const Common::String staticDataFilename() { return "kyra.dat"; } - StaticResource(KyraEngine *vm) : _vm(vm), _resList(), _fileLoader(0), _builtIn(0), _filenameTable(0) {} + StaticResource(KyraEngine_v1 *vm) : _vm(vm), _resList(), _fileLoader(0), _builtIn(0), _filenameTable(0) {} ~StaticResource() { deinit(); } static bool checkKyraDat(); @@ -265,7 +265,7 @@ public: private: void outputError(); - KyraEngine *_vm; + KyraEngine_v1 *_vm; struct FilenameTable; struct ResData; diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index 590d40f2e3..22f934ba69 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -27,7 +27,7 @@ #include "common/savefile.h" #include "common/system.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #define CURRENT_SAVE_VERSION 13 @@ -37,7 +37,7 @@ namespace Kyra { -KyraEngine::kReadSaveHeaderError KyraEngine::readSaveHeader(Common::InSaveFile *in, SaveHeader &header) { +KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::InSaveFile *in, SaveHeader &header) { uint32 type = in->readUint32BE(); header.originalSave = false; header.oldHeader = false; @@ -108,14 +108,14 @@ KyraEngine::kReadSaveHeaderError KyraEngine::readSaveHeader(Common::InSaveFile * return (in->ioFailed() ? kRSHEIoError : kRSHENoError); } -Common::InSaveFile *KyraEngine::openSaveForReading(const char *filename, SaveHeader &header) { - debugC(9, kDebugLevelMain, "KyraEngine::openSaveForReading('%s', -)", filename); +Common::InSaveFile *KyraEngine_v1::openSaveForReading(const char *filename, SaveHeader &header) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::openSaveForReading('%s', -)", filename); Common::InSaveFile *in = 0; if (!(in = _saveFileMan->openForLoading(filename))) return 0; - kReadSaveHeaderError errorCode = KyraEngine::readSaveHeader(in, header); + kReadSaveHeaderError errorCode = KyraEngine_v1::readSaveHeader(in, header); if (errorCode != kRSHENoError) { if (errorCode == kRSHEInvalidType) warning("No ScummVM Kyra engine savefile header."); @@ -159,8 +159,8 @@ Common::InSaveFile *KyraEngine::openSaveForReading(const char *filename, SaveHea return in; } -Common::OutSaveFile *KyraEngine::openSaveForWriting(const char *filename, const char *saveName) const { - debugC(9, kDebugLevelMain, "KyraEngine::openSaveForWriting('%s', '%s')", filename, saveName); +Common::OutSaveFile *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName) const { + debugC(9, kDebugLevelMain, "KyraEngine_v1::openSaveForWriting('%s', '%s')", filename, saveName); if (_quitFlag) return 0; @@ -191,7 +191,7 @@ Common::OutSaveFile *KyraEngine::openSaveForWriting(const char *filename, const return out; } -const char *KyraEngine::getSavegameFilename(int num) { +const char *KyraEngine_v1::getSavegameFilename(int num) { static Common::String filename; assert(num >= 0 && num <= 999); @@ -204,7 +204,7 @@ const char *KyraEngine::getSavegameFilename(int num) { return filename.c_str(); } -bool KyraEngine::saveFileLoadable(int slot) { +bool KyraEngine_v1::saveFileLoadable(int slot) { if (slot < 0 || slot > 999) return false; diff --git a/engines/kyra/scene.cpp b/engines/kyra/scene.cpp deleted file mode 100644 index e96a44cb2e..0000000000 --- a/engines/kyra/scene.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* 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. - * - * $URL$ - * $Id$ - * - */ - -#include "kyra/kyra.h" -#include "kyra/screen.h" - -namespace Kyra { - -int KyraEngine::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { - debugC(9, kDebugLevelMain, "KyraEngine::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); - x &= 0xFFFC; toX &= 0xFFFC; - y &= 0xFFFE; toY &= 0xFFFE; - x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; - - if (x == toY && y == toY) { - moveTable[0] = 8; - return 0; - } - - int curX = x; - int curY = y; - int tempValue = 0; - int lastUsedEntry = 0; - int *pathTable1 = new int[0x7D0]; - int *pathTable2 = new int[0x7D0]; - assert(pathTable1 && pathTable2); - - while (true) { - int newFacing = getFacingFromPointToPoint(x, y, toX, toY); - changePosTowardsFacing(curX, curY, newFacing); - - if (curX == toX && curY == toY) { - if (!lineIsPassable(curX, curY)) - break; - moveTable[lastUsedEntry++] = newFacing; - break; - } - - if (lineIsPassable(curX, curY)) { - if (lastUsedEntry == moveTableSize) { - delete[] pathTable1; - delete[] pathTable2; - return 0x7D00; - } - // debug drawing - /*if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { - screen()->setPagePixel(0, curX, curY, 11); - screen()->updateScreen(); - delayWithTicks(5); - }*/ - moveTable[lastUsedEntry++] = newFacing; - x = curX; - y = curY; - continue; - } - - int temp = 0; - while (true) { - newFacing = getFacingFromPointToPoint(curX, curY, toX, toY); - changePosTowardsFacing(curX, curY, newFacing); - // debug drawing - /*if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { - screen()->setPagePixel(0, curX, curY, 8); - screen()->updateScreen(); - delayWithTicks(5); - }*/ - - if (!lineIsPassable(curX, curY)) { - if (curX != toX || curY != toY) - continue; - } - - if (curX == toX && curY == toY) { - if (!lineIsPassable(curX, curY)) { - tempValue = 0; - temp = 0; - break; - } - } - - temp = findSubPath(x, y, curX, curY, pathTable1, 1, 0x7D0); - tempValue = findSubPath(x, y, curX, curY, pathTable2, 0, 0x7D0); - if (curX == toX && curY == toY) { - if (temp == 0x7D00 && tempValue == 0x7D00) { - delete[] pathTable1; - delete[] pathTable2; - return 0x7D00; - } - } - - if (temp != 0x7D00 || tempValue != 0x7D00) - break; - } - - if (temp < tempValue) { - if (lastUsedEntry + temp > moveTableSize) { - delete[] pathTable1; - delete[] pathTable2; - return 0x7D00; - } - memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int)); - lastUsedEntry += temp; - } else { - if (lastUsedEntry + tempValue > moveTableSize) { - delete[] pathTable1; - delete[] pathTable2; - return 0x7D00; - } - memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int)); - lastUsedEntry += tempValue; - } - x = curX; - y = curY; - if (curX == toX && curY == toY) - break; - } - - delete[] pathTable1; - delete[] pathTable2; - moveTable[lastUsedEntry] = 8; - return lastUsedEntry; -} - -int KyraEngine::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { - debugC(9, kDebugLevelMain, "KyraEngine::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); - // only used for debug specific code - //static uint16 unkTable[] = { 8, 5 }; - static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; - static const int8 facingTable2[] = { -1, 0, -1, 2, -1, 4, -1, 6, -1, 2, -1, 4, -1, 6, -1, 0 }; - static const int8 facingTable3[] = { 2, 4, 4, 6, 6, 0, 0, 2, 6, 6, 0, 0, 2, 2, 4, 4 }; - static const int8 addPosTableX[] = { -1, 0, -1, 4, -1, 0, -1, -4, -1, -4, -1, 0, -1, 4, -1, 0 }; - static const int8 addPosTableY[] = { -1, 2, -1, 0, -1, -2, -1, 0, -1, 0, -1, 2, -1, 0, -1, -2 }; - - // debug specific - /*++unkTable[start]; - while (screen()->getPalette(0)[unkTable[start]] != 0x0F) { - ++unkTable[start]; - }*/ - - int xpos1 = x, xpos2 = x; - int ypos1 = y, ypos2 = y; - int newFacing = getFacingFromPointToPoint(x, y, toX, toY); - int position = 0; - - while (position != end) { - int newFacing2 = newFacing; - while (true) { - changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]); - if (!lineIsPassable(xpos1, ypos1)) { - if (facingTable1[start*8 + newFacing2] == newFacing) - return 0x7D00; - newFacing2 = facingTable1[start*8 + newFacing2]; - xpos1 = x; - ypos1 = y; - continue; - } - newFacing = facingTable1[start*8 + newFacing2]; - break; - } - // debug drawing - /*if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) { - screen()->setPagePixel(0, xpos1, ypos1, unkTable[start]); - screen()->updateScreen(); - delayWithTicks(5); - }*/ - if (newFacing & 1) { - int temp = xpos1 + addPosTableX[newFacing + start * 8]; - if (toX == temp) { - temp = ypos1 + addPosTableY[newFacing + start * 8]; - if (toY == temp) { - moveTable[position++] = facingTable2[newFacing + start * 8]; - return position; - } - } - } - - moveTable[position++] = newFacing; - x = xpos1; - y = ypos1; - - if (x == toX && y == toY) - return position; - - if (xpos1 == xpos2 && ypos1 == ypos2) - break; - - newFacing = facingTable3[start*8 + newFacing]; - } - - return 0x7D00; -} - -int KyraEngine::getFacingFromPointToPoint(int x, int y, int toX, int toY) { - debugC(9, kDebugLevelMain, "KyraEngine::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); - static const int facingTable[] = { - 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 - }; - - int facingEntry = 0; - int ydiff = y - toY; - if (ydiff < 0) { - ++facingEntry; - ydiff = -ydiff; - } - facingEntry <<= 1; - - int xdiff = toX - x; - if (xdiff < 0) { - ++facingEntry; - xdiff = -xdiff; - } - - if (xdiff >= ydiff) { - int temp = ydiff; - ydiff = xdiff; - xdiff = temp; - - facingEntry <<= 1; - } else { - facingEntry <<= 1; - facingEntry += 1; - } - int temp = (ydiff + 1) >> 1; - - if (xdiff < temp) { - facingEntry <<= 1; - facingEntry += 1; - } else { - facingEntry <<= 1; - } - - assert(facingEntry < ARRAYSIZE(facingTable)); - return facingTable[facingEntry]; -} - - -int KyraEngine::getOppositeFacingDirection(int dir) { - debugC(9, kDebugLevelMain, "KyraEngine::getOppositeFacingDirection(%d)", dir); - switch (dir) { - case 0: - return 2; - case 1: - return 1; - case 3: - return 7; - case 4: - return 6; - case 5: - return 5; - case 6: - return 4; - case 7: - return 3; - default: - break; - } - return 0; -} - -void KyraEngine::changePosTowardsFacing(int &x, int &y, int facing) { - debugC(9, kDebugLevelMain, "KyraEngine::changePosTowardsFacing(%d, %d, %d)", x, y, facing); - x += _addXPosTable[facing]; - y += _addYPosTable[facing]; -} - -int KyraEngine::getMoveTableSize(int *moveTable) { - debugC(9, kDebugLevelMain, "KyraEngine::getMoveTableSize(%p)", (const void *)moveTable); - int retValue = 0; - if (moveTable[0] == 8) - return 0; - - static const int facingTable[] = { - 4, 5, 6, 7, 0, 1, 2, 3 - }; - static const int unkTable[] = { - -1, -1, 1, 2, -1, 6, 7, -1, - -1, -1, -1, -1, 2, -1, 0, -1, - 1, -1, -1, -1, 3, 4, -1, 0, - 2, -1, -1, -1, -1, -1, 4, -1, - -1, 2, 3, -1, -1, -1, 5, 6, - 6, -1, 4, -1, -1, -1, -1, -1, - 7, 0, -1, 4, 5, -1, -1, -1, - -1, -1, 0, -1, 6, -1, -1, -1 - }; - - int *oldPosition = moveTable; - int *tempPosition = moveTable; - int *curPosition = moveTable + 1; - retValue = 1; - - while (*curPosition != 8) { - if (*oldPosition == facingTable[*curPosition]) { - retValue -= 2; - *oldPosition = 9; - *curPosition = 9; - - while (tempPosition != moveTable) { - --tempPosition; - if (*tempPosition != 9) - break; - } - - if (tempPosition == moveTable && *tempPosition == 9) { - while (*tempPosition != 8 && *tempPosition == 9) - ++tempPosition; - - if (*tempPosition == 8) - return 0; - } - - oldPosition = tempPosition; - curPosition = oldPosition+1; - - while (*curPosition != 8 && *curPosition == 9) - ++curPosition; - - continue; - } - - if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { - --retValue; - *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; - *curPosition = 9; - - if (tempPosition != oldPosition) { - curPosition = oldPosition; - oldPosition = tempPosition; - while (true) { - if (tempPosition == moveTable) - break; - - --tempPosition; - if (*tempPosition != 9) - break; - - } - } else { - while (true) { - ++curPosition; - if (*curPosition != 9) - break; - } - } - continue; - } - - tempPosition = oldPosition; - oldPosition = curPosition; - ++retValue; - - while (true) { - ++curPosition; - if (*curPosition != 9) - break; - } - } - - return retValue; -} - -} // end of namespace Kyra diff --git a/engines/kyra/scene_lok.cpp b/engines/kyra/scene_lok.cpp index 36535eba60..085332b525 100644 --- a/engines/kyra/scene_lok.cpp +++ b/engines/kyra/scene_lok.cpp @@ -1166,7 +1166,7 @@ void KyraEngine_LoK::setCharactersPositions(int character) { int KyraEngine_LoK::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { debugC(9, kDebugLevelMain, "KyraEngine_LoK::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); - int ret = KyraEngine::findWay(x, y, toX, toY, moveTable, moveTableSize); + int ret = KyraEngine_v1::findWay(x, y, toX, toY, moveTable, moveTableSize); if (ret == 0x7D00) return 0; return getMoveTableSize(moveTable); diff --git a/engines/kyra/scene_v1.cpp b/engines/kyra/scene_v1.cpp new file mode 100644 index 0000000000..65171ad831 --- /dev/null +++ b/engines/kyra/scene_v1.cpp @@ -0,0 +1,383 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/kyra_v1.h" +#include "kyra/screen.h" + +namespace Kyra { + +int KyraEngine_v1::findWay(int x, int y, int toX, int toY, int *moveTable, int moveTableSize) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); + x &= 0xFFFC; toX &= 0xFFFC; + y &= 0xFFFE; toY &= 0xFFFE; + x = (int16)x; y = (int16)y; toX = (int16)toX; toY = (int16)toY; + + if (x == toY && y == toY) { + moveTable[0] = 8; + return 0; + } + + int curX = x; + int curY = y; + int tempValue = 0; + int lastUsedEntry = 0; + int *pathTable1 = new int[0x7D0]; + int *pathTable2 = new int[0x7D0]; + assert(pathTable1 && pathTable2); + + while (true) { + int newFacing = getFacingFromPointToPoint(x, y, toX, toY); + changePosTowardsFacing(curX, curY, newFacing); + + if (curX == toX && curY == toY) { + if (!lineIsPassable(curX, curY)) + break; + moveTable[lastUsedEntry++] = newFacing; + break; + } + + if (lineIsPassable(curX, curY)) { + if (lastUsedEntry == moveTableSize) { + delete[] pathTable1; + delete[] pathTable2; + return 0x7D00; + } + // debug drawing + /*if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { + screen()->setPagePixel(0, curX, curY, 11); + screen()->updateScreen(); + delayWithTicks(5); + }*/ + moveTable[lastUsedEntry++] = newFacing; + x = curX; + y = curY; + continue; + } + + int temp = 0; + while (true) { + newFacing = getFacingFromPointToPoint(curX, curY, toX, toY); + changePosTowardsFacing(curX, curY, newFacing); + // debug drawing + /*if (curX >= 0 && curY >= 0 && curX < 320 && curY < 200) { + screen()->setPagePixel(0, curX, curY, 8); + screen()->updateScreen(); + delayWithTicks(5); + }*/ + + if (!lineIsPassable(curX, curY)) { + if (curX != toX || curY != toY) + continue; + } + + if (curX == toX && curY == toY) { + if (!lineIsPassable(curX, curY)) { + tempValue = 0; + temp = 0; + break; + } + } + + temp = findSubPath(x, y, curX, curY, pathTable1, 1, 0x7D0); + tempValue = findSubPath(x, y, curX, curY, pathTable2, 0, 0x7D0); + if (curX == toX && curY == toY) { + if (temp == 0x7D00 && tempValue == 0x7D00) { + delete[] pathTable1; + delete[] pathTable2; + return 0x7D00; + } + } + + if (temp != 0x7D00 || tempValue != 0x7D00) + break; + } + + if (temp < tempValue) { + if (lastUsedEntry + temp > moveTableSize) { + delete[] pathTable1; + delete[] pathTable2; + return 0x7D00; + } + memcpy(&moveTable[lastUsedEntry], pathTable1, temp*sizeof(int)); + lastUsedEntry += temp; + } else { + if (lastUsedEntry + tempValue > moveTableSize) { + delete[] pathTable1; + delete[] pathTable2; + return 0x7D00; + } + memcpy(&moveTable[lastUsedEntry], pathTable2, tempValue*sizeof(int)); + lastUsedEntry += tempValue; + } + x = curX; + y = curY; + if (curX == toX && curY == toY) + break; + } + + delete[] pathTable1; + delete[] pathTable2; + moveTable[lastUsedEntry] = 8; + return lastUsedEntry; +} + +int KyraEngine_v1::findSubPath(int x, int y, int toX, int toY, int *moveTable, int start, int end) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::findSubPath(%d, %d, %d, %d, %p, %d, %d)", x, y, toX, toY, (const void *)moveTable, start, end); + // only used for debug specific code + //static uint16 unkTable[] = { 8, 5 }; + static const int8 facingTable1[] = { 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0 }; + static const int8 facingTable2[] = { -1, 0, -1, 2, -1, 4, -1, 6, -1, 2, -1, 4, -1, 6, -1, 0 }; + static const int8 facingTable3[] = { 2, 4, 4, 6, 6, 0, 0, 2, 6, 6, 0, 0, 2, 2, 4, 4 }; + static const int8 addPosTableX[] = { -1, 0, -1, 4, -1, 0, -1, -4, -1, -4, -1, 0, -1, 4, -1, 0 }; + static const int8 addPosTableY[] = { -1, 2, -1, 0, -1, -2, -1, 0, -1, 0, -1, 2, -1, 0, -1, -2 }; + + // debug specific + /*++unkTable[start]; + while (screen()->getPalette(0)[unkTable[start]] != 0x0F) { + ++unkTable[start]; + }*/ + + int xpos1 = x, xpos2 = x; + int ypos1 = y, ypos2 = y; + int newFacing = getFacingFromPointToPoint(x, y, toX, toY); + int position = 0; + + while (position != end) { + int newFacing2 = newFacing; + while (true) { + changePosTowardsFacing(xpos1, ypos1, facingTable1[start*8 + newFacing2]); + if (!lineIsPassable(xpos1, ypos1)) { + if (facingTable1[start*8 + newFacing2] == newFacing) + return 0x7D00; + newFacing2 = facingTable1[start*8 + newFacing2]; + xpos1 = x; + ypos1 = y; + continue; + } + newFacing = facingTable1[start*8 + newFacing2]; + break; + } + // debug drawing + /*if (xpos1 >= 0 && ypos1 >= 0 && xpos1 < 320 && ypos1 < 200) { + screen()->setPagePixel(0, xpos1, ypos1, unkTable[start]); + screen()->updateScreen(); + delayWithTicks(5); + }*/ + if (newFacing & 1) { + int temp = xpos1 + addPosTableX[newFacing + start * 8]; + if (toX == temp) { + temp = ypos1 + addPosTableY[newFacing + start * 8]; + if (toY == temp) { + moveTable[position++] = facingTable2[newFacing + start * 8]; + return position; + } + } + } + + moveTable[position++] = newFacing; + x = xpos1; + y = ypos1; + + if (x == toX && y == toY) + return position; + + if (xpos1 == xpos2 && ypos1 == ypos2) + break; + + newFacing = facingTable3[start*8 + newFacing]; + } + + return 0x7D00; +} + +int KyraEngine_v1::getFacingFromPointToPoint(int x, int y, int toX, int toY) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getFacingFromPointToPoint(%d, %d, %d, %d)", x, y, toX, toY); + static const int facingTable[] = { + 1, 0, 1, 2, 3, 4, 3, 2, 7, 0, 7, 6, 5, 4, 5, 6 + }; + + int facingEntry = 0; + int ydiff = y - toY; + if (ydiff < 0) { + ++facingEntry; + ydiff = -ydiff; + } + facingEntry <<= 1; + + int xdiff = toX - x; + if (xdiff < 0) { + ++facingEntry; + xdiff = -xdiff; + } + + if (xdiff >= ydiff) { + int temp = ydiff; + ydiff = xdiff; + xdiff = temp; + + facingEntry <<= 1; + } else { + facingEntry <<= 1; + facingEntry += 1; + } + int temp = (ydiff + 1) >> 1; + + if (xdiff < temp) { + facingEntry <<= 1; + facingEntry += 1; + } else { + facingEntry <<= 1; + } + + assert(facingEntry < ARRAYSIZE(facingTable)); + return facingTable[facingEntry]; +} + + +int KyraEngine_v1::getOppositeFacingDirection(int dir) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getOppositeFacingDirection(%d)", dir); + switch (dir) { + case 0: + return 2; + case 1: + return 1; + case 3: + return 7; + case 4: + return 6; + case 5: + return 5; + case 6: + return 4; + case 7: + return 3; + default: + break; + } + return 0; +} + +void KyraEngine_v1::changePosTowardsFacing(int &x, int &y, int facing) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::changePosTowardsFacing(%d, %d, %d)", x, y, facing); + x += _addXPosTable[facing]; + y += _addYPosTable[facing]; +} + +int KyraEngine_v1::getMoveTableSize(int *moveTable) { + debugC(9, kDebugLevelMain, "KyraEngine_v1::getMoveTableSize(%p)", (const void *)moveTable); + int retValue = 0; + if (moveTable[0] == 8) + return 0; + + static const int facingTable[] = { + 4, 5, 6, 7, 0, 1, 2, 3 + }; + static const int unkTable[] = { + -1, -1, 1, 2, -1, 6, 7, -1, + -1, -1, -1, -1, 2, -1, 0, -1, + 1, -1, -1, -1, 3, 4, -1, 0, + 2, -1, -1, -1, -1, -1, 4, -1, + -1, 2, 3, -1, -1, -1, 5, 6, + 6, -1, 4, -1, -1, -1, -1, -1, + 7, 0, -1, 4, 5, -1, -1, -1, + -1, -1, 0, -1, 6, -1, -1, -1 + }; + + int *oldPosition = moveTable; + int *tempPosition = moveTable; + int *curPosition = moveTable + 1; + retValue = 1; + + while (*curPosition != 8) { + if (*oldPosition == facingTable[*curPosition]) { + retValue -= 2; + *oldPosition = 9; + *curPosition = 9; + + while (tempPosition != moveTable) { + --tempPosition; + if (*tempPosition != 9) + break; + } + + if (tempPosition == moveTable && *tempPosition == 9) { + while (*tempPosition != 8 && *tempPosition == 9) + ++tempPosition; + + if (*tempPosition == 8) + return 0; + } + + oldPosition = tempPosition; + curPosition = oldPosition+1; + + while (*curPosition != 8 && *curPosition == 9) + ++curPosition; + + continue; + } + + if (unkTable[*curPosition+((*oldPosition)*8)] != -1) { + --retValue; + *oldPosition = unkTable[*curPosition+((*oldPosition)*8)]; + *curPosition = 9; + + if (tempPosition != oldPosition) { + curPosition = oldPosition; + oldPosition = tempPosition; + while (true) { + if (tempPosition == moveTable) + break; + + --tempPosition; + if (*tempPosition != 9) + break; + + } + } else { + while (true) { + ++curPosition; + if (*curPosition != 9) + break; + } + } + continue; + } + + tempPosition = oldPosition; + oldPosition = curPosition; + ++retValue; + + while (true) { + ++curPosition; + if (*curPosition != 9) + break; + } + } + + return retValue; +} + +} // end of namespace Kyra diff --git a/engines/kyra/scene_v2.cpp b/engines/kyra/scene_v2.cpp index 5d811bcf44..7072cfc9a5 100644 --- a/engines/kyra/scene_v2.cpp +++ b/engines/kyra/scene_v2.cpp @@ -90,7 +90,7 @@ int KyraEngine_v2::findWay(int x, int y, int toX, int toY, int *moveTable, int m debugC(9, kDebugLevelMain, "KyraEngine_v2::findWay(%d, %d, %d, %d, %p, %d)", x, y, toX, toY, (const void *)moveTable, moveTableSize); x &= ~3; toX &= ~3; y &= ~1; toY &= ~1; - int size = KyraEngine::findWay(x, y, toX, toY, moveTable, moveTableSize); + int size = KyraEngine_v1::findWay(x, y, toX, toY, moveTable, moveTableSize); static bool usePostProcess = false; if (size && !usePostProcess) { usePostProcess = true; diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 568befac1e..6e250f292a 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -28,12 +28,12 @@ #include "common/system.h" #include "graphics/cursorman.h" #include "kyra/screen.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/resource.h" namespace Kyra { -Screen::Screen(KyraEngine *vm, OSystem *system) +Screen::Screen(KyraEngine_v1 *vm, OSystem *system) : _system(system), _vm(vm), _sjisInvisibleColor(0) { _debugEnabled = false; } @@ -2644,7 +2644,7 @@ void Screen::shakeScreen(int times) { } void Screen::loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *palData, bool skip) { - debugC(9, kDebugLevelScreen, "KyraEngine::loadBitmap('%s', %d, %d, %p, %d)", filename, tempPage, dstPage, (void *)palData, skip); + debugC(9, kDebugLevelScreen, "KyraEngine_v1::loadBitmap('%s', %d, %d, %p, %d)", filename, tempPage, dstPage, (void *)palData, skip); uint32 fileSize; uint8 *srcData = _vm->resource()->fileData(filename, &fileSize); diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index bf23747daf..f8c85a2bac 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -35,7 +35,7 @@ namespace Kyra { typedef Common::Functor0 UpdateFunctor; -class KyraEngine; +class KyraEngine_v1; struct Rect { int x, y; @@ -96,7 +96,7 @@ public: FID_NUM }; - Screen(KyraEngine *vm, OSystem *system); + Screen(KyraEngine_v1 *vm, OSystem *system); virtual ~Screen(); // init @@ -301,7 +301,7 @@ protected: void addDirtyRect(int x, int y, int w, int h); OSystem *_system; - KyraEngine *_vm; + KyraEngine_v1 *_vm; // shape int drawShapeMarginNoScaleUpwind(uint8 *&dst, const uint8 *&src, int &cnt); diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 13186b0167..e26ef87bad 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -29,7 +29,7 @@ namespace Kyra { -Screen_v2::Screen_v2(KyraEngine *vm, OSystem *system) : Screen(vm, system), _wsaFrameAnimBuffer(0) { +Screen_v2::Screen_v2(KyraEngine_v1 *vm, OSystem *system) : Screen(vm, system), _wsaFrameAnimBuffer(0) { _wsaFrameAnimBuffer = new uint8[1024]; assert(_wsaFrameAnimBuffer); } diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h index caec6af992..f624228445 100644 --- a/engines/kyra/screen_v2.h +++ b/engines/kyra/screen_v2.h @@ -33,7 +33,7 @@ namespace Kyra { class Screen_v2 : public Screen { public: - Screen_v2(KyraEngine *vm, OSystem *system); + Screen_v2(KyraEngine_v1 *vm, OSystem *system); ~Screen_v2(); // screen page handling diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index e00ac6878d..ef3e259cfa 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -28,12 +28,12 @@ #include "common/stream.h" #include "common/util.h" #include "common/system.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/resource.h" #include "kyra/script.h" namespace Kyra { -EMCInterpreter::EMCInterpreter(KyraEngine *vm) : _vm(vm) { +EMCInterpreter::EMCInterpreter(KyraEngine_v1 *vm) : _vm(vm) { #define COMMAND(x) { &EMCInterpreter::x, #x } static CommandEntry commandProcs[] = { // 0x00 diff --git a/engines/kyra/script.h b/engines/kyra/script.h index df86ec79c3..de52093f66 100644 --- a/engines/kyra/script.h +++ b/engines/kyra/script.h @@ -27,6 +27,7 @@ #define KYRA_SCRIPT_H #include "common/stream.h" +#include "common/array.h" #include "common/func.h" namespace Kyra { @@ -63,7 +64,7 @@ struct EMCState { #define AVTL_CHUNK 0x4C545641 class Resource; -class KyraEngine; +class KyraEngine_v1; class ScriptFileParser { public: @@ -89,7 +90,7 @@ private: class EMCInterpreter { public: - EMCInterpreter(KyraEngine *vm); + EMCInterpreter(KyraEngine_v1 *vm); bool load(const char *filename, EMCData *data, const Common::Array *opcodes); void unload(EMCData *data); @@ -101,7 +102,7 @@ public: bool run(EMCState *script); protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; int16 _parameter; typedef void (EMCInterpreter::*CommandProc)(EMCState*); diff --git a/engines/kyra/script_tim.cpp b/engines/kyra/script_tim.cpp index fa9d54e8be..66390047b4 100644 --- a/engines/kyra/script_tim.cpp +++ b/engines/kyra/script_tim.cpp @@ -31,7 +31,7 @@ namespace Kyra { -TIMInterpreter::TIMInterpreter(KyraEngine *vm, OSystem *system) : _vm(vm), _system(system), _currentTim(0) { +TIMInterpreter::TIMInterpreter(KyraEngine_v1 *vm, OSystem *system) : _vm(vm), _system(system), _currentTim(0) { #define COMMAND(x) { &TIMInterpreter::x, #x } #define COMMAND_UNIMPL() { 0, 0 } static CommandEntry commandProcs[] = { diff --git a/engines/kyra/script_tim.h b/engines/kyra/script_tim.h index 2ffbf89d65..957bffcc3c 100644 --- a/engines/kyra/script_tim.h +++ b/engines/kyra/script_tim.h @@ -26,7 +26,7 @@ #ifndef KYRA_SCRIPT_TIM_H #define KYRA_SCRIPT_TIM_H -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "common/array.h" #include "common/func.h" @@ -57,7 +57,7 @@ struct TIM { class TIMInterpreter { public: - TIMInterpreter(KyraEngine *vm, OSystem *system); + TIMInterpreter(KyraEngine_v1 *vm, OSystem *system); TIM *load(const char *filename, const Common::Array *opcodes); void unload(TIM *&tim) const; @@ -70,7 +70,7 @@ public: void play(const char *filename); private: - KyraEngine *_vm; + KyraEngine_v1 *_vm; OSystem *_system; TIM *_currentTim; diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp index fc0959f444..d34014ef33 100644 --- a/engines/kyra/sequences_hof.cpp +++ b/engines/kyra/sequences_hof.cpp @@ -23,7 +23,7 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_hof.h" #include "kyra/screen.h" #include "kyra/wsamovie.h" diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 90cbd5e539..a8566a7309 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -40,7 +40,7 @@ namespace Kyra { -Sound::Sound(KyraEngine *vm, Audio::Mixer *mixer) +Sound::Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _soundChannels(), _musicEnabled(1), _sfxEnabled(true), _soundDataList(0) { } @@ -145,7 +145,7 @@ bool Sound::voiceIsPlaying(const char *file) { #pragma mark - -SoundMidiPC::SoundMidiPC(KyraEngine *vm, Audio::Mixer *mixer, MidiDriver *driver) : Sound(vm, mixer) { +SoundMidiPC::SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *driver) : Sound(vm, mixer) { _driver = driver; _passThrough = false; @@ -467,8 +467,8 @@ void SoundMidiPC::beginFadeOut() { #pragma mark - -void KyraEngine::snd_playTheme(int file, int track) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playTheme(%d, %d)", file, track); +void KyraEngine_v1::snd_playTheme(int file, int track) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playTheme(%d, %d)", file, track); if (_curMusicTheme == file) return; @@ -478,13 +478,13 @@ void KyraEngine::snd_playTheme(int file, int track) { _sound->playTrack(track); } -void KyraEngine::snd_playSoundEffect(int track, int volume) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playSoundEffect(%d, %d)", track, volume); +void KyraEngine_v1::snd_playSoundEffect(int track, int volume) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playSoundEffect(%d, %d)", track, volume); _sound->playSoundEffect(track); } -void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playWanderScoreViaMap(%d, %d)", command, restart); +void KyraEngine_v1::snd_playWanderScoreViaMap(int command, int restart) { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_playWanderScoreViaMap(%d, %d)", command, restart); if (restart) _lastMusicCommand = -1; @@ -527,13 +527,13 @@ void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) { _lastMusicCommand = command; } -void KyraEngine::snd_stopVoice() { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_stopVoice()"); +void KyraEngine_v1::snd_stopVoice() { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_stopVoice()"); _sound->voiceStop(_speechFile.empty() ? 0 : _speechFile.c_str()); } -bool KyraEngine::snd_voiceIsPlaying() { - debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_voiceIsPlaying()"); +bool KyraEngine_v1::snd_voiceIsPlaying() { + debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine_v1::snd_voiceIsPlaying()"); return _sound->voiceIsPlaying(_speechFile.empty() ? 0 : _speechFile.c_str()); } diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index e1ae29cba3..595619c7e9 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -42,7 +42,7 @@ #ifndef KYRA_SOUND_H #define KYRA_SOUND_H -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "common/scummsys.h" #include "common/file.h" @@ -66,7 +66,7 @@ namespace Kyra { */ class Sound { public: - Sound(KyraEngine *vm, Audio::Mixer *mixer); + Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer); virtual ~Sound(); enum kType { @@ -209,7 +209,7 @@ protected: int _currentTheme; - KyraEngine *_vm; + KyraEngine_v1 *_vm; Audio::Mixer *_mixer; private: @@ -243,7 +243,7 @@ class AdlibDriver; */ class SoundAdlibPC : public Sound { public: - SoundAdlibPC(KyraEngine *vm, Audio::Mixer *mixer); + SoundAdlibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer); ~SoundAdlibPC(); kType getMusicType() const { return kAdlib; } @@ -298,7 +298,7 @@ private: */ class SoundMidiPC : public MidiDriver, public Sound { public: - SoundMidiPC(KyraEngine *vm, Audio::Mixer *mixer, MidiDriver *driver); + SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *driver); ~SoundMidiPC(); kType getMusicType() const { return isMT32() ? kMidiMT32 : kMidiGM; } @@ -378,7 +378,7 @@ private: class SoundTowns_EuphonyDriver; class SoundTowns : public MidiDriver, public Sound { public: - SoundTowns(KyraEngine *vm, Audio::Mixer *mixer); + SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer); ~SoundTowns(); kType getMusicType() const { return kTowns; } @@ -435,7 +435,7 @@ private: //class SoundTowns_v2_TwnDriver; class SoundTowns_v2 : public Sound { public: - SoundTowns_v2(KyraEngine *vm, Audio::Mixer *mixer); + SoundTowns_v2(KyraEngine_v1 *vm, Audio::Mixer *mixer); ~SoundTowns_v2(); kType getMusicType() const { return kTowns; } @@ -463,7 +463,7 @@ private: class MixedSoundDriver : public Sound { public: - MixedSoundDriver(KyraEngine *vm, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(vm, mixer), _music(music), _sfx(sfx) {} + MixedSoundDriver(KyraEngine_v1 *vm, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(vm, mixer), _music(music), _sfx(sfx) {} ~MixedSoundDriver() { delete _music; delete _sfx; } kType getMusicType() const { return _music->getMusicType(); } diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index e227d1fc46..68a2f0be9c 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -2210,7 +2210,7 @@ const int SoundAdlibPC::_kyra1SoundTriggers[] = { const int SoundAdlibPC::_kyra1NumSoundTriggers = ARRAYSIZE(SoundAdlibPC::_kyra1SoundTriggers); -SoundAdlibPC::SoundAdlibPC(KyraEngine *vm, Audio::Mixer *mixer) +SoundAdlibPC::SoundAdlibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer) : Sound(vm, mixer), _driver(0), _trackEntries(), _soundDataPtr(0) { memset(_trackEntries, 0, sizeof(_trackEntries)); _v2 = (_vm->gameFlags().gameID == GI_KYRA2); diff --git a/engines/kyra/sound_lok.cpp b/engines/kyra/sound_lok.cpp index 398ac085c4..728013cdaa 100644 --- a/engines/kyra/sound_lok.cpp +++ b/engines/kyra/sound_lok.cpp @@ -35,7 +35,7 @@ void KyraEngine_LoK::snd_playSoundEffect(int track, int volume) { return; } - KyraEngine::snd_playSoundEffect(track); + KyraEngine_v1::snd_playSoundEffect(track); } void KyraEngine_LoK::snd_playWanderScoreViaMap(int command, int restart) { @@ -57,7 +57,7 @@ void KyraEngine_LoK::snd_playWanderScoreViaMap(int command, int restart) { _sound->haltTrack(); } } else { - KyraEngine::snd_playWanderScoreViaMap(command, restart); + KyraEngine_v1::snd_playWanderScoreViaMap(command, restart); } } diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp index d2ce48f452..3d8c7becae 100644 --- a/engines/kyra/sound_towns.cpp +++ b/engines/kyra/sound_towns.cpp @@ -1084,7 +1084,7 @@ void SoundTowns_EuphonyTrackQueue::initDriver() { _driver->send(0x79B0); } -SoundTowns::SoundTowns(KyraEngine *vm, Audio::Mixer *mixer) +SoundTowns::SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer) : Sound(vm, mixer), _lastTrack(-1), _currentSFX(0), _sfxFileData(0), _sfxFileIndex((uint)-1), _sfxWDTable(0), _sfxBTTable(0), _parser(0) { @@ -1357,7 +1357,7 @@ float SoundTowns::semitoneAndSampleRate_to_sampleStep(int8 semiTone, int8 semiTo // KYRA 2 -SoundTowns_v2::SoundTowns_v2(KyraEngine *vm, Audio::Mixer *mixer) +SoundTowns_v2::SoundTowns_v2(KyraEngine_v1 *vm, Audio::Mixer *mixer) : Sound(vm, mixer), _lastTrack(-1), _currentSFX(0), /*_driver(0),*/ _twnTrackData(0) { } diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index dbe181b84f..2ac960dc75 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -26,7 +26,7 @@ #include "common/endian.h" #include "common/md5.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_lok.h" #include "kyra/kyra_v2.h" #include "kyra/kyra_hof.h" @@ -1338,11 +1338,11 @@ const ScreenDim Screen_MR::_screenDimTable[] = { const int Screen_MR::_screenDimTableCount = ARRAYSIZE(Screen_MR::_screenDimTable); -const int8 KyraEngine::_addXPosTable[] = { +const int8 KyraEngine_v1::_addXPosTable[] = { 4, 4, 0, -4, -4, -4, 0, 4 }; -const int8 KyraEngine::_addYPosTable[] = { +const int8 KyraEngine_v1::_addYPosTable[] = { 0, -2, -2, -2, 0, 2, 2, 2 }; diff --git a/engines/kyra/text.cpp b/engines/kyra/text.cpp index 980b762b23..931c5fe1c9 100644 --- a/engines/kyra/text.cpp +++ b/engines/kyra/text.cpp @@ -25,7 +25,7 @@ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/screen.h" #include "kyra/text.h" @@ -35,7 +35,7 @@ namespace Kyra { -TextDisplayer::TextDisplayer(KyraEngine *vm, Screen *screen) { +TextDisplayer::TextDisplayer(KyraEngine_v1 *vm, Screen *screen) { _screen = screen; _vm = vm; diff --git a/engines/kyra/text.h b/engines/kyra/text.h index 5ae37e32ef..d45e5f9242 100644 --- a/engines/kyra/text.h +++ b/engines/kyra/text.h @@ -31,11 +31,11 @@ #include "kyra/screen.h" namespace Kyra { -class KyraEngine; +class KyraEngine_v1; class TextDisplayer { public: - TextDisplayer(KyraEngine *vm, Screen *screen); + TextDisplayer(KyraEngine_v1 *vm, Screen *screen); virtual ~TextDisplayer() {} int maxSubstringLen() const { return TALK_SUBSTRING_LEN; } @@ -60,7 +60,7 @@ public: bool printed() const { return _talkMessagePrinted; } protected: Screen *_screen; - KyraEngine *_vm; + KyraEngine_v1 *_vm; struct TalkCoords { uint16 y, x, w; diff --git a/engines/kyra/timer.cpp b/engines/kyra/timer.cpp index b20d9510cc..777871d65a 100644 --- a/engines/kyra/timer.cpp +++ b/engines/kyra/timer.cpp @@ -23,7 +23,7 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/timer.h" #include "common/func.h" @@ -34,7 +34,7 @@ namespace Kyra { namespace { struct TimerResync : public Common::UnaryFunction { uint32 _tickLength, _curTime; - TimerResync(KyraEngine *vm, uint32 curTime) : _tickLength(vm->tickLength()), _curTime(curTime) {} + TimerResync(KyraEngine_v1 *vm, uint32 curTime) : _tickLength(vm->tickLength()), _curTime(curTime) {} void operator()(TimerEntry &entry) const { if (entry.lastUpdate < 0) { diff --git a/engines/kyra/timer.h b/engines/kyra/timer.h index 264590845e..691bac3fb5 100644 --- a/engines/kyra/timer.h +++ b/engines/kyra/timer.h @@ -26,7 +26,7 @@ #ifndef KYRA_TIMER_H #define KYRA_TIMER_H -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "common/list.h" #include "common/stream.h" @@ -49,7 +49,7 @@ struct TimerEntry { class TimerManager { public: - TimerManager(KyraEngine *vm, OSystem *sys) : _vm(vm), _system(sys), _timers(), _nextRun(0), _isPaused(0), _pauseStart(0) {} + TimerManager(KyraEngine_v1 *vm, OSystem *sys) : _vm(vm), _system(sys), _timers(), _nextRun(0), _isPaused(0), _pauseStart(0) {} ~TimerManager() { reset(); } void pause(bool p); @@ -79,7 +79,7 @@ public: private: void resync(); - KyraEngine *_vm; + KyraEngine_v1 *_vm; OSystem *_system; Common::List _timers; uint32 _nextRun; diff --git a/engines/kyra/timer_lok.cpp b/engines/kyra/timer_lok.cpp index 91081a36b3..69b93b54c3 100644 --- a/engines/kyra/timer_lok.cpp +++ b/engines/kyra/timer_lok.cpp @@ -23,7 +23,7 @@ * */ -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_lok.h" #include "kyra/screen.h" #include "kyra/animator_lok.h" diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp index f4eadee4e2..cea52e911e 100644 --- a/engines/kyra/vqa.cpp +++ b/engines/kyra/vqa.cpp @@ -42,7 +42,7 @@ namespace Kyra { -VQAMovie::VQAMovie(KyraEngine *vm, OSystem *system) { +VQAMovie::VQAMovie(KyraEngine_v1 *vm, OSystem *system) { _system = system; _vm = vm; _opened = false; diff --git a/engines/kyra/vqa.h b/engines/kyra/vqa.h index 35f7d78004..f600f008b7 100644 --- a/engines/kyra/vqa.h +++ b/engines/kyra/vqa.h @@ -30,11 +30,11 @@ class OSystem; namespace Kyra { -class KyraEngine; +class KyraEngine_v1; class VQAMovie { public: - VQAMovie(KyraEngine *vm, OSystem *system); + VQAMovie(KyraEngine_v1 *vm, OSystem *system); ~VQAMovie(); bool opened() { return _opened; } @@ -54,7 +54,7 @@ public: protected: OSystem *_system; - KyraEngine *_vm; + KyraEngine_v1 *_vm; bool _opened; int _x, _y; diff --git a/engines/kyra/wsamovie.cpp b/engines/kyra/wsamovie.cpp index 42159478dd..110755c3ba 100644 --- a/engines/kyra/wsamovie.cpp +++ b/engines/kyra/wsamovie.cpp @@ -27,7 +27,7 @@ #include "common/endian.h" #include "common/system.h" -#include "kyra/kyra.h" +#include "kyra/kyra_v1.h" #include "kyra/kyra_v2.h" #include "kyra/screen.h" #include "kyra/screen_v2.h" @@ -35,7 +35,7 @@ #include "kyra/resource.h" namespace Kyra { -WSAMovie_v1::WSAMovie_v1(KyraEngine *vm) : Movie(vm) {} +WSAMovie_v1::WSAMovie_v1(KyraEngine_v1 *vm) : Movie(vm) {} WSAMovie_v1::~WSAMovie_v1() { close(); } int WSAMovie_v1::open(const char *filename, int offscreenDecode, uint8 *palBuf) { @@ -213,7 +213,7 @@ void WSAMovie_v1::processFrame(int frameNum, uint8 *dst) { #pragma mark - -WSAMovieAmiga::WSAMovieAmiga(KyraEngine *vm) : WSAMovie_v1(vm), _buffer(0) {} +WSAMovieAmiga::WSAMovieAmiga(KyraEngine_v1 *vm) : WSAMovie_v1(vm), _buffer(0) {} int WSAMovieAmiga::open(const char *filename, int offscreenDecode, uint8 *palBuf) { debugC(9, kDebugLevelMovie, "WSAMovieAmiga::open('%s', %d, %p)", filename, offscreenDecode, (const void *)palBuf); @@ -342,7 +342,7 @@ void WSAMovieAmiga::processFrame(int frameNum, uint8 *dst) { #pragma mark - -WSAMovie_v2::WSAMovie_v2(KyraEngine *vm, Screen_v2 *screen) : WSAMovie_v1(vm), _screen(screen), _xAdd(0), _yAdd(0) {} +WSAMovie_v2::WSAMovie_v2(KyraEngine_v1 *vm, Screen_v2 *screen) : WSAMovie_v1(vm), _screen(screen), _xAdd(0), _yAdd(0) {} int WSAMovie_v2::open(const char *filename, int unk1, uint8 *palBuf) { debugC(9, kDebugLevelMovie, "WSAMovie_v2::open('%s', %d, %p)", filename, unk1, (const void *)palBuf); diff --git a/engines/kyra/wsamovie.h b/engines/kyra/wsamovie.h index cc3a188eea..36cd75b1ab 100644 --- a/engines/kyra/wsamovie.h +++ b/engines/kyra/wsamovie.h @@ -32,12 +32,12 @@ class SoundHandle; } // end of namespace Audio namespace Kyra { -class KyraEngine; +class KyraEngine_v1; class Screen_v2; class Movie { public: - Movie(KyraEngine *vm) : _vm(vm), _opened(false), _x(-1), _y(-1), _drawPage(-1) {} + Movie(KyraEngine_v1 *vm) : _vm(vm), _opened(false), _x(-1), _y(-1), _drawPage(-1) {} virtual ~Movie() {} virtual bool opened() { return _opened; } @@ -53,7 +53,7 @@ public: virtual void setY(int y) { _y = y; } virtual void setDrawPage(int page) { _drawPage = page; } protected: - KyraEngine *_vm; + KyraEngine_v1 *_vm; bool _opened; int _x, _y; @@ -62,7 +62,7 @@ protected: class WSAMovie_v1 : public Movie { public: - WSAMovie_v1(KyraEngine *vm); + WSAMovie_v1(KyraEngine_v1 *vm); virtual ~WSAMovie_v1(); virtual int open(const char *filename, int offscreen, uint8 *palette); @@ -96,7 +96,7 @@ protected: class WSAMovieAmiga : public WSAMovie_v1 { public: - WSAMovieAmiga(KyraEngine *vm); + WSAMovieAmiga(KyraEngine_v1 *vm); int open(const char *filename, int offscreen, uint8 *palette); void close(); @@ -109,7 +109,7 @@ private: class WSAMovie_v2 : public WSAMovie_v1 { public: - WSAMovie_v2(KyraEngine *vm, Screen_v2 *scren); + WSAMovie_v2(KyraEngine_v1 *vm, Screen_v2 *scren); int open(const char *filename, int unk1, uint8 *palette); -- cgit v1.2.3