ScummVM
sequences_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/resource/resource.h"
25 
26 namespace Kyra {
27 
30  return;
31 
32  _badConscienceShown = true;
34  if (_currentChapter == 2)
36  else if (_currentChapter == 3)
38  else if (_currentChapter == 4 && _rnd.getRandomNumberRng(1, 100) <= 25)
40  else if (_currentChapter == 5 && _rnd.getRandomNumberRng(1, 100) <= 25)
42 
43  if (_characterShapeFile == 9)
45 
47 
50 
51  int anim = _badConscienceAnim + (_badConsciencePosition ? 0 : 8);
52  TalkObject &talkObject = _talkObjectList[1];
53 
55  talkObject.x = 290;
56  else
57  talkObject.x = 30;
58  talkObject.y = 30;
59 
60  static const char *const animFilenames[] = {
61  "GUNFL00.WSA", "GUNFL01.WSA", "GUNFL02.WSA", "GUNFL03.WSA", "GUNFL04.WSA", "GUNFL05.WSA", "GUNFL06.WSA", "GUNFL07.WSA",
62  "GUNFR00.WSA", "GUNFR01.WSA", "GUNFR02.WSA", "GUNFR03.WSA", "GUNFR04.WSA", "GUNFR05.WSA", "GUNFR06.WSA", "GUNFR07.WSA"
63  };
64 
65  setupSceneAnimObject(0x0E, 9, 0, 187, -1, -1, -1, -1, 0, 0, 0, -1, animFilenames[anim]);
66  for (uint i = 0; i <= _badConscienceFrameTable[_badConscienceAnim]; ++i) {
67  if (i == 8)
68  snd_playSoundEffect(0x1B, 0xC8);
69  updateSceneAnim(0x0E, i);
70  delay(3*_tickLength, true);
71  }
72 
74  return;
75 
76  if (_mainCharacter.y1 == -1 || (_mainCharacter.x1 != -1 && _mainCharacter.animFrame == 87) || _mainCharacter.animFrame == 87) {
78  } else {
81  else
83  // _mainCharacter.facing can not be 0xFF here, so this is safe.
85  }
86 
89 }
90 
93  return;
94 
95  _badConscienceShown = false;
97  if (frame == 15)
98  snd_playSoundEffect(0x31, 0xC8);
99  updateSceneAnim(0x0E, frame);
100  delay(1*_tickLength, true);
101  }
102 
103  updateSceneAnim(0x0E, -1);
104  update();
105  removeSceneAnimObject(0x0E, 1);
107 }
108 
111  return;
112 
113  _goodConscienceShown = true;
115  _goodConscienceAnim %= 5;
116 
119 
122 
123  int anim = _goodConscienceAnim + (_goodConsciencePosition ? 0 : 5);
124  TalkObject &talkObject = _talkObjectList[87];
125 
127  talkObject.x = 290;
128  else
129  talkObject.x = 30;
130  talkObject.y = 30;
131 
132  static const char *const animFilenames[] = {
133  "STUFL00.WSA", "STUFL02.WSA", "STUFL04.WSA", "STUFL03.WSA", "STUFL01.WSA",
134  "STUFR00.WSA", "STUFR02.WSA", "STUFR04.WSA", "STUFR03.WSA", "STUFR01.WSA"
135  };
136 
137  setupSceneAnimObject(0x0F, 9, 0, 187, -1, -1, -1, -1, 0, 0, 0, -1, animFilenames[anim]);
138  for (uint i = 0; i <= _goodConscienceFrameTable[_goodConscienceAnim]; ++i) {
139  if (i == 10)
140  snd_playSoundEffect(0x7F, 0xC8);
141  updateSceneAnim(0x0F, i);
142  delay(2*_tickLength, true);
143  }
144 
146  return;
147 
148  if (_mainCharacter.y1 == -1 || (_mainCharacter.x1 != -1 && _mainCharacter.animFrame == 87) || _mainCharacter.animFrame == 87) {
150  } else {
153  else
156  }
157 
160 }
161 
164  return;
165 
166  _goodConscienceShown = false;
168  if (frame == 17)
169  snd_playSoundEffect(0x31, 0xC8);
170  updateSceneAnim(0x0F, frame);
171  delay(1*_tickLength, true);
172  }
173 
174  updateSceneAnim(0x0F, -1);
175  update();
176  removeSceneAnimObject(0x0F, 1);
178 }
179 
181  if (_chatText)
182  return;
183  _screen->hideMouse();
184 
185  if (_inventoryState)
186  hideInventory();
187  removeHandItem();
188 
189  objectChat((const char *)getTableEntry(_cCodeFile, 35), 0, 204, 35);
190  objectChat((const char *)getTableEntry(_cCodeFile, 40), 0, 204, 40);
191 
192  setGameFlag(0xD1);
193 
194  snd_playSoundEffect(0x2A, 0xC8);
195 
196  setGameFlag(0x171);
197 
198  switch (_characterShapeFile-1) {
199  case 0:
200  runAnimationScript("EELS01.EMC", 0, 0, 1, 1);
201  break;
202 
203  case 1:
204  runAnimationScript("EELS02.EMC", 0, 0, 1, 1);
205  break;
206 
207  case 2:
208  runAnimationScript("EELS03.EMC", 0, 0, 1, 1);
209  break;
210 
211  case 3:
212  runAnimationScript("EELS04.EMC", 0, 0, 1, 1);
213  break;
214 
215  default:
216  resetGameFlag(0x171);
217  runAnimationScript("EELS00.EMC", 0, 0, 1, 1);
218  }
219 
220  changeChapter(2, 29, 0, 4);
221  _screen->showMouse();
222 }
223 
225  const int lastEntry = MIN(_animShapeLastEntry, 41);
226  for (int i = 0; i < lastEntry; ++i)
227  _gameShapes[9+i] = _screen->getPtrToShape(filedata, i);
228  return lastEntry;
229 }
230 
232  for (int i = 0; i < count; ++i)
233  _gameShapes[9+i] = 0;
234  delete[] filedata;
236 }
237 
238 } // End of namespace Kyra
Kyra::KyraEngine_MR::_talkObjectList
TalkObject * _talkObjectList
Definition: kyra_mr.h:412
Kyra
This is the namespace of the Kyra engine.
Definition: chargen.cpp:37
Kyra::KyraEngine_MR::showGoodConscience
void showGoodConscience()
Definition: sequences_mr.cpp:109
Kyra::KyraEngine_MR::_goodConscienceShown
bool _goodConscienceShown
Definition: kyra_mr.h:484
MIN
T MIN(T a, T b)
Definition: util.h:49
Kyra::Screen::showMouse
void showMouse()
Definition: screen.cpp:2984
Kyra::KyraEngine_v2::Character::animFrame
uint16 animFrame
Definition: kyra_v2.h:322
Kyra::KyraEngine_MR::removeSceneAnimObject
void removeSceneAnimObject(int anim, int refresh)
Definition: animator_mr.cpp:394
kyra_mr.h
Kyra::KyraEngine_MR::TalkObject::x
int16 x
Definition: kyra_mr.h:407
Kyra::KyraEngine_MR::update
void update() override
Definition: kyra_mr.cpp:1046
Kyra::KyraEngine_v2::_mainCharacter
Character _mainCharacter
Definition: kyra_v2.h:330
Kyra::KyraEngine_MR::_cCodeFile
uint8 * _cCodeFile
Definition: kyra_mr.h:269
Kyra::KyraEngine_MR::objectChat
void objectChat(const char *text, int object, int vocHigh, int vocLow)
Definition: text_mr.cpp:193
Kyra::KyraEngine_v2::Character::x1
int16 x1
Definition: kyra_v2.h:325
Kyra::KyraEngine_v1::resetGameFlag
int resetGameFlag(int flag)
Definition: kyra_v1.cpp:527
Kyra::KyraEngine_MR::_goodConsciencePosition
bool _goodConsciencePosition
Definition: kyra_mr.h:486
Kyra::KyraEngine_MR::_screen
Screen_MR * _screen
Definition: kyra_mr.h:82
Kyra::KyraEngine_v2::runAnimationScript
void runAnimationScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload)
Definition: sequences_v2.cpp:30
Kyra::KyraEngine_MR::changeChapter
void changeChapter(int newChapter, int sceneId, int malcolmShapes, int facing)
Definition: kyra_mr.cpp:1342
Kyra::KyraEngine_v2::_gameShapes
ShapeMap _gameShapes
Definition: kyra_v2.h:256
uint8
unsigned char uint8
Definition: cdtypes.h:28
Kyra::KyraEngine_v2::delay
void delay(uint32 time, bool update=false, bool isMainLoop=false) override
Definition: kyra_v2.cpp:149
Kyra::KyraEngine_MR::hideGoodConscience
void hideGoodConscience()
Definition: sequences_mr.cpp:162
frame
ShapeFrame * frame
Definition: soft_render_surface.inl:184
Kyra::KyraEngine_MR::_badConscienceShown
bool _badConscienceShown
Definition: kyra_mr.h:475
Kyra::KyraEngine_MR::updateCharacterAnim
void updateCharacterAnim(int charId) override
Definition: animator_mr.cpp:233
Kyra::KyraEngine_MR::_characterFrameTable
static const uint8 _characterFrameTable[]
Definition: kyra_mr.h:388
Kyra::KyraEngine_MR::_badConscienceAnim
int _badConscienceAnim
Definition: kyra_mr.h:476
Kyra::KyraEngine_MR::setupSceneAnimObject
void setupSceneAnimObject(int anim, uint16 flags, int x, int y, int x2, int y2, int w, int h, int unk10, int specialSize, int unk14, int shape, const char *filename)
Definition: animator_mr.cpp:315
Kyra::KyraEngine_v2::_animShapeLastEntry
int _animShapeLastEntry
Definition: kyra_v2.h:238
Kyra::KyraEngine_v2::removeHandItem
void removeHandItem() override
Definition: items_v2.cpp:93
Kyra::KyraEngine_MR::updateSceneAnim
void updateSceneAnim(int anim, int newFrame) override
Definition: animator_mr.cpp:278
Kyra::KyraEngine_MR::hideInventory
void hideInventory()
Definition: gui_mr.cpp:240
uint
unsigned int uint
Definition: scummsys.h:440
Kyra::KyraEngine_v2::Character::facing
uint8 facing
Definition: kyra_v2.h:321
Kyra::KyraEngine_MR::snd_playSoundEffect
void snd_playSoundEffect(int item, int volume) override
Definition: kyra_mr.cpp:440
Kyra::KyraEngine_MR::hideBadConscience
void hideBadConscience()
Definition: sequences_mr.cpp:91
Kyra::KyraEngine_v2::Character::y1
int16 y1
Definition: kyra_v2.h:325
Kyra::KyraEngine_MR::_currentChapter
int _currentChapter
Definition: kyra_mr.h:508
Kyra::KyraEngine_MR::showBadConscience
void showBadConscience()
Definition: sequences_mr.cpp:28
Kyra::KyraEngine_v2::_chatText
const char * _chatText
Definition: kyra_v2.h:346
Kyra::KyraEngine_MR::setNextIdleAnimTimer
void setNextIdleAnimTimer()
Definition: timer_mr.cpp:97
Kyra::KyraEngine_v2::_characterShapeFile
int _characterShapeFile
Definition: kyra_v2.h:263
Kyra::KyraEngine_v1::_tickLength
uint16 _tickLength
Definition: kyra_v1.h:312
Kyra::KyraEngine_MR::_goodConscienceAnim
int _goodConscienceAnim
Definition: kyra_mr.h:485
Kyra::KyraEngine_v1::_rnd
Common::RandomSource _rnd
Definition: kyra_v1.h:205
Kyra::KyraEngine_v2::refreshAnimObjectsIfNeed
void refreshAnimObjectsIfNeed()
Definition: animator_v2.cpp:115
count
u32 count
Definition: disc_io.c:107
Kyra::KyraEngine_MR::eelScript
void eelScript()
Definition: sequences_mr.cpp:180
Kyra::KyraEngine_MR::TalkObject
Definition: kyra_mr.h:403
Kyra::KyraEngine_MR::_badConscienceFrameTable
static const uint8 _badConscienceFrameTable[]
Definition: kyra_mr.h:479
Kyra::KyraEngine_MR::_badConsciencePosition
bool _badConsciencePosition
Definition: kyra_mr.h:477
Kyra::Screen::hideMouse
void hideMouse()
Definition: screen.cpp:2979
resource.h
Kyra::KyraEngine_MR::uninitAnimationShapes
void uninitAnimationShapes(int count, uint8 *filedata) override
Definition: sequences_mr.cpp:231
Kyra::Screen_v2::getPtrToShape
uint8 * getPtrToShape(uint8 *shpFile, int shape)
Definition: screen_v2.cpp:204
Kyra::KyraEngine_MR::getTableEntry
uint8 * getTableEntry(uint8 *buffer, int id)
Definition: kyra_mr.cpp:1246
Kyra::KyraEngine_MR::_inventoryState
bool _inventoryState
Definition: kyra_mr.h:244
Kyra::KyraEngine_MR::_goodConscienceFrameTable
static const uint8 _goodConscienceFrameTable[]
Definition: kyra_mr.h:488
Kyra::KyraEngine_v1::setGameFlag
int setGameFlag(int flag)
Definition: kyra_v1.cpp:516
Kyra::KyraEngine_MR::initAnimationShapes
int initAnimationShapes(uint8 *filedata) override
Definition: sequences_mr.cpp:224
Common::RandomSource::getRandomNumberRng
uint getRandomNumberRng(uint min, uint max)
Generates a random unsigned integer in the interval [min, max].
Definition: random.cpp:58