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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
/* 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.
*
* $URL$
* $Id$
*
*/
#include "common/system.h"
#include "common/util.h"
#include "parallaction/parallaction.h"
#include "parallaction/sound.h"
namespace Parallaction {
enum MenuOptions {
kMenuPart0 = 0,
kMenuPart1 = 1,
kMenuPart2 = 2,
kMenuPart3 = 3,
kMenuPart4 = 4,
kMenuLoadGame = 5,
kMenuQuit = 6
};
const char *partNames[] = {
"PART0",
"PART1",
"PART2",
"PART3",
"PART4"
};
const char *partFirstLocation[] = {
"intro",
"museo",
"start",
"bolscoi",
"treno"
};
int Parallaction_br::init() {
_screenWidth = 640;
_screenHeight = 400;
if (getGameType() == GType_BRA) {
if (getPlatform() == Common::kPlatformPC) {
_disk = new DosDisk_br(this);
_disk->setLanguage(2); // NOTE: language is now hardcoded to English. Original used command-line parameters.
} else
error("unsupported platform for Big Red Adventure");
} else
error("unknown game type");
_soundMan = new DummySoundMan(this);
_activeZone2 = 0;
initJobs();
initResources();
initFonts();
initCursors();
initOpcodes();
initParsers();
_part = -1;
Parallaction::init();
return 0;
}
Parallaction_br::~Parallaction_br() {
freeFonts();
delete _dinoCursor;
delete _dougCursor;
delete _donnaCursor;
}
void Parallaction_br::callFunction(uint index, void* parm) {
assert(index < 6); // magic value 6 is maximum # of callables for Big Red Adventure
(this->*_callables[index])(parm);
}
int Parallaction_br::go() {
splash("dyna");
splash("core");
// TODO: load progress value from special save game
_progress = 3;
while ((_engineFlags & kEngineQuit) == 0) {
// initCharacter();
int option = showMenu();
switch (option) {
case kMenuQuit:
_engineFlags |= kEngineQuit;
break;
case kMenuLoadGame:
warning("loadgame not yet implemented");
break;
default:
_part = option;
_disk->selectArchive(partNames[_part]);
startPart();
break;
}
runGame();
freePart();
// freeLocation();
// freeCharacter();
}
return 0;
}
void Parallaction_br::splash(const char *name) {
BackgroundInfo info;
_gfx->clearScreen(Gfx::kBitFront);
_disk->loadSlide(info, name);
_gfx->setPalette(info.palette);
_gfx->flatBlitCnv(&info.bg, (640 - info.width) >> 1, (400 - info.height) >> 1, Gfx::kBitFront);
_gfx->updateScreen();
_system->delayMillis(600);
Palette pal;
for (uint i = 0; i < 64; i++) {
info.palette.fadeTo(pal, 1);
_gfx->setPalette(info.palette);
_gfx->updateScreen();
_system->delayMillis(20);
}
info.bg.free();
return;
}
#define MENUITEMS_X 250
#define MENUITEMS_Y 200
#define MENUITEM_WIDTH 190
#define MENUITEM_HEIGHT 18
void Parallaction_br::renderMenuItem(Graphics::Surface &surf, const char *text) {
surf.create(MENUITEM_WIDTH, MENUITEM_HEIGHT, 1);
_menuFont->setColor(0);
_menuFont->drawString((byte*)surf.getBasePtr(5, 2), MENUITEM_WIDTH, text);
}
void Parallaction_br::invertMenuItem(Graphics::Surface &surf) {
for (int i = 0; i < surf.w * surf.h; i++)
((byte*)surf.pixels)[i] ^= 0xD;
}
int Parallaction_br::showMenu() {
// TODO: filter menu entries according to progress in game
_gfx->clearScreen(Gfx::kBitFront);
BackgroundInfo info;
Graphics::Surface _menuItems[7];
const char *menuStrings[7] = {
"SEE INTRO",
"NEW GAME",
"SAVED GAME",
"EXIT TO DOS",
"PART 2",
"PART 3",
"PART 4"
};
MenuOptions options[7] = {
kMenuPart0,
kMenuPart1,
kMenuLoadGame,
kMenuQuit,
kMenuPart2,
kMenuPart3,
kMenuPart4
};
_disk->loadSlide(info, "tbra");
_gfx->setPalette(info.palette);
_gfx->flatBlitCnv(&info.bg, 20, 50, Gfx::kBitFront);
int availItems = 4 + _progress;
for (int i = 0; i < availItems; i++)
renderMenuItem(_menuItems[i], menuStrings[i]);
int selectedItem = -1, oldSelectedItem = -2;
setMousePointer(0);
while (true) {
if ((_mouseButtons == kMouseLeftUp) && selectedItem >= 0)
break;
readInput();
if ((_mousePos.x > MENUITEMS_X) && (_mousePos.x < (MENUITEMS_X+MENUITEM_WIDTH)) && (_mousePos.y > MENUITEMS_Y)) {
selectedItem = (_mousePos.y - MENUITEMS_Y) / MENUITEM_HEIGHT;
if (!(selectedItem < availItems))
selectedItem = -1;
} else
selectedItem = -1;
if (selectedItem != oldSelectedItem) {
if (selectedItem >= 0 && selectedItem < availItems)
invertMenuItem(_menuItems[selectedItem]);
if (oldSelectedItem >= 0 && oldSelectedItem < availItems)
invertMenuItem(_menuItems[oldSelectedItem]);
Common::Rect r(MENUITEM_WIDTH, MENUITEM_HEIGHT);
for (int i = 0; i < availItems; i++) {
r.moveTo(MENUITEMS_X, MENUITEMS_Y + i * 20);
_gfx->copyRect(Gfx::kBitFront, r, (byte*)_menuItems[i].pixels, _menuItems[i].pitch);
}
oldSelectedItem = selectedItem;
}
_gfx->updateScreen();
_system->delayMillis(20);
}
_system->showMouse(false);
info.bg.free();
for (int i = 0; i < availItems; i++)
_menuItems[i].free();
return options[selectedItem];
}
void Parallaction_br::initFonts() {
_menuFont = _disk->loadFont("russia");
_dialogueFont = _disk->loadFont("comic");
_labelFont = _menuFont;
}
void Parallaction_br::freeFonts() {
delete _menuFont;
delete _dialogueFont;
return;
}
void Parallaction_br::initCursors() {
_dinoCursor = _disk->loadPointer("pointer1");
_dougCursor = _disk->loadPointer("pointer2");
_donnaCursor = _disk->loadPointer("pointer3");
_mouseArrow = _donnaCursor;
}
void Parallaction_br::setMousePointer(int16 index) {
Common::Rect r;
_mouseArrow->getRect(0, r);
_system->setMouseCursor(_mouseArrow->getData(0), r.width(), r.height(), 0, 0, 0);
_system->showMouse(true);
}
void Parallaction_br::initPart() {
memset(_counters, 0, ARRAYSIZE(_counters));
_globalTable = _disk->loadTable("global");
_objectsNames = _disk->loadTable("objects");
_countersNames = _disk->loadTable("counters");
// _disk->loadObjects("icone.ico");
}
void Parallaction_br::freePart() {
delete _globalTable;
delete _objectsNames;
delete _countersNames;
_globalTable = 0;
_objectsNames = 0;
_countersNames = 0;
}
void Parallaction_br::startPart() {
initPart();
strcpy(_location._name, partFirstLocation[_part]);
parseLocation("common");
parseLocation(_location._name);
}
void Parallaction_br::changeLocation(char *location) {
}
void Parallaction_br::changeCharacter(const char *name) {
}
void Parallaction_br::initJobs() {
static const JobFn jobs[] = {
0,
0,
&Parallaction_br::jobDisplayDroppedItem,
&Parallaction_br::jobRemovePickedItem,
0,
0,
0,
0,
&Parallaction_br::jobWaitRemoveLabelJob,
&Parallaction_br::jobToggleDoor,
&Parallaction_br::jobEraseSubtitle,
&Parallaction_br::jobDisplaySubtitle,
&Parallaction_br::jobWaitRemoveSubtitleJob,
&Parallaction_br::jobPauseSfx,
&Parallaction_br::jobStopFollower,
&Parallaction_br::jobScroll
};
_jobsFn = jobs;
}
JobOpcode* Parallaction_br::createJobOpcode(uint functionId, Job *job) {
return new OpcodeImpl2<Parallaction_br>(this, _jobsFn[functionId], job);
}
void Parallaction_br::setArrowCursor() {
}
void Parallaction_br::setInventoryCursor(int pos) {
}
} // namespace Parallaction
|