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
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/* 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.
*
*/
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/error.h"
#include "common/EventRecorder.h"
#include "common/file.h"
#include "common/fs.h"
#include "engines/util.h"
#include "cge/cge.h"
#include "cge/vga13h.h"
#include "cge/cge_main.h"
#include "cge/talk.h"
#include "cge/text.h"
#include "cge/vol.h"
#include "cge/walk.h"
#include "cge/startup.h"
namespace CGE {
CGEEngine::CGEEngine(OSystem *syst, const ADGameDescription *gameDescription)
: Engine(syst), _gameDescription(gameDescription), _randomSource("cge") {
// Debug/console setup
DebugMan.addDebugChannel(kCGEDebug, "general", "CGE general debug channel");
_isDemo = _gameDescription->flags & ADGF_DEMO;
_startupMode = 1;
_demoText = DEMO_TEXT;
_oldLev = 0;
_jbw = false;
_pocPtr = 0;
}
void CGEEngine::setup() {
// Initialise fields
_lastFrame = 0;
_hero = NULL;
_shadow = NULL;
// Create debugger console
_console = new CGEConsole(this);
// Initialise classes that have static members
Vga::init();
VFile::init();
Bitmap::init();
Talk::init();
Cluster::init(this);
// Initialise engine objects
_text = new Text(this, progName(), 128);
_vga = new Vga(M13H);
_heart = new Heart;
_sys = new System(this);
_pocLight = new PocLight(this);
for (int i = 0; i < POCKET_NX; i++) {
_pocket[i] = new Sprite(this, NULL);
_pocket[i]->_flags._kill = false;
}
_sprite = new Sprite(this, NULL);
_miniCave = new Sprite(this, NULL);
_miniCave->_flags._kill = false;
_horzLine = new HorizLine(this);
_infoLine = new InfoLine(this, INFO_W);
_cavLight = new CavLight(this);
_debugLine = new InfoLine(this, SCR_WID);
_snail = new Snail(this, false);
_snail_ = new Snail(this, true);
_mouse = new Mouse(this);
_keyboard = new Keyboard();
_eventManager = new EventManager();
_offUseCount = atoi(_text->getText(OFF_USE_COUNT));
_music = true;
_mini = new byte[MINI_EMM_SIZE];
for (int i = 0; i < POCKET_NX; i++)
_pocref[i] = -1;
_volume[0] = 0;
_volume[1] = 0;
if (_isDemo) {
_maxCaveArr[0] = CAVE_MAX;
_maxCaveArr[1] = -1;
_maxCaveArr[2] = -1;
_maxCaveArr[3] = -1;
_maxCaveArr[4] = -1;
} else {
_maxCaveArr[0] = 1;
_maxCaveArr[1] = 8;
_maxCaveArr[2] = 16;
_maxCaveArr[3] = 23;
_maxCaveArr[4] = 24;
};
_maxCave = 0;
_dark = false;
_game = false;
_now = 1;
_lev = -1;
for (int i = 0; i < 4; i++)
_flag[i] = false;
}
CGEEngine::~CGEEngine() {
debug("CGEEngine::~CGEEngine");
// Call classes with static members to clear them up
Talk::deinit();
Bitmap::deinit();
VFile::deinit();
Vga::deinit();
Cluster::init(this);
// Remove all of our debug levels here
DebugMan.clearAllDebugChannels();
delete _console;
// Delete engine objects
delete _vga;
delete _sys;
//delete _sprite; Sprite is destroyed by the queue it's added to
delete _miniCave;
delete _shadow;
delete _horzLine;
delete _infoLine;
delete _cavLight;
delete _debugLine;
delete _text;
delete _heart;
delete _pocLight;
delete _keyboard;
delete _mouse;
for (int i = 0; i < POCKET_NX; i++)
delete _pocket[i];
delete _snail;
delete _snail_;
delete _hero;
delete[] _mini;
}
Common::Error CGEEngine::run() {
// Initialize graphics using following:
initGraphics(320, 200, false);
// Setup necessary game objects
setup();
// Additional setup.
debug("CGEEngine::init");
cge_main();
return Common::kNoError;
}
} // End of namespace CGE
|