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