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