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
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (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, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "access/resources.h"
24 #include "access/amazon/amazon_game.h"
25 #include "access/amazon/amazon_resources.h"
26 #include "access/amazon/amazon_room.h"
27 #include "access/amazon/amazon_scripts.h"
28
29 namespace Access {
30
31 namespace Amazon {
32
AmazonEngine(OSystem * syst,const AccessGameDescription * gameDesc)33 AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc)
34 : AccessEngine(syst, gameDesc), _guardLocation(_flags[122]), _guardFind(_flags[128]),
35 _helpLevel(_flags[167]), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]),
36 _flashbackFlag(_flags[171]), _riverFlag(_flags[185]), _aniOutFlag(_flags[195]),
37 _badEnd(_flags[218]), _noHints(_flags[219]), _aniFlag(_flags[229]),
38 _allenFlag(_flags[237]), _noSound(_flags[239]) {
39 _ant = nullptr;
40 _cast = nullptr;
41 _guard = nullptr;
42 _jungle = nullptr;
43 _opening = nullptr;
44 _plane = nullptr;
45 _river = nullptr;
46
47 _charSegSwitch = false;
48
49 _oldTitleChapter = _chapter = 0;
50 _updateChapter = -1;
51 _rawInactiveX = 0;
52 _rawInactiveY = 0;
53 _inactiveYOff = 0;
54 _hintLevel = 0;
55
56 Common::fill(&_tileData[0], &_tileData[0] + sizeof(_tileData), 0);
57 Common::fill(&_help1[0], &_help1[0] + sizeof(_help1), 0);
58 Common::fill(&_help2[0], &_help2[0] + sizeof(_help2), 0);
59 Common::fill(&_help3[0], &_help3[0] + sizeof(_help3), 0);
60 _helpTbl[0] = _help1;
61 _helpTbl[1] = _help2;
62 _helpTbl[2] = _help3;
63
64 _chapter = 0;
65 _rawInactiveX = _rawInactiveY = 0;
66 _inactiveYOff = 0;
67 _hintLevel = 0;
68 _updateChapter = 0;
69 _oldTitleChapter = 0;
70 _iqValue = 0;
71
72 _chapterCells.push_back(CellIdent(0, 96, 17));
73 _inactive._spritesPtr = nullptr;
74 _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0;
75 _inactive._position = Common::Point(0, 0);
76 }
77
~AmazonEngine()78 AmazonEngine::~AmazonEngine() {
79 delete _inactive._altSpritesPtr;
80
81 delete _ant;
82 delete _cast;
83 delete _guard;
84 delete _jungle;
85 delete _opening;
86 delete _plane;
87 delete _river;
88 }
89
freeInactivePlayer()90 void AmazonEngine::freeInactivePlayer() {
91 delete _inactive._altSpritesPtr;
92 _inactive._altSpritesPtr = nullptr;
93 }
94
configSelect()95 void AmazonEngine::configSelect() {
96 // Initialize fields contained in the config file.
97 _hintLevel = 3;
98 }
99
initObjects()100 void AmazonEngine::initObjects() {
101 _room = new AmazonRoom(this);
102 _scripts = new AmazonScripts(this);
103
104 _ant = new Ant(this);
105 _cast = new Cast(this);
106 _guard = new Guard(this);
107 _jungle = new Jungle(this);
108 _opening = new Opening(this);
109 _plane = new Plane(this);
110 _river = new River(this);
111 }
112
playGame()113 void AmazonEngine::playGame() {
114 // Initialize Amazon game-specific objects
115 initObjects();
116
117 // Setup the game
118 setupGame();
119 configSelect();
120
121 if (_loadSaveSlot == -1) {
122 // Do introduction
123 _opening->doIntroduction();
124 if (shouldQuit())
125 return;
126 }
127
128 do {
129 _restartFl = false;
130 _screen->clearScreen();
131 _screen->setPanel(0);
132 _screen->forceFadeOut();
133 _events->showCursor();
134
135 initVariables();
136
137 // If there's a pending savegame to load, load it
138 if (_loadSaveSlot != -1) {
139 loadGameState(_loadSaveSlot);
140 _loadSaveSlot = -1;
141 }
142
143 // Execute the room
144 _room->doRoom();
145 } while (_restartFl);
146 }
147
setupGame()148 void AmazonEngine::setupGame() {
149 Amazon::AmazonResources &res = *((Amazon::AmazonResources *)_res);
150
151 // Load death list
152 _deaths.resize(_res->DEATHS.size());
153
154 for (uint idx = 0; idx < _deaths.size(); ++idx) {
155 _deaths[idx]._screenId = res.DEATHS[idx]._screenId;
156 _deaths[idx]._msg = res.DEATHS[idx]._msg;
157 }
158
159 // Load the deaths cells
160 _deaths._cells.resize(13);
161 for (int i = 0; i < 13; ++i)
162 _deaths._cells[i] = CellIdent(DEATH_CELLS[i][0], DEATH_CELLS[i][1], DEATH_CELLS[i][2]);
163
164 // Miscellaneous
165 _fonts.load(res._font6x6, res._font3x5);
166
167 initVariables();
168 }
169
initVariables()170 void AmazonEngine::initVariables() {
171 _chapter = 1;
172 // Set player room and position
173 if (isDemo())
174 _player->_roomNumber = 33;
175 else
176 _player->_roomNumber = 4;
177
178 _converseMode = 0;
179 _inventory->_startInvItem = 0;
180 _inventory->_startInvBox = 0;
181 Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr);
182 _player->_playerOff = false;
183
184 // Setup timers
185 const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 };
186 for (int i = 0; i < 32; ++i) {
187 TimerEntry te;
188 te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1;
189 te._flag = 1;
190
191 _timers.push_back(te);
192 }
193
194 _player->_playerX = _player->_rawPlayer.x = _res->ROOMTBL[_player->_roomNumber]._travelPos.x;
195 _player->_playerY = _player->_rawPlayer.y = _res->ROOMTBL[_player->_roomNumber]._travelPos.y;
196 _room->_selectCommand = -1;
197 _events->setNormalCursor(CURSOR_CROSSHAIRS);
198 _mouseMode = 0;
199 _numAnimTimers = 0;
200 }
201
establish(int screenId,int esatabIndex)202 void AmazonEngine::establish(int screenId, int esatabIndex) {
203 _establishMode = 0;
204 _establishGroup = 0;
205 doEstablish(screenId, esatabIndex);
206 }
207
establishCenter(int screenId,int esatabIndex)208 void AmazonEngine::establishCenter(int screenId, int esatabIndex) {
209 _establishMode = 1;
210 doEstablish(screenId, esatabIndex);
211 }
212
213 const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" };
214
loadEstablish(int estabIndex)215 void AmazonEngine::loadEstablish(int estabIndex) {
216 if (!_files->existFile("ETEXT.DAT")) {
217 int oldGroup = _establishGroup;
218 _establishGroup = 0;
219
220 _establish = _files->loadFile(_estTable[oldGroup]);
221 _establishCtrlTblOfs = READ_LE_UINT16(_establish->data());
222
223 int ofs = _establishCtrlTblOfs + (estabIndex * 2);
224 int idx = READ_LE_UINT16(_establish->data() + ofs);
225 _narateFile = READ_LE_UINT16(_establish->data() + idx);
226 _txtPages = READ_LE_UINT16(_establish->data() + idx + 2);
227
228 if (!_txtPages)
229 return;
230
231 _sndSubFile = READ_LE_UINT16(_establish->data() + idx + 4);
232 for (int i = 0; i < _txtPages; ++i)
233 _countTbl[i] = READ_LE_UINT16(_establish->data() + idx + 6 + (2 * i));
234 } else {
235 _establishGroup = 0;
236 _narateFile = 0;
237 _txtPages = 0;
238 _sndSubFile = 0;
239 _establish = _files->loadFile("ETEXT.DAT");
240 }
241 }
242
doEstablish(int screenId,int estabIndex)243 void AmazonEngine::doEstablish(int screenId, int estabIndex) {
244 _establishMode = 1;
245
246 _events->clearEvents();
247 _screen->forceFadeOut();
248 _screen->clearScreen();
249 _screen->setPanel(3);
250
251 if (screenId != -1) {
252 _files->loadScreen(95, screenId);
253 _buffer2.copyBuffer(_screen);
254 }
255
256 _screen->setIconPalette();
257 _screen->forceFadeIn();
258
259 if (getGameID() == GType_MartianMemorandum) {
260 _fonts._charSet._lo = 1;
261 _fonts._charSet._hi = 10;
262 _fonts._charFor._lo = 0xF7;
263 _fonts._charFor._hi = 0xFF;
264
265 _screen->_maxChars = 50;
266 _screen->_printOrg = _screen->_printStart = Common::Point(24, 18);
267 } else {
268 _fonts._charSet._lo = 1;
269 _fonts._charSet._hi = 10;
270 _fonts._charFor._lo = 29;
271 _fonts._charFor._hi = 32;
272
273 _screen->_maxChars = 37;
274 _screen->_printOrg = _screen->_printStart = Common::Point(48, 35);
275 }
276
277 loadEstablish(estabIndex);
278 uint16 msgOffset;
279 if (!isCD())
280 msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2));
281 else
282 msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2);
283
284 _printEnd = 155;
285 Common::String msg((const char *)_establish->data() + msgOffset);
286
287 if ((_txtPages == 0) || !isCD()) {
288 printText(_screen, msg);
289 } else {
290 speakText(_screen, msg);
291 }
292
293 _screen->forceFadeOut();
294 _screen->clearScreen();
295
296 delete _establish;
297 _establish = nullptr;
298
299 if (_establishMode == 0)
300 _room->init4Quads();
301 }
302
303 const char *const _tileFiles[] = {
304 "GRAY.BLK", "RED.BLK", "LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "LITEBLUE.BLK",
305 "DARKBLUE.BLK", "CYAN.BLK", "GREEN.BLK", "OLIVE.BLK", "GRAY.BLK", "RED.BLK",
306 "LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "OLIVE.BLK"
307 };
308
tileScreen()309 void AmazonEngine::tileScreen() {
310 if (!_screen->_vesaMode)
311 return;
312
313 if (!_clearSummaryFlag && (_oldTitleChapter == _chapter))
314 return;
315
316 _oldTitleChapter = _chapter;
317 int idx = _chapter - 1;
318
319 if (!_files->existFile(_tileFiles[idx]))
320 return;
321
322 Resource *res = _files->loadFile(_tileFiles[idx]);
323 int x = res->_stream->readSint16LE();
324 int y = res->_stream->readSint16LE();
325 int size = ((x + 2) * y) + 10;
326
327 for (int i = 0; i < size; ++i)
328 _tileData[i] = res->_stream->readByte();
329
330 // CHECKME: Depending on the Vesa mode during initialization, 400 or 480
331 Common::Point tilePos;
332 for (tilePos.y = 0; tilePos.y < 480; tilePos.y += y) {
333 for (tilePos.x = 0; tilePos.x < 640; tilePos.x += x)
334 warning("TODO: DRAWOBJECT");
335 }
336
337 delete res;
338 }
339
updateSummary(int chap)340 void AmazonEngine::updateSummary(int chap) {
341 if (!_screen->_vesaMode)
342 return;
343
344 int chapter = chap;
345 if (chapter > 16)
346 chapter = 16;
347
348 if (!_clearSummaryFlag && (chapter == _updateChapter))
349 return;
350
351 _clearSummaryFlag = false;
352 int celSubFile = 0;
353 _updateChapter = chapter;
354 Common::Array<CellIdent> summaryCells;
355 loadCells(summaryCells);
356
357 for (int i = celSubFile; i < 16; ++i) {
358 if (i > 7)
359 warning("TODO: DRAWOBJECT");
360 else
361 warning("TODO: DRAWOBJECT");
362 }
363
364 delete _objectsTable[93];
365 _objectsTable[93] = nullptr;
366
367 for (int i = 1; i <= _updateChapter; ++i) {
368 celSubFile = i;
369 loadCells(summaryCells);
370 if (i > 8)
371 warning("TODO: DRAWOBJECT");
372 else
373 warning("TODO: DRAWOBJECT");
374
375 delete _objectsTable[93];
376 _objectsTable[93] = nullptr;
377 }
378 }
379
calcIQ()380 void AmazonEngine::calcIQ() {
381 int tmpIQ = 170;
382 for (int i = 0; i < 256; i++) {
383 if (_help1[i] == 1)
384 tmpIQ -= 3;
385 }
386
387 for (int i = 0; i < 256; i++) {
388 if (_help2[i] == 1)
389 tmpIQ -= 5;
390 }
391
392 for (int i = 0; i < 256; i++) {
393 if (_help3[i] == 1)
394 tmpIQ -= 10;
395 }
396
397 if (tmpIQ < 0)
398 tmpIQ = 0;
399
400 _iqValue = tmpIQ;
401
402 if (_iqValue <= 100)
403 _badEnd = 1;
404
405 if (_iqValue <= 0)
406 _noHints = 1;
407 }
408
helpTitle()409 void AmazonEngine::helpTitle() {
410 AmazonResources &res = *(AmazonResources *)_res;
411 int width = _fonts._font2->stringWidth(_bubbleBox->_bubbleTitle);
412 int posX = 160 - (width / 2);
413 _fonts._font2->_fontColors[0] = 0;
414 _fonts._font2->_fontColors[1] = 33;
415 _fonts._font2->_fontColors[2] = 34;
416 _fonts._font2->_fontColors[3] = 35;
417 _fonts._font2->drawString(_screen, _bubbleBox->_bubbleTitle, Common::Point(posX, 24));
418
419 width = _fonts._font2->stringWidth(res.HELPLVLTXT[_helpLevel]);
420 posX = 160 - (width / 2);
421 _fonts._font2->_fontColors[0] = 0;
422 _fonts._font2->_fontColors[1] = 10;
423 _fonts._font2->_fontColors[2] = 11;
424 _fonts._font2->_fontColors[3] = 12;
425 _fonts._font2->drawString(_screen, res.HELPLVLTXT[_helpLevel], Common::Point(posX, 36));
426
427 Common::String iqText = "IQ: ";
428 calcIQ();
429 Common::String scoreIQ = Common::String::format("%d", _iqValue);
430 while (scoreIQ.size() < 4)
431 scoreIQ = " " + scoreIQ;
432
433 iqText += scoreIQ;
434 int index = _iqValue;
435 if (index == 170)
436 index = 169;
437
438 index /= 20;
439
440 iqText += " ";
441 iqText += res.IQLABELS[index];
442
443 width = _fonts._font2->stringWidth(iqText);
444 posX = 160 - (width / 2);
445 _fonts._font2->_fontColors[0] = 0;
446 _fonts._font2->_fontColors[1] = 10;
447 _fonts._font2->_fontColors[2] = 11;
448 _fonts._font2->_fontColors[3] = 12;
449 _fonts._font2->drawString(_screen, iqText, Common::Point(posX, 44));
450 }
451
drawHelpText(const Common::String & msg)452 void AmazonEngine::drawHelpText(const Common::String &msg) {
453 _screen->_maxChars = 39;
454 _screen->_printOrg = Common::Point(26, 58);
455 _screen->_printStart = Common::Point(26, 58);
456
457 Common::String lines = msg;
458 Common::String line;
459 int width = 0;
460 bool lastLine = false;
461 do {
462 lastLine = _fonts._font2->getLine(lines, _screen->_maxChars * 6, line, width);
463
464 // Set font colors
465 _fonts._font2->_fontColors[0] = 0;
466 _fonts._font2->_fontColors[1] = 27;
467 _fonts._font2->_fontColors[2] = 28;
468 _fonts._font2->_fontColors[3] = 29;
469
470 _fonts._font2->drawString(_screen, line, _screen->_printOrg);
471 _screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 8);
472 } while (!lastLine);
473
474 _events->showCursor();
475 }
476
drawHelp(const Common::String str)477 void AmazonEngine::drawHelp(const Common::String str) {
478 _events->hideCursor();
479 if (_useItem == 0) {
480 _buffer2.copyBuffer(_screen);
481 if (_screen->_vesaMode) {
482 _screen->setPanel(2);
483 _screen->saveScreen();
484 }
485 _screen->savePalette();
486 _screen->fadeOut();
487 _screen->clearBuffer();
488 if (_moreHelp == 1) {
489 // Set cells
490 Common::Array<CellIdent> cells;
491 cells.push_back(CellIdent(95, 95, 3));
492 loadCells(cells);
493 }
494 }
495
496 _files->loadScreen(95, 2);
497 if (_moreHelp == 1) {
498 BaseSurface *oldDest = _destIn;
499 _destIn = _screen;
500 int oldClip = _screen->_clipHeight;
501 _screen->_clipHeight = 200;
502 _screen->plotImage(_objectsTable[95], 0, Common::Point(76, 168));
503 _destIn = oldDest;
504 _screen->_clipHeight = oldClip;
505 }
506
507 if ((_useItem == 0) && (_screen->_vesaMode == 0))
508 _screen->fadeIn();
509
510 helpTitle();
511 drawHelpText(str);
512 }
513
startChapter(int chapter)514 void AmazonEngine::startChapter(int chapter) {
515 _chapter = chapter;
516 assert(_chapter <= 14);
517
518 if (chapter != 1) {
519 _room->clearRoom();
520 freeChar();
521
522 _midi->newMusic(32, 0);
523 playVideo(0, Common::Point());
524 if (shouldQuit())
525 return;
526
527 _events->debounceLeft();
528 _events->zeroKeys();
529 playVideo(_chapter, Common::Point(4, 113));
530 if (shouldQuit())
531 return;
532
533 _timers[20]._timer = 500;
534 _timers[20]._initTm = 500;
535 _timers[20]._flag++;
536 _sound->freeSounds();
537
538 if (isCD()) {
539 _sound->loadSoundTable(0, 115, 0);
540 _sound->loadSoundTable(1, 115, 1);
541 _sound->playSound(0);
542 _sound->playSound(1);
543
544 _sound->freeSounds();
545 }
546
547 // Wait loop
548 while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
549 _events->pollEventsAndWait();
550 }
551 }
552
553 _screen->forceFadeOut();
554 _events->debounceLeft();
555 _events->zeroKeys();
556 _screen->clearScreen();
557
558 _screen->setPanel(3);
559
560 // Set up cells for the chapter display
561 Common::Array<CellIdent> chapterCells;
562 chapterCells.push_back(CellIdent(0, 96, 17));
563 const int *chapCell = &CHAPTER_CELLS[_chapter - 1][0];
564 chapterCells.push_back(CellIdent(chapCell[0], chapCell[1], chapCell[2]));
565 loadCells(chapterCells);
566
567 // Show chapter screen
568 _files->loadScreen(96, 15);
569 _buffer2.blitFrom(*_screen);
570
571 const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0];
572 _screen->plotImage(_objectsTable[0], _chapter - 1,
573 Common::Point(chapImg[1], chapImg[2]));
574 _screen->plotImage(_objectsTable[_chapter], 0,
575 Common::Point(chapImg[3], chapImg[4]));
576 if (chapter == 14)
577 _screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76));
578
579 _midi->newMusic(chapImg[4], 1);
580 _midi->newMusic(33, 0);
581 _screen->forceFadeIn();
582
583 _timers[20]._timer = 950;
584 _timers[20]._initTm = 950;
585 _timers[20]._flag++;
586
587 // Wait loop
588 while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) {
589 _events->pollEventsAndWait();
590 }
591 if (shouldQuit())
592 return;
593
594 _screen->forceFadeOut();
595 _events->debounceLeft();
596 _events->zeroKeys();
597
598 _screen->clearBuffer();
599 _files->loadScreen(96, 16);
600 _buffer2.blitFrom(*_screen);
601 _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7));
602
603 _midi->newMusic(7, 1);
604 _midi->newMusic(34, 0);
605
606 _screen->forceFadeIn();
607 _buffer2.blitFrom(*_screen);
608
609 _fonts._charSet._lo = 1;
610 _fonts._charSet._hi = 10;
611 _fonts._charFor._lo = 55;
612 _fonts._charFor._hi = 0xFF;
613 _screen->_maxChars = 43;
614 _screen->_printOrg = Common::Point(31, 77);
615 _screen->_printStart = Common::Point(31, 77);
616
617 _establishGroup = 1;
618 loadEstablish(0x40 + _chapter);
619
620 byte *entryOffset = _establish->data() + ((0x40 + _chapter) * 2);
621 if (isCD())
622 entryOffset += 2;
623
624 uint16 msgOffset = READ_LE_UINT16(entryOffset);
625 _printEnd = 170;
626
627 Common::String msg((const char *)_establish->data() + msgOffset);
628
629 if ((_txtPages == 0) || !isCD()) {
630 printText(_screen, msg);
631 } else {
632 speakText(_screen, msg);
633 }
634 if (shouldQuit())
635 return;
636
637 _screen->forceFadeOut();
638 _screen->clearBuffer();
639 freeCells();
640
641 _midi->newMusic(_chapter * 2, 1);
642
643 if (chapter != 1 && chapter != 14) {
644 _room->init4Quads();
645 }
646
647 if (isCD()) {
648 if (chapter == 14) {
649 _conversation = 31;
650 _char->loadChar(_conversation);
651 _events->setCursor(CURSOR_ARROW);
652
653 _images.clear();
654 _oldRects.clear();
655 _scripts->_sequence = 0;
656 _scripts->searchForSequence();
657
658 if (_screen->_vesaMode) {
659 _converseMode = 1;
660 }
661 } else if (chapter != 1) {
662 _player->_roomNumber = CHAPTER_JUMP[_chapter - 1];
663 _room->_function = FN_CLEAR1;
664 _converseMode = 0;
665
666 _scripts->cmdRetPos();
667 }
668 }
669 }
670
671
dead(int deathId)672 void AmazonEngine::dead(int deathId) {
673 _events->hideCursor();
674 _screen->forceFadeOut();
675 _scripts->cmdFreeSound();
676 _events->debounceLeft();
677 _events->zeroKeys();
678
679 _sound->_soundTable.push_back(SoundEntry(_files->loadFile(98, 44), 1));
680
681 _screen->clearScreen();
682 _screen->setPanel(3);
683
684 if ((deathId == 10) && !isDemo()) {
685 quitGame();
686 _events->pollEvents();
687 return;
688 } else {
689 if (!isDemo())
690 _midi->newMusic(62, 0);
691 _files->_setPaletteFlag = false;
692 _files->loadScreen(94, 0);
693 _files->_setPaletteFlag = true;
694 _buffer2.blitFrom(*_screen);
695
696 if (!isDemo() || deathId != 10) {
697 for (int i = 0; i < 3; ++i) {
698 _sound->playSound(0);
699 _screen->forceFadeIn();
700 _sound->playSound(0);
701 _screen->forceFadeOut();
702
703 _events->pollEvents();
704 if (shouldQuit())
705 return;
706 }
707 }
708
709 if (!isDemo()) {
710 freeCells();
711
712 // Load the cell list for the death screen
713 DeathEntry &de = _deaths[deathId];
714 Common::Array<CellIdent> cells;
715 cells.push_back(_deaths._cells[de._screenId]);
716 loadCells(cells);
717
718 _screen->setDisplayScan();
719 _files->_setPaletteFlag = false;
720 _files->loadScreen(&_buffer2, 94, 1);
721 _screen->setIconPalette();
722
723 _buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25));
724 _buffer2.copyTo(_screen);
725 _screen->forceFadeIn();
726
727 _fonts._charSet._hi = 10;
728 _fonts._charSet._lo = 1;
729 _fonts._charFor._lo = 55;
730 _fonts._charFor._hi = 255;
731 _screen->_maxChars = 46;
732 _screen->_printOrg = Common::Point(20, 155);
733 _screen->_printStart = Common::Point(20, 155);
734
735 Common::String &msg = de._msg;
736 _printEnd = 180;
737
738 printText(_screen, msg);
739 _screen->forceFadeOut();
740
741 _midi->newMusic(0, 1);
742 _events->showCursor();
743 _room->clearRoom();
744 freeChar();
745
746 _currentManOld = 1;
747 _player->removeSprite1();
748
749 } else {
750 _files->loadScreen(_screen, 94, _deaths[deathId]._screenId);
751 _screen->forceFadeIn();
752
753 _fonts._charSet._hi = 10;
754 _fonts._charSet._lo = 1;
755 _fonts._charFor._lo = 55;
756 _fonts._charFor._hi = 255;
757 _screen->_maxChars = 49;
758 _screen->_printOrg = Common::Point(15, 165);
759 _screen->_printStart = Common::Point(15, 165);
760
761 Common::String msg = Common::String(_deaths[deathId]._msg);
762 _printEnd = 200;
763
764 printText(_screen, msg);
765 _screen->fadeOut();
766
767 _events->showCursor();
768 _room->clearRoom();
769 freeChar();
770
771 _currentManOld = 1;
772 _player->removeSprite1();
773 }
774
775 // The original was jumping to the restart label in main
776 _restartFl = true;
777 _events->pollEvents();
778 }
779 }
780
synchronize(Common::Serializer & s)781 void AmazonEngine::synchronize(Common::Serializer &s) {
782 AccessEngine::synchronize(s);
783
784 s.syncAsSint16LE(_chapter);
785 s.syncAsSint16LE(_rawInactiveX);
786 s.syncAsSint16LE(_rawInactiveY);
787 s.syncAsSint16LE(_inactiveYOff);
788
789 for (int i = 0; i < 366; ++i) {
790 s.syncAsByte(_help1[i]);
791 s.syncAsByte(_help2[i]);
792 s.syncAsByte(_help3[i]);
793 }
794
795 _river->synchronize(s);
796 _ant->synchronize(s);
797 }
798
799 } // End of namespace Amazon
800
801 } // End of namespace Access
802