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