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  soundFx *load1bPCM(Common::SeekableReadStream *file, int offset);
113  void loadHeartFramesCPC(Common::SeekableReadStream *file, int restOffset, int beatOffset);
114  void loadHeartFramesZX(Common::SeekableReadStream *file, int restOffset, int beatOffset);
115  void loadHeartFramesDOS(Common::SeekableReadStream *file, int restOffset, int beatOffset);
116  void drawHeartIndicator(Graphics::Surface *surface, int x, int y);
117 
118  // CPC heart frames stored as indexed (CLUT8) for per-area re-paletting
119  Common::Array<Graphics::ManagedSurface *> _heartFramesCPCIndexed;
120  void updateHeartFramesCPC();
121 
122  Common::Array<byte> _musicData; // TEMUSIC.ST TEXT segment (Atari ST)
123  Common::Array<byte> _c64MusicData;
124  EclipseC64SFXPlayer *_playerC64Sfx;
125  bool _c64UseSFX;
126  void playSoundC64(int index) override;
127  void toggleC64Sound();
128 
129  MusicPlayer *_playerMusic;
130  void restartBackgroundMusic();
131  void stopBackgroundMusic();
132 
133  // Atari ST UI sprites (extracted from binary, pre-converted to target format)
134  Font _fontScore; // Font B (10 score digit glyphs, 4-plane at $249BE)
135  Common::Array<Graphics::ManagedSurface *> _eclipseSprites; // 2 eclipse animation frames (16x13)
136  Common::Array<Graphics::ManagedSurface *> _eclipseProgressSprites; // 16 eclipse animation frames (16x16)
137  Graphics::ManagedSurface *_compassBackground; // Atari ST compass background at $20986
138  Graphics::ManagedSurface *_atariWaterBody; // Atari ST water body bitmap at $2003C
139  Common::Array<Graphics::ManagedSurface *> _compassSprites; // signed Atari compass needle bank addressed by the $1542 lookup table
140  Common::Array<Graphics::ManagedSurface *> _lanternLightSprites; // 6 lantern light animation frames (32x6)
141  Common::Array<Graphics::ManagedSurface *> _lanternSwitchSprites; // 2 lantern on/off frames (32x23)
142  Common::Array<Graphics::ManagedSurface *> _shootSprites; // 2 shooting crosshair frames (32x25, 48x25)
143  Common::Array<Graphics::ManagedSurface *> _ankhSprites; // 5 ankh fade-in frames (16x15)
144  Common::Array<uint16> _atariDarkAreas; // Atari ST dark areas from the $2A520 runtime table
145  byte _eclipseFadePalettes[6][16 * 3]; // 6 brightness levels from prog $10EB6 (post LSR.L #1)
146  void applyEclipseFadePalette(uint16 areaID, int brightnessLevel);
147  Common::Array<uint16> _atariWaterSurfacePixels; // Atari ST water surface row words at $2024C
148  Common::Array<uint16> _atariWaterSurfaceMask; // Atari ST water surface mask words at $2025C
149  Common::Array<Graphics::ManagedSurface *> _soundToggleSprites; // 5 sound on/off toggle frames (16x11)
150  int8 _compassLookup[72]; // signed Atari ST phase-to-frame lookup table
151  int _atariCompassPhase;
152  int _atariCompassTargetPhase;
153  float _atariCompassTargetRemainder;
154  int _atariCompassLastUpdateTick;
155  bool _atariCompassPhaseInitialized;
156  int _atariLanternLightFrame;
157  int _atariLanternAnimationDirection;
158  int _atariLanternLastUpdateTick;
159  int _lanternBatteryLevel; // 5=full, 0=nearly dead, -1=dead (non-rechargeable)
160 
161  // Atari ST on-screen control hotspots (from binary hotspot table at prog $869A)
162  bool onScreenControls(Common::Point mouse) override;
163 
164  Common::Rect _lookUpArea;
165  Common::Rect _lookDownArea;
166  Common::Rect _turnLeftArea;
167  Common::Rect _turnRightArea;
168  Common::Rect _uTurnArea;
169  Common::Rect _faceForwardArea;
170  Common::Rect _moveBackwardArea;
171  Common::Rect _stepBackwardArea;
172  Common::Rect _interactArea;
173  Common::Rect _infoDisplayArea;
174  Common::Rect _lanternArea;
175  Common::Rect _restArea;
176  Common::Rect _stepSizeArea;
177  Common::Rect _heightArea;
178  Common::Rect _saveGameArea;
179  Common::Rect _loadGameArea;
180 
181  bool triggerWinCondition() override;
182  bool checkIfGameEnded() override;
183  void endGame() override;
184  void loadSoundsFx(Common::SeekableReadStream *file, int offset, int number) override;
185  void playSoundFx(int index, bool sync) override;
186 
187  Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
188  Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
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:30
Definition: sound.h:30
Definition: rect.h:524
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: font.h:32
Definition: system.h:165
Definition: instruction.h:36