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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
#include "common/textconsole.h"
|
2012-09-28 12:15:59 +00:00
|
|
|
#include "common/file.h"
|
2012-09-07 12:20:05 +00:00
|
|
|
#include "hopkins/globals.h"
|
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
|
|
|
|
|
|
|
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");
|
|
|
|
|
2012-10-06 14:02:02 +00:00
|
|
|
// Initialise array properties
|
|
|
|
for (int i = 0; i < 6; ++i)
|
2012-10-10 10:03:29 +00:00
|
|
|
CACHE_BANQUE[i] = g_PTRNUL;
|
2012-10-06 14:02:02 +00: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)
|
|
|
|
Common::fill((byte *)&Bob[i], (byte *)&Bob[i] + sizeof(BobItem), 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)
|
|
|
|
Common::fill((byte *)&Liste2[i], (byte *)&Liste2[i] + sizeof(Liste2Item), 0);
|
|
|
|
for (int i = 0; i < 30; ++i)
|
|
|
|
Common::fill((byte *)&BL_ANIM[i], (byte *)&BL_ANIM[i] + sizeof(BlAnimItem), 0);
|
2012-10-26 08:14:10 +00:00
|
|
|
for (int i = 0; i < 30; ++i)
|
2012-10-06 14:02:02 +00:00
|
|
|
Common::fill((byte *)&VBob[i], (byte *)&VBob[i] + sizeof(VBobItem), 0);
|
|
|
|
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-24 22:29:57 +00:00
|
|
|
BOBZONE_FLAG[i] = false;
|
2012-10-06 14:02:02 +00: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-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)
|
|
|
|
Common::fill((byte *)&Tri[i], (byte *)&Tri[i] + sizeof(TriItem), 0);
|
|
|
|
|
2012-10-06 14:02:02 +00:00
|
|
|
// Initialise fields
|
2012-09-07 12:20:05 +00:00
|
|
|
FR = 0;
|
|
|
|
SVGA = 2;
|
2012-11-08 07:29:26 +00:00
|
|
|
internet = true;
|
|
|
|
|
|
|
|
PUBEXIT = false;
|
2012-09-08 00:08:12 +00:00
|
|
|
vitesse = 1;
|
|
|
|
INSTALL_TYPE = 1;
|
|
|
|
MUSICVOL = 6;
|
|
|
|
SOUNDVOL = 6;
|
|
|
|
VOICEVOL = 6;
|
2012-09-09 10:10:32 +00:00
|
|
|
g_old_anim = 0;
|
|
|
|
g_old_sens = 0;
|
2012-10-06 14:02:02 +00:00
|
|
|
g_old_sens2 = 0;
|
2012-10-13 04:19:54 +00:00
|
|
|
last_sens = 0;
|
2012-09-09 10:10:32 +00:00
|
|
|
police_l = police_h = 0;
|
|
|
|
TETE = NULL;
|
|
|
|
texte_long = 0;
|
|
|
|
TEXTE_FORMATE = 0;
|
2012-12-16 13:22:24 +00:00
|
|
|
_curObjectIndex = 0;
|
2012-09-09 10:10:32 +00:00
|
|
|
NUM_FICHIER_OBJ = 0;
|
|
|
|
nbrligne = 0;
|
|
|
|
largeur_boite = 0;
|
|
|
|
hauteur_boite = 0;
|
2012-11-18 02:42:44 +00:00
|
|
|
FORET = false;
|
2012-09-09 10:10:32 +00:00
|
|
|
OBJL = OBJH = 0;
|
|
|
|
HELICO = 0;
|
|
|
|
CAT_POSI = 0;
|
|
|
|
CAT_TAILLE = 0;
|
2012-12-16 13:22:24 +00:00
|
|
|
_newObjectFl = false;
|
2012-09-15 00:27:15 +00:00
|
|
|
iRegul = 0;
|
2012-09-17 06:53:21 +00:00
|
|
|
SORTIE = 0;
|
|
|
|
PLANX = PLANY = 0;
|
2012-10-06 14:02:02 +00:00
|
|
|
PLANI = 0;
|
2012-09-17 06:53:21 +00:00
|
|
|
PERSO = 0;
|
2012-11-09 18:22:29 +00:00
|
|
|
PASSWORD = false;
|
2012-09-17 06:53:21 +00:00
|
|
|
ECRAN = 0;
|
2012-11-11 13:22:58 +00:00
|
|
|
NOSPRECRAN = false;
|
2012-09-17 06:53:21 +00:00
|
|
|
OLD_ECRAN = 0;
|
|
|
|
Max_Propre_Gen = 0;
|
|
|
|
Max_Ligne_Long = 0;
|
|
|
|
Max_Perso_Y = 0;
|
|
|
|
Max_Propre = 0;
|
2012-11-11 13:22:58 +00:00
|
|
|
fmusic = 0;
|
2012-09-19 11:34:23 +00:00
|
|
|
NBBLOC = 0;
|
2012-09-23 00:59:52 +00:00
|
|
|
opt_scrtype = 0;
|
|
|
|
opt_scrspeed = 0;
|
|
|
|
opt_vitesse = 0;
|
|
|
|
opt_sound = 0;
|
|
|
|
opt_voice = 0;
|
|
|
|
opt_music = 0;
|
|
|
|
opt_txt = 0;
|
|
|
|
opt_anm = 0;
|
|
|
|
NBTRI = 0;
|
2012-11-11 15:43:18 +00:00
|
|
|
AFFLI = false;
|
|
|
|
AFFIVBL = false;
|
2012-10-06 14:02:02 +00:00
|
|
|
NOT_VERIF = 0;
|
|
|
|
PERSO_TYPE = 0;
|
|
|
|
GOACTION = 0;
|
2012-10-31 21:15:09 +00:00
|
|
|
NECESSAIRE = false;
|
2012-10-06 14:02:02 +00:00
|
|
|
Compteur = 0;
|
|
|
|
ACTION_SENS = 0;
|
|
|
|
ACTION_SENS = 0;
|
|
|
|
SegmentEnCours = 0;
|
|
|
|
STOP_BUG = 0;
|
|
|
|
MAX_COMPTE = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-11-11 16:59:29 +00: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-11 23:28:01 +00:00
|
|
|
Credit_l = 0;
|
|
|
|
Credit_h = 0;
|
2012-11-11 16:59:29 +00:00
|
|
|
|
2012-11-11 20:37:04 +00:00
|
|
|
OCEAN_SENS = 0;
|
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
// Initialise pointers
|
|
|
|
ICONE = NULL;
|
|
|
|
BUF_ZONE = NULL;
|
|
|
|
CACHE_BANQUE[6] = NULL;
|
|
|
|
texte_tmp = NULL;
|
|
|
|
SPRITE_ECRAN = NULL;
|
|
|
|
SAUVEGARDE = NULL;
|
|
|
|
BUFFERTAPE = NULL;
|
|
|
|
essai0 = NULL;
|
|
|
|
essai1 = NULL;
|
|
|
|
essai2 = NULL;
|
|
|
|
inventaire2 = NULL;
|
|
|
|
GESTE = NULL;
|
|
|
|
INVENTAIRE_OBJET = NULL;
|
|
|
|
FORETSPR = NULL;
|
|
|
|
COUCOU = NULL;
|
|
|
|
chemin = NULL;
|
|
|
|
cache_souris = NULL;
|
|
|
|
BufLig = NULL;
|
|
|
|
Bufferdecor = NULL;
|
|
|
|
ADR_FICHIER_OBJ = NULL;
|
2012-09-09 10:10:32 +00:00
|
|
|
police = NULL;
|
2012-09-17 06:53:21 +00:00
|
|
|
PERSO = NULL;
|
2012-09-23 00:59:52 +00:00
|
|
|
OPTION_SPR = NULL;
|
2012-09-19 11:34:23 +00:00
|
|
|
|
2012-09-08 11:43:33 +00:00
|
|
|
// Reset flags
|
2012-09-09 10:10:32 +00:00
|
|
|
MUSICOFF = false;
|
|
|
|
SOUNDOFF = false;
|
|
|
|
VOICEOFF = false;
|
2012-09-08 11:43:33 +00:00
|
|
|
SOUNDOFF = false;
|
|
|
|
MUSICOFF = false;
|
|
|
|
VOICEOFF = false;
|
|
|
|
CENSURE = false;
|
|
|
|
GESTE_FLAG = false;
|
2012-09-15 03:23:46 +00:00
|
|
|
BPP_NOAFF = false;
|
2012-12-10 22:57:59 +00:00
|
|
|
_disableInventFl = false;
|
2012-09-17 06:53:21 +00:00
|
|
|
FLAG_VISIBLE = false;
|
|
|
|
netscape = false;
|
2012-09-19 11:34:23 +00:00
|
|
|
NOMARCHE = false;
|
2012-09-22 00:36:18 +00:00
|
|
|
NO_VISU = false;
|
2012-12-10 22:57:59 +00:00
|
|
|
_optionDialogFl = false;
|
2012-09-23 00:59:52 +00:00
|
|
|
CACHEFLAG = false;
|
2012-09-26 13:34:10 +00:00
|
|
|
NOPARLE = false;
|
2012-11-11 14:11:31 +00:00
|
|
|
couleur_40 = 50;
|
2012-10-06 14:02:02 +00: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;
|
|
|
|
old_z_69 = 0;
|
|
|
|
old_x_69 = 0;
|
|
|
|
old_y_70 = 0;
|
|
|
|
compteur_71 = 0;
|
|
|
|
zozo_73 = 0;
|
2012-10-13 04:19:54 +00:00
|
|
|
j_104 = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Globals::~Globals() {
|
|
|
|
free(ICONE);
|
2012-12-12 07:05:04 +00:00
|
|
|
freeMemory(TETE);
|
|
|
|
freeMemory(police);
|
|
|
|
freeMemory(BUF_ZONE);
|
|
|
|
freeMemory(CACHE_BANQUE[6]);
|
|
|
|
freeMemory(texte_tmp);
|
|
|
|
freeMemory(SPRITE_ECRAN);
|
|
|
|
freeMemory((byte *)SAUVEGARDE);
|
|
|
|
freeMemory(BUFFERTAPE);
|
|
|
|
freeMemory(inventaire2);
|
|
|
|
freeMemory(GESTE);
|
|
|
|
freeMemory(INVENTAIRE_OBJET);
|
|
|
|
freeMemory(FORETSPR);
|
|
|
|
freeMemory(COUCOU);
|
|
|
|
freeMemory(cache_souris);
|
|
|
|
freeMemory(Bufferdecor);
|
|
|
|
freeMemory(ADR_FICHIER_OBJ);
|
|
|
|
freeMemory(PERSO);
|
2012-10-10 10:03:29 +00:00
|
|
|
|
2012-12-08 11:44:00 +00:00
|
|
|
CLEAR_VBOB();
|
|
|
|
|
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() {
|
|
|
|
HOPIMAGE = "BUFFER";
|
|
|
|
HOPANIM = "ANIM";
|
|
|
|
HOPLINK = "LINK";
|
|
|
|
HOPSAVE = "SAVE";
|
|
|
|
HOPSOUND = "SOUND";
|
|
|
|
HOPMUSIC = "MUSIC";
|
|
|
|
HOPVOICE = "VOICE";
|
|
|
|
HOPANM = "ANM";
|
2012-11-17 08:59:50 +00:00
|
|
|
HOPTSVGA = "TSVGA";
|
|
|
|
HOPSVGA = "SVGA";
|
|
|
|
HOPVGA = "VGA";
|
2012-09-08 00:08:12 +00:00
|
|
|
HOPSEQ = "SEQ";
|
2012-12-09 19:22:12 +00:00
|
|
|
HOPSYSTEM = "SYSTEM";
|
2012-09-08 00:08:12 +00:00
|
|
|
|
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-11-07 21:49:13 +00:00
|
|
|
FR = 0;
|
|
|
|
break;
|
|
|
|
case Common::FR_FRA:
|
|
|
|
FR = 1;
|
|
|
|
break;
|
|
|
|
case Common::ES_ESP:
|
|
|
|
FR = 2;
|
|
|
|
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
|
|
|
if (_vm->getIsDemo())
|
|
|
|
internet = true;
|
|
|
|
else
|
|
|
|
internet = false;
|
|
|
|
// End of CHECKME
|
|
|
|
|
2012-09-08 00:08:12 +00:00
|
|
|
switch (FR) {
|
|
|
|
case 0:
|
|
|
|
FICH_ZONE = "ZONEAN.TXT";
|
|
|
|
FICH_TEXTE = "TEXTEAN.TXT";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
FICH_ZONE = "ZONE01.TXT";
|
|
|
|
FICH_TEXTE = "TEXTE01.TXT";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
FICH_ZONE = "ZONEES.TXT";
|
|
|
|
FICH_TEXTE = "TEXTEES.TXT";
|
|
|
|
break;
|
|
|
|
}
|
2012-09-07 12:20:05 +00:00
|
|
|
}
|
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
void Globals::clearAll() {
|
|
|
|
// TODO: The original allocated an explicit memory block for the null pointer
|
|
|
|
// to point to. For now, we're seeing if the NULL value will do as well
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
for (int idx = 0; idx < 6; ++idx)
|
2012-10-10 10:03:29 +00:00
|
|
|
CACHE_BANQUE[idx] = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
|
|
|
nbrligne = 80;
|
|
|
|
INIT_ANIM();
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-10 10:03:29 +00:00
|
|
|
texte_tmp = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
texte_long = 0;
|
2012-10-10 10:03:29 +00:00
|
|
|
police = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
police_h = 0;
|
|
|
|
police_l = 0;
|
|
|
|
hauteur_boite = 0;
|
|
|
|
largeur_boite = 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
|
|
|
|
|
|
|
INIT_VBOB();
|
2012-10-10 10:03:29 +00:00
|
|
|
ADR_FICHIER_OBJ = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
NUM_FICHIER_OBJ = 0;
|
2012-10-10 10:03:29 +00:00
|
|
|
Bufferdecor = g_PTRNUL;
|
2012-12-11 00:53:50 +00:00
|
|
|
_vm->_eventsManager._objectBuf = g_PTRNUL;
|
2012-12-10 22:57:59 +00:00
|
|
|
_vm->_dialogsManager._inventWin1 = g_PTRNUL;
|
|
|
|
_vm->_dialogsManager._inventBuf2 = g_PTRNUL;
|
2012-10-10 10:03:29 +00:00
|
|
|
COUCOU = g_PTRNUL;
|
|
|
|
SPRITE_ECRAN = g_PTRNUL;
|
|
|
|
SAUVEGARDE = (Sauvegarde *)g_PTRNUL;
|
2012-12-16 13:22:24 +00:00
|
|
|
_curObjectIndex = 0;
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-09-08 08:45:22 +00:00
|
|
|
for (int idx = 0; idx < 105; ++idx) {
|
2012-10-22 11:39:04 +00:00
|
|
|
ZONEP[idx].destX = 0;
|
|
|
|
ZONEP[idx].destY = 0;
|
2012-09-28 23:33:42 +00:00
|
|
|
ZONEP[idx].field4 = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
2012-10-19 11:19:50 +00:00
|
|
|
essai0 = (int16 *)g_PTRNUL;
|
|
|
|
essai1 = (int16 *)g_PTRNUL;
|
|
|
|
essai2 = (int16 *)g_PTRNUL;
|
2012-10-20 06:06:57 +00:00
|
|
|
BufLig = (int16 *)g_PTRNUL;
|
2012-10-20 06:47:57 +00:00
|
|
|
chemin = (int16 *)g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
|
|
|
for (int idx = 0; idx < 400; ++idx) {
|
2012-10-02 11:44:23 +00:00
|
|
|
_vm->_linesManager.Ligne[idx].field0 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field2 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field4 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field6 = 0;
|
|
|
|
_vm->_linesManager.Ligne[idx].field8 = 0;
|
2012-10-19 22:16:25 +00:00
|
|
|
_vm->_linesManager.Ligne[idx].lineData = (int16 *)g_PTRNUL;
|
2012-10-02 11:44:23 +00:00
|
|
|
|
2012-10-13 10:14:18 +00:00
|
|
|
_vm->_linesManager.LigneZone[idx].count = 0;
|
2012-10-02 11:44:23 +00:00
|
|
|
_vm->_linesManager.LigneZone[idx].field2 = 0;
|
2012-10-13 10:14:18 +00:00
|
|
|
_vm->_linesManager.LigneZone[idx].zoneData = (int16 *)g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 100; ++idx) {
|
|
|
|
CarreZone[idx].field0 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
texte_long = 0;
|
2012-10-10 10:03:29 +00:00
|
|
|
texte_tmp = g_PTRNUL;
|
2012-12-12 07:05:04 +00:00
|
|
|
BUFFERTAPE = allocMemory(85000);
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-09-23 12:52:12 +00:00
|
|
|
SAUVEGARDE = (Sauvegarde *)malloc(sizeof(Sauvegarde));
|
|
|
|
memset(SAUVEGARDE, 0, sizeof(Sauvegarde));
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-10-19 11:19:50 +00:00
|
|
|
essai0 = (int16 *)BUFFERTAPE;
|
|
|
|
essai1 = (int16 *)(BUFFERTAPE + 25000);
|
|
|
|
essai2 = (int16 *)(BUFFERTAPE + 50000);
|
2012-10-20 06:06:57 +00:00
|
|
|
BufLig = (int16 *)(BUFFERTAPE + 75000);
|
2012-09-08 08:45:22 +00:00
|
|
|
largeur_boite = 240;
|
|
|
|
TEXTE_FORMATE = 300;
|
|
|
|
|
2012-12-12 07:05:04 +00:00
|
|
|
_vm->_eventsManager._objectBuf = allocMemory(2500);
|
|
|
|
INVENTAIRE_OBJET = allocMemory(2500);
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-10-10 10:03:29 +00:00
|
|
|
ADR_FICHIER_OBJ = g_PTRNUL;
|
|
|
|
FORETSPR = g_PTRNUL;
|
2012-11-18 02:42:44 +00:00
|
|
|
FORET = false;
|
2012-09-08 08:45:22 +00:00
|
|
|
|
2012-12-12 07:05:04 +00:00
|
|
|
cache_souris = allocMemory(2500);
|
2012-10-10 10:03:29 +00:00
|
|
|
GESTE = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
GESTE_FLAG = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::HOPKINS_DATA() {
|
2012-10-18 20:15:17 +00: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 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_old_anim = -1;
|
|
|
|
g_old_sens = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::INIT_ANIM() {
|
|
|
|
for (int idx = 0; idx < 35; ++idx) {
|
2012-10-10 10:03:29 +00:00
|
|
|
Bqe_Anim[idx].data = g_PTRNUL;
|
2012-09-16 07:21:24 +00:00
|
|
|
Bqe_Anim[idx].field4 = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 8; ++idx) {
|
2012-10-10 10:03:29 +00:00
|
|
|
Bank[idx].data = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
Bank[idx].field4 = 0;
|
2012-09-16 07:21:24 +00:00
|
|
|
Bank[idx].filename1 = "";
|
|
|
|
Bank[idx].fileHeader = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
Bank[idx].field1C = 0;
|
2012-09-16 07:21:24 +00:00
|
|
|
Bank[idx].filename2 = "";
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::INIT_VBOB() {
|
|
|
|
for (int idx = 0; idx < 30; ++idx) {
|
|
|
|
VBob[idx].field4 = 0;
|
2012-10-24 23:43:31 +00:00
|
|
|
VBob[idx].xp = 0;
|
|
|
|
VBob[idx].yp = 0;
|
|
|
|
VBob[idx].frameIndex = 0;
|
2012-09-08 08:45:22 +00:00
|
|
|
VBob[idx].fieldC = 0;
|
2012-10-24 23:43:31 +00:00
|
|
|
VBob[idx].surface = g_PTRNUL;
|
|
|
|
VBob[idx].spriteData = g_PTRNUL;
|
|
|
|
VBob[idx].oldSpriteData = g_PTRNUL;
|
2012-09-08 08:45:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-28 23:33:42 +00:00
|
|
|
void Globals::CLEAR_VBOB() {
|
|
|
|
for (int idx = 0; idx < 30; ++idx) {
|
|
|
|
VBob[idx].field4 = 0;
|
2012-10-24 23:43:31 +00:00
|
|
|
VBob[idx].xp = 0;
|
|
|
|
VBob[idx].yp = 0;
|
|
|
|
VBob[idx].frameIndex = 0;
|
2012-09-28 23:33:42 +00:00
|
|
|
VBob[idx].fieldC = 0;
|
2012-12-12 07:05:04 +00:00
|
|
|
VBob[idx].surface = freeMemory(VBob[idx].surface);
|
2012-10-24 23:43:31 +00:00
|
|
|
VBob[idx].spriteData = g_PTRNUL;
|
|
|
|
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-09-08 11:43:33 +00:00
|
|
|
void Globals::CHARGE_OBJET() {
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(HOPSYSTEM, "OBJET.DAT");
|
|
|
|
byte *data = _vm->_fileManager.loadFile(NFICHIER);
|
2012-09-08 11:43:33 +00:00
|
|
|
byte *srcP = data;
|
|
|
|
|
|
|
|
for (int idx = 0; idx < 300; ++idx) {
|
|
|
|
ObjetW[idx].field0 = *srcP++;
|
|
|
|
ObjetW[idx].field1 = *srcP++;
|
|
|
|
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 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
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Reset Cache
|
2012-09-28 12:15:59 +00:00
|
|
|
void Globals::RESET_CACHE() {
|
|
|
|
|
|
|
|
for (int idx = 1; idx <= 5; ++idx) {
|
2012-12-12 07:05:04 +00:00
|
|
|
CACHE_BANQUE[idx] = freeMemory(CACHE_BANQUE[idx]);
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int idx = 0; idx <= 20; ++idx) {
|
2012-10-10 10:03:29 +00:00
|
|
|
Cache[idx].fieldC = g_PTRNUL;
|
2012-09-28 12:15:59 +00:00
|
|
|
Cache[idx].field0 = 0;
|
|
|
|
Cache[idx].field4 = 0;
|
|
|
|
Cache[idx].field2 = 0;
|
|
|
|
Cache[idx].fieldA = 0;
|
|
|
|
Cache[idx].field6 = 0;
|
|
|
|
Cache[idx].field8 = 0;
|
|
|
|
Cache[idx].field10 = 0;
|
|
|
|
Cache[idx].field12 = 0;
|
|
|
|
Cache[idx].field14 = 0;
|
|
|
|
}
|
|
|
|
|
2012-10-28 21:38:34 +00:00
|
|
|
CACHEFLAG = false;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::CACHE_ON() {
|
2012-10-28 21:38:34 +00:00
|
|
|
CACHEFLAG = true;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
2012-10-20 16:59:06 +00:00
|
|
|
|
2012-09-30 11:02:39 +00:00
|
|
|
// TODO: Find why some calls have a parameter value
|
|
|
|
void Globals::CACHE_OFF(int v1) {
|
2012-10-28 21:38:34 +00:00
|
|
|
CACHEFLAG = false;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::CACHE_SUB(int idx) {
|
|
|
|
Cache[idx].fieldA = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::CACHE_ADD(int idx) {
|
|
|
|
Cache[idx].fieldA = 1;
|
|
|
|
}
|
|
|
|
|
2012-10-20 16:59:06 +00:00
|
|
|
// Load Cache
|
2012-09-28 12:15:59 +00:00
|
|
|
void Globals::CHARGE_CACHE(const Common::String &file) {
|
2012-10-10 10:03:29 +00:00
|
|
|
byte *v2 = g_PTRNUL;
|
2012-12-14 00:49:22 +00:00
|
|
|
byte *spriteData;
|
|
|
|
byte *ptr;
|
2012-09-28 12:15:59 +00:00
|
|
|
Common::String v16;
|
|
|
|
Common::File f;
|
|
|
|
|
|
|
|
RESET_CACHE();
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(HOPLINK, file);
|
|
|
|
ptr = _vm->_fileManager.loadFile(NFICHIER);
|
2012-09-28 12:15:59 +00:00
|
|
|
v16 = Common::String((const char *)ptr);
|
|
|
|
|
2012-12-09 19:22:12 +00:00
|
|
|
_vm->_fileManager.constructFilename(HOPLINK, v16);
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-10-13 04:23:29 +00:00
|
|
|
if (f.exists(NFICHIER)) {
|
2012-12-09 19:22:12 +00:00
|
|
|
spriteData = _vm->_fileManager.loadFile(NFICHIER);
|
2012-09-28 12:15:59 +00:00
|
|
|
CACHE_BANQUE[1] = spriteData;
|
2012-11-23 21:21:35 +00:00
|
|
|
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;
|
2012-10-11 11:58:04 +00:00
|
|
|
Cache[v6].field14 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 4);
|
2012-09-28 12:15:59 +00:00
|
|
|
Cache[v6].field2 = v11;
|
|
|
|
Cache[v6].field0 = v4;
|
|
|
|
Cache[v6].field4 = v5;
|
|
|
|
Cache[v6].field12 = 1;
|
2012-10-10 10:03:29 +00:00
|
|
|
if (spriteData == g_PTRNUL) {
|
2012-11-23 21:21:35 +00:00
|
|
|
Cache[i].fieldA = 0;
|
2012-09-28 12:15:59 +00:00
|
|
|
} else {
|
2012-12-10 06:54:03 +00:00
|
|
|
int v8 = _vm->_objectsManager.getWidth(spriteData, v11);
|
|
|
|
int v9 = _vm->_objectsManager.getHeight(spriteData, v11);
|
2012-11-23 21:21:35 +00:00
|
|
|
Cache[i].fieldC = spriteData;
|
|
|
|
Cache[i].field6 = v8;
|
|
|
|
Cache[i].field8 = v9;
|
|
|
|
Cache[i].fieldA = 1;
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
2012-12-14 00:49:22 +00:00
|
|
|
|
2012-11-23 21:21:35 +00:00
|
|
|
if ( !Cache[i].field0 && !Cache[i].field4 && !Cache[i].field2)
|
|
|
|
Cache[i].fieldA = 0;
|
2012-09-28 12:15:59 +00:00
|
|
|
v15 += 5;
|
2012-11-23 21:21:35 +00:00
|
|
|
}
|
2012-09-28 12:15:59 +00:00
|
|
|
CACHE_ON();
|
|
|
|
v2 = ptr;
|
|
|
|
}
|
2012-12-12 07:05:04 +00:00
|
|
|
freeMemory(v2);
|
2012-09-28 12:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Globals::B_CACHE_OFF(int idx) {
|
|
|
|
Bob[idx].field34 = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-07 12:20:05 +00:00
|
|
|
} // End of namespace Hopkins
|