ScummVM API documentation
base.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 // Hopkins FBI underwater-base shooter (the original Windows WBASE module).
23 
24 #ifndef HOPKINS_BASE_H
25 #define HOPKINS_BASE_H
26 
27 #include "hopkins/base_data.h"
28 #include "hopkins/base_engine.h"
29 
30 #include "common/array.h"
31 #include "common/scummsys.h"
32 #include "common/str.h"
33 
34 namespace Hopkins {
35 
36 class BaseRenderer;
37 class HopkinsEngine;
38 
39 enum BaseRunStatus {
40  kBaseRunCompleted,
41  kBaseRunFallback,
42  kBaseRunQuit
43 };
44 
45 struct BaseRunResult {
46  BaseRunStatus status;
47  int roomId;
48 
49  BaseRunResult(BaseRunStatus runStatus, int resultRoom = 0) :
50  status(runStatus), roomId(resultRoom) {}
51 };
52 
53 class BaseGame {
54 public:
55  explicit BaseGame(HopkinsEngine *vm);
56  ~BaseGame();
57 
58  static bool hasRequiredResources(Common::String *missingResources = nullptr);
59 
61  BaseRunResult run(int entryId);
62 
63 private:
64  struct GraphicsStateBackup {
65  bool breakout;
66  bool mouseVisible;
67  bool disableInventory;
68  int lineNbr;
69  int lineNbr2;
70  int minX;
71  int minY;
72  int maxX;
73  int maxY;
74  byte paletteBuffer[256 * 2];
75  byte palette[800];
76  byte oldPalette[800];
77  };
78 
79  class SessionGuard;
80 
81  static const BaseEntryPoint *entryPoints(uint &count);
82  static const BaseEntryPoint *findEntryPoint(int entryId);
83 
84  bool initializePresentation(GraphicsStateBackup &backup);
85  void restorePresentation(const GraphicsStateBackup &backup);
86  void initializeAudio();
87  void releaseAudio();
88  void switchKeymaps(bool entering);
89  void pollInput();
90  void handleAction(uint32 action, bool pressed);
91  void openMainMenu();
92  void refreshPresentation();
93  void processSoundEvents();
94  void renderFrame();
95  void setEngineActive(bool active);
96 
97  HopkinsEngine *_vm;
98  BaseData _data;
99  BaseEngine *_engine;
100  BaseRenderer *_renderer;
101  Common::Array<byte> _framebuffer;
102  BaseInputState _input;
103  const BaseEntryPoint *_entry;
104  int _result;
105  bool _audioLoaded[6];
106  bool _keymapsSwitched;
107  bool _defaultKeymapWasEnabled;
108  bool _shortcutKeymapWasEnabled;
109  bool _baseKeymapWasEnabled;
110  bool _inputSuspended;
111  bool _mainMenuRequested;
112  bool _presentationRefreshRequested;
113  bool _timingResetRequested;
114  bool _quitRequested;
115 };
116 
117 } // End of namespace Hopkins
118 
119 #endif // HOPKINS_BASE_H
Definition: str.h:59
Definition: base_engine.h:55
Definition: base.h:45
Definition: base_renderer.h:39
Definition: base_types.h:181
Definition: base_engine.h:35
Definition: anim.h:30
Definition: hopkins.h:95
Definition: base_data.h:35
Definition: base.h:53