1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on original Sfinx source code
* Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon
*/
#include "engines/util.h"
#include "cge2/cge2.h"
#include "cge2/bitmap.h"
#include "cge2/vga13h.h"
#include "cge2/sound.h"
#include "cge2/text.h"
#include "cge2/hero.h"
#include "cge2/general.h"
#include "cge2/spare.h"
#include "cge2/events.h"
#include "cge2/talk.h"
namespace CGE2 {
CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
: Engine(syst), _gameDescription(gameDescription), _randomSource("cge") {
_resman = nullptr;
_vga = nullptr;
_sprite = nullptr;
_midiPlayer = nullptr;
_fx = nullptr;
_sound = nullptr;
_text = nullptr;
for (int i = 0; i < 2; i++)
_heroTab[i] = nullptr;
_eye = nullptr;
for (int i = 0; i < kCaveMax; i++)
_eyeTab[i] = nullptr;
_spare = nullptr;
_commandHandler = nullptr;
_commandHandlerTurbo = nullptr;
_infoLine = nullptr;
_mouse = nullptr;
_keyboard = nullptr;
_talk = nullptr;
for (int i = 0; i < kMaxPoint; i++)
_point[i] = nullptr;
_quitFlag = false;
_bitmapPalette = nullptr;
_mode = 0;
_music = true;
_startupMode = 1;
_now = 1;
_sex = true;
_mouseTop = kWorldHeight / 3;
_dark = false;
_lastFrame = 0;
_lastTick = 0;
_waitSeq = 0;
_waitRef = 0;
_commandStat = { nullptr, { 0 , 0 } };
_taken = false;
}
void CGE2Engine::init() {
_resman = new ResourceManager();
_vga = new Vga(this);
_fx = new Fx(this, 16);
_sound = new Sound(this);
_midiPlayer = new MusicPlayer(this);
_text = new Text(this, "CGE");
for (int i = 0; i < 2; i++)
_heroTab[i] = new HeroTab(this);
_eye = new V3D();
for (int i = 0; i < kCaveMax; i++)
_eyeTab[i] = new V3D();
_spare = new Spare(this);
_commandHandler = new CommandHandler(this, false);
_commandHandlerTurbo = new CommandHandler(this, true);
_infoLine = new InfoLine(this, kInfoW);
_mouse = new Mouse(this);
_keyboard = new Keyboard(this);
for (int i = 0; i < kMaxPoint; i++)
_point[i] = new V3D();
}
void CGE2Engine::deinit() {
delete _resman;
delete _vga;
delete _fx;
delete _sound;
delete _midiPlayer;
delete _text;
for (int i = 0; i < 2; i++)
delete _heroTab[i];
for (int i = 0; i < kCaveMax; i++) {
if (_eye == _eyeTab[i])
_eye = nullptr;
delete _eyeTab[i];
}
if (_eye != nullptr)
delete _eye;
delete _spare;
delete _sprite;
delete _commandHandler;
delete _commandHandlerTurbo;
delete _infoLine;
delete _mouse;
delete _keyboard;
if (_talk != nullptr)
delete _talk;
for (int i = 0; i < kMaxPoint; i++) {
delete _point[i];
}
}
bool CGE2Engine::hasFeature(EngineFeature f) const {
return false;
}
bool CGE2Engine::canLoadGameStateCurrently() {
return false;
}
bool CGE2Engine::canSaveGameStateCurrently() {
return false;
}
Common::Error CGE2Engine::loadGameState(int slot) {
warning("STUB: CGE2Engine::loadGameState()");
return Common::kNoError;
}
Common::Error CGE2Engine::saveGameState(int slot, const Common::String &desc) {
warning("STUB: CGE2Engine::saveGameState()");
return Common::kNoError;
}
Common::Error CGE2Engine::run() {
warning("STUB: CGE2Engine::run()");
initGraphics(kScrWidth, kScrHeight, false);
init();
cge2_main();
deinit();
return Common::kNoError;
}
} // End of namespace CGE2
|