ScummVM API documentation
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 borderScreen() override;
63  void selectCharacterScreen();
64  void drawOption();
65 
66  void initZX();
67  void initDOS();
68 
69  void drawDOSUI(Graphics::Surface *surface) override;
70  void drawZXUI(Graphics::Surface *surface) override;
71  void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
72  void drawEnergyMeter(Graphics::Surface *surface, Common::Point origin);
73  void pressedKey(const int keycode) override;
74  void checkSensors() override;
75  void updateTimeVariables() override;
76 
77  bool checkIfGameEnded() override;
78  void drawSensorShoot(Sensor *sensor) override;
79 
80  void executePrint(FCLInstruction &instruction) override;
81  void executeDestroy(FCLInstruction &instruction) override;
82  void executeRedraw(FCLInstruction &instruction) override;
83  void gotoArea(uint16 areaID, int entranceID) override;
84  Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
85  Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
86 
87  Common::Array<Riddle> _riddleList;
88  Common::BitArray _fontPlane1;
89  Common::BitArray _fontPlane2;
90  Common::BitArray _fontPlane3;
91 
92  void drawRiddleStringInSurface(const Common::String &str, int x, int y, uint32 fontColor, uint32 backColor, Graphics::Surface *surface);
93  Graphics::ManagedSurface *loadFrameWithHeaderDOS(Common::SeekableReadStream *file);
94  Common::Array <Graphics::ManagedSurface *>loadFramesWithHeaderDOS(Common::SeekableReadStream *file, int numFrames);
95 
96  Common::Array<Graphics::ManagedSurface *> loadFramesWithHeader(Common::SeekableReadStream *file, int pos, int numFrames, uint32 front, uint32 back);
97  Graphics::ManagedSurface *loadFrameWithHeader(Common::SeekableReadStream *file, int pos, uint32 front, uint32 back);
98  Graphics::ManagedSurface *loadFrame(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height, uint32 back);
99  Graphics::ManagedSurface *loadFrameFromPlanes(Common::SeekableReadStream *file, int widthInBytes, int height);
100  Graphics::ManagedSurface *loadFrameFromPlanesInternal(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height);
101 
102  Graphics::ManagedSurface *loadFrameFromPlanesVertical(Common::SeekableReadStream *file, int widthInBytes, int height);
103  Graphics::ManagedSurface *loadFrameFromPlanesInternalVertical(Common::SeekableReadStream *file, Graphics::ManagedSurface *surface, int width, int height, int plane);
104 
107  Graphics::ManagedSurface *_spiritsMeterIndicatorBackgroundFrame;
108  Graphics::ManagedSurface *_spiritsMeterIndicatorFrame;
109  Graphics::ManagedSurface *_spiritsMeterIndicatorSideFrame;
110  Graphics::ManagedSurface *_strenghtBackgroundFrame;
111  Graphics::ManagedSurface *_strenghtBarFrame;
112  Common::Array<Graphics::ManagedSurface *> _strenghtWeightsFrames;
114  Graphics::ManagedSurface *_thunderFrame;
115  Graphics::ManagedSurface *_riddleTopFrame;
116  Graphics::ManagedSurface *_riddleBackgroundFrame;
117  Graphics::ManagedSurface *_riddleBottomFrame;
118 
119  Graphics::ManagedSurface *_endGameThroneFrame;
120  Graphics::ManagedSurface *_endGameBackgroundFrame;
121  Graphics::ManagedSurface *_gameOverBackgroundFrame;
122 
123  Common::Array<int> _keysCollected;
124  bool _useRockTravel;
125  int _spiritsMeter;
126  int _spiritsMeterPosition;
127  int _spiritsMeterMax;
128  int _spiritsToKill;
129 
130  int _lastTenSeconds;
131 
132 private:
133  Common::SeekableReadStream *decryptFile(const Common::Path &filename);
134  void loadRiddles(Common::SeekableReadStream *file, int offset, int number);
135  void loadDOSFonts(Common::SeekableReadStream *file, int pos);
136  void drawFullscreenRiddleAndWait(uint16 riddle);
137  void drawFullscreenEndGameAndWait();
138  void drawFullscreenGameOverAndWait();
139  void drawRiddle(uint16 riddle, uint32 front, uint32 back, Graphics::Surface *surface);
140  void tryToCollectKey();
141  void addGhosts();
142  bool ghostInArea();
143  Texture *_optionTexture;
144  Font _fontRiddle;
145 };
146 
147 }
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:152
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:45