ScummVM API documentation
ultima2.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#ifndef ULTIMA2_H
23#define ULTIMA2_H
24
25#include "common/scummsys.h"
26#include "common/system.h"
27#include "common/error.h"
28#include "common/ptr.h"
29#include "common/serializer.h"
30#include "common/util.h"
31#include "engines/engine.h"
32#include "ultima/shared/engine/events.h"
33#include "ultima/detection.h"
34#include "ultima/ultima2/data/map.h"
35#include "ultima/ultima2/data/map_dungeon.h"
36#include "ultima/ultima2/data/savegame.h"
37#include "ultima/ultima2/logic/logic.h"
38
39namespace Audio {
40class PCSpeaker;
41}
42
43namespace Ultima {
44namespace Ultima2 {
45
46struct Ultima2GameDescription;
47
48class Ultima2Engine : public Engine, public Shared::Events {
49private:
50 const Ultima::UltimaGameDescription *_gameDescription;
51
52protected:
53 // Engine APIs
54 Common::Error run() override;
55
59 bool shouldQuit() const override {
60 return Engine::shouldQuit();
61 }
62
66 void returnToMainMenu() override;
67
68private:
69 // 6-byte lagged-Fibonacci-style state for randByte(), matching the
70 // original's rand_byte generator
71 byte _rngState[6] = {};
72
73 Audio::PCSpeaker *_pcSpeaker = nullptr;
74 bool _pcSpeakerReady = false;
75
81 void queueTone(int divisor, uint32 lengthMs);
82
86 void queueSilence(uint32 lengthMs);
87
88public:
89 Data::Savegame _savegame;
90 Data::Map _map;
91 Data::MapDungeon _dungeon;
93
94 // Lets the player choose which attribute the Offer command's gift raises,
95 // as in the Ultima II Upgrade, rather than it being random
96 bool _statBoostChoice = false;
97
98 // Shows text in mixed case, and in color in the EGA modes, as the Ultima II
99 // Upgrade does. When off, all text is in capitals
100 bool _mixedCaseText = false;
101
102 // Food is eaten at half the original rate
103 bool _lessHunger = false;
104
105 // Debug flag toggled by the "intangible" console command, allowing
106 // movement through normally impassable terrain
107 bool _intangible = false;
108
109private:
110 Data::RenderMode _renderMode = Data::RENDER_CGA;
111
115 void loadOptions();
116
117public:
119 ~Ultima2Engine() override;
120
121 uint32 getFeatures() const;
122
126 Graphics::Font *createFont() const override;
127
131 bool isEnhanced() const;
132
137
138 bool hasFeature(EngineFeature f) const override {
139 return
143 };
144
145 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
146 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
147
153
154 Common::Error saveGameStream(Common::WriteStream *stream, bool = false) override {
155 Common::Serializer s(nullptr, stream);
156 return syncGame(s);
157 }
159 Common::Serializer s(stream, nullptr);
160 return syncGame(s);
161 }
162
166 bool savegamesExist() const;
167
171 byte randByte();
172
178 void playFX(Data::SoundEffect fx);
179
184 Data::RenderMode getRenderMode() const {
185 return _renderMode;
186 }
187
193 void setRenderMode(Data::RenderMode mode);
194
199 void applyGameSettings() override;
200
204 void pauseMillis(uint32 millis);
205};
206
207extern Ultima2Engine *g_engine;
208#define _G(X) (Ultima2::g_engine->_##X)
209
210} // namespace Ultima2
211} // namespace Ultima
212
213#endif
Definition: pcspk.h:36
Definition: error.h:81
Definition: stream.h:745
Definition: serializer.h:80
Definition: ptr.h:159
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:155
static bool shouldQuit()
EngineFeature
Definition: engine.h:293
@ kSupportsReturnToLauncher
Definition: engine.h:307
@ kSupportsSavingDuringRuntime
Definition: engine.h:325
@ kSupportsLoadingDuringRuntime
Definition: engine.h:316
Definition: font.h:83
Definition: system.h:166
Definition: events.h:61
Definition: ultima2.h:48
void playFX(Data::SoundEffect fx)
void pauseMillis(uint32 millis)
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Data::RenderMode getRenderMode() const
Definition: ultima2.h:184
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: ultima2.h:158
void setRenderMode(Data::RenderMode mode)
bool hasFeature(EngineFeature f) const override
Definition: ultima2.h:138
Graphics::Font * createFont() const override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error saveGameStream(Common::WriteStream *stream, bool=false) override
Definition: ultima2.h:154
void returnToMainMenu() override
bool shouldQuit() const override
Definition: ultima2.h:59
void applyGameSettings() override
Common::String getGameId() const
Common::Error syncGame(Common::Serializer &s)
Common::Error run() override
Engine * g_engine
Definition: system.h:39
Definition: map_dungeon.h:54
Definition: map.h:50
Definition: savegame.h:37
Definition: detection.h:65