2007-09-01 14:58:46 +00: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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
2010-05-04 11:59:22 +00:00
|
|
|
#include "common/debug-channels.h"
|
2010-03-18 15:07:11 +00:00
|
|
|
#include "common/random.h"
|
2007-09-01 14:58:46 +00:00
|
|
|
|
|
|
|
#include "sound/mididrv.h"
|
|
|
|
|
2007-09-18 16:20:44 +00:00
|
|
|
#include "agi/preagi.h"
|
2007-09-01 14:58:46 +00:00
|
|
|
#include "agi/graphics.h"
|
|
|
|
|
|
|
|
// preagi engines
|
|
|
|
#include "agi/preagi_mickey.h"
|
2007-09-18 16:20:44 +00:00
|
|
|
#include "agi/preagi_troll.h"
|
2007-09-06 10:48:00 +00:00
|
|
|
#include "agi/preagi_winnie.h"
|
2007-09-01 14:58:46 +00:00
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
|
2007-09-01 14:58:46 +00:00
|
|
|
|
|
|
|
// Setup mixer
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
|
|
|
|
|
|
|
_rnd = new Common::RandomSource();
|
|
|
|
|
2010-04-27 21:40:52 +00:00
|
|
|
DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelInventory, "Inventory", "Inventory debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging");
|
|
|
|
DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging");
|
2007-09-01 14:58:46 +00:00
|
|
|
|
|
|
|
memset(&_game, 0, sizeof(struct AgiGame));
|
|
|
|
memset(&_debug, 0, sizeof(struct AgiDebug));
|
2009-10-20 11:13:00 +00:00
|
|
|
memset(&_mouse, 0, sizeof(struct Mouse));
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreAgiEngine::initialize() {
|
|
|
|
// TODO: Some sound emulation modes do not fit our current music
|
|
|
|
// drivers, and I'm not sure what they are. For now, they might
|
|
|
|
// as well be called "PC Speaker" and "Not PC Speaker".
|
|
|
|
|
2007-09-03 09:39:15 +00:00
|
|
|
switch (MidiDriver::detectMusicDriver(MDT_PCSPK)) {
|
|
|
|
case MD_PCSPK:
|
|
|
|
_soundemu = SOUND_EMU_PC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_soundemu = SOUND_EMU_NONE;
|
|
|
|
break;
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ConfMan.hasKey("render_mode")) {
|
|
|
|
_renderMode = Common::parseRenderMode(ConfMan.get("render_mode").c_str());
|
|
|
|
} else if (ConfMan.hasKey("platform")) {
|
|
|
|
switch (Common::parsePlatform(ConfMan.get("platform"))) {
|
|
|
|
case Common::kPlatformAmiga:
|
|
|
|
_renderMode = Common::kRenderAmiga;
|
|
|
|
break;
|
|
|
|
case Common::kPlatformPC:
|
|
|
|
_renderMode = Common::kRenderEGA;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_renderMode = Common::kRenderEGA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_gfx = new GfxMgr(this);
|
2007-11-19 20:34:26 +00:00
|
|
|
//_sound = new SoundMgr(this, _mixer);
|
2007-09-01 14:58:46 +00:00
|
|
|
_picture = new PictureMgr(this, _gfx);
|
|
|
|
//_sprites = new SpritesMgr(this, _gfx);
|
|
|
|
|
|
|
|
_gfx->initMachine();
|
|
|
|
|
|
|
|
_game.gameFlags = 0;
|
|
|
|
|
|
|
|
_game.colorFg = 15;
|
|
|
|
_game.colorBg = 0;
|
|
|
|
|
2007-09-18 16:20:44 +00:00
|
|
|
_defaultColor = 0xF;
|
|
|
|
|
2007-09-01 14:58:46 +00:00
|
|
|
_game.name[0] = '\0';
|
|
|
|
|
|
|
|
_game.sbufOrig = (uint8 *)calloc(_WIDTH, _HEIGHT * 2); // Allocate space for two AGI screens vertically
|
|
|
|
_game.sbuf16c = _game.sbufOrig + SBUF16_OFFSET; // Make sbuf16c point to the 16 color (+control line & priority info) AGI screen
|
|
|
|
_game.sbuf = _game.sbuf16c; // Make sbuf point to the 16 color (+control line & priority info) AGI screen by default
|
|
|
|
|
2007-09-02 22:45:02 +00:00
|
|
|
_game.lineMinPrint = 0; // hardcoded
|
2007-09-01 14:58:46 +00:00
|
|
|
|
|
|
|
_gfx->initVideo();
|
2007-11-19 20:34:26 +00:00
|
|
|
//_sound->initSound();
|
|
|
|
|
|
|
|
_speakerStream = new Audio::PCSpeaker(_mixer->getOutputRate());
|
2010-04-12 09:14:17 +00:00
|
|
|
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
|
2010-01-08 22:09:43 +00:00
|
|
|
_speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
|
2007-11-19 20:34:26 +00:00
|
|
|
|
2007-09-01 14:58:46 +00:00
|
|
|
|
|
|
|
//_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL);
|
|
|
|
|
|
|
|
debugC(2, kDebugLevelMain, "Detect game");
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
// clear all resources and events
|
2007-09-01 14:58:46 +00:00
|
|
|
for (int i = 0; i < MAX_DIRS; i++) {
|
|
|
|
memset(&_game.pictures[i], 0, sizeof(struct AgiPicture));
|
2007-09-03 09:39:15 +00:00
|
|
|
memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now
|
2007-09-01 14:58:46 +00:00
|
|
|
memset(&_game.dirPic[i], 0, sizeof(struct AgiDir));
|
2007-09-03 09:39:15 +00:00
|
|
|
memset(&_game.dirSound[i], 0, sizeof(struct AgiDir));
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
debugC(2, kDebugLevelMain, "Init sound");
|
|
|
|
}
|
|
|
|
|
|
|
|
PreAgiEngine::~PreAgiEngine() {
|
2007-11-19 22:37:52 +00:00
|
|
|
_mixer->stopHandle(_speakerHandle);
|
2007-11-19 20:34:26 +00:00
|
|
|
delete _speakerStream;
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-06 17:05:54 +00:00
|
|
|
Common::Error PreAgiEngine::go() {
|
2007-09-03 09:39:15 +00:00
|
|
|
setflag(fSoundOn, true); // enable sound
|
|
|
|
|
2009-06-06 17:39:13 +00:00
|
|
|
//
|
|
|
|
// FIXME (Fingolfin asks): Why are Mickey, Winnie and Troll standalone classes
|
|
|
|
// instead of being subclasses of PreAgiEngine ?
|
|
|
|
//
|
2007-11-23 10:51:16 +00:00
|
|
|
|
2007-09-01 14:58:46 +00:00
|
|
|
// run preagi engine main loop
|
|
|
|
switch (getGameID()) {
|
2008-01-13 23:43:17 +00:00
|
|
|
case GID_MICKEY:
|
|
|
|
{
|
|
|
|
Mickey *mickey = new Mickey(this);
|
|
|
|
mickey->init();
|
|
|
|
mickey->run();
|
|
|
|
delete mickey;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GID_WINNIE:
|
|
|
|
{
|
|
|
|
Winnie *winnie = new Winnie(this);
|
|
|
|
winnie->init();
|
|
|
|
winnie->run();
|
|
|
|
delete winnie;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GID_TROLL:
|
|
|
|
{
|
|
|
|
Troll *troll = new Troll(this);
|
|
|
|
troll->init();
|
|
|
|
troll->run();
|
|
|
|
delete troll;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("Unknown preagi engine");
|
|
|
|
break;
|
2007-09-19 08:40:12 +00:00
|
|
|
}
|
2008-11-06 17:05:54 +00:00
|
|
|
return Common::kNoError;
|
2007-09-01 14:58:46 +00:00
|
|
|
}
|
|
|
|
|
2010-03-18 15:07:11 +00:00
|
|
|
int PreAgiEngine::rnd(int hi) {
|
|
|
|
return (_rnd->getRandomNumber(hi - 1) + 1);
|
|
|
|
}
|
|
|
|
|
2007-09-01 14:58:46 +00:00
|
|
|
} // End of namespace Agi
|