2011-06-08 00:01:44 +02: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"
|
|
|
|
#include "common/EventRecorder.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/fs.h"
|
|
|
|
#include "engines/util.h"
|
|
|
|
#include "cge/cge.h"
|
2011-06-20 23:40:22 +02:00
|
|
|
#include "cge/vga13h.h"
|
2011-06-09 08:20:53 +02:00
|
|
|
#include "cge/cge_main.h"
|
2011-06-28 22:18:21 +10:00
|
|
|
#include "cge/talk.h"
|
2011-06-19 11:17:54 +02:00
|
|
|
#include "cge/text.h"
|
2011-07-13 21:04:44 +10:00
|
|
|
#include "cge/walk.h"
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-06-08 00:01:44 +02:00
|
|
|
namespace CGE {
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-09-14 08:15:30 +02:00
|
|
|
const int CGEEngine::_maxSceneArr[5] = {1, 8, 16, 23, 24};
|
2011-09-06 22:59:10 +02:00
|
|
|
|
2011-06-08 00:01:44 +02:00
|
|
|
CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
|
2011-07-05 20:51:29 +10:00
|
|
|
: Engine(syst), _gameDescription(gameDescription), _randomSource("cge") {
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-06-26 17:53:55 +10:00
|
|
|
// Debug/console setup
|
2011-07-20 14:22:56 +02:00
|
|
|
DebugMan.addDebugChannel(kCGEDebugBitmap, "bitmap", "CGE Bitmap debug channel");
|
|
|
|
DebugMan.addDebugChannel(kCGEDebugFile, "file", "CGE IO debug channel");
|
|
|
|
DebugMan.addDebugChannel(kCGEDebugEngine, "engine", "CGE Engine debug channel");
|
2011-06-22 08:11:18 +02:00
|
|
|
|
2011-07-04 08:15:56 +02:00
|
|
|
_startupMode = 1;
|
2011-07-22 11:54:46 +02:00
|
|
|
_demoText = kDemo;
|
2011-07-04 08:15:56 +02:00
|
|
|
_oldLev = 0;
|
|
|
|
_pocPtr = 0;
|
2011-09-17 17:17:22 +02:00
|
|
|
_bitmapPalette = NULL;
|
2011-11-16 00:00:07 +01:00
|
|
|
_quitFlag = false;
|
2011-11-28 18:54:01 +01:00
|
|
|
_showBoundariesFl = false;
|
2011-06-26 17:53:55 +10:00
|
|
|
}
|
|
|
|
|
2011-09-14 08:15:30 +02:00
|
|
|
void CGEEngine::initSceneValues() {
|
|
|
|
for (int i = 0; i < kSceneMax; i++) {
|
2011-09-06 23:14:49 +02:00
|
|
|
_heroXY[i].x = 0;
|
|
|
|
_heroXY[i].y = 0;
|
2011-07-30 15:43:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-14 08:15:30 +02:00
|
|
|
for (int i = 0; i < kSceneMax + 1; i++) {
|
2011-07-30 15:43:49 +02:00
|
|
|
_barriers[i]._horz = 0xFF;
|
|
|
|
_barriers[i]._vert = 0xFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-29 22:51:45 +02:00
|
|
|
void CGEEngine::init() {
|
2011-07-20 14:22:56 +02:00
|
|
|
debugC(1, kCGEDebugEngine, "CGEEngine::setup()");
|
2011-07-18 18:05:57 +02:00
|
|
|
|
2011-07-02 18:38:25 +10:00
|
|
|
// Initialise fields
|
|
|
|
_lastFrame = 0;
|
2011-07-16 22:28:49 +10:00
|
|
|
_lastTick = 0;
|
2011-07-05 21:07:14 +10:00
|
|
|
_hero = NULL;
|
2011-07-13 19:18:23 +10:00
|
|
|
_shadow = NULL;
|
2011-09-14 08:15:30 +02:00
|
|
|
_miniScene = NULL;
|
2011-07-16 15:17:18 +10:00
|
|
|
_miniShp = NULL;
|
|
|
|
_miniShpList = NULL;
|
2011-08-06 18:23:53 +10:00
|
|
|
_sprite = NULL;
|
2011-09-14 00:10:59 +02:00
|
|
|
_resman = new ResourceManager();
|
2011-07-02 18:38:25 +10:00
|
|
|
|
2011-06-26 17:53:55 +10:00
|
|
|
// Create debugger console
|
2011-06-13 11:57:24 +02:00
|
|
|
_console = new CGEConsole(this);
|
2011-06-26 17:53:55 +10:00
|
|
|
|
2011-07-05 21:39:14 +10:00
|
|
|
// Initialise engine objects
|
2011-09-15 07:58:31 +02:00
|
|
|
_font = new Font(this, "CGE");
|
2011-09-11 14:19:46 +02:00
|
|
|
_text = new Text(this, "CGE");
|
2011-09-17 17:27:05 +02:00
|
|
|
_talk = NULL;
|
2011-11-28 18:54:01 +01:00
|
|
|
_vga = new Vga(this);
|
2011-07-05 21:39:14 +10:00
|
|
|
_sys = new System(this);
|
2011-07-10 10:10:51 +10:00
|
|
|
_pocLight = new PocLight(this);
|
2011-08-06 22:14:23 +10:00
|
|
|
for (int i = 0; i < kPocketNX; i++)
|
|
|
|
_pocket[i] = NULL;
|
2011-08-29 22:51:45 +02:00
|
|
|
_horzLine = new HorizLine(this);
|
2011-07-21 01:56:40 +02:00
|
|
|
_infoLine = new InfoLine(this, kInfoW);
|
2011-09-14 08:15:30 +02:00
|
|
|
_sceneLight = new SceneLight(this);
|
2011-07-21 01:56:40 +02:00
|
|
|
_debugLine = new InfoLine(this, kScrWidth);
|
2011-09-18 11:25:34 +02:00
|
|
|
_commandHandler = new CommandHandler(this, false);
|
|
|
|
_commandHandlerTurbo = new CommandHandler(this, true);
|
2011-09-17 10:54:50 +02:00
|
|
|
_midiPlayer = new MusicPlayer(this);
|
2011-07-08 08:21:35 +02:00
|
|
|
_mouse = new Mouse(this);
|
2011-09-04 14:28:12 +02:00
|
|
|
_keyboard = new Keyboard(this);
|
2011-09-16 20:31:11 +02:00
|
|
|
_eventManager = new EventManager(this);
|
2011-09-17 10:54:50 +02:00
|
|
|
_fx = new Fx(this, 16); // must precede SOUND!!
|
2011-07-29 10:02:32 +02:00
|
|
|
_sound = new Sound(this);
|
|
|
|
|
2011-07-22 11:54:46 +02:00
|
|
|
_offUseCount = atoi(_text->getText(kOffUseCount));
|
2011-07-04 08:15:56 +02:00
|
|
|
_music = true;
|
|
|
|
|
2011-07-21 01:56:40 +02:00
|
|
|
for (int i = 0; i < kPocketNX; i++)
|
2011-07-04 08:15:56 +02:00
|
|
|
_pocref[i] = -1;
|
|
|
|
_volume[0] = 0;
|
|
|
|
_volume[1] = 0;
|
|
|
|
|
2011-09-14 08:15:30 +02:00
|
|
|
initSceneValues();
|
2011-07-25 19:09:12 +02:00
|
|
|
|
2011-09-14 08:15:30 +02:00
|
|
|
_maxScene = 0;
|
2011-07-18 23:14:22 +02:00
|
|
|
_dark = false;
|
|
|
|
_game = false;
|
2011-09-06 00:43:40 +02:00
|
|
|
_finis = false;
|
2011-07-18 23:14:22 +02:00
|
|
|
_now = 1;
|
|
|
|
_lev = -1;
|
|
|
|
_recentStep = -2;
|
2011-07-05 23:13:12 +02:00
|
|
|
|
2011-07-07 08:11:29 +02:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
_flag[i] = false;
|
2011-07-05 23:13:12 +02:00
|
|
|
|
2011-07-29 10:02:32 +02:00
|
|
|
_mode = 0;
|
2011-08-12 21:33:45 +10:00
|
|
|
_soundOk = 1;
|
2011-07-30 12:52:04 +02:00
|
|
|
_sprTv = NULL;
|
|
|
|
_gameCase2Cpt = 0;
|
2011-09-06 00:43:40 +02:00
|
|
|
_offUseCount = 0;
|
2011-07-29 10:02:32 +02:00
|
|
|
|
2011-07-16 21:12:19 +10:00
|
|
|
_startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
|
2011-06-08 00:01:44 +02:00
|
|
|
}
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-08-29 22:51:45 +02:00
|
|
|
void CGEEngine::deinit() {
|
2011-06-08 00:01:44 +02:00
|
|
|
// Remove all of our debug levels here
|
|
|
|
DebugMan.clearAllDebugChannels();
|
2011-06-22 08:11:18 +02:00
|
|
|
|
2011-07-03 17:14:47 +10:00
|
|
|
delete _console;
|
2011-06-22 08:11:18 +02:00
|
|
|
|
2011-07-28 15:35:12 +02:00
|
|
|
// Delete engine objects
|
2011-07-10 17:56:29 +10:00
|
|
|
delete _vga;
|
|
|
|
delete _sys;
|
2011-08-06 17:22:04 +10:00
|
|
|
delete _sprite;
|
2011-09-14 08:15:30 +02:00
|
|
|
delete _miniScene;
|
2011-06-29 00:35:21 +02:00
|
|
|
delete _shadow;
|
|
|
|
delete _horzLine;
|
2011-07-03 11:28:22 +02:00
|
|
|
delete _infoLine;
|
2011-09-14 08:15:30 +02:00
|
|
|
delete _sceneLight;
|
2011-07-03 11:28:22 +02:00
|
|
|
delete _debugLine;
|
|
|
|
delete _text;
|
2011-07-02 20:38:27 +10:00
|
|
|
delete _pocLight;
|
|
|
|
delete _keyboard;
|
|
|
|
delete _mouse;
|
2011-07-29 10:02:32 +02:00
|
|
|
delete _eventManager;
|
|
|
|
delete _sound;
|
2011-11-16 00:00:07 +01:00
|
|
|
delete _fx;
|
|
|
|
delete _midiPlayer;
|
2011-09-15 07:58:31 +02:00
|
|
|
delete _font;
|
2011-09-18 11:25:34 +02:00
|
|
|
delete _commandHandler;
|
|
|
|
delete _commandHandlerTurbo;
|
2011-07-03 16:22:26 +02:00
|
|
|
delete _hero;
|
2011-09-14 00:10:59 +02:00
|
|
|
delete _resman;
|
2011-07-30 15:43:49 +02:00
|
|
|
|
2011-08-12 21:33:45 +10:00
|
|
|
if (_miniShpList) {
|
|
|
|
for (int i = 0; _miniShpList[i]; ++i)
|
|
|
|
delete _miniShpList[i];
|
|
|
|
delete[] _miniShpList;
|
|
|
|
}
|
2011-06-08 00:01:44 +02:00
|
|
|
}
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-08-29 22:51:45 +02:00
|
|
|
CGEEngine::~CGEEngine() {
|
|
|
|
debugC(1, kCGEDebugEngine, "CGEEngine::~CGEEngine()");
|
|
|
|
}
|
|
|
|
|
2011-06-08 00:01:44 +02:00
|
|
|
Common::Error CGEEngine::run() {
|
2011-07-20 14:22:56 +02:00
|
|
|
debugC(1, kCGEDebugEngine, "CGEEngine::run()");
|
2011-07-18 18:05:57 +02:00
|
|
|
|
2011-08-29 22:51:45 +02:00
|
|
|
if (_gameDescription->flags & ADGF_DEMO) {
|
|
|
|
warning("Demos of Soltys are not supported.\nPlease get a free version on ScummVM download page");
|
|
|
|
return Common::kUnsupportedGameidError;
|
|
|
|
}
|
|
|
|
|
2011-06-08 00:01:44 +02:00
|
|
|
// Initialize graphics using following:
|
|
|
|
initGraphics(320, 200, false);
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-06-26 17:53:55 +10:00
|
|
|
// Setup necessary game objects
|
2011-08-29 22:51:45 +02:00
|
|
|
init();
|
2011-07-16 21:12:19 +10:00
|
|
|
// Run the game
|
2011-06-09 08:20:53 +02:00
|
|
|
cge_main();
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-08-29 22:51:45 +02:00
|
|
|
// Remove game objects
|
|
|
|
deinit();
|
|
|
|
|
2011-06-08 00:01:44 +02:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
2011-06-13 11:57:24 +02:00
|
|
|
|
2011-07-16 21:12:19 +10:00
|
|
|
bool CGEEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return
|
|
|
|
(f == kSupportsRTL) ||
|
|
|
|
(f == kSupportsLoadingDuringRuntime) ||
|
|
|
|
(f == kSupportsSavingDuringRuntime);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGEEngine::canLoadGameStateCurrently() {
|
2011-11-27 22:16:52 +11:00
|
|
|
return (_startupMode == 0) && _mouse->_active;
|
2011-07-16 21:12:19 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGEEngine::canSaveGameStateCurrently() {
|
2011-11-08 20:32:41 +11:00
|
|
|
return (_startupMode == 0) && _mouse->_active &&
|
|
|
|
_commandHandler->idle() && !_hero->_flags._hide;
|
2011-07-16 21:12:19 +10:00
|
|
|
}
|
|
|
|
|
2011-06-08 00:01:44 +02:00
|
|
|
} // End of namespace CGE
|