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  void loadAssetsAtariFullGame() override;
85 
86  void loadAssetsCPCFullGame() override;
87 
88  void loadAssetsZXDemo() override;
89  void loadAssetsZXFullGame() override;
90  void loadMessagesVariableSize(Common::SeekableReadStream *file, int offset, int number) override;
91 
92  int _lastTenSeconds;
93  int _lastSecond;
94  void updateTimeVariables() override;
95 
96  void drawBinaryClock(Graphics::Surface *surface, int xPosition, int yPosition, uint32 front, uint32 back);
97  void drawIndicator(Graphics::Surface *surface, int xPosition, int yPosition);
98 
99  void drawSensorShoot(Sensor *sensor) override;
100  void drawDOSUI(Graphics::Surface *surface) override;
101  void drawC64UI(Graphics::Surface *surface) override;
102  void drawZXUI(Graphics::Surface *surface) override;
103  void drawCPCUI(Graphics::Surface *surface) override;
104  void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
105  void drawC64Compass(Graphics::Surface *surface);
106 
107  Font _fontBig;
108  Font _fontMedium;
109  Font _fontSmall;
111  Common::Array<Graphics::ManagedSurface *> _cpcJetpackIndicators;
112  Common::Array<Graphics::ManagedSurface *> _cpcActionIndicators;
113  uint32 _cpcActionIndicatorUntilMillis;
115 
116  // Dark Side Amiga stores the grounded jetpack indicator states as raw
117  // 4-plane bitplane data. The executable drives those frames through a tiny
118  // fixed color ramp, so the renderer keeps the raw planes and applies a
119  // hardcoded palette at draw time.
120  Common::Array<Common::Array<byte>> _jetpackTransitionFrames;
121  Common::Array<byte> _jetpackCrouchFrame;
122  Common::Array<Graphics::ManagedSurface *> _amigaCompassYawFrames;
123  Graphics::ManagedSurface *_amigaCompassPitchMarker;
124  Common::Array<Graphics::ManagedSurface *> _amigaCompassNeedleFrames;
125  Common::Array<Graphics::ManagedSurface *> _amigaCompassLeftFrames;
126  Common::Array<Graphics::ManagedSurface *> _amigaCompassRightFrames;
127  bool _amigaCompassYawPhaseInitialized;
128  int _amigaCompassYawPhase;
129  int _amigaCompassYawLastUpdateTick;
130  bool _jetpackIndicatorStateInitialized;
131  bool _jetpackIndicatorLastFlyMode;
132  int _jetpackIndicatorTransitionFrame;
133  int _jetpackIndicatorTransitionDirection;
134  uint32 _jetpackIndicatorNextFrameMillis;
135  void loadJetpackRawFrames(Common::SeekableReadStream *file);
136  void loadAmigaIndicatorSprites(Common::SeekableReadStream *file, byte *palette);
137  void loadAmigaCompass(Common::SeekableReadStream *file, byte *palette);
138  void drawAmigaCompass(Graphics::Surface *surface);
139  void drawAmigaAmbientIndicators(Graphics::Surface *surface);
140  void drawJetpackIndicator(Graphics::Surface *surface);
141 
142  int _soundIndexRestoreECD;
143  int _soundIndexDestroyECD;
144  Audio::SoundHandle _soundFxHandleJetpack;
145 
146  DarkSideC64SFXPlayer *_playerC64Sfx;
147  MusicPlayer *_playerMusic;
148  bool _c64UseSFX;
149  bool _c64CompassInitialized;
150  int _c64CompassPosition;
151  Common::Array<byte> _c64CompassTable;
152  void playSoundC64(int index) override;
153  void toggleC64Sound();
154 
155  Common::Array<byte> _musicData; // HDSMUSIC.AM TEXT segment (Amiga)
156 
157  void drawString(const DarkFontSize size, const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface);
158  void drawInfoMenu() override;
159 
160  Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
161  Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
162 
163 private:
164  void addECDs(Area *area);
165  void addECD(Area *area, const Math::Vector3d position, int index);
166  void restoreECD(Area &area, int index);
167  bool checkECD(uint16 areaID, int index);
168  bool tryDestroyECD(int index);
169  bool tryDestroyECDFullGame(int index);
170  void addWalls(Area *area);
171  void loadCPCIndicator(Common::SeekableReadStream *file, uint32 offset, Common::Array<Graphics::ManagedSurface *> &target);
172  void loadCPCIndicatorData(const byte *data, int widthBytes, int height, Common::Array<Graphics::ManagedSurface *> &target);
173  void loadCPCIndicators(Common::SeekableReadStream *file);
174  void drawC64ModeIndicator(Graphics::Surface *surface);
175  void drawCPCSprite(Graphics::Surface *surface, const Graphics::ManagedSurface *indicator, int xPosition, int yPosition);
176  void drawCPCIndicator(Graphics::Surface *surface, int xPosition, int yPosition);
177  void drawVerticalCompass(Graphics::Surface *surface, int x, int y, float angle, uint32 color);
178  void drawHorizontalCompass(int x, int y, float angle, uint32 front, uint32 back, Graphics::Surface *surface);
179 };
180 
181 }
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:30
Definition: music.h:29
Definition: font.h:32
Definition: dark.h:41
Definition: system.h:165
Definition: instruction.h:36
Definition: dark.h:52