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