ScummVM API documentation
ultima1.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 ULTIMA1_H
23#define ULTIMA1_H
24
25#include "common/scummsys.h"
26#include "common/system.h"
27#include "common/error.h"
28#include "common/fs.h"
29#include "common/hash-str.h"
30#include "common/ptr.h"
31#include "common/random.h"
32#include "common/serializer.h"
33#include "common/util.h"
34#include "audio/audiostream.h"
35#include "audio/mixer.h"
36#include "engines/engine.h"
37#include "engines/savestate.h"
38#include "graphics/palette.h"
39#include "graphics/screen.h"
40#include "ultima/shared/engine/events.h"
41#include "ultima/detection.h"
42#include "ultima/ultima1/data/map.h"
43#include "ultima/ultima1/data/map_dungeon.h"
44#include "ultima/ultima1/gfx/render_mode.h"
45#include "ultima/ultima1/data/savegame.h"
46#include "ultima/ultima1/data/space_map.h"
47#include "ultima/ultima1/data/tiles.h"
48#include "ultima/ultima1/logic/logic.h"
49
50namespace Ultima {
51namespace Ultima1 {
52
53struct Ultima1GameDescription;
54
55class Ultima1Engine : public Engine, public Shared::Events {
56private:
57 const Ultima::UltimaGameDescription *_gameDescription;
58 Audio::QueuingAudioStream *_effectStream = nullptr;
59 Audio::SoundHandle _effectHandle;
60
64 void queueEffect(const Common::Array<byte> &samples);
65
66protected:
67 // Engine APIs
68 Common::Error run() override;
69
73 bool shouldQuit() const override {
74 return Engine::shouldQuit();
75 }
76
80 void returnToMainMenu() override;
81
82public:
83 // The graphics being shown, and the palette indices things are drawn
84 // with in them
85 Data::RenderMode _renderMode = Data::RENDER_EGA;
86 Data::RenderColors _colors;
87 Data::Map _map;
88 Data::MapDungeon _dungeon;
89 Data::SpaceStarfield _starfield;
90 Data::Savegame _savegame;
92 int _creaturesCount = 0;
93 int _transportFoodCtr = 0;
94 // The flight speed set while in the cockpit view (the overhead vs
95 // cockpit distinction is carried by which SpaceLogic subclass is active)
96 int _cockpitSpeed = 0;
97 // The speed it was when the cockpit view was entered, which the drift on
98 // return to the overhead view is scaled relative to
99 int _cockpitEntrySpeed = 1;
100 // The overhead sector view's current drift velocity (sectorChangeX/Y),
101 // applied to the player's ship position each frame, and the number of
102 // frames left to keep showing its engine exhaust trail (_countdown)
103 int _sectorDriftX = 0;
104 int _sectorDriftY = 0;
105 int _shipExhaustCountdown = 0;
106 // The current cockpit-view combat encounter's screen position (0 = no
107 // enemy currently engaged), set up by SpaceCockpitLogic::setupSectorEnemies
108 int _cockpitTargetX = 0;
109 int _cockpitTargetY = 0;
110 // How far the current encounter has "closed in" (targetApproachStage,
111 // 0-6 - indexes the SPACE_TARGET_HIT_* tables), and the frame counter
112 // gating how often it advances (approachTimer)
113 int _cockpitTargetStage = 0;
114 int _cockpitApproachTimer = 0;
115
116public:
118 ~Ultima1Engine() override;
119
120 uint32 getFeatures() const;
121
126
127 bool hasFeature(EngineFeature f) const override {
128 return
132 };
133
134 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
135 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
136
142
143 Common::Error saveGameStream(Common::WriteStream *stream, bool = false) override {
144 Common::Serializer s(nullptr, stream);
145 return syncGame(s);
146 }
148 Common::Serializer s(stream, nullptr);
149 return syncGame(s);
150 }
151
155 bool savegamesExist() const;
156
160 void playFX(int num);
161
165 void setHitFlash(bool on);
166
170 void pauseForEffect(int num);
171
175 void flashScreen(int effectNum);
176
180 void pauseMillis(uint32 millis);
181
185 void setRenderMode(Data::RenderMode mode);
186
190 void applyGameSettings() override;
191
195 Graphics::Font *createFont() const override;
196};
197
198extern Ultima1Engine *g_engine;
199#define _G(X) (Ultima1::g_engine->_##X)
200
201} // namespace Ultima1
202} // namespace Ultima
203
204#endif
Definition: audiostream.h:370
Definition: mixer.h:49
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: ultima1.h:55
Common::Error saveGameStream(Common::WriteStream *stream, bool=false) override
Definition: ultima1.h:143
void applyGameSettings() override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature f) const override
Definition: ultima1.h:127
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Definition: ultima1.h:147
Common::Error syncGame(Common::Serializer &s)
void pauseMillis(uint32 millis)
Common::String getGameId() const
Graphics::Font * createFont() const override
void flashScreen(int effectNum)
bool shouldQuit() const override
Definition: ultima1.h:73
void setRenderMode(Data::RenderMode mode)
Common::Error run() override
void returnToMainMenu() override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Engine * g_engine
Definition: map_dungeon.h:87
Definition: map.h:82
Definition: render_mode.h:50
Definition: savegame.h:50
Definition: space_map.h:226
Definition: detection.h:65