diff options
Diffstat (limited to 'engines/agi/preagi.cpp')
-rw-r--r-- | engines/agi/preagi.cpp | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp new file mode 100644 index 0000000000..f24fbcd294 --- /dev/null +++ b/engines/agi/preagi.cpp @@ -0,0 +1,275 @@ +/* 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/stdafx.h" + +#include "common/events.h" +#include "common/file.h" +#include "common/savefile.h" +#include "common/config-manager.h" + +#include "base/plugins.h" +#include "base/version.h" + +#include "graphics/cursorman.h" + +#include "sound/mididrv.h" +#include "sound/mixer.h" + +#include "agi/agi.h" +#include "agi/graphics.h" +#include "agi/sprite.h" +#include "agi/opcodes.h" +#include "agi/keyboard.h" +#include "agi/menu.h" +#include "agi/sound.h" + +// preagi engines +#include "agi/preagi_mickey.h" + +namespace Agi { + +PreAgiEngine::PreAgiEngine(OSystem *syst) : AgiBase(syst) { + + // Setup mixer + if (!_mixer->isReady()) { + warning("Sound initialization failed."); + } + + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + +/* + const GameSettings *g; + + const char *gameid = ConfMan.get("gameid").c_str(); + for (g = agiSettings; g->gameid; ++g) + if (!scumm_stricmp(g->gameid, gameid)) + _gameId = g->id; +*/ + + _rnd = new Common::RandomSource(); + + Common::addSpecialDebugLevel(kDebugLevelMain, "Main", "Generic debug level"); + Common::addSpecialDebugLevel(kDebugLevelResources, "Resources", "Resources debugging"); + Common::addSpecialDebugLevel(kDebugLevelSprites, "Sprites", "Sprites debugging"); + Common::addSpecialDebugLevel(kDebugLevelInventory, "Inventory", "Inventory debugging"); + Common::addSpecialDebugLevel(kDebugLevelInput, "Input", "Input events debugging"); + Common::addSpecialDebugLevel(kDebugLevelMenu, "Menu", "Menu debugging"); + Common::addSpecialDebugLevel(kDebugLevelScripts, "Scripts", "Scripts debugging"); + Common::addSpecialDebugLevel(kDebugLevelSound, "Sound", "Sound debugging"); + Common::addSpecialDebugLevel(kDebugLevelText, "Text", "Text output debugging"); + Common::addSpecialDebugLevel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); + + memset(&_game, 0, sizeof(struct AgiGame)); + memset(&_debug, 0, sizeof(struct AgiDebug)); + memset(&g_mouse, 0, sizeof(struct Mouse)); + +/* + _game.clockEnabled = false; + _game.state = STATE_INIT; + + _keyQueueStart = 0; + _keyQueueEnd = 0; + + _keyControl = 0; + _keyAlt = 0; + + _allowSynthetic = false; + + g_tickTimer = 0; + + _intobj = NULL; + + _stackSize = 0; + _imageStack = NULL; + _imageStackPointer = 0; + + _menu = NULL; + + _lastSentence[0] = 0; + memset(&_stringdata, 0, sizeof(struct StringData)); + + _objects = NULL; + + _oldMode = -1; + + _predictiveDialogRunning = false; + _predictiveDictText = NULL; + _predictiveDictLine = NULL; + _predictiveDictLineCount = 0; + _firstSlot = 0; +*/ +} + +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". + + // If used platform is Apple IIGS then we must use Apple IIGS sound emulation + // because Apple IIGS AGI games use only Apple IIGS specific sound resources. + /* + if (ConfMan.hasKey("platform") && + Common::parsePlatform(ConfMan.get("platform")) == Common::kPlatformApple2GS) { + _soundemu = SOUND_EMU_APPLE2GS; + } else { + switch (MidiDriver::detectMusicDriver(MDT_PCSPK)) { + case MD_PCSPK: + _soundemu = SOUND_EMU_PC; + break; + default: + _soundemu = SOUND_EMU_NONE; + break; + } + } + */ + + 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; + } + } + + //_buttonStyle = AgiButtonStyle(_renderMode); + //_defaultButtonStyle = AgiButtonStyle(); + //_console = new Console(this); + _gfx = new GfxMgr(this); + //_sound = new SoundMgr(this, _mixer); + _picture = new PictureMgr(this, _gfx); + //_sprites = new SpritesMgr(this, _gfx); + + _gfx->initMachine(); + + _game.gameFlags = 0; + + _game.colorFg = 15; + _game.colorBg = 0; + + _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 + + _game.lineMinPrint = 1; // hardcoded + + _gfx->initVideo(); + //_sound->initSound(); + + //_timer->installTimerProc(agiTimerFunctionLow, 10 * 1000, NULL); + + _game.ver = -1; // Don't display the conf file warning + + debugC(2, kDebugLevelMain, "Detect game"); + + _loader = new AgiLoader_preagi(this); + + if (_loader->detectGame() == errOK) { + _game.state = STATE_LOADED; + debugC(2, kDebugLevelMain, "game loaded"); + } else { + report("Could not open PreAGI game"); + } + + /* clear all resources and events */ + for (int i = 0; i < MAX_DIRS; i++) { + //memset(&_game.views[i], 0, sizeof(struct AgiView)); + memset(&_game.pictures[i], 0, sizeof(struct AgiPicture)); + //memset(&_game.logics[i], 0, sizeof(struct AgiLogic)); + //memset(&_game.sounds[i], 0, sizeof(class AgiSound *)); // _game.sounds contains pointers now + //memset(&_game.dirView[i], 0, sizeof(struct AgiDir)); + memset(&_game.dirPic[i], 0, sizeof(struct AgiDir)); + //memset(&_game.dirLogic[i], 0, sizeof(struct AgiDir)); + //memset(&_game.dirSound[i], 0, sizeof(struct AgiDir)); + } + + // load resources + _loader->init(); + + debugC(2, kDebugLevelMain, "Init sound"); +} + +PreAgiEngine::~PreAgiEngine() { + +} + +int PreAgiEngine::init() { + + // Detect game + if (!initGame()) { + GUIErrorMessage("No valid games were found in the specified directory."); + return -1; + } + + // Initialize backend + _system->beginGFXTransaction(); + initCommonGFX(false); + _system->initSize(320, 200); + _system->endGFXTransaction(); + + initialize(); + + _gfx->gfxSetPalette(); + + return 0; +} + +int PreAgiEngine::go() { + // run preagi engine main loop + switch (getGameID()) { + case GID_MICKEY: + { + Mickey *mickey = new Mickey(this); + mickey->init(); + mickey->run(); + } + break; + default: + error("Unknown preagi engine"); + break; + } + return 0; +} + +int PreAgiEngine::preAgiLoadResource(int r, int n) { + return _loader->loadResource(r, n); +} + +int PreAgiEngine::preAgiUnloadResource(int r, int n) { + return _loader->unloadResource(r, n); +} + +} // End of namespace Agi |