ScummVM
kyra_mr.cpp
Go to the documentation of this file.
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 "kyra/engine/kyra_mr.h"
24 #include "kyra/graphics/wsamovie.h"
25 #include "kyra/text/text_mr.h"
26 #include "kyra/graphics/vqa.h"
27 #include "kyra/engine/timer.h"
28 #include "kyra/gui/debugger.h"
29 #include "kyra/gui/gui_mr.h"
30 #include "kyra/resource/resource.h"
32 
33 #include "common/system.h"
34 #include "common/config-manager.h"
35 
36 namespace Kyra {
37 
38 const KyraEngine_v2::EngineDesc KyraEngine_MR::_mrEngineDesc = {
39  // Generic shape related
40  248,
42 
43  // Scene script
44  9,
45 
46  // Animation script specific
47  9,
48 
49  // Item specific
50  71
51 };
52 
53 KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngine_v2(system, flags, _mrEngineDesc) {
54  _soundDigital = 0;
55  _musicSoundChannel = -1;
56  _menuAudioFile = "TITLE1";
57  _lastMusicCommand = -1;
59  _scoreFile = 0;
60  _cCodeFile = 0;
61  _scenesFile = 0;
62  _itemFile = 0;
63  _gamePlayBuffer = 0;
65  _costPalBuffer = 0;
66  memset(_sceneShapes, 0, sizeof(_sceneShapes));
67  memset(_sceneAnimMovie, 0, sizeof(_sceneAnimMovie));
68  _gfxBackUpRect = 0;
69  _paletteOverlay = 0;
70  _sceneList = 0;
72  _mainCharacter.height = 0x4C;
76  memset(_activeItemAnim, 0, sizeof(_activeItemAnim));
77  _nextAnimItem = 0;
78  _text = 0;
79  _commandLineY = 189;
80  _inventoryState = false;
81  memset(_characterAnimTable, 0, sizeof(_characterAnimTable));
82  _overwriteSceneFacing = false;
84  _sceneStrings = 0;
86  _mainCharX = _mainCharY = -1;
87  _animList = 0;
88  _drawNoShapeFlag = false;
89  _wasPlayingVQA = false;
90  _lastCharPalLayer = -1;
91  _charPalUpdate = false;
92  _runFlag = false;
93  _unk5 = 0;
94  _unkSceneScreenFlag1 = false;
95  _noScriptEnter = true;
97  _savedMouseState = -1;
98  _unk4 = 0;
99  _loadingState = false;
100  _noStartupChat = false;
101  _pathfinderFlag = 0;
102  _talkObjectList = 0;
103  memset(&_chatScriptState, 0, sizeof(_chatScriptState));
104  memset(&_chatScriptData, 0, sizeof(_chatScriptData));
105  _voiceSoundChannel = -1;
108  _useActorBuffer = false;
109  _curStudioSFX = 283;
110  _badConscienceShown = false;
111  _currentChapter = 1;
113  memset(_sceneShapeDescs, 0, sizeof(_sceneShapeDescs));
114  _cnvFile = _dlgBuffer = 0;
116  _isStartupDialog = 0;
117  _stringBuffer = 0;
118  _menu = 0;
119  _menuAnim = 0;
121  memset(&_dialogScriptData, 0, sizeof(_dialogScriptData));
122  memset(&_dialogScriptState, 0, sizeof(_dialogScriptState));
124  _malcolmsMood = 1;
125  _nextIdleAnim = 0;
126  _nextIdleType = false;
128  _invWsa = 0;
129  _invWsaFrame = -1;
130  _score = 0;
131  memset(_scoreFlagTable, 0, sizeof(_scoreFlagTable));
132  _mainButtonData = 0;
133  _mainButtonList = 0;
135  _enableInventory = true;
136  _goodConscienceShown = false;
137  _goodConscienceAnim = -1;
138  _goodConsciencePosition = false;
139  _menuDirectlyToLoad = false;
140  _optionsFile = 0;
141  _actorFile = 0;
142  _chatAltFlag = false;
143  _albumChatActive = false;
144  memset(&_album, 0, sizeof(_album));
145  _configHelium = false;
147  memset(_scaleTable, 0, sizeof(_scaleTable));
148 }
149 
151  uninitMainMenu();
152 
153  delete _screen;
154  delete _soundDigital;
155 
156  delete[] _itemBuffer1;
157  delete[] _itemBuffer2;
158  delete[] _scoreFile;
159  delete[] _cCodeFile;
160  delete[] _scenesFile;
161  delete[] _itemFile;
162  delete[] _actorFile;
163  delete[] _gamePlayBuffer;
164  delete[] _interface;
165  delete[] _interfaceCommandLine;
166  delete[] _costPalBuffer;
167 
168  for (uint i = 0; i < ARRAYSIZE(_sceneShapes); ++i)
169  delete[] _sceneShapes[i];
170 
171  for (uint i = 0; i < ARRAYSIZE(_sceneAnimMovie); ++i)
172  delete _sceneAnimMovie[i];
173 
174  delete[] _gfxBackUpRect;
175  delete[] _paletteOverlay;
176 
177  for (ShapeMap::iterator i = _gameShapes.begin(); i != _gameShapes.end(); ++i) {
178  delete[] i->_value;
179  i->_value = 0;
180  }
181  _gameShapes.clear();
182 
183  delete[] _sceneStrings;
184  delete[] _talkObjectList;
185 
187  delete *i;
188  _opcodesDialog.clear();
189 
190  delete _cnvFile;
191  delete _dlgBuffer;
192  delete[] _stringBuffer;
193  delete _invWsa;
194  delete[] _mainButtonData;
195  delete _gui;
196  delete[] _optionsFile;
197 
198  delete _album.wsa;
199  delete _album.leftPage.wsa;
200  delete _album.rightPage.wsa;
201 }
202 
204  _screen = new Screen_MR(this, _system);
205  assert(_screen);
207 
208  _debugger = new Debugger_v2(this);
209  assert(_debugger);
210 
213 
214  _soundDigital = new SoundDigital_MR(this, _mixer);
217  assert(_text);
218  _gui = new GUI_MR(this);
219  assert(_gui);
220  _gui->initStaticData();
221 
223  _screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
224  _screen->loadFont(Screen::FID_BOOKFONT_FNT, "BOOKFONT.FNT");
226  _screen->setAnimBlockPtr(3500);
227  _screen->setScreenDim(0);
228 
229  _screen->loadPalette("PALETTE.COL", _screen->getPalette(0));
231 
232  return Common::kNoError;
233 }
234 
236  bool running = true;
237  preinit();
238  _screen->hideMouse();
239  initMainMenu();
240 
241  _screen->clearPage(0);
242  _screen->clearPage(2);
243 
244  const bool firstTimeGame = !saveFileLoadable(0);
245 
246  if (firstTimeGame) {
247  playVQA("K3INTRO");
248  _wasPlayingVQA = false;
249  }
250 
251  if (_gameToLoad != -1 || firstTimeGame) {
252  while (!_screen->isMouseVisible())
253  _screen->showMouse();
254 
255  uninitMainMenu();
256  _musicSoundChannel = -1;
257  startup();
258  runLoop();
259  running = false;
260  }
261 
262  while (running && !shouldQuit()) {
263  _screen->_curPage = 0;
264  _screen->clearPage(0);
265 
267 
269 
270  for (int i = 0; i < 64 && !shouldQuit(); ++i) {
271  uint32 nextRun = _system->getMillis() + 3 * _tickLength;
272  _menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0);
274  delayUntil(nextRun);
275  }
276 
277  for (int i = 64; i > 29 && !shouldQuit(); --i) {
278  uint32 nextRun = _system->getMillis() + 3 * _tickLength;
279  _menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0);
281  delayUntil(nextRun);
282  }
283 
284  _eventList.clear();
285 
286  switch (_menu->handle(3)) {
287  case 2:
288  _menuDirectlyToLoad = true;
289  // fall through
290 
291  case 0:
292  uninitMainMenu();
293 
294  fadeOutMusic(60);
295  _screen->fadeToBlack(60);
296  _musicSoundChannel = -1;
297  startup();
298  runLoop();
299  running = false;
300  break;
301 
302  case 1:
303  playVQA("K3INTRO");
304  _wasPlayingVQA = false;
305  _screen->hideMouse();
306  break;
307 
308  case 3:
309  fadeOutMusic(60);
310  _screen->fadeToBlack(60);
311  uninitMainMenu();
312  quitGame();
313  running = false;
314  break;
315 
316  default:
317  break;
318  }
319  }
320 
321  if (_showOutro && !shouldQuit())
322  playVQA("CREDITS");
323 
324  return Common::kNoError;
325 }
326 
328  _menuAnim = new WSAMovie_v2(this);
329  _menuAnim->open("REVENGE.WSA", 1, &_screen->getPalette(0));
330  _screen->getPalette(0).fill(0, 1, 0);
331 
332  _menu = new MainMenu(this);
333  MainMenu::StaticData data = {
334  { _mainMenuStrings[_lang*4+0], _mainMenuStrings[_lang*4+1], _mainMenuStrings[_lang*4+2], _mainMenuStrings[_lang*4+3], 0 },
335  { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF },
336  { 0x16, 0x19, 0x1A, 0x16 },
337  Screen::FID_8_FNT, 240
338  };
339 
340  if (_flags.lang == Common::ES_ESP) {
341  for (int i = 0; i < 4; ++i)
342  data.strings[i] = _mainMenuSpanishFan[i];
343  } else if (_flags.lang == Common::IT_ITA) {
344  for (int i = 0; i < 4; ++i)
345  data.strings[i] = _mainMenuItalianFan[i];
346  }
347 
348  MainMenu::Animation anim;
349  anim.anim = _menuAnim;
350  anim.startFrame = 29;
351  anim.endFrame = 63;
352  anim.delay = 2;
353 
354  _menu->init(data, anim);
355 }
356 
358  delete _menuAnim;
359  _menuAnim = 0;
360  delete _menu;
361  _menu = 0;
362 }
363 
364 void KyraEngine_MR::playVQA(const char *name) {
365  VQAMovie vqa(this, _system);
366 
368 
369  if (vqa.open(filename.c_str())) {
370  for (int i = 0; i < 4; ++i) {
371  if (i != _musicSoundChannel)
373  }
374 
375  _screen->hideMouse();
376  _screen->copyPalette(1, 0);
377  fadeOutMusic(60);
378  _screen->fadeToBlack(60);
379  _screen->clearPage(0);
380 
381  vqa.play();
382  vqa.close();
383 
385  _screen->showMouse();
386 
387  // Taken from original, it used '1' here too
388  _screen->getPalette(0).fill(0, 256, 1);
390  _screen->clearPage(0);
391  _screen->copyPalette(0, 1);
392  _wasPlayingVQA = true;
393  }
394 }
395 
396 #pragma mark -
397 
400  return;
401 
403 }
404 
405 void KyraEngine_MR::snd_playWanderScoreViaMap(int track, int force) {
407  force = 1;
408  else if (_musicSoundChannel == -1)
409  force = 1;
410 
411  if (track == _lastMusicCommand && !force)
412  return;
413 
414  stopMusicTrack();
415 
416  if (_musicSoundChannel == -1) {
417  assert(track < _soundListSize && track >= 0);
418 
420  }
421 
422  _lastMusicCommand = track;
423 }
424 
428 
429  _lastMusicCommand = -1;
430  _musicSoundChannel = -1;
431 }
432 
434  if (_musicSoundChannel >= 0) {
437  _lastMusicCommand = -1;
438  }
439 }
440 
442  if (_sfxFileMap[item*2+0] != 0xFF) {
443  assert(_sfxFileMap[item*2+0] < _sfxFileListSize);
445  uint8 priority = _sfxFileMap[item*2+1];
446 
448  }
449 }
450 
452  snd_playVoiceFile(high * 1000 + low);
453 }
454 
457 
458  if (speechEnabled())
460 }
461 
464 }
465 
467  if (_voiceSoundChannel != -1)
469 }
470 
471 void KyraEngine_MR::playStudioSFX(const char *str) {
472  if (!_configStudio)
473  return;
474 
475  if (_rnd.getRandomNumberRng(1, 2) != 2)
476  return;
477 
478  const int strSize = strlen(str) - 1;
479  if (str[strSize] != '?' && str[strSize] != '!')
480  return;
481 
483 
484  if (_curStudioSFX > 291)
485  _curStudioSFX = 283;
486 }
487 
488 #pragma mark -
489 
491  _itemBuffer1 = new int8[72];
492  _itemBuffer2 = new int8[144];
493  initMouseShapes();
494  initItems();
495 
497 }
498 
500  uint8 *data = _res->fileData("MOUSE.SHP", 0);
501  assert(data);
502  for (int i = 0; i <= 6; ++i)
503  _gameShapes[i] = _screen->makeShapeCopy(data, i);
504  delete[] data;
505 }
506 
508  _album.wsa = new WSAMovie_v2(this);
509  assert(_album.wsa);
510  _album.leftPage.wsa = new WSAMovie_v2(this);
512  _album.rightPage.wsa = new WSAMovie_v2(this);
514 
515  _gamePlayBuffer = new uint8[64000];
516 
517  _interface = new uint8[17920];
518  _interfaceCommandLine = new uint8[3840];
519 
521 
522  _stringBuffer = new char[500];
523  allocAnimObjects(1, 16, 50);
524 
525  memset(_sceneShapes, 0, sizeof(_sceneShapes));
526  _screenBuffer = new uint8[64000];
527 
528  if (!loadLanguageFile("ITEMS.", _itemFile))
529  error("Couldn't load ITEMS");
530  if (!loadLanguageFile("SCORE.", _scoreFile))
531  error("Couldn't load SCORE");
532  if (!loadLanguageFile("C_CODE.", _cCodeFile))
533  error("Couldn't load C_CODE");
534  if (!loadLanguageFile("SCENES.", _scenesFile))
535  error("Couldn't load SCENES");
536  if (!loadLanguageFile("OPTIONS.", _optionsFile))
537  error("Couldn't load OPTIONS");
538  if (!loadLanguageFile("_ACTOR.", _actorFile))
539  error("couldn't load _ACTOR");
540 
541  openTalkFile(0);
542  _currentTalkFile = 0;
543  openTalkFile(1);
544  loadCostPal();
545 
546  for (int i = 0; i < 16; ++i) {
547  _sceneAnims[i].flags = 0;
548  _sceneAnimMovie[i] = new WSAMovie_v2(this);
550  }
551 
552  _screen->_curPage = 0;
553 
554  _talkObjectList = new TalkObject[88];
555  memset(_talkObjectList, 0, sizeof(TalkObject)*88);
556  for (int i = 0; i < 88; ++i)
557  _talkObjectList[i].sceneId = 0xFF;
558 
559  _gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)];
560  initItemList(50);
561  resetItemList();
562 
563  loadShadowShape();
568  initMainButtonList(true);
571 
572  _screen->loadPalette("PALETTE.COL", _screen->getPalette(0));
573  _paletteOverlay = new uint8[256];
575 
576  loadInterface();
577 
579 
580  _scoreMax = 0;
581  for (int i = 0; i < _scoreTableSize; ++i) {
582  if (_scoreTable[i] > 0)
583  _scoreMax += _scoreTable[i];
584  }
585 
586  memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
587  memset(_conversationState, -1, sizeof(_conversationState));
588 
589  _sceneList = new SceneDesc[98];
591  memset(_sceneList, 0, sizeof(SceneDesc)*98);
592  _sceneListSize = 98;
593 
594  runStartupScript(1, 0);
595  _res->exists("MOODOMTR.WSA", true);
596  _invWsa = new WSAMovie_v2(this);
597  assert(_invWsa);
598  _invWsa->open("MOODOMTR.WSA", 1, 0);
599  _invWsaFrame = 6;
600  saveGameStateIntern(0, "New Game", 0);
601  if (_gameToLoad == -1)
603  else
605 
608 
610  _screen->showMouse();
611 
614 }
615 
617  _res->exists("_COSTPAL.DAT", true);
618  uint32 size = 0;
619  _costPalBuffer = _res->fileData("_COSTPAL.DAT", &size);
621  assert(size == 864);
622 }
623 
625  _screen->loadBitmap("SHADOW.CSH", 3, 3, 0);
626  addShapeToPool(_screen->getCPagePtr(3), 421, 0);
627 }
628 
630  _screen->loadBitmap("EXTRAS.CSH", 3, 3, 0);
631  for (int i = 0; i < 20; ++i)
632  addShapeToPool(_screen->getCPagePtr(3), i+433, i);
633  addShapeToPool(_screen->getCPagePtr(3), 453, 20);
634  addShapeToPool(_screen->getCPagePtr(3), 454, 21);
635 }
636 
638  _screen->loadBitmap("INTRFACE.CSH", 3, 3, 0);
639  for (int i = 422; i <= 432; ++i)
640  addShapeToPool(_screen->getCPagePtr(3), i, i-422);
641 }
642 
644  _screen->loadBitmap("INTRFACE.CPS", 3, 3, 0);
645  memcpy(_interface, _screen->getCPagePtr(3), 17920);
646  memcpy(_interfaceCommandLine, _screen->getCPagePtr(3), 3840);
647 }
648 
650  _screen->loadBitmap("ITEMS.CSH", 3, 3, 0);
651 
652  for (int i = 248; i <= 319; ++i)
653  addShapeToPool(_screen->getCPagePtr(3), i, i-248);
654 
655  _screen->loadBitmap("ITEMS2.CSH", 3, 3, 0);
656 
657  for (int i = 320; i <= 397; ++i)
658  addShapeToPool(_screen->getCPagePtr(3), i, i-320);
659 
660  uint32 size = 0;
661  uint8 *itemsDat = _res->fileData("_ITEMS.DAT", &size);
662 
663  assert(size >= 72+144);
664 
665  memcpy(_itemBuffer1, itemsDat , 72);
666  memcpy(_itemBuffer2, itemsDat+72, 144);
667 
668  delete[] itemsDat;
669 
670  _screen->_curPage = 0;
671 }
672 
673 void KyraEngine_MR::runStartupScript(int script, int unk1) {
674  EMCState state;
675  EMCData data;
676  memset(&state, 0, sizeof(state));
677  memset(&data, 0, sizeof(data));
678  char filename[13];
679  strcpy(filename, "_START0X.EMC");
680  filename[7] = (script % 10) + '0';
681 
682  _emc->load(filename, &data, &_opcodes);
683  _emc->init(&state, &data);
684  _emc->start(&state, 0);
685  state.regs[6] = unk1;
686 
687  while (_emc->isValid(&state))
688  _emc->run(&state);
689 
690  _emc->unload(&data);
691 }
692 
694  char talkFilename[16];
695 
696  if (file == 0) {
697  strcpy(talkFilename, "ANYTALK.TLK");
698  } else {
699  if (_currentTalkFile > 0) {
700  sprintf(talkFilename, "CH%dTALK.TLK", _currentTalkFile);
701  _res->unloadPakFile(talkFilename);
702  }
703  sprintf(talkFilename, "CH%dTALK.TLK", file);
704  }
705 
707  if (!_res->loadPakFile(talkFilename)) {
708  if (speechEnabled()) {
709  warning("Couldn't load voice file '%s', falling back to text only mode", talkFilename);
710  _configVoice = 0;
711 
712  // Sync the config manager with the new settings
713  writeSettings();
714  }
715  }
716 }
717 
718 #pragma mark -
719 
721  static const uint8 numberOffset[] = { 3, 3, 4, 4, 3, 3 };
722  static const uint8 startShape[] = { 0x32, 0x58, 0x78, 0x98, 0xB8, 0xD8 };
723  static const uint8 endShape[] = { 0x57, 0x77, 0x97, 0xB7, 0xD7, 0xF7 };
724  static const char *const filenames[] = {
725  "MSW##.SHP",
726  "MTA##.SHP",
727  "MTFL##.SHP",
728  "MTFR##.SHP",
729  "MTL##.SHP",
730  "MTR##.SHP"
731  };
732 
733  for (int i = 50; i <= 247; ++i) {
734  if (i == 87)
735  continue;
736 
738  if (iter != _gameShapes.end()) {
739  delete[] iter->_value;
740  iter->_value = 0;
741  }
742  }
743 
744  const char lowNum = (newShapes % 10) + '0';
745  const char highNum = (newShapes / 10) + '0';
746 
747  for (int i = 0; i < 6; ++i) {
748  char filename[16];
749  strcpy(filename, filenames[i]);
750  filename[numberOffset[i]+0] = highNum;
751  filename[numberOffset[i]+1] = lowNum;
752  _res->exists(filename, true);
753  _res->loadFileToBuf(filename, _screenBuffer, 64000);
754  for (int j = startShape[i]; j <= endShape[i]; ++j) {
755  if (j == 87)
756  continue;
757  addShapeToPool(_screenBuffer, j, j-startShape[i]);
758  }
759  }
760 
761  _characterShapeFile = newShapes;
763 }
764 
771 }
772 
773 #pragma mark -
774 
776  return _mainCharacter.walkspeed;
777 }
778 
781  int facing = _mainCharacter.facing;
782 
783  if (table) {
784  if (table[0] != table[-1] && table[1] == table[-1]) {
785  facing = getOppositeFacingDirection(table[-1]);
786  table[0] = table[-1];
787  }
788  }
789 
790  if (facing) {
791  if (facing == 7 || facing == 1) {
792  if (_characterAnimTable[0] > 2)
793  facing = 0;
794  memset(_characterAnimTable, 0, sizeof(_characterAnimTable));
795  } else if (facing == 4) {
796  ++_characterAnimTable[1];
797  } else if (facing == 5 || facing == 3) {
798  if (_characterAnimTable[1] > 2)
799  facing = 4;
800  memset(_characterAnimTable, 0, sizeof(_characterAnimTable));
801  }
802  } else {
803  ++_characterAnimTable[0];
804  }
805 
806  switch (facing) {
807  case 0:
810  break;
811 
812  case 1: case 2: case 3:
815  break;
816 
817  case 4:
820  break;
821 
822  case 5: case 6: case 7:
825  break;
826 
827  default:
828  break;
829  }
830 
832 }
833 
835  int layer = _screen->getLayer(_mainCharacter.x1, _mainCharacter.y1) - 1;
836  const uint8 *src = _costPalBuffer + _characterShapeFile * 72;
837  Palette &dst = _screen->getPalette(0);
838  const int8 *sceneDatPal = &_sceneDatPalette[layer * 3];
839 
840  if (layer != _lastCharPalLayer && unk1) {
841  for (int i = 144; i < 168; ++i) {
842  for (int j = 0; j < 3; ++j) {
843  uint8 col = dst[i * 3 + j];
844  int subCol = src[(i - 144) * 3 + j] + sceneDatPal[j];
845  subCol = CLIP(subCol, 0, 63);
846  subCol = (col - subCol) / 2;
847  dst[i * 3 + j] -= subCol;
848  }
849  }
850 
851  _charPalUpdate = true;
853  _lastCharPalLayer = layer;
854  } else if (_charPalUpdate || !unk1) {
855  dst.copy(_costPalBuffer, _characterShapeFile * 24, 24, 144);
856 
857  for (int i = 144; i < 168; ++i) {
858  for (int j = 0; j < 3; ++j) {
859  int col = dst[i * 3 + j] + sceneDatPal[j];
860  dst[i * 3 + j] = CLIP(col, 0, 63);
861  }
862  }
863 
865  _charPalUpdate = false;
866  }
867 }
868 
871  int width = (scale * 37) >> 8;
872  int height = (scale * 76) >> 8;
873 
874  int x1 = _mainCharacter.x1 - width/2;
875  int x2 = _mainCharacter.x1 + width/2;
876  int y1 = _mainCharacter.y1 - height;
877  int y2 = _mainCharacter.y1;
878 
879  if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
880  return true;
881  return false;
882 }
883 
884 #pragma mark -
885 
887  // Initialize debugger since how it should be fully usable
889 
890  _eventList.clear();
891 
892  _runFlag = true;
893  while (_runFlag && !shouldQuit()) {
894  if (_deathHandler >= 0) {
895  removeHandItem();
896  delay(5);
897  _drawNoShapeFlag = 0;
898  _gui->optionsButton(0);
899  _deathHandler = -1;
900 
901  if (!_runFlag || shouldQuit())
902  break;
903  }
904 
905  if (_system->getMillis() >= _nextIdleAnim)
906  showIdleAnim();
907 
908  int inputFlag = checkInput(_mainButtonList, true);
909  removeInputTop();
910 
911  update();
912  _timer->update();
913 
914  if (inputFlag == 198 || inputFlag == 199) {
916  Common::Point mouse = getMousePos();
917  handleInput(mouse.x, mouse.y);
918  }
919 
920  _system->delayMillis(10);
921  }
922 }
923 
925  if (_inventoryState)
926  return;
928 
929  if (_unk5) {
930  _unk5 = 0;
931  return;
932  }
933 
934  if (!_screen->isMouseVisible())
935  return;
936 
937  if (_savedMouseState == -3) {
938  snd_playSoundEffect(0x0D, 0x80);
939  return;
940  }
941 
943 
944  int skip = 0;
945 
946  if (checkCharCollision(x, y) && _savedMouseState >= -1 && runSceneScript2()) {
947  return;
948  } else if (_itemInHand != 27 && pickUpItem(x, y, 1)) {
949  return;
950  } else if (checkItemCollision(x, y) == -1) {
951  resetGameFlag(1);
952  skip = runSceneScript1(x, y);
953 
954  if (queryGameFlag(1)) {
955  resetGameFlag(1);
956  return;
957  } else if (_unk5) {
958  _unk5 = 0;
959  return;
960  }
961  }
962 
963  if (_deathHandler >= 0)
964  skip = 1;
965 
966  if (skip)
967  return;
968 
969  if (checkCharCollision(x, y)) {
970  if (runSceneScript2())
971  return;
972  } else if (_itemInHand >= 0 && _savedMouseState >= 0) {
973  if (_itemInHand == 27) {
975  } else if (y <= 187) {
976  if (_itemInHand == 43)
977  removeHandItem();
978  else
979  dropItem(0, _itemInHand, x, y, 1);
980  }
981  return;
982  } else if (_savedMouseState == -3) {
983  return;
984  } else {
985  if (y > 187 && _savedMouseState > -4)
986  return;
987  if (_unk5) {
988  _unk5 = 0;
989  return;
990  }
991  }
992 
993  inputSceneChange(x, y, 1, 1);
994 }
995 
996 int KyraEngine_MR::inputSceneChange(int x, int y, int unk1, int unk2) {
997  uint16 curScene = _mainCharacter.sceneId;
998  _pathfinderFlag = 15;
999 
1001  if (_savedMouseState == -4) {
1002  if (_sceneList[curScene].exit4 != 0xFFFF) {
1003  x = 4;
1004  y = _sceneEnterY4;
1005  _pathfinderFlag = 7;
1006  }
1007  } else if (_savedMouseState == -6) {
1008  if (_sceneList[curScene].exit2 != 0xFFFF) {
1009  x = 316;
1010  y = _sceneEnterY2;
1011  _pathfinderFlag = 7;
1012  }
1013  } else if (_savedMouseState == -7) {
1014  if (_sceneList[curScene].exit1 != 0xFFFF) {
1015  x = _sceneEnterX1;
1016  y = _sceneEnterY1 - 2;
1017  _pathfinderFlag = 14;
1018  }
1019  } else if (_savedMouseState == -5) {
1020  if (_sceneList[curScene].exit3 != 0xFFFF) {
1021  x = _sceneEnterX3;
1022  y = 191;
1023  _pathfinderFlag = 11;
1024  }
1025  }
1026  }
1027 
1028  if (ABS(_mainCharacter.x1 - x) < 4 && ABS(_mainCharacter.y1 - y) < 2) {
1029  _pathfinderFlag = 0;
1030  return 0;
1031  }
1032 
1033  int x1 = _mainCharacter.x1 & (~3);
1034  int y1 = _mainCharacter.y1 & (~1);
1035  x &= ~3;
1036  y &= ~1;
1037 
1038  int size = findWay(x1, y1, x, y, _movFacingTable, 600);
1039  _pathfinderFlag = 0;
1040 
1041  if (!size || size == 0x7D00)
1042  return 0;
1043 
1044  return trySceneChange(_movFacingTable, unk1, unk2);
1045 }
1046 
1048  updateInput();
1049 
1051  updateMouse();
1055 
1056  _screen->updateScreen();
1057 }
1058 
1060  updateInput();
1061 
1062  updateMouse();
1066 
1067  restorePage3();
1068  drawAnimObjects();
1069  if (_chatTextEnabled && _chatText) {
1070  int curPage = _screen->_curPage;
1071  _screen->_curPage = 2;
1073  _screen->_curPage = curPage;
1074  }
1075  refreshAnimObjects(0);
1076 
1077  _screen->updateScreen();
1078 }
1079 
1081  int shape = 0, offsetX = 0, offsetY = 0;
1082  Common::Point mouse = getMousePos();
1083  bool hasItemCollision = checkItemCollision(mouse.x, mouse.y) != -1;
1084 
1085  if (mouse.y > 187) {
1086  bool setItemCursor = false;
1087  if (_mouseState == -6) {
1088  if (mouse.x < 311)
1089  setItemCursor = true;
1090  } else if (_mouseState == -5) {
1091  if (mouse.x < _sceneMinX || mouse.x > _sceneMaxX)
1092  setItemCursor = true;
1093  } else if (_mouseState == -4) {
1094  if (mouse.x > 8)
1095  setItemCursor = true;
1096  }
1097 
1098  if (setItemCursor) {
1100  return;
1101  }
1102  }
1103 
1104  if (_inventoryState) {
1105  if (mouse.y >= 144)
1106  return;
1107  hideInventory();
1108  }
1109 
1110  if (hasItemCollision && _mouseState < -1 && _itemInHand < 0) {
1113  _screen->setMouseCursor(0, 0, _gameShapes[0]);
1114  }
1115 
1116  int type = 0;
1117  if (mouse.y <= 199) {
1118  if (mouse.x <= 8) {
1119  if (_sceneExit4 != 0xFFFF) {
1120  type = -4;
1121  shape = 4;
1122  offsetX = 0;
1123  offsetY = 0;
1124  }
1125  } else if (mouse.x >= 311) {
1126  if (_sceneExit2 != 0xFFFF) {
1127  type = -6;
1128  shape = 2;
1129  offsetX = 13;
1130  offsetY = 8;
1131  }
1132  } else if (mouse.y >= 171) {
1133  if (_sceneExit3 != 0xFFFF) {
1134  if (mouse.x >= _sceneMinX && mouse.x <= _sceneMaxX) {
1135  type = -5;
1136  shape = 3;
1137  offsetX = 8;
1138  offsetY = 13;
1139  }
1140  }
1141  } else if (mouse.y <= 8) {
1142  if (_sceneExit1 != 0xFFFF) {
1143  type = -7;
1144  shape = 1;
1145  offsetX = 8;
1146  offsetY = 0;
1147  }
1148  }
1149  }
1150 
1151  for (int i = 0; i < _specialExitCount; ++i) {
1152  if (checkSpecialSceneExit(i, mouse.x, mouse.y)) {
1153  switch (_specialExitTable[20+i]) {
1154  case 0:
1155  type = -7;
1156  shape = 1;
1157  offsetX = 8;
1158  offsetY = 0;
1159  break;
1160 
1161  case 2:
1162  type = -6;
1163  shape = 2;
1164  offsetX = 13;
1165  offsetY = 8;
1166  break;
1167 
1168  case 4:
1169  type = -5;
1170  shape = 3;
1171  offsetX = 8;
1172  offsetY = 13;
1173  break;
1174 
1175  case 6:
1176  type = -4;
1177  shape = 4;
1178  offsetX = 0;
1179  offsetY = 8;
1180  break;
1181 
1182  default:
1183  break;
1184  }
1185  }
1186  }
1187 
1188  if (type != 0 && type != _mouseState && !hasItemCollision) {
1189  _mouseState = type;
1190  _screen->setMouseCursor(offsetX, offsetY, _gameShapes[shape]);
1191  } else if (type == 0 && _mouseState != _itemInHand && mouse.x > 8 && mouse.x < 311 && mouse.y < 171 && mouse.y > 8) {
1193  } else if (mouse.y > 187 && _mouseState > -4 && type == 0 && !_inventoryState) {
1194  showInventory();
1195  }
1196 }
1197 
1198 #pragma mark -
1199 
1201  if (_mainCharacter.x1 > _mouseX)
1202  _mainCharacter.facing = 5;
1203  else
1204  _mainCharacter.facing = 3;
1208 }
1209 
1210 #pragma mark -
1211 
1213  int layer = _screen->getLayer(x, y) - 1;
1214  layer = _sceneDatLayerTable[layer];
1215  return MAX(0, MIN(layer, 6));
1216 }
1217 
1218 int KyraEngine_MR::getScale(int x, int y) {
1219  return _scaleTable[_screen->getLayer(x, y) - 1];
1220 }
1221 
1222 #pragma mark -
1223 
1226 }
1227 
1230 }
1231 
1232 #pragma mark -
1233 
1234 int KyraEngine_MR::loadLanguageFile(const char *file, uint8 *&buffer) {
1235  delete[] buffer;
1236  buffer = 0;
1237 
1238  uint32 size = 0;
1239  Common::String nBuf = file;
1240  nBuf += _languageExtension[_lang];
1241  buffer = _res->fileData(nBuf.c_str(), &size);
1242 
1243  return buffer ? size : 0;
1244 }
1245 
1247  uint16 tableEntries = READ_LE_UINT16(buffer);
1248  const uint16 *indexTable = (const uint16 *)(buffer + 2);
1249  const uint16 *offsetTable = indexTable + tableEntries;
1250 
1251  int num = 0;
1252  while (id != READ_LE_UINT16(indexTable)) {
1253  ++indexTable;
1254  ++num;
1255  }
1256 
1257  return buffer + READ_LE_UINT16(offsetTable + num);
1258 }
1259 
1261  stream->seek(0, SEEK_SET);
1262  uint16 tableEntries = stream->readUint16LE();
1263 
1264  int num = 0;
1265  while (id != stream->readUint16LE())
1266  ++num;
1267 
1268  stream->seek(2+tableEntries*2+num*2, SEEK_SET);
1269  stream->seek(stream->readUint16LE(), SEEK_SET);
1270  char c = 0;
1271  while ((c = stream->readByte()) != 0)
1272  *dst++ = c;
1273  *dst = 0;
1274 }
1275 
1276 #pragma mark -
1277 
1279  for (int i = 0; i < 88; ++i) {
1280  if (_talkObjectList[i].sceneId == _mainCharacter.sceneId)
1281  return true;
1282  }
1283 
1284  return false;
1285 }
1286 
1287 #pragma mark -
1288 
1289 bool KyraEngine_MR::updateScore(int scoreId, int strId) {
1290  int scoreIndex = (scoreId >> 3);
1291  int scoreBit = scoreId & 7;
1292  if ((_scoreFlagTable[scoreIndex] & (1 << scoreBit)) != 0)
1293  return false;
1294 
1296  _scoreFlagTable[scoreIndex] |= (1 << scoreBit);
1297 
1298  strcpy(_stringBuffer, (const char *)getTableEntry(_scoreFile, strId));
1299  strcat(_stringBuffer, ": ");
1300 
1301  assert(scoreId < _scoreTableSize);
1302 
1303  int count = _scoreTable[scoreId];
1304  if (count > 0)
1305  scoreIncrease(count, _stringBuffer);
1306 
1308  return true;
1309 }
1310 
1311 void KyraEngine_MR::scoreIncrease(int count, const char *str) {
1312  int drawOld = 1;
1313  _screen->hideMouse();
1314 
1315  showMessage(str, 0xFF, 0xF0);
1316  const int x = getScoreX(str);
1317 
1318  for (int i = 0; i < count; ++i) {
1319  int oldScore = _score;
1320  int newScore = ++_score;
1321 
1322  if (newScore > _scoreMax) {
1323  _score = _scoreMax;
1324  break;
1325  }
1326 
1327  drawScoreCounting(oldScore, newScore, drawOld, x);
1328  if (_inventoryState)
1329  drawScore(0, 215, 191);
1330  _screen->updateScreen();
1331  delay(20, true);
1332 
1333  snd_playSoundEffect(0x0E, 0xC8);
1334  drawOld = 0;
1335  }
1336 
1337  _screen->showMouse();
1338 }
1339 
1340 #pragma mark -
1341 
1342 void KyraEngine_MR::changeChapter(int newChapter, int sceneId, int malcolmShapes, int facing) {
1343  resetItemList();
1344 
1345  _currentChapter = newChapter;
1346  runStartupScript(newChapter, 0);
1348 
1349  _malcolmsMood = 1;
1350  memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
1351 
1352  if (malcolmShapes >= 0)
1353  loadCharacterShapes(malcolmShapes);
1354 
1355  enterNewScene(sceneId, facing, 0, 0, 0);
1356 }
1357 
1358 #pragma mark -
1359 
1361  if (!_configSkip)
1362  return false;
1363  return KyraEngine_v2::skipFlag();
1364 }
1365 
1366 void KyraEngine_MR::resetSkipFlag(bool removeEvent) {
1367  if (!_configSkip) {
1368  if (removeEvent)
1369  _eventList.clear();
1370  return;
1371  }
1372  KyraEngine_v2::resetSkipFlag(removeEvent);
1373 }
1374 
1375 #pragma mark -
1376 
1379 
1380  // Most settings already have sensible defaults. This one, however, is
1381  // specific to the Kyra engine.
1382  ConfMan.registerDefault("walkspeed", 5);
1383  ConfMan.registerDefault("studio_audience", true);
1384  ConfMan.registerDefault("skip_support", true);
1385  ConfMan.registerDefault("helium_mode", false);
1386  // 0 - best, 1 - mid, 2 - low
1387  ConfMan.registerDefault("video_quality", 0);
1388 }
1389 
1391  switch (_lang) {
1392  case 1:
1394  break;
1395 
1396  case 2:
1398  break;
1399 
1400  case 0:
1401  default:
1403  }
1404 
1407 
1408  ConfMan.set("language", Common::getLanguageCode(_flags.lang));
1409 
1410  ConfMan.setBool("studio_audience", _configStudio);
1411  ConfMan.setBool("skip_support", _configSkip);
1412  ConfMan.setBool("helium_mode", _configHelium);
1413 
1415 }
1416 
1419 
1420  _configStudio = ConfMan.getBool("studio_audience");
1421  _configSkip = ConfMan.getBool("skip_support");
1422  _configHelium = ConfMan.getBool("helium_mode");
1423  _configVQAQuality = CLIP(ConfMan.getInt("video_quality"), 0, 2);
1424 }
1425 
1426 } // End of namespace Kyra
int _malcolmShapeXOffset
Definition: kyra_mr.h:323
bool snd_voiceIsPlaying()
Definition: kyra_mr.cpp:462
bool open(const char *filename)
Definition: vqa.cpp:604
void objectChatPrintText(const char *text, int object)
Definition: text_mr.cpp:278
virtual void setScreenPalette(const Palette &pal)
Definition: screen.cpp:918
bool _unkSceneScreenFlag1
Definition: kyra_v2.h:361
FontId setFont(FontId fontId)
Definition: screen.cpp:1395
void exit1(L9BYTE *d4, L9BYTE *d5p, L9BYTE d6, L9BYTE d7)
int _malcolmShapeYOffset
Definition: kyra_mr.h:323
Character _mainCharacter
Definition: kyra_v2.h:330
unsigned short uint16
Definition: cdtypes.h:27
void stopSound(int channel)
Stop the playback of a sound in the given channel.
uint32 _nextIdleAnim
Definition: kyra_mr.h:177
T ABS(T x)
Definition: util.h:48
uint16 readUint16LE()
Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it...
Definition: stream.h:333
uint8 * _gamePlayBuffer
Definition: kyra_mr.h:192
Simple string class for ScummVM.
Definition: str.h:49
uint8 * _paletteOverlay
Definition: kyra_mr.h:505
bool checkSpecialSceneExit(int num, int x, int y)
Definition: kyra_v2.cpp:166
static const ShapeDesc _shapeDescs[]
Definition: kyra_mr.h:329
AnimObj * _animList
Definition: kyra_v2.h:131
Common::Language replacedLang
Definition: kyra_v1.h:115
const char * _menuAudioFile
Definition: kyra_mr.h:114
unsigned int uint32
Definition: cdtypes.h:26
virtual void registerDefaultSettings()
Definition: kyra_v1.cpp:549
void playVoice(int high, int low)
Definition: kyra_mr.cpp:451
uint8 * _interface
Definition: kyra_mr.h:227
void handleInput(int x, int y)
Definition: kyra_mr.cpp:924
int count
Definition: voc.cpp:116
void makeCharFacingMouse()
Definition: kyra_mr.cpp:1200
EMCState _chatScriptState
Definition: kyra_v2.h:353
void init(StaticData data, Animation anim)
Definition: gui_v1.cpp:423
virtual bool loadFont(FontId fontId, const char *filename)
Definition: screen.cpp:1361
bool _goodConsciencePosition
Definition: kyra_mr.h:486
const uint8 * getCPagePtr(int pageNum) const
Definition: screen.cpp:572
Digital audio output device.
const uint8 * _scoreTable
Definition: kyra_mr.h:526
iterator end()
Definition: hashmap.h:263
Screen_MR * _screen
Definition: kyra_mr.h:82
uint8 _configWalkspeed
Definition: kyra_v1.h:299
#define assert(s)
Definition: portdefs.h:77
void drawScoreCounting(int oldScore, int newScore, int drawOld, const int x)
Definition: gui_mr.cpp:383
signed char int8
Definition: cdtypes.h:31
TextDisplayer * _text
Definition: kyra_v1.h:266
bool isMouseVisible() const
Definition: screen.cpp:3048
bool start(EMCState *script, int function)
Definition: script.cpp:155
void openTalkFile(int file)
Definition: kyra_mr.cpp:693
void warning(const char *s,...)
Definition: textconsole.cpp:49
void setWalkspeed(uint8)
Definition: timer_mr.cpp:82
iterator find(const Key &key)
Definition: hashmap.h:279
void loadGameStateCheck(int slot)
Definition: saveload.cpp:264
u16 flags
Definition: zipreader.h:215
void loadButtonShapes()
Definition: gui_mr.cpp:36
uint8 * _gfxBackUpRect
Definition: kyra_mr.h:517
Common::SeekableReadStream * _dlgBuffer
Definition: kyra_mr.h:446
bool _menuDirectlyToLoad
Definition: kyra_mr.h:98
SceneDesc * _sceneList
Definition: kyra_v2.h:174
int checkInput(Button *buttonList, bool mainLoop=false, int eventFlag=0x8000)
Definition: kyra_v1.cpp:239
uint8 * _actorFile
Definition: kyra_mr.h:273
virtual void setMouseCursor(int x, int y, const byte *shape)
Definition: screen.cpp:3059
int y
Definition: dialogs.cpp:409
FILE * file
Simple HashMap iterator implementation.
Definition: hashmap.h:164
unsigned char uint8
Definition: cdtypes.h:28
static CodeValue high
Definition: decode.cpp:56
#define ARRAYSIZE(x)
Macro which determines the number of entries in a fixed size array.
Definition: util.h:66
void clear()
Definition: list.h:193
Audio::Mixer * _mixer
Definition: engine.h:60
void copyPalette(const int dst, const int src)
Definition: screen.cpp:3112
void snd_playVoiceFile(int file)
Definition: kyra_mr.cpp:455
int open(const char *filename, int unk1, Palette *palette)
Definition: wsamovie.cpp:364
Palette & getPalette(int num)
Definition: screen.cpp:3107
uint16 _sceneExit1
Definition: kyra_v2.h:178
struct Kyra::KyraEngine_MR::Album _album
void copy(const Palette &source, int firstCol=0, int numCols=-1, int dstStart=-1)
Copy data from another palette.
Definition: screen.cpp:3914
bool _goodConscienceShown
Definition: kyra_mr.h:484
static const char *const _mainMenuSpanishFan[]
Definition: kyra_mr.h:188
void updateMalcolmShapes()
Definition: kyra_mr.cpp:765
KyraEngine_MR(OSystem *system, const GameFlags &flags)
Definition: kyra_mr.cpp:53
int16 _lastMusicCommand
Definition: kyra_v1.h:360
bool _overwriteSceneFacing
Definition: kyra_v2.h:185
uint8 * _optionsFile
Definition: kyra_mr.h:272
void initMainButtonList(bool disable)
Definition: staticres.cpp:1887
virtual void displayFrame(int frameNum, int pageNum, int x, int y, uint16 flags, const uint8 *table1, const uint8 *table2)
Definition: wsamovie.h:118
Callback buttonCallback
Definition: gui.h:89
EMCData _chatScriptData
Definition: kyra_v2.h:352
SceneAnim _sceneAnims[16]
Definition: kyra_v2.h:210
bool isValid(EMCState *script)
Definition: script.cpp:175
EMCInterpreter * _emc
Definition: kyra_v1.h:269
#define SEEK_SET
Definition: gba_nds_fat.h:76
virtual void loadBitmap(const char *filename, int tempPage, int dstPage, Palette *pal, bool skip=false)
Definition: screen.cpp:3233
Simple class for handling both 2D position and size.
Definition: rect.h:37
bool updateScore(int scoreId, int strId)
Definition: kyra_mr.cpp:1289
AnimObj * _animObjects
Definition: kyra_v2.h:124
Common::Array< const Opcode * > _opcodesDialog
Definition: kyra_mr.h:466
int8 * _itemBuffer1
Definition: kyra_mr.h:281
bool talkObjectsInCurScene()
Definition: kyra_mr.cpp:1278
Common::Error init()
Definition: kyra_mr.cpp:203
void playStudioSFX(const char *str)
Definition: kyra_mr.cpp:471
uint16 height
Definition: thumbnail.cpp:41
void drawScore(int page, int x, int y)
Definition: gui_mr.cpp:366
bool _badConscienceShown
Definition: kyra_mr.h:475
uint8 * _sceneStrings
Definition: kyra_mr.h:275
virtual Common::Error init()
Definition: kyra_v1.cpp:95
void setItemMouseCursor()
Definition: items_mr.cpp:94
Common::SeekableReadStream * _cnvFile
Definition: kyra_mr.h:445
int resetGameFlag(int flag)
Definition: kyra_v1.cpp:522
byte _newSceneDlgState[40]
Definition: kyra_mr.h:439
virtual void readSettings()
Definition: kyra_v1.cpp:562
int _movFacingTable[600]
Definition: kyra_v2.h:267
int getOppositeFacingDirection(int dir)
Definition: scene_v1.cpp:252
int inputSceneChange(int x, int y, int unk1, int unk2)
Definition: kyra_mr.cpp:996
static bool shouldQuit()
Return whether the ENGINE should quit respectively should return to the launcher. ...
Definition: engine.cpp:669
int _dialogScriptFuncEnd
Definition: kyra_mr.h:459
static void quitGame()
Request the engine to quit.
Definition: engine.cpp:662
int8 _characterAnimTable[2]
Definition: kyra_mr.h:387
void changeChapter(int newChapter, int sceneId, int malcolmShapes, int facing)
Definition: kyra_mr.cpp:1342
Resource * _res
Definition: kyra_v1.h:264
Button * _mainButtonList
Definition: kyra_mr.h:145
const char * getLanguageCode(Language id)
Definition: language.cpp:90
ShapeMap _gameShapes
Definition: kyra_v2.h:256
void updateCharAnimFrame(int *table)
Definition: kyra_mr.cpp:779
virtual bool seek(int32 offset, int whence=SEEK_SET)=0
Sets the stream position indicator for the stream.
int findWay(int curX, int curY, int dstX, int dstY, int *moveTable, int moveTableSize)
Definition: scene_v2.cpp:83
bool checkCharCollision(int x, int y)
Definition: kyra_mr.cpp:869
int playSound(const char *filename, uint8 priority, Audio::Mixer::SoundType type, int volume=255, bool loop=false, int channel=-1)
Plays a sound.
GameFlags _flags
Definition: kyra_v1.h:323
void updateScreen()
Definition: screen.cpp:324
void showInventory()
Definition: gui_mr.cpp:162
void close()
Definition: vqa.cpp:611
const char *const * _mainMenuStrings
Definition: kyra_mr.h:185
TimerManager * _timer
Definition: kyra_v1.h:268
OSystem * _system
Definition: engine.h:59
int _inventoryScrollSpeed
Definition: kyra_mr.h:245
int queryGameFlag(int flag) const
Definition: kyra_v1.cpp:517
virtual uint32 getMillis(bool skipRecord=false)=0
Get the number of milliseconds since the program was started.
const char * c_str() const
Definition: str.h:208
void updateSpecialSceneScripts()
Definition: scene_v2.cpp:39
void registerDefaultSettings()
Definition: kyra_mr.cpp:1377
bool exists(const char *file, bool errorOutOnFail=false)
Definition: resource.cpp:308
void snd_playWanderScoreViaMap(int track, int force)
Definition: kyra_mr.cpp:405
int getLayer(int x, int y)
Definition: screen_mr.cpp:35
void fill(int firstCol, int numCols, uint8 value)
Fill the given indexes with the given component value.
Definition: screen.cpp:3908
int getCharacterWalkspeed() const
Definition: kyra_mr.cpp:775
void loadShadowShape()
Definition: kyra_mr.cpp:624
int8 _sceneDatPalette[45]
Definition: kyra_mr.h:368
EMCState _dialogScriptState
Definition: kyra_mr.h:456
void hideMouse()
Definition: screen.cpp:3029
friend class GUI_MR
Definition: kyra_mr.h:45
int _curPage
Definition: screen.h:628
void showMessage(const char *string, uint8 c0, uint8 c1)
Definition: gui_mr.cpp:105
void resetSkipFlag(bool removeEvent=true)
Definition: kyra_mr.cpp:1366
uint32 type
Definition: mididrv.cpp:60
T MIN(T a, T b)
Definition: util.h:49
char name[4]
Definition: cdaudio.cpp:49
int optionsButton(Button *button)
Definition: gui_mr.cpp:1141
uint getRandomNumberRng(uint min, uint max)
Generates a random unsigned integer in the interval [min, max].
Definition: random.cpp:58
void refreshAnimObjects(int force)
void showMouse()
Definition: screen.cpp:3034
static const char *const _languageExtension[]
Definition: kyra_mr.h:662
uint16 _sceneExit4
Definition: kyra_v2.h:178
void runStartupScript(int script, int unk1)
Definition: kyra_mr.cpp:673
void clear(bool shrinkArray=0)
Definition: hashmap.h:396
int _dialogScriptFuncStart
Definition: kyra_mr.h:459
Common::Language lang
Definition: kyra_v1.h:111
void playMenuAudioFile()
Definition: kyra_mr.cpp:398
virtual void delayUntil(uint32 timestamp, bool updateGameTimers=false, bool update=false, bool isMainLoop=false)
Definition: kyra_v1.cpp:528
void updateCommandLine()
Definition: gui_mr.cpp:143
void initItemList(int size)
Definition: items_v2.cpp:28
int _fadeOutMusicChannel
Definition: kyra_mr.h:113
bool saveFileLoadable(int slot)
Definition: saveload.cpp:242
uint8 * _scoreFile
Definition: kyra_mr.h:268
Common::Array< const Opcode * > _opcodes
Definition: kyra_v1.h:327
virtual bool skipFlag() const
Definition: kyra_v1.cpp:490
friend class TextDisplayer_MR
Definition: kyra_mr.h:44
Constant for invalid item.
Definition: item.h:36
friend class Debugger_v2
Definition: kyra_v2.h:55
uint8 * _scenesFile
Definition: kyra_mr.h:270
static const int _shapeDescsSize
Definition: kyra_mr.h:330
unsigned int uint
Definition: scummsys.h:440
int getScale(int x, int y)
Definition: kyra_mr.cpp:1218
void backUpGfxRect32x32(int x, int y)
Definition: kyra_mr.cpp:1224
uint8 * _sceneShapes[20]
Definition: kyra_mr.h:333
Common::String filename
Definition: action.cpp:479
No error occurred.
Definition: error.h:45
void scoreIncrease(int count, const char *str)
Definition: kyra_mr.cpp:1311
int8 _sceneDatLayerTable[15]
Definition: kyra_mr.h:369
virtual bool loadPalette(const char *filename, Palette &pal)
Definition: screen.cpp:3282
Button * _mainButtonData
Definition: kyra_mr.h:144
InventoryItem item
Definition: action.cpp:650
bool dropItem(int unk1, Item item, int x, int y, int unk2)
Definition: items_mr.cpp:102
int getDrawLayer(int x, int y)
Definition: kyra_mr.cpp:1212
Common::Error saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumbnail)
Definition: saveload_mr.cpp:33
An Error instance pairs an error code with string description providing more details about the error...
Definition: error.h:77
virtual void writeSettings()
Definition: kyra_v1.cpp:592
void playVQA(const char *name)
Definition: kyra_mr.cpp:364
void stopAllSounds()
Stops playback of all sounds.
void unloadPakFile(Common::String filename, bool remFromCache=false)
Definition: resource.cpp:257
void enterNewScene(uint16 scene, int facing, int unk1, int unk2, int unk3)
Definition: scene_mr.cpp:32
char * _stringBuffer
Definition: kyra_mr.h:521
SoundDigital_MR * _soundDigital
Definition: kyra_mr.h:83
Common::Point getMousePos()
Definition: kyra_v1.cpp:220
uint16 width
Definition: thumbnail.cpp:41
const uint8 * _sfxFileMap
Definition: kyra_mr.h:126
int loadLanguageFile(const char *file, uint8 *&buffer)
Definition: kyra_mr.cpp:1234
This is the namespace of the Kyra engine.
Definition: chargen.cpp:37
int handle(int dim)
Definition: gui_v1.cpp:476
An arbitrary graphics surface, which can be the target (or source) of blit operations, font rendering, etc.
Definition: surface.h:42
void loadCharacterShapes(int newShapes)
Definition: kyra_mr.cpp:720
MainMenu * _menu
Definition: kyra_mr.h:164
static const struct @120 priority[]
void delay(uint32 time, bool update=false, bool isMainLoop=false)
Definition: kyra_v2.cpp:149
void hideInventory()
Definition: gui_mr.cpp:240
void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest)
Definition: screen.cpp:1067
uint8 * fileData(const char *file, uint32 *size)
Definition: resource.cpp:293
bool pickUpItem(int x, int y, int runScript)
Definition: items_mr.cpp:342
A class that manages KYRA palettes.
Definition: screen.h:329
const char *const * _sfxFileList
Definition: kyra_mr.h:128
void addShapeToPool(const uint8 *data, int realIndex, int shape)
Definition: kyra_v2.cpp:173
WSAMovie_v2 * _invWsa
Definition: kyra_mr.h:264
int _dialogScriptFuncProc
Definition: kyra_mr.h:459
void beginFadeOut(int channel, int ticks)
Makes the sound in a given channel fading out.
Common::List< Event > _eventList
Definition: kyra_v1.h:290
virtual void resetSkipFlag(bool removeEvent=true)
Definition: kyra_v1.cpp:498
#define system
Definition: sdl-sys.h:224
#define size
Definition: cdaudio.cpp:50
Interface for ScummVM backends.
Definition: system.h:113
uint8 * makeShapeCopy(const uint8 *src, int index)
Definition: screen_v2.cpp:235
void loadInterfaceShapes()
Definition: kyra_mr.cpp:637
uint16 _sceneExit3
Definition: kyra_v2.h:178
TextDisplayer_MR * _text
Definition: kyra_mr.h:657
int8 * _itemBuffer2
Definition: kyra_mr.h:282
uint16 _tickLength
Definition: kyra_v1.h:311
WSAMovie_v2 * _sceneAnimMovie[16]
Definition: kyra_v2.h:211
Common::Error go()
Definition: kyra_mr.cpp:235
uint8 * _interfaceCommandLine
Definition: kyra_mr.h:228
void refreshAnimObjectsIfNeed()
static const uint8 _characterFrameTable[]
Definition: kyra_mr.h:388
void setNextIdleAnimTimer()
Definition: timer_mr.cpp:97
bool run(EMCState *script)
Definition: script.cpp:181
bool _mainButtonListInitialized
Definition: kyra_mr.h:146
ActiveItemAnim _activeItemAnim[10]
Definition: kyra_mr.h:223
#define ConfMan
Shortcut for accessing the configuration manager.
void NORETURN_PRE error(const char *s,...)
Definition: textconsole.cpp:67
const char *const * _soundList
Definition: kyra_mr.h:116
EMCData _dialogScriptData
Definition: kyra_mr.h:455
void fadeOutMusic(int ticks)
Definition: kyra_mr.cpp:433
void initMouseShapes()
Definition: kyra_mr.cpp:499
bool load(const char *filename, EMCData *data, const Common::Array< const Opcode *> *opcodes)
Definition: script.cpp:98
void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc=0)
Definition: screen.cpp:785
u8 col
Definition: main.cpp:94
uint16 _sceneExit2
Definition: kyra_v2.h:178
int checkItemCollision(int x, int y)
Definition: items_mr.cpp:49
bool skipFlag() const
Definition: kyra_mr.cpp:1360
void play()
Definition: vqa.cpp:617
static const char *const _mainMenuItalianFan[]
Definition: kyra_mr.h:189
void unload(EMCData *data)
Definition: script.cpp:135
void setAnimBlockPtr(int size)
Definition: screen.cpp:1331
int runSceneScript1(int x, int y)
Definition: scene_mr.cpp:701
void initStaticData()
Definition: staticres.cpp:1926
uint16 _specialExitTable[25]
Definition: kyra_v2.h:182
void loadExtrasShapes()
Definition: kyra_mr.cpp:629
virtual void setResolution()
Definition: screen.cpp:258
Common::Language fanLang
Definition: kyra_v1.h:114
uint8 * getTableEntry(uint8 *buffer, int id)
Definition: kyra_mr.cpp:1246
void restoreGfxRect32x32(int x, int y)
Definition: kyra_mr.cpp:1228
uint8 * _itemFile
Definition: kyra_mr.h:271
int trySceneChange(int *moveTable, int unk1, int unk2)
Definition: scene_mr.cpp:591
SceneShapeDesc _sceneShapeDescs[20]
Definition: kyra_mr.h:377
const char * _chatText
Definition: kyra_v2.h:346
T CLIP(T v, T amin, T amax)
Definition: util.h:51
uint8 * _screenBuffer
Definition: kyra_v2.h:162
iterator begin()
Definition: hashmap.h:255
T MAX(T a, T b)
Definition: util.h:50
static String format(const char *fmt,...) GCC_PRINTF(1
Print formatted data into a String object.
Definition: str.cpp:634
bool _unkHandleSceneChangeFlag
Definition: kyra_v2.h:362
bool isPlaying(int channel)
Checks if a given channel is playing a sound.
uint8 * _costPalBuffer
Definition: kyra_mr.h:504
void clearPage(int pageNum)
Definition: screen.cpp:584
int8 _scoreFlagTable[26]
Definition: kyra_mr.h:529
Interface for a seekable & readable data stream.
Definition: stream.h:561
int getScoreX(const char *str)
Definition: gui_mr.cpp:417
static const EngineDesc _mrEngineDesc
Definition: kyra_mr.h:67
Debugger * _debugger
Definition: kyra_v1.h:270
int8 _conversationState[30][30]
Definition: kyra_mr.h:440
void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src)
Definition: screen.cpp:1104
int getRectSize(int w, int h)
Definition: screen_v2.cpp:270
byte readByte()
Read an unsigned byte from the stream and return it.
Definition: stream.h:310
virtual void initialize()
Definition: debugger.cpp:40
bool loadPakFile(Common::String filename)
Definition: resource.cpp:165
uint8 * _cCodeFile
Definition: kyra_mr.h:269
int16 y
The vertical part of the point.
Definition: rect.h:39
void setScreenDim(int dim)
Definition: screen.cpp:533
u8 state
Definition: ps2kbd.h:101
int16 x
The horizontal part of the point.
Definition: rect.h:38
int _scaleTable[15]
Definition: kyra_mr.h:382
Common::RandomSource _rnd
Definition: kyra_v1.h:205
WSAMovie_v2 * _menuAnim
Definition: kyra_mr.h:165
static CodeValue low
Definition: decode.cpp:56
void updateCharacterAnim(int charId)
const char * strings[5]
Definition: gui_v1.h:161
void init(EMCState *scriptState, const EMCData *data)
Definition: script.cpp:147
bool loadFileToBuf(const char *file, void *buf, uint32 maxSize)
Definition: resource.cpp:326
virtual void delayMillis(uint msecs)=0
Delay/sleep for the specified amount of milliseconds.
void updateCharPal(int unk1)
Definition: kyra_mr.cpp:834
void snd_playSoundEffect(int item, int volume)
Definition: kyra_mr.cpp:441
int16 regs[30]
Definition: script.h:58
void allocAnimObjects(int actors, int anims, int items)
Definition: animator_v2.cpp:28
uint8 * generateOverlay(const Palette &pal, uint8 *buffer, int color, uint weight, int maxColor=-1)
Definition: screen_v2.cpp:39
TalkObject * _talkObjectList
Definition: kyra_mr.h:412