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