2012-09-07 22:20:05 +10: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 22:20:24 +01:00
|
|
|
|
2012-09-08 21:43:33 +10:00
|
|
|
#include "hopkins/files.h"
|
2012-09-22 19:54:30 +10:00
|
|
|
#include "hopkins/font.h"
|
|
|
|
#include "hopkins/graphics.h"
|
|
|
|
#include "hopkins/hopkins.h"
|
2012-09-07 22:20:05 +10:00
|
|
|
|
2013-02-15 22:20:24 +01:00
|
|
|
#include "common/textconsole.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-10-19 07:15:17 +11:00
|
|
|
// Default data for the Hopkins array
|
|
|
|
|
|
|
|
const int HOPKINS_PERSO_0[] = {
|
2012-12-14 01:49:22 +01: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-19 07:15:17 +11: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 01:49:22 +01: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-19 07:15:17 +11: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 01:49:22 +01: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-19 07:15:17 +11:00
|
|
|
0, 2, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2
|
|
|
|
};
|
|
|
|
|
2013-03-20 07:27:42 +01:00
|
|
|
Globals::Globals(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
|
2013-02-15 08:24:10 +01:00
|
|
|
// Initialize array properties
|
2012-10-07 00:02:02 +10:00
|
|
|
for (int i = 0; i < 500; ++i)
|
2013-01-22 07:53:59 +01:00
|
|
|
_spriteSize[i] = 0;
|
2012-10-07 00:02:02 +10:00
|
|
|
for (int i = 0; i < 70; ++i)
|
2013-02-19 23:18:43 +01:00
|
|
|
Common::fill((byte *)&_hopkinsItem[i], (byte *)&_hopkinsItem[i] + sizeof(HopkinsItem), 0);
|
2012-10-07 00:02:02 +10:00
|
|
|
|
2012-10-23 08:57:16 +11:00
|
|
|
for (int i = 0; i < 36; ++i)
|
2012-12-16 14:22:24 +01:00
|
|
|
_inventory[i] = 0;
|
2012-10-23 08:57:16 +11:00
|
|
|
|
2013-01-14 08:04:38 +01:00
|
|
|
// Initialize fields
|
2012-12-24 11:36:53 +01:00
|
|
|
_language = LANG_EN;
|
2012-11-08 08:29:26 +01:00
|
|
|
|
2013-02-07 08:44:22 +01:00
|
|
|
_linuxEndDemoFl = false;
|
2012-12-17 08:01:29 +01:00
|
|
|
_speed = 1;
|
2013-03-31 10:47:46 -04:00
|
|
|
_eventMode = EVENTMODE_DEFAULT;
|
2012-12-24 13:32:39 +01:00
|
|
|
_exitId = 0;
|
2013-03-24 18:57:46 +01:00
|
|
|
_characterSpriteBuf = 0;
|
2012-12-24 13:32:39 +01:00
|
|
|
_screenId = 0;
|
2013-01-01 13:53:07 +01:00
|
|
|
_prevScreenId = 0;
|
2013-01-27 14:32:05 +01:00
|
|
|
_characterMaxPosY = 0;
|
2012-12-30 18:51:47 +01:00
|
|
|
_menuScrollSpeed = 0;
|
|
|
|
_menuSpeed = 0;
|
|
|
|
_menuSoundOff = 0;
|
|
|
|
_menuVoiceOff = 0;
|
|
|
|
_menuMusicOff = 0;
|
|
|
|
_menuTextOff = 0;
|
|
|
|
_menuDisplayType = 0;
|
2013-02-22 08:18:13 +01:00
|
|
|
_checkDistanceFl = false;
|
2013-05-06 08:21:50 +02:00
|
|
|
_characterType = CHARACTER_HOPKINS;
|
2013-02-21 08:23:38 +01:00
|
|
|
_actionMoveTo = false;
|
2013-02-18 01:19:41 +01:00
|
|
|
_actionDirection = DIR_NONE;
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2013-02-19 21:12:57 +01:00
|
|
|
_creditsStartX = -1;
|
|
|
|
_creditsEndX = -1;
|
|
|
|
_creditsStartY = -1;
|
|
|
|
_creditsEndY = -1;
|
2013-01-29 08:35:14 +01:00
|
|
|
_creditsPosY = 0;
|
|
|
|
_creditsLineNumb = 0;
|
|
|
|
memset(_creditsItem, 0, 12000);
|
|
|
|
_creditsStep = 0;
|
2012-11-11 17:59:29 +01:00
|
|
|
|
2013-02-18 01:19:41 +01:00
|
|
|
_oceanDirection = DIR_NONE;
|
2012-11-11 21:37:04 +01:00
|
|
|
|
2013-01-27 22:28:10 +01:00
|
|
|
// Initialize pointers
|
2013-04-04 07:54:45 +02:00
|
|
|
_levelSpriteBuf = NULL;
|
2013-04-05 01:27:09 +02:00
|
|
|
_saveData = NULL;
|
2013-04-04 07:54:45 +02:00
|
|
|
_answerBuffer = NULL;
|
|
|
|
_characterSpriteBuf = NULL;
|
|
|
|
_optionDialogSpr = NULL;
|
2012-09-19 21:34:23 +10:00
|
|
|
|
2012-09-08 21:43:33 +10:00
|
|
|
// Reset flags
|
2012-12-31 00:18:08 +01:00
|
|
|
_censorshipFl = false;
|
2012-12-10 23:57:59 +01:00
|
|
|
_disableInventFl = false;
|
2013-02-21 08:23:38 +01:00
|
|
|
_freezeCharacterFl = false;
|
2012-12-10 23:57:59 +01:00
|
|
|
_optionDialogFl = false;
|
2013-01-23 01:38:34 +01:00
|
|
|
_introSpeechOffFl = false;
|
2013-03-27 00:51:35 +01:00
|
|
|
_cityMapEnabledFl = false;
|
|
|
|
|
2013-01-29 08:35:14 +01:00
|
|
|
_baseMapColor = 50;
|
2013-03-29 19:47:40 +01:00
|
|
|
_curRoomNum = 0;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
Globals::~Globals() {
|
2013-03-24 18:57:46 +01:00
|
|
|
freeMemory(_levelSpriteBuf);
|
2012-12-24 13:32:39 +01:00
|
|
|
freeMemory((byte *)_saveData);
|
2013-01-27 01:25:46 +01:00
|
|
|
freeMemory(_answerBuffer);
|
2013-03-24 18:57:46 +01:00
|
|
|
freeMemory(_characterSpriteBuf);
|
2013-04-04 07:54:45 +02:00
|
|
|
free(NULL);
|
2012-09-08 10:08:12 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::setConfig() {
|
2012-11-07 22:49:13 +01:00
|
|
|
// CHECKME: Should be in Globals() but it doesn't work
|
2012-12-09 10:05:26 +01:00
|
|
|
// The Polish version is a translation of the English version. The filenames are the same.
|
2013-07-14 19:01:47 +02:00
|
|
|
// The Russian version looks like a translation of the English version, based on the filenames.
|
2012-11-07 22:49:13 +01:00
|
|
|
switch (_vm->getLanguage()) {
|
|
|
|
case Common::EN_ANY:
|
2012-12-09 10:05:26 +01:00
|
|
|
case Common::PL_POL:
|
2013-05-11 12:15:45 +02:00
|
|
|
case Common::RU_RUS:
|
2012-12-24 11:36:53 +01:00
|
|
|
_language = LANG_EN;
|
2012-11-07 22:49:13 +01:00
|
|
|
break;
|
|
|
|
case Common::FR_FRA:
|
2012-12-24 11:36:53 +01:00
|
|
|
_language = LANG_FR;
|
2012-11-07 22:49:13 +01:00
|
|
|
break;
|
|
|
|
case Common::ES_ESP:
|
2012-12-24 11:36:53 +01:00
|
|
|
_language = LANG_SP;
|
2012-11-07 22:49:13 +01:00
|
|
|
break;
|
|
|
|
default:
|
2012-12-09 10:05:26 +01:00
|
|
|
warning("Unknown language in internal language mapping");
|
2012-11-07 22:49:13 +01:00
|
|
|
break;
|
|
|
|
}
|
2012-11-08 08:29:26 +01:00
|
|
|
// End of CHECKME
|
|
|
|
|
2012-12-24 11:36:53 +01:00
|
|
|
switch (_language) {
|
|
|
|
case LANG_EN:
|
2013-02-22 10:36:54 +01:00
|
|
|
_zoneFilename = "ZONEAN.TXT";
|
|
|
|
_textFilename = "TEXTEAN.TXT";
|
2012-09-08 10:08:12 +10:00
|
|
|
break;
|
2012-12-24 11:36:53 +01:00
|
|
|
case LANG_FR:
|
2013-02-22 10:36:54 +01:00
|
|
|
_zoneFilename = "ZONE01.TXT";
|
|
|
|
_textFilename = "TEXTE01.TXT";
|
2012-09-08 10:08:12 +10:00
|
|
|
break;
|
2012-12-24 11:36:53 +01:00
|
|
|
case LANG_SP:
|
2013-02-22 10:36:54 +01:00
|
|
|
_zoneFilename = "ZONEES.TXT";
|
|
|
|
_textFilename = "TEXTEES.TXT";
|
2012-09-08 10:08:12 +10:00
|
|
|
break;
|
|
|
|
}
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
2012-09-08 18:45:22 +10:00
|
|
|
void Globals::clearAll() {
|
2013-04-10 10:27:06 +02:00
|
|
|
_vm->_fontMan->clearAll();
|
|
|
|
_vm->_dialog->clearAll();
|
2013-04-04 07:54:45 +02:00
|
|
|
_answerBuffer = NULL;
|
|
|
|
_levelSpriteBuf = NULL;
|
2013-04-05 01:27:09 +02:00
|
|
|
_saveData = NULL;
|
2013-04-10 10:27:06 +02:00
|
|
|
_vm->_objectsMan->_curObjectIndex = 0;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2013-04-10 10:27:06 +02:00
|
|
|
_vm->_linesMan->clearAll();
|
|
|
|
_vm->_objectsMan->clearAll();
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2013-03-05 07:45:15 +01:00
|
|
|
_saveData = (Savegame *)malloc(sizeof(Savegame));
|
|
|
|
memset(_saveData, 0, sizeof(Savegame));
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2013-04-10 10:27:06 +02:00
|
|
|
_vm->_events->clearAll();
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
2012-12-31 00:18:08 +01:00
|
|
|
void Globals::loadCharacterData() {
|
2012-10-19 07:15:17 +11:00
|
|
|
const int *srcList[] = { HOPKINS_PERSO_0, HOPKINS_PERSO_1, HOPKINS_PERSO_2 };
|
2013-02-19 21:12:57 +01:00
|
|
|
const int *srcP = srcList[_characterType];
|
2012-10-19 07:15:17 +11:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 240 / 4; ++idx) {
|
2013-02-19 23:18:43 +01:00
|
|
|
_hopkinsItem[idx]._speedX = *srcP++;
|
|
|
|
_hopkinsItem[idx]._speedY = *srcP++;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
2013-04-10 10:27:06 +02:00
|
|
|
_vm->_objectsMan->resetOldFrameIndex();
|
|
|
|
_vm->_objectsMan->resetOldDirection();
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
2012-12-12 08:05:04 +01:00
|
|
|
byte *Globals::allocMemory(int count) {
|
2012-09-08 23:43:35 +10:00
|
|
|
byte *result = (byte *)malloc(count);
|
|
|
|
if (!result)
|
2013-04-04 07:54:45 +02:00
|
|
|
result = NULL;
|
2012-09-08 21:43:33 +10:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-12 08:05:04 +01:00
|
|
|
byte *Globals::freeMemory(byte *p) {
|
2013-04-05 01:43:10 +02:00
|
|
|
if (p)
|
2012-10-10 21:03:29 +11:00
|
|
|
free(p);
|
2013-04-04 07:54:45 +02:00
|
|
|
return NULL;
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
} // End of namespace Hopkins
|