2017-03-21 21:07:58 +01:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/debug-channels.h"
|
|
|
|
#include "common/error.h"
|
|
|
|
|
2017-07-20 19:08:53 +02:00
|
|
|
#include "sludge/event.h"
|
2017-07-19 13:37:54 +02:00
|
|
|
#include "sludge/graphics.h"
|
2017-03-21 21:07:58 +01:00
|
|
|
#include "sludge/sludge.h"
|
2017-07-20 23:18:05 +02:00
|
|
|
#include "sludge/sound.h"
|
2017-07-21 00:11:17 +02:00
|
|
|
#include "sludge/fonttext.h"
|
2017-06-05 19:10:47 +02:00
|
|
|
#include "sludge/main_loop.h"
|
2017-05-26 05:24:38 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
namespace Sludge {
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-06-06 01:35:25 +02:00
|
|
|
SludgeEngine *g_sludge;
|
|
|
|
|
2017-06-06 09:01:46 +02:00
|
|
|
Graphics::PixelFormat *SludgeEngine::getScreenPixelFormat() const { return _pixelFormat; }
|
|
|
|
Graphics::PixelFormat *SludgeEngine::getOrigPixelFormat() const { return _origFormat; }
|
2017-06-06 01:35:25 +02:00
|
|
|
|
2017-06-05 11:49:19 +02:00
|
|
|
SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc) :
|
|
|
|
Engine(syst), _gameDescription(gameDesc), _console(nullptr) {
|
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
// register your random source
|
|
|
|
_rnd = new Common::RandomSource("sludge");
|
|
|
|
|
|
|
|
// Add debug channels
|
2017-06-03 19:50:02 +02:00
|
|
|
DebugMan.addDebugChannel(kSludgeDebugFatal, "Script", "Script debug level");
|
2017-05-27 20:04:09 +02:00
|
|
|
DebugMan.addDebugChannel(kSludgeDebugDataLoad, "Data Load", "Data loading debug level");
|
|
|
|
DebugMan.addDebugChannel(kSludgeDebugStackMachine, "Stack Machine", "Stack Machine debug level");
|
|
|
|
DebugMan.addDebugChannel(kSludgeDebugBuiltin, "Built-in", "Built-in debug level");
|
2017-05-29 07:51:40 +02:00
|
|
|
DebugMan.addDebugChannel(kSludgeDebugGraphics, "Graphics", "Graphics debug level");
|
2017-03-21 21:07:58 +01:00
|
|
|
|
2017-07-15 17:35:01 +02:00
|
|
|
// init graphics
|
|
|
|
_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
|
|
|
_pixelFormat = new Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
2017-07-11 15:39:22 +02:00
|
|
|
|
|
|
|
// Init Strings
|
|
|
|
launchMe = "";
|
|
|
|
loadNow = "";
|
|
|
|
gamePath = "";
|
|
|
|
bundleFolder = "";
|
|
|
|
|
|
|
|
fatalMessage = "";
|
|
|
|
fatalInfo = "Initialisation error! Something went wrong before we even got started!";
|
2017-07-18 17:25:00 +02:00
|
|
|
|
|
|
|
// Init managers
|
2017-07-18 19:03:45 +02:00
|
|
|
_resMan = new ResourceManager();
|
2017-07-18 17:25:00 +02:00
|
|
|
_languageMan = new LanguageManager();
|
2017-07-18 19:50:45 +02:00
|
|
|
_objMan = new ObjectManager(this);
|
2017-07-20 00:41:13 +02:00
|
|
|
_gfxMan = new GraphicsManager(this);
|
2017-07-20 19:08:53 +02:00
|
|
|
_evtMan = new EventManager(this);
|
2017-07-20 23:18:05 +02:00
|
|
|
_soundMan = new SoundManager();
|
2017-07-21 00:11:17 +02:00
|
|
|
_txtMan = new TextManager();
|
2017-03-21 21:07:58 +01:00
|
|
|
}
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
SludgeEngine::~SludgeEngine() {
|
|
|
|
|
|
|
|
// Dispose resources
|
|
|
|
delete _rnd;
|
2017-06-06 09:01:46 +02:00
|
|
|
_rnd = nullptr;
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
// Remove debug levels
|
|
|
|
DebugMan.clearAllDebugChannels();
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
// Dispose console
|
|
|
|
delete _console;
|
2017-06-06 09:01:46 +02:00
|
|
|
_console = nullptr;
|
|
|
|
|
|
|
|
// Dispose pixel formats
|
|
|
|
delete _origFormat;
|
|
|
|
_origFormat = nullptr;
|
|
|
|
delete _pixelFormat;
|
|
|
|
_pixelFormat = nullptr;
|
2017-07-18 17:25:00 +02:00
|
|
|
|
|
|
|
// Dispose managers
|
2017-07-21 00:11:17 +02:00
|
|
|
delete _txtMan;
|
|
|
|
_txtMan = nullptr;
|
2017-07-20 23:18:05 +02:00
|
|
|
delete _soundMan;
|
|
|
|
_soundMan = nullptr;
|
2017-07-20 19:08:53 +02:00
|
|
|
delete _evtMan;
|
|
|
|
_evtMan = nullptr;
|
2017-07-19 13:37:54 +02:00
|
|
|
delete _gfxMan;
|
|
|
|
_gfxMan = nullptr;
|
2017-07-18 19:50:45 +02:00
|
|
|
delete _objMan;
|
|
|
|
_objMan = nullptr;
|
2017-07-18 17:25:00 +02:00
|
|
|
delete _languageMan;
|
|
|
|
_languageMan = nullptr;
|
2017-07-18 19:03:45 +02:00
|
|
|
delete _resMan;
|
|
|
|
_resMan = nullptr;
|
2017-03-21 21:07:58 +01:00
|
|
|
}
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
Common::Error SludgeEngine::run() {
|
2017-06-06 01:35:25 +02:00
|
|
|
// set global variable
|
|
|
|
g_sludge = this;
|
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
// create console
|
|
|
|
_console = new SludgeConsole(this);
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
// debug log
|
2017-06-06 01:04:17 +02:00
|
|
|
main_loop(getGameFile());
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
2017-06-05 11:49:19 +02:00
|
|
|
|
2017-03-21 21:07:58 +01:00
|
|
|
} // End of namespace Sludge
|
|
|
|
|