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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-09-08 18:45:22 +10:00
|
|
|
#include "common/textconsole.h"
|
2012-09-28 22:15:59 +10:00
|
|
|
#include "common/file.h"
|
2012-09-07 22:20:05 +10:00
|
|
|
#include "hopkins/globals.h"
|
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
|
|
|
|
|
|
|
namespace Hopkins {
|
|
|
|
|
2012-10-19 07:15:17 +11: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 21:03:29 +11:00
|
|
|
byte *g_PTRNUL;
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
Globals::Globals() {
|
2012-10-10 21:03:29 +11:00
|
|
|
// Set up the special g_PTRNUL variable
|
|
|
|
g_PTRNUL = (byte *)malloc(16);
|
|
|
|
strcpy((char *)g_PTRNUL, "POINTERNULL");
|
|
|
|
|
2012-10-07 00:02:02 +10:00
|
|
|
// Initialise array properties
|
|
|
|
for (int i = 0; i < 6; ++i)
|
2012-10-10 21:03:29 +11:00
|
|
|
CACHE_BANQUE[i] = g_PTRNUL;
|
2012-10-07 00:02:02 +10:00
|
|
|
for (int i = 0; i < 106; ++i)
|
|
|
|
Common::fill((byte *)&ZONEP[i], (byte *)&ZONEP[i] + sizeof(ZonePItem), 0);
|
|
|
|
for (int i = 0; i < 100; ++i)
|
|
|
|
Common::fill((byte *)&CarreZone[i], (byte *)&CarreZone[i] + sizeof(CarreZoneItem), 0);
|
|
|
|
for (int i = 0; i < 35; ++i)
|
|
|
|
Common::fill((byte *)&Bqe_Anim[i], (byte *)&Bqe_Anim[i] + sizeof(BqeAnimItem), 0);
|
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
Common::fill((byte *)&Bank[i], (byte *)&Bank[i] + sizeof(BankItem), 0);
|
|
|
|
for (int i = 0; i < 36; ++i)
|
2012-12-20 08:35:11 +01:00
|
|
|
Common::fill((byte *)&_bob[i], (byte *)&_bob[i] + sizeof(BobItem), 0);
|
2012-10-07 00:02:02 +10:00
|
|
|
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 07:50:12 +01:00
|
|
|
Common::fill((byte *)&Liste2[i], (byte *)&Liste2[i] + sizeof(ListeItem), 0);
|
2012-12-30 14:28:24 +01:00
|
|
|
for (int i = 0; i < 30; ++i) {
|
2012-12-29 14:20:34 +01:00
|
|
|
Common::fill((byte *)&_lockedAnims[i], (byte *)&_lockedAnims[i] + sizeof(LockAnimItem), 0);
|
2012-10-07 00:02:02 +10:00
|
|
|
Common::fill((byte *)&VBob[i], (byte *)&VBob[i] + sizeof(VBobItem), 0);
|
2012-12-30 14:28:24 +01:00
|
|
|
}
|
2012-10-07 00:02:02 +10:00
|
|
|
for (int i = 0; i < 300; ++i)
|
|
|
|
Common::fill((byte *)&ObjetW[i], (byte *)&ObjetW[i] + sizeof(ObjetWItem), 0);
|
|
|
|
for (int i = 0; i < 250; ++i)
|
|
|
|
Common::fill((byte *)&BLOC[i], (byte *)&BLOC[i] + sizeof(BlocItem), 0);
|
|
|
|
for (int i = 0; i < 25; ++i)
|
|
|
|
Common::fill((byte *)&Cache[i], (byte *)&Cache[i] + sizeof(CacheItem), 0);
|
|
|
|
|
|
|
|
for (int i = 0; i < 101; ++i)
|
|
|
|
Common::fill((byte *)&Segment[i], (byte *)&Segment[i] + sizeof(SegmentItem), 0);
|
|
|
|
for (int i = 0; i < 105; ++i) {
|
|
|
|
BOBZONE[i] = 0;
|
2012-10-25 09:29:57 +11:00
|
|
|
BOBZONE_FLAG[i] = false;
|
2012-10-07 00:02:02 +10:00
|
|
|
}
|
|
|
|
for (int i = 0; i < 500; ++i)
|
|
|
|
STAILLE[i] = 0;
|
|
|
|
for (int i = 0; i < 32002; ++i)
|
|
|
|
super_parcours[i] = 0;
|
|
|
|
for (int i = 0; i < 2100; ++i)
|
|
|
|
Param[i] = 0;
|
|
|
|
for (int i = 0; i < 70; ++i)
|
|
|
|
Common::fill((byte *)&Hopkins[i], (byte *)&Hopkins[i] + sizeof(HopkinsItem), 0);
|
|
|
|
|
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
|
|
|
for (int i = 0; i < 51; ++i)
|
2013-01-02 00:57:00 +01:00
|
|
|
Common::fill((byte *)&_sortedDisplay[i], (byte *)&_sortedDisplay[i] + sizeof(SortItem), 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
|
|
|
|
|
|
|
PUBEXIT = false;
|
2012-12-17 08:01:29 +01:00
|
|
|
_speed = 1;
|
2012-09-09 20:10:32 +10:00
|
|
|
g_old_anim = 0;
|
2013-01-14 08:04:38 +01:00
|
|
|
_oldDirection = 0;
|
|
|
|
_oldDirectionSpriteIdx = 59;
|
2012-12-26 22:02:48 +01:00
|
|
|
_lastDirection = 0;
|
2012-09-09 20:10:32 +10:00
|
|
|
police_l = police_h = 0;
|
|
|
|
TETE = NULL;
|
2012-12-16 14:22:24 +01:00
|
|
|
_curObjectIndex = 0;
|
2012-09-09 20:10:32 +10:00
|
|
|
NUM_FICHIER_OBJ = 0;
|
|
|
|
nbrligne = 0;
|
2012-12-25 22:48:11 +01:00
|
|
|
_boxWidth = 0;
|
2012-12-25 02:25:13 +01:00
|
|
|
_forestFl = false;
|
2012-12-19 08:00:22 +01:00
|
|
|
_objectWidth = _objectHeight = 0;
|
2012-12-24 18:43:49 +01:00
|
|
|
_helicopterFl = false;
|
2012-12-19 08:00:22 +01:00
|
|
|
_catalogPos = 0;
|
|
|
|
_catalogSize = 0;
|
2012-09-15 10:27:15 +10:00
|
|
|
iRegul = 0;
|
2012-12-24 13:32:39 +01:00
|
|
|
_exitId = 0;
|
2013-01-14 07:58:06 +01:00
|
|
|
_mapCarPosX = _mapCarPosY = 0;
|
2012-09-17 16:53:21 +10:00
|
|
|
PERSO = 0;
|
2012-12-24 13:32:39 +01:00
|
|
|
_screenId = 0;
|
2013-01-01 13:53:07 +01:00
|
|
|
_prevScreenId = 0;
|
2013-01-07 17:53:17 +02:00
|
|
|
_maxLineLength = 0;
|
2012-09-17 16:53:21 +10:00
|
|
|
Max_Perso_Y = 0;
|
|
|
|
Max_Propre = 0;
|
2012-09-19 21:34:23 +10:00
|
|
|
NBBLOC = 0;
|
2012-12-30 18:51:47 +01:00
|
|
|
_menuScrollType = 0;
|
|
|
|
_menuScrollSpeed = 0;
|
|
|
|
_menuSpeed = 0;
|
|
|
|
_menuSoundOff = 0;
|
|
|
|
_menuVoiceOff = 0;
|
|
|
|
_menuMusicOff = 0;
|
|
|
|
_menuTextOff = 0;
|
|
|
|
_menuDisplayType = 0;
|
2013-01-02 00:57:00 +01:00
|
|
|
_sortedDisplayCount = 0;
|
|
|
|
NOT_VERIF = false;
|
2012-10-07 00:02:02 +10:00
|
|
|
PERSO_TYPE = 0;
|
2012-12-19 02:15:32 +01:00
|
|
|
GOACTION = false;
|
2012-10-07 00:02:02 +10:00
|
|
|
Compteur = 0;
|
2012-12-24 18:43:49 +01:00
|
|
|
_actionDirection = 0;
|
|
|
|
_actionDirection = 0;
|
2012-10-07 00:02:02 +10:00
|
|
|
SegmentEnCours = 0;
|
2013-01-12 11:55:44 +01:00
|
|
|
pathFindingDepth = 0;
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2012-11-11 17:59:29 +01:00
|
|
|
Credit_bx = -1;
|
|
|
|
Credit_bx1 = -1;
|
|
|
|
Credit_by = -1;
|
|
|
|
Credit_by1 = -1;
|
|
|
|
Credit_y = 0;
|
|
|
|
Credit_lignes = 0;
|
|
|
|
memset(Credit, 0, 12000);
|
|
|
|
Credit_step = 0;
|
2012-11-12 00:28:01 +01:00
|
|
|
Credit_l = 0;
|
|
|
|
Credit_h = 0;
|
2012-11-11 17:59:29 +01:00
|
|
|
|
2012-12-26 22:02:48 +01:00
|
|
|
_oceanDirection = 0;
|
2012-11-11 21:37:04 +01:00
|
|
|
|
2012-09-08 18:45:22 +10:00
|
|
|
// Initialise pointers
|
|
|
|
ICONE = NULL;
|
|
|
|
BUF_ZONE = NULL;
|
2013-01-02 16:04:15 +01:00
|
|
|
for (int idx = 0; idx < 6; ++idx)
|
|
|
|
CACHE_BANQUE[idx] = NULL;
|
2012-09-08 18:45:22 +10:00
|
|
|
SPRITE_ECRAN = NULL;
|
2012-12-24 13:32:39 +01:00
|
|
|
_saveData = NULL;
|
2012-09-08 18:45:22 +10:00
|
|
|
BUFFERTAPE = NULL;
|
|
|
|
essai0 = NULL;
|
|
|
|
essai1 = NULL;
|
|
|
|
essai2 = NULL;
|
|
|
|
inventaire2 = NULL;
|
|
|
|
GESTE = NULL;
|
2012-12-25 22:48:11 +01:00
|
|
|
_inventoryObject = NULL;
|
|
|
|
_forestSprite = NULL;
|
2012-09-08 18:45:22 +10:00
|
|
|
COUCOU = NULL;
|
|
|
|
chemin = NULL;
|
|
|
|
BufLig = NULL;
|
|
|
|
ADR_FICHIER_OBJ = NULL;
|
2012-09-09 20:10:32 +10:00
|
|
|
police = NULL;
|
2012-09-17 16:53:21 +10:00
|
|
|
PERSO = NULL;
|
2012-09-23 10:59:52 +10:00
|
|
|
OPTION_SPR = 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-25 22:48:11 +01:00
|
|
|
GESTE_FLAG = 0;
|
2012-12-10 23:57:59 +01:00
|
|
|
_disableInventFl = false;
|
2012-09-19 21:34:23 +10:00
|
|
|
NOMARCHE = false;
|
2012-12-10 23:57:59 +01:00
|
|
|
_optionDialogFl = false;
|
2012-12-30 14:28:24 +01:00
|
|
|
_cacheFl = false;
|
2012-09-26 23:34:10 +10:00
|
|
|
NOPARLE = false;
|
2012-11-11 15:11:31 +01:00
|
|
|
couleur_40 = 50;
|
2012-10-07 00:02:02 +10:00
|
|
|
|
|
|
|
// Reset indexed variables
|
|
|
|
force_to_data_0 = 0;
|
|
|
|
oldzone_46 = 0;
|
|
|
|
old_x1_65 = 0;
|
|
|
|
old_y1_66 = 0;
|
|
|
|
old_x2_67 = 0;
|
|
|
|
old_y2_68 = 0;
|
|
|
|
old_zone_68 = 0;
|
2013-01-12 11:55:44 +01:00
|
|
|
_oldZoneNum = 0;
|
2012-10-07 00:02:02 +10:00
|
|
|
old_x_69 = 0;
|
|
|
|
old_y_70 = 0;
|
|
|
|
compteur_71 = 0;
|
|
|
|
zozo_73 = 0;
|
2012-10-13 15:19:54 +11:00
|
|
|
j_104 = 0;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
Globals::~Globals() {
|
|
|
|
free(ICONE);
|
2012-12-12 08:05:04 +01:00
|
|
|
freeMemory(TETE);
|
|
|
|
freeMemory(police);
|
|
|
|
freeMemory(BUF_ZONE);
|
2013-01-02 16:04:15 +01:00
|
|
|
for (int idx = 0; idx < 6; ++idx)
|
|
|
|
CACHE_BANQUE[idx] = freeMemory(CACHE_BANQUE[idx]);
|
2012-12-12 08:05:04 +01:00
|
|
|
freeMemory(SPRITE_ECRAN);
|
2012-12-24 13:32:39 +01:00
|
|
|
freeMemory((byte *)_saveData);
|
2012-12-12 08:05:04 +01:00
|
|
|
freeMemory(BUFFERTAPE);
|
|
|
|
freeMemory(inventaire2);
|
|
|
|
freeMemory(GESTE);
|
2012-12-25 22:48:11 +01:00
|
|
|
freeMemory(_inventoryObject);
|
|
|
|
freeMemory(_forestSprite);
|
2012-12-12 08:05:04 +01:00
|
|
|
freeMemory(COUCOU);
|
|
|
|
freeMemory(ADR_FICHIER_OBJ);
|
|
|
|
freeMemory(PERSO);
|
2012-10-10 21:03:29 +11:00
|
|
|
|
2012-12-08 22:44:00 +11:00
|
|
|
CLEAR_VBOB();
|
|
|
|
|
2012-10-10 21:03:29 +11:00
|
|
|
free(g_PTRNUL);
|
2012-09-08 10:08:12 +10:00
|
|
|
}
|
|
|
|
|
2012-09-22 19:54:30 +10:00
|
|
|
void Globals::setParent(HopkinsEngine *vm) {
|
|
|
|
_vm = vm;
|
|
|
|
}
|
|
|
|
|
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.
|
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:
|
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:
|
2012-09-08 10:08:12 +10:00
|
|
|
FICH_ZONE = "ZONEAN.TXT";
|
|
|
|
FICH_TEXTE = "TEXTEAN.TXT";
|
|
|
|
break;
|
2012-12-24 11:36:53 +01:00
|
|
|
case LANG_FR:
|
2012-09-08 10:08:12 +10:00
|
|
|
FICH_ZONE = "ZONE01.TXT";
|
|
|
|
FICH_TEXTE = "TEXTE01.TXT";
|
|
|
|
break;
|
2012-12-24 11:36:53 +01:00
|
|
|
case LANG_SP:
|
2012-09-08 10:08:12 +10:00
|
|
|
FICH_ZONE = "ZONEES.TXT";
|
|
|
|
FICH_TEXTE = "TEXTEES.TXT";
|
|
|
|
break;
|
|
|
|
}
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
2012-09-08 18:45:22 +10:00
|
|
|
void Globals::clearAll() {
|
|
|
|
for (int idx = 0; idx < 6; ++idx)
|
2012-10-10 21:03:29 +11:00
|
|
|
CACHE_BANQUE[idx] = g_PTRNUL;
|
2012-09-08 18:45:22 +10:00
|
|
|
|
|
|
|
nbrligne = 80;
|
|
|
|
INIT_ANIM();
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-10-10 21:03:29 +11:00
|
|
|
police = g_PTRNUL;
|
2012-09-08 18:45:22 +10:00
|
|
|
police_h = 0;
|
|
|
|
police_l = 0;
|
2012-12-25 22:48:11 +01:00
|
|
|
_boxWidth = 0;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-22 19:54:30 +10:00
|
|
|
_vm->_fontManager.clearAll();
|
2012-09-08 18:45:22 +10:00
|
|
|
|
|
|
|
INIT_VBOB();
|
2012-10-10 21:03:29 +11:00
|
|
|
ADR_FICHIER_OBJ = g_PTRNUL;
|
2012-09-08 18:45:22 +10:00
|
|
|
NUM_FICHIER_OBJ = 0;
|
2012-12-11 01:53:50 +01:00
|
|
|
_vm->_eventsManager._objectBuf = g_PTRNUL;
|
2012-12-10 23:57:59 +01:00
|
|
|
_vm->_dialogsManager._inventWin1 = g_PTRNUL;
|
|
|
|
_vm->_dialogsManager._inventBuf2 = g_PTRNUL;
|
2012-10-10 21:03:29 +11:00
|
|
|
COUCOU = g_PTRNUL;
|
|
|
|
SPRITE_ECRAN = g_PTRNUL;
|
2012-12-24 13:32:39 +01:00
|
|
|
_saveData = (Sauvegarde *)g_PTRNUL;
|
2012-12-16 14:22:24 +01:00
|
|
|
_curObjectIndex = 0;
|
2012-12-14 01:49:22 +01:00
|
|
|
|
2012-09-08 18:45:22 +10:00
|
|
|
for (int idx = 0; idx < 105; ++idx) {
|
2012-12-17 00:16:49 +01:00
|
|
|
ZONEP[idx]._destX = 0;
|
|
|
|
ZONEP[idx]._destY = 0;
|
2013-01-20 23:36:58 +01:00
|
|
|
ZONEP[idx]._spriteIndex = 0;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
2012-10-19 22:19:50 +11:00
|
|
|
essai0 = (int16 *)g_PTRNUL;
|
|
|
|
essai1 = (int16 *)g_PTRNUL;
|
|
|
|
essai2 = (int16 *)g_PTRNUL;
|
2012-10-20 17:06:57 +11:00
|
|
|
BufLig = (int16 *)g_PTRNUL;
|
2012-10-20 17:47:57 +11:00
|
|
|
chemin = (int16 *)g_PTRNUL;
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2013-01-10 22:09:37 +01:00
|
|
|
for (int idx = 0; idx < MAX_LINES; ++idx) {
|
2013-01-10 08:28:15 +01:00
|
|
|
_vm->_linesManager.Ligne[idx]._lineDataEndIdx = 0;
|
2012-10-02 21:44:23 +10:00
|
|
|
_vm->_linesManager.Ligne[idx].field2 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field4 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field6 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field8 = 0;
|
2013-01-10 08:28:15 +01:00
|
|
|
_vm->_linesManager.Ligne[idx]._lineData = (int16 *)g_PTRNUL;
|
2012-10-02 21:44:23 +10:00
|
|
|
|
2012-12-31 00:18:08 +01:00
|
|
|
_vm->_linesManager._zoneLine[idx].count = 0;
|
|
|
|
_vm->_linesManager._zoneLine[idx].field2 = 0;
|
|
|
|
_vm->_linesManager._zoneLine[idx].zoneData = (int16 *)g_PTRNUL;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 100; ++idx) {
|
2013-01-21 07:50:12 +01:00
|
|
|
CarreZone[idx]._enabledFl = 0;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
2012-12-12 08:05:04 +01:00
|
|
|
BUFFERTAPE = allocMemory(85000);
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2012-12-24 13:32:39 +01:00
|
|
|
_saveData = (Sauvegarde *)malloc(sizeof(Sauvegarde));
|
|
|
|
memset(_saveData, 0, sizeof(Sauvegarde));
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2012-10-19 22:19:50 +11:00
|
|
|
essai0 = (int16 *)BUFFERTAPE;
|
|
|
|
essai1 = (int16 *)(BUFFERTAPE + 25000);
|
|
|
|
essai2 = (int16 *)(BUFFERTAPE + 50000);
|
2012-10-20 17:06:57 +11:00
|
|
|
BufLig = (int16 *)(BUFFERTAPE + 75000);
|
2012-12-25 22:48:11 +01:00
|
|
|
_boxWidth = 240;
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2012-12-12 08:05:04 +01:00
|
|
|
_vm->_eventsManager._objectBuf = allocMemory(2500);
|
2012-12-25 22:48:11 +01:00
|
|
|
_inventoryObject = allocMemory(2500);
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2012-10-10 21:03:29 +11:00
|
|
|
ADR_FICHIER_OBJ = g_PTRNUL;
|
2012-12-25 22:48:11 +01:00
|
|
|
_forestSprite = g_PTRNUL;
|
2012-12-25 02:25:13 +01:00
|
|
|
_forestFl = false;
|
2012-09-08 18:45:22 +10:00
|
|
|
|
2012-10-10 21:03:29 +11:00
|
|
|
GESTE = g_PTRNUL;
|
2012-12-25 22:48:11 +01:00
|
|
|
GESTE_FLAG = 0;
|
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
|
|
|
assert(PERSO_TYPE >= 0 && PERSO_TYPE <= 2);
|
|
|
|
|
|
|
|
const int *srcList[] = { HOPKINS_PERSO_0, HOPKINS_PERSO_1, HOPKINS_PERSO_2 };
|
|
|
|
const int *srcP = srcList[PERSO_TYPE];
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 240 / 4; ++idx) {
|
|
|
|
Hopkins[idx].field0 = *srcP++;
|
|
|
|
Hopkins[idx].field2 = *srcP++;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
g_old_anim = -1;
|
2013-01-14 08:04:38 +01:00
|
|
|
_oldDirection = -1;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::INIT_ANIM() {
|
|
|
|
for (int idx = 0; idx < 35; ++idx) {
|
2012-12-17 00:16:49 +01:00
|
|
|
Bqe_Anim[idx]._data = g_PTRNUL;
|
2012-12-29 14:20:34 +01:00
|
|
|
Bqe_Anim[idx]._enabledFl = false;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 8; ++idx) {
|
2012-12-17 00:16:49 +01:00
|
|
|
Bank[idx]._data = g_PTRNUL;
|
2012-12-29 23:57:50 +01:00
|
|
|
Bank[idx]._loadedFl = false;
|
2012-12-17 00:16:49 +01:00
|
|
|
Bank[idx]._filename = "";
|
|
|
|
Bank[idx]._fileHeader = 0;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::INIT_VBOB() {
|
|
|
|
for (int idx = 0; idx < 30; ++idx) {
|
|
|
|
VBob[idx].field4 = 0;
|
2012-12-17 00:16:49 +01:00
|
|
|
VBob[idx]._xp = 0;
|
|
|
|
VBob[idx]._yp = 0;
|
|
|
|
VBob[idx]._frameIndex = 0;
|
|
|
|
VBob[idx]._surface = g_PTRNUL;
|
2012-12-20 00:30:01 +01:00
|
|
|
VBob[idx]._spriteData = g_PTRNUL;
|
2012-12-17 00:16:49 +01:00
|
|
|
VBob[idx]._oldSpriteData = g_PTRNUL;
|
2012-09-08 18:45:22 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-29 09:33:42 +10:00
|
|
|
void Globals::CLEAR_VBOB() {
|
|
|
|
for (int idx = 0; idx < 30; ++idx) {
|
|
|
|
VBob[idx].field4 = 0;
|
2012-12-17 00:16:49 +01:00
|
|
|
VBob[idx]._xp = 0;
|
|
|
|
VBob[idx]._yp = 0;
|
|
|
|
VBob[idx]._frameIndex = 0;
|
|
|
|
VBob[idx]._surface = freeMemory(VBob[idx]._surface);
|
2012-12-20 00:30:01 +01:00
|
|
|
VBob[idx]._spriteData = g_PTRNUL;
|
2012-12-17 00:16:49 +01:00
|
|
|
VBob[idx]._oldSpriteData = g_PTRNUL;
|
2012-12-14 01:49:22 +01:00
|
|
|
}
|
2012-09-29 09:33:42 +10:00
|
|
|
}
|
|
|
|
|
2012-10-20 18:59:06 +02:00
|
|
|
// Load Object
|
2012-12-24 01:43:37 +01:00
|
|
|
void Globals::loadObjects() {
|
2013-01-07 23:56:39 +01:00
|
|
|
byte *data = _vm->_fileManager.loadFile("OBJET.DAT");
|
2012-09-08 21:43:33 +10:00
|
|
|
byte *srcP = data;
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 300; ++idx) {
|
|
|
|
ObjetW[idx].field0 = *srcP++;
|
2012-12-20 00:30:01 +01:00
|
|
|
ObjetW[idx]._idx = *srcP++;
|
2012-09-08 21:43:33 +10:00
|
|
|
ObjetW[idx].field2 = *srcP++;
|
|
|
|
ObjetW[idx].field3 = *srcP++;
|
|
|
|
ObjetW[idx].field4 = *srcP++;
|
|
|
|
ObjetW[idx].field5 = *srcP++;
|
|
|
|
ObjetW[idx].field6 = *srcP++;
|
|
|
|
ObjetW[idx].field7 = *srcP++;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
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)
|
2012-10-10 21:03:29 +11:00
|
|
|
result = g_PTRNUL;
|
2012-09-08 21:43:33 +10:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-12 08:05:04 +01:00
|
|
|
byte *Globals::freeMemory(byte *p) {
|
2012-10-10 21:03:29 +11:00
|
|
|
if (p != g_PTRNUL)
|
|
|
|
free(p);
|
|
|
|
return g_PTRNUL;
|
2012-09-09 19:55:05 +10:00
|
|
|
}
|
|
|
|
|
2012-10-20 18:59:06 +02:00
|
|
|
// Reset Cache
|
2013-01-02 00:57:00 +01:00
|
|
|
void Globals::resetCache() {
|
2012-09-28 22:15:59 +10:00
|
|
|
|
|
|
|
for (int idx = 1; idx <= 5; ++idx) {
|
2012-12-12 08:05:04 +01:00
|
|
|
CACHE_BANQUE[idx] = freeMemory(CACHE_BANQUE[idx]);
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx <= 20; ++idx) {
|
2012-12-20 00:30:01 +01:00
|
|
|
Cache[idx]._spriteData = g_PTRNUL;
|
|
|
|
Cache[idx]._x = 0;
|
|
|
|
Cache[idx]._y = 0;
|
|
|
|
Cache[idx]._spriteIndex = 0;
|
2012-09-28 22:15:59 +10:00
|
|
|
Cache[idx].fieldA = 0;
|
2012-12-20 00:30:01 +01:00
|
|
|
Cache[idx]._width = 0;
|
|
|
|
Cache[idx]._height = 0;
|
|
|
|
Cache[idx].field10 = false;
|
2012-09-28 22:15:59 +10:00
|
|
|
Cache[idx].field14 = 0;
|
|
|
|
}
|
|
|
|
|
2012-12-30 14:28:24 +01:00
|
|
|
_cacheFl = false;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::CACHE_ON() {
|
2012-12-30 14:28:24 +01:00
|
|
|
_cacheFl = true;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2012-10-20 18:59:06 +02:00
|
|
|
|
2012-09-30 21:02:39 +10:00
|
|
|
// TODO: Find why some calls have a parameter value
|
|
|
|
void Globals::CACHE_OFF(int v1) {
|
2012-12-30 14:28:24 +01:00
|
|
|
_cacheFl = false;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::CACHE_SUB(int idx) {
|
|
|
|
Cache[idx].fieldA = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::CACHE_ADD(int idx) {
|
|
|
|
Cache[idx].fieldA = 1;
|
|
|
|
}
|
|
|
|
|
2012-10-20 18:59:06 +02:00
|
|
|
// Load Cache
|
2012-12-19 02:15:32 +01:00
|
|
|
void Globals::loadCache(const Common::String &file) {
|
2012-10-10 21:03:29 +11:00
|
|
|
byte *v2 = g_PTRNUL;
|
2012-12-14 01:49:22 +01:00
|
|
|
byte *spriteData;
|
|
|
|
byte *ptr;
|
2012-09-28 22:15:59 +10:00
|
|
|
Common::String v16;
|
|
|
|
Common::File f;
|
|
|
|
|
2013-01-02 00:57:00 +01:00
|
|
|
resetCache();
|
2013-01-07 23:56:39 +01:00
|
|
|
ptr = _vm->_fileManager.loadFile(file);
|
2012-09-28 22:15:59 +10:00
|
|
|
v16 = Common::String((const char *)ptr);
|
|
|
|
|
2013-01-07 23:56:39 +01:00
|
|
|
if (!f.exists(v16))
|
2012-12-30 14:28:24 +01:00
|
|
|
return;
|
|
|
|
|
2013-01-07 23:56:39 +01:00
|
|
|
spriteData = _vm->_fileManager.loadFile(v16);
|
2012-12-30 14:28:24 +01:00
|
|
|
CACHE_BANQUE[1] = spriteData;
|
|
|
|
int v15 = 60;
|
|
|
|
for (int i = 0; i <= 21; i++) {
|
|
|
|
int v11 = (int16)READ_LE_UINT16((uint16 *)ptr + v15);
|
|
|
|
int v4 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 1);
|
|
|
|
int v5 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 2);
|
|
|
|
int v6 = i;
|
|
|
|
Cache[v6].field14 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 4);
|
|
|
|
Cache[v6]._spriteIndex = v11;
|
|
|
|
Cache[v6]._x = v4;
|
|
|
|
Cache[v6]._y = v5;
|
|
|
|
if (spriteData == g_PTRNUL) {
|
|
|
|
Cache[i].fieldA = 0;
|
|
|
|
} else {
|
|
|
|
int v8 = _vm->_objectsManager.getWidth(spriteData, v11);
|
|
|
|
int v9 = _vm->_objectsManager.getHeight(spriteData, v11);
|
|
|
|
Cache[i]._spriteData = spriteData;
|
|
|
|
Cache[i]._width = v8;
|
|
|
|
Cache[i]._height = v9;
|
|
|
|
Cache[i].fieldA = 1;
|
2012-11-23 22:21:35 +01:00
|
|
|
}
|
2012-12-30 14:28:24 +01:00
|
|
|
|
|
|
|
if ( !Cache[i]._x && !Cache[i]._y && !Cache[i]._spriteIndex)
|
|
|
|
Cache[i].fieldA = 0;
|
|
|
|
v15 += 5;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
2012-12-30 14:28:24 +01:00
|
|
|
CACHE_ON();
|
|
|
|
v2 = ptr;
|
2012-12-12 08:05:04 +01:00
|
|
|
freeMemory(v2);
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::B_CACHE_OFF(int idx) {
|
2012-12-20 08:35:11 +01:00
|
|
|
_bob[idx].field34 = true;
|
2012-09-28 22:15:59 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
} // End of namespace Hopkins
|