ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
castle.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 namespace Freescape {
23 
24 struct RiddleText {
25  int8 _dx;
26  int8 _dy;
27  Common::String _text;
28 
29  RiddleText(int8 dx, int8 dy, const Common::String &text) : _dx(dx), _dy(dy), _text(text) {}
30 };
31 
32 struct Riddle {
33  Common::Point _origin;
35 };
36 
37 class CastleEngine : public FreescapeEngine {
38 public:
39  CastleEngine(OSystem *syst, const ADGameDescription *gd);
40  ~CastleEngine();
41 
42  // Only in DOS
43  Graphics::ManagedSurface *_option;
44  Graphics::ManagedSurface *_menuButtons;
45  Graphics::ManagedSurface *_menuCrawlIndicator;
46  Graphics::ManagedSurface *_menuWalkIndicator;
47  Graphics::ManagedSurface *_menuRunIndicator;
48  Graphics::ManagedSurface *_menuFxOnIndicator;
49  Graphics::ManagedSurface *_menuFxOffIndicator;
51 
52  void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
53  void initGameState() override;
54  void endGame() override;
55 
56  void drawInfoMenu() override;
57  void loadAssets() override;
58  void loadAssetsDOSFullGame() override;
59  void loadAssetsDOSDemo() override;
60  void loadAssetsAmigaDemo() override;
61  void loadAssetsZXFullGame() override;
62  void loadAssetsCPCFullGame() override;
63  void borderScreen() override;
64  void selectCharacterScreen();
65  void drawOption();
66 
67  void initZX();
68  void initDOS();
69  void initCPC();
70 
71  void drawDOSUI(Graphics::Surface *surface) override;
72  void drawZXUI(Graphics::Surface *surface) override;
73  void drawCPCUI(Graphics::Surface *surface) override;
74  void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
75  void drawEnergyMeter(Graphics::Surface *surface, Common::Point origin);
76  void pressedKey(const int keycode) override;
77  void checkSensors() override;
78  void updateTimeVariables() override;
79 
80  bool checkIfGameEnded() override;
81  void drawSensorShoot(Sensor *sensor) override;
82 
83  void executePrint(FCLInstruction &instruction) override;
84  void executeDestroy(FCLInstruction &instruction) override;
85  void executeRedraw(FCLInstruction &instruction) override;
86  void gotoArea(uint16 areaID, int entranceID) override;
87  Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
88  Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
89 
90  Common::Array<Riddle> _riddleList;
91  Common::BitArray _fontPlane1;
92  Common::BitArray _fontPlane2;
93  Common::BitArray _fontPlane3;
94 
95  void drawRiddleStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface);
96  Graphics::ManagedSurface *loadFrameWithHeaderDOS(Common::SeekableReadStream *file);
97  Common::Array <Graphics::ManagedSurface *>loadFramesWithHeaderDOS(Common::SeekableReadStream *file, int numFrames);
98 
99  Common::Array<Graphics::ManagedSurface *> loadFramesWithHeader(Common::SeekableReadStream *file, int pos, int numFrames, uint32 front, uint32 back);
100  Graphics::ManagedSurface *loadFrameWithHeader(Common::SeekableReadStream *file, int pos, uint32 front, uint32 back);
101  Graphics::ManagedSurface *loadFrame(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height, uint32 back);
102  Graphics::ManagedSurface *loadFrameFromPlanes(Common::SeekableReadStream *file, int widthInBytes, int height);
103  Graphics::ManagedSurface *loadFrameFromPlanesInternal(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height);
104 
105  Graphics::ManagedSurface *loadFrameFromPlanesVertical(Common::SeekableReadStream *file, int widthInBytes, int height);
106  Graphics::ManagedSurface *loadFrameFromPlanesInternalVertical(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height, int plane);
107 
110  Graphics::ManagedSurface *_spiritsMeterIndicatorBackgroundFrame;
111  Graphics::ManagedSurface *_spiritsMeterIndicatorFrame;
112  Graphics::ManagedSurface *_spiritsMeterIndicatorSideFrame;
113  Graphics::ManagedSurface *_strenghtBackgroundFrame;
114  Graphics::ManagedSurface *_strenghtBarFrame;
115  Common::Array<Graphics::ManagedSurface *> _strenghtWeightsFrames;
117  Graphics::ManagedSurface *_thunderFrame;
118  Graphics::ManagedSurface *_riddleTopFrame;
119  Graphics::ManagedSurface *_riddleBackgroundFrame;
120  Graphics::ManagedSurface *_riddleBottomFrame;
121 
122  Graphics::ManagedSurface *_endGameThroneFrame;
123  Graphics::ManagedSurface *_endGameBackgroundFrame;
124  Graphics::ManagedSurface *_gameOverBackgroundFrame;
125 
126  Common::Array<int> _keysCollected;
127  bool _useRockTravel;
128  int _spiritsMeter;
129  int _spiritsMeterPosition;
130  int _spiritsMeterMax;
131  int _spiritsToKill;
132 
133  int _lastTenSeconds;
134 
135 private:
136  Common::SeekableReadStream *decryptFile(const Common::Path &filename);
137  void loadRiddles(Common::SeekableReadStream *file, int offset, int number);
138  void loadDOSFonts(Common::SeekableReadStream *file, int pos);
139  void drawFullscreenRiddleAndWait(uint16 riddle);
140  void drawFullscreenEndGameAndWait();
141  void drawFullscreenGameOverAndWait();
142  void drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics::Surface *surface);
143  void tryToCollectKey();
144  void addGhosts();
145  bool ghostInArea();
146  Texture *_optionTexture;
147  Font _fontRiddle;
148 };
149 
150 }
Definition: managed_surface.h:51
Definition: keymap.h:66
Definition: str.h:59
Definition: surface.h:67
Definition: stream.h:77
Definition: error.h:84
Definition: area.h:36
Definition: array.h:52
Definition: advancedDetector.h:163
Definition: path.h:52
Definition: stream.h:745
Definition: freescape.h:159
Definition: castle.h:32
Definition: sensor.h:34
Definition: bitarray.h:29
Definition: rect.h:45
Definition: castle.h:24
Definition: font.h:32
Definition: system.h:161
Definition: instruction.h:36
Definition: castle.h:37
Definition: gfx.h:47