ScummVM API documentation
driller.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 "audio/audiostream.h"
23 #include "audio/mixer.h"
24 
25 #include "engines/freescape/music.h"
26 #include "engines/freescape/games/driller/c64.music.h"
27 #include "engines/freescape/games/driller/c64.sfx.h"
28 
29 namespace Freescape {
30 
31 enum DrillerFontSize {
32  kDrillerFontSmall,
33  kDrillerFontNormal,
34 };
35 
37 public:
38  DrillerEngine(OSystem *syst, const ADGameDescription *gd);
39  ~DrillerEngine();
40 
41  uint32 _initialJetEnergy;
42  uint32 _initialJetShield;
43 
44  uint32 _initialTankEnergy;
45  uint32 _initialTankShield;
46 
47  bool _useAutomaticDrilling;
48 
49  MusicPlayer *_playerMusic;
50  DrillerC64SFXPlayer *_playerC64Sfx;
51  bool _c64UseSFX;
52 
53  void playSoundC64(int index) override;
54  void toggleC64Sound();
55 
56  // Only used for Amiga and Atari ST
57  Font _fontSmall;
58  void drawString(const DrillerFontSize size, const Common::String &str, int x, int y, uint32 primaryColor, uint32 secondaryColor, uint32 backColor, Graphics::Surface *surface);
59 
60  Common::HashMap<uint16, uint32> _drillStatusByArea;
61  Common::HashMap<uint16, uint32> _drillMaxScoreByArea;
62  Common::HashMap<uint16, uint32> _drillSuccessByArea;
63 
64  void initKeymaps(Common::Keymap *engineKeyMap, Common::Keymap *infoScreenKeyMap, const char *target) override;
65  void initGameState() override;
66  bool triggerWinCondition() override;
67  bool checkIfGameEnded() override;
68  void endGame() override;
69 
70  void gotoArea(uint16 areaID, int entranceID) override;
71 
72  void playSoundZX(int index, Audio::SoundHandle &handle) override;
73  void drawInfoMenu() override;
74  void drawSensorShoot(Sensor *sensor) override;
75  void drawCompass(Graphics::Surface *surface, int x, int y, double degrees, double magnitude, double fov, uint32 color);
76 
77  void pressedKey(const int keycode) override;
78  Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
79  Common::Error loadGameStreamExtended(Common::SeekableReadStream *stream) override;
80 
81 private:
82  int _finalAreaWinConditionIndex;
83  int _amigaAtariEndGameStep;
84  bool drillDeployed(Area *area);
85  Math::Vector3d drillPosition();
86  float compassYaw() const;
87  void addDrill(const Math::Vector3d position, bool gasFound);
88  bool checkDrill(const Math::Vector3d position);
89  void removeDrill(Area *area);
90  void addSkanner(Area *area);
91 
92  void loadAssets() override;
93  void loadAssetsAtariFullGame() override;
94  void loadAssetsAtariDemo() override;
95  void loadAssetsAmigaFullGame() override;
96  void loadAssetsAmigaDemo() override;
97  void loadAssetsDOSFullGame() override;
98  void loadAssetsDOSDemo() override;
99  void loadAssetsZXFullGame() override;
100  void loadAssetsCPCFullGame() override;
101  void loadAssetsC64FullGame() override;
102 
103  void drawDOSUI(Graphics::Surface *surface) override;
104  void drawZXUI(Graphics::Surface *surface) override;
105  void drawCPCUI(Graphics::Surface *surface) override;
106  void drawC64UI(Graphics::Surface *surface) override;
107  void drawAmigaAtariSTUI(Graphics::Surface *surface) override;
108  bool onScreenControls(Common::Point mouse) override;
109  void initAmigaAtari();
110  void initDOS();
111  void initZX();
112 
113  // Amiga/Atari UI sprite indicators loaded from executable
114  Common::Array<Graphics::ManagedSurface *> _rigSprites; // 5 rig animation frames
115  Common::Array<Graphics::ManagedSurface *> _stepSprites; // 8 step indicator frames
116  Common::Array<Graphics::ManagedSurface *> _angleSprites; // 8 angle/compass frames
117  Common::Array<Graphics::ManagedSurface *> _vehicleSprites; // 5 vehicle mode frames (fly + 4 tank heights)
118  Common::Array<Graphics::ManagedSurface *> _quitSprites; // 11 quit animation frames
119  int _quitConfirmCounter; // 0=not quitting, 1-4=waiting for confirmations
120  int _quitStartTicks; // _ticks when quit was initiated (for shutter animation)
121  Common::Rect _quitArea; // click area for quit button on Amiga/Atari console
122  Common::Array<Graphics::ManagedSurface *> _earthquakeSprites; // seismograph monitor frames
123  int _earthquakeLastFrame;
124  void loadRigSprites(Common::SeekableReadStream *file, int sprigsOffset, byte *palette = nullptr);
125  void loadIndicatorSprites(Common::SeekableReadStream *file, byte *palette,
126  int stepOffset, int angleOffset, int vehicleOffset, int quitOffset);
127  void loadEarthquakeSprites(Common::SeekableReadStream *file, byte *palette, int earthquakeOffset);
128 
129  // Compass indicators loaded from executable
130  Graphics::ManagedSurface *_compassPitchStrip; // pitch: 32px wide × (144+29) rows scrolling strip
131  Common::Array<Graphics::ManagedSurface *> _compassYawFrames; // yaw: 72 pre-rendered 30×5 frames
132  void loadCompassStrips(Common::SeekableReadStream *file, byte *palette,
133  int pitchStripOffset, int yawCogOffset);
134  void initCPC();
135  void initC64();
136 
137  void updateTimeVariables() override;
138 
139  Common::Rect _moveFowardArea;
140  Common::Rect _moveLeftArea;
141  Common::Rect _moveRightArea;
142  Common::Rect _moveBackArea;
143  Common::Rect _moveUpArea;
144  Common::Rect _moveDownArea;
145  Common::Rect _deployDrillArea;
146  Common::Rect _infoScreenArea;
147  Common::Rect _saveGameArea;
148  Common::Rect _loadGameArea;
149 
150  Graphics::ManagedSurface *load8bitTitleImage(Common::SeekableReadStream *file, int offset);
151  Graphics::ManagedSurface *load8bitDemoImage(Common::SeekableReadStream *file, int offset);
152 
153  uint32 getPixel8bitTitleImage(int index);
154  void renderPixels8bitTitleImage(Graphics::ManagedSurface *surface, int &i, int &j, int pixels);
155  Graphics::ManagedSurface *_borderExtra;
156  Texture *_borderExtraTexture;
157 
158  Common::SeekableReadStream *decryptFileAtari(const Common::Path &filename);
159 };
160 
161 enum DrillerReleaseFlags {
162  GF_AMIGA_MAGAZINE_DEMO = (1 << 0),
163  GF_ATARI_MAGAZINE_DEMO = (1 << 1),
164 };
165 
166 }
Definition: managed_surface.h:51
Definition: c64.sfx.h:30
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: rect.h:524
Definition: area.h:41
Definition: path.h:52
Definition: stream.h:745
Definition: freescape.h:191
Definition: mixer.h:49
Definition: sensor.h:34
Definition: driller.h:36
Definition: rect.h:144
Definition: music.h:29
Definition: font.h:32
Definition: system.h:165
Definition: gfx.h:50