1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SWORD1_SWORD1_H 24 #define SWORD1_SWORD1_H 25 26 #include "engines/engine.h" 27 #include "common/error.h" 28 #include "common/keyboard.h" 29 #include "common/rect.h" 30 #include "common/util.h" 31 #include "sword1/sworddefs.h" 32 #include "sword1/console.h" 33 34 /** 35 * This is the namespace of the Sword1 engine. 36 * 37 * Status of this engine: ??? 38 * 39 * Games using this engine: 40 * - Broken Sword: The Shadow of the Templars 41 */ 42 namespace Sword1 { 43 44 enum { 45 GF_DEMO = 1 << 0 46 }; 47 48 enum ControlPanelMode { 49 CP_NORMAL = 0, 50 CP_DEATHSCREEN, 51 CP_THEEND, 52 CP_NEWGAME 53 }; 54 55 class Screen; 56 class Sound; 57 class Logic; 58 class Mouse; 59 class ResMan; 60 class ObjectMan; 61 class Menu; 62 class Music; 63 class Control; 64 65 struct SystemVars { 66 bool runningFromCd; 67 uint32 currentCD; // starts at zero, then either 1 or 2 depending on section being played 68 uint32 justRestoredGame; // see main() in sword.c & New_screen() in gtm_core.c 69 70 uint8 controlPanelMode; // 1 death screen version of the control panel, 2 = successful end of game, 3 = force restart 71 bool forceRestart; 72 bool wantFade; // when true => fade during scene change, else cut. 73 bool playSpeech; 74 bool showText; 75 uint8 language; 76 bool isDemo; 77 bool isSpanishDemo; 78 Common::Platform platform; 79 Common::Language realLanguage; 80 bool isLangRtl; 81 }; 82 83 class SwordEngine : public Engine { 84 friend class SwordConsole; 85 public: 86 SwordEngine(OSystem *syst); 87 ~SwordEngine() override; 88 static SystemVars _systemVars; 89 void reinitialize(); 90 91 uint32 _features; 92 93 bool mouseIsActive(); 94 isMac()95 static bool isMac() { return _systemVars.platform == Common::kPlatformMacintosh; } isPsx()96 static bool isPsx() { return _systemVars.platform == Common::kPlatformPSX; } isWindows()97 static bool isWindows() { return _systemVars.platform == Common::kPlatformWindows ; } 98 99 protected: 100 // Engine APIs 101 Common::Error init(); 102 Common::Error go(); run()103 Common::Error run() override { 104 Common::Error err; 105 err = init(); 106 if (err.getCode() != Common::kNoError) 107 return err; 108 return go(); 109 } 110 bool hasFeature(EngineFeature f) const override; 111 void syncSoundSettings() override; 112 113 Common::Error loadGameState(int slot) override; 114 bool canLoadGameStateCurrently() override; 115 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override; 116 bool canSaveGameStateCurrently() override; getSaveStateName(int slot)117 virtual Common::String getSaveStateName(int slot) const override { 118 return Common::String::format("sword1.%03d", slot); 119 } 120 private: 121 void delay(int32 amount); 122 123 void checkCdFiles(); 124 void checkCd(); 125 void showFileErrorMsg(uint8 type, bool *fileExists); 126 void flagsToBool(bool *dest, uint8 flags); 127 128 void reinitRes(); //Reinits the resources after a GMM load 129 130 uint8 mainLoop(); 131 132 Common::Point _mouseCoord; 133 uint16 _mouseState; 134 Common::KeyState _keyPressed; 135 136 ResMan *_resMan; 137 ObjectMan *_objectMan; 138 Screen *_screen; 139 Mouse *_mouse; 140 Logic *_logic; 141 Sound *_sound; 142 Menu *_menu; 143 Music *_music; 144 Control *_control; 145 static const uint8 _cdList[TOTAL_SECTIONS]; 146 static const CdFile _pcCdFileList[]; 147 static const CdFile _macCdFileList[]; 148 static const CdFile _psxCdFileList[]; 149 }; 150 151 } // End of namespace Sword1 152 153 #endif // SWORD1_SWORD1_H 154