ScummVM API documentation
eclipse.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_ECLIPSE_H
23#define FREESCAPE_ECLIPSE_H
24
25#include "common/file.h"
26
27#include "freescape/music.h"
28#include "freescape/sound.h"
29
30namespace Freescape {
31
32class EclipseC64SFXPlayer;
33
34enum EclipseReleaseFlags {
35 GF_ZX_DEMO_CRASH = (1 << 0),
36 GF_ZX_DEMO_MICROHOBBY = (1 << 1),
37};
38
39enum {
40 kVariableEclipse2SphinxParts = 1,
41 kVariableEclipseAnkhs = 32,
42};
43
45public:
46 EclipseEngine(OSystem *syst, const ADGameDescription *gd);
47 ~EclipseEngine() override;
48
49 void gotoArea(uint16 areaID, int entranceID) override;
50
51 void borderScreen() override;
52 void titleScreen() override;
53 void drawInfoMenu() override;
54 void drawIndicator(Graphics::Surface *surface, int xPosition, int yPosition, int separation);
55
56 void drawSensorShoot(Sensor *sensor) override;
57
58 void loadAssets() override;
59 void loadAssetsDOSFullGame() override;
60 void pressedKey(const int keycode) override;
61 void releasedKey(const int keycode) override;
62
63 uint32 _initialEnergy;
64 uint32 _initialShield;
65
66 int _soundIndexStartFalling;
67 int _soundIndexEndFalling;
68
69 bool _resting;
70 bool _flashlightOn;
71 bool _atariAreaDark;
72 int _lastThirtySeconds;
73 int _lastFiveSeconds;
74 int _lastHeartbeatSoundTick;
75 int _lastHeartIndicatorFrame;
76
77 int _lastSecond;
78 void updateTimeVariables() override;
79
80 void initDOS();
81 void initCPC();
82 void initZX();
83 void initC64();
84 void initAmigaAtari();
85
86 void loadAssetsZXFullGame() override;
87 void loadAssetsCPCFullGame() override;
88 void loadAssetsC64FullGame() override;
89 void loadAssetsAmigaFullGame() override;
90 void loadAssetsAtariFullGame() override;
91 void loadAssetsCPCDemo() override;
92 void loadAssetsZXDemo() override;
93
94 void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
95 void initGameState() override;
96 void executePrint(FCLInstruction &instruction) override;
97
98 void drawBackground() override;
99 void drawDOSUI(Graphics::Surface *surface) override;
100 void drawCPCUI(Graphics::Surface *surface) override;
101 void drawC64UI(Graphics::Surface *surface) override;
102 void drawZXUI(Graphics::Surface *surface) override;
103 void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
104 void drawAnalogClock(Graphics::Surface *surface, int x, int y, uint32 colorHand1, uint32 colorHand2, uint32 colorBack);
105 void drawAnalogClockHand(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, uint32 color);
106 void drawCompass(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, uint32 color);
107 int atariCompassPhaseFromRotationY(float rotationY) const;
108 int atariCompassTargetPhaseFromYaw(float yaw, int referencePhase) const;
109 bool isAtariDarkArea(uint16 areaID) const;
110 void onRotate(float xoffset, float yoffset, float zoffset) override;
111 void drawEclipseIndicator(Graphics::Surface *surface, int x, int y, uint32 color1, uint32 color2, uint32 color3 = 0);
112 Common::String getScoreString(int score);
113 void drawScoreString(int score, int x, int y, uint32 front, uint32 back, Graphics::Surface *surface);
114
115 void loadHeartFramesCPC(Common::SeekableReadStream *file, int restOffset, int beatOffset);
116 void loadHeartFramesZX(Common::SeekableReadStream *file, int restOffset, int beatOffset);
117 void loadHeartFramesDOS(Common::SeekableReadStream *file, int restOffset, int beatOffset);
118 void drawHeartIndicator(Graphics::Surface *surface, int x, int y);
119
120 // Heart frames stored as indexed (CLUT8) for per-area re-paletting (CPC, CGA)
122 void updateHeartFramesCPC();
123 void updateHeartFrames(const byte *palette);
124
125 // No CGA ankh in the bundle, so the masks are built at load time
126 Graphics::ManagedSurface *_ankhIndicatorMask;
127 Graphics::ManagedSurface *_ankhCollectedMask;
128 void loadAnkhIndicatorMask();
129 void loadAnkhCollectedMask();
130 void updateAnkhIndicator(const byte *palette);
131
132 Common::Array<byte> _musicData; // TEMUSIC.ST TEXT segment (Atari ST)
133 Common::Array<byte> _c64MusicData;
134 EclipseC64SFXPlayer *_playerC64Sfx;
135 bool _c64UseSFX;
136 void toggleC64Sound();
137
138 MusicPlayer *_playerMusic;
139 void restartBackgroundMusic();
140 void stopBackgroundMusic();
141
142 // Atari ST UI sprites (extracted from binary, pre-converted to target format)
143 Font _fontScore; // Font B (10 score digit glyphs, 4-plane at $249BE)
144 Common::Array<Graphics::ManagedSurface *> _eclipseSprites; // 2 eclipse animation frames (16x13)
145 Common::Array<Graphics::ManagedSurface *> _eclipseProgressSprites; // 16 eclipse animation frames (16x16)
146 Graphics::ManagedSurface *_compassBackground; // Atari ST compass background at $20986
147 Graphics::ManagedSurface *_atariWaterBody; // Atari ST water body bitmap at $2003C
148 Common::Array<Graphics::ManagedSurface *> _compassSprites; // signed Atari compass needle bank addressed by the $1542 lookup table
149 Common::Array<Graphics::ManagedSurface *> _lanternLightSprites; // 6 lantern light animation frames (32x6)
150 Common::Array<Graphics::ManagedSurface *> _lanternSwitchSprites; // 2 lantern on/off frames (32x23)
151 Common::Array<Graphics::ManagedSurface *> _shootSprites; // 2 shooting crosshair frames (32x25, 48x25)
152 Common::Array<Graphics::ManagedSurface *> _ankhSprites; // 5 ankh fade-in frames (16x15)
153 Common::Array<uint16> _atariDarkAreas; // Atari ST dark areas from the $2A520 runtime table
154 byte _eclipseFadePalettes[6][16 * 3]; // 6 brightness levels from prog $10EB6 (post LSR.L #1)
155 void applyEclipseFadePalette(uint16 areaID, int brightnessLevel);
156 Common::Array<uint16> _atariWaterSurfacePixels; // Atari ST water surface row words at $2024C
157 Common::Array<uint16> _atariWaterSurfaceMask; // Atari ST water surface mask words at $2025C
158 Common::Array<Graphics::ManagedSurface *> _soundToggleSprites; // 5 sound on/off toggle frames (16x11)
159 int8 _compassLookup[72]; // signed Atari ST phase-to-frame lookup table
160 int _atariCompassPhase;
161 int _atariCompassTargetPhase;
162 float _atariCompassTargetRemainder;
163 int _atariCompassLastUpdateTick;
164 bool _atariCompassPhaseInitialized;
165 int _atariLanternLightFrame;
166 int _atariLanternAnimationDirection;
167 int _atariLanternLastUpdateTick;
168 int _lanternBatteryLevel; // 5=full, 0=nearly dead, -1=dead (non-rechargeable)
169
170 // Atari ST on-screen control hotspots (from binary hotspot table at prog $869A)
171 bool onScreenControls(Common::Point mouse) override;
172
173 Common::Rect _lookUpArea;
174 Common::Rect _lookDownArea;
175 Common::Rect _turnLeftArea;
176 Common::Rect _turnRightArea;
177 Common::Rect _uTurnArea;
178 Common::Rect _faceForwardArea;
179 Common::Rect _moveBackwardArea;
180 Common::Rect _stepBackwardArea;
181 Common::Rect _interactArea;
182 Common::Rect _infoDisplayArea;
183 Common::Rect _lanternArea;
184 Common::Rect _restArea;
185 Common::Rect _stepSizeArea;
186 Common::Rect _heightArea;
187 Common::Rect _saveGameArea;
188 Common::Rect _loadGameArea;
189
190 bool triggerWinCondition() override;
191 bool checkIfGameEnded() override;
192 void endGame() override;
193 void playSoundFx(int index, bool sync, Sound::Type type = Sound::kTypeNormal) override;
194
195 Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
196 Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
197
198private:
199 Sound *_soundFx;
200};
201
202}
203
204#endif // FREESCAPE_ECLIPSE_H
Definition: error.h:81
Definition: keymap.h:66
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: c64.sfx.h:31
Definition: eclipse.h:44
Definition: instruction.h:49
Definition: font.h:32
Definition: freescape.h:191
Definition: music.h:29
Definition: sensor.h:34
Definition: sound.h:35
Definition: managed_surface.h:51
Definition: system.h:166
Definition: area.h:36
Definition: advancedDetector.h:164
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67