diff options
author | Matthew Hoops | 2011-05-31 14:16:29 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-31 14:16:29 -0400 |
commit | aa49b38c5a8032586cb94fc4ca07149eecabe64a (patch) | |
tree | ea5c7617f8c482c8cf4141b728b3ccff5a7f84c7 /engines/scumm/scumm.cpp | |
parent | d3ea9ab2a9334747eb445c1b45aa30cb17ffdf1b (diff) | |
parent | c86a6c466fabe31fbf36363aa8d0ac8ea6001b9f (diff) | |
download | scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.gz scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.tar.bz2 scummvm-rg350-aa49b38c5a8032586cb94fc4ca07149eecabe64a.zip |
Merge remote branch 'upstream/master' into t7g-ios
Conflicts:
engines/groovie/script.cpp
Diffstat (limited to 'engines/scumm/scumm.cpp')
-rw-r--r-- | engines/scumm/scumm.cpp | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index f43aed53f7..e8dd6cb548 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -18,16 +18,12 @@ * 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 "common/debug-channels.h" #include "common/md5.h" #include "common/events.h" -#include "common/EventRecorder.h" #include "common/system.h" #include "common/translation.h" @@ -65,6 +61,7 @@ #include "scumm/player_v2a.h" #include "scumm/player_v3a.h" #include "scumm/player_v4a.h" +#include "scumm/resource.h" #include "scumm/he/resource_he.h" #include "scumm/scumm_v0.h" #include "scumm/scumm_v8.h" @@ -113,9 +110,13 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _language(dr.language), _debugger(0), _currentScript(0xFF), // Let debug() work on init stage - _messageDialog(0), _pauseDialog(0), _versionDialog(0) { + _messageDialog(0), _pauseDialog(0), _versionDialog(0), + _rnd("scumm") + { - if (_game.platform == Common::kPlatformNES) { + if (_game.heversion > 0) { + _gdi = new GdiHE(this); + } else if (_game.platform == Common::kPlatformNES) { _gdi = new GdiNES(this); #ifdef USE_RGB_COLOR } else if (_game.features & GF_16BIT_COLOR) { @@ -574,8 +575,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) assert(!_mainMenuDialog); _mainMenuDialog = new ScummMenuDialog(this); #endif - - g_eventRec.registerRandomSource(_rnd, "scumm"); } @@ -1184,10 +1183,6 @@ Common::Error ScummEngine::init() { resetScumm(); resetScummVars(); - if (_imuse) { - _imuse->setBase(_res->address[rtSound]); - } - if (_game.version >= 5 && _game.version <= 7) _sound->setupSound(); @@ -1233,7 +1228,7 @@ void ScummEngine::setupScumm() { requestLoad(ConfMan.getInt("save_slot")); } - _res->allocResTypeData(rtBuffer, 0, 10, "buffer", 0); + _res->allocResTypeData(rtBuffer, 0, 10, kDynamicResTypeMode); setupScummVars(); @@ -1833,22 +1828,22 @@ void ScummEngine::setupMusic(int midi) { MidiDriver *nativeMidiDriver = 0; MidiDriver *adlibMidiDriver = 0; - if (_musicType != MDT_ADLIB) + if (_musicType != MDT_ADLIB && _musicType != MDT_TOWNS) nativeMidiDriver = MidiDriver::createMidi(dev); if (nativeMidiDriver != NULL && _native_mt32) nativeMidiDriver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); bool multi_midi = ConfMan.getBool("multi_midi") && _musicType != MDT_NONE && (midi & MDT_ADLIB); - if (_musicType == MDT_ADLIB || multi_midi) { - adlibMidiDriver = MidiDriver::createMidi(MidiDriver::detectDevice(MDT_ADLIB)); + if (_musicType == MDT_ADLIB || MDT_TOWNS || multi_midi) { + adlibMidiDriver = MidiDriver::createMidi(MidiDriver::detectDevice(_musicType == MDT_TOWNS ? MDT_TOWNS : MDT_ADLIB)); adlibMidiDriver->property(MidiDriver::PROP_OLD_ADLIB, (_game.features & GF_SMALL_HEADER) ? 1 : 0); } _imuse = IMuse::create(_system, nativeMidiDriver, adlibMidiDriver); if (_game.platform == Common::kPlatformFMTowns) { - _musicEngine = _townsPlayer = new Player_Towns_v2(this, _imuse, _mixer, true); + _musicEngine = _townsPlayer = new Player_Towns_v2(this, _mixer, _imuse, true); if (!_townsPlayer->init()) - error("Failed to initialize FM-Towns audio driver"); + error("ScummEngine::setupMusic(): Failed to initialize FM-Towns audio driver"); } else { _musicEngine = _imuse; } @@ -1860,7 +1855,6 @@ void ScummEngine::setupMusic(int midi) { _imuse->property(IMuse::PROP_GAME_ID, _game.id); if (ConfMan.hasKey("tempo")) _imuse->property(IMuse::PROP_TEMPO_BASE, ConfMan.getInt("tempo")); - // YM2162 driver can't handle midi->getPercussionChannel(), NULL shouldn't init MT-32/GM/GS if (midi != MDT_NONE) { _imuse->property(IMuse::PROP_NATIVE_MT32, _native_mt32); if (MidiDriver::getMusicType(dev) != MT_MT32) // MT-32 Emulation shouldn't be GM/GS initialized @@ -2422,13 +2416,16 @@ void ScummEngine::pauseGame() { } void ScummEngine::restart() { -// TODO: Check this function - we should probably be reinitting a lot more stuff, and I suspect -// this leaks memory like a sieve + // FIXME: This function *leaks memory*, and quite a lot so. For example, + // we re-init the resource manager, which causes readMAXS() to be called + // again, which allocates some memory. There are many other leaks, though. + + // TODO: We should also probably be reinitting a lot more stuff. -// Fingolfin seez: An alternate way to implement restarting would be to create -// a save state right after startup ... to this end we could introduce a SaveFile -// subclass which is implemented using a memory buffer (i.e. no actual file is -// created). Then to restart we just have to load that pseudo save state. + // Fingolfin seez: An alternate way to implement restarting would be to create + // a save state right after startup ... to this end we could introduce a SaveFile + // subclass which is implemented using a memory buffer (i.e. no actual file is + // created). Then to restart we just have to load that pseudo save state. int i; @@ -2448,23 +2445,12 @@ void ScummEngine::restart() { for (i = 1; i < _numGlobalObjects; i++) clearOwnerOf(i); - // Reallocate arrays - // FIXME: This should already be called by readIndexFile. - // FIXME: regardless of that, allocateArrays and allocResTypeData leaks - // heavily, which should be fixed. - allocateArrays(); - - // Reread index (reset objectstate etc) readIndexFile(); // Reinit scumm variables resetScumm(); resetScummVars(); - if (_imuse) { - _imuse->setBase(_res->address[rtSound]); - } - // Reinit sound engine if (_game.version >= 5 && _game.version <= 7) _sound->setupSound(); |