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