18
18
* along with this program; if not, write to the Free Software
19
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-2-1/engines/kyra/kyra_hof.cpp $
22
* $Id: kyra_hof.cpp 51757 2010-08-05 14:41:00Z lordhoto $
26
#include "kyra/kyra_v1.h"
27
26
#include "kyra/kyra_hof.h"
28
#include "kyra/screen.h"
29
27
#include "kyra/resource.h"
30
#include "kyra/wsamovie.h"
31
#include "kyra/sound.h"
32
#include "kyra/script.h"
33
#include "kyra/script_tim.h"
34
28
#include "kyra/text_hof.h"
35
29
#include "kyra/timer.h"
36
30
#include "kyra/debugger.h"
37
31
#include "kyra/util.h"
32
#include "kyra/sound.h"
39
34
#include "common/system.h"
40
35
#include "common/config-manager.h"
146
143
_chatIsNote = false;
147
144
memset(&_npcScriptData, 0, sizeof(_npcScriptData));
146
_setCharPalFinal = false;
149
memset(_characterFacingCountTable, 0, sizeof(_characterFacingCountTable));
150
152
KyraEngine_HoF::~KyraEngine_HoF() {
441
443
if (_gameToLoad == -1) {
442
444
snd_playWanderScoreViaMap(52, 1);
443
445
enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
444
saveGameState(0, "New Game", 0);
446
saveGameStateIntern(0, "New Game", 0);
446
448
loadGameStateCheck(_gameToLoad);
504
506
int inputFlag = checkInput(_buttonList, true);
505
507
removeInputTop();
509
if (_updateHandItemCursor) {
510
// This works around an issue which would occur when setHandItem(_itemInHand)
511
// was called from inside loadGameState(). When loading via GMM the
512
// mouse cursor would not be set correctly.
513
_updateHandItemCursor = false;
514
setHandItem(_itemInHand);
509
519
if (inputFlag == 198 || inputFlag == 199) {
520
_savedMouseState = _mouseState;
511
521
handleInput(_mouseX, _mouseY);
790
800
if ((mouse.y > 145) || (mouse.x > 6 && mouse.x < 312 && mouse.y > 6 && mouse.y < 135)) {
791
801
_mouseState = _itemInHand;
792
802
_screen->hideMouse();
793
if (_itemInHand == -1)
803
if (_itemInHand == kItemNone)
794
804
_screen->setMouseCursor(0, 0, getShapePtr(0));
796
806
_screen->setMouseCursor(8, 15, getShapePtr(_itemInHand+64));
1146
1154
_screen->setScreenPalette(_screen->getPalette(0));
1155
_setCharPalFinal = true;
1148
1156
_charPalEntry = palEntry;
1149
} else if (unkVar1 || !unk1) {
1157
} else if (_setCharPalFinal || !unk1) {
1150
1158
_screen->getPalette(0).copy(_scenePal, palEntry << 4, 16, 112);
1151
1159
_screen->setScreenPalette(_screen->getPalette(0));
1160
_setCharPalFinal = false;
1169
1177
_pathfinderFlag = 15;
1171
1179
if (!_unkHandleSceneChangeFlag) {
1180
if (_savedMouseState == -3) {
1173
1181
if (_sceneList[curScene].exit4 != 0xFFFF) {
1175
1183
y = _sceneEnterY4;
1176
1184
_pathfinderFlag = 7;
1178
} else if (_unk3 == -5) {
1186
} else if (_savedMouseState == -5) {
1179
1187
if (_sceneList[curScene].exit2 != 0xFFFF) {
1181
1189
y = _sceneEnterY2;
1182
1190
_pathfinderFlag = 7;
1184
} else if (_unk3 == -6) {
1192
} else if (_savedMouseState == -6) {
1185
1193
if (_sceneList[curScene].exit1 != 0xFFFF) {
1186
1194
x = _sceneEnterX1;
1187
1195
y = _sceneEnterY1 - 2;
1188
1196
_pathfinderFlag = 14;
1190
} else if (_unk3 == -4) {
1198
} else if (_savedMouseState == -4) {
1191
1199
if (_sceneList[curScene].exit3 != 0xFFFF) {
1192
1200
x = _sceneEnterX3;
1200
1208
int vocH = _flags.isTalkie ? 131 : -1;
1202
1210
if (_pathfinderFlag) {
1203
if (findItem(curScene, 13) >= 0 && _unk3 <= -3) {
1211
if (findItem(curScene, 13) >= 0 && _savedMouseState <= -3) {
1205
1213
} else if (_itemInHand == 72) {
1207
} else if (findItem(curScene, 72) >= 0 && _unk3 <= -3) {
1215
} else if (findItem(curScene, 72) >= 0 && _savedMouseState <= -3) {
1209
} else if (getInventoryItemSlot(72) != -1 && _unk3 <= -3) {
1217
} else if (getInventoryItemSlot(72) != -1 && _savedMouseState <= -3) {
1266
1274
return _timer->getDelay(0);
1269
void KyraEngine_HoF::updateCharAnimFrame(int charId, int *table) {
1270
static int unkTable1[] = { 0, 0 };
1271
static const int unkTable2[] = { 17, 0 };
1272
static const int unkTable3[] = { 10, 0 };
1273
static const int unkTable4[] = { 24, 0 };
1274
static const int unkTable5[] = { 19, 0 };
1275
static const int unkTable6[] = { 21, 0 };
1276
static const int unkTable7[] = { 31, 0 };
1277
static const int unkTable8[] = { 26, 0 };
1277
void KyraEngine_HoF::updateCharAnimFrame(int *table) {
1278
static const int unkFrame1 = 17;
1279
static const int unkFrame2 = 10;
1280
static const int unkFrame3 = 24;
1281
static const int unkFrame4 = 19;
1282
static const int unkFrame5 = 21;
1283
static const int unkFrame6 = 31;
1284
static const int unkFrame7 = 26;
1279
1286
Character *character = &_mainCharacter;
1280
1287
++character->animFrame;
1292
++unkTable1[charId];
1299
++_characterFacingCountTable[0];
1293
1300
} else if (facing == 4) {
1294
++unkTable1[charId+1];
1301
++_characterFacingCountTable[1];
1295
1302
} else if (facing == 7 || facing == 1 || facing == 5 || facing == 3) {
1296
1303
if (facing == 7 || facing == 1) {
1297
if (unkTable1[charId] > 2)
1304
if (_characterFacingCountTable[0] > 2)
1300
if (unkTable1[charId+1] > 2)
1307
if (_characterFacingCountTable[1] > 2)
1304
unkTable1[charId] = 0;
1305
unkTable1[charId+1] = 0;
1311
_characterFacingCountTable[0] = 0;
1312
_characterFacingCountTable[1] = 0;
1308
1315
if (facing == 0) {
1309
if (character->animFrame < unkTable8[charId])
1310
character->animFrame = unkTable8[charId];
1316
if (character->animFrame < unkFrame7)
1317
character->animFrame = unkFrame7;
1312
if (character->animFrame > unkTable7[charId])
1313
character->animFrame = unkTable8[charId];
1319
if (character->animFrame > unkFrame6)
1320
character->animFrame = unkFrame7;
1314
1321
} else if (facing == 4) {
1315
if (character->animFrame < unkTable5[charId])
1316
character->animFrame = unkTable5[charId];
1322
if (character->animFrame < unkFrame4)
1323
character->animFrame = unkFrame4;
1318
if (character->animFrame > unkTable4[charId])
1319
character->animFrame = unkTable5[charId];
1325
if (character->animFrame > unkFrame3)
1326
character->animFrame = unkFrame4;
1321
if (character->animFrame > unkTable5[charId])
1322
character->animFrame = unkTable6[charId];
1324
if (character->animFrame == unkTable2[charId])
1325
character->animFrame = unkTable3[charId];
1327
if (character->animFrame > unkTable2[charId])
1328
character->animFrame = unkTable3[charId] + 2;
1328
if (character->animFrame > unkFrame4)
1329
character->animFrame = unkFrame5;
1331
if (character->animFrame == unkFrame1)
1332
character->animFrame = unkFrame2;
1334
if (character->animFrame > unkFrame1)
1335
character->animFrame = unkFrame2 + 2;
1331
updateCharacterAnim(charId);
1338
updateCharacterAnim(0);
1334
1341
bool KyraEngine_HoF::checkCharCollision(int x, int y) {
1385
1392
if (queryGameFlag(0x159) && _flags.isTalkie)
1388
static bool scriptAnimation = false;
1389
if (!scriptAnimation && _flags.isTalkie) {
1390
scriptAnimation = true;
1395
if (!_useSceneIdleAnim && _flags.isTalkie) {
1396
_useSceneIdleAnim = true;
1391
1397
randomSceneChat();
1393
scriptAnimation = false;
1399
_useSceneIdleAnim = false;
1394
1400
if (_characterShapeFile > 8)