aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2012-09-08 21:43:33 +1000
committerPaul Gilbert2012-09-08 21:43:33 +1000
commitca84b2737f6bd1c6c971d5ff7451cfb164afadb8 (patch)
treeb7fd3331751f33e61f34f9da3423ee1e56ea4da6 /engines
parentb8086aabc53f2359f9a6952f083701b4a01282be (diff)
downloadscummvm-rg350-ca84b2737f6bd1c6c971d5ff7451cfb164afadb8.tar.gz
scummvm-rg350-ca84b2737f6bd1c6c971d5ff7451cfb164afadb8.tar.bz2
scummvm-rg350-ca84b2737f6bd1c6c971d5ff7451cfb164afadb8.zip
HOPKINS: Add object loading
Diffstat (limited to 'engines')
-rw-r--r--engines/hopkins/files.cpp5
-rw-r--r--engines/hopkins/files.h1
-rw-r--r--engines/hopkins/globals.cpp93
-rw-r--r--engines/hopkins/globals.h21
-rw-r--r--engines/hopkins/graphics.cpp88
-rw-r--r--engines/hopkins/graphics.h45
-rw-r--r--engines/hopkins/hopkins.cpp15
-rw-r--r--engines/hopkins/hopkins.h1
-rw-r--r--engines/hopkins/module.mk4
-rw-r--r--engines/hopkins/sound.cpp32
-rw-r--r--engines/hopkins/sound.h38
11 files changed, 337 insertions, 6 deletions
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
index 1d9c3adb54..40cd238d1e 100644
--- a/engines/hopkins/files.cpp
+++ b/engines/hopkins/files.cpp
@@ -158,4 +158,9 @@ void FileManager::CONSTRUIT_FICHIER(const Common::String &hop, const Common::Str
GLOBALS.NFICHIER = Common::String::format("%s/%s", hop.c_str(), file.c_str());
}
+byte *FileManager::LIBERE_FICHIER(byte *ptr) {
+ free(ptr);
+ return PTRNUL;
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h
index b90b80b3c5..52412c11e8 100644
--- a/engines/hopkins/files.h
+++ b/engines/hopkins/files.h
@@ -42,6 +42,7 @@ public:
static void F_Censure();
static int CONSTRUIT_SYSTEM(const Common::String &file);
static void CONSTRUIT_FICHIER(const Common::String &hop, const Common::String &file);
+ static byte *LIBERE_FICHIER(byte *ptr);
};
} // End of namespace Hopkins
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp
index 1c47b9b275..f6db20fe8f 100644
--- a/engines/hopkins/globals.cpp
+++ b/engines/hopkins/globals.cpp
@@ -22,6 +22,8 @@
#include "common/textconsole.h"
#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/files.h"
namespace Hopkins {
@@ -65,6 +67,18 @@ Globals::Globals() {
BufLig = NULL;
Bufferdecor = NULL;
ADR_FICHIER_OBJ = NULL;
+
+ // Reset flags
+ XFULLSCREEN = false;
+ XFORCE16 = false;
+ XFORCE8 = false;
+ CARD_SB = false;
+ SOUNDOFF = false;
+ MUSICOFF = false;
+ VOICEOFF = false;
+ CENSURE = false;
+ GESTE_FLAG = false;
+ redraw = false;
}
Globals::~Globals() {
@@ -618,4 +632,83 @@ void Globals::INIT_VBOB() {
}
}
+void Globals::CHARGE_OBJET() {
+ FileManager::CONSTRUIT_SYSTEM("OBJET.DAT");
+ byte *data = FileManager::CHARGE_FICHIER(NFICHIER);
+ 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);
+}
+
+byte *Globals::CHANGE_OBJET(int objIndex) {
+ byte *result = CAPTURE_OBJET(objIndex, 1);
+ Bufferobjet = result;
+ Nouv_objet = 1;
+ OBJET_EN_COURS = objIndex;
+ return result;
+}
+
+byte *Globals::CAPTURE_OBJET(int objIndex, int mode) {
+ byte *result = NULL;
+ byte *dataP;
+
+ dataP = 0;
+ int v2 = ObjetW[objIndex].field0;
+ int v3 = ObjetW[objIndex].field1;
+
+ if (mode == 1)
+ ++v3;
+ if (v2 != NUM_FICHIER_OBJ) {
+ if (ADR_FICHIER_OBJ != PTRNUL)
+ ObjectManager::DEL_FICHIER_OBJ();
+ if (v2 == 1) {
+ FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR");
+ ADR_FICHIER_OBJ = ObjectManager::CHARGE_SPRITE(NFICHIER);
+ }
+ NUM_FICHIER_OBJ = v2;
+ }
+
+ int width = ObjectManager::Get_Largeur(ADR_FICHIER_OBJ, v3);
+ int height = ObjectManager::Get_Hauteur(ADR_FICHIER_OBJ, v3);
+ OBJL = width;
+ OBJH = height;
+
+ switch (mode) {
+ case 0:
+ dataP = (byte *)malloc(height * width);
+ if (dataP == PTRNUL)
+ error("CAPTURE_OBJET");
+
+ ObjectManager::capture_mem_sprite(ADR_FICHIER_OBJ, dataP, v3);
+ break;
+
+ case 1:
+ ObjectManager::sprite_alone(ADR_FICHIER_OBJ, Bufferobjet, v3);
+ result = Bufferobjet;
+ break;
+
+ case 3:
+ ObjectManager::capture_mem_sprite(ADR_FICHIER_OBJ, INVENTAIRE_OBJET, v3);
+ result = INVENTAIRE_OBJET;
+ break;
+
+ default:
+ result = dataP;
+ break;
+ }
+
+ return result;
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h
index b9fa044a93..47100bb7ba 100644
--- a/engines/hopkins/globals.h
+++ b/engines/hopkins/globals.h
@@ -92,6 +92,17 @@ struct VBobItem {
byte *field1C;
};
+struct ObjetWItem {
+ byte field0;
+ byte field1;
+ byte field2;
+ byte field3;
+ byte field4;
+ byte field5;
+ byte field6;
+ byte field7;
+};
+
/**
* Engine Globals
*/
@@ -157,6 +168,7 @@ public:
BgeAnimItem Bge_Anim[35];
BankItem Bank[8];
VBobItem VBob[35];
+ ObjetWItem ObjetW[300];
byte *Winventaire;
byte *texte_tmp;
int texte_long;
@@ -185,6 +197,9 @@ public:
byte *BufLig;
byte *Bufferdecor;
byte *ADR_FICHIER_OBJ;
+ bool redraw;
+ int OBJL, OBJH;
+ int Nouv_objet;
Globals();
~Globals();
@@ -194,8 +209,14 @@ public:
void HOPKINS_DATA();
void INIT_ANIM();
void INIT_VBOB();
+ void CHARGE_OBJET();
+ byte *CHANGE_OBJET(int objIndex);
+ byte *CAPTURE_OBJET(int objIndex, int mode);
};
+// TODO: The original pointed PTRNUL to a specially allocated memory block. If this proves
+// to be necsesary, all malloc calls will need to be replaced with a stub that sets the
+// result to PTRNUL if the memory block can't be allocated
#define PTRNUL (byte *)NULL
} // End of namespace Hopkins
diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp
new file mode 100644
index 0000000000..01a673f020
--- /dev/null
+++ b/engines/hopkins/graphics.cpp
@@ -0,0 +1,88 @@
+/* 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 "common/system.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+int ObjectManager::Get_Largeur(const byte *objectData, int objIndex) {
+ const byte *objP = objectData + 3;
+ for (int i = objIndex; i; --i )
+ objP += READ_LE_UINT32(objP) + 16;
+
+ return READ_LE_UINT16(objP + 4);
+}
+
+int ObjectManager::Get_Hauteur(const byte *objectData, int objIndex) {
+ const byte *objP = objectData + 3;
+ for (int i = objIndex; i; --i)
+ objP += READ_LE_UINT32(objP) + 16;
+
+ return READ_LE_UINT16(objP + 6);
+}
+
+int ObjectManager::sprite_alone(const byte *objectData, byte *sprite, int objIndex) {
+ const byte *objP = objectData + 3;
+ for (int i = objIndex; i; --i) {
+ objP += READ_LE_UINT32(objP) + 16;
+ }
+
+ objP += 4;
+ int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2);
+
+ memcpy(sprite + 3, objP - 4, result + 16);
+ return result;
+}
+
+byte *ObjectManager::DEL_FICHIER_OBJ() {
+ GLOBALS.NUM_FICHIER_OBJ = 0;
+ if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL)
+ GLOBALS.ADR_FICHIER_OBJ = FileManager::LIBERE_FICHIER(GLOBALS.ADR_FICHIER_OBJ);
+
+ byte *result = PTRNUL;
+ GLOBALS.ADR_FICHIER_OBJ = PTRNUL;
+ return result;
+}
+
+byte *ObjectManager::CHARGE_SPRITE(const Common::String &file) {
+ FileManager::DMESS1();
+ return FileManager::CHARGE_FICHIER(file);
+}
+
+int ObjectManager::capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex) {
+ const byte *objP = objectData + 3;
+ for (int i = objIndex; i; --i) {
+ objP += READ_LE_UINT32(objP) + 16;
+ }
+
+ objP += 4;
+ int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2);
+
+ memcpy(sprite, objP + 12, result);
+ return result;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h
new file mode 100644
index 0000000000..523ab28575
--- /dev/null
+++ b/engines/hopkins/graphics.h
@@ -0,0 +1,45 @@
+/* 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.
+ *
+ */
+
+#ifndef HOPKINS_GRAPHICS_H
+#define HOPKINS_GRAPHICS_H
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+class ObjectManager {
+public:
+ static int Get_Largeur(const byte *objectData, int objIndex);
+ static int Get_Hauteur(const byte *objectData, int objIndex);
+ static int sprite_alone(const byte *objectData, byte *sprite, int objIndex);
+ static byte *DEL_FICHIER_OBJ();
+
+ static byte *CHARGE_SPRITE(const Common::String &file);
+ static int capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_GRAPHICS_H */
diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp
index 8321457374..ecadd25953 100644
--- a/engines/hopkins/hopkins.cpp
+++ b/engines/hopkins/hopkins.cpp
@@ -28,6 +28,7 @@
#include "engines/util.h"
#include "hopkins/hopkins.h"
#include "hopkins/files.h"
+#include "hopkins/sound.h"
namespace Hopkins {
@@ -54,13 +55,13 @@ Common::Error HopkinsEngine::run() {
GLOBALS.setConfig();
FileManager::F_Censure();
INIT_SYSTEM();
+ Init_Interrupt();
+
+ SoundManager::WSOUND_INIT();
+
+ GLOBALS.CHARGE_OBJET();
/*
- REDRAW = 0;
- SDL_WM_SetCaption("Hopkins FBI for Linux ", "LINUX");
- Init_Interrupt();
- WSOUND_INIT();
- CHARGE_OBJET();
CHANGE_OBJET(14);
AJOUTE_OBJET(14);
HELICO = 0;
@@ -573,4 +574,8 @@ void HopkinsEngine::INIT_SYSTEM() {
GLOBALS.lOldItCounter = 0;
}
+void HopkinsEngine::Init_Interrupt() {
+ // TODO: Determine whether the timer is needed
+}
+
} // End of namespace Hopkins
diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h
index e9976e5be4..641be0113a 100644
--- a/engines/hopkins/hopkins.h
+++ b/engines/hopkins/hopkins.h
@@ -72,6 +72,7 @@ private:
void processIniParams(Common::StringMap &iniParams);
void INIT_SYSTEM();
+ void Init_Interrupt();
protected:
// Engine APIs
virtual Common::Error run();
diff --git a/engines/hopkins/module.mk b/engines/hopkins/module.mk
index 702a8c0a8f..2bff26dbb2 100644
--- a/engines/hopkins/module.mk
+++ b/engines/hopkins/module.mk
@@ -4,8 +4,10 @@ MODULE_OBJS := \
detection.o \
events.o \
files.o \
+ graphics.o \
globals.o \
- hopkins.o
+ hopkins.o \
+ sound.o
# This module can be built as a plugin
ifeq ($(ENABLE_HOPKINS), DYNAMIC_PLUGIN)
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
new file mode 100644
index 0000000000..f11bc25cae
--- /dev/null
+++ b/engines/hopkins/sound.cpp
@@ -0,0 +1,32 @@
+/* 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 "common/system.h"
+#include "hopkins/sound.h"
+
+namespace Hopkins {
+
+void SoundManager::WSOUND_INIT() {
+ // TODO: WSOUND_INIT
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h
new file mode 100644
index 0000000000..15469ff8b5
--- /dev/null
+++ b/engines/hopkins/sound.h
@@ -0,0 +1,38 @@
+/* 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.
+ *
+ */
+
+#ifndef HOPKINS_SOUND_H
+#define HOPKINS_SOUND_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+class SoundManager {
+public:
+ static void WSOUND_INIT();
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_SOUND_H */