ScummVM API documentation
dark.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 #include "audio/mixer.h"
23 #include "common/array.h"
24 #include "freescape/games/dark/c64.music.h"
25 #include "freescape/games/dark/c64.sfx.h"
26 
27 namespace Freescape {
28 
29 enum {
30  kVariableDarkEnding = 28,
31  kVariableDarkECD = 29,
32  kVariableActiveECDs = 60,
33 };
34 
35 enum {
36  kDarkEndingEvathDestroyed = 1,
37  kDarkEndingECDsDestroyed = 2,
38 };
39 
40 struct ECD {
41  uint16 _area;
42  int _id;
43 };
44 
45 enum DarkFontSize {
46  kDarkFontSmall,
47  kDarkFontMedium,
48  kDarkFontBig,
49 };
50 
51 class DarkEngine : public FreescapeEngine {
52 public:
53  DarkEngine(OSystem *syst, const ADGameDescription *gd);
54  ~DarkEngine();
55 
56  uint32 _initialEnergy;
57  uint32 _initialShield;
58  uint32 _jetFuelSeconds;
59  void addSkanner(Area *area);
60 
61  void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
62  void initGameState() override;
63  void borderScreen() override;
64  bool triggerWinCondition() override;
65  bool checkIfGameEnded() override;
66  void endGame() override;
67 
68  void gotoArea(uint16 areaID, int entranceID) override;
69  void pressedKey(const int keycode) override;
70  void executePrint(FCLInstruction &instruction) override;
71 
72  void initDOS();
73  void initC64();
74  void initAmigaAtari();
75  void initZX();
76  void initCPC();
77 
78  void loadAssets() override;
79  void loadAssetsDOSFullGame() override;
80  void loadAssetsDOSDemo() override;
81  void loadAssetsC64FullGame() override;
82  void loadAssetsAmigaFullGame() override;
83  void loadAssetsAtariFullGame() override;
84 
85  void loadAssetsCPCFullGame() override;
86 
87  void loadAssetsZXDemo() override;
88  void loadAssetsZXFullGame() override;
89  void loadMessagesVariableSize(Common::SeekableReadStream *file, int offset, int number) override;
90 
91  int _lastTenSeconds;
92  int _lastSecond;
93  void updateTimeVariables() override;
94 
95  void drawBinaryClock(Graphics::Surface *surface, int xPosition, int yPosition, uint32 front, uint32 back);
96  void drawIndicator(Graphics::Surface *surface, int xPosition, int yPosition);
97 
98  void drawSensorShoot(Sensor *sensor) override;
99  void drawDOSUI(Graphics::Surface *surface) override;
100  void drawC64UI(Graphics::Surface *surface) override;
101  void drawZXUI(Graphics::Surface *surface) override;
102  void drawCPCUI(Graphics::Surface *surface) override;
103  void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
104  void drawC64Compass(Graphics::Surface *surface);
105 
106  Font _fontBig;
107  Font _fontMedium;
108  Font _fontSmall;
110  Common::Array<Graphics::ManagedSurface *> _cpcJetpackIndicators;
111  Common::Array<Graphics::ManagedSurface *> _cpcActionIndicators;
112  uint32 _cpcActionIndicatorUntilMillis;
114 
115  // Dark Side Amiga stores the grounded jetpack indicator states as raw
116  // 4-plane bitplane data. The executable drives those frames through a tiny
117  // fixed color ramp, so the renderer keeps the raw planes and applies a
118  // hardcoded palette at draw time.
119  Common::Array<Common::Array<byte>> _jetpackTransitionFrames;
120  Common::Array<byte> _jetpackCrouchFrame;
121  Common::Array<Graphics::ManagedSurface *> _amigaCompassYawFrames;
122  Graphics::ManagedSurface *_amigaCompassPitchMarker;
123  Common::Array<Graphics::ManagedSurface *> _amigaCompassNeedleFrames;
124  Common::Array<Graphics::ManagedSurface *> _amigaCompassLeftFrames;
125  Common::Array<Graphics::ManagedSurface *> _amigaCompassRightFrames;
126  bool _amigaCompassYawPhaseInitialized;
127  int _amigaCompassYawPhase;
128  int _amigaCompassYawLastUpdateTick;
129  bool _jetpackIndicatorStateInitialized;
130  bool _jetpackIndicatorLastFlyMode;
131  int _jetpackIndicatorTransitionFrame;
132  int _jetpackIndicatorTransitionDirection;
133  uint32 _jetpackIndicatorNextFrameMillis;
134  void loadJetpackRawFrames(Common::SeekableReadStream *file);
135  void loadAmigaIndicatorSprites(Common::SeekableReadStream *file, byte *palette);
136  void loadAmigaCompass(Common::SeekableReadStream *file, byte *palette);
137  void drawAmigaCompass(Graphics::Surface *surface);
138  void drawAmigaAmbientIndicators(Graphics::Surface *surface);
139  void drawJetpackIndicator(Graphics::Surface *surface);
140 
141  int _soundIndexRestoreECD;
142  int _soundIndexDestroyECD;
143  Audio::SoundHandle _soundFxHandleJetpack;
144 
145  DarkSideC64SFXPlayer *_playerC64Sfx;
146  DarkSideC64MusicPlayer *_playerC64Music;
147  bool _c64UseSFX;
148  bool _c64CompassInitialized;
149  int _c64CompassPosition;
150  Common::Array<byte> _c64CompassTable;
151  void playSoundC64(int index) override;
152  void toggleC64Sound();
153 
154  Common::Array<byte> _musicData; // HDSMUSIC.AM TEXT segment (Amiga)
155 
156  void drawString(const DarkFontSize size, const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface);
157  void drawInfoMenu() override;
158 
159  Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
160  Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
161 
162 private:
163  void addECDs(Area *area);
164  void addECD(Area *area, const Math::Vector3d position, int index);
165  void restoreECD(Area &area, int index);
166  bool checkECD(uint16 areaID, int index);
167  bool tryDestroyECD(int index);
168  bool tryDestroyECDFullGame(int index);
169  void addWalls(Area *area);
170  void loadCPCIndicator(Common::SeekableReadStream *file, uint32 offset, Common::Array<Graphics::ManagedSurface *> &target);
171  void loadCPCIndicatorData(const byte *data, int widthBytes, int height, Common::Array<Graphics::ManagedSurface *> &target);
172  void loadCPCIndicators(Common::SeekableReadStream *file);
173  void drawC64ModeIndicator(Graphics::Surface *surface);
174  void drawCPCSprite(Graphics::Surface *surface, const Graphics::ManagedSurface *indicator, int xPosition, int yPosition);
175  void drawCPCIndicator(Graphics::Surface *surface, int xPosition, int yPosition);
176  void drawVerticalCompass(Graphics::Surface *surface, int x, int y, float angle, uint32 color);
177  void drawHorizontalCompass(int x, int y, float angle, uint32 front, uint32 back, Graphics::Surface *surface);
178 };
179 
180 }
Definition: managed_surface.h:51
Definition: keymap.h:66
Definition: str.h:59
Definition: surface.h:67
Definition: stream.h:77
Definition: error.h:81
Definition: area.h:36
Definition: array.h:52
Definition: advancedDetector.h:164
Definition: area.h:40
Definition: stream.h:745
Definition: freescape.h:189
Definition: mixer.h:49
Definition: sensor.h:34
Definition: c64.music.h:31
Definition: c64.sfx.h:30
Definition: font.h:32
Definition: dark.h:40
Definition: system.h:164
Definition: instruction.h:36
Definition: dark.h:51