diff options
author | James Brown | 2004-10-15 06:06:47 +0000 |
---|---|---|
committer | James Brown | 2004-10-15 06:06:47 +0000 |
commit | 8f65711a28b0cdedca29cdd1787b40546d448575 (patch) | |
tree | feafc61c0bdbd529ef1eb52acf743033395f3547 /kyra/kyra.cpp | |
parent | 9e40ef7d29ccaca45708b39e1da92bbca088d6ac (diff) | |
download | scummvm-rg350-8f65711a28b0cdedca29cdd1787b40546d448575.tar.gz scummvm-rg350-8f65711a28b0cdedca29cdd1787b40546d448575.tar.bz2 scummvm-rg350-8f65711a28b0cdedca29cdd1787b40546d448575.zip |
Merge in some of LordHotos kyra code, with some changes.
It's still non-functional, but once I merge in some more of my local changes things should actually be moving a long a bit.
svn-id: r15554
Diffstat (limited to 'kyra/kyra.cpp')
-rw-r--r-- | kyra/kyra.cpp | 142 |
1 files changed, 121 insertions, 21 deletions
diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index b7875cb76a..a1ae6449c2 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -1,5 +1,5 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2003 The ScummVM project +/* ScummVM - Kyrandia Interpreter + * Copyright (C) 2003-2004 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -8,7 +8,7 @@ * 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 + * 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 @@ -28,35 +28,58 @@ #include "sound/mixer.h" #include "common/file.h" #include "common/config-manager.h" -#include "kyra.h" -static const GameSettings kyra_setting = - { "kyra", "Legend of Kyrandia", 0 }; +#include "kyra.h" +#include "resource.h" +#include "script.h" + +struct KyraGameSettings { + const char *name; + const char *description; + uint32 features; + const char *detectName; + GameSettings toGameSettings() const { + GameSettings dummy = { name, description, features }; + return dummy; + } +}; + +static const KyraGameSettings kyra_settings[] = { + {"kyra1cd", "Legend of Kyrandia (CD)", GF_TALKIE & GF_KYRA1, "CHAPTER1.VRM"}, + {"kyra1", "Legend of Kyrandia (Floppy)", GF_FLOPPY & GF_KYRA1, "INTRO.SND"}, + { 0, 0, 0, 0} +}; GameList Engine_KYRA_gameList() { GameList games; + const KyraGameSettings *g = kyra_settings; + + while (g->name) { + games.push_back(g->toGameSettings()); + g++; + } - games.push_back(kyra_setting); return games; } -// TODO: Improve this :) DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) { + const KyraGameSettings *game; DetectedGameList detectedGames; - File test_file; - - // Iterate over all files in the given directory - for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { - const char *name = file->displayName().c_str(); - if ((0 == scumm_stricmp("chapter1.vrm", name)) || - (0 == scumm_stricmp("chapter5.vrm", name))) { - detectedGames.push_back(kyra_setting); - printf("Detecting Kyra...\n"); - break; + + for (game = kyra_settings; game->name; ++game) { + if (game->detectName == NULL) + continue; + + for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { + const char *name = file->displayName().c_str(); + if ((!scumm_stricmp(game->detectName, name))) { + detectedGames.push_back(game->toGameSettings()); + break; + } } } - return detectedGames; + return detectedGames; } Engine *Engine_KYRA_create(GameDetector *detector, OSystem *syst) { @@ -78,11 +101,37 @@ KyraEngine::KyraEngine(GameDetector *detector, OSystem *syst) //getGameDataPath(); - // Initialize backend - syst->initSize(320, 240); + // Initialize backen + syst->initSize(320, 200); + _screen = new uint8[320*200]; + memset((void*)_screen, 0, sizeof(_screen)); + + _resMgr = new Resourcemanager(this, getGameDataPath()); + assert(_resMgr); + + setCurrentPalette(_resMgr->loadPalette("PALETTE.COL")); + + // loads the 2 cursors + _mouse = _resMgr->loadImage("MOUSE.CPS"); //startup.pak + _items = _resMgr->loadImage("ITEMS.CPS"); + + // loads the Font + _font = _resMgr->loadFont("8FAT.FNT"); + printf("loading scripts\n"); + // loads out scripts + _npcScript = _resMgr->loadScript("_NPC.EMC"); + _currentScript = _resMgr->loadScript("_STARTUP.EMC"); + printf("done\n"); + } KyraEngine::~KyraEngine() { + delete _resMgr; + delete _mouse; + delete _items; + delete _npcScript; + delete _currentScript; + delete _font; } void KyraEngine::errorString(const char *buf1, char *buf2) { @@ -91,10 +140,61 @@ void KyraEngine::errorString(const char *buf1, char *buf2) { void KyraEngine::go() { warning("Kyrandia Engine ::go()"); + // starts the init script + if (!_currentScript->startScript(kSetupScene)) { + error("couldn't init '_STARTUP.EMC' script"); + } + + if (_currentScript->contScript() != kScriptStopped) { + if (_currentScript->state() == kScriptError) { + error("couldn't run script"); + } else { + warning("init script returned: %d", _currentScript->state()); + } + } + + while(true) { + OSystem::Event event; + //if (_debugger->isAttached()) + // _debugger->onFrame(); + + updateScreen(); + while (g_system->pollEvent(event)) { + switch (event.event_code) { + case OSystem::EVENT_QUIT: + g_system->quit(); + break; + default: + break; + } + } + _system->delayMillis(10); + } } void KyraEngine::shutdown() { _system->quit(); } + +void KyraEngine::updateScreen(void) { + _system->copyRectToScreen(_screen, 320, 0, 0, 320, 240); + _system->updateScreen(); +} + +void KyraEngine::setCurrentPalette(Palette* pal, bool delNextTime) { +// if (_delPalNextTime) +// delete _currentPal; + +// _delPalNextTime = delNextTime; + +// _currentPal = pal; + + if (pal->getData()) { + _system->setPalette(pal->getData(), 0, 256); + } else { + warning("palette contains no data"); + } +} + } // End of namespace KYRA |