2012-09-07 12:20:05 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hopkins/globals.h"
|
2013-02-15 21:20:24 +00:00
|
|
|
|
2012-09-08 11:43:33 +00:00
|
|
|
#include "hopkins/files.h"
|
2012-09-22 09:54:30 +00:00
|
|
|
#include "hopkins/font.h"
|
|
|
|
#include "hopkins/graphics.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
2012-09-07 12:20:05 +00:00
|
|
|
|
2013-02-15 21:20:24 +00:00
|
|
|
#include "common/textconsole.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
|
2012-09-07 12:20:05 +00:00
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-10-18 20:15:17 +00:00
|
|
|
// Global null pointer. This is needed by the engine to recognise NULL pointers, since
|
|
|
|
// there are places that differentiate between it and a 0 'error' value
|
2012-10-10 10:03:29 +00:00
|
|
|
byte *g_PTRNUL;
|
|
|
|
|
2012-10-18 20:15:17 +00:00
|
|
|
// Default data for the Hopkins array
|
|
|
|
|
|
|
|
const int HOPKINS_PERSO_0[] = {
|
2012-12-14 00:49:22 +00:00
|
|
|
0, -2, 0, -3, 0, -6, 0, -1, 0, -3, 0, -3, 0, -5, 0, -3, 0, -6, 0, -3, 0, -3, 0, -3,
|
|
|
|
9, -4, 8, -4, 6, -2, 9, -2, 9, -3, 9, -3, 9, -4, 9, -2, 9, -2, 8, -2, 9, -3, 9, -2,
|
|
|
|
13, 0, 13, 0, 13, 0, 13, 0, 14, 0, 13, 0, 13, 0, 12, 0, 12, 0, 14, 0, 13, 0, 14, 0,
|
|
|
|
10, 3, 9, 3, 10, 4, 8, 2, 7, 1, 10, 2, 9, 2, 7, 4, 7, 3, 8, 0, 9, 1, 9, 1, 0, 4, 0,
|
2012-10-18 20:15:17 +00:00
|
|
|
4, 0, 6, 0, 3, 0, 4, 0, 3, 0, 4, 0, 4, 0, 6, 0, 3, 0, 3, 0, 3
|
|
|
|
};
|
|
|
|
|
|
|
|
const int HOPKINS_PERSO_1[] = {
|
2012-12-14 00:49:22 +00:00
|
|
|
0, -2, 0, -2, 0, -5, 0, -1, 0, -2, 0, -2, 0, -4, 0, -2, 0, -5, 0, -2, 0, -2, 0, -2,
|
|
|
|
11, 0, 10, 0, 11, 0, 11, 0, 11, 0, 11, 0, 12, 0, 11, 0, 9, 0, 10, 0, 11, 0, 11, 0,
|
|
|
|
11, 0, 10, 0, 11, 0, 11, 0, 11, 0, 11, 0, 12, 0, 11, 0, 9, 0, 10, 0, 11, 0, 11, 0,
|
|
|
|
11, 0, 10, 0, 11, 0, 11, 0, 11, 0, 11, 0, 12, 0, 11, 0, 9, 0, 10, 0, 11, 0, 11, 0,
|
2012-10-18 20:15:17 +00:00
|
|
|
0, 3, 0, 3, 0, 5, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 5, 0, 3, 0, 3, 0, 3
|
|
|
|
};
|
|
|
|
|
|
|
|
const int HOPKINS_PERSO_2[] = {
|
2012-12-14 00:49:22 +00:00
|
|
|
0, -2, 0, 0, 0, -3, 0, -2, 0, -2, 0, -1, 0, -2, 0, -1, 0, -3, 0, -2, 0, -2, 0, -2,
|
|
|
|
8, 0, 9, 0, 5, 0, 9, 0, 7, 0, 7, 0, 7, 0, 7, 0, 6, 0, 7, 0, 6, 0, 9, 0, 8, 0, 9, 0,
|
|
|
|
5, 0, 9, 0, 7, 0, 7, 0, 7, 0, 7, 0, 6, 0, 7, 0, 6, 0, 9, 0, 8, 0, 9, 0, 5, 0, 9, 0,
|
|
|
|
7, 0, 7, 0, 7, 0, 7, 0, 6, 0, 7, 0, 6, 0, 9, 0, 0, 2, 0, 0, 0, 2, 0, 1, 0, 2, 0, 2,
|
2012-10-18 20:15:17 +00:00
|
|
|
0, 2, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2
|
|
|
|
};
|
|
|
|
|
2012-09-07 12:20:05 +00:00
|
|
|
Globals::Globals() {
|
2012-10-10 10:03:29 +00:00
|
|
|
// Set up the special g_PTRNUL variable
|
|
|
|
g_PTRNUL = (byte *)malloc(16);
|
|
|
|
strcpy((char *)g_PTRNUL, "POINTERNULL");
|
|
|
|
|
2013-02-15 07:24:10 +00:00
|
|
|
// Initialize array properties
|
2012-10-06 14:02:02 +00:00
|
|
|
for (int i = 0; i < 35; ++i)
|
2013-02-20 00:23:39 +00:00
|
|
|
Common::fill((byte *)&_animBqe[i], (byte *)&_animBqe[i] + sizeof(BqeAnimItem), 0);
|
2012-10-06 14:02:02 +00:00
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
Common::fill((byte *)&Bank[i], (byte *)&Bank[i] + sizeof(BankItem), 0);
|
|
|
|
for (int i = 0; i < 6; ++i)
|
|
|
|
Common::fill((byte *)&Liste[i], (byte *)&Liste[i] + sizeof(ListeItem), 0);
|
|
|
|
for (int i = 0; i < 35; ++i)
|
2013-01-21 06:50:12 +00:00
|
|
|
Common::fill((byte *)&Liste2[i], (byte *)&Liste2[i] + sizeof(ListeItem), 0);
|
2012-12-30 13:28:24 +00:00
|
|
|
for (int i = 0; i < 30; ++i) {
|
2012-12-29 13:20:34 +00:00
|
|
|
Common::fill((byte *)&_lockedAnims[i], (byte *)&_lockedAnims[i] + sizeof(LockAnimItem), 0);
|
2012-10-06 14:02:02 +00:00
|
|
|
Common::fill((byte *)&VBob[i], (byte *)&VBob[i] + sizeof(VBobItem), 0);
|
2012-12-30 13:28:24 +00:00
|
|
|
}
|
2012-10-06 14:02:02 +00:00
|
|
|
for (int i = 0; i < 300; ++i)
|
2013-02-22 09:36:54 +00:00
|
|
|
Common::fill((byte *)&_objectAuthIcons[i], (byte *)&_objectAuthIcons[i] + sizeof(ObjectAuthIcon), 0);
|
2012-10-06 14:02:02 +00:00
|
|
|
for (int i = 0; i < 25; ++i)
|
2013-02-22 08:10:45 +00:00
|
|
|
Common::fill((byte *)&_hidingItem[i], (byte *)&_hidingItem[i] + sizeof(HidingItem), 0);
|
2012-10-06 14:02:02 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 500; ++i)
|
2013-01-22 06:53:59 +00:00
|
|
|
_spriteSize[i] = 0;
|
2012-10-06 14:02:02 +00:00
|
|
|
for (int i = 0; i < 70; ++i)
|
2013-02-19 22:18:43 +00:00
|
|
|
Common::fill((byte *)&_hopkinsItem[i], (byte *)&_hopkinsItem[i] + sizeof(HopkinsItem), 0);
|
2012-10-06 14:02:02 +00:00
|
|
|
|
2012-10-22 21:57:16 +00:00
|
|
|
for (int i = 0; i < 36; ++i)
|
2012-12-16 13:22:24 +00:00
|
|
|
_inventory[i] = 0;
|
2012-10-22 21:57:16 +00:00
|
|
|
for (int i = 0; i < 51; ++i)
|
2013-01-01 23:57:00 +00:00
|
|
|
Common::fill((byte *)&_sortedDisplay[i], (byte *)&_sortedDisplay[i] + sizeof(SortItem), 0);
|
2012-10-22 21:57:16 +00:00
|
|
|
|
2013-01-14 07:04:38 +00:00
|
|
|
// Initialize fields
|
2012-12-24 10:36:53 +00:00
|
|
|
_language = LANG_EN;
|
2012-11-08 07:29:26 +00:00
|
|
|
|
2013-02-07 07:44:22 +00:00
|
|
|
_linuxEndDemoFl = false;
|
2012-12-17 07:01:29 +00:00
|
|
|
_speed = 1;
|
2013-01-29 07:35:14 +00:00
|
|
|
_oldFrameIndex = 0;
|
2013-02-16 17:48:55 +00:00
|
|
|
_oldDirection = DIR_NONE;
|
2013-01-14 07:04:38 +00:00
|
|
|
_oldDirectionSpriteIdx = 59;
|
2013-02-16 17:48:55 +00:00
|
|
|
_lastDirection = DIR_NONE;
|
2013-02-22 09:36:54 +00:00
|
|
|
_curObjectFileNum = 0;
|
2012-12-25 21:48:11 +00:00
|
|
|
_boxWidth = 0;
|
2012-12-19 07:00:22 +00:00
|
|
|
_objectWidth = _objectHeight = 0;
|
|
|
|
_catalogPos = 0;
|
|
|
|
_catalogSize = 0;
|
2012-09-15 00:27:15 +00:00
|
|
|
iRegul = 0;
|
2012-12-24 12:32:39 +00:00
|
|
|
_exitId = 0;
|
2012-09-17 06:53:21 +00:00
|
|
|
PERSO = 0;
|
2012-12-24 12:32:39 +00:00
|
|
|
_screenId = 0;
|
2013-01-01 12:53:07 +00:00
|
|
|
_prevScreenId = 0;
|
2013-01-27 13:32:05 +00:00
|
|
|
_characterMaxPosY = 0;
|
2012-12-30 17:51:47 +00:00
|
|
|
_menuScrollSpeed = 0;
|
|
|
|
_menuSpeed = 0;
|
|
|
|
_menuSoundOff = 0;
|
|
|
|
_menuVoiceOff = 0;
|
|
|
|
_menuMusicOff = 0;
|
|
|
|
_menuTextOff = 0;
|
|
|
|
_menuDisplayType = 0;
|
2013-01-01 23:57:00 +00:00
|
|
|
_sortedDisplayCount = 0;
|
2013-02-22 07:18:13 +00:00
|
|
|
_checkDistanceFl = false;
|
2013-02-19 20:12:57 +00:00
|
|
|
_characterType = 0;
|
2013-02-21 07:23:38 +00:00
|
|
|
_actionMoveTo = false;
|
2012-10-06 14:02:02 +00:00
|
|
|
Compteur = 0;
|
2013-02-18 00:19:41 +00:00
|
|
|
_actionDirection = DIR_NONE;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2013-02-19 20:12:57 +00:00
|
|
|
_creditsStartX = -1;
|
|
|
|
_creditsEndX = -1;
|
|
|
|
_creditsStartY = -1;
|
|
|
|
_creditsEndY = -1;
|
2013-01-29 07:35:14 +00:00
|
|
|
_creditsPosY = 0;
|
|
|
|
_creditsLineNumb = 0;
|
|
|
|
memset(_creditsItem, 0, 12000);
|
|
|
|
_creditsStep = 0;
|
2012-11-11 16:59:29 +00:00
|
|
|
|
2013-02-18 00:19:41 +00:00
|
|
|
_oceanDirection = DIR_NONE;
|
2012-11-11 20:37:04 +00:00
|
|
|
|
2013-01-27 21:28:10 +00:00
|
|
|
// Initialize pointers
|
2013-02-22 08:10:45 +00:00
|
|
|
for (int i = 0; i < 6; ++i)
|
|
|
|
_hidingItemData[i] = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
SPRITE_ECRAN = NULL;
|
2012-12-24 12:32:39 +00:00
|
|
|
_saveData = NULL;
|
2013-01-27 00:25:46 +00:00
|
|
|
_answerBuffer = g_PTRNUL;
|
2013-02-22 09:36:54 +00:00
|
|
|
_objectDataBuf = NULL;
|
2012-09-17 06:53:21 +00:00
|
|
|
PERSO = NULL;
|
2013-02-04 23:12:42 +00:00
|
|
|
_optionDialogSpr = NULL;
|
2012-09-19 11:34:23 +00:00
|
|
|
|
2012-09-08 11:43:33 +00:00
|
|
|
// Reset flags
|
2012-12-30 23:18:08 +00:00
|
|
|
_censorshipFl = false;
|
2012-12-10 22:57:59 +00:00
|
|
|
_disableInventFl = false;
|
2013-02-21 07:23:38 +00:00
|
|
|
_freezeCharacterFl = false;
|
2012-12-10 22:57:59 +00:00
|
|
|
_optionDialogFl = false;
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingActiveFl = false;
|
2013-01-23 00:38:34 +00:00
|
|
|
_introSpeechOffFl = false;
|
2013-01-29 07:35:14 +00:00
|
|
|
_baseMapColor = 50;
|
2012-10-06 14:02:02 +00:00
|
|
|
|
|
|
|
// Reset indexed variables
|
2013-01-23 07:10:36 +00:00
|
|
|
_hotspotTextColor = 0;
|
2013-01-29 07:35:14 +00:00
|
|
|
_oldRouteFromX = 0;
|
|
|
|
_oldRouteFromY = 0;
|
|
|
|
_oldRouteDestX = 0;
|
|
|
|
_oldRouteDestY = 0;
|
2013-01-23 07:10:36 +00:00
|
|
|
_oldMouseZoneId = 0;
|
2013-01-12 10:55:44 +00:00
|
|
|
_oldZoneNum = 0;
|
2013-01-23 07:10:36 +00:00
|
|
|
_oldMouseX = 0;
|
|
|
|
_oldMouseY = 0;
|
2012-10-06 14:02:02 +00:00
|
|
|
compteur_71 = 0;
|
2013-01-23 07:10:36 +00:00
|
|
|
_forceHideText = false;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Globals::~Globals() {
|
2013-01-02 15:04:15 +00:00
|
|
|
for (int idx = 0; idx < 6; ++idx)
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItemData[idx] = freeMemory(_hidingItemData[idx]);
|
2012-12-12 07:05:04 +00:00
|
|
|
freeMemory(SPRITE_ECRAN);
|
2012-12-24 12:32:39 +00:00
|
|
|
freeMemory((byte *)_saveData);
|
2013-01-27 00:25:46 +00:00
|
|
|
freeMemory(_answerBuffer);
|
2013-02-22 09:36:54 +00:00
|
|
|
freeMemory(_objectDataBuf);
|
2012-12-12 07:05:04 +00:00
|
|
|
freeMemory(PERSO);
|
2012-10-10 10:03:29 +00:00
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
clearVBob();
|
2012-12-08 11:44:00 +00:00
|
|
|
|
2012-10-10 10:03:29 +00:00
|
|
|
free(g_PTRNUL);
|
2012-09-08 00:08:12 +00:00
|
|
|
}
|
|
|
|
|
2012-09-22 09:54:30 +00:00
|
|
|
void Globals::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
2012-09-08 00:08:12 +00:00
|
|
|
void Globals::setConfig() {
|
2012-11-07 21:49:13 +00:00
|
|
|
// CHECKME: Should be in Globals() but it doesn't work
|
2012-12-09 09:05:26 +00:00
|
|
|
// The Polish version is a translation of the English version. The filenames are the same.
|
2012-11-07 21:49:13 +00:00
|
|
|
switch (_vm->getLanguage()) {
|
|
|
|
case Common::EN_ANY:
|
2012-12-09 09:05:26 +00:00
|
|
|
case Common::PL_POL:
|
2012-12-24 10:36:53 +00:00
|
|
|
_language = LANG_EN;
|
2012-11-07 21:49:13 +00:00
|
|
|
break;
|
|
|
|
case Common::FR_FRA:
|
2012-12-24 10:36:53 +00:00
|
|
|
_language = LANG_FR;
|
2012-11-07 21:49:13 +00:00
|
|
|
break;
|
|
|
|
case Common::ES_ESP:
|
2012-12-24 10:36:53 +00:00
|
|
|
_language = LANG_SP;
|
2012-11-07 21:49:13 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-12-09 09:05:26 +00:00
|
|
|
warning("Unknown language in internal language mapping");
|
2012-11-07 21:49:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-11-08 07:29:26 +00:00
|
|
|
// End of CHECKME
|
|
|
|
|
2012-12-24 10:36:53 +00:00
|
|
|
switch (_language) {
|
|
|
|
case LANG_EN:
|
2013-02-22 09:36:54 +00:00
|
|
|
_zoneFilename = "ZONEAN.TXT";
|
|
|
|
_textFilename = "TEXTEAN.TXT";
|
2012-09-08 00:08:12 +00:00
|
|
|
break;
|
2012-12-24 10:36:53 +00:00
|
|
|
case LANG_FR:
|
2013-02-22 09:36:54 +00:00
|
|
|
_zoneFilename = "ZONE01.TXT";
|
|
|
|
_textFilename = "TEXTE01.TXT";
|
2012-09-08 00:08:12 +00:00
|
|
|
break;
|
2012-12-24 10:36:53 +00:00
|
|
|
case LANG_SP:
|
2013-02-22 09:36:54 +00:00
|
|
|
_zoneFilename = "ZONEES.TXT";
|
|
|
|
_textFilename = "TEXTEES.TXT";
|
2012-09-08 00:08:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-09-07 12:20:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
void Globals::clearAll() {
|
|
|
|
for (int idx = 0; idx < 6; ++idx)
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItemData[idx] = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
initAnimBqe();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-12-25 21:48:11 +00:00
|
|
|
_boxWidth = 0;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-22 09:54:30 +00:00
|
|
|
_vm->_fontManager.clearAll();
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
initVBob();
|
2013-02-22 09:36:54 +00:00
|
|
|
_objectDataBuf = g_PTRNUL;
|
|
|
|
_curObjectFileNum = 0;
|
2013-03-19 19:40:55 +00:00
|
|
|
_vm->_eventsManager->_objectBuf = g_PTRNUL;
|
2013-03-19 07:26:36 +00:00
|
|
|
_vm->_dialogsManager->_inventWin1 = g_PTRNUL;
|
|
|
|
_vm->_dialogsManager->_inventBuf2 = g_PTRNUL;
|
2013-01-27 00:25:46 +00:00
|
|
|
_answerBuffer = g_PTRNUL;
|
2012-10-10 10:03:29 +00:00
|
|
|
SPRITE_ECRAN = g_PTRNUL;
|
2013-03-05 06:45:15 +00:00
|
|
|
_saveData = (Savegame *)g_PTRNUL;
|
2013-01-27 19:20:36 +00:00
|
|
|
_vm->_objectsManager._curObjectIndex = 0;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2013-01-27 21:28:10 +00:00
|
|
|
_vm->_linesManager.clearAll();
|
2013-02-07 21:30:40 +00:00
|
|
|
_vm->_objectsManager.clearAll();
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2013-03-05 06:45:15 +00:00
|
|
|
_saveData = (Savegame *)malloc(sizeof(Savegame));
|
|
|
|
memset(_saveData, 0, sizeof(Savegame));
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-12-25 21:48:11 +00:00
|
|
|
_boxWidth = 240;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2013-03-19 19:40:55 +00:00
|
|
|
_vm->_eventsManager->_objectBuf = allocMemory(2500);
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2013-02-22 09:36:54 +00:00
|
|
|
_objectDataBuf = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
2012-12-30 23:18:08 +00:00
|
|
|
void Globals::loadCharacterData() {
|
2013-02-19 20:12:57 +00:00
|
|
|
assert(_characterType >= 0 && _characterType <= 2);
|
2012-10-18 20:15:17 +00:00
|
|
|
|
|
|
|
const int *srcList[] = { HOPKINS_PERSO_0, HOPKINS_PERSO_1, HOPKINS_PERSO_2 };
|
2013-02-19 20:12:57 +00:00
|
|
|
const int *srcP = srcList[_characterType];
|
2012-10-18 20:15:17 +00:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 240 / 4; ++idx) {
|
2013-02-19 22:18:43 +00:00
|
|
|
_hopkinsItem[idx]._speedX = *srcP++;
|
|
|
|
_hopkinsItem[idx]._speedY = *srcP++;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 07:35:14 +00:00
|
|
|
_oldFrameIndex = -1;
|
2013-02-16 17:48:55 +00:00
|
|
|
_oldDirection = DIR_NONE;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::initAnimBqe() {
|
2012-09-08 08:45:22 +00:00
|
|
|
for (int idx = 0; idx < 35; ++idx) {
|
2013-02-20 00:23:39 +00:00
|
|
|
_animBqe[idx]._data = g_PTRNUL;
|
|
|
|
_animBqe[idx]._enabledFl = false;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 8; ++idx) {
|
2012-12-16 23:16:49 +00:00
|
|
|
Bank[idx]._data = g_PTRNUL;
|
2012-12-29 22:57:50 +00:00
|
|
|
Bank[idx]._loadedFl = false;
|
2012-12-16 23:16:49 +00:00
|
|
|
Bank[idx]._filename = "";
|
|
|
|
Bank[idx]._fileHeader = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::initVBob() {
|
2012-09-08 08:45:22 +00:00
|
|
|
for (int idx = 0; idx < 30; ++idx) {
|
2013-03-17 21:41:10 +00:00
|
|
|
VBob[idx]._displayMode = 0;
|
2012-12-16 23:16:49 +00:00
|
|
|
VBob[idx]._xp = 0;
|
|
|
|
VBob[idx]._yp = 0;
|
|
|
|
VBob[idx]._frameIndex = 0;
|
|
|
|
VBob[idx]._surface = g_PTRNUL;
|
2012-12-19 23:30:01 +00:00
|
|
|
VBob[idx]._spriteData = g_PTRNUL;
|
2012-12-16 23:16:49 +00:00
|
|
|
VBob[idx]._oldSpriteData = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::clearVBob() {
|
2012-09-28 23:33:42 +00:00
|
|
|
for (int idx = 0; idx < 30; ++idx) {
|
2013-03-17 21:41:10 +00:00
|
|
|
VBob[idx]._displayMode = 0;
|
2012-12-16 23:16:49 +00:00
|
|
|
VBob[idx]._xp = 0;
|
|
|
|
VBob[idx]._yp = 0;
|
|
|
|
VBob[idx]._frameIndex = 0;
|
|
|
|
VBob[idx]._surface = freeMemory(VBob[idx]._surface);
|
2012-12-19 23:30:01 +00:00
|
|
|
VBob[idx]._spriteData = g_PTRNUL;
|
2012-12-16 23:16:49 +00:00
|
|
|
VBob[idx]._oldSpriteData = g_PTRNUL;
|
2012-12-14 00:49:22 +00:00
|
|
|
}
|
2012-09-28 23:33:42 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Load Object
|
2012-12-24 00:43:37 +00:00
|
|
|
void Globals::loadObjects() {
|
2013-01-07 22:56:39 +00:00
|
|
|
byte *data = _vm->_fileManager.loadFile("OBJET.DAT");
|
2012-09-08 11:43:33 +00:00
|
|
|
byte *srcP = data;
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 300; ++idx) {
|
2013-02-22 11:18:20 +00:00
|
|
|
ObjectAuthIcon *objectAuthIcon = &_objectAuthIcons[idx];
|
|
|
|
objectAuthIcon->_objectFileNum = *srcP++;
|
|
|
|
objectAuthIcon->_idx = *srcP++;
|
|
|
|
objectAuthIcon->_flag1 = *srcP++;
|
|
|
|
objectAuthIcon->_flag2 = *srcP++;
|
|
|
|
objectAuthIcon->_flag3 = *srcP++;
|
|
|
|
objectAuthIcon->_flag4 = *srcP++;
|
|
|
|
objectAuthIcon->_flag5 = *srcP++;
|
|
|
|
objectAuthIcon->_flag6 = *srcP++;
|
2012-09-08 11:43:33 +00:00
|
|
|
}
|
|
|
|
|
2013-02-15 07:41:22 +00:00
|
|
|
freeMemory(data);
|
2012-09-08 11:43:33 +00:00
|
|
|
}
|
|
|
|
|
2012-12-12 07:05:04 +00:00
|
|
|
byte *Globals::allocMemory(int count) {
|
2012-09-08 13:43:35 +00:00
|
|
|
byte *result = (byte *)malloc(count);
|
|
|
|
if (!result)
|
2012-10-10 10:03:29 +00:00
|
|
|
result = g_PTRNUL;
|
2012-09-08 11:43:33 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-12 07:05:04 +00:00
|
|
|
byte *Globals::freeMemory(byte *p) {
|
2012-10-10 10:03:29 +00:00
|
|
|
if (p != g_PTRNUL)
|
|
|
|
free(p);
|
|
|
|
return g_PTRNUL;
|
2012-09-09 09:55:05 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
// Reset Hiding Items
|
|
|
|
void Globals::resetHidingItems() {
|
2012-09-28 12:15:59 +00:00
|
|
|
|
|
|
|
for (int idx = 1; idx <= 5; ++idx) {
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItemData[idx] = freeMemory(_hidingItemData[idx]);
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx <= 20; ++idx) {
|
2013-02-23 09:55:41 +00:00
|
|
|
HidingItem *hid = &_hidingItem[idx];
|
|
|
|
hid->_spriteData = g_PTRNUL;
|
|
|
|
hid->_x = 0;
|
|
|
|
hid->_y = 0;
|
|
|
|
hid->_spriteIndex = 0;
|
|
|
|
hid->_useCount = 0;
|
|
|
|
hid->_width = 0;
|
|
|
|
hid->_height = 0;
|
2013-03-17 21:06:03 +00:00
|
|
|
hid->_resetUseCount = false;
|
|
|
|
hid->_yOffset = 0;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingActiveFl = false;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::enableHiding() {
|
|
|
|
_hidingActiveFl = true;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
2012-10-20 16:59:06 +00:00
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::disableHiding() {
|
|
|
|
_hidingActiveFl = false;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 10:15:19 +00:00
|
|
|
void Globals::B_CACHE_OFF(int idx) {
|
|
|
|
assert(idx < 36);
|
2013-02-10 23:15:00 +00:00
|
|
|
_vm->_objectsManager._bob[idx].field34 = true;
|
2013-02-10 10:15:19 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::resetHidingUseCount(int idx) {
|
|
|
|
_hidingItem[idx]._useCount = 0;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
void Globals::setHidingUseCount(int idx) {
|
|
|
|
_hidingItem[idx]._useCount = 1;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
// Load Hiding Items
|
|
|
|
void Globals::loadHidingItems(const Common::String &file) {
|
|
|
|
resetHidingItems();
|
2013-02-11 07:04:20 +00:00
|
|
|
byte *ptr = _vm->_fileManager.loadFile(file);
|
|
|
|
Common::String filename = Common::String((const char *)ptr);
|
2012-09-28 12:15:59 +00:00
|
|
|
|
2013-02-11 07:04:20 +00:00
|
|
|
Common::File f;
|
|
|
|
if (!f.exists(filename))
|
2012-12-30 13:28:24 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-11 07:04:20 +00:00
|
|
|
byte *spriteData = _vm->_fileManager.loadFile(filename);
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItemData[1] = spriteData;
|
2013-02-11 07:04:20 +00:00
|
|
|
int curBufIdx = 60;
|
2012-12-30 13:28:24 +00:00
|
|
|
for (int i = 0; i <= 21; i++) {
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItem[i]._spriteIndex = READ_LE_INT16((uint16 *)ptr + curBufIdx);
|
|
|
|
_hidingItem[i]._x = READ_LE_INT16((uint16 *)ptr + curBufIdx + 1);
|
|
|
|
_hidingItem[i]._y = READ_LE_INT16((uint16 *)ptr + curBufIdx + 2);
|
2013-03-17 21:06:03 +00:00
|
|
|
_hidingItem[i]._yOffset = READ_LE_INT16((uint16 *)ptr + curBufIdx + 4);
|
2012-12-30 13:28:24 +00:00
|
|
|
if (spriteData == g_PTRNUL) {
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItem[i]._useCount = 0;
|
2012-12-30 13:28:24 +00:00
|
|
|
} else {
|
2013-02-22 08:10:45 +00:00
|
|
|
_hidingItem[i]._spriteData = spriteData;
|
|
|
|
_hidingItem[i]._width = _vm->_objectsManager.getWidth(spriteData, _hidingItem[i]._spriteIndex);
|
|
|
|
_hidingItem[i]._height = _vm->_objectsManager.getHeight(spriteData, _hidingItem[i]._spriteIndex);
|
|
|
|
_hidingItem[i]._useCount = 1;
|
2012-11-23 21:21:35 +00:00
|
|
|
}
|
2012-12-30 13:28:24 +00:00
|
|
|
|
2013-02-22 08:10:45 +00:00
|
|
|
if ( !_hidingItem[i]._x && !_hidingItem[i]._y && !_hidingItem[i]._spriteIndex)
|
|
|
|
_hidingItem[i]._useCount = 0;
|
2013-02-11 07:04:20 +00:00
|
|
|
curBufIdx += 5;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
2013-02-22 08:10:45 +00:00
|
|
|
enableHiding();
|
2013-02-11 07:04:20 +00:00
|
|
|
freeMemory(ptr);
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 12:20:05 +00:00
|
|
|
} // End of namespace Hopkins
|