diff options
Diffstat (limited to 'engines/prince')
-rw-r--r-- | engines/prince/archive.h | 1 | ||||
-rw-r--r-- | engines/prince/debugger.cpp | 46 | ||||
-rw-r--r-- | engines/prince/debugger.h | 19 | ||||
-rw-r--r-- | engines/prince/detection.cpp | 292 | ||||
-rw-r--r-- | engines/prince/flags.cpp | 406 | ||||
-rw-r--r-- | engines/prince/flags.h | 416 | ||||
-rw-r--r-- | engines/prince/font.cpp | 58 | ||||
-rw-r--r-- | engines/prince/font.h | 28 | ||||
-rw-r--r-- | engines/prince/graphics.cpp | 51 | ||||
-rw-r--r-- | engines/prince/graphics.h | 23 | ||||
-rw-r--r-- | engines/prince/mhwanh.cpp | 56 | ||||
-rw-r--r-- | engines/prince/mhwanh.h | 28 | ||||
-rw-r--r-- | engines/prince/mob.cpp | 65 | ||||
-rw-r--r-- | engines/prince/mob.h | 53 | ||||
-rw-r--r-- | engines/prince/module.mk | 41 | ||||
-rw-r--r-- | engines/prince/musNum.h | 87 | ||||
-rw-r--r-- | engines/prince/object.cpp | 78 | ||||
-rw-r--r-- | engines/prince/object.h | 48 | ||||
-rw-r--r-- | engines/prince/prince.cpp | 790 | ||||
-rw-r--r-- | engines/prince/prince.h | 255 | ||||
-rw-r--r-- | engines/prince/script.cpp | 1127 | ||||
-rw-r--r-- | engines/prince/script.h | 381 | ||||
-rw-r--r-- | engines/prince/sound.cpp | 216 | ||||
-rw-r--r-- | engines/prince/sound.h | 73 | ||||
-rw-r--r-- | engines/prince/variatxt.cpp | 59 | ||||
-rw-r--r-- | engines/prince/variatxt.h | 44 |
26 files changed, 3523 insertions, 1218 deletions
diff --git a/engines/prince/archive.h b/engines/prince/archive.h index 3f5c5be4ef..8e106693dc 100644 --- a/engines/prince/archive.h +++ b/engines/prince/archive.h @@ -25,6 +25,7 @@ #include "common/archive.h" +// This is here just as remainder that archive support is missing namespace Price { class Archive : public Common::Archive { diff --git a/engines/prince/debugger.cpp b/engines/prince/debugger.cpp index 5da11acd88..be9677b99f 100644 --- a/engines/prince/debugger.cpp +++ b/engines/prince/debugger.cpp @@ -27,10 +27,13 @@ namespace Prince { Debugger::Debugger(PrinceEngine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit)); + DCmd_Register("level", WRAP_METHOD(Debugger, Cmd_DebugLevel)); DCmd_Register("setflag", WRAP_METHOD(Debugger, Cmd_SetFlag)); DCmd_Register("getflag", WRAP_METHOD(Debugger, Cmd_GetFlag)); DCmd_Register("clearflag", WRAP_METHOD(Debugger, Cmd_ClearFlag)); DCmd_Register("viewflc", WRAP_METHOD(Debugger, Cmd_ViewFlc)); + DCmd_Register("initroom", WRAP_METHOD(Debugger, Cmd_InitRoom)); + DCmd_Register("changecursor", WRAP_METHOD(Debugger, Cmd_ChangeCursor)); } static int strToInt(const char *s) { @@ -49,6 +52,22 @@ static int strToInt(const char *s) { return (int)tmp; } +bool Debugger::Cmd_DebugLevel(int argc, const char **argv) { + if (argc == 1) { + DebugPrintf("Debugging is currently set at level %d\n", gDebugLevel); + } else { // set level + gDebugLevel = atoi(argv[1]); + if (0 <= gDebugLevel && gDebugLevel < 11) { + DebugPrintf("Debug level set to level %d\n", gDebugLevel); + } else if (gDebugLevel < 0) { + DebugPrintf("Debugging is now disabled\n"); + } else + DebugPrintf("Not a valid debug level (0 - 10)\n"); + } + + return true; +} + /* * This command sets a flag */ @@ -105,7 +124,32 @@ bool Debugger::Cmd_ViewFlc(int argc, const char **argv) { } int flagNum = strToInt(argv[1]); - _vm->loadAnim(flagNum); + _vm->loadAnim(flagNum, false); return true; } + +bool Debugger::Cmd_InitRoom(int argc, const char **argv) { + // Check for a flag to clear + if (argc != 2) { + DebugPrintf("Usage: %s <anim number>\n", argv[0]); + return true; + } + + int flagNum = strToInt(argv[1]); + _vm->loadLocation(flagNum); + return true; +} + +bool Debugger::Cmd_ChangeCursor(int argc, const char **argv) { + // Check for a flag to clear + if (argc != 2) { + DebugPrintf("Usage: %s <curId>\n", argv[0]); + return true; + } + + int flagNum = strToInt(argv[1]); + _vm->changeCursor(flagNum); + return true; +} + } diff --git a/engines/prince/debugger.h b/engines/prince/debugger.h index c5a8be60c6..08b1676fd7 100644 --- a/engines/prince/debugger.h +++ b/engines/prince/debugger.h @@ -32,16 +32,19 @@ class PrinceEngine; class Debugger : public GUI::Debugger { public: - Debugger(PrinceEngine *vm); - virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ + Debugger(PrinceEngine *vm); + virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ private: - bool Cmd_SetFlag(int argc, const char **argv); - bool Cmd_GetFlag(int argc, const char **argv); - bool Cmd_ClearFlag(int argc, const char **argv); - bool Cmd_ViewFlc(int argc, const char **argv); - - PrinceEngine *_vm; + bool Cmd_DebugLevel(int argc, const char **argv); + bool Cmd_SetFlag(int argc, const char **argv); + bool Cmd_GetFlag(int argc, const char **argv); + bool Cmd_ClearFlag(int argc, const char **argv); + bool Cmd_ViewFlc(int argc, const char **argv); + bool Cmd_InitRoom(int argc, const char **argv); + bool Cmd_ChangeCursor(int argc, const char **argv); + + PrinceEngine *_vm; }; diff --git a/engines/prince/detection.cpp b/engines/prince/detection.cpp index c5f6039ca1..fa9df38c90 100644 --- a/engines/prince/detection.cpp +++ b/engines/prince/detection.cpp @@ -1,145 +1,147 @@ -/* 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 "base/plugins.h"
-#include "engines/advancedDetector.h"
-
-#include "prince/prince.h"
-
-namespace Prince {
-
-struct PrinceGameDescription {
- ADGameDescription desc;
-
- int gameType;
-};
-
-int PrinceEngine::getGameType() const {
- return _gameDescription->gameType;
-}
-
-const char *PrinceEngine::getGameId() const {
- return _gameDescription->desc.gameid;
-}
-
-uint32 PrinceEngine::getFeatures() const {
- return _gameDescription->desc.flags;
-}
-
-Common::Language PrinceEngine::getLanguage() const {
- return _gameDescription->desc.language;
-}
-
-}
-
-static const PlainGameDescriptor princeGames[] = {
- {"prince", "Prince Game"},
- {0, 0}
-};
-
-namespace Prince {
-
-static const PrinceGameDescription gameDescriptions[] = {
-
- // German
- {
- {
- "prince",
- "Galador",
- AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031),
- Common::DE_DEU,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
- },
- 0
- },
- // Polish
- {
- {
- "prince",
- "Ksiaze i Tchorz",
- AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298),
- Common::PL_POL,
- Common::kPlatformWindows,
- ADGF_NO_FLAGS,
- GUIO1(GUIO_NONE)
- },
- 1
- },
-
-
- { AD_TABLE_END_MARKER, 0 }
-};
-
-} // End of namespace Prince
-
-using namespace Prince;
-
-// we match from data too, to stop detection from a non-top-level directory
-const static char *directoryGlobs[] = {
- "all",
- 0
-};
-
-class PrinceMetaEngine : public AdvancedMetaEngine {
-public:
- PrinceMetaEngine() : AdvancedMetaEngine(Prince::gameDescriptions, sizeof(Prince::PrinceGameDescription), princeGames) {
- _singleid = "prince";
- _maxScanDepth = 2;
- _directoryGlobs = directoryGlobs;
- }
-
- virtual const char *getName() const {
- return "Prince Engine";
- }
-
- virtual const char *getOriginalCopyright() const {
- return "Copyright (C)";
- }
-
- virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
- virtual bool hasFeature(MetaEngineFeature f) const;
-};
-
-bool PrinceMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
- using namespace Prince;
- const PrinceGameDescription *gd = (const PrinceGameDescription *)desc;
- if (gd) {
- *engine = new PrinceEngine(syst, gd);
- }
- return gd != 0;
-}
-
-bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const {
- return false;
-}
-
-bool Prince::PrinceEngine::hasFeature(EngineFeature f) const {
- return false;//(f == kSupportsRTL);
-}
-
-#if PLUGIN_ENABLED_DYNAMIC(PRINCE)
-REGISTER_PLUGIN_DYNAMIC(PRINCE, PLUGIN_TYPE_ENGINE, PrinceMetaEngine);
-#else
-REGISTER_PLUGIN_STATIC(PRINCE, PLUGIN_TYPE_ENGINE, PrinceMetaEngine);
-#endif
+/* 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 "base/plugins.h" +#include "engines/advancedDetector.h" + +#include "prince/prince.h" + +namespace Prince { + +struct PrinceGameDescription { + ADGameDescription desc; + + int gameType; +}; + +int PrinceEngine::getGameType() const { + return _gameDescription->gameType; +} + +const char *PrinceEngine::getGameId() const { + return _gameDescription->desc.gameid; +} + +uint32 PrinceEngine::getFeatures() const { + return _gameDescription->desc.flags; +} + +Common::Language PrinceEngine::getLanguage() const { + return _gameDescription->desc.language; +} + +} + +static const PlainGameDescriptor princeGames[] = { + {"prince", "Prince Game"}, + {0, 0} +}; + +namespace Prince { + +static const PrinceGameDescription gameDescriptions[] = { + + // German + { + { + "prince", + "Galador", + AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + 0 + }, + // Polish + { + { + "prince", + "Ksiaze i Tchorz", + AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298), + Common::PL_POL, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + 1 + }, + + + { AD_TABLE_END_MARKER, 0 } +}; + +} // End of namespace Prince + +using namespace Prince; + +// we match from data too, to stop detection from a non-top-level directory +const static char *directoryGlobs[] = { + "all", + 0 +}; + +class PrinceMetaEngine : public AdvancedMetaEngine { +public: + PrinceMetaEngine() : AdvancedMetaEngine(Prince::gameDescriptions, sizeof(Prince::PrinceGameDescription), princeGames) { + _singleid = "prince"; + _maxScanDepth = 2; + _directoryGlobs = directoryGlobs; + } + + virtual const char *getName() const { + return "Prince Engine"; + } + + virtual const char *getOriginalCopyright() const { + return "Copyright (C)"; + } + + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual bool hasFeature(MetaEngineFeature f) const; +}; + +bool PrinceMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + using namespace Prince; + const PrinceGameDescription *gd = (const PrinceGameDescription *)desc; + if (gd) { + *engine = new PrinceEngine(syst, gd); + } + return gd != 0; +} + +bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const { + return false; +} + +bool Prince::PrinceEngine::hasFeature(EngineFeature f) const { + return false;//(f == kSupportsRTL); +} + +#if PLUGIN_ENABLED_DYNAMIC(PRINCE) +REGISTER_PLUGIN_DYNAMIC(PRINCE, PLUGIN_TYPE_ENGINE, PrinceMetaEngine); +#else +REGISTER_PLUGIN_STATIC(PRINCE, PLUGIN_TYPE_ENGINE, PrinceMetaEngine); +#endif + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/flags.cpp b/engines/prince/flags.cpp new file mode 100644 index 0000000000..d6d577a575 --- /dev/null +++ b/engines/prince/flags.cpp @@ -0,0 +1,406 @@ +/* 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 "prince/flags.h" + +namespace Prince { + +const char * Flags::getFlagName(uint16 flagId) +{ + switch (flagId) { + default: return "unknown_flag"; + case FLAGA1: return "FLAGA1"; + case FLAGA2: return "FLAGA2"; + case FLAGA3: return "FLAGA3"; + case DESTX: return "DESTX"; + case DESTY: return "DESTY"; + case DESTD: return "DESTD"; + case DwarfDone: return "DwarfDone"; + case GRABARZCOUNTER: return "GRABARZCOUNTER"; + case KIERUNEK: return "KIERUNEK"; + case BACKFLAG1: return "BACKFLAG1"; + case BACKFLAG2: return "BACKFLAG2"; + case BACKFLAG3: return "BACKFLAG3"; + case BACKFLAG4: return "BACKFLAG4"; + case MACROFLAG1: return "MACROFLAG1"; + case MACROFLAG2: return "MACROFLAG2"; + case MACROFLAG3: return "MACROFLAG3"; + case HEROLDDONE: return "HEROLDDONE"; + case BRIDGESET: return "BRIDGESET"; + case U_BT_1: return "U_BT_1"; + case U_BT_2: return "U_BT_2"; + case U_BT_3: return "U_BT_3"; + case U_BT_4: return "U_BT_4"; + case U_BT_5: return "U_BT_5"; + case U_BT_6: return "U_BT_6"; + case U_BT_7: return "U_BT_7"; + case U_BT_8: return "U_BT_8"; + case U_BT_9: return "U_BT_9"; + case U_BT_COUNTER: return "U_BT_COUNTER"; + case ARIVALDALIVE: return "ARIVALDALIVE"; + case TALKCHAR1: return "TALKCHAR1"; + case TalkType1: return "TalkType1"; + case TALKROUT1: return "TALKROUT1"; + case TALKROUT2: return "TALKROUT2"; + case TALKROUT3: return "TALKROUT3"; + case TALKROUT4: return "TALKROUT4"; + case TALKANIM1: return "TALKANIM1"; + case TALKANIM2: return "TALKANIM2"; + case TALKCOLOR1: return "TALKCOLOR1"; + case TALKCOLOR2: return "TALKCOLOR2"; + case KapciuchTaken: return "KapciuchTaken"; + case CurrentBeggarA: return "CurrentBeggarA"; + case TempKapc: return "TempKapc"; + case HomTaken: return "HomTaken"; + case WizardTalk: return "WizardTalk"; + case SunlordTalk: return "SunlordTalk"; + case HermitTalk: return "HermitTalk"; + case RunyMode: return "RunyMode"; + case FatMerchantTalk: return "FatMerchantTalk"; + case HotDogTalk: return "HotDogTalk"; + case ThiefTalk: return "ThiefTalk"; + case BeggarTalk: return "BeggarTalk"; + case MonkTalk: return "MonkTalk"; + case BardTalk: return "BardTalk"; + case BarmanTalk: return "BarmanTalk"; + case LeftPlayerTalk: return "LeftPlayerTalk"; + case OczySowy: return "OczySowy"; + case CzachySpeed1: return "CzachySpeed1"; + case CzachySpeed2: return "CzachySpeed2"; + case CzachySpeed3: return "CzachySpeed3"; + case CzachySlowDown1: return "CzachySlowDown1"; + case CzachySlowDown2: return "CzachySlowDown2"; + case CzachySlowDown3: return "CzachySlowDown3"; + case FjordDane: return "FjordDane"; + case GKopany1: return "GKopany1"; + case GKopany2: return "GKopany2"; + case GKopany3: return "GKopany3"; + case GKopany4: return "GKopany4"; + case KnowGodWord: return "KnowGodWord"; + case TALKROUT21: return "TALKROUT21"; + case TALKROUT22: return "TALKROUT22"; + case TALKROUT23: return "TALKROUT23"; + case TALKROUT24: return "TALKROUT24"; + case TalkType2: return "TalkType2"; + case GrabarzTalk: return "GrabarzTalk"; + case LastTalker: return "LastTalker"; + case MapaPustelniaEnabled: return "MapaPustelniaEnabled"; + case MapaTempleEnabled: return "MapaTempleEnabled"; + case MapaFjordEnabled: return "MapaFjordEnabled"; + case MapaSilmanionaEnabled: return "MapaSilmanionaEnabled"; + case MapaKurhanEnabled: return "MapaKurhanEnabled"; + case MapaDragonEnabled: return "MapaDragonEnabled"; + case MapaMillEnabled: return "MapaMillEnabled"; + case DwarfRunning: return "DwarfRunning"; + case DwarfTalk: return "DwarfTalk"; + case CurseLift: return "CurseLift"; + case KosciSwapped: return "KosciSwapped"; + case BookStolen: return "BookStolen"; + case MapaUsable: return "MapaUsable"; + case FjordBoss: return "FjordBoss"; + case FjordHotDog: return "FjordHotDog"; + case FjordLewy: return "FjordLewy"; + case FjordPrawy: return "FjordPrawy"; + case TalkArivald: return "TalkArivald"; + case ShootDone: return "ShootDone"; + case ShootRunning: return "ShootRunning"; + case ShootKnow: return "ShootKnow"; + case MirrorKnow: return "MirrorKnow"; + case Gar1stTime: return "Gar1stTime"; + case KosciTaken: return "KosciTaken"; + case ArivGotSpell: return "ArivGotSpell"; + case BookGiven: return "BookGiven"; + case Wywieszka: return "Wywieszka"; + case TalkSheila: return "TalkSheila"; + case TalkSheila2: return "TalkSheila2"; + case BackHuman: return "BackHuman"; + case SkarbiecOpen: return "SkarbiecOpen"; + case LustroTaken: return "LustroTaken"; + case GargoyleHom: return "GargoyleHom"; + case GargoyleBroken: return "GargoyleBroken"; + case FjordDzien: return "FjordDzien"; + case GargoyleHom2: return "GargoyleHom2"; + case RunMonstersRunning: return "RunMonstersRunning"; + case FoundPaperInCoffin: return "FoundPaperInCoffin"; + case KnowSunlord: return "KnowSunlord"; + case KnowSunlordTalk: return "KnowSunlordTalk"; + case ArivaldCzyta: return "ArivaldCzyta"; + case TelepX: return "TelepX"; + case TelepY: return "TelepY"; + case TelepDir: return "TelepDir"; + case TelepRoom: return "TelepRoom"; + case ListStolen: return "ListStolen"; + case WifeInDoor: return "WifeInDoor"; + case TalkWifeFlag: return "TalkWifeFlag"; + case LetterGiven: return "LetterGiven"; + case LutniaTaken: return "LutniaTaken"; + case BardHomeOpen: return "BardHomeOpen"; + case FjordNoMonsters: return "FjordNoMonsters"; + case ShandriaWallTalking: return "ShandriaWallTalking"; + case ShandriaWallCounter: return "ShandriaWallCounter"; + case ShandriaWallDone: return "ShandriaWallDone"; + case FutureDone: return "FutureDone"; + case TalkButch: return "TalkButch"; + case GotSzalik: return "GotSzalik"; + case GotCzosnek: return "GotCzosnek"; + case BearDone: return "BearDone"; + case NekrVisited: return "NekrVisited"; + case SunRiddle: return "SunRiddle"; + case PtaszekAway: return "PtaszekAway"; + case KotGadanie: return "KotGadanie"; + case SzlafmycaTaken: return "SzlafmycaTaken"; + case BabkaTalk: return "BabkaTalk"; + case SellerTalk: return "SellerTalk"; + case CzosnekDone: return "CzosnekDone"; + case PriestCounter: return "PriestCounter"; + case PriestGest1: return "PriestGest1"; + case PriestGest2: return "PriestGest2"; + case PriestGest3: return "PriestGest3"; + case PriestGest4: return "PriestGest4"; + case PriestAnim: return "PriestAnim"; + case HolyWaterTaken: return "HolyWaterTaken"; + case AxeTaken: return "AxeTaken"; + case BadylTaken1: return "BadylTaken1"; + case BadylTaken2: return "BadylTaken2"; + case BadylSharpened: return "BadylSharpened"; + case PorwanieSmoka: return "PorwanieSmoka"; + case ShopReOpen: return "ShopReOpen"; + case LuskaShown: return "LuskaShown"; + case CudKnow: return "CudKnow"; + case VampireDead: return "VampireDead"; + case MapaVisible1: return "MapaVisible1"; + case MapaVisible2: return "MapaVisible2"; + case MapaVisible3: return "MapaVisible3"; + case MapaVisible4: return "MapaVisible4"; + case MapaVisible5: return "MapaVisible5"; + case MapaVisible6: return "MapaVisible6"; + case MapaVisible7: return "MapaVisible7"; + case MapaVisible8: return "MapaVisible8"; + case MapaVisible9: return "MapaVisible9"; + case MapaX: return "MapaX"; + case MapaY: return "MapaY"; + case MapaD: return "MapaD"; + case OldMapaX: return "OldMapaX"; + case OldMapaY: return "OldMapaY"; + case OldMapaD: return "OldMapaD"; + case MovingBack: return "MovingBack"; + case MapaCount: return "MapaCount"; + case Pustelnia1st: return "Pustelnia1st"; + case CzarnePole1st: return "CzarnePole1st"; + case TalkArivNum: return "TalkArivNum"; + case Pfui: return "Pfui"; + case MapaSunlordEnabled:return "MapaSunlordEnabled"; + case WebDone: return "WebDone"; + case DragonDone: return "DragonDone"; + case KanPlay: return "KanPlay"; + case OldKanPlay: return "OldKanPlay"; + case LapkiWait: return "LapkiWait"; + case WebNoCheck: return "WebNoCheck"; + case Perfumeria: return "Perfumeria"; + case SmokNoCheck: return "SmokNoCheck"; + case IluzjaBroken: return "IluzjaBroken"; + case IluzjaWorking: return "IluzjaWorking"; + case IluzjaCounter: return "IluzjaCounter"; + case KurhanOpen1: return "KurhanOpen1"; + case KastetTaken: return "KastetTaken"; + case KastetDown: return "KastetDown"; + case KurhanDone: return "KurhanDone"; + case SkelCounter: return "SkelCounter"; + case SkelDial1: return "SkelDial1"; + case SkelDial2: return "SkelDial2"; + case SkelDial3: return "SkelDial3"; + case SkelDial4: return "SkelDial4"; + case SameTalker: return "SameTalker"; + case RunMonstersText: return "RunMonstersText"; + case PiwnicaChecked: return "PiwnicaChecked"; + case DragonTalked: return "DragonTalked"; + case ToldAboutBook: return "ToldAboutBook"; + case SilmanionaDone: return "SilmanionaDone"; + case ToldBookCount: return "ToldBookCount"; + case SmrodNoCheck: return "SmrodNoCheck"; + case RopeTaken: return "RopeTaken"; + case RopeTime: return "RopeTime"; + case LaskaFree: return "LaskaFree"; + case ShanSmokTalked: return "ShanSmokTalked"; + case SwordTaken: return "SwordTaken"; + case Mill1st: return "Mill1st"; + case SawRat: return "SawRat"; + case KnowRat: return "KnowRat"; + case DziuraTimer: return "DziuraTimer"; + case LaskaInside: return "LaskaInside"; + case HoleBig: return "HoleBig"; + case EnableWiedzmin: return "EnableWiedzmin"; + case EnableTrucizna: return "EnableTrucizna"; + case KnowPoison: return "KnowPoison"; + case KufelTaken: return "KufelTaken"; + case BojkaEnabled: return "BojkaEnabled"; + case BitwaNot1st: return "BitwaNot1st"; + case BojkaTimer: return "BojkaTimer"; + case BojkaGirl: return "BojkaGirl"; + case Look1st: return "Look1st"; + case RatTaken: return "RatTaken"; + case LaskaTalkedGr: return "LaskaTalkedGr"; + case RatusGivus: return "RatusGivus"; + case MamObole: return "MamObole"; + case Speed1st: return "Speed1st"; + case SpeedTimer: return "SpeedTimer"; + case ProveIt: return "ProveIt"; + case Proven: return "Proven"; + case ShowWoalka: return "ShowWoalka"; + case PoisonTaken: return "PoisonTaken"; + case HellOpened: return "HellOpened"; + case HellNoCheck: return "HellNoCheck"; + case TalAn1: return "TalAn1"; + case TalAn2: return "TalAn2"; + case TalAn3: return "TalAn3"; + case TalkDevilGuard: return "TalkDevilGuard"; + case Sword1st: return "Sword1st"; + case IluzjaNoCheck: return "IluzjaNoCheck"; + case RozdzielniaNumber: return "RozdzielniaNumber"; + case JailChecked: return "JailChecked"; + case JailTalked: return "JailTalked"; + case TrickFailed: return "TrickFailed"; + case WegielVisible: return "WegielVisible"; + case WegielTimer1: return "WegielTimer1"; + case RandomSample: return "RandomSample"; + case RandomSampleTimer: return "RandomSampleTimer"; + case SampleTimer: return "SampleTimer"; + case ZonaSample: return "ZonaSample"; + case HoleTryAgain: return "HoleTryAgain"; + case TeleportTimer: return "TeleportTimer"; + case RozLezy: return "RozLezy"; + case UdkoTimer: return "UdkoTimer"; + case ZaworZatkany: return "ZaworZatkany"; + case ZaworOpened: return "ZaworOpened"; + case DoorExploded: return "DoorExploded"; + case SkoraTaken: return "SkoraTaken"; + case CiezkieByl: return "CiezkieByl"; + case MamWegiel: return "MamWegiel"; + case SwiecaAway: return "SwiecaAway"; + case ITSAVE: return "ITSAVE"; + case RozpadlSie: return "RozpadlSie"; + case WegielFullTimer: return "WegielFullTimer"; + case WegielDown: return "WegielDown"; + case WegielDownTimer: return "WegielDownTimer"; + case PaliSie: return "PaliSie"; + case DiabGuardTalked: return "DiabGuardTalked"; + case GuardsNoCheck: return "GuardsNoCheck"; + case TalkedPowloka: return "TalkedPowloka"; + case JailOpen: return "JailOpen"; + case PrzytulTimer: return "PrzytulTimer"; + case JailDone: return "JailDone"; + case MamMonety: return "MamMonety"; + case LotTimer: return "LotTimer"; + case LotObj: return "LotObj"; + case PtakTimer: return "PtakTimer"; + case BookTimer: return "BookTimer"; + case BookGiba: return "BookGiba"; + case PtakLata: return "PtakLata"; + case Podej: return "Podej"; + case GotHint: return "GotHint"; + case LawaLeci: return "LawaLeci"; + case PowerKlik: return "PowerKlik"; + case LucekBad: return "LucekBad"; + case LucekBad1st: return "LucekBad1st"; + case IntroDial1: return "IntroDial1"; + case IntroDial2: return "IntroDial2"; + case ItsOutro: return "ItsOutro"; + case KamienComment: return "KamienComment"; + case KamienSkip: return "KamienSkip"; + case TesterFlag: return "TesterFlag"; + case RememberLine: return "RememberLine"; + case OpisLapek: return "OpisLapek"; + case TalWait: return "TalWait"; + case OpisKamienia: return "OpisKamienia"; + case JumpBox: return "JumpBox"; + case JumpBox1: return "JumpBox1"; + case JumpBox2: return "JumpBox2"; + case JumpBox3: return "JumpBox3"; + case SpecPiesek: return "SpecPiesek"; + case SpecPiesekCount: return "SpecPiesekCount"; + case SpecPiesekGadanie: return "SpecPiesekGadanie"; + case ZnikaFlag: return "ZnikaFlag"; + case ZnikaTimer: return "ZnikaTimer"; + case SowaTimer: return "SowaTimer"; + case MamrotanieOff: return "MamrotanieOff"; + + case CURRMOB: return "CURRMOB"; + case KOLOR: return "KOLOR"; + case MBFLAG: return "MBFLAG"; + case MXFLAG: return "MXFLAG"; + case MYFLAG: return "MYFLAG"; + case SCROLLTYPE: return "SCROLLTYPE"; + case SCROLLVALUE: return "SCROLLVALUE"; + case SCROLLVALUE2: return "SCROLLVALUE2"; + case TALKEXITCODE: return "TALKEXITCODE"; + case SPECROUTFLAG1: return "SPECROUTFLAG1"; + case SPECROUTFLAG2: return "SPECROUTFLAG2"; + case SPECROUTFLAG3: return "SPECROUTFLAG3"; + case TALKFLAGCODE: return "TALKFLAGCODE"; + case CURRROOM: return "CURRROOM"; + case Talker1Init: return "Talker1Init"; + case Talker2Init: return "Talker2Init"; + case RESTOREROOM: return "RESTOREROOM"; + case INVALLOWED: return "INVALLOWED"; + case BOXSEL: return "BOXSEL"; + case CURSEBLINK: return "CURSEBLINK"; + case EXACTMOVE: return "EXACTMOVE"; + case MOVEDESTX: return "MOVEDESTX"; + case MOVEDESTY: return "MOVEDESTY"; + case NOANTIALIAS: return "NOANTIALIAS"; + case ESCAPED: return "ESCAPED"; + case ALLOW1OPTION: return "ALLOW1OPTION"; + case VOICE_H_LINE: return "VOICE_H_LINE"; + case VOICE_A_LINE: return "VOICE_A_LINE"; + case VOICE_B_LINE: return "VOICE_B_LINE"; + case VOICE_C_LINE: return "VOICE_C_LINE"; + case NOHEROATALL: return "NOHEROATALL"; + case MOUSEENABLED: return "MOUSEENABLED"; + case DIALINES: return "DIALINES"; + + case SHANWALK: return "SHANWALK"; + case SHANDOG: return "SHANDOG"; + case GETACTIONBACK: return "GETACTIONBACK"; + case GETACTIONDATA: return "GETACTIONDATA"; + case GETACTION: return "GETACTION"; + case HEROFAST: return "HEROFAST"; + case SELITEM: return "SELITEM"; + case LMOUSE: return "LMOUSE"; + case MINMX: return "MINMX"; + case MAXMX: return "MAXMX"; + case MINMY: return "MINMY"; + case MAXMY: return "MAXMY"; + case TORX1: return "TORX1"; + case TORY1: return "TORY1"; + case TORX2: return "TORX2"; + case TORY2: return "TORY2"; + case POWER: return "POWER"; + case POWERENABLED: return "POWERENABLED"; + case FLCRESTORE: return "FLCRESTORE"; + case NOCLSTEXT: return "NOCLSTEXT"; + case ESCAPED2: return "ESCAPED2"; + } +} + +} + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/flags.h b/engines/prince/flags.h new file mode 100644 index 0000000000..aa607a01fe --- /dev/null +++ b/engines/prince/flags.h @@ -0,0 +1,416 @@ +/* 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. + * + */ + +#ifndef PRINCE_FLAGS_H +#define PRINCE_FLAGS_H + +#include "common/scummsys.h" + +namespace Prince { + +struct Flags { + + // TODO: Remove from release build + // useful just for debugging + static const char * getFlagName(uint16 flagId); + + enum Id { + FLAGA1 = 0x8000, + FLAGA2 = 0x8002, + FLAGA3 = 0x8004, + DESTX = 0x8006, + DESTY = 0x8008, + DESTD = 0x800A, + DwarfDone = 0x800C, + GRABARZCOUNTER = 0x800E, + KIERUNEK = 0x8010, + BACKFLAG1 = 0x8012, + BACKFLAG2 = 0x8014, + BACKFLAG3 = 0x8016, + BACKFLAG4 = 0x8018, + MACROFLAG1 = 0x801A, + MACROFLAG2 = 0x801C, + MACROFLAG3 = 0x801E, + HEROLDDONE = 0x8020, + BRIDGESET = 0x8022, + U_BT_1 = 0x8024, + U_BT_2 = 0x8026, + U_BT_3 = 0x8028, + U_BT_4 = 0x802A, + U_BT_5 = 0x802C, + U_BT_6 = 0x802E, + U_BT_7 = 0x8030, + U_BT_8 = 0x8032, + U_BT_9 = 0x8034, + U_BT_COUNTER = 0x8036, + ARIVALDALIVE = 0x8038, + TALKCHAR1 = 0x803A, + TalkType1 = 0x803C, + TALKROUT1 = 0x803E, + TALKROUT2 = 0x8042, + TALKROUT3 = 0x8046, + TALKROUT4 = 0x804A, + TALKANIM1 = 0x804E, + TALKANIM2 = 0x8050, + TALKCOLOR1 = 0x8052, + TALKCOLOR2 = 0x8054, + KapciuchTaken = 0x8056, + CurrentBeggarA = 0x8058, + TempKapc = 0x805A, + HomTaken = 0x805C, + WizardTalk = 0x805E, + SunlordTalk = 0x8060, + HermitTalk = 0x8062, + RunyMode = 0x8064, + FatMerchantTalk = 0x8066, + HotDogTalk = 0x8068, + ThiefTalk = 0x806A, + BeggarTalk = 0x806C, + // DwarfTalk = 0x806E, // Redefinition + MonkTalk = 0x8070, + BardTalk = 0x8072, + BarmanTalk = 0x8074, + LeftPlayerTalk = 0x8076, + OczySowy = 0x8078, + CzachySpeed1 = 0x807A, + CzachySpeed2 = 0x807C, + CzachySpeed3 = 0x807E, + CzachySlowDown1 = 0x8080, + CzachySlowDown2 = 0x8082, + CzachySlowDown3 = 0x8084, + FjordDane = 0x8086, + GKopany1 = 0x8088, + GKopany2 = 0x808A, + GKopany3 = 0x808C, + GKopany4 = 0x808E, + KnowGodWord = 0x8090, + TALKROUT21 = 0x8092, + TALKROUT22 = 0x8096, + TALKROUT23 = 0x809A, + TALKROUT24 = 0x809E, + TalkType2 = 0x80A2, + GrabarzTalk = 0x80A4, + LastTalker = 0x80A6, + MapaPustelniaEnabled = 0x80A8, + MapaTempleEnabled = 0x80AA, + MapaFjordEnabled = 0x80AC, + MapaSilmanionaEnabled = 0x80AE, + MapaKurhanEnabled = 0x80B0, + MapaDragonEnabled = 0x80B2, + MapaMillEnabled = 0x80B4, + DwarfRunning = 0x80B6, + DwarfTalk = 0x80B8, + CurseLift = 0x80BA, + KosciSwapped = 0x80BC, + BookStolen = 0x80BE, + MapaUsable = 0x80C0, + FjordBoss = 0x80C2, + FjordHotDog = 0x80C4, + FjordLewy = 0x80C6, + FjordPrawy = 0x80C8, + TalkArivald = 0x80CA, + ShootDone = 0x80CC, + ShootRunning = 0x80CE, + ShootKnow = 0x80D0, + MirrorKnow = 0x80D2, + Gar1stTime = 0x80D4, + KosciTaken = 0x80D6, + ArivGotSpell = 0x80D8, + BookGiven = 0x80DA, + Wywieszka = 0x80DC, + TalkSheila = 0x80DE, + TalkSheila2 = 0x80E0, + BackHuman = 0x80E2, + SkarbiecOpen = 0x80E4, + LustroTaken = 0x80E6, + GargoyleHom = 0x80E8, + GargoyleBroken = 0x80EA, + FjordDzien = 0x80EC, + GargoyleHom2 = 0x80EE, + RunMonstersRunning = 0x80F0, + FoundPaperInCoffin = 0x80F2, + KnowSunlord = 0x80F4, + KnowSunlordTalk = 0x80F6, + ArivaldCzyta = 0x80F8, + TelepX = 0x80FA, + TelepY = 0x80FC, + TelepDir = 0x80FE, + TelepRoom = 0x8100, + ListStolen = 0x8102, + WifeInDoor = 0x8104, + TalkWifeFlag = 0x8106, + LetterGiven = 0x8108, + LutniaTaken = 0x810A, + BardHomeOpen = 0x810C, + FjordNoMonsters = 0x810E, + ShandriaWallTalking = 0x8110, + ShandriaWallCounter = 0x8112, + ShandriaWallDone = 0x8114, + FutureDone = 0x8116, + TalkButch = 0x8118, + GotSzalik = 0x811A, + GotCzosnek = 0x811C, + BearDone = 0x811E, + NekrVisited = 0x8120, + SunRiddle = 0x8122, + PtaszekAway = 0x8124, + KotGadanie = 0x8126, + SzlafmycaTaken = 0x8128, + BabkaTalk = 0x812A, + SellerTalk = 0x812C, + CzosnekDone = 0x812E, + PriestCounter = 0x8130, + PriestGest1 = 0x8132, + PriestGest2 = 0x8134, + PriestGest3 = 0x8136, + PriestGest4 = 0x8138, + PriestAnim = 0x813A, + HolyWaterTaken = 0x813C, + AxeTaken = 0x813E, + BadylTaken1 = 0x8140, + BadylTaken2 = 0x8142, + BadylSharpened = 0x8144, + PorwanieSmoka = 0x8146, + ShopReOpen = 0x8148, + LuskaShown = 0x814A, + CudKnow = 0x814C, + VampireDead = 0x814E, + MapaVisible1 = 0x8150, + MapaVisible2 = 0x8152, + MapaVisible3 = 0x8154, + MapaVisible4 = 0x8156, + MapaVisible5 = 0x8158, + MapaVisible6 = 0x815A, + MapaVisible7 = 0x815C, + MapaVisible8 = 0x815E, + MapaVisible9 = 0x8160, + MapaX = 0x8162, + MapaY = 0x8164, + MapaD = 0x8166, + OldMapaX = 0x8168, + OldMapaY = 0x816A, + OldMapaD = 0x816C, + MovingBack = 0x816E, + MapaCount = 0x8170, + Pustelnia1st = 0x8172, + CzarnePole1st = 0x8174, + TalkArivNum = 0x8176, + Pfui = 0x8178, + MapaSunlordEnabled = 0x817A, + WebDone = 0x817C, + DragonDone = 0x817E, + KanPlay = 0x8180, + OldKanPlay = 0x8182, + LapkiWait = 0x8184, + WebNoCheck = 0x8186, + Perfumeria = 0x8188, + SmokNoCheck = 0x818A, + IluzjaBroken = 0x818C, + IluzjaWorking = 0x818E, + IluzjaCounter = 0x8190, + KurhanOpen1 = 0x8192, + KastetTaken = 0x8194, + KastetDown = 0x8196, + KurhanDone = 0x8198, + SkelCounter = 0x819A, + SkelDial1 = 0x819C, + SkelDial2 = 0x819E, + SkelDial3 = 0x81A0, + SkelDial4 = 0x81A2, + SameTalker = 0x81A4, + RunMonstersText = 0x81A6, + PiwnicaChecked = 0x81A8, + DragonTalked = 0x81AA, + ToldAboutBook = 0x81AC, + SilmanionaDone = 0x81AE, + ToldBookCount = 0x81B0, + SmrodNoCheck = 0x81B2, + RopeTaken = 0x81B4, + RopeTime = 0x81B6, + LaskaFree = 0x81B8, + ShanSmokTalked = 0x81BA, + SwordTaken = 0x81BC, + Mill1st = 0x81BE, + SawRat = 0x81C0, + KnowRat = 0x81C2, + DziuraTimer = 0x81C4, + LaskaInside = 0x81C6, + HoleBig = 0x81C8, + EnableWiedzmin = 0x81CA, + EnableTrucizna = 0x81CC, + KnowPoison = 0x81CE, + KufelTaken = 0x81D0, + BojkaEnabled = 0x81D2, + BitwaNot1st = 0x81D4, + BojkaTimer = 0x81D6, + BojkaGirl = 0x81D8, + Look1st = 0x81DA, + RatTaken = 0x81DC, + LaskaTalkedGr = 0x81DE, + RatusGivus = 0x81E0, + MamObole = 0x81E2, + Speed1st = 0x81E4, + SpeedTimer = 0x81E6, + ProveIt = 0x81E8, + Proven = 0x81EA, + ShowWoalka = 0x81EC, + PoisonTaken = 0x81EE, + HellOpened = 0x81F0, + HellNoCheck = 0x81F2, + TalAn1 = 0x81F4, + TalAn2 = 0x81F6, + TalAn3 = 0x81F8, + TalkDevilGuard = 0x81fA, + Sword1st = 0x81FC, + IluzjaNoCheck = 0x81FE, + RozdzielniaNumber = 0x8200, + JailChecked = 0x8202, + JailTalked = 0x8204, + TrickFailed = 0x8206, + WegielVisible = 0x8208, + WegielTimer1 = 0x820A, + RandomSample = 0x820C, + RandomSampleTimer = 0x820E, + SampleTimer = 0x8210, + ZonaSample = 0x8212, + HoleTryAgain = 0x8214, + TeleportTimer = 0x8216, + RozLezy = 0x8218, + UdkoTimer = 0x821A, + ZaworZatkany = 0x821C, + ZaworOpened = 0x821E, + DoorExploded = 0x8220, + SkoraTaken = 0x8222, + CiezkieByl = 0x8224, + MamWegiel = 0x8226, + SwiecaAway = 0x8228, + ITSAVE = 0x822A, + RozpadlSie = 0x822C, + WegielFullTimer = 0x822E, + WegielDown = 0x8230, + WegielDownTimer = 0x8232, + PaliSie = 0x8234, + DiabGuardTalked = 0x8236, + GuardsNoCheck = 0x8238, + TalkedPowloka = 0x823A, + JailOpen = 0x823C, + PrzytulTimer = 0x823E, + JailDone = 0x8240, + MamMonety = 0x8242, + LotTimer = 0x8244, + LotObj = 0x8246, + PtakTimer = 0x8248, + BookTimer = 0x824A, + BookGiba = 0x824C, + PtakLata = 0x824E, + Podej = 0x8250, + GotHint = 0x8252, + LawaLeci = 0x8254, + PowerKlik = 0x8258, + LucekBad = 0x825A, + LucekBad1st = 0x825C, + IntroDial1 = 0x825E, + IntroDial2 = 0x8260, + ItsOutro = 0x8262, + KamienComment = 0x8264, + KamienSkip = 0x8266, + TesterFlag = 0x8268, + RememberLine = 0x826A, + OpisLapek = 0x826C, + //OpisKamienia = 0x826E, // Redefinition + TalWait = 0x8270, + OpisKamienia = 0x8272, + JumpBox = 0x8274, + JumpBox1 = 0x8276, + JumpBox2 = 0x8278, + JumpBox3 = 0x827A, + SpecPiesek = 0x827C, + SpecPiesekCount = 0x827E, + SpecPiesekGadanie = 0x8282, + ZnikaFlag = 0x8284, + ZnikaTimer = 0x8286, + SowaTimer = 0x8288, + MamrotanieOff = 0x828A, + // Flagi systemowe do kontroli przez skrypt + // System flags controlled by script + CURRMOB = 0x8400, + KOLOR = 0x8402, + MBFLAG = 0x8404, + MXFLAG = 0x8406, + MYFLAG = 0x8408, + SCROLLTYPE = 0x840A, + SCROLLVALUE = 0x840C, + SCROLLVALUE2 = 0x840E, + TALKEXITCODE = 0x8410, + SPECROUTFLAG1 = 0x8412, + SPECROUTFLAG2 = 0x8414, + SPECROUTFLAG3 = 0x8416, + TALKFLAGCODE = 0x8418, + CURRROOM = 0x841A, + Talker1Init = 0x841C, + Talker2Init = 0x841E, + RESTOREROOM = 0x8420, + INVALLOWED = 0x8422, + BOXSEL = 0x8424, + CURSEBLINK = 0x8426, + EXACTMOVE = 0x8428, + MOVEDESTX = 0x842A, + MOVEDESTY = 0x842C, + NOANTIALIAS = 0x842E, + ESCAPED = 0x8430, + ALLOW1OPTION = 0x8432, + VOICE_H_LINE = 0x8434, + VOICE_A_LINE = 0x8436, + VOICE_B_LINE = 0x8438, + VOICE_C_LINE = 0x843A, + NOHEROATALL = 0x843C, + MOUSEENABLED = 0x843E, + DIALINES = 0x8440, + //SELITEM = 0x8442, // Redefinition + SHANWALK = 0x8444, + SHANDOG = 0x8446, + GETACTIONBACK = 0x8448, + GETACTIONDATA = 0x844C, + GETACTION = 0x8450, + HEROFAST = 0x8452, + SELITEM = 0x8454, + LMOUSE = 0x8456, + MINMX = 0x8458, + MAXMX = 0x845A, + MINMY = 0x845C, + MAXMY = 0x845E, + TORX1 = 0x8460, + TORY1 = 0x8462, + TORX2 = 0x8464, + TORY2 = 0x8466, + POWER = 0x8468, + POWERENABLED = 0x846A, + FLCRESTORE = 0x846C, + NOCLSTEXT = 0x846E, + ESCAPED2 = 0x8470 + }; +}; + +} +#endif +/* vim: set tabstop=4 noexpandtab: */ + diff --git a/engines/prince/font.cpp b/engines/prince/font.cpp index 8c72f1b912..30e7b5aee2 100644 --- a/engines/prince/font.cpp +++ b/engines/prince/font.cpp @@ -35,51 +35,57 @@ Font::Font() { } Font::~Font() { - delete [] _fontData; + delete [] _fontData; } bool Font::load(Common::SeekableReadStream &stream) { - stream.seek(0); - _fontData = new byte[stream.size()]; - stream.read(_fontData, stream.size()); - return true; + stream.seek(0); + _fontData = new byte[stream.size()]; + stream.read(_fontData, stream.size()); + return true; } int Font::getFontHeight() const { - debug("Font::getFontHeight %d", _fontData[5]); - return _fontData[5]; + return _fontData[5]; } int Font::getMaxCharWidth() const { - return 0; + return 0; } Font::ChrData Font::getChrData(byte chr) const { - chr -= 32; - uint16 chrOffset = 4*chr+6; + chr -= 32; + uint16 chrOffset = 4*chr+6; - ChrData chrData; - chrData._width = _fontData[chrOffset+2]; - chrData._height = _fontData[chrOffset+3]; - chrData._pixels = _fontData + READ_LE_UINT16(_fontData + chrOffset); + ChrData chrData; + chrData._width = _fontData[chrOffset+2]; + chrData._height = _fontData[chrOffset+3]; + chrData._pixels = _fontData + READ_LE_UINT16(_fontData + chrOffset); - return chrData; + return chrData; } int Font::getCharWidth(byte chr) const { - return getChrData(chr)._width; + return getChrData(chr)._width; } -void Font::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const { - const ChrData chrData = getChrData(chr); - const byte *src = chrData._pixels; - byte *target = (byte *)dst->getBasePtr(x, y); - - for (int i = 0; i < chrData._height; i++) { - memcpy(target, src, chrData._width); - src += chrData._width; - target += dst->pitch; - } +void Font::drawChar(Graphics::Surface *dst, byte chr, int posX, int posY, uint32 color) const { + const ChrData chrData = getChrData(chr); + + for (int y = 0; y < chrData._height; ++y) { + for (int x = 0; x < chrData._width; ++x) { + byte d = chrData._pixels[x + (chrData._width * y)]; + if (d == 0) d = 255; + else if (d == 1) d = 0; + else if (d == 2) d = color; + else if (d == 3) d = 0; + if (d != 255) { + *(byte*)dst->getBasePtr(posX + x, posY + y) = d; + } + } + } } } + +/* vim: set tabstop=4 expandtab!: */ diff --git a/engines/prince/font.h b/engines/prince/font.h index 54e6b6b0a5..1afafa3be3 100644 --- a/engines/prince/font.h +++ b/engines/prince/font.h @@ -25,21 +25,21 @@ #include "graphics/font.h" namespace Graphics { - struct Surface; + struct Surface; } namespace Common { - class String; + class String; } namespace Prince { class Font : public Graphics::Font { public: - Font(); - virtual ~Font(); + Font(); + virtual ~Font(); - bool load(Common::SeekableReadStream &stream); + bool load(Common::SeekableReadStream &stream); virtual int getFontHeight() const override; @@ -49,18 +49,22 @@ public: virtual void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) const override; + virtual int getKerningOffset(byte left, byte right) const { return -2; } + private: - struct ChrData { - byte * _pixels; - byte _width; - byte _height; - }; + struct ChrData { + byte *_pixels; + byte _width; + byte _height; + }; - ChrData getChrData(byte chr) const; + ChrData getChrData(byte chr) const; - byte * _fontData; + byte *_fontData; }; } #endif + +/* vim: set tabstop=4 expandtab!: */ diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index 74b46aad4c..29d3a331df 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -29,46 +29,53 @@ namespace Prince { GraphicsMan::GraphicsMan(PrinceEngine *vm) - : _vm(vm), _changed(false) { - initGraphics(640, 480, true); - _frontScreen = new Graphics::Surface(); - _frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); + : _vm(vm), _changed(false) { + initGraphics(640, 480, true); + _frontScreen = new Graphics::Surface(); + _frontScreen->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); } void GraphicsMan::update() { - if (_changed) { - _vm->_system->copyRectToScreen((byte*)_frontScreen->getBasePtr(0,0), 640, 0, 0, 640, 480); + if (_changed) { + _vm->_system->copyRectToScreen((byte*)_frontScreen->getBasePtr(0,0), 640, 0, 0, 640, 480); - _vm->_system->updateScreen(); - } + _vm->_system->updateScreen(); + _changed = false; + } } void GraphicsMan::setPalette(const byte *palette) { - _vm->_system->getPaletteManager()->setPalette(palette, 0, 256); + _vm->_system->getPaletteManager()->setPalette(palette, 0, 256); } void GraphicsMan::change() { - _changed = true; + _changed = true; } -void GraphicsMan::draw(const Graphics::Surface *s) +void GraphicsMan::draw(uint16 posX, uint16 posY, const Graphics::Surface *s) { - for (uint y = 0; y < 480; y++) - memcpy((byte*)_frontScreen->getBasePtr(0, y), (byte*)s->getBasePtr(0, y), 640); - change(); + uint16 w = MIN(_frontScreen->w, s->w); + for (uint y = 0; y < s->h; y++) { + if (y < _frontScreen->h) { + memcpy((byte*)_frontScreen->getBasePtr(0, y), (byte*)s->getBasePtr(0, y), w); + } + } + change(); } void GraphicsMan::drawTransparent(const Graphics::Surface *s) { - for (uint y = 0; y < 480; ++y) { - for (uint x = 0; x < 640; ++x) { - byte pixel = *((byte*)s->getBasePtr(x,y)); - if (pixel != 255) { - *((byte*)_frontScreen->getBasePtr(x, y)) = pixel; - } - } - } + for (uint y = 0; y < s->h; ++y) { + for (uint x = 0; x < s->w; ++x) { + byte pixel = *((byte*)s->getBasePtr(x,y)); + if (pixel != 255) { + *((byte*)_frontScreen->getBasePtr(x, y)) = pixel; + } + } + } change(); } } + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h index 0f12c734c6..3ef768a073 100644 --- a/engines/prince/graphics.h +++ b/engines/prince/graphics.h @@ -33,27 +33,26 @@ class PrinceEngine; class GraphicsMan { public: - GraphicsMan(PrinceEngine *vm); + GraphicsMan(PrinceEngine *vm); - void update(); + void update(); - void change(); + void change(); - void setPalette(const byte *palette); + void setPalette(const byte *palette); - void draw(const Graphics::Surface *s); - void drawTransparent(const Graphics::Surface *s); + void draw(uint16 x, uint16 y, const Graphics::Surface *s); + void drawTransparent(const Graphics::Surface *s); - Graphics::Surface *_frontScreen; - Graphics::Surface *_backScreen; - const Graphics::Surface *_roomBackground; + Graphics::Surface *_frontScreen; + Graphics::Surface *_backScreen; + const Graphics::Surface *_roomBackground; private: - PrinceEngine *_vm; + PrinceEngine *_vm; - bool _changed; - byte _palette[3 * 256]; + bool _changed; }; } diff --git a/engines/prince/mhwanh.cpp b/engines/prince/mhwanh.cpp index 4240ed4097..92a6a900f5 100644 --- a/engines/prince/mhwanh.cpp +++ b/engines/prince/mhwanh.cpp @@ -29,45 +29,45 @@ namespace Prince { MhwanhDecoder::MhwanhDecoder() - : _surface(NULL), _palette(0), _paletteColorCount(0) { + : _surface(NULL), _palette(0), _paletteColorCount(0) { } MhwanhDecoder::~MhwanhDecoder() { - destroy(); + destroy(); } void MhwanhDecoder::destroy() { - if (_surface) { - _surface->free(); - delete _surface; _surface = 0; - } + if (_surface) { + _surface->free(); + delete _surface; _surface = 0; + } - delete [] _palette; _palette = 0; - _paletteColorCount = 0; + delete [] _palette; _palette = 0; + _paletteColorCount = 0; } bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream) { - destroy(); - _paletteColorCount = 256; - stream.seek(0); - stream.skip(0x20); - // Read the palette - _palette = new byte[_paletteColorCount * 3]; - for (uint16 i = 0; i < _paletteColorCount; i++) { - _palette[i * 3 + 0] = stream.readByte(); - _palette[i * 3 + 1] = stream.readByte(); - _palette[i * 3 + 2] = stream.readByte(); - } - - _surface = new Graphics::Surface(); - _surface->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); - for (int h = 0; h < 480; ++h) { - stream.read(_surface->getBasePtr(0, h), 640); - } - - return true; + destroy(); + _paletteColorCount = 256; + stream.seek(0); + stream.skip(0x20); + // Read the palette + _palette = new byte[_paletteColorCount * 3]; + for (uint16 i = 0; i < _paletteColorCount; i++) { + _palette[i * 3 + 0] = stream.readByte(); + _palette[i * 3 + 1] = stream.readByte(); + _palette[i * 3 + 2] = stream.readByte(); + } + + _surface = new Graphics::Surface(); + _surface->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); + for (int h = 0; h < 480; ++h) { + stream.read(_surface->getBasePtr(0, h), 640); + } + + return true; } } - +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/mhwanh.h b/engines/prince/mhwanh.h index 21822759e8..2b70ae525b 100644 --- a/engines/prince/mhwanh.h +++ b/engines/prince/mhwanh.h @@ -28,26 +28,26 @@ namespace Prince { -class MhwanhDecoder : public Graphics::ImageDecoder -{ +class MhwanhDecoder : public Graphics::ImageDecoder { public: - MhwanhDecoder(); - virtual ~MhwanhDecoder(); + MhwanhDecoder(); + virtual ~MhwanhDecoder(); - // ImageDecoder API - void destroy(); - virtual bool loadStream(Common::SeekableReadStream &stream); - virtual Graphics::Surface *getSurface() const { return _surface; } - const byte *getPalette() const { return _palette; } - uint16 getPaletteCount() const { return _paletteColorCount; } + // ImageDecoder API + void destroy(); + virtual bool loadStream(Common::SeekableReadStream &stream); + virtual Graphics::Surface *getSurface() const { return _surface; } + const byte *getPalette() const { return _palette; } + uint16 getPaletteCount() const { return _paletteColorCount; } private: - Graphics::Surface *_surface; - byte *_palette; - uint16 _paletteColorCount; + Graphics::Surface *_surface; + byte *_palette; + uint16 _paletteColorCount; }; } - #endif + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/mob.cpp b/engines/prince/mob.cpp new file mode 100644 index 0000000000..3df7235d2d --- /dev/null +++ b/engines/prince/mob.cpp @@ -0,0 +1,65 @@ +/* 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 "prince/mob.h" + +#include "common/stream.h" + +namespace Prince { + +bool Mob::loadFromStream(Common::SeekableReadStream &stream) { + int32 pos = stream.pos(); + + uint16 visible = stream.readUint16LE(); + + if (visible == 0xFFFF) + return false; + + _visible = visible; + _type = stream.readUint16LE(); + _rect.left = stream.readUint16LE(); + _rect.top = stream.readUint16LE(); + _rect.right = stream.readUint16LE(); + _rect.bottom = stream.readUint16LE(); + + stream.skip(6 * sizeof(uint16)); + uint32 nameOffset = stream.readUint32LE(); + uint32 examTextOffset = stream.readUint32LE(); + + byte c; + stream.seek(nameOffset); + _name.clear(); + while ((c = stream.readByte())) + _name += c; + + stream.seek(examTextOffset); + _examText.clear(); + while ((c = stream.readByte())) + _examText += c; + stream.seek(pos + 32); + + return true; +} + +} + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/mob.h b/engines/prince/mob.h new file mode 100644 index 0000000000..b8208246a1 --- /dev/null +++ b/engines/prince/mob.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +#ifndef PRINCE_MOB_H +#define PRINCE_MOB_H + +#include "common/scummsys.h" +#include "common/rect.h" +#include "common/str.h" + +namespace Common { + class SeekableReadStream; +} + +namespace Prince { + +class Mob { +public: + Mob() {} + + bool loadFromStream(Common::SeekableReadStream &stream); + + bool _visible; + uint16 _type; + Common::Rect _rect; + Common::String _name; + Common::String _examText; +}; + +} + +#endif + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/module.mk b/engines/prince/module.mk index a177e670ed..f8003f834a 100644 --- a/engines/prince/module.mk +++ b/engines/prince/module.mk @@ -1,18 +1,23 @@ -MODULE := engines/prince
-
-MODULE_OBJS = \
- debugger.o \
- script.o \
- graphics.o \
- mhwanh.o \
- detection.o \
- font.o \
- prince.o
-
-# This module can be built as a plugin
-ifeq ($(ENABLE_PRINCE), DYNAMIC_PLUGIN)
-PLUGIN := 1
-endif
-
-# Include common rules
-include $(srcdir)/rules.mk
+MODULE := engines/prince + +MODULE_OBJS = \ + debugger.o \ + script.o \ + graphics.o \ + mhwanh.o \ + detection.o \ + font.o \ + mob.o \ + object.o \ + sound.o \ + flags.o \ + variatxt.o \ + prince.o + +# This module can be built as a plugin +ifeq ($(ENABLE_PRINCE), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk diff --git a/engines/prince/musNum.h b/engines/prince/musNum.h new file mode 100644 index 0000000000..65b31f8175 --- /dev/null +++ b/engines/prince/musNum.h @@ -0,0 +1,87 @@ +/* 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. + * + */ + +namespace Prince { + +enum RoomMus { + ROOM01MUS = 3, + ROOM02MUS = 9, + ROOM03MUS = 9, + ROOM04MUS = 9, + ROOM05MUS = 13, + ROOM06MUS = 9, + ROOM07MUS = 9, + ROOM08MUS = 9, + ROOM09MUS = 14, + ROOM10MUS = 9, + ROOM11MUS = 9, + ROOM12MUS = 9, + ROOM13MUS = 9, + ROOM14MUS = 9, + ROOM15MUS = 5, + ROOM16MUS = 5, + ROOM17MUS = 5, + ROOM18MUS = 5, + ROOM19MUS = 5, + ROOM20MUS = 12, + ROOM21MUS = 9, + ROOM22MUS = 9, + ROOM23MUS = 1, + ROOM24MUS = 1, + ROOM25MUS = 2, + ROOM26MUS = 10, + ROOM27MUS = 7, + ROOM28MUS = 10, + ROOM29MUS = 10, + ROOM30MUS = 11, + ROOM31MUS = 14, + ROOM32MUS = 11, + ROOM33MUS = 7, + ROOM34MUS = 7, + ROOM35MUS = 7, + ROOM36MUS = 7, + ROOM37MUS = 7, + ROOM38MUS = 7, + ROOM39MUS = 7, + ROOM40MUS = 7, + ROOM41MUS = 7, + ROOM42MUS = 7, + ROOM43MUS = 15, + ROOM46MUS = 100, + ROOM47MUS = 100, + ROOM48MUS = 100, + ROOM49MUS = 100, + ROOM50MUS = 100, + ROOM51MUS = 12, + ROOM52MUS = 9, + ROOM53MUS = 5, + ROOM54MUS = 11, + ROOM55MUS = 11, + ROOM56MUS = 11, + ROOM57MUS = 7, + ROOM58MUS = 13, + ROOM59MUS = 16, + ROOM60MUS = 4, + ROOM61MUS = 0 +}; + +} diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp new file mode 100644 index 0000000000..9f7efcfb88 --- /dev/null +++ b/engines/prince/object.cpp @@ -0,0 +1,78 @@ +/* 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/archive.h" +#include "common/debug-channels.h" +#include "common/debug.h" +#include "common/stream.h" + + +#include "graphics/surface.h" + +#include "prince/object.h" + +namespace Prince { + +Object::Object() : _surface(NULL) { +} + +void Object::loadSurface(Common::SeekableReadStream &stream) { + stream.skip(4); + + _surface = new Graphics::Surface(); + _surface->create(stream.readUint16LE(), stream.readUint16LE(), Graphics::PixelFormat::createFormatCLUT8()); + for (int h = 0; h < _surface->h; ++h) { + stream.read(_surface->getBasePtr(0, h), _surface->w); + } + +} + +bool Object::loadFromStream(Common::SeekableReadStream &stream) { + + int32 pos = stream.pos(); + uint16 x = stream.readUint16LE(); + if (x == 0xFFFF) + return false; + _x = x; + _y = stream.readUint16LE(); + + const Common::String obStreamName = Common::String::format("OB%02d", stream.readUint16LE()); + Common::SeekableReadStream *obStream = SearchMan.createReadStreamForMember(obStreamName); + if (!obStream) { + error("Can't load %s", obStreamName.c_str()); + return false; + } + + loadSurface(*obStream); + delete obStream; + + _z = stream.readUint16LE(); + + stream.seek(pos + 16); + + debug("Object x %d, y %d, z %d", _x, _y, _z); + + return true; +} + +} +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/object.h b/engines/prince/object.h new file mode 100644 index 0000000000..2c2dbc9fbf --- /dev/null +++ b/engines/prince/object.h @@ -0,0 +1,48 @@ +/* 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. + * + */ + +#ifndef PRINCE_OBJECT_H +#define PRINCE_OBJECT_H + +#include "graphics/decoders/image_decoder.h" +#include "graphics/surface.h" + +namespace Prince { + +class Object { +public: + Object(); + + bool loadFromStream(Common::SeekableReadStream &stream); + Graphics::Surface *getSurface() const { return _surface; } + +private: + void loadSurface(Common::SeekableReadStream &stream); + + Graphics::Surface *_surface; + uint16 _x, _y, _z; +}; + +} + +#endif +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 4fb2082baf..6d01cf2017 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -1,240 +1,550 @@ -/* 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-channels.h"
-#include "common/debug.h"
-#include "common/events.h"
-#include "common/file.h"
-#include "common/random.h"
-#include "common/fs.h"
-#include "common/keyboard.h"
-#include "common/substream.h"
-
-#include "graphics/cursorman.h"
-#include "graphics/surface.h"
-#include "graphics/palette.h"
-#include "graphics/pixelformat.h"
-
-#include "engines/util.h"
-#include "engines/advancedDetector.h"
-
-#include "audio/audiostream.h"
-
-#include "prince/prince.h"
-#include "prince/font.h"
-#include "prince/graphics.h"
-#include "prince/script.h"
-#include "prince/debugger.h"
-
-#include "video/flic_decoder.h"
-
-namespace Prince {
-
-PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL),
- _locationNr(0), _debugger(NULL) {
- _rnd = new Common::RandomSource("prince");
- _debugger = new Debugger(this);
-
-}
-
-PrinceEngine::~PrinceEngine() {
- DebugMan.clearAllDebugChannels();
-
- delete _rnd;
- delete _debugger;
-}
-
-GUI::Debugger *PrinceEngine::getDebugger() {
- return _debugger;
-}
-
-Common::Error PrinceEngine::run() {
- _graph = new GraphicsMan(this);
-
- const Common::FSNode gameDataDir(ConfMan.get("path"));
-
- debug("Adding all path: %s", gameDataDir.getPath().c_str());
-
- SearchMan.addSubDirectoryMatching(gameDataDir, "all", 0, 2);
-
- Common::SeekableReadStream *font1stream = SearchMan.createReadStreamForMember("font1.raw");
- if (!font1stream)
- return Common::kPathNotFile;
-
- if (_font.load(*font1stream)) {
- _font.getCharWidth(103);
- }
- delete font1stream;
-
- Common::SeekableReadStream * walizka = SearchMan.createReadStreamForMember("walizka");
- if (!walizka)
- return Common::kPathDoesNotExist;
-
- debug("Loading walizka");
- if (!_walizkaBmp.loadStream(*walizka)) {
- return Common::kPathDoesNotExist;
- }
-
- Common::SeekableReadStream * skryptStream = SearchMan.createReadStreamForMember("skrypt.dat");
- if (!skryptStream)
- return Common::kPathNotFile;
-
- debug("Loading skrypt");
- _script = new Script(this);
- _script->loadFromStream(*skryptStream);
-
- delete skryptStream;
-
- Common::SeekableReadStream *logoStrema = SearchMan.createReadStreamForMember("logo.raw");
- if (logoStrema)
- {
- MhwanhDecoder logo;
- logo.loadStream(*logoStrema);
- _graph->setPalette(logo.getPalette());
- _graph->draw(logo.getSurface());
- _graph->update();
- _system->delayMillis(700);
- }
- delete logoStrema;
-
- mainLoop();
-
- return Common::kNoError;
-}
-
-bool PrinceEngine::loadLocation(uint16 locationNr) {
- debug("PrinceEngine::loadLocation %d", locationNr);
- const Common::FSNode gameDataDir(ConfMan.get("path"));
- SearchMan.remove(Common::String::format("%02d", _locationNr));
- _locationNr = locationNr;
-
- const Common::String locationNrStr = Common::String::format("%02d", _locationNr);
- debug("loadLocation %s", locationNrStr.c_str());
- SearchMan.addSubDirectoryMatching(gameDataDir, locationNrStr, 0, 2);
-
- // load location background
- Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room");
-
- if (!room) {
- error("Can't load room bitmap");
- return false;
- }
-
- if(_roomBmp.loadStream(*room)) {
- debug("Room bitmap loaded");
- _system->getPaletteManager()->setPalette(_roomBmp.getPalette(), 0, 256);
- }
-
- delete room;
-
- return true;
-}
-
-bool PrinceEngine::playNextFrame() {
- const Graphics::Surface *s = _flicPlayer.decodeNextFrame();
- if (s) {
- _graph->drawTransparent(s);
- _graph->change();
- }
-
- return true;
-}
-
-bool PrinceEngine::loadAnim(uint16 animNr) {
- Common::String streamName = Common::String::format("AN%02d", animNr);
- Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName);
-
- if (!flicStream) {
- error("Can't open %s", streamName.c_str());
- return false;
- }
-
- if (!_flicPlayer.loadStream(flicStream)) {
- error("Can't load flic stream %s", streamName.c_str());
- }
-
- debug("%s loaded", streamName.c_str());
- _flicPlayer.start();
- return true;
-}
-
-void PrinceEngine::keyHandler(Common::Event event) {
- uint16 nChar = event.kbd.keycode;
- if (event.kbd.hasFlags(Common::KBD_CTRL)) {
- switch (nChar) {
- case Common::KEYCODE_d:
- getDebugger()->attach();
- getDebugger()->onFrame();
- break;
- }
- }
-}
-
-void PrinceEngine::mainLoop() {
-
- while (!shouldQuit()) {
- Common::Event event;
- Common::EventManager *eventMan = _system->getEventManager();
- while (eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- keyHandler(event);
- break;
- case Common::EVENT_KEYUP:
- break;
- case Common::EVENT_MOUSEMOVE:
- break;
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_RBUTTONDOWN:
- break;
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- break;
- case Common::EVENT_QUIT:
- break;
- default:
- break;
- }
- }
-
- if (shouldQuit())
- return;
-
- _script->step();
-
- if (_roomBmp.getSurface())
- _graph->draw(_roomBmp.getSurface());
-
- playNextFrame();
-
- _graph->update();
-
- _system->delayMillis(40);
-
- }
-}
-
-} // End of namespace Prince
+/* 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-channels.h" +#include "common/debug.h" +#include "common/events.h" +#include "common/file.h" +#include "common/random.h" +#include "common/fs.h" +#include "common/keyboard.h" +#include "common/substream.h" + +#include "graphics/cursorman.h" +#include "graphics/surface.h" +#include "graphics/palette.h" +#include "graphics/pixelformat.h" + +#include "engines/util.h" +#include "engines/advancedDetector.h" + +#include "audio/audiostream.h" + +#include "prince/prince.h" +#include "prince/font.h" +#include "prince/graphics.h" +#include "prince/script.h" +#include "prince/debugger.h" +#include "prince/object.h" +#include "prince/mob.h" +#include "prince/sound.h" +#include "prince/variatxt.h" +#include "prince/flags.h" + +#include "video/flic_decoder.h" + +namespace Prince { + +Graphics::Surface *loadCursor(const char *curName) +{ + Common::SeekableReadStream *curStream = SearchMan.createReadStreamForMember(curName); + if (!curStream) { + error("Can't load %s", curName); + return NULL; + } + + curStream->skip(4); + uint16 w = curStream->readUint16LE(); + uint16 h = curStream->readUint16LE(); + + debug("Loading cursor %s, w %d, h %d", curName, w, h); + + Graphics::Surface *curSurface = new Graphics::Surface(); + curSurface->create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + for (int ih = 0; ih < h; ++ih) { + curStream->read(curSurface->getBasePtr(0, ih), w); + } + + delete curStream; + return curSurface; +} + + + +PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) : + Engine(syst), _gameDescription(gameDesc), _graph(NULL), _script(NULL), + _locationNr(0), _debugger(NULL), _objectList(NULL), _mobList(NULL), _midiPlayer(NULL), + _cameraX(0), _newCameraX(0), _frameNr(0) { + + // Debug/console setup + DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel"); + DebugMan.addDebugChannel(DebugChannel::kEngine, "engine", "Prince Engine debug channel"); + + DebugMan.enableDebugChannel("script"); + + gDebugLevel = 10; + + + _rnd = new Common::RandomSource("prince"); + _debugger = new Debugger(this); + _midiPlayer = new MusicPlayer(this); + +} + +PrinceEngine::~PrinceEngine() { + DebugMan.clearAllDebugChannels(); + + delete _rnd; + delete _debugger; + delete _cur1; + delete _cur2; + delete _midiPlayer; +} + +GUI::Debugger *PrinceEngine::getDebugger() { + return _debugger; +} + +Common::Error PrinceEngine::run() { + _graph = new GraphicsMan(this); + + const Common::FSNode gameDataDir(ConfMan.get("path")); + + debug("Adding all path: %s", gameDataDir.getPath().c_str()); + + SearchMan.addSubDirectoryMatching(gameDataDir, "all", 0, 2); + SearchMan.addSubDirectoryMatching(gameDataDir, "data/voices/output", 0, 2); + + Common::SeekableReadStream *font1stream = SearchMan.createReadStreamForMember("font1.raw"); + if (!font1stream) + return Common::kPathNotFile; + + if (_font.load(*font1stream)) { + _font.getCharWidth(103); + } + delete font1stream; + + Common::SeekableReadStream * walizka = SearchMan.createReadStreamForMember("walizka"); + if (!walizka) + return Common::kPathDoesNotExist; + + debug("Loading walizka"); + if (!_walizkaBmp.loadStream(*walizka)) { + return Common::kPathDoesNotExist; + } + + Common::SeekableReadStream * skryptStream = SearchMan.createReadStreamForMember("skrypt.dat"); + if (!skryptStream) + return Common::kPathNotFile; + + debug("Loading skrypt"); + _script = new Script(this); + _script->loadFromStream(*skryptStream); + + delete skryptStream; + + Common::SeekableReadStream *variaTxtStream = SearchMan.createReadStreamForMember("variatxt.dat"); + + if (!variaTxtStream) { + error("Can't load variatxt.dat"); + return Common::kPathNotFile; + } + + _variaTxt = new VariaTxt(); + _variaTxt->loadFromStream(*variaTxtStream); + delete variaTxtStream; + + Common::SeekableReadStream *talkTxtStream = SearchMan.createReadStreamForMember("talktxt.dat"); + if (!talkTxtStream) { + error("Can't load talkTxtStream"); + return Common::kPathDoesNotExist; + } + + _talkTxtSize = talkTxtStream->size(); + _talkTxt = new byte[_talkTxtSize]; + talkTxtStream->read(_talkTxt, _talkTxtSize); + + delete talkTxtStream; + + + _cur1 = loadCursor("mouse1.cur"); + _cur2 = loadCursor("mouse2.cur"); +#if 0 + Common::SeekableReadStream *logoStream = SearchMan.createReadStreamForMember("logo.raw"); + if (logoStream) + { + MhwanhDecoder logo; + logo.loadStream(*logoStream); + _graph->setPalette(logo.getPalette()); + _graph->draw(0, 0, logo.getSurface()); + _graph->update(); + _system->delayMillis(700); + } + delete logoStream; +#endif + mainLoop(); + + return Common::kNoError; +} + +class MobList { +public: + bool loadFromStream(Common::SeekableReadStream &stream); + + Common::Array<Mob> _mobList; +}; + +bool MobList::loadFromStream(Common::SeekableReadStream &stream) +{ + Mob mob; + while (mob.loadFromStream(stream)) + _mobList.push_back(mob); + + return true; +} + +class ObjectList { +public: + bool loadFromStream(Common::SeekableReadStream &stream); + + Common::Array<Object> _objList; +}; + +bool ObjectList::loadFromStream(Common::SeekableReadStream &stream) +{ + Object obj; + while (obj.loadFromStream(stream)) + _objList.push_back(obj); + + return true; +} + +bool PrinceEngine::loadLocation(uint16 locationNr) { + debug("PrinceEngine::loadLocation %d", locationNr); + const Common::FSNode gameDataDir(ConfMan.get("path")); + SearchMan.remove(Common::String::format("%02d", _locationNr)); + _locationNr = locationNr; + + const Common::String locationNrStr = Common::String::format("%02d", _locationNr); + debug("loadLocation %s", locationNrStr.c_str()); + SearchMan.addSubDirectoryMatching(gameDataDir, locationNrStr, 0, 2); + + // load location background + Common::SeekableReadStream *room = SearchMan.createReadStreamForMember("room"); + + if (!room) { + error("Can't load room bitmap"); + return false; + } + + if(_roomBmp.loadStream(*room)) { + debug("Room bitmap loaded"); + _sceneWidth = _roomBmp.getSurface()->w; + } + + delete room; + + delete _mobList; + _mobList = NULL; + + Common::SeekableReadStream *mobListStream = SearchMan.createReadStreamForMember("mob.lst"); + if (!mobListStream) { + error("Can't read mob.lst"); + return false; + } + + _mobList = new MobList(); + _mobList->loadFromStream(*mobListStream); + + delete mobListStream; + + delete _objectList; + _objectList = NULL; + + Common::SeekableReadStream *objListStream = SearchMan.createReadStreamForMember("obj.lst"); + if (!objListStream) { + error("Can't read obj.lst"); + return false; + } + + _objectList = new ObjectList(); + _objectList->loadFromStream(*objListStream); + delete objListStream; + + const char *musName = MusicPlayer::_musTable[MusicPlayer::_musRoomTable[locationNr]]; + _midiPlayer->loadMidi(musName); + + return true; +} + +void PrinceEngine::changeCursor(uint16 curId) +{ + Graphics::Surface *curSurface = NULL; + + uint16 hotspotX = 0; + uint16 hotspotY = 0; + + switch(curId) { + case 0: + CursorMan.showMouse(false); + return; + case 1: + curSurface = _cur1; + break; + case 2: + curSurface = _cur2; + hotspotX = curSurface->w >> 1; + hotspotY = curSurface->h >> 1; + break; + } + + CursorMan.replaceCursorPalette(_roomBmp.getPalette(), 0, 255); + CursorMan.replaceCursor( + curSurface->getBasePtr(0, 0), + curSurface->w, curSurface->h, + hotspotX, hotspotY, + 255, false, + &curSurface->format + ); + CursorMan.showMouse(true); +} + +bool PrinceEngine::playNextFrame() { + if (!_flicPlayer.isVideoLoaded()) + return false; + + const Graphics::Surface *s = _flicPlayer.decodeNextFrame(); + if (s) { + _graph->drawTransparent(s); + _graph->change(); + } else if (_flicLooped) { + _flicPlayer.rewind(); + playNextFrame(); + } + + return true; +} + +bool PrinceEngine::loadAnim(uint16 animNr, bool loop) { + Common::String streamName = Common::String::format("AN%02d", animNr); + Common::SeekableReadStream * flicStream = SearchMan.createReadStreamForMember(streamName); + + if (!flicStream) { + error("Can't open %s", streamName.c_str()); + return false; + } + + if (!_flicPlayer.loadStream(flicStream)) { + error("Can't load flic stream %s", streamName.c_str()); + } + + debug("%s loaded", streamName.c_str()); + _flicLooped = loop; + _flicPlayer.start(); + playNextFrame(); + return true; +} + +void PrinceEngine::scrollCameraLeft(int16 delta) { + if (_newCameraX > 0) { + if (_newCameraX < delta) + _newCameraX = 0; + else + _newCameraX -= delta; + } +} + +void PrinceEngine::scrollCameraRight(int16 delta) { + if (_newCameraX != _sceneWidth - 640) { + if (_sceneWidth - 640 < delta + _newCameraX) + delta += (_sceneWidth - 640) - (delta + _newCameraX); + _newCameraX += delta; + debug(0, "PrinceEngine::scrollCameraRight() _newCameraX = %d; delta = %d", _newCameraX, delta); + } +} + +void PrinceEngine::keyHandler(Common::Event event) { + uint16 nChar = event.kbd.keycode; + switch (nChar) { + case Common::KEYCODE_d: + if (event.kbd.hasFlags(Common::KBD_CTRL)) { + getDebugger()->attach(); + } + break; + case Common::KEYCODE_LEFT: + scrollCameraLeft(32); + break; + case Common::KEYCODE_RIGHT: + scrollCameraRight(32); + break; + case Common::KEYCODE_ESCAPE: + _script->setFlag(Flags::ESCAPED2, 1); + break; + } +} + +void PrinceEngine::hotspot() { + if (!_mobList) + return; + Common::Point mousepos = _system->getEventManager()->getMousePos(); + Common::Point mousePosCamera(mousepos.x + _cameraX, mousepos.y); + + for (Common::Array<Mob>::const_iterator it = _mobList->_mobList.begin() + ; it != _mobList->_mobList.end() ; ++it) { + if (it->_visible) + continue; + if (it->_rect.contains(mousePosCamera)) { + uint16 textW = 0; + for (int i = 0; i < it->_name.size(); ++i) + textW += _font.getCharWidth(it->_name[i]); + + uint16 x = mousepos.x - textW/2; + if (x > _graph->_frontScreen->w) + x = 0; + + if (x + textW > _graph->_frontScreen->w) + x = _graph->_frontScreen->w - textW; + + _font.drawString( + _graph->_frontScreen, + it->_name, + x, + mousepos.y - _font.getFontHeight(), + _graph->_frontScreen->w, + 216 + ); + break; + } + } +} + +void PrinceEngine::printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y) { + + debugC(1, DebugChannel::kEngine, "PrinceEngine::printAt slot %d, color %d, x %02d, y %02d, str %s", slot, color, x, y, s); + + Text &text = _textSlots[slot]; + text._str = s; + text._x = x; + text._y = y; + text._color = color; +} + +uint32 PrinceEngine::getTextWidth(const char *s) { + uint16 textW = 0; + while (*s) { + textW += _font.getCharWidth(*s) + _font.getKerningOffset(0, 0); + ++s; + } + return textW; +} + +void PrinceEngine::showTexts() { + for (uint32 slot = 0; slot < MAXTEXTS; ++slot) { + Text& text = _textSlots[slot]; + if (!text._str && !text._time) + continue; + + Common::Array<Common::String> lines; + _font.wordWrapText(text._str, _graph->_frontScreen->w, lines); + + for (int i = 0; i < lines.size(); ++i) { + _font.drawString( + _graph->_frontScreen, + lines[i], + text._x - getTextWidth(lines[i].c_str())/2, + text._y - (lines.size() - i) * (_font.getFontHeight()), + _graph->_frontScreen->w, + text._color + ); + } + + --text._time; + if (text._time == 0) { + text._str = NULL; + } + } +} + +void PrinceEngine::drawScreen() { + const Graphics::Surface *roomSurface = _roomBmp.getSurface(); + if (roomSurface) { + _graph->setPalette(_roomBmp.getPalette()); + const Graphics::Surface visiblePart = roomSurface->getSubArea(Common::Rect(_cameraX, 0, roomSurface->w, roomSurface->h)); + _graph->draw(0, 0, &visiblePart); + } + + playNextFrame(); + + //if (_objectList) + // _graph->drawTransparent(_objectList->getSurface()); + + hotspot(); + + showTexts(); + + getDebugger()->onFrame(); + + _graph->update(); +} + +void PrinceEngine::mainLoop() { + + while (!shouldQuit()) { + uint32 currentTime = _system->getMillis(); + + Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); + while (eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + keyHandler(event); + break; + case Common::EVENT_KEYUP: + break; + case Common::EVENT_MOUSEMOVE: + break; + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_RBUTTONDOWN: + break; + case Common::EVENT_LBUTTONUP: + case Common::EVENT_RBUTTONUP: + break; + case Common::EVENT_QUIT: + break; + default: + break; + } + } + + if (shouldQuit()) + return; + + _script->step(); + drawScreen(); + + // Calculate the frame delay based off a desired frame time + int delay = 1000/15 - int32(_system->getMillis() - currentTime); + // Ensure non-negative + delay = delay < 0 ? 0 : delay; + _system->delayMillis(delay); + + _cameraX = _newCameraX; + ++_frameNr; + } +} + +} // End of namespace Prince + +/* vim: set tabstop=4 expandtab!: */ diff --git a/engines/prince/prince.h b/engines/prince/prince.h index b289c75553..68a7793157 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -1,100 +1,155 @@ -/* 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.
- *
- */
-
-#ifndef PRINCE_H
-#define PRINCE_H
-
-#include "common/random.h"
-#include "common/system.h"
-#include "common/debug.h"
-#include "common/debug-channels.h"
-#include "common/textconsole.h"
-#include "common/rect.h"
-#include "common/events.h"
-
-#include "graphics/decoders/bmp.h"
-
-#include "gui/debugger.h"
-
-#include "engines/engine.h"
-#include "engines/util.h"
-
-#include "audio/mixer.h"
-
-#include "video/flic_decoder.h"
-
-#include "prince/font.h"
-#include "prince/mhwanh.h"
-
-namespace Prince {
-
-struct PrinceGameDescription;
-
-class PrinceEngine;
-class GraphicsMan;
-class Script;
-class Debugger;
-
-class PrinceEngine : public Engine {
-protected:
- Common::Error run();
-
-public:
- PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc);
- virtual ~PrinceEngine();
-
- virtual bool hasFeature(EngineFeature f) const;
-
- int getGameType() const;
- const char *getGameId() const;
- uint32 getFeatures() const;
- Common::Language getLanguage() const;
-
- const PrinceGameDescription *_gameDescription;
- Video::FlicDecoder _flicPlayer;
-
- bool loadLocation(uint16 locationNr);
- bool loadAnim(uint16 animNr);
-
- virtual GUI::Debugger *getDebugger();
-
-private:
- bool playNextFrame();
- void keyHandler(Common::Event event);
-
- Common::RandomSource *_rnd;
- Graphics::BitmapDecoder _roomBmp;
- uint16 _locationNr;
- MhwanhDecoder _walizkaBmp;
-
- Debugger *_debugger;
- GraphicsMan *_graph;
- Script *_script;
- Font _font;
-
- void mainLoop();
-
-};
-
-} // End of namespace Prince
-
-#endif
+/* 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. + * + */ + +#ifndef PRINCE_H +#define PRINCE_H + +#include "common/random.h" +#include "common/system.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/textconsole.h" +#include "common/rect.h" +#include "common/events.h" + +#include "graphics/decoders/bmp.h" + +#include "gui/debugger.h" + +#include "engines/engine.h" +#include "engines/util.h" + +#include "audio/mixer.h" + +#include "video/flic_decoder.h" + +#include "prince/font.h" +#include "prince/mhwanh.h" + +namespace Prince { + +struct PrinceGameDescription; + +class PrinceEngine; +class GraphicsMan; +class Script; +class Debugger; +class ObjectList; +class MobList; +class MusicPlayer; +class VariaTxt; + +struct Text { + const char *_str; + uint16 _x, _y; + uint16 _time; + uint32 _color; + + Text() : _str(NULL), _x(0), _y(0), _time(0), _color(255){ + } +}; + +struct DebugChannel { + +enum Type { + kScript, + kEngine +}; + +}; + +class PrinceEngine : public Engine { +protected: + Common::Error run(); + +public: + PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc); + virtual ~PrinceEngine(); + + virtual bool hasFeature(EngineFeature f) const; + + int getGameType() const; + const char *getGameId() const; + uint32 getFeatures() const; + Common::Language getLanguage() const; + + const PrinceGameDescription *_gameDescription; + Video::FlicDecoder _flicPlayer; + VariaTxt *_variaTxt; + + uint32 _talkTxtSize; + byte *_talkTxt; + + bool loadLocation(uint16 locationNr); + bool loadAnim(uint16 animNr, bool loop); + + virtual GUI::Debugger *getDebugger(); + + void changeCursor(uint16 curId); + void printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y); + + static const uint8 MAXTEXTS = 32; + Text _textSlots[MAXTEXTS]; + + uint64 _frameNr; + +private: + bool playNextFrame(); + void keyHandler(Common::Event event); + void hotspot(); + void scrollCameraRight(int16 delta); + void scrollCameraLeft(int16 delta); + void drawScreen(); + void showTexts(); + + uint32 getTextWidth(const char *s); + + Common::RandomSource *_rnd; + Graphics::BitmapDecoder _roomBmp; + uint16 _locationNr; + MhwanhDecoder _walizkaBmp; + + Graphics::Surface *_cur1; + Graphics::Surface *_cur2; + + Debugger *_debugger; + GraphicsMan *_graph; + Script *_script; + Font _font; + ObjectList *_objectList; + MobList *_mobList; + MusicPlayer *_midiPlayer; + uint16 _cameraX; + uint16 _newCameraX; + uint16 _sceneWidth; + + bool _flicLooped; + + void mainLoop(); + +}; + +} // End of namespace Prince + +#endif + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index d790d6d9c3..1aacda4f0b 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -22,23 +22,35 @@ #include "prince/script.h" #include "prince/prince.h" +#include "prince/flags.h" +#include "prince/variatxt.h" +#include "prince/font.h" #include "common/debug.h" #include "common/debug-channels.h" #include "common/stream.h" +#include "common/archive.h" + +#include "audio/decoders/wave.h" +#include "audio/audiostream.h" namespace Prince { static const uint16 NUM_OPCODES = 144; Script::Script(PrinceEngine *vm) : - _code(NULL), _stacktop(0), _vm(vm), _opcodeNF(false) { + _code(NULL), _stacktop(0), _vm(vm), _opcodeNF(false), + _waitFlag(0), _voiceStream(NULL) { } Script::~Script() { delete[] _code; } +void Script::setFlag(Flags::Id flagId, uint16 value) { + _flags[flagId - 0x8000] = value; +} + bool Script::loadFromStream(Common::SeekableReadStream &stream) { _codeSize = stream.size(); _code = new byte[_codeSize]; @@ -46,48 +58,69 @@ bool Script::loadFromStream(Common::SeekableReadStream &stream) { if (!_code) return false; - stream.read(_code, _codeSize); - // Initialize the script - _currentInstruction = READ_LE_UINT32(_code + 4); + stream.read(_code, _codeSize); + // Initialize the script + _fgOpcodePC = READ_LE_UINT32(_code + 4); + _bgOpcodePC = 0; return true; } void Script::debugScript(const char *s, ...) { - char buf[STRINGBUFLEN]; - va_list va; + char buf[STRINGBUFLEN]; + va_list va; va_start(va, s); vsnprintf(buf, STRINGBUFLEN, s, va); va_end(va); - Common::String str = Common::String::format("@0x%04X: ", _lastInstruction); - str += Common::String::format("op %02d: ", _lastOpcode); - debug("%s %s", str.c_str(), buf); + Common::String str = Common::String::format("@0x%04X: ", _lastInstruction); + str += Common::String::format("op %04d: ", _lastOpcode); + //debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf); + + debug("Prince::Script frame %ld %s %s", _vm->_frameNr, str.c_str(), buf); } void Script::step() { - //while (!_opcodeNF) - { - _lastInstruction = _currentInstruction; - // Prepare the base debug string - Common::String dstr = Common::String::format("@0x%04X: ", _currentInstruction); + if (_bgOpcodePC) { + _bgOpcodePC = step(_bgOpcodePC); + } + if (_fgOpcodePC) { + _fgOpcodePC = step(_fgOpcodePC); + } +} + +uint32 Script::step(uint32 opcodePC) { + + _currentInstruction = opcodePC; + while (!_opcodeNF) + { + _lastInstruction = _currentInstruction; + // Prepare the base debug string + Common::String dstr = Common::String::format("@0x%04X: ", _currentInstruction); - // Get the current opcode - _lastOpcode = readScript16bits(); + // Get the current opcode + _lastOpcode = readScript16bits(); - dstr += Common::String::format("op %02d: ", _lastOpcode); + dstr += Common::String::format("op %02d: ", _lastOpcode); - if (_lastOpcode > NUM_OPCODES) - error("Trying to execute unknown opcode %s", dstr.c_str()); + if (_lastOpcode > NUM_OPCODES) + error("Trying to execute unknown opcode %s", dstr.c_str()); - debug("%s", dstr.c_str()); + debugScript(""); - // Execute the current opcode - OpcodeFunc op = _opcodes[_lastOpcode]; - (this->*op)(); - } + // Execute the current opcode + OpcodeFunc op = _opcodes[_lastOpcode]; + (this->*op)(); + if (_opcodeNF) { + + _opcodeNF = 0; + break; + } + } + + return _currentInstruction; } uint8 Script::getCodeByte(uint32 address) { @@ -116,258 +149,421 @@ uint32 Script::readScript32bits() { } void Script::O_WAITFOREVER() { - debugScript("O_WAITFOREVER"); - _currentInstruction -= 2; + debugScript("O_WAITFOREVER"); + _opcodeNF = 1; + _currentInstruction -= 2; } void Script::O_BLACKPALETTE() { - debugScript("O_BLACKPALETTE"); + debugScript("O_BLACKPALETTE"); } void Script::O_SETUPPALETTE() { - debugScript("O_SETUPPALETTE"); + debugScript("O_SETUPPALETTE"); } void Script::O_INITROOM() { - uint16 roomId = readScript16bits(); - debugScript("O_INITROOM %d", roomId); - _vm->loadLocation(roomId); + uint16 roomId = readScript16bits(); + debugScript("O_INITROOM %d", roomId); + _vm->loadLocation(roomId); + _opcodeNF = 1; } void Script::O_SETSAMPLE() { - uint16 sampleId = readScript16bits(); - int32 sampleNameOffset = readScript32bits(); - const char * sampleName = (const char *)_code + _currentInstruction + sampleNameOffset - 4; - debugScript("O_SETSAMPLE %d %s", sampleId, sampleName); + uint16 sampleId = readScript16bits(); + int32 sampleNameOffset = readScript32bits(); + const char * sampleName = (const char *)_code + _currentInstruction + sampleNameOffset - 4; + debugScript("O_SETSAMPLE %d %s", sampleId, sampleName); } void Script::O_FREESAMPLE() { - uint16 sample = readScript16bits(); - debugScript("O_FREESAMPLE %d", sample); + uint16 sample = readScript16bits(); + debugScript("O_FREESAMPLE %d", sample); } void Script::O_PLAYSAMPLE() { - uint16 sampleId = readScript16bits(); - uint16 loopType = readScript16bits(); - debugScript("O_PLAYSAMPLE sampleId %d loopType %d", sampleId, loopType); + uint16 sampleId = readScript16bits(); + uint16 loopType = readScript16bits(); + debugScript("O_PLAYSAMPLE sampleId %d loopType %d", sampleId, loopType); + + if (_voiceStream) { + + Audio::RewindableAudioStream *audioStream = Audio::makeWAVStream(_voiceStream, DisposeAfterUse::YES); + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, audioStream, sampleId); + } } void Script::O_PUTOBJECT() { - uint16 roomId = readScript16bits(); - uint16 slot = readScript16bits(); - uint16 objectId = readScript16bits(); - debugScript("O_PUTOBJECT roomId %d, slot %d, objectId %d", roomId, slot, objectId); + uint16 roomId = readScript16bits(); + uint16 slot = readScript16bits(); + uint16 objectId = readScript16bits(); + debugScript("O_PUTOBJECT roomId %d, slot %d, objectId %d", roomId, slot, objectId); } void Script::O_REMOBJECT() { - uint16 roomId = readScript16bits(); - uint16 objectId = readScript16bits(); + uint16 roomId = readScript16bits(); + uint16 objectId = readScript16bits(); - debugScript("O_REMOBJECT roomId %d objectId %d", roomId, objectId); + debugScript("O_REMOBJECT roomId %d objectId %d", roomId, objectId); } void Script::O_SHOWANIM() { - uint16 slot = readScript16bits(); - uint16 animId = readScript16bits(); + uint16 slot = readScript16bits(); + uint16 animId = readScript16bits(); - debugScript("O_SHOWANIM slot %d, animId %d", slot, animId); + debugScript("O_SHOWANIM slot %d, animId %d", slot, animId); } void Script::O_CHECKANIMEND() { - uint16 slot = readScript16bits(); - uint16 frameId = readScript16bits(); + uint16 slot = readScript16bits(); + uint16 frameId = readScript16bits(); - debugScript("O_CHECKANIMEND slot %d, frameId %d", slot, frameId); + debugScript("O_CHECKANIMEND slot %d, frameId %d", slot, frameId); + _opcodeNF = 1; } void Script::O_FREEANIM() { - uint16 slot = readScript16bits(); - debugScript("O_FREEANIM slot %d", slot); + uint16 slot = readScript16bits(); + debugScript("O_FREEANIM slot %d", slot); } void Script::O_CHECKANIMFRAME() { - uint16 slot = readScript16bits(); - uint16 frameId = readScript16bits(); + uint16 slot = readScript16bits(); + uint16 frameId = readScript16bits(); - debugScript("O_CHECKANIMFRAME slot %d, frameId %d", slot, frameId); + debugScript("O_CHECKANIMFRAME slot %d, frameId %d", slot, frameId); + _opcodeNF = 1; } void Script::O_PUTBACKANIM() { - uint16 roomId = readScript16bits(); - uint16 slot = readScript16bits(); - uint32 animId = readScript32bits(); - debugScript("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId); + uint16 roomId = readScript16bits(); + uint16 slot = readScript16bits(); + uint32 animId = readScript32bits(); + debugScript("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId); } void Script::O_REMBACKANIM() { - uint16 roomId = readScript16bits(); - uint16 slot = readScript16bits(); + uint16 roomId = readScript16bits(); + uint16 slot = readScript16bits(); + + debugScript("O_REMBACKANIM roomId %d, slot %d", roomId, slot); +} - debugScript("O_REMBACKANIM roomId %d, slot %d", roomId, slot); +void Script::O_CHECKBACKANIMFRAME() { + uint16 slotId = readScript16bits(); + uint16 frameId = readScript16bits(); + + debugScript("O_CHECKBACKANIMFRAME slotId %d, frameId %d", slotId, frameId); + _opcodeNF = 1; } -void Script::O_CHECKBACKANIMFRAME() {} +void Script::O_FREEALLSAMPLES() { + debugScript("O_FREEALLSAMPLES"); +} -void Script::O_FREEALLSAMPLES() {} +void Script::O_SETMUSIC() { + uint16 musicId = readScript16bits(); -void Script::O_SETMUSIC() {} + debugScript("O_SETMUSIC musicId %d", musicId); +} -void Script::O_STOPMUSIC() {} +void Script::O_STOPMUSIC() { + debugScript("O_STOPMUSIC"); +} -void Script::O__WAIT() {} +void Script::O__WAIT() { + uint16 pause = readScript16bits(); -void Script::O_UPDATEOFF() {} + debugScript("O__WAIT pause %d", pause); -void Script::O_UPDATEON() {} + if (_waitFlag == 0) { + // set new wait flag value and continue + _waitFlag = pause; + _opcodeNF = 1; + _currentInstruction -= 4; + return; + } -void Script::O_UPDATE () {} + --_waitFlag; -void Script::O_CLS() {} + if (_waitFlag > 0) { + _opcodeNF = 1; + _currentInstruction -= 4; + return; + } +} +void Script::O_UPDATEOFF() { + debugScript("O_UPDATEOFF"); +} + +void Script::O_UPDATEON() { + debugScript("O_UPDATEON"); +} + +void Script::O_UPDATE () { + debugScript("O_UPDATE"); +} + +void Script::O_CLS() { + debugScript("O_CLS"); +} void Script::O__CALL() { - int32 address = readScript32bits(); - _stack[_stacktop] = _currentInstruction; - _stacktop++; - _currentInstruction += address - 4; - debugScript("O__CALL 0x%04X", _currentInstruction); + int32 address = readScript32bits(); + _stack[_stacktop] = _currentInstruction; + _stacktop++; + _currentInstruction += address - 4; + debugScript("O__CALL 0x%04X", _currentInstruction); } + void Script::O_RETURN() { - // Get the return address - if (_stacktop > 0) { - _stacktop--; - _currentInstruction = _stack[_stacktop]; - debugScript("O_RETURN 0x%04X", _currentInstruction); - } else { - error("Return: Stack is empty"); - } + // Get the return address + if (_stacktop > 0) { + _stacktop--; + _currentInstruction = _stack[_stacktop]; + debugScript("O_RETURN 0x%04X", _currentInstruction); + } else { + error("Return: Stack is empty"); + } } + void Script::O_GO() { - int32 opPC = readScript32bits(); - debugScript("O_GO 0x%04X", opPC); - _currentInstruction += opPC - 4; + int32 opPC = readScript32bits(); + debugScript("O_GO 0x%04X", opPC); + _currentInstruction += opPC - 4; +} + +void Script::O_BACKANIMUPDATEOFF() { + uint16 slotId = readScript32bits(); + debugScript("O_BACKANIMUPDATEOFF slotId %d", slotId); } -void Script::O_BACKANIMUPDATEOFF() {} void Script::O_BACKANIMUPDATEON() { - uint16 slot = readScript16bits(); - debugScript("O_BACKANIMUPDATEON %d", slot); + uint16 slot = readScript16bits(); + debugScript("O_BACKANIMUPDATEON %d", slot); } void Script::O_CHANGECURSOR() { - uint16 cursorId = readScript16bits(); - debugScript("O_CHANGECURSOR %x", cursorId); + uint16 cursorId = readScript16bits(); + debugScript("O_CHANGECURSOR %x", cursorId); } -void Script::O_CHANGEANIMTYPE() {} + +void Script::O_CHANGEANIMTYPE() { + // NOT IMPLEMENTED +} + void Script::O__SETFLAG() { - uint16 flagId = readScript16bits(); - uint16 value = readScript16bits(); - debugScript("O__SETFLAG 0x%04X %d", flagId, value); - _flags[flagId-0x8000] = value; + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); + + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } + + debugScript("O__SETFLAG 0x%04X (%s) = %d", flagId, Flags::getFlagName(flagId), value); + + _flags[flagId - 0x8000] = value; } void Script::O_COMPARE() { - uint16 flagId = readScript16bits(); - uint16 value = readScript16bits(); - debugScript("O_COMPARE flagId 0x%04X, value %d", flagId, value); - _result = (_flags[flagId-0x8000] == value); + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); + + if (value & 0x8000) { + uint16 val = _flags[value - 0x8000]; + debugScript("GetFlagValue 0x%04X (%s), value %d", value, Flags::getFlagName(value), val); + + value = val; + } + + _result = !(_flags[flagId - 0x8000] == value); + debugScript("O_COMPARE flagId 0x%04X (%s), value %d == %d (%d)", flagId, Flags::getFlagName(flagId), value, _flags[flagId - 0x8000], _result); } void Script::O_JUMPZ() { - int32 offset = readScript32bits(); - debugScript("O_JUMPZ offset 0x%04X", offset); - if (_result == 0) - { - _currentInstruction += offset - 4; - } + int32 offset = readScript32bits(); + debugScript("O_JUMPZ offset 0x%04X", offset); + if (! _result) { + _currentInstruction += offset - 4; + } } void Script::O_JUMPNZ() { - int32 offset = readScript32bits(); - debugScript("O_JUMPNZ offset 0x%04X", offset); - if (_result) - { - _currentInstruction += offset - 4; - } + int32 offset = readScript32bits(); + debugScript("O_JUMPNZ offset 0x%04X", offset); + if (_result) { + _currentInstruction += offset - 4; + } } -void Script::O_EXIT() {} +void Script::O_EXIT() { + uint16 exitCode = readScript16bits(); + debugScript("O_EXIT exitCode %d", exitCode); +} void Script::O_ADDFLAG() { - uint16 flagId = readScript16bits(); - uint16 value = readScript16bits(); + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); - _flags[flagId-0x8000] += value; - if (_flags[flagId-0x8000]) - _result = 1; - else - _result = 0; + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } - debugScript("O_ADDFLAG flagId %d, value %d", flagId, value); + _flags[flagId - 0x8000] += value; + if (_flags[flagId - 0x8000]) + _result = 1; + else + _result = 0; + + debugScript("O_ADDFLAG flagId %04x (%s), value %d", flagId, Flags::getFlagName(flagId), value); } void Script::O_TALKANIM() { - uint16 animSlot = readScript16bits(); - uint16 slot = readScript16bits(); + uint16 animSlot = readScript16bits(); + uint16 slot = readScript16bits(); - debugScript("O_TALKANIM animSlot %d, slot %d", animSlot, slot); + debugScript("O_TALKANIM animSlot %d, slot %d", animSlot, slot); } void Script::O_SUBFLAG() { - uint16 flagId = readScript16bits(); - uint16 value = readScript16bits(); + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); + + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } - _flags[flagId-0x8000] -= value; - if (_flags[flagId-0x8000]) - _result = 1; - else - _result = 0; + _flags[flagId - 0x8000] -= value; + if (_flags[flagId - 0x8000]) + _result = 1; + else + _result = 0; - debugScript("O_SUBFLAG flagId %d, value %d", flagId, value); + debugScript("O_SUBFLAG flagId %d, value %d", flagId, value); } void Script::O_SETSTRING() { - int32 offset = readScript32bits(); + int32 offset = readScript32bits(); + _currentString = offset; + + if (offset >= 80000) { + debug("GetVaria %s", _vm->_variaTxt->getString(offset - 80000)); + } + else if (offset < 2000) { + uint32 of = READ_LE_UINT32(_vm->_talkTxt+offset*4); + const char * txt = (const char *)&_vm->_talkTxt[of]; + _string = &_vm->_talkTxt[of]; + debug("TalkTxt %d %s", of, txt); + } + + debugScript("O_SETSTRING %04d", offset); +} + +void Script::O_ANDFLAG() { + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); - debugScript("O_SETSTRING 0x%04X", offset); + debugScript("O_ANDFLAG flagId %d, value %d", flagId, value); + + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } + + _flags[flagId - 0x8000] &= value; + + if (_flags[flagId - 0x8000]) { + _result = 1; + } else { + _result = 0; + } } -void Script::O_ANDFLAG() {} +void Script::O_GETMOBDATA() { + uint16 flagId = readScript16bits(); + uint16 mobId = readScript16bits(); + uint16 mobOffset = readScript16bits(); -void Script::O_GETMOBDATA() {} + debugScript("O_GETMOBDATA flagId %d, modId %d, mobOffset %d", flagId, mobId, mobOffset); +} + +void Script::O_ORFLAG() { + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); + + debugScript("O_ORFLAG flagId %d, value %d", flagId, value); -void Script::O_ORFLAG() {} + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } -void Script::O_SETMOBDATA() {} + _flags[flagId - 0x8000] |= value; -void Script::O_XORFLAG() {} + if (_flags[flagId - 0x8000]) { + _result = 1; + } else { + _result = 0; + } +} -void Script::O_GETMOBTEXT() {} +void Script::O_SETMOBDATA() { + uint16 mobId = readScript16bits(); + uint16 mobOffset = readScript16bits(); + uint16 value = readScript16bits(); + + debugScript("O_SETMOBDATA mobId %d, mobOffset %d, value %d", mobId, mobOffset, value); +} + +void Script::O_XORFLAG() { + uint16 flagId = readScript16bits(); + uint16 value = readScript16bits(); + + debugScript("O_XORFLAG flagId %d, value %d", flagId, value); + + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } + + _flags[flagId - 0x8000] ^= value; + + if (_flags[flagId - 0x8000]) { + _result = 1; + } else { + _result = 0; + } +} + +void Script::O_GETMOBTEXT() { + uint16 value = readScript16bits(); + + debugScript("O_GETMOBTEXT value %d", value); +} void Script::O_MOVEHERO() { - uint16 heroId = readScript16bits(); - uint16 x = readScript16bits(); - uint16 y = readScript16bits(); - uint16 dir = readScript16bits(); - - debugScript("O_MOVEHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir); + uint16 heroId = readScript16bits(); + uint16 x = readScript16bits(); + uint16 y = readScript16bits(); + uint16 dir = readScript16bits(); + + debugScript("O_MOVEHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir); } void Script::O_WALKHERO() { - uint16 heroId = readScript16bits(); + uint16 heroId = readScript16bits(); - debugScript("O_WALKHERO %d", heroId); + debugScript("O_WALKHERO %d", heroId); + _opcodeNF = 1; } void Script::O_SETHERO() {} void Script::O_HEROOFF() { - uint16 heroId = readScript16bits(); - debugScript("O_HEROOFF %d", heroId); + uint16 heroId = readScript16bits(); + debugScript("O_HEROOFF %d", heroId); } void Script::O_HEROON() { - uint16 heroId = readScript16bits(); - debugScript("O_HEROON %d", heroId); + uint16 heroId = readScript16bits(); + debugScript("O_HEROON %d", heroId); } void Script::O_CLSTEXT() {} @@ -382,8 +578,8 @@ void Script::O_REMWALKAREA() {} void Script::O_RESTOREWALKAREA() {} void Script::O_WAITFRAME() { - debugScript("O_WAITFRAME"); - _opcodeNF = true; + debugScript("O_WAITFRAME"); + _opcodeNF = true; } void Script::O_SETFRAME() {} @@ -396,8 +592,15 @@ void Script::O_CHECKINV() {} void Script::O_TALKHERO() {} void Script::O_WAITTEXT() { - uint16 slot = readScript16bits(); - debugScript("O_WAITTEXT slot %d", slot); + uint16 slot = readScript16bits(); + if (slot & 0x8000) { + slot = _flags[slot - 0x8000]; + } + Text &text = _vm->_textSlots[slot]; + if (text._time) { + _opcodeNF = 1; + _currentInstruction -= 4; + } } void Script::O_SETHEROANIM() {} @@ -409,8 +612,9 @@ void Script::O_CHANGEBACKFRAMES() {} void Script::O_GETBACKANIMDATA() {} void Script::O_GETANIMDATA() {} void Script::O_SETBGCODE() { - int32 bgcode = readScript32bits(); - debugScript("O_SETBGCODE %d", bgcode); + int32 bgcode = readScript32bits(); + debugScript("O_SETBGCODE %d", bgcode); + _bgOpcodePC = _currentInstruction + bgcode; } void Script::O_SETBACKFRAME() {} void Script::O_GETRND() {} @@ -418,418 +622,517 @@ void Script::O_TALKBACKANIM() {} void Script::O_LOADPATH() {} void Script::O_GETCHAR() { - uint16 flagId = readScript16bits(); - debugScript("O_GETCHAR %d", flagId); + uint16 flagId = readScript16bits(); + + _flags[flagId - 0x8000] = *_string; + + debugScript("O_GETCHAR %04X (%s) %02x", flagId, Flags::getFlagName(flagId), _flags[flagId - 0x8000]); + + ++_string; } void Script::O_SETDFLAG() {} void Script::O_CALLDFLAG() {} -void Script::O_PRINTAT() {} + +void Script::O_PRINTAT() { + uint16 slot = readScript16bits(); + uint16 fr1 = readScript16bits(); + uint16 fr2 = readScript16bits(); + + debugScript("O_PRINTAT slot %d, fr1 %d, fr2 %d", slot, fr1, fr2); + + uint8 color = _flags[Flags::KOLOR - 0x8000]; + + _vm->printAt(slot, color, (const char *)_string, fr1, fr2); + + while (*_string) { + ++_string; + } + ++_string; +} + void Script::O_ZOOMIN() {} + void Script::O_ZOOMOUT() {} -void Script::O_SETSTRINGOFFSET() {} + +void Script::O_SETSTRINGOFFSET() { +} + void Script::O_GETOBJDATA() {} + void Script::O_SETOBJDATA() {} + void Script::O_SWAPOBJECTS() {} -void Script::O_CHANGEHEROSET() {} + +void Script::O_CHANGEHEROSET() { + uint16 hero = readScript16bits(); + uint16 heroSet = readScript16bits(); + + debugScript("O_CHANGEHEROSET hero %d, heroSet %d", hero, heroSet); +} + void Script::O_ADDSTRING() {} + void Script::O_SUBSTRING() {} + void Script::O_INITDIALOG() {} + void Script::O_ENABLEDIALOGOPT() {} + void Script::O_DISABLEDIALOGOPT() {} + void Script::O_SHOWDIALOGBOX() {} void Script::O_STOPSAMPLE() { - uint16 slot = readScript16bits(); - debugScript("O_STOPSAMPLE slot %d", slot); + uint16 slot = readScript16bits(); + debugScript("O_STOPSAMPLE slot %d", slot); + + _vm->_mixer->stopID(slot); + _voiceStream = NULL; } void Script::O_BACKANIMRANGE() { - uint16 slotId = readScript16bits(); - uint16 animId = readScript16bits(); - uint16 low = readScript16bits(); - uint16 high = readScript16bits(); + uint16 slotId = readScript16bits(); + uint16 animId = readScript16bits(); + uint16 low = readScript16bits(); + uint16 high = readScript16bits(); - debugScript("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d", slotId, animId, low, high); + debugScript("O_BACKANIMRANGE slotId %d, animId %d, low %d, high %d", slotId, animId, low, high); } void Script::O_CLEARPATH() { - debugScript("O_CLEARPATH"); + debugScript("O_CLEARPATH"); } void Script::O_SETPATH() { - debugScript("O_SETPATH"); + debugScript("O_SETPATH"); } void Script::O_GETHEROX() { - uint16 heroId = readScript16bits(); - uint16 flagId = readScript16bits(); + uint16 heroId = readScript16bits(); + uint16 flagId = readScript16bits(); - debugScript("O_GETHEROX heroId %d, flagId %d", heroId, flagId); + debugScript("O_GETHEROX heroId %d, flagId %d", heroId, flagId); } void Script::O_GETHEROY() { - uint16 heroId = readScript16bits(); - uint16 flagId = readScript16bits(); + uint16 heroId = readScript16bits(); + uint16 flagId = readScript16bits(); - debugScript("O_GETHEROY heroId %d, flagId %d", heroId, flagId); + debugScript("O_GETHEROY heroId %d, flagId %d", heroId, flagId); } void Script::O_GETHEROD() { - uint16 heroId = readScript16bits(); - uint16 flagId = readScript16bits(); + uint16 heroId = readScript16bits(); + uint16 flagId = readScript16bits(); - debugScript("O_GETHEROD heroId %d, flagId %d", heroId, flagId); + debugScript("O_GETHEROD heroId %d, flagId %d", heroId, flagId); } void Script::O_PUSHSTRING() { - debugScript("O_PUSHSTRING"); + debugScript("O_PUSHSTRING"); } void Script::O_POPSTRING() { - debugScript("O_POPSTRING"); + debugScript("O_POPSTRING"); } void Script::O_SETFGCODE() { - int32 offset = readScript32bits(); + int32 offset = readScript32bits(); + + debugScript("O_SETFGCODE offset %04X", offset); - debugScript("O_SETFGCODE offset %04X", offset); + _fgOpcodePC = _currentInstruction + offset; } void Script::O_STOPHERO() { - uint16 heroId = readScript16bits(); + uint16 heroId = readScript16bits(); - debugScript("O_STOPHERO heroId %d", heroId); + debugScript("O_STOPHERO heroId %d", heroId); } void Script::O_ANIMUPDATEOFF() { - uint16 slotId = readScript16bits(); - debugScript("O_ANIMUPDATEOFF slotId %d", slotId); + uint16 slotId = readScript16bits(); + debugScript("O_ANIMUPDATEOFF slotId %d", slotId); } void Script::O_ANIMUPDATEON() { - uint16 slotId = readScript16bits(); - debugScript("O_ANIMUPDATEON slotId %d", slotId); + uint16 slotId = readScript16bits(); + debugScript("O_ANIMUPDATEON slotId %d", slotId); } void Script::O_FREECURSOR() { - debugScript("O_FREECURSOR"); + debugScript("O_FREECURSOR"); } void Script::O_ADDINVQUIET() { - uint16 heroId = readScript16bits(); - uint16 itemId = readScript16bits(); + uint16 heroId = readScript16bits(); + uint16 itemId = readScript16bits(); - debugScript("O_ADDINVQUIET heorId %d, itemId %d", heroId, itemId); + debugScript("O_ADDINVQUIET heorId %d, itemId %d", heroId, itemId); } void Script::O_RUNHERO() { - uint16 heroId = readScript16bits(); - uint16 x = readScript16bits(); - uint16 y = readScript16bits(); - uint16 dir = readScript16bits(); + uint16 heroId = readScript16bits(); + uint16 x = readScript16bits(); + uint16 y = readScript16bits(); + uint16 dir = readScript16bits(); - debugScript("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir); + debugScript("O_RUNHERO heroId %d, x %d, y %d, dir %d", heroId, x, y, dir); } void Script::O_SETBACKANIMDATA() { - uint16 animId = readScript16bits(); - uint16 animOffset = readScript16bits(); - uint16 wart = readScript16bits(); + uint16 animId = readScript16bits(); + uint16 animOffset = readScript16bits(); + uint16 wart = readScript16bits(); - debugScript("O_SETBACKANIMDATA animId %d, animOffset %d, wart %d", animId, animOffset, wart); + debugScript("O_SETBACKANIMDATA animId %d, animOffset %d, wart %d", animId, animOffset, wart); } void Script::O_VIEWFLC() { - uint16 animNr = readScript16bits(); - debugScript("O_VIEWFLC animNr %d", animNr); + uint16 animNr = readScript16bits(); + debug("O_VIEWFLC animNr %d", animNr); + _vm->loadAnim(animNr, false); } void Script::O_CHECKFLCFRAME() { - uint16 frameNr = readScript16bits(); + uint16 frameNr = readScript16bits(); - debugScript("O_CHECKFLCFRAME frame number %d", frameNr); + debugScript("O_CHECKFLCFRAME frame number %d", frameNr); - const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer; + const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer; - if (flicPlayer.getCurFrame() != frameNr) - { - // Move instruction pointer before current instruciton - // must do this check once again till it's false - _currentInstruction -= 2; - } + if (flicPlayer.getCurFrame() != frameNr) + { + // Move instruction pointer before current instruciton + // must do this check once again till it's false + _currentInstruction -= 2; + _opcodeNF = 1; + } } void Script::O_CHECKFLCEND() { - debugScript("O_CHECKFLCEND"); + //debugScript("O_CHECKFLCEND"); - const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer; + const Video::FlicDecoder &flicPlayer = _vm->_flicPlayer; - if (flicPlayer.getFrameCount() - flicPlayer.getCurFrame() <= 1) - { - // Move instruction pointer before current instruciton - // must do this check once again till it's false - _currentInstruction -= 2; - } + //debug("frameCount %d, currentFrame %d", flicPlayer.getFrameCount(), flicPlayer.getCurFrame()); + + if (flicPlayer.getFrameCount() - flicPlayer.getCurFrame() > 1) + { + // Move instruction pointer before current instruciton + // must do this check once again till it's false + _currentInstruction -= 2; + _opcodeNF = 1; + } } void Script::O_FREEFLC() { - debugScript("O_FREEFLC"); + debugScript("O_FREEFLC"); } void Script::O_TALKHEROSTOP() { - uint16 heroId = readScript16bits(); - debugScript("O_TALKHEROSTOP %d", heroId); + uint16 heroId = readScript16bits(); + debugScript("O_TALKHEROSTOP %d", heroId); } void Script::O_HEROCOLOR() { - uint16 heroId = readScript16bits(); - uint16 kolorr = readScript16bits(); - debugScript("O_HEROCOLOR heroId %d, kolorr %d", heroId, kolorr); + uint16 heroId = readScript16bits(); + uint16 kolorr = readScript16bits(); + debugScript("O_HEROCOLOR heroId %d, kolorr %d", heroId, kolorr); } void Script::O_GRABMAPA() { - debugScript("O_GRABMAPA"); + debugScript("O_GRABMAPA"); } void Script::O_ENABLENAK() { - uint16 nakId = readScript16bits(); - debugScript("O_ENABLENAK nakId %d", nakId); + uint16 nakId = readScript16bits(); + debugScript("O_ENABLENAK nakId %d", nakId); } void Script::O_DISABLENAK() { - uint16 nakId = readScript16bits(); - debugScript("O_DISABLENAK nakId %d", nakId); + uint16 nakId = readScript16bits(); + debugScript("O_DISABLENAK nakId %d", nakId); } void Script::O_GETMOBNAME() { - uint16 war = readScript16bits(); - debugScript("O_GETMOBNAME war %d", war); + uint16 war = readScript16bits(); + debugScript("O_GETMOBNAME war %d", war); } void Script::O_SWAPINVENTORY() { - uint16 heroId = readScript16bits(); - debugScript("O_SWAPINVENTORY heroId %d", heroId); + uint16 heroId = readScript16bits(); + debugScript("O_SWAPINVENTORY heroId %d", heroId); } void Script::O_CLEARINVENTORY() { - uint16 heroId = readScript16bits(); - debugScript("O_CLEARINVENTORY heroId %d", heroId); + uint16 heroId = readScript16bits(); + debugScript("O_CLEARINVENTORY heroId %d", heroId); } void Script::O_SKIPTEXT() { - debugScript("O_SKIPTEXT"); + debugScript("O_SKIPTEXT"); +} + +void Script::SetVoice(uint32 slot) { + + const uint16 VOICE_H_LINE = _flags[Flags::VOICE_H_LINE - 0x8000]; + + const Common::String streamName = Common::String::format("%03d-%02d.WAV", _currentString, VOICE_H_LINE); + debugScript("Loading wav %s slot %d", streamName.c_str(), slot); + + _voiceStream = SearchMan.createReadStreamForMember(streamName); + if (!_voiceStream) { + error("Can't open %s", streamName.c_str()); + } + uint32 id = _voiceStream->readUint32LE(); + if (id != 0x46464952) { + error("It's not RIFF file %s", streamName.c_str()); + return; + } + + _voiceStream->skip(0x20); + id = _voiceStream->readUint32LE(); + if (id != 0x61746164) { + error("No data section in %s id %04x", streamName.c_str(), id); + return; + } + + id = _voiceStream->readUint32LE(); + debugScript("SetVoice slot %d time %04x", slot, id); + id <<= 3; + id /= 22050; + id += 2; + + _vm->_textSlots[slot]._time = id; + + debugScript("SetVoice slot %d time %04x", slot, id); + _voiceStream->seek(0); } void Script::O_SETVOICEH() { - uint16 txn = readScript16bits(); - debugScript("O_SETVOICEH txn %d", txn); + uint16 txn = readScript16bits(); + debugScript("O_SETVOICEH txn %d", txn); + SetVoice(txn); } void Script::O_SETVOICEA() { - uint16 txn = readScript16bits(); - debugScript("O_SETVOICEA txn %d", txn); + uint16 txn = readScript16bits(); + debugScript("O_SETVOICEA txn %d", txn); + SetVoice(txn); } void Script::O_SETVOICEB() { - uint16 txn = readScript16bits(); - debugScript("O_SETVOICEB txn %d", txn); + uint16 txn = readScript16bits(); + debugScript("O_SETVOICEB txn %d", txn); + SetVoice(txn); } void Script::O_SETVOICEC() { - uint16 txn = readScript16bits(); - debugScript("O_SETVOICEC txn %d", txn); + uint16 txn = readScript16bits(); + debugScript("O_SETVOICEC txn %d", txn); + SetVoice(txn); } void Script::O_VIEWFLCLOOP() { - uint16 animId = readScript16bits(); - debugScript("O_VIEWFLCLOOP animId %d", animId); + uint16 value = readScript16bits(); + debugScript("O_VIEWFLCLOOP animId %d", value); + + if (value & 0x8000) { + value = _flags[value - 0x8000]; + } + + _vm->loadAnim(value, true); } void Script::O_FLCSPEED() { - uint16 speed = readScript16bits(); - debugScript("O_FLCSPEED speed %d", speed); + uint16 speed = readScript16bits(); + debugScript("O_FLCSPEED speed %d", speed); } void Script::O_OPENINVENTORY() { - debugScript("O_OPENINVENTORY"); + debugScript("O_OPENINVENTORY"); + _opcodeNF = 1; } void Script::O_KRZYWA() { - debugScript("O_KRZYWA"); + debugScript("O_KRZYWA"); } void Script::O_GETKRZYWA() { - debugScript("O_GETKRZYWA"); + debugScript("O_GETKRZYWA"); } void Script::O_GETMOB() { - uint16 flagId = readScript16bits(); - uint16 mx = readScript16bits(); - uint16 my = readScript16bits(); - debugScript("O_GETMOB flagId %d, mx %d, my %d", flagId, mx, my); + uint16 flagId = readScript16bits(); + uint16 mx = readScript16bits(); + uint16 my = readScript16bits(); + debugScript("O_GETMOB flagId %d, mx %d, my %d", flagId, mx, my); } void Script::O_INPUTLINE() { - debugScript("O_INPUTLINE"); + debugScript("O_INPUTLINE"); } void Script::O_SETVOICED() { - uint16 txn = readScript16bits(); - debugScript("O_SETVOICED txn %d", txn); + uint16 txn = readScript16bits(); + debugScript("O_SETVOICED txn %d", txn); + SetVoice(txn); } void Script::O_BREAK_POINT() { - debugScript("O_BREAK_POINT"); + debugScript("O_BREAK_POINT"); } Script::OpcodeFunc Script::_opcodes[NUM_OPCODES] = { - &Script::O_WAITFOREVER, - &Script::O_BLACKPALETTE, - &Script::O_SETUPPALETTE, - &Script::O_INITROOM, - &Script::O_SETSAMPLE, - &Script::O_FREESAMPLE, - &Script::O_PLAYSAMPLE, - &Script::O_PUTOBJECT, - &Script::O_REMOBJECT, - &Script::O_SHOWANIM, - &Script::O_CHECKANIMEND, - &Script::O_FREEANIM, - &Script::O_CHECKANIMFRAME, - &Script::O_PUTBACKANIM, - &Script::O_REMBACKANIM, - &Script::O_CHECKBACKANIMFRAME, - &Script::O_FREEALLSAMPLES, - &Script::O_SETMUSIC, - &Script::O_STOPMUSIC, - &Script::O__WAIT, - &Script::O_UPDATEOFF, - &Script::O_UPDATEON, - &Script::O_UPDATE , - &Script::O_CLS, - &Script::O__CALL, - &Script::O_RETURN, - &Script::O_GO, - &Script::O_BACKANIMUPDATEOFF, - &Script::O_BACKANIMUPDATEON, - &Script::O_CHANGECURSOR, - &Script::O_CHANGEANIMTYPE, - &Script::O__SETFLAG, - &Script::O_COMPARE, - &Script::O_JUMPZ, - &Script::O_JUMPNZ, - &Script::O_EXIT, - &Script::O_ADDFLAG, - &Script::O_TALKANIM, - &Script::O_SUBFLAG, - &Script::O_SETSTRING, - &Script::O_ANDFLAG, - &Script::O_GETMOBDATA, - &Script::O_ORFLAG, - &Script::O_SETMOBDATA, - &Script::O_XORFLAG, - &Script::O_GETMOBTEXT, - &Script::O_MOVEHERO, - &Script::O_WALKHERO, - &Script::O_SETHERO, - &Script::O_HEROOFF, - &Script::O_HEROON, - &Script::O_CLSTEXT, - &Script::O_CALLTABLE, - &Script::O_CHANGEMOB, - &Script::O_ADDINV, - &Script::O_REMINV, - &Script::O_REPINV, - &Script::O_OBSOLETE_GETACTION, - &Script::O_ADDWALKAREA, - &Script::O_REMWALKAREA, - &Script::O_RESTOREWALKAREA, - &Script::O_WAITFRAME, - &Script::O_SETFRAME, - &Script::O_RUNACTION, - &Script::O_COMPAREHI, - &Script::O_COMPARELO, - &Script::O_PRELOADSET, - &Script::O_FREEPRELOAD, - &Script::O_CHECKINV, - &Script::O_TALKHERO, - &Script::O_WAITTEXT, - &Script::O_SETHEROANIM, - &Script::O_WAITHEROANIM, - &Script::O_GETHERODATA, - &Script::O_GETMOUSEBUTTON, - &Script::O_CHANGEFRAMES, - &Script::O_CHANGEBACKFRAMES, - &Script::O_GETBACKANIMDATA, - &Script::O_GETANIMDATA, - &Script::O_SETBGCODE, - &Script::O_SETBACKFRAME, - &Script::O_GETRND, - &Script::O_TALKBACKANIM, - &Script::O_LOADPATH, - &Script::O_GETCHAR, - &Script::O_SETDFLAG, - &Script::O_CALLDFLAG, - &Script::O_PRINTAT, - &Script::O_ZOOMIN, - &Script::O_ZOOMOUT, - &Script::O_SETSTRINGOFFSET, - &Script::O_GETOBJDATA, - &Script::O_SETOBJDATA, - &Script::O_SWAPOBJECTS, - &Script::O_CHANGEHEROSET, - &Script::O_ADDSTRING, - &Script::O_SUBSTRING, - &Script::O_INITDIALOG, - &Script::O_ENABLEDIALOGOPT, - &Script::O_DISABLEDIALOGOPT, - &Script::O_SHOWDIALOGBOX, - &Script::O_STOPSAMPLE, - &Script::O_BACKANIMRANGE, - &Script::O_CLEARPATH, - &Script::O_SETPATH, - &Script::O_GETHEROX, - &Script::O_GETHEROY, - &Script::O_GETHEROD, - &Script::O_PUSHSTRING, - &Script::O_POPSTRING, - &Script::O_SETFGCODE, - &Script::O_STOPHERO, - &Script::O_ANIMUPDATEOFF, - &Script::O_ANIMUPDATEON, - &Script::O_FREECURSOR, - &Script::O_ADDINVQUIET, - &Script::O_RUNHERO, - &Script::O_SETBACKANIMDATA, - &Script::O_VIEWFLC, - &Script::O_CHECKFLCFRAME, - &Script::O_CHECKFLCEND, - &Script::O_FREEFLC, - &Script::O_TALKHEROSTOP, - &Script::O_HEROCOLOR, - &Script::O_GRABMAPA, - &Script::O_ENABLENAK, - &Script::O_DISABLENAK, - &Script::O_GETMOBNAME, - &Script::O_SWAPINVENTORY, - &Script::O_CLEARINVENTORY, - &Script::O_SKIPTEXT, - &Script::O_SETVOICEH, - &Script::O_SETVOICEA, - &Script::O_SETVOICEB, - &Script::O_SETVOICEC, - &Script::O_VIEWFLCLOOP, - &Script::O_FLCSPEED, - &Script::O_OPENINVENTORY, - &Script::O_KRZYWA, - &Script::O_GETKRZYWA, - &Script::O_GETMOB, - &Script::O_INPUTLINE, - &Script::O_SETVOICED, - &Script::O_BREAK_POINT, + &Script::O_WAITFOREVER, + &Script::O_BLACKPALETTE, + &Script::O_SETUPPALETTE, + &Script::O_INITROOM, + &Script::O_SETSAMPLE, + &Script::O_FREESAMPLE, + &Script::O_PLAYSAMPLE, + &Script::O_PUTOBJECT, + &Script::O_REMOBJECT, + &Script::O_SHOWANIM, + &Script::O_CHECKANIMEND, + &Script::O_FREEANIM, + &Script::O_CHECKANIMFRAME, + &Script::O_PUTBACKANIM, + &Script::O_REMBACKANIM, + &Script::O_CHECKBACKANIMFRAME, + &Script::O_FREEALLSAMPLES, + &Script::O_SETMUSIC, + &Script::O_STOPMUSIC, + &Script::O__WAIT, + &Script::O_UPDATEOFF, + &Script::O_UPDATEON, + &Script::O_UPDATE , + &Script::O_CLS, + &Script::O__CALL, + &Script::O_RETURN, + &Script::O_GO, + &Script::O_BACKANIMUPDATEOFF, + &Script::O_BACKANIMUPDATEON, + &Script::O_CHANGECURSOR, + &Script::O_CHANGEANIMTYPE, + &Script::O__SETFLAG, + &Script::O_COMPARE, + &Script::O_JUMPZ, + &Script::O_JUMPNZ, + &Script::O_EXIT, + &Script::O_ADDFLAG, + &Script::O_TALKANIM, + &Script::O_SUBFLAG, + &Script::O_SETSTRING, + &Script::O_ANDFLAG, + &Script::O_GETMOBDATA, + &Script::O_ORFLAG, + &Script::O_SETMOBDATA, + &Script::O_XORFLAG, + &Script::O_GETMOBTEXT, + &Script::O_MOVEHERO, + &Script::O_WALKHERO, + &Script::O_SETHERO, + &Script::O_HEROOFF, + &Script::O_HEROON, + &Script::O_CLSTEXT, + &Script::O_CALLTABLE, + &Script::O_CHANGEMOB, + &Script::O_ADDINV, + &Script::O_REMINV, + &Script::O_REPINV, + &Script::O_OBSOLETE_GETACTION, + &Script::O_ADDWALKAREA, + &Script::O_REMWALKAREA, + &Script::O_RESTOREWALKAREA, + &Script::O_WAITFRAME, + &Script::O_SETFRAME, + &Script::O_RUNACTION, + &Script::O_COMPAREHI, + &Script::O_COMPARELO, + &Script::O_PRELOADSET, + &Script::O_FREEPRELOAD, + &Script::O_CHECKINV, + &Script::O_TALKHERO, + &Script::O_WAITTEXT, + &Script::O_SETHEROANIM, + &Script::O_WAITHEROANIM, + &Script::O_GETHERODATA, + &Script::O_GETMOUSEBUTTON, + &Script::O_CHANGEFRAMES, + &Script::O_CHANGEBACKFRAMES, + &Script::O_GETBACKANIMDATA, + &Script::O_GETANIMDATA, + &Script::O_SETBGCODE, + &Script::O_SETBACKFRAME, + &Script::O_GETRND, + &Script::O_TALKBACKANIM, + &Script::O_LOADPATH, + &Script::O_GETCHAR, + &Script::O_SETDFLAG, + &Script::O_CALLDFLAG, + &Script::O_PRINTAT, + &Script::O_ZOOMIN, + &Script::O_ZOOMOUT, + &Script::O_SETSTRINGOFFSET, + &Script::O_GETOBJDATA, + &Script::O_SETOBJDATA, + &Script::O_SWAPOBJECTS, + &Script::O_CHANGEHEROSET, + &Script::O_ADDSTRING, + &Script::O_SUBSTRING, + &Script::O_INITDIALOG, + &Script::O_ENABLEDIALOGOPT, + &Script::O_DISABLEDIALOGOPT, + &Script::O_SHOWDIALOGBOX, + &Script::O_STOPSAMPLE, + &Script::O_BACKANIMRANGE, + &Script::O_CLEARPATH, + &Script::O_SETPATH, + &Script::O_GETHEROX, + &Script::O_GETHEROY, + &Script::O_GETHEROD, + &Script::O_PUSHSTRING, + &Script::O_POPSTRING, + &Script::O_SETFGCODE, + &Script::O_STOPHERO, + &Script::O_ANIMUPDATEOFF, + &Script::O_ANIMUPDATEON, + &Script::O_FREECURSOR, + &Script::O_ADDINVQUIET, + &Script::O_RUNHERO, + &Script::O_SETBACKANIMDATA, + &Script::O_VIEWFLC, + &Script::O_CHECKFLCFRAME, + &Script::O_CHECKFLCEND, + &Script::O_FREEFLC, + &Script::O_TALKHEROSTOP, + &Script::O_HEROCOLOR, + &Script::O_GRABMAPA, + &Script::O_ENABLENAK, + &Script::O_DISABLENAK, + &Script::O_GETMOBNAME, + &Script::O_SWAPINVENTORY, + &Script::O_CLEARINVENTORY, + &Script::O_SKIPTEXT, + &Script::O_SETVOICEH, + &Script::O_SETVOICEA, + &Script::O_SETVOICEB, + &Script::O_SETVOICEC, + &Script::O_VIEWFLCLOOP, + &Script::O_FLCSPEED, + &Script::O_OPENINVENTORY, + &Script::O_KRZYWA, + &Script::O_GETKRZYWA, + &Script::O_GETMOB, + &Script::O_INPUTLINE, + &Script::O_SETVOICED, + &Script::O_BREAK_POINT, }; } +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/script.h b/engines/prince/script.h index 43d5759a0b..984b2d93e9 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -25,200 +25,221 @@ #include "common/random.h" +#include "audio/mixer.h" + +#include "prince/flags.h" + namespace Common { - class SeekableReadStream; + class SeekableReadStream; } namespace Prince { class PrinceEngine; -class Script -{ +class Script { public: - Script(PrinceEngine *vm); - virtual ~Script(); + Script(PrinceEngine *vm); + virtual ~Script(); - bool loadFromStream(Common::SeekableReadStream &stream); + bool loadFromStream(Common::SeekableReadStream &stream); - void step(); + void step(); + void setFlag(Flags::Id flag, uint16 value); private: - PrinceEngine *_vm; - - byte *_code; - uint32 _codeSize; - uint32 _currentInstruction; - uint16 _lastOpcode; - uint32 _lastInstruction; - byte _result; - int16 _flags[2000]; - bool _opcodeNF; - - // Stack - static const uint32 _STACK_SIZE = 500; - uint16 _stack[_STACK_SIZE]; - uint8 _stacktop; - uint8 _savedStacktop; - - // Helper functions - void checkPC(uint32 address); - uint8 getCodeByte(uint32 address); - uint8 readScript8bits(); - uint16 readScript16bits(); - uint32 readScript32bits(); - uint16 readScript8or16bits(); - void debugScript(const char *s, ...); - - typedef void (Script::*OpcodeFunc)(); - static OpcodeFunc _opcodes[]; - - void O_WAITFOREVER(); - void O_BLACKPALETTE(); - void O_SETUPPALETTE(); - void O_INITROOM(); - void O_SETSAMPLE(); - void O_FREESAMPLE(); - void O_PLAYSAMPLE(); - void O_PUTOBJECT(); - void O_REMOBJECT(); - void O_SHOWANIM(); - void O_CHECKANIMEND(); - void O_FREEANIM(); - void O_CHECKANIMFRAME(); - void O_PUTBACKANIM(); - void O_REMBACKANIM(); - void O_CHECKBACKANIMFRAME(); - void O_FREEALLSAMPLES(); - void O_SETMUSIC(); - void O_STOPMUSIC(); - void O__WAIT(); - void O_UPDATEOFF(); - void O_UPDATEON(); - void O_UPDATE (); - void O_CLS(); - void O__CALL(); - void O_RETURN(); - void O_GO(); - void O_BACKANIMUPDATEOFF(); - void O_BACKANIMUPDATEON(); - void O_CHANGECURSOR(); - void O_CHANGEANIMTYPE(); - void O__SETFLAG(); - void O_COMPARE(); - void O_JUMPZ(); - void O_JUMPNZ(); - void O_EXIT(); - void O_ADDFLAG(); - void O_TALKANIM(); - void O_SUBFLAG(); - void O_SETSTRING(); - void O_ANDFLAG(); - void O_GETMOBDATA(); - void O_ORFLAG(); - void O_SETMOBDATA(); - void O_XORFLAG(); - void O_GETMOBTEXT(); - void O_MOVEHERO(); - void O_WALKHERO(); - void O_SETHERO(); - void O_HEROOFF(); - void O_HEROON(); - void O_CLSTEXT(); - void O_CALLTABLE(); - void O_CHANGEMOB(); - void O_ADDINV(); - void O_REMINV(); - void O_REPINV(); - void O_OBSOLETE_GETACTION(); - void O_ADDWALKAREA(); - void O_REMWALKAREA(); - void O_RESTOREWALKAREA(); - void O_WAITFRAME(); - void O_SETFRAME(); - void O_RUNACTION(); - void O_COMPAREHI(); - void O_COMPARELO(); - void O_PRELOADSET(); - void O_FREEPRELOAD(); - void O_CHECKINV(); - void O_TALKHERO(); - void O_WAITTEXT(); - void O_SETHEROANIM(); - void O_WAITHEROANIM(); - void O_GETHERODATA(); - void O_GETMOUSEBUTTON(); - void O_CHANGEFRAMES(); - void O_CHANGEBACKFRAMES(); - void O_GETBACKANIMDATA(); - void O_GETANIMDATA(); - void O_SETBGCODE(); - void O_SETBACKFRAME(); - void O_GETRND(); - void O_TALKBACKANIM(); - void O_LOADPATH(); - void O_GETCHAR(); - void O_SETDFLAG(); - void O_CALLDFLAG(); - void O_PRINTAT(); - void O_ZOOMIN(); - void O_ZOOMOUT(); - void O_SETSTRINGOFFSET(); - void O_GETOBJDATA(); - void O_SETOBJDATA(); - void O_SWAPOBJECTS(); - void O_CHANGEHEROSET(); - void O_ADDSTRING(); - void O_SUBSTRING(); - void O_INITDIALOG(); - void O_ENABLEDIALOGOPT(); - void O_DISABLEDIALOGOPT(); - void O_SHOWDIALOGBOX(); - void O_STOPSAMPLE(); - void O_BACKANIMRANGE(); - void O_CLEARPATH(); - void O_SETPATH(); - void O_GETHEROX(); - void O_GETHEROY(); - void O_GETHEROD(); - void O_PUSHSTRING(); - void O_POPSTRING(); - void O_SETFGCODE(); - void O_STOPHERO(); - void O_ANIMUPDATEOFF(); - void O_ANIMUPDATEON(); - void O_FREECURSOR(); - void O_ADDINVQUIET(); - void O_RUNHERO(); - void O_SETBACKANIMDATA(); - void O_VIEWFLC(); - void O_CHECKFLCFRAME(); - void O_CHECKFLCEND(); - void O_FREEFLC(); - void O_TALKHEROSTOP(); - void O_HEROCOLOR(); - void O_GRABMAPA(); - void O_ENABLENAK(); - void O_DISABLENAK(); - void O_GETMOBNAME(); - void O_SWAPINVENTORY(); - void O_CLEARINVENTORY(); - void O_SKIPTEXT(); - void O_SETVOICEH(); - void O_SETVOICEA(); - void O_SETVOICEB(); - void O_SETVOICEC(); - void O_VIEWFLCLOOP(); - void O_FLCSPEED(); - void O_OPENINVENTORY(); - void O_KRZYWA(); - void O_GETKRZYWA(); - void O_GETMOB(); - void O_INPUTLINE(); - void O_SETVOICED(); - void O_BREAK_POINT(); + PrinceEngine *_vm; + + byte *_code; + uint32 _codeSize; + uint32 _currentInstruction; + + uint32 _bgOpcodePC; + uint32 _fgOpcodePC; + + uint16 _lastOpcode; + uint32 _lastInstruction; + byte _result; + int16 _flags[2000]; + bool _opcodeNF; + + + // Stack + static const uint32 _STACK_SIZE = 500; + uint32 _stack[_STACK_SIZE]; + uint8 _stacktop; + uint8 _savedStacktop; + uint32 _waitFlag; + Audio::SoundHandle _soundHandle; + + const byte * _string; + uint32 _currentString; + Common::SeekableReadStream *_voiceStream; + + // Helper functions + uint32 step(uint32 opcodePC); + void checkPC(uint32 address); + uint8 getCodeByte(uint32 address); + uint8 readScript8bits(); + uint16 readScript16bits(); + uint32 readScript32bits(); + uint16 readScript8or16bits(); + void debugScript(const char *s, ...); + void SetVoice(uint32 slot); + + typedef void (Script::*OpcodeFunc)(); + static OpcodeFunc _opcodes[]; + + // Keep opcode handlers names as they are in original code + // it easier to switch back and forth + void O_WAITFOREVER(); + void O_BLACKPALETTE(); + void O_SETUPPALETTE(); + void O_INITROOM(); + void O_SETSAMPLE(); + void O_FREESAMPLE(); + void O_PLAYSAMPLE(); + void O_PUTOBJECT(); + void O_REMOBJECT(); + void O_SHOWANIM(); + void O_CHECKANIMEND(); + void O_FREEANIM(); + void O_CHECKANIMFRAME(); + void O_PUTBACKANIM(); + void O_REMBACKANIM(); + void O_CHECKBACKANIMFRAME(); + void O_FREEALLSAMPLES(); + void O_SETMUSIC(); + void O_STOPMUSIC(); + void O__WAIT(); + void O_UPDATEOFF(); + void O_UPDATEON(); + void O_UPDATE (); + void O_CLS(); + void O__CALL(); + void O_RETURN(); + void O_GO(); + void O_BACKANIMUPDATEOFF(); + void O_BACKANIMUPDATEON(); + void O_CHANGECURSOR(); + void O_CHANGEANIMTYPE(); + void O__SETFLAG(); + void O_COMPARE(); + void O_JUMPZ(); + void O_JUMPNZ(); + void O_EXIT(); + void O_ADDFLAG(); + void O_TALKANIM(); + void O_SUBFLAG(); + void O_SETSTRING(); + void O_ANDFLAG(); + void O_GETMOBDATA(); + void O_ORFLAG(); + void O_SETMOBDATA(); + void O_XORFLAG(); + void O_GETMOBTEXT(); + void O_MOVEHERO(); + void O_WALKHERO(); + void O_SETHERO(); + void O_HEROOFF(); + void O_HEROON(); + void O_CLSTEXT(); + void O_CALLTABLE(); + void O_CHANGEMOB(); + void O_ADDINV(); + void O_REMINV(); + void O_REPINV(); + void O_OBSOLETE_GETACTION(); + void O_ADDWALKAREA(); + void O_REMWALKAREA(); + void O_RESTOREWALKAREA(); + void O_WAITFRAME(); + void O_SETFRAME(); + void O_RUNACTION(); + void O_COMPAREHI(); + void O_COMPARELO(); + void O_PRELOADSET(); + void O_FREEPRELOAD(); + void O_CHECKINV(); + void O_TALKHERO(); + void O_WAITTEXT(); + void O_SETHEROANIM(); + void O_WAITHEROANIM(); + void O_GETHERODATA(); + void O_GETMOUSEBUTTON(); + void O_CHANGEFRAMES(); + void O_CHANGEBACKFRAMES(); + void O_GETBACKANIMDATA(); + void O_GETANIMDATA(); + void O_SETBGCODE(); + void O_SETBACKFRAME(); + void O_GETRND(); + void O_TALKBACKANIM(); + void O_LOADPATH(); + void O_GETCHAR(); + void O_SETDFLAG(); + void O_CALLDFLAG(); + void O_PRINTAT(); + void O_ZOOMIN(); + void O_ZOOMOUT(); + void O_SETSTRINGOFFSET(); + void O_GETOBJDATA(); + void O_SETOBJDATA(); + void O_SWAPOBJECTS(); + void O_CHANGEHEROSET(); + void O_ADDSTRING(); + void O_SUBSTRING(); + void O_INITDIALOG(); + void O_ENABLEDIALOGOPT(); + void O_DISABLEDIALOGOPT(); + void O_SHOWDIALOGBOX(); + void O_STOPSAMPLE(); + void O_BACKANIMRANGE(); + void O_CLEARPATH(); + void O_SETPATH(); + void O_GETHEROX(); + void O_GETHEROY(); + void O_GETHEROD(); + void O_PUSHSTRING(); + void O_POPSTRING(); + void O_SETFGCODE(); + void O_STOPHERO(); + void O_ANIMUPDATEOFF(); + void O_ANIMUPDATEON(); + void O_FREECURSOR(); + void O_ADDINVQUIET(); + void O_RUNHERO(); + void O_SETBACKANIMDATA(); + void O_VIEWFLC(); + void O_CHECKFLCFRAME(); + void O_CHECKFLCEND(); + void O_FREEFLC(); + void O_TALKHEROSTOP(); + void O_HEROCOLOR(); + void O_GRABMAPA(); + void O_ENABLENAK(); + void O_DISABLENAK(); + void O_GETMOBNAME(); + void O_SWAPINVENTORY(); + void O_CLEARINVENTORY(); + void O_SKIPTEXT(); + void O_SETVOICEH(); + void O_SETVOICEA(); + void O_SETVOICEB(); + void O_SETVOICEC(); + void O_VIEWFLCLOOP(); + void O_FLCSPEED(); + void O_OPENINVENTORY(); + void O_KRZYWA(); + void O_GETKRZYWA(); + void O_GETMOB(); + void O_INPUTLINE(); + void O_SETVOICED(); + void O_BREAK_POINT(); }; } #endif + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/sound.cpp b/engines/prince/sound.cpp new file mode 100644 index 0000000000..40f182e630 --- /dev/null +++ b/engines/prince/sound.cpp @@ -0,0 +1,216 @@ +/* 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. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#include "prince/prince.h" +#include "prince/sound.h" +#include "prince/musNum.h" + +#include "common/config-manager.h" +#include "common/memstream.h" +#include "common/archive.h" +#include "audio/decoders/raw.h" +#include "audio/audiostream.h" + +namespace Prince { + +const char * MusicPlayer::_musTable[] = { + "", + "Battlfld.mid", + "Cave.mid", + "Cemetery.mid", + "Credits.mid", + "Fjord.mid", + "Guitar.mid", + "Hell.mid", + "Jingle.mid", + "Main.mid", + "Night.mid", + "Reality.mid", + "Sunlord.mid", + "Tavern.mid", + "Temple.mid", + "Boruta.mid", + "Intro.mid" +}; + +const uint8 MusicPlayer::_musRoomTable[] = { + 0, + ROOM01MUS, + ROOM02MUS, + ROOM03MUS, + ROOM04MUS, + ROOM05MUS, + ROOM06MUS, + ROOM07MUS, + ROOM08MUS, + ROOM09MUS, + ROOM10MUS, + ROOM11MUS, + ROOM12MUS, + ROOM13MUS, + ROOM14MUS, + ROOM15MUS, + ROOM16MUS, + ROOM17MUS, + ROOM18MUS, + ROOM19MUS, + ROOM20MUS, + ROOM21MUS, + ROOM22MUS, + ROOM23MUS, + ROOM24MUS, + ROOM25MUS, + ROOM26MUS, + ROOM27MUS, + ROOM28MUS, + ROOM29MUS, + ROOM30MUS, + ROOM31MUS, + ROOM32MUS, + ROOM33MUS, + ROOM34MUS, + ROOM35MUS, + ROOM36MUS, + ROOM37MUS, + ROOM38MUS, + ROOM39MUS, + ROOM40MUS, + ROOM41MUS, + ROOM42MUS, + ROOM43MUS, + 0, + 0, + ROOM46MUS, + ROOM47MUS, + ROOM48MUS, + ROOM49MUS, + ROOM50MUS, + ROOM51MUS, + ROOM52MUS, + ROOM53MUS, + ROOM54MUS, + ROOM55MUS, + ROOM56MUS, + ROOM57MUS, + ROOM58MUS, + ROOM59MUS, + ROOM60MUS, + ROOM61MUS +}; + + +MusicPlayer::MusicPlayer(PrinceEngine *vm) : _vm(vm) { + _data = NULL; + _isGM = false; + + MidiPlayer::createDriver(); + + int ret = _driver->open(); + if (ret == 0) { + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + + // TODO: Load cmf.ins with the instrument table. It seems that an + // interface for such an operation is supported for AdLib. Maybe for + // this card, setting instruments is necessary. + + _driver->setTimerCallback(this, &timerCallback); + } +} + +MusicPlayer::~MusicPlayer() { + killMidi(); +} + +void MusicPlayer::killMidi() { + Audio::MidiPlayer::stop(); + + free(_data); + _data = NULL; +} + +void MusicPlayer::loadMidi(const char * name) { + Common::SeekableReadStream * stream = SearchMan.createReadStreamForMember(name); + if (!stream) + return; + + // Stop any currently playing MIDI file + killMidi(); + + // Read in the data for the file + _dataSize = stream->size(); + _data = (byte *)malloc(_dataSize); + stream->read(_data, _dataSize); + + // Start playing the music + sndMidiStart(); +} + +void MusicPlayer::sndMidiStart() { + _isGM = true; + + MidiParser *parser = MidiParser::createParser_SMF(); + if (parser->loadMusic(_data, _dataSize)) { + parser->setTrack(0); + parser->setMidiDriver(this); + parser->setTimerRate(_driver->getBaseTempo()); + parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); + + _parser = parser; + + syncVolume(); + + // Al the tracks are supposed to loop + _isLooping = true; + _isPlaying = true; + } +} + +void MusicPlayer::send(uint32 b) { + if ((b & 0xF0) == 0xC0 && !_isGM && !_nativeMT32) { + b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8; + } + + Audio::MidiPlayer::send(b); +} + +void MusicPlayer::sendToChannel(byte channel, uint32 b) { + if (!_channelsTable[channel]) { + _channelsTable[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel(); + // If a new channel is allocated during the playback, make sure + // its volume is correctly initialized. + if (_channelsTable[channel]) + _channelsTable[channel]->volume(_channelsVolume[channel] * _masterVolume / 255); + } + + if (_channelsTable[channel]) + _channelsTable[channel]->send(b); +} + +} // End of namespace CGE diff --git a/engines/prince/sound.h b/engines/prince/sound.h new file mode 100644 index 0000000000..7219411b36 --- /dev/null +++ b/engines/prince/sound.h @@ -0,0 +1,73 @@ +/* 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. + * + */ + +/* + * This code is based on original Soltys source code + * Copyright (c) 1994-1995 Janus B. Wisniewski and L.K. Avalon + */ + +#ifndef PRINCE_SOUND_H +#define PRINCE_SOUND_H + +#include "audio/audiostream.h" +#include "audio/decoders/wave.h" +#include "audio/fmopl.h" +#include "audio/mididrv.h" +#include "audio/midiparser.h" +#include "audio/midiplayer.h" +#include "audio/mixer.h" +#include "common/memstream.h" + +namespace Prince { + +class PrinceEngine; + +class MusicPlayer: public Audio::MidiPlayer { +private: + PrinceEngine *_vm; + byte *_data; + int _dataSize; + bool _isGM; + + // Start MIDI File + void sndMidiStart(); + + // Stop MIDI File + void sndMidiStop(); +public: + MusicPlayer(PrinceEngine *vm); + ~MusicPlayer(); + + void loadMidi(const char *); + void killMidi(); + + virtual void send(uint32 b); + virtual void sendToChannel(byte channel, uint32 b); + + static const char * _musTable[]; + static const uint8 _musRoomTable[]; +}; + +} // End of namespace Prince + +#endif + diff --git a/engines/prince/variatxt.cpp b/engines/prince/variatxt.cpp new file mode 100644 index 0000000000..0788d449e3 --- /dev/null +++ b/engines/prince/variatxt.cpp @@ -0,0 +1,59 @@ +/* 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 "prince/variatxt.h" +#include "common/debug.h" + +namespace Prince { + +VariaTxt::VariaTxt() : _dataSize(0), _data(NULL) { +} + +VariaTxt::~VariaTxt() { + _dataSize = 0; + delete[] _data; + _dataSize = NULL; +} + + +bool VariaTxt::loadFromStream(Common::SeekableReadStream &stream) { + _dataSize = stream.size(); + _data = new byte [_dataSize]; + stream.read(_data, _dataSize); + return true; +} + +const char * VariaTxt::getString(uint32 stringId) { + uint32 stringOffset = READ_LE_UINT32(_data + stringId); + + if (stringOffset > _dataSize) { + assert(false); + } + + debug("VariaTxt::getString %04X %04X", stringId, stringOffset); + + return (const char *)_data + stringOffset; +} + +} + +/* vim: set tabstop=4 noexpandtab: */ diff --git a/engines/prince/variatxt.h b/engines/prince/variatxt.h new file mode 100644 index 0000000000..dcdba7bd8a --- /dev/null +++ b/engines/prince/variatxt.h @@ -0,0 +1,44 @@ +/* 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/stream.h" + +namespace Prince { + +class VariaTxt { +public: + VariaTxt(); + + ~VariaTxt(); + + bool loadFromStream(Common::SeekableReadStream &stream); + + const char * getString(uint32 stringId); + +private: + uint32 _dataSize; + byte *_data; +}; + +} + +/* vim: set tabstop=4 noexpandtab: */ |