aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hopkins')
-rw-r--r--engines/hopkins/anim.cpp1340
-rw-r--r--engines/hopkins/anim.h59
-rw-r--r--engines/hopkins/debugger.cpp38
-rw-r--r--engines/hopkins/debugger.h45
-rw-r--r--engines/hopkins/detection.cpp185
-rw-r--r--engines/hopkins/detection_tables.h106
-rw-r--r--engines/hopkins/dialogs.cpp752
-rw-r--r--engines/hopkins/dialogs.h67
-rw-r--r--engines/hopkins/events.cpp501
-rw-r--r--engines/hopkins/events.h89
-rw-r--r--engines/hopkins/files.cpp323
-rw-r--r--engines/hopkins/files.h64
-rw-r--r--engines/hopkins/font.cpp497
-rw-r--r--engines/hopkins/font.h88
-rw-r--r--engines/hopkins/globals.cpp595
-rw-r--r--engines/hopkins/globals.h483
-rw-r--r--engines/hopkins/graphics.cpp2507
-rw-r--r--engines/hopkins/graphics.h192
-rw-r--r--engines/hopkins/hopkins.cpp1015
-rw-r--r--engines/hopkins/hopkins.h147
-rw-r--r--engines/hopkins/lines.cpp3927
-rw-r--r--engines/hopkins/lines.h98
-rw-r--r--engines/hopkins/menu.cpp434
-rw-r--r--engines/hopkins/menu.h48
-rw-r--r--engines/hopkins/module.mk28
-rw-r--r--engines/hopkins/objects.cpp5824
-rw-r--r--engines/hopkins/objects.h248
-rw-r--r--engines/hopkins/saveload.cpp254
-rw-r--r--engines/hopkins/saveload.h71
-rw-r--r--engines/hopkins/script.cpp2586
-rw-r--r--engines/hopkins/script.h50
-rw-r--r--engines/hopkins/sound.cpp114
-rw-r--r--engines/hopkins/sound.h73
-rw-r--r--engines/hopkins/talk.cpp1349
-rw-r--r--engines/hopkins/talk.h75
35 files changed, 24272 insertions, 0 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp
new file mode 100644
index 0000000000..5102a883a6
--- /dev/null
+++ b/engines/hopkins/anim.cpp
@@ -0,0 +1,1340 @@
+/* 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 "graphics/palette.h"
+#include "common/file.h"
+#include "common/rect.h"
+#include "engines/util.h"
+#include "hopkins/anim.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+AnimationManager::AnimationManager() {
+ CLS_ANM = false;
+ NO_SEQ = false;
+}
+
+// Play Anim
+void AnimationManager::PLAY_ANM(const Common::String &filename, uint32 rate1, uint32 rate2, uint32 rate3) {
+ int v4;
+ int v5;
+ bool hasScreenCopy;
+ byte *screenCopy = NULL;
+ byte *v10 = NULL;
+ int v13;
+ byte *ptr = NULL;
+ size_t nbytes;
+ Common::File f;
+
+ if (_vm->shouldQuit())
+ return;
+
+ hasScreenCopy = false;
+ while (!_vm->shouldQuit()) {
+LABEL_2:
+ v10 = _vm->_graphicsManager.VESA_SCREEN;
+ ptr = _vm->_globals.dos_malloc2(0x14u);
+
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANM, filename);
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("File not found - %s", _vm->_globals.NFICHIER.c_str());
+
+ f.skip(6);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.skip(4);
+ nbytes = f.readUint32LE();
+ f.skip(14);
+ f.read(v10, nbytes);
+
+ if (CLS_ANM == true) {
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ }
+ if (_vm->_graphicsManager.WinScan / _vm->_graphicsManager.Winbpp > 640) {
+ hasScreenCopy = true;
+ screenCopy = _vm->_globals.dos_malloc2(0x4B000u);
+ memcpy(screenCopy, v10, 0x4B000u);
+ }
+ if (NO_SEQ) {
+ if (hasScreenCopy)
+ memcpy(screenCopy, _vm->_graphicsManager.VESA_BUFFER, 0x4B000u);
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ } else {
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (hasScreenCopy)
+ _vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(v10, 0, 0, 640, 480, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (hasScreenCopy)
+ _vm->_graphicsManager.m_scroll2A(screenCopy, 0, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(v10, 0, 0, 640, 480, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ }
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_eventsManager.ESC_KEY = false;
+ _vm->_soundManager.LOAD_ANM_SOUND();
+ if (_vm->_globals.iRegul != 1)
+ break;
+ while (!_vm->shouldQuit()) {
+ if (_vm->_eventsManager.ESC_KEY == true)
+ goto LABEL_58;
+ if (REDRAW_ANIM() == true)
+ break;
+ _vm->_eventsManager.CONTROLE_MES();
+ if (_vm->_eventsManager.lItCounter >= rate1)
+ goto LABEL_25;
+ }
+LABEL_53:
+ if (_vm->_graphicsManager.NOLOCK == true)
+ goto LABEL_58;
+ _vm->_globals.dos_free2(ptr);
+ f.close();
+
+ if (hasScreenCopy == 1)
+LABEL_55:
+ screenCopy = _vm->_globals.dos_free2(screenCopy);
+ }
+LABEL_25:
+ _vm->_eventsManager.lItCounter = 0;
+ v4 = 0;
+ v13 = 0;
+ while (!_vm->shouldQuit()) {
+ ++v13;
+ _vm->_soundManager.PLAY_ANM_SOUND(v13);
+
+ if (f.read(ptr, 16) != 16)
+ v4 = -1;
+
+ if (strncmp((char *)ptr, "IMAGE=", 6))
+ v4 = -1;
+ if (v4)
+ goto LABEL_49;
+
+ f.read(v10, READ_LE_UINT32(ptr + 8));
+ if (_vm->_globals.iRegul == 1)
+ break;
+LABEL_38:
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_graphicsManager.DD_Lock();
+ if (hasScreenCopy) {
+ if (*v10 != (byte)-4) {
+ _vm->_graphicsManager.Copy_WinScan_Vbe3(v10, screenCopy);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2A(screenCopy, 0, 0, 640, 480, 0, 0);
+ }
+ } else if (*v10 != (byte)-4) {
+ if (_vm->_graphicsManager.Winbpp == 1)
+ _vm->_graphicsManager.Copy_Video_Vbe3(v10);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.Copy_Video_Vbe16(v10);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ _vm->_soundManager.VERIF_SOUND();
+LABEL_49:
+ if (v4 == -1) {
+ if (_vm->_globals.iRegul == 1) {
+ while (_vm->_eventsManager.ESC_KEY != true) {
+ if (REDRAW_ANIM() == true)
+ goto LABEL_53;
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ if (_vm->_eventsManager.lItCounter >= rate3)
+ goto LABEL_57;
+ }
+ } else {
+LABEL_57:
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_soundManager.VERIF_SOUND();
+ }
+ goto LABEL_58;
+ }
+ }
+ while (!_vm->shouldQuit() && _vm->_eventsManager.ESC_KEY != true) {
+ if (REDRAW_ANIM() == true) {
+ if (_vm->_graphicsManager.NOLOCK == true)
+ break;
+ _vm->_globals.dos_free2(ptr);
+ f.close();
+
+ if (1 /*hasScreenCopy <= 640 */)
+ goto LABEL_2;
+ goto LABEL_55;
+ }
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ if (_vm->_eventsManager.lItCounter >= rate2)
+ goto LABEL_38;
+ }
+LABEL_58:
+ if (_vm->_graphicsManager.FADE_LINUX == 2 && !hasScreenCopy) {
+ screenCopy = _vm->_globals.dos_malloc2(0x4B000u);
+
+ f.seek(0);
+ f.skip(6);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.skip(4);
+ nbytes = f.readUint32LE();
+ f.skip(14);
+ f.read(v10, nbytes);
+
+ memcpy(screenCopy, v10, 0x4B000u);
+
+ v5 = 0;
+ do {
+ memset(ptr, 0, 0x13u);
+ if (f.read(ptr, 16) != 16)
+ v5 = -1;
+
+ if (strncmp((char *)ptr, "IMAGE=", 6))
+ v5 = -1;
+ if (!v5) {
+ f.read(v10, READ_LE_UINT32(ptr + 8));
+ if (*v10 != (byte)-4)
+ _vm->_graphicsManager.Copy_WinScan_Vbe3(v10, screenCopy);
+ }
+ } while (v5 != -1);
+ _vm->_graphicsManager.FADE_OUTW_LINUX(screenCopy);
+ screenCopy = _vm->_globals.dos_free2(screenCopy);
+ }
+ if (hasScreenCopy == 1) {
+ if (_vm->_graphicsManager.FADE_LINUX == 2)
+ _vm->_graphicsManager.FADE_OUTW_LINUX(screenCopy);
+ _vm->_globals.dos_free2(screenCopy);
+ }
+
+ _vm->_graphicsManager.FADE_LINUX = 0;
+ f.close();
+ _vm->_globals.dos_free2(ptr);
+ _vm->_graphicsManager.NOLOCK = false;
+}
+
+// Play Anim 2
+void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint32 a3, uint32 a4) {
+ byte *v4;
+ int v5;
+ int v6;
+ int v8;
+ byte *ptr;
+ byte *ptra;
+ int v11;
+ byte *v12;
+ byte *v13;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ char v21;
+ size_t nbytes;
+ byte buf[6];
+ char v25;
+ Common::File f;
+
+ if (_vm->shouldQuit())
+ return;
+
+ v8 = 0;
+ while (!_vm->shouldQuit()) {
+ v17 = 0;
+ v16 = 0;
+ v19 = 0;
+ v18 = 0;
+ v20 = 1;
+ memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u);
+
+ _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
+ if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ if (_vm->_graphicsManager.nbrligne == 1280)
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+ if (!_vm->_graphicsManager.nbrligne)
+ _vm->_graphicsManager.ofscroll = 0;
+
+ v12 = _vm->_graphicsManager.VESA_SCREEN;
+ v13 = _vm->_globals.dos_malloc2(0x14u);
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANM, filename);
+
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("Error opening file - %s", _vm->_globals.NFICHIER.c_str());
+
+ f.read(&buf, 6);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.read(&buf, 4);
+ nbytes = f.readUint32LE();
+ v21 = f.readUint32LE();
+ v20 = f.readUint16LE();
+ v19 = f.readUint16LE();
+ v18 = f.readUint16LE();
+ v17 = f.readUint16LE();
+ v16 = f.readUint16LE();
+
+ f.read(v12, nbytes);
+
+ _vm->_graphicsManager.Cls_Pal();
+ v11 = _vm->_graphicsManager.SCROLL;
+ _vm->_graphicsManager.SCANLINE(SCREEN_WIDTH * 2);
+ _vm->_graphicsManager.SCROLL_ECRAN(0);
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.max_x = SCREEN_WIDTH;
+ if (_vm->_graphicsManager.WinScan / _vm->_graphicsManager.Winbpp > SCREEN_WIDTH) {
+ v8 = 1;
+ ptr = _vm->_globals.dos_malloc2(0x4B000u);
+ memcpy(ptr, v12, 0x4B000u);
+ }
+ if (_vm->_animationManager.NO_SEQ) {
+ if (v8 == 1)
+ memcpy(ptr, _vm->_graphicsManager.VESA_BUFFER, 0x4B000u);
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ } else {
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (v8)
+ _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(v12, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (v8)
+ _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(v12, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ }
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_eventsManager.ESC_KEY = false;
+ _vm->_soundManager.LOAD_ANM_SOUND();
+ if (_vm->_globals.iRegul != 1)
+ break;
+ while (1) {
+ if (_vm->_eventsManager.ESC_KEY == true)
+ goto LABEL_114;
+ if (REDRAW_ANIM() == true)
+ break;
+ _vm->_eventsManager.CONTROLE_MES();
+ if (_vm->_eventsManager.lItCounter >= a2)
+ goto LABEL_48;
+ }
+ if (_vm->_graphicsManager.NOLOCK == true)
+ goto LABEL_114;
+ if (v8 == 1)
+ ptr = _vm->_globals.dos_free2(ptr);
+ _vm->_globals.dos_free2(v13);
+ f.close();
+
+ _vm->_fileManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u);
+ v4 = &_vm->_graphicsManager.Palette[769];
+ _vm->_graphicsManager.Cls_Pal();
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.SCROLL = v11;
+ _vm->_graphicsManager.SCROLL_ECRAN(v11);
+ if (_vm->_graphicsManager.DOUBLE_ECRAN == true) {
+ _vm->_graphicsManager.SCANLINE(0x500u);
+ _vm->_graphicsManager.max_x = 1280;
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else {
+ _vm->_eventsManager.souris_max();
+ _vm->_graphicsManager.SCANLINE(SCREEN_WIDTH * 2);
+ _vm->_graphicsManager.max_x = SCREEN_WIDTH;
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+LABEL_111:
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ }
+LABEL_112:
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_eventsManager.VBL();
+ _vm->_graphicsManager.FADE_INS();
+ }
+LABEL_48:
+ _vm->_eventsManager.lItCounter = 0;
+ v5 = 0;
+ v15 = 0;
+ while (1) {
+ ++v15;
+ _vm->_soundManager.PLAY_ANM_SOUND(v15);
+ memset(&buf, 0, 6u);
+ memset(v13, 0, 0x13u);
+
+ if (f.read(v13, 0x10) != 0x10)
+ v5 = -1;
+
+ v25 = 0;
+ if (strncmp((const char *)v13, "IMAGE=", 6))
+ v5 = -1;
+
+ if (v5)
+ goto LABEL_88;
+ f.read(v12, READ_LE_UINT32(v13 + 2));
+ if (_vm->_globals.iRegul == 1)
+ break;
+LABEL_77:
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_graphicsManager.DD_Lock();
+ if (v8) {
+ if (*v12 != (byte)-4) {
+ _vm->_graphicsManager.Copy_WinScan_Vbe3(v12, ptr);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else if (*v12 != (byte)-4) {
+ if (_vm->_graphicsManager.Winbpp == 1)
+ _vm->_graphicsManager.Copy_Video_Vbe3(v12);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.Copy_Video_Vbe16(v12);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ _vm->_soundManager.VERIF_SOUND();
+LABEL_88:
+ if (v5 == -1) {
+ if (_vm->_globals.iRegul == 1) {
+ while (_vm->_eventsManager.ESC_KEY != true) {
+ if (REDRAW_ANIM() == true) {
+ if (_vm->_graphicsManager.NOLOCK == true)
+ goto LABEL_114;
+ if (v8 == 1)
+ ptr = _vm->_globals.dos_free2(ptr);
+ _vm->_globals.dos_free2(v13);
+ f.close();
+
+ _vm->_fileManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u);
+ v4 = &_vm->_graphicsManager.Palette[769];
+ _vm->_graphicsManager.Cls_Pal();
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.SCROLL = v11;
+ _vm->_graphicsManager.SCROLL_ECRAN(v11);
+ if (_vm->_graphicsManager.DOUBLE_ECRAN == true) {
+ _vm->_graphicsManager.SCANLINE(0x500u);
+ _vm->_graphicsManager.max_x = 1280;
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else {
+ _vm->_eventsManager.souris_max();
+ _vm->_graphicsManager.SCANLINE(SCREEN_WIDTH * 2);
+ _vm->_graphicsManager.max_x = SCREEN_WIDTH;
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ goto LABEL_111;
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ }
+ goto LABEL_112;
+ }
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ if (_vm->_eventsManager.lItCounter >= a4)
+ goto LABEL_114;
+ }
+ }
+ goto LABEL_114;
+ }
+ }
+ while (_vm->_eventsManager.ESC_KEY != true) {
+ if (REDRAW_ANIM() == true) {
+ if (_vm->_graphicsManager.NOLOCK == true)
+ break;
+ if (v8 == 1)
+ ptr = _vm->_globals.dos_free2(ptr);
+ _vm->_globals.dos_free2(v13);
+ f.close();
+
+ _vm->_fileManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u);
+ v4 = &_vm->_graphicsManager.Palette[769];
+ _vm->_graphicsManager.Cls_Pal();
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.SCROLL = v11;
+ _vm->_graphicsManager.SCROLL_ECRAN(v11);
+ if (_vm->_graphicsManager.DOUBLE_ECRAN == true) {
+ _vm->_graphicsManager.SCANLINE(0x500u);
+ _vm->_graphicsManager.max_x = 1280;
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else {
+ _vm->_eventsManager.souris_max();
+ _vm->_graphicsManager.SCANLINE(SCREEN_WIDTH * 2);
+ _vm->_graphicsManager.max_x = SCREEN_WIDTH;
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ goto LABEL_111;
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ }
+ goto LABEL_112;
+ }
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ if (_vm->_eventsManager.lItCounter >= a3)
+ goto LABEL_77;
+ }
+LABEL_114:
+ _vm->_graphicsManager.NOLOCK = false;
+ f.close();
+
+ if (_vm->_graphicsManager.FADE_LINUX == 2 && !v8) {
+ ptra = _vm->_globals.dos_malloc2(0x4B000u);
+
+ f.seek(0);
+ f.read(&buf, 6);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.read(&buf, 4u);
+ nbytes = f.readUint32LE();
+ v21 = f.readUint32LE();
+ v20 = f.readUint16LE();
+ v19 = f.readUint16LE();
+ v18 = f.readUint16LE();
+ v17 = f.readUint16LE();
+ v16 = f.readUint16LE();
+ f.read(v12, nbytes);
+ memcpy(ptra, v12, 0x4B000u);
+
+ v6 = 0;
+ do {
+ memset(&buf, 0, 6u);
+ memset(v13, 0, 0x13u);
+ if (f.read(v13, 16) != 16)
+ v6 = -1;
+ if (strncmp((const char *)v13, "IMAGE=", 6))
+ v6 = -1;
+
+ if (!v6) {
+ f.read(v12, READ_LE_UINT32(v13 + 8));
+ if (*v12 != (byte)-4)
+ _vm->_graphicsManager.Copy_WinScan_Vbe3(v12, ptra);
+ }
+ } while (v6 != -1);
+ _vm->_graphicsManager.FADE_OUTW_LINUX(ptra);
+ ptr = _vm->_globals.dos_free2(ptra);
+ }
+ if (v8 == 1) {
+ if (_vm->_graphicsManager.FADE_LINUX == 2)
+ _vm->_graphicsManager.FADE_OUTW_LINUX(ptr);
+ _vm->_globals.dos_free2(ptr);
+ }
+ _vm->_graphicsManager.FADE_LINUX = 0;
+ _vm->_globals.dos_free2(v13);
+
+ _vm->_fileManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u);
+ _vm->_graphicsManager.Cls_Pal();
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.SCROLL = v11;
+ _vm->_graphicsManager.SCROLL_ECRAN(v11);
+ if (_vm->_graphicsManager.DOUBLE_ECRAN == true) {
+ _vm->_graphicsManager.SCANLINE(0x500u);
+ _vm->_graphicsManager.max_x = 1280;
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else {
+ _vm->_eventsManager.souris_max();
+ _vm->_graphicsManager.SCANLINE(SCREEN_WIDTH * 2);
+ _vm->_graphicsManager.max_x = SCREEN_WIDTH;
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.Cls_Video();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.FADE_INS();
+ _vm->_graphicsManager.DD_VBL();
+}
+
+bool AnimationManager::REDRAW_ANIM() {
+ return false;
+}
+
+// Load Anim
+void AnimationManager::CHARGE_ANIM(const Common::String &animName) {
+ byte v20[15];
+ char header[10];
+ char filename1[15];
+ char filename2[15];
+ char filename3[15];
+ char filename4[15];
+ char filename5[15];
+ char filename6[15];
+
+ CLEAR_ANIM();
+
+ Common::String filename = animName + ".ANI";
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename);
+
+ Common::File f;
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("Failed to open %s", _vm->_globals.NFICHIER.c_str());
+
+ int filesize = f.size();
+ int nbytes = filesize - 115;
+ f.read(header, 10);
+ f.read(v20, 15);
+ f.read(filename1, 15);
+ f.read(filename2, 15);
+ f.read(filename3, 15);
+ f.read(filename4, 15);
+ f.read(filename5, 15);
+ f.read(filename6, 15);
+
+ if (header[0] != 'A' || header[1] != 'N' || header[2] != 'I' || header[3] != 'S')
+ error("File incompatible with this soft.");
+
+ const char *files[6] = { &filename1[0], &filename2[0], &filename3[0], &filename4[0],
+ &filename5[0], &filename6[0] };
+
+ for (int idx = 1; idx <= 6; ++idx) {
+ if (files[idx - 1][0]) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, files[idx - 1]);
+
+ if (!f.exists(_vm->_globals.NFICHIER))
+ error("File not found");
+ if (CHARGE_BANK_SPRITE1(idx, files[idx - 1]))
+ error("File not compatible with this soft.");
+ }
+ }
+
+ byte *data = _vm->_globals.dos_malloc2(nbytes + 1);
+ f.read(data, nbytes);
+ f.close();
+
+ for (int idx = 1; idx <= 20; ++idx) {
+ RECHERCHE_ANIM(data, idx, nbytes);
+ }
+
+ _vm->_globals.dos_free2(data);
+}
+
+void AnimationManager::CLEAR_ANIM() {
+ for (int idx = 0; idx < 35; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].data != g_PTRNUL)
+ _vm->_globals.Bqe_Anim[idx].data = _vm->_globals.dos_free2(_vm->_globals.Bqe_Anim[idx].data);
+ _vm->_globals.Bqe_Anim[idx].field4 = 0;
+ }
+
+ for (int idx = 0; idx < 8; ++idx) {
+ if (_vm->_globals.Bank[idx].data != g_PTRNUL)
+ _vm->_globals.Bank[idx].data = _vm->_globals.dos_free2(_vm->_globals.Bank[idx].data);
+ _vm->_globals.Bank[idx].field4 = 0;
+ _vm->_globals.Bank[idx].filename1 = "";
+ _vm->_globals.Bank[idx].fileHeader = 0;
+ _vm->_globals.Bank[idx].field1C = 0;
+ }
+}
+
+// Load Sprite Bank 1
+int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filename) {
+ byte *v3;
+ byte *v4;
+ int v7;
+ int v8;
+ int width;
+ int height;
+ byte *v13;
+ int v16;
+ int v17;
+ byte *ptr;
+ byte *v19;
+ int v20;
+ int v21;
+ int result = 0;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename);
+ _vm->_globals.Bank[idx].field1C = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER);
+ _vm->_globals.Bank[idx].field4 = 1;
+ _vm->_globals.Bank[idx].filename1 = filename;
+ _vm->_globals.Bank[idx].filename2 = _vm->_globals.REP_SPR;
+
+ v3 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ v4 = v3;
+
+ _vm->_globals.Bank[idx].fileHeader = 0;
+ if (*(v3 + 1) == 'L' && *(v3 + 2) == 'E')
+ _vm->_globals.Bank[idx].fileHeader = 1;
+ if (*(v3 + 1) == 'O' && *(v3 + 2) == 'R')
+ _vm->_globals.Bank[184].fileHeader = 2;
+
+ if (_vm->_globals.Bank[idx].fileHeader) {
+ _vm->_globals.Bank[idx].data = v3;
+
+ v7 = 0;
+ v8 = 0;
+ do {
+ ptr = v4;
+ width = _vm->_objectsManager.Get_Largeur(v4, v8);
+ height = _vm->_objectsManager.Get_Hauteur(ptr, v8);
+ v4 = ptr;
+ if (!width && !height)
+ v7 = 1;
+ if (!v7)
+ ++v8;
+ if (v8 > 249)
+ v7 = 1;
+ } while (v7 != 1);
+
+ if (v8 <= 249) {
+ _vm->_globals.Bank[idx].field1A = v8;
+
+ Common::String ofsFilename = _vm->_globals.Bank[idx].filename1;
+ char ch;
+ do {
+ ch = ofsFilename.lastChar();
+ ofsFilename.deleteLastChar();
+ } while (ch != '.');
+ ofsFilename += ".OFS";
+
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, ofsFilename);
+ Common::File f;
+ if (f.exists(_vm->_globals.NFICHIER)) {
+ v19 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ v13 = v19;
+
+ if (_vm->_globals.Bank[idx].field1A > 0) {
+ for (int v14 = 0; v14 < _vm->_globals.Bank[idx].field1A; ++v14) {
+ v16 = (int16)READ_LE_UINT16(v13);
+ v17 = (int16)READ_LE_UINT16(v13 + 2);
+ v21 = (int16)READ_LE_UINT16(v13 + 4);
+ v20 = (int16)READ_LE_UINT16(v13 + 6);
+ v13 += 8;
+
+ _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, v14, v16, v17, 0);
+ if (_vm->_globals.Bank[idx].fileHeader == 2)
+ _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, v14, v21, v20, 1);
+ }
+ }
+
+ _vm->_globals.dos_free2(v19);
+ }
+
+ result = 0;
+ } else {
+ _vm->_globals.dos_free2(ptr);
+ _vm->_globals.Bank[idx].field4 = 0;
+ result = -2;
+ }
+ } else {
+ _vm->_globals.dos_free2(v3);
+ _vm->_globals.Bank[idx].field4 = 0;
+ result = -1;
+ }
+
+ return result;
+}
+
+// Search Anim
+void AnimationManager::RECHERCHE_ANIM(const byte *data, int animIndex, int count) {
+ int v3;
+ const byte *v5;
+ int v6;
+ int v7;
+ int v8;
+ byte *v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ const byte *v23;
+ int v;
+
+ v21 = 0;
+ v3 = 0;
+ v19 = animIndex;
+ do {
+ v20 = *(v21 + data);
+ if (v20 == 'A' && *(data + v21 + 1) == 'N' && *(data + v21 + 2) == 'I' && *(data + v21 + 3) == 'M') {
+ int entryIndex = *(data + v21 + 4);
+ if (animIndex == entryIndex) {
+ v5 = v21 + data + 5;
+ v6 = v21 + 5;
+ v7 = 0;
+ v8 = 0;
+ do {
+ if (*v5 == 'A' && *(v5 + 1) == 'N' && *(v5 + 2) == 'I' && *(v5 + 3) == 'M')
+ v8 = 1;
+ if (*v5 == 'F' && *(v5 + 1) == 'I' && *(v5 + 2) == 'N')
+ v8 = 1;
+ if (count < v6) {
+ _vm->_globals.Bqe_Anim[animIndex].field4 = 0;
+ _vm->_globals.Bqe_Anim[v19].data = g_PTRNUL;
+ return;
+ }
+ ++v6;
+ ++v7;
+ ++v5;
+ } while (v8 != 1);
+ _vm->_globals.Bqe_Anim[v19].data = _vm->_globals.dos_malloc2(v7 + 50);
+ _vm->_globals.Bqe_Anim[animIndex].field4 = 1;
+ memcpy(_vm->_globals.Bqe_Anim[v19].data, v21 + data + 5, 0x14u);
+
+ byte *dataP = _vm->_globals.Bqe_Anim[v19].data;
+ v9 = dataP + 20;
+ v23 = v21 + data + 25;
+ v10 = READ_LE_UINT16(v21 + data + 25);
+ v11 = READ_LE_UINT16(v21 + data + 27);
+ v22 = READ_LE_UINT16(v21 + data + 29);
+ v12 = READ_LE_UINT16(v21 + data + 31);
+ v13 = *(v21 + data + 33);
+ *(dataP + 29) = *(v21 + data + 34);
+ WRITE_LE_UINT16(dataP + 20, v10);
+ WRITE_LE_UINT16(dataP + 22, v11);
+ WRITE_LE_UINT16(dataP + 24, v22);
+ WRITE_LE_UINT16(dataP + 26, v12);
+ *(dataP + 28) = v13;
+
+ v14 = 1;
+ do {
+ v9 += 10;
+ v23 += 10;
+ if (!v22)
+ break;
+
+ v = READ_LE_UINT16(v23);
+ v15 = READ_LE_UINT16(v23 + 2);
+ v22 = READ_LE_UINT16(v23 + 4);
+ v16 = READ_LE_UINT16(v23 + 6);
+ v17 = *(v23 + 8);
+ *(v9 + 9) = *(v23 + 9);
+ WRITE_LE_UINT16(v9, v);
+ WRITE_LE_UINT16(v9 + 2, v15);
+ WRITE_LE_UINT16(v9 + 4, v22);
+ WRITE_LE_UINT16(v9 + 6, v16);
+ *(v9 + 8) = v17;
+ ++v14;
+ } while (v14 <= 4999);
+ v3 = 1;
+ }
+ }
+ if (v20 == 'F' && *(data + v21 + 1) == 'I' && *(data + v21 + 2) == 'N')
+ v3 = 1;
+ ++v21;
+ } while (v21 <= count && v3 != 1);
+}
+
+void AnimationManager::PLAY_SEQ(int a1, const Common::String &a2, uint32 a3, uint32 a4, uint32 a5) {
+ int v5;
+ int v7;
+ byte *ptr = NULL;
+ byte *v9;
+ byte *v10;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ char v18;
+ size_t nbytes;
+ int buf;
+ Common::File f;
+
+ if (_vm->shouldQuit())
+ return;
+
+ v7 = 0;
+ v14 = 0;
+ v13 = 0;
+ v16 = 0;
+ v15 = 0;
+ v17 = 1;
+ _vm->_eventsManager.souris_flag = false;
+ if (!NO_COUL) {
+ _vm->_eventsManager.VBL();
+
+ _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
+ if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2))
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+ if (!_vm->_graphicsManager.nbrligne)
+ _vm->_graphicsManager.ofscroll = 0;
+ }
+ v9 = _vm->_graphicsManager.VESA_SCREEN;
+ v10 = _vm->_globals.dos_malloc2(0x16u);
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSEQ, a2);
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("Error opening file - %s", _vm->_globals.NFICHIER.c_str());
+
+ f.read(&buf, 6u);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.read(&buf, 4u);
+ nbytes = f.readUint32LE();
+ v18 = f.readUint32LE();
+ v17 = f.readUint16LE();
+ v16 = f.readUint16LE();
+ v15 = f.readUint16LE();
+ v14 = f.readUint16LE();
+ v13 = f.readUint16LE();
+ f.read(v9, nbytes);
+
+ if (_vm->_graphicsManager.WinScan / _vm->_graphicsManager.Winbpp > SCREEN_WIDTH) {
+ v7 = 1;
+ ptr = _vm->_globals.dos_malloc2(0x4B000u);
+ memcpy(ptr, v9, 0x4B000u);
+ }
+ if (_vm->_animationManager.NO_SEQ) {
+ if (v7 == 1)
+ memcpy(ptr, _vm->_graphicsManager.VESA_BUFFER, 0x4B000u);
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ } else {
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (v7)
+ _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(v9, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (v7)
+ _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(v9, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ }
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_eventsManager.ESC_KEY = false;
+ _vm->_soundManager.LOAD_ANM_SOUND();
+ if (_vm->_globals.iRegul == 1) {
+ do {
+ if (_vm->_eventsManager.ESC_KEY == true) {
+ if (!_vm->_eventsManager.NOESC)
+ goto LABEL_59;
+ _vm->_eventsManager.ESC_KEY = false;
+ }
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ } while (_vm->_eventsManager.lItCounter < a3);
+ }
+ _vm->_eventsManager.lItCounter = 0;
+ v5 = 0;
+ v12 = 0;
+ do {
+ ++v12;
+ _vm->_soundManager.PLAY_ANM_SOUND(v12);
+ memset(&buf, 0, 6u);
+ memset(v10, 0, 0x13u);
+ if (f.read(v10, 16) != 16)
+ v5 = -1;
+
+ if (strncmp((const char *)v10, "IMAGE=", 6))
+ v5 = -1;
+ if (!v5) {
+ f.read(v9, (int16)READ_LE_UINT16(v10 + 8));
+ if (_vm->_globals.iRegul == 1) {
+ do {
+ if (_vm->_eventsManager.ESC_KEY == true) {
+ if (!_vm->_eventsManager.NOESC)
+ goto LABEL_59;
+ _vm->_eventsManager.ESC_KEY = false;
+ }
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ } while (_vm->_eventsManager.lItCounter < a4);
+ }
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_graphicsManager.DD_Lock();
+ if (v7) {
+ if (*v9 != (byte)-4) {
+ _vm->_graphicsManager.Copy_WinScan_Vbe(v9, ptr);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else if (*v9 != (byte)-4) {
+ if (_vm->_graphicsManager.Winbpp == 1)
+ _vm->_graphicsManager.Copy_Video_Vbe(v9);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.Copy_Video_Vbe16a(v9);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ _vm->_soundManager.VERIF_SOUND();
+ }
+ } while (v5 != -1);
+ if (_vm->_globals.iRegul == 1) {
+ do {
+ if (_vm->_eventsManager.ESC_KEY == true) {
+ if (!_vm->_eventsManager.NOESC)
+ goto LABEL_59;
+ _vm->_eventsManager.ESC_KEY = false;
+ }
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ } while (_vm->_eventsManager.lItCounter < a5);
+ }
+ _vm->_eventsManager.lItCounter = 0;
+LABEL_59:
+ _vm->_graphicsManager.NOLOCK = false;
+ f.close();
+
+ if (!NO_COUL) {
+ _vm->_fileManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ _vm->_eventsManager.souris_flag = true;
+ }
+ if (v7 == 1)
+ _vm->_globals.dos_free2(ptr);
+ _vm->_globals.dos_free2(v10);
+}
+
+void AnimationManager::PLAY_SEQ2(const Common::String &a1, uint32 a2, uint32 a3, uint32 a4) {
+ bool v4;
+ bool v5;
+ int v7;
+ byte *ptr = NULL;
+ byte *ptra;
+ byte *v10;
+ byte *v11 = NULL;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ char v19;
+ size_t nbytes;
+ Common::File f;
+
+ v7 = 0;
+ for (;;) {
+ if (_vm->shouldQuit())
+ return;
+
+ v15 = 0;
+ v14 = 0;
+ v17 = 0;
+ v16 = 0;
+ v18 = 1;
+ _vm->_eventsManager.souris_flag = false;
+ v10 = _vm->_graphicsManager.VESA_SCREEN;
+ v11 = _vm->_globals.dos_malloc2(0x16u);
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSEQ, a1);
+
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("File not found - %s", _vm->_globals.NFICHIER.c_str());
+
+ f.skip(6);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.skip(4);
+ nbytes = f.readUint32LE();
+ v19 = f.readUint32LE();
+ v18 = f.readUint16LE();
+ v17 = f.readUint16LE();
+ v16 = f.readUint16LE();
+ v15 = f.readUint16LE();
+ v14 = f.readUint16LE();
+ f.read(v10, nbytes);
+
+ if (_vm->_graphicsManager.WinScan / _vm->_graphicsManager.Winbpp > SCREEN_WIDTH) {
+ v7 = 1;
+ ptr = _vm->_globals.dos_malloc2(0x4B000u);
+ memcpy((void *)ptr, v10, 0x4B000u);
+ }
+ if (_vm->_animationManager.NO_SEQ) {
+ if (v7 == 1) {
+ assert(ptr != NULL);
+ memcpy((void *)ptr, _vm->_graphicsManager.VESA_BUFFER, 0x4B000u);
+ }
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ } else {
+ _vm->_graphicsManager.DD_Lock();
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (v7)
+ _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(v10, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (v7)
+ _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(v10, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ }
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_eventsManager.ESC_KEY = false;
+ _vm->_soundManager.LOAD_ANM_SOUND();
+ if (_vm->_globals.iRegul != 1)
+ break;
+ while (!_vm->shouldQuit()) {
+ if (_vm->_eventsManager.ESC_KEY == true)
+ goto LABEL_54;
+ if (REDRAW_ANIM() == true)
+ break;
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ if (_vm->_eventsManager.lItCounter >= a2)
+ goto LABEL_23;
+ }
+LABEL_48:
+ if (_vm->_graphicsManager.NOLOCK == true)
+ goto LABEL_54;
+ if (v7 == 1)
+ ptr = _vm->_globals.dos_free2(ptr);
+ _vm->_globals.dos_free2(v11);
+ f.close();
+ }
+LABEL_23:
+ _vm->_eventsManager.lItCounter = 0;
+ v4 = false;
+ v13 = 0;
+ while (!_vm->shouldQuit()) {
+ _vm->_soundManager.PLAY_ANM_SOUND(v13++);
+
+ memset(v11, 0, 0x13u);
+ if (f.read(v11, 16) != 16)
+ v4 = true;
+
+ if (strncmp((const char *)v11, "IMAGE=", 6))
+ v4 = true;
+ if (v4)
+ goto LABEL_44;
+ f.read(v10, READ_LE_UINT32(v11 + 8));
+ if (_vm->_globals.iRegul == 1)
+ break;
+LABEL_33:
+ _vm->_eventsManager.lItCounter = 0;
+ _vm->_graphicsManager.DD_Lock();
+ if (v7) {
+ if (*v10 != (byte)-4) {
+ _vm->_graphicsManager.Copy_WinScan_Vbe(v10, ptr);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.m_scroll16A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2A(ptr, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ } else if (*v10 != (byte)-4) {
+ if (_vm->_graphicsManager.Winbpp == 1)
+ _vm->_graphicsManager.Copy_Video_Vbe(v10);
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.Copy_Video_Vbe16a(v10);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ _vm->_soundManager.VERIF_SOUND();
+LABEL_44:
+ if (v4) {
+ if (_vm->_globals.iRegul == 1) {
+ while (_vm->_eventsManager.ESC_KEY != true) {
+ if (REDRAW_ANIM() == true)
+ goto LABEL_48;
+ _vm->_eventsManager.CONTROLE_MES();
+ _vm->_soundManager.VERIF_SOUND();
+ if (_vm->_eventsManager.lItCounter >= a4)
+ goto LABEL_53;
+ }
+ } else {
+LABEL_53:
+ _vm->_eventsManager.lItCounter = 0;
+ }
+ goto LABEL_54;
+ }
+ }
+ while (_vm->_eventsManager.ESC_KEY != true) {
+ _vm->_eventsManager.CONTROLE_MES();
+ if (REDRAW_ANIM() == true)
+ goto LABEL_48;
+ if (_vm->_eventsManager.lItCounter >= a3)
+ goto LABEL_33;
+ }
+LABEL_54:
+ if (_vm->_graphicsManager.FADE_LINUX == 2 && !v7) {
+ ptra = _vm->_globals.dos_malloc2(0x4B000u);
+
+ f.seek(0);
+ f.skip(6);
+ f.read(_vm->_graphicsManager.Palette, 0x320u);
+ f.skip(4);
+ nbytes = f.readUint32LE();
+ v19 = f.readUint32LE();
+ v18 = f.readUint16LE();
+ v17 = f.readUint16LE();
+ v16 = f.readUint16LE();
+ v15 = f.readUint16LE();
+ v14 = f.readUint16LE();
+ f.read(v10, nbytes);
+
+ memcpy(ptra, v10, 0x4B000u);
+ v5 = false;
+ do {
+ memset(v11, 0, 0x13u);
+ if (f.read(v11, 16) != 16)
+ v5 = true;
+
+ if (strncmp((const char *)v11, "IMAGE=", 6))
+ v5 = true;
+ if (!v5) {
+ f.read(v10, READ_LE_UINT32(v11 + 8));
+ if (*v10 != (byte)-4)
+ _vm->_graphicsManager.Copy_WinScan_Vbe(v10, ptra);
+ }
+ } while (!v5);
+ _vm->_graphicsManager.FADE_OUTW_LINUX(ptra);
+ ptr = _vm->_globals.dos_free2(ptra);
+ }
+ if (v7 == 1) {
+ if (_vm->_graphicsManager.FADE_LINUX == 2)
+ _vm->_graphicsManager.FADE_OUTW_LINUX(ptr);
+ _vm->_globals.dos_free2(ptr);
+ }
+ _vm->_graphicsManager.FADE_LINUX = 0;
+
+ f.close();
+ _vm->_globals.dos_free2(v11);
+ _vm->_eventsManager.souris_flag = true;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/anim.h b/engines/hopkins/anim.h
new file mode 100644
index 0000000000..339355ef75
--- /dev/null
+++ b/engines/hopkins/anim.h
@@ -0,0 +1,59 @@
+/* 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_ANIM_H
+#define HOPKINS_ANIM_H
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/str.h"
+#include "graphics/surface.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+class AnimationManager {
+private:
+ int CHARGE_BANK_SPRITE1(int idx, const Common::String &filename);
+public:
+ HopkinsEngine *_vm;
+ bool CLS_ANM;
+ bool NO_SEQ;
+ bool NO_COUL;
+public:
+ AnimationManager();
+ void setParent(HopkinsEngine *vm) { _vm = vm; }
+
+ void PLAY_ANM(const Common::String &filename, uint32 rate, uint32 rate2, uint32 rate3);
+ void PLAY_ANM2(const Common::String &filename, uint32 a2, uint32 a3, uint32 a4);
+ bool REDRAW_ANIM();
+ void CHARGE_ANIM(const Common::String &animName);
+ void CLEAR_ANIM();
+ void RECHERCHE_ANIM(const byte *data, int animIndex, int count);
+ void PLAY_SEQ(int a1, const Common::String &a2, uint32 a3, uint32 a4, uint32 a5);
+ void PLAY_SEQ2(const Common::String &a1, uint32 a2, uint32 a3, uint32 a4);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_ANIM_H */
diff --git a/engines/hopkins/debugger.cpp b/engines/hopkins/debugger.cpp
new file mode 100644
index 0000000000..a332d2160e
--- /dev/null
+++ b/engines/hopkins/debugger.cpp
@@ -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.
+ *
+ */
+
+#include "hopkins/debugger.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+Debugger::Debugger() : GUI::Debugger() {
+ DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
+}
+
+void Debugger::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/debugger.h b/engines/hopkins/debugger.h
new file mode 100644
index 0000000000..7a2f44aafe
--- /dev/null
+++ b/engines/hopkins/debugger.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_DEBUGGER_H
+#define HOPKINS_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+class Debugger : public GUI::Debugger {
+private:
+ HopkinsEngine *_vm;
+
+public:
+ Debugger();
+ virtual ~Debugger() {}
+ void setParent(HopkinsEngine *vm);
+};
+
+} // End of namespace Hopkins
+
+#endif
diff --git a/engines/hopkins/detection.cpp b/engines/hopkins/detection.cpp
new file mode 100644
index 0000000000..8724802552
--- /dev/null
+++ b/engines/hopkins/detection.cpp
@@ -0,0 +1,185 @@
+/* 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 "base/plugins.h"
+
+#include "common/savefile.h"
+#include "common/str-array.h"
+#include "common/memstream.h"
+#include "engines/advancedDetector.h"
+#include "common/system.h"
+#include "graphics/colormasks.h"
+#include "graphics/surface.h"
+
+#include "hopkins/hopkins.h"
+
+#define MAX_SAVES 99
+
+namespace Hopkins {
+
+struct HopkinsGameDescription {
+ ADGameDescription desc;
+};
+
+uint32 HopkinsEngine::getFeatures() const {
+ return _gameDescription->desc.flags;
+}
+
+Common::Language HopkinsEngine::getLanguage() const {
+ return _gameDescription->desc.language;
+}
+
+Common::Platform HopkinsEngine::getPlatform() const {
+ return _gameDescription->desc.platform;
+}
+
+bool HopkinsEngine::getIsDemo() const {
+ return _gameDescription->desc.flags & ADGF_DEMO;
+}
+
+} // End of namespace Hopkins
+
+static const PlainGameDescriptor hopkinsGames[] = {
+ {"hopkins", "Hopkins FBI"},
+ {0, 0}
+};
+
+#include "hopkins/detection_tables.h"
+
+class HopkinsMetaEngine : public AdvancedMetaEngine {
+public:
+ HopkinsMetaEngine() : AdvancedMetaEngine(Hopkins::gameDescriptions, sizeof(Hopkins::HopkinsGameDescription), hopkinsGames) {
+ }
+
+ virtual const char *getName() const {
+ return "Hopkins Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Hopkins Engine (C) ???";
+ }
+
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual int getMaximumSaveSlot() const;
+ virtual void removeSaveState(const char *target, int slot) const;
+ SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+};
+
+bool HopkinsMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail);
+}
+
+bool Hopkins::HopkinsEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}
+
+bool HopkinsMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ const Hopkins::HopkinsGameDescription *gd = (const Hopkins::HopkinsGameDescription *)desc;
+ if (gd) {
+ *engine = new Hopkins::HopkinsEngine(syst, gd);
+ }
+ return gd != 0;
+}
+
+SaveStateList HopkinsMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringArray filenames;
+ Common::String saveDesc;
+ Common::String pattern = Common::String::format("%s.0??", target);
+
+ filenames = saveFileMan->listSavefiles(pattern);
+ sort(filenames.begin(), filenames.end()); // Sort to get the files in numerical order
+
+ Hopkins::hopkinsSavegameHeader header;
+
+ SaveStateList saveList;
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ const char *ext = strrchr(file->c_str(), '.');
+ int slot = ext ? atoi(ext + 1) : -1;
+
+ if (slot >= 0 && slot < MAX_SAVES) {
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+
+ if (in) {
+ if (Hopkins::SaveLoadManager::readSavegameHeader(in, header)) {
+ saveList.push_back(SaveStateDescriptor(slot, header.saveName));
+
+ header.thumbnail->free();
+ delete header.thumbnail;
+ }
+
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
+int HopkinsMetaEngine::getMaximumSaveSlot() const {
+ return MAX_SAVES;
+}
+
+void HopkinsMetaEngine::removeSaveState(const char *target, int slot) const {
+ Common::String filename = Common::String::format("%s.%03d", target, slot);
+ g_system->getSavefileManager()->removeSavefile(filename);
+}
+
+SaveStateDescriptor HopkinsMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ Common::String filename = Common::String::format("%s.%03d", target, slot);
+ Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
+
+ if (f) {
+ Hopkins::hopkinsSavegameHeader header;
+ Hopkins::SaveLoadManager::readSavegameHeader(f, header);
+ delete f;
+
+ // Create the return descriptor
+ SaveStateDescriptor desc(slot, header.saveName);
+ desc.setThumbnail(header.thumbnail);
+ desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay);
+ desc.setSaveTime(header.saveHour, header.saveMinutes);
+ desc.setPlayTime(header.totalFrames * GAME_FRAME_TIME);
+
+ return desc;
+ }
+
+ return SaveStateDescriptor();
+}
+
+
+#if PLUGIN_ENABLED_DYNAMIC(HOPKINS)
+REGISTER_PLUGIN_DYNAMIC(HOPKINS, PLUGIN_TYPE_ENGINE, HopkinsMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(HOPKINS, PLUGIN_TYPE_ENGINE, HopkinsMetaEngine);
+#endif
diff --git a/engines/hopkins/detection_tables.h b/engines/hopkins/detection_tables.h
new file mode 100644
index 0000000000..9e1d329f39
--- /dev/null
+++ b/engines/hopkins/detection_tables.h
@@ -0,0 +1,106 @@
+/* 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.
+ *
+ */
+
+namespace Hopkins {
+
+static const HopkinsGameDescription gameDescriptions[] = {
+ {
+ // Hopkins FBI Linux Demo 1.00
+ {
+ "hopkins",
+ 0,
+ {
+ {"Hopkins-PDemo.bin", 0, "88b4d6e14b9b1407083cb3d1213c0fa7", 272027},
+ AD_LISTEND
+ },
+ Common::EN_ANY,
+ Common::kPlatformLinux,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ },
+
+ {
+ // Hopkins FBI Linux Demo 1.02
+ {
+ "hopkins",
+ 0,
+ {
+ {"Hopkins-PDemo.bin", 0, "f82f4e698f3a189419351be0de2b2f8e", 273760},
+ AD_LISTEND
+ },
+ Common::EN_ANY,
+ Common::kPlatformLinux,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ },
+
+ {
+ // Hopkins FBI OS/2, provided by Strangerke
+ {
+ "hopkins",
+ 0,
+ {
+ {"Hopkins.exe", 0, "63d45f882278e5a9fa1027066223e5d9", 292864},
+ AD_LISTEND
+ },
+ Common::EN_ANY,
+ Common::kPlatformOS2,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+ },
+ {
+ // Hopkins FBI Win95 Demo, provided by Strangerke
+ {
+ "hopkins",
+ 0,
+ {
+ {"Hopkins.exe", 0, "0c9ebfe371f4dcf84a49f333f04839a0", 376897},
+ AD_LISTEND
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ GUIO1(GUIO_NONE)
+ },
+ },
+ {
+ // Hopkins FBI Win95, provided by Strangerke
+ {
+ "hopkins",
+ 0,
+ {
+ {"Hopkins.exe", 0, "277a5c144bf9ec7d8450ae37afb85090", 419281},
+ AD_LISTEND
+ },
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ GUIO1(GUIO_NONE)
+ },
+ },
+ { AD_TABLE_END_MARKER }
+};
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp
new file mode 100644
index 0000000000..28207bf6c7
--- /dev/null
+++ b/engines/hopkins/dialogs.cpp
@@ -0,0 +1,752 @@
+/* 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/scummsys.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/util.h"
+#include "hopkins/dialogs.h"
+#include "hopkins/events.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/sound.h"
+
+namespace Hopkins {
+
+DialogsManager::DialogsManager() {
+ DESACTIVE_INVENT = false;
+ INVENTFLAG = false;
+ AFFINVEN = false;
+ VIRE_INVENT = false;
+ inventairex = inventairey = 0;
+ inventairel = inventaireh = 0;
+ Winventaire = NULL;
+ inventaire2 = g_PTRNUL;
+}
+
+DialogsManager::~DialogsManager() {
+ _vm->_globals.dos_free2(Winventaire);
+}
+
+void DialogsManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+void DialogsManager::showOptionsDialog() {
+ bool doneFlag;
+
+ doneFlag = false;
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+ _vm->_eventsManager.VBL();
+ if (_vm->_globals.FR == 1)
+ _vm->_fileManager.CONSTRUIT_SYSTEM("OPTIFR.SPR");
+ if (!_vm->_globals.FR)
+ _vm->_fileManager.CONSTRUIT_SYSTEM("OPTIAN.SPR");
+ if (_vm->_globals.FR == 2)
+ _vm->_fileManager.CONSTRUIT_SYSTEM("OPTIES.SPR");
+
+ _vm->_globals.OPTION_SPR = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ _vm->_globals.OPTION_FLAG = true;
+
+ do {
+ if (_vm->_eventsManager.BMOUSE()) {
+ Common::Point mousePos(_vm->_eventsManager.XMOUSE(), _vm->_eventsManager.YMOUSE());
+ mousePos.x = _vm->_eventsManager.XMOUSE();
+ mousePos.y = _vm->_eventsManager.YMOUSE();
+
+ if (!_vm->_soundManager.MUSICOFF) {
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 138) {
+ ++_vm->_soundManager.MUSICVOL;
+ _vm->_soundManager.OLD_MUSICVOL = _vm->_soundManager.MUSICVOL;
+
+ if (_vm->_soundManager.MUSICVOL <= 12)
+ _vm->_soundManager.PLAY_SOUND("bruit2.wav");
+ else
+ _vm->_soundManager.MUSICVOL = 12;
+ _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
+ }
+
+ if (!_vm->_soundManager.MUSICOFF && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 138) {
+ --_vm->_soundManager.MUSICVOL;
+ if (_vm->_soundManager.MUSICVOL >= 0)
+ _vm->_soundManager.PLAY_SOUND("bruit2.wav");
+ else
+ _vm->_soundManager.MUSICVOL = 0;
+
+ _vm->_soundManager.OLD_MUSICVOL = _vm->_soundManager.MUSICVOL;
+ _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
+ }
+ }
+ if (!_vm->_soundManager.SOUNDOFF) {
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 165) {
+ ++_vm->_soundManager.SOUNDVOL;
+ if (_vm->_soundManager.SOUNDVOL <= 16)
+ _vm->_soundManager.PLAY_SOUND("bruit2.wav");
+ else
+ _vm->_soundManager.SOUNDVOL = 16;
+ _vm->_soundManager.OLD_SOUNDVOL = _vm->_soundManager.SOUNDVOL;
+ _vm->_soundManager.MODSetSampleVolume();
+ }
+
+ if (!_vm->_soundManager.SOUNDOFF && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 165) {
+ --_vm->_soundManager.SOUNDVOL;
+ if (_vm->_soundManager.SOUNDVOL >= 0)
+ _vm->_soundManager.PLAY_SOUND("bruit2.wav");
+ else
+ _vm->_soundManager.SOUNDVOL = 0;
+ _vm->_soundManager.OLD_SOUNDVOL = _vm->_soundManager.SOUNDVOL;
+ _vm->_soundManager.MODSetSampleVolume();
+ }
+ }
+
+ if (!_vm->_soundManager.VOICEOFF) {
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 327 && mousePos.y <= 192) {
+ ++_vm->_soundManager.VOICEVOL;
+
+ if (_vm->_soundManager.VOICEVOL <= 16)
+ _vm->_soundManager.PLAY_SOUND("bruit2.wav");
+ else
+ _vm->_soundManager.VOICEVOL = 16;
+ _vm->_soundManager.OLD_VOICEVOL = _vm->_soundManager.VOICEVOL;
+ _vm->_soundManager.MODSetVoiceVolume();
+ }
+
+ if (!_vm->_soundManager.VOICEOFF && mousePos.x >= _vm->_graphicsManager.ofscroll + 331 && mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 192) {
+ --_vm->_soundManager.VOICEVOL;
+ if (_vm->_soundManager.VOICEVOL >= 0)
+ _vm->_soundManager.PLAY_SOUND("bruit2.wav");
+ else
+ _vm->_soundManager.VOICEVOL = 0;
+ _vm->_soundManager.OLD_VOICEVOL = _vm->_soundManager.VOICEVOL;
+ _vm->_soundManager.MODSetVoiceVolume();
+ }
+ }
+
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
+ if (mousePos.y > 194 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 219)
+ _vm->_soundManager.TEXTOFF = _vm->_soundManager.TEXTOFF != 1;
+
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
+ if (mousePos.y > 167 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 192)
+ _vm->_soundManager.VOICEOFF = _vm->_soundManager.VOICEOFF != 1;
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431) {
+ if (mousePos.y > 113 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 138) {
+ if (_vm->_soundManager.MUSICOFF == 1) {
+ _vm->_soundManager.MUSICOFF = 0;
+ _vm->_soundManager.MODSetMusicVolume(_vm->_soundManager.MUSICVOL);
+ } else {
+ _vm->_soundManager.MUSICOFF = 1;
+ _vm->_soundManager.MODSetMusicVolume(0);
+ }
+ }
+
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 431 && mousePos.y > 140 && mousePos.x <= _vm->_graphicsManager.ofscroll + 489 && mousePos.y <= 165)
+ _vm->_soundManager.SOUNDOFF = _vm->_soundManager.SOUNDOFF != 1;
+ }
+ }
+ }
+
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 175 && mousePos.y > 285 && mousePos.x <= _vm->_graphicsManager.ofscroll + 281 && mousePos.y <= 310) {
+ _vm->_globals.SORTIE = 300;
+ doneFlag = true;
+ }
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 355 && mousePos.y > 285 && mousePos.x <= _vm->_graphicsManager.ofscroll + 490 && mousePos.y <= 310)
+ doneFlag = true;
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 194 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 219) {
+ switch (_vm->_graphicsManager.SPEED_SCROLL) {
+ case 1:
+ _vm->_graphicsManager.SPEED_SCROLL = 2;
+ break;
+ case 2:
+ _vm->_graphicsManager.SPEED_SCROLL = 4;
+ break;
+ case 4:
+ _vm->_graphicsManager.SPEED_SCROLL = 8;
+ break;
+ case 8:
+ _vm->_graphicsManager.SPEED_SCROLL = 16;
+ break;
+ case 16:
+ _vm->_graphicsManager.SPEED_SCROLL = 32;
+ break;
+ case 32:
+ _vm->_graphicsManager.SPEED_SCROLL = 48;
+ break;
+ case 48:
+ _vm->_graphicsManager.SPEED_SCROLL = 64;
+ break;
+ case 64:
+ _vm->_graphicsManager.SPEED_SCROLL = 128;
+ break;
+ case 128:
+ _vm->_graphicsManager.SPEED_SCROLL = 160;
+ break;
+ case 160:
+ _vm->_graphicsManager.SPEED_SCROLL = 320;
+ break;
+ case 320:
+ _vm->_graphicsManager.SPEED_SCROLL = 1;
+ break;
+ }
+ }
+
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 348 && mousePos.y > 248 && mousePos.x <= _vm->_graphicsManager.ofscroll + 394 && mousePos.y <= 273)
+ _vm->_globals.vitesse = 2;
+ if (mousePos.x >= _vm->_graphicsManager.ofscroll + 300 && mousePos.y > 221 && mousePos.x <= _vm->_graphicsManager.ofscroll + 358 && mousePos.y <= 246)
+ _vm->_globals.SVGA = 2;
+ if (mousePos.x < _vm->_graphicsManager.ofscroll + 165 || mousePos.x > _vm->_graphicsManager.ofscroll + 496 || (uint)(mousePos.y - 107) > 0xD3u)
+ doneFlag = true;
+ }
+
+ if (!_vm->_graphicsManager.MANU_SCROLL)
+ _vm->_globals.opt_scrtype = 2;
+ if (_vm->_graphicsManager.MANU_SCROLL == 1)
+ _vm->_globals.opt_scrtype = 1;
+ if (_vm->_globals.vitesse == 1)
+ _vm->_globals.opt_vitesse = 6;
+ if (_vm->_globals.vitesse == 2)
+ _vm->_globals.opt_vitesse = 5;
+ if (_vm->_globals.vitesse == 3)
+ _vm->_globals.opt_vitesse = 4;
+
+ _vm->_globals.opt_txt = !_vm->_soundManager.TEXTOFF ? 7 : 8;
+ _vm->_globals.opt_voice = !_vm->_soundManager.VOICEOFF ? 7 : 8;
+ _vm->_globals.opt_sound = !_vm->_soundManager.SOUNDOFF ? 7 : 8;
+ _vm->_globals.opt_music = !_vm->_soundManager.MUSICOFF ? 7 : 8;
+
+ if (_vm->_globals.SVGA == 1)
+ _vm->_globals.opt_anm = 10;
+ if (_vm->_globals.SVGA == 2)
+ _vm->_globals.opt_anm = 9;
+ if (_vm->_globals.SVGA == 3)
+ _vm->_globals.opt_anm = 11;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 1)
+ _vm->_globals.opt_scrspeed = 12;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 2)
+ _vm->_globals.opt_scrspeed = 13;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 4)
+ _vm->_globals.opt_scrspeed = 14;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 8)
+ _vm->_globals.opt_scrspeed = 15;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 16)
+ _vm->_globals.opt_scrspeed = 16;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 32)
+ _vm->_globals.opt_scrspeed = 17;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 48)
+ _vm->_globals.opt_scrspeed = 18;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 64)
+ _vm->_globals.opt_scrspeed = 19;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 128)
+ _vm->_globals.opt_scrspeed = 20;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 160)
+ _vm->_globals.opt_scrspeed = 21;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 320)
+ _vm->_globals.opt_scrspeed = 22;
+ if (_vm->_graphicsManager.SPEED_SCROLL == 640)
+ _vm->_globals.opt_scrspeed = 23;
+
+ _vm->_eventsManager.VBL();
+ } while (!doneFlag);
+
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_graphicsManager.ofscroll + 164,
+ 107, 335, 215, _vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll + 164, 107);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_graphicsManager.ofscroll + 164, 107,
+ _vm->_graphicsManager.ofscroll + 498, 320);
+
+ _vm->_globals.OPTION_SPR = _vm->_globals.dos_free2(_vm->_globals.OPTION_SPR);
+ _vm->_globals.OPTION_FLAG = false;
+}
+
+void DialogsManager::showInventory() {
+ int v1;
+ size_t filesize;
+ int v4;
+ int v5;
+ int v6;
+ byte *v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ Common::File f;
+
+ v13 = 0;
+ if (!VIRE_INVENT && !AFFINVEN && !_vm->_globals.DESACTIVE_INVENT) {
+ _vm->_graphicsManager.no_scroll = 1;
+ _vm->_objectsManager.FLAG_VISIBLE_EFFACE = 4;
+ _vm->_objectsManager.FLAG_VISIBLE = false;
+ v1 = 0;
+ do {
+ INVENT_ANIM();
+ _vm->_eventsManager.XMOUSE();
+ _vm->_eventsManager.YMOUSE();
+ _vm->_eventsManager.VBL();
+ ++v1;
+ } while (v1 <= 1);
+ _vm->_dialogsManager.Winventaire = g_PTRNUL;
+
+LABEL_7:
+ _vm->_eventsManager.souris_bb = 0;
+ _vm->_eventsManager.souris_b = 0;
+ _vm->_globals.DESACTIVE_INVENT = true;
+ _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
+
+ switch (_vm->_globals.FR) {
+ case 0:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTAN.SPR");
+ break;
+ case 1:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTFR.SPR");
+ break;
+ case 2:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTES.SPR");
+ break;
+ }
+
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("Error opening file - %s", _vm->_globals.NFICHIER.c_str());
+
+ filesize = f.size();
+ _vm->_dialogsManager.Winventaire = _vm->_globals.dos_malloc2(filesize);
+ _vm->_fileManager.bload_it(f, _vm->_dialogsManager.Winventaire, filesize);
+ f.close();
+
+ _vm->_fileManager.CONSTRUIT_SYSTEM("INVENT2.SPR");
+ inventaire2 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ v19 = _vm->_graphicsManager.ofscroll + 152;
+ v18 = _vm->_objectsManager.Get_Largeur(_vm->_dialogsManager.Winventaire, 0);
+ v17 = _vm->_objectsManager.Get_Hauteur(_vm->_dialogsManager.Winventaire, 0);
+ inventairex = v19;
+ inventairey = 114;
+ inventairel = v18;
+ inventaireh = v17;
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire,
+ v19 + 300, 414, 0, 0, 0, 0);
+ v15 = 0;
+ v4 = 0;
+ v14 = 1;
+ do {
+ v16 = 0;
+ v5 = 1;
+ do {
+ ++v4;
+ v6 = _vm->_globals.INVENTAIRE[v4];
+ if (v6 && v4 <= 29) {
+ v7 = _vm->_objectsManager.CAPTURE_OBJET(v6, 0);
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, v7, v19 + v16 + 6,
+ v15 + 120, _vm->_globals.OBJL, _vm->_globals.OBJH);
+ _vm->_globals.dos_free2(v7);
+ }
+ v16 += 54;
+ ++v5;
+ } while (v5 <= 6);
+ v15 += 38;
+ ++v14;
+ } while (v14 <= 5);
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire, inventairex, inventairey, inventairel, inventaireh);
+ _vm->_eventsManager.souris_bb = 0;
+ v20 = 0;
+
+ // Main loop to select an inventory item
+ while (!_vm->shouldQuit()) {
+ // Turn on drawing the inventory dialog in the event manager
+ AFFINVEN = true;
+
+ v8 = _vm->_eventsManager.XMOUSE();
+ v9 = _vm->_eventsManager.YMOUSE();
+ v12 = _vm->_eventsManager.BMOUSE();
+ v10 = v13;
+ v11 = _vm->_linesManager.ZONE_OBJET(v8, v9);
+ v13 = v11;
+ if (v11 != v10)
+ _vm->_objectsManager.PARAMCADRE(v11);
+ if (_vm->_eventsManager.btsouris != 16) {
+ if ((uint16)(_vm->_eventsManager.btsouris - 1) > 1u) {
+ if (_vm->_eventsManager.btsouris != 3) {
+ if (v12 == 2) {
+ _vm->_objectsManager.OBJETPLUS(v13);
+ if (_vm->_eventsManager.btsouris != 23)
+ _vm->_eventsManager.CHANGE_MOUSE(_vm->_eventsManager.btsouris);
+ }
+ }
+ }
+ }
+ if (v12 == 1) {
+ if (_vm->_eventsManager.btsouris == 1 || _vm->_eventsManager.btsouris == 16 || !_vm->_eventsManager.btsouris || (uint16)(_vm->_eventsManager.btsouris - 2) <= 1u)
+ break;
+ v9 = v13;
+ _vm->_objectsManager.VALID_OBJET(_vm->_globals.INVENTAIRE[v13]);
+ if (_vm->_eventsManager.btsouris == 8)
+ v20 = 1;
+ if (v20 != 1) {
+ _vm->_scriptManager.TRAVAILOBJET = 1;
+ _vm->_globals.SAUVEGARDE->data[svField3] = _vm->_globals.OBJET_EN_COURS;
+ _vm->_globals.SAUVEGARDE->data[svField8] = _vm->_globals.INVENTAIRE[v13];
+ _vm->_globals.SAUVEGARDE->data[svField9] = _vm->_eventsManager.btsouris;
+ _vm->_objectsManager.OPTI_OBJET();
+ _vm->_scriptManager.TRAVAILOBJET = 0;
+
+ if (_vm->_soundManager.VOICEOFF == 1) {
+ do
+ _vm->_eventsManager.VBL();
+ while (!_vm->_globals.SORTIE && _vm->_eventsManager.BMOUSE() != 1);
+ _vm->_fontManager.TEXTE_OFF(9);
+ }
+ if (_vm->_globals.SORTIE) {
+ if (_vm->_globals.SORTIE == 2)
+ v20 = 1;
+ _vm->_globals.SORTIE = 0;
+ if (v20 != 1) {
+ inventaire2 = _vm->_globals.dos_free2(inventaire2);
+ if (g_PTRNUL != _vm->_dialogsManager.Winventaire)
+ _vm->_dialogsManager.Winventaire = _vm->_globals.dos_free2(_vm->_dialogsManager.Winventaire);
+ goto LABEL_7;
+ }
+ } else if (v20 != 1) {
+ AFFINVEN = true;
+ }
+ }
+ }
+ if (VIRE_INVENT == true)
+ v20 = 1;
+ if (v20 == 1)
+ break;
+ _vm->_eventsManager.VBL();
+ if ((uint16)(_vm->_globals.ECRAN - 35) <= 5u)
+ _vm->_objectsManager.SPECIAL_JEU();
+ }
+ _vm->_fontManager.TEXTE_OFF(9);
+ if (AFFINVEN) {
+ AFFINVEN = false;
+ v9 = 114;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, v19, 114, v18, v17, _vm->_graphicsManager.VESA_BUFFER, v19, 114);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(v19, 114, v19 + v18, v18 + 114);
+ _vm->_objectsManager.BOBTOUS = true;
+ }
+ if (_vm->_dialogsManager.Winventaire != g_PTRNUL)
+ _vm->_dialogsManager.Winventaire = _vm->_globals.dos_free2(_vm->_dialogsManager.Winventaire);
+ inventaire2 = _vm->_globals.dos_free2(inventaire2);
+
+ if (_vm->_eventsManager.btsouris == 1)
+ showOptionsDialog();
+ if (_vm->_eventsManager.btsouris == 3)
+ _vm->_dialogsManager.CHARGE_PARTIE();
+ if (_vm->_eventsManager.btsouris == 2)
+ _vm->_dialogsManager.SAUVE_PARTIE();
+
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ _vm->_objectsManager.old_cady = 0;
+ _vm->_objectsManager.cady = 0;
+ _vm->_objectsManager.old_cadx = 0;
+ _vm->_objectsManager.cadx = 0;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ _vm->_graphicsManager.no_scroll = 0;
+ }
+}
+
+void DialogsManager::INVENT_ANIM() {
+ int v0;
+ int v1;
+
+ if (!DESACTIVE_INVENT) {
+ if (_vm->_objectsManager.FLAG_VISIBLE_EFFACE && !_vm->_objectsManager.FLAG_VISIBLE) {
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_objectsManager.I_old_x, 27, 48, 38,
+ _vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.I_old_x, 27);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_objectsManager.I_old_x, 27, _vm->_objectsManager.I_old_x + 48, 65);
+ --_vm->_objectsManager.FLAG_VISIBLE_EFFACE;
+ }
+
+ if (_vm->_objectsManager.FLAG_VISIBLE) {
+ if (_vm->_objectsManager.I_old_x <= 1)
+ _vm->_objectsManager.I_old_x = 2;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_objectsManager.I_old_x, 27, 48, 38,
+ _vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.I_old_x, 27);
+
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_objectsManager.I_old_x, 27, _vm->_objectsManager.I_old_x + 48, 65);
+ v0 = _vm->_graphicsManager.ofscroll + 2;
+ v1 = _vm->_graphicsManager.ofscroll + 2;
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.ICONE, v1 + 300, 327, 0);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(v1, 27, v1 + 45, 62);
+ _vm->_objectsManager.I_old_x = v0;
+ }
+
+ if (_vm->_globals.SAUVEGARDE->data[svField357] == 1) {
+ if (_vm->_globals.SAUVEGARDE->data[svField353] == 1)
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 832, 325, 0, 0, 0, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField355] == 1)
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 866, 325, 1, 0, 0, 0);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 560, 60);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(566, 25, 594, 60);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField356] == 1) {
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 832, 325, 0, 0, 0, 0);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 560, 60);
+ }
+
+ if (_vm->_globals.SAUVEGARDE->data[svField354] == 1) {
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.TETE, 832, 325, 0, 0, 0, 0);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 560, 60);
+ }
+ }
+}
+
+void DialogsManager::TestForDialogOpening() {
+ if (_vm->_globals.PLAN_FLAG)
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+
+ if (_vm->_eventsManager.GAME_KEY != KEY_NONE) {
+ if (!INVENTFLAG) {
+ DIALOG_KEY key = _vm->_eventsManager.GAME_KEY;
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+ INVENTFLAG = true;
+
+ switch (key) {
+ case KEY_INVENTORY:
+ _vm->_dialogsManager.showInventory();
+ break;
+ case KEY_OPTIONS:
+ _vm->_dialogsManager.showOptionsDialog();
+ break;
+ case KEY_LOAD:
+ _vm->_dialogsManager.CHARGE_PARTIE();
+ break;
+ case KEY_SAVE:
+ _vm->_dialogsManager.SAUVE_PARTIE();
+ break;
+ default:
+ break;
+ }
+
+ INVENTFLAG = false;
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+ }
+ }
+}
+
+// Load Game
+void DialogsManager::CHARGE_PARTIE() {
+ int slotNumber;
+
+ _vm->_eventsManager.VBL();
+ LOAD_SAUVE(2);
+ do {
+ do {
+ slotNumber = CHERCHE_PARTIE();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_eventsManager.BMOUSE() != 1);
+ } while (!slotNumber);
+ _vm->_objectsManager.SL_FLAG = false;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, 457, 413);
+ _vm->_objectsManager.BOBTOUS = true;
+ _vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
+ _vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+
+ if (slotNumber != 7) {
+ _vm->_saveLoadManager.restore(slotNumber);
+ }
+
+ _vm->_objectsManager.CHANGE_OBJET(14);
+}
+
+// Save Game
+void DialogsManager::SAUVE_PARTIE() {
+ int slotNumber;
+ Common::String saveName;
+
+ _vm->_eventsManager.VBL();
+
+ LOAD_SAUVE(1);
+ do {
+ do {
+ slotNumber = CHERCHE_PARTIE();
+ _vm->_eventsManager.VBL();
+ } while (!_vm->shouldQuit() && _vm->_eventsManager.BMOUSE() != 1);
+ } while (!_vm->shouldQuit() && !slotNumber);
+
+ _vm->_objectsManager.SL_FLAG = false;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x + 183, 60, 274, 353, _vm->_graphicsManager.VESA_BUFFER, _vm->_eventsManager.start_x + 183, 60);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, _vm->_eventsManager.start_x + 457, 413);
+ _vm->_objectsManager.BOBTOUS = true;
+ _vm->_objectsManager.SL_SPR = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR);
+ _vm->_objectsManager.SL_SPR2 = _vm->_globals.dos_free2(_vm->_objectsManager.SL_SPR2);
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+
+ if (slotNumber != 7) {
+ // Since the original GUI doesn't support save names, use a default name
+ saveName = Common::String::format("Save #%d", slotNumber);
+
+ // Save the game
+ _vm->_saveLoadManager.save(slotNumber, saveName);
+ }
+}
+
+
+// Load Save
+void DialogsManager::LOAD_SAUVE(int a1) {
+ int slotNumber;
+ hopkinsSavegameHeader header;
+ byte *thumb;
+
+ switch (_vm->_globals.FR) {
+ case 0:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEAN.SPR");
+ break;
+ case 1:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEFR.SPR");
+ break;
+ case 2:
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEES.SPR");
+ break;
+ }
+
+ _vm->_objectsManager.SL_SPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_fileManager.CONSTRUIT_SYSTEM("SAVE2.SPR");
+ _vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 483, 360, 0);
+
+ if (_vm->_globals.FR) {
+ if (a1 == 1)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 525, 375, 1);
+ if (a1 == 2)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 515, 375, 2);
+ } else {
+ if (a1 == 1)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 535, 372, 1);
+ if (a1 == 2)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 539, 372, 2);
+ }
+
+ for (slotNumber = 1; slotNumber <= 6; ++slotNumber) {
+ if (_vm->_saveLoadManager.readSavegameHeader(slotNumber, header)) {
+ thumb = (byte *)header.thumbnail->pixels;
+
+ switch (slotNumber) {
+ case 1:
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 190, 112, 0x80u, 87);
+ break;
+ case 2:
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 323, 112, 0x80u, 87);
+ break;
+ case 3:
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 190, 203, 0x80u, 87);
+ break;
+ case 4:
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 323, 203, 0x80u, 87);
+ break;
+ case 5:
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 190, 294, 0x80u, 87);
+ break;
+ case 6:
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, thumb, _vm->_eventsManager.start_x + 323, 294, 0x80u, 87);
+ break;
+ }
+
+ delete header.thumbnail;
+ }
+ }
+
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 183, 60, 0x112u, 353);
+ _vm->_objectsManager.SL_FLAG = true;
+ _vm->_objectsManager.SL_MODE = a1;
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+}
+
+// Search Game
+int DialogsManager::CHERCHE_PARTIE() {
+ int slotNumber;
+ int xp;
+ int yp;
+
+ slotNumber = 0;
+ xp = _vm->_eventsManager.XMOUSE();
+ yp = _vm->_eventsManager.YMOUSE();
+
+ _vm->_graphicsManager.ofscroll = _vm->_eventsManager.start_x;
+ if ((uint16)(yp - 112) <= 0x56u) {
+ if (xp > _vm->_eventsManager.start_x + 189 && xp < _vm->_eventsManager.start_x + 318)
+ slotNumber = 1;
+ if ((uint16)(yp - 112) <= 0x56u && xp > _vm->_graphicsManager.ofscroll + 322 && xp < _vm->_graphicsManager.ofscroll + 452)
+ slotNumber = 2;
+ }
+ if ((uint16)(yp - 203) <= 0x56u) {
+ if (xp > _vm->_graphicsManager.ofscroll + 189 && xp < _vm->_graphicsManager.ofscroll + 318)
+ slotNumber = 3;
+ if ((uint16)(yp - 203) <= 0x56u && xp > _vm->_graphicsManager.ofscroll + 322 && xp < _vm->_graphicsManager.ofscroll + 452)
+ slotNumber = 4;
+ }
+ if ((uint16)(yp - 294) <= 0x56u) {
+ if (xp > _vm->_graphicsManager.ofscroll + 189 && xp < _vm->_graphicsManager.ofscroll + 318)
+ slotNumber = 5;
+ if ((uint16)(yp - 294) <= 0x56u && xp > _vm->_graphicsManager.ofscroll + 322 && xp < _vm->_graphicsManager.ofscroll + 452)
+ slotNumber = 6;
+ }
+ if ((uint16)(yp - 388) <= 0x10u && xp > _vm->_graphicsManager.ofscroll + 273 && xp < _vm->_graphicsManager.ofscroll + 355)
+ slotNumber = 7;
+ if (slotNumber == 1) {
+ _vm->_objectsManager.SL_X = 189;
+ _vm->_objectsManager.SL_Y = 111;
+ }
+ if (slotNumber == 2) {
+ _vm->_objectsManager.SL_X = 322;
+ _vm->_objectsManager.SL_Y = 111;
+ }
+ if (slotNumber == 3) {
+ _vm->_objectsManager.SL_X = 189;
+ _vm->_objectsManager.SL_Y = 202;
+ }
+ if (slotNumber == 4) {
+ _vm->_objectsManager.SL_X = 322;
+ _vm->_objectsManager.SL_Y = 202;
+ }
+ if (slotNumber == 5) {
+ _vm->_objectsManager.SL_X = 189;
+ _vm->_objectsManager.SL_Y = 293;
+ }
+ if (slotNumber == 6) {
+ _vm->_objectsManager.SL_X = 322;
+ _vm->_objectsManager.SL_Y = 293;
+ }
+ if (slotNumber == 7 || !slotNumber) {
+ _vm->_objectsManager.SL_X = 0;
+ _vm->_objectsManager.SL_Y = 0;
+ }
+ return slotNumber;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/dialogs.h b/engines/hopkins/dialogs.h
new file mode 100644
index 0000000000..3f4cdfadbb
--- /dev/null
+++ b/engines/hopkins/dialogs.h
@@ -0,0 +1,67 @@
+/* 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_DIALOGS_H
+#define HOPKINS_DIALOGS_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/error.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+/**
+ * Class for manging game dialogs
+ */
+class DialogsManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ bool DESACTIVE_INVENT;
+ bool INVENTFLAG;
+ bool AFFINVEN;
+ bool VIRE_INVENT;
+ int inventairex, inventairey;
+ int inventairel, inventaireh;
+ byte *Winventaire;
+ byte *inventaire2;
+public:
+ DialogsManager();
+ ~DialogsManager();
+ void setParent(HopkinsEngine *vm);
+
+ void showOptionsDialog();
+ void showInventory();
+
+ void INVENT_ANIM();
+ void TestForDialogOpening();
+ void CHARGE_PARTIE();
+ void SAUVE_PARTIE();
+ void LOAD_SAUVE(int a1);
+ int CHERCHE_PARTIE();
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_MENU_H */
diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp
new file mode 100644
index 0000000000..0b3d252f57
--- /dev/null
+++ b/engines/hopkins/events.cpp
@@ -0,0 +1,501 @@
+/* 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 "common/textconsole.h"
+#include "hopkins/events.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/sound.h"
+
+namespace Hopkins {
+
+EventsManager::EventsManager() {
+ souris_flag = false;
+ mouse_linux = false;
+ souris_sizex = souris_sizey = 0;
+ ofset_souris_x = ofset_souris_y = 0;
+ start_x = start_y = 0;
+ CASSE = false;
+ souris_n = 0;
+ souris_bb = 0;
+ souris_b = 0;
+ pointeur_souris = NULL;
+ _gameCounter = 0;
+ lItCounter = 0;
+ ESC_KEY = false;
+ GAME_KEY = KEY_NONE;
+ btsouris = 0;
+ OLD_ICONE = 0;
+
+ _priorCounterTime = 0;
+ _priorFrameTime = 0;
+}
+
+void EventsManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+// Install Mouse
+void EventsManager::INSTALL_SOURIS() {
+ // No implementation in original
+}
+
+// Mouse On
+void EventsManager::souris_on() {
+ souris_flag = true;
+
+ if (mouse_linux) {
+ souris_sizex = 52;
+ souris_sizey = 32;
+ } else {
+ souris_sizex = 34;
+ souris_sizey = 20;
+ }
+
+ ofset_souris_x = 0;
+ ofset_souris_y = 0;
+
+ if (!CASSE)
+ souris_xy(300, 200);
+ else
+ souris_xy(150, 100);
+}
+
+// Set Mouse position
+void EventsManager::souris_xy(int xp, int yp) {
+ g_system->warpMouse(xp, yp);
+}
+
+// Mouse Max
+void EventsManager::souris_max() {
+ // No implementation in original
+}
+
+// Get Mouse X
+int EventsManager::XMOUSE() {
+ souris_x = start_x + g_system->getEventManager()->getMousePos().x;
+ souris_y = g_system->getEventManager()->getMousePos().y;
+
+ return souris_x + ofset_souris_x;
+}
+
+// Get Mouse Y
+int EventsManager::YMOUSE() {
+ souris_x = start_x + g_system->getEventManager()->getMousePos().x;
+ souris_y = g_system->getEventManager()->getMousePos().y;
+
+ return souris_y + ofset_souris_y;
+}
+
+// Get Mouse Button
+int EventsManager::BMOUSE() {
+ CONTROLE_MES();
+ return souris_bb;
+}
+
+// Mouse Off
+void EventsManager::MOUSE_OFF() {
+ souris_flag = false;
+ g_system->showMouse(false);
+}
+
+// Mouse On
+void EventsManager::MOUSE_ON() {
+ souris_on();
+ souris_flag = true;
+ g_system->showMouse(true);
+}
+
+// Change Mouse Cursor
+void EventsManager::CHANGE_MOUSE(int id) {
+ int cursorId = id;
+
+ if (btsouris != 23) {
+ if (id == 4 && btsouris == 4 && _vm->_globals.NOMARCHE)
+ cursorId = 0;
+ if (cursorId == 25)
+ cursorId = 5;
+
+ if (OLD_ICONE != cursorId || !cursorId) {
+ OLD_ICONE = cursorId;
+ souris_n = cursorId;
+
+ // Backup the current sprite clipping bounds and reset them
+ Common::Rect clipBounds(_vm->_graphicsManager.min_x, _vm->_graphicsManager.min_y,
+ _vm->_graphicsManager.max_x, _vm->_graphicsManager.max_y);
+ _vm->_graphicsManager.min_x = _vm->_graphicsManager.min_y = 0;
+ _vm->_graphicsManager.max_x = _vm->_globals.OBJL;
+ _vm->_graphicsManager.max_y = _vm->_globals.OBJH;
+ int pitch = _vm->_graphicsManager.nbrligne2;
+ _vm->_graphicsManager.nbrligne2 = _vm->_globals.OBJL;
+
+ // Draw the cursor onto a temporary surface
+ byte *cursorSurface = new byte[_vm->_globals.OBJH * _vm->_globals.OBJL];
+ Common::fill(cursorSurface, cursorSurface + _vm->_globals.OBJH * _vm->_globals.OBJL, 0);
+ _vm->_graphicsManager.Sprite_Vesa(cursorSurface, pointeur_souris, 300, 300, cursorId);
+
+ // Reset the clipping bounds
+ _vm->_graphicsManager.min_x = clipBounds.left;
+ _vm->_graphicsManager.min_y = clipBounds.top;
+ _vm->_graphicsManager.max_x = clipBounds.right;
+ _vm->_graphicsManager.max_y = clipBounds.bottom;
+ _vm->_graphicsManager.nbrligne2 = pitch;
+
+ // Convert the cursor to the pixel format. At the moment, it's hardcoded
+ // to expect the game to be in 16-bit mode
+ uint16 *cursorPixels = new uint16[_vm->_globals.OBJH * _vm->_globals.OBJL];
+ const byte *srcP = cursorSurface;
+ uint16 *destP = cursorPixels;
+
+ for (int yp = 0; yp < _vm->_globals.OBJH; ++yp) {
+ const byte *lineSrcP = srcP;
+ uint16 *lineDestP = destP;
+
+ for (int xp = 0; xp < _vm->_globals.OBJL; ++xp)
+ *lineDestP++ = *(uint16 *)&_vm->_graphicsManager.PAL_PIXELS[*lineSrcP++ * 2];
+
+ srcP += _vm->_globals.OBJL;
+ destP += _vm->_globals.OBJL;
+ }
+
+ // Calculate the X offset within the pointer image to the actual cursor data
+ int xOffset = !mouse_linux ? 10 : 20;
+
+ // Set the ScummVM cursor from the surface
+ Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
+ g_system->setMouseCursor(cursorPixels, _vm->_globals.OBJL, _vm->_globals.OBJH,
+ xOffset, 0, 0, true, &pixelFormat);
+
+ // Delete the cursor surface
+ delete[] cursorPixels;
+ delete[] cursorSurface;
+ }
+ }
+}
+
+// Check Events
+void EventsManager::CONTROLE_MES() {
+ pollEvents();
+}
+
+void EventsManager::checkForNextFrameCounter() {
+ // Check for whether to increment the game counter
+ uint32 milli = g_system->getMillis();
+ while ((milli - _priorCounterTime) >= 10) {
+ _priorCounterTime += 10;
+ lItCounter += 3;
+ }
+
+ // Check for next game frame
+ if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
+ ++_gameCounter;
+ _priorFrameTime = milli;
+ g_system->updateScreen();
+
+ // Signal the ScummVM debugger
+ _vm->_debugger.onFrame();
+ }
+}
+
+void EventsManager::delay(int totalMilli) {
+ uint32 delayEnd = g_system->getMillis() + totalMilli;
+
+ while (!g_system->getEventManager()->shouldQuit() && g_system->getMillis() < delayEnd) {
+ g_system->delayMillis(10);
+ }
+}
+
+void EventsManager::pollEvents() {
+ checkForNextFrameCounter();
+
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ // Handle keypress
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ case Common::EVENT_RTL:
+ return;
+
+ case Common::EVENT_KEYDOWN:
+ handleKey(event);
+ return;
+
+ case Common::EVENT_LBUTTONDOWN:
+ souris_b = 1;
+ break;
+ case Common::EVENT_RBUTTONDOWN:
+ souris_b = 2;
+ break;
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ souris_b = 0;
+ return;
+
+ default:
+ break;
+ }
+ }
+}
+
+void EventsManager::handleKey(Common::Event &event) {
+ ESC_KEY = event.kbd.keycode == Common::KEYCODE_ESCAPE;
+
+ if (event.kbd.keycode == Common::KEYCODE_i || event.kbd.keycode == Common::KEYCODE_TAB)
+ GAME_KEY = KEY_INVENTORY;
+ else if (event.kbd.keycode == Common::KEYCODE_F5)
+ GAME_KEY = KEY_SAVE;
+ else if (event.kbd.keycode == Common::KEYCODE_F7)
+ GAME_KEY = KEY_LOAD;
+ else if (event.kbd.keycode == Common::KEYCODE_F1 || event.kbd.keycode == Common::KEYCODE_o)
+ GAME_KEY = KEY_OPTIONS;
+
+ // Check for debugger
+ if ((event.kbd.keycode == Common::KEYCODE_d) && (event.kbd.flags & Common::KBD_CTRL)) {
+ // Attach to the debugger
+ _vm->_debugger.attach();
+ _vm->_debugger.onFrame();
+ }
+
+}
+
+void EventsManager::VBL() {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v10;
+ signed int v11 = 0;
+ signed int v12 = 0;
+ int v13 = 0;
+ unsigned int v14 = 0;
+ int v15 = 0;
+ int yp = 0;
+
+ if (_vm->_graphicsManager.REDRAW) {
+ _vm->_graphicsManager.DD_Lock();
+ if (CASSE) {
+ _vm->_graphicsManager.CopyAsm(_vm->_graphicsManager.VESA_BUFFER);
+ _vm->_graphicsManager.REDRAW = 0;
+ } else {
+ if (_vm->_globals.iRegul == 3)
+ _vm->_graphicsManager.m_scroll(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll, 50, 0x280u, 340, 0, 50);
+ else
+ _vm->_graphicsManager.m_scroll(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll, 20, 0x280u, 440, 0, 20);
+ _vm->_fileManager.DMESS();
+ --_vm->_graphicsManager.REDRAW;
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ }
+ if (souris_flag == true) {
+ v1 = 20;
+ if (!mouse_linux)
+ v1 = 10;
+ v2 = 20;
+ if (!mouse_linux)
+ v2 = 15;
+ v15 = souris_x - v1;
+ yp = souris_y;
+ v14 = souris_sizex;
+ v13 = souris_sizey;
+ if (btsouris == 23) {
+ v14 = _vm->_globals.OBJL;
+ v13 = _vm->_globals.OBJH;
+ goto LABEL_35;
+ }
+ if (CASSE) {
+ if (v15 < _vm->_graphicsManager.min_x)
+ v15 = _vm->_graphicsManager.min_x;
+ if (souris_y < _vm->_graphicsManager.min_y)
+ yp = _vm->_graphicsManager.min_y;
+ if (souris_sizex + v15 >= _vm->_graphicsManager.max_x)
+ v14 = souris_sizex - (souris_sizex + v15 - _vm->_graphicsManager.max_x);
+ if (yp + souris_sizey < _vm->_graphicsManager.max_y)
+ goto LABEL_34;
+ v3 = yp + souris_sizey - _vm->_graphicsManager.max_y;
+ } else {
+ if (v15 < _vm->_graphicsManager.min_x)
+ v15 = _vm->_graphicsManager.min_x - v1;
+ v2 = (int16)v2;
+ if (souris_y < _vm->_graphicsManager.min_y - (int16)v2)
+ yp = _vm->_graphicsManager.min_y - (int16)v2;
+ if (souris_sizex + v15 >= _vm->_graphicsManager.max_x)
+ v14 = souris_sizex - (souris_sizex + v15 - _vm->_graphicsManager.max_x - v1);
+ if (yp + souris_sizey < v2 + _vm->_graphicsManager.max_y)
+ goto LABEL_34;
+ v3 = v2 + yp + souris_sizey - _vm->_graphicsManager.max_y;
+ }
+ v13 = souris_sizey - v3;
+LABEL_34:
+ v12 = v14 + v15;
+ v11 = yp + v13;
+ }
+LABEL_35:
+ if (!_vm->_globals.PUBEXIT)
+ _vm->_objectsManager.AFF_SPRITES();
+ if (souris_flag != true)
+ goto LABEL_54;
+ if (btsouris == 23)
+ goto LABEL_45;
+ if (yp >= _vm->_graphicsManager.max_y || v15 >= _vm->_graphicsManager.max_x || v14 <= 1 || v13 <= 1) {
+ if (btsouris != 23)
+ goto LABEL_54;
+LABEL_45:
+ if (yp < _vm->_graphicsManager.max_y && v15 < _vm->_graphicsManager.max_x) {
+ if ((signed int)(v14 + v15) > _vm->_graphicsManager.max_x)
+ v14 -= v14 + v15 - _vm->_graphicsManager.max_x;
+ if (yp + v13 > _vm->_graphicsManager.max_y)
+ v13 -= yp + v13 - _vm->_graphicsManager.max_y;
+ if (v14 > 1 && v13 > 1) {
+/* Commented out in favour of using ScummVM cursor display
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, yp, v14, v13);
+*/
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Bufferobjet, v15 + 300, yp + 300, 0, 0, 0, 0);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(v15, yp, v14 + v15, yp + v13);
+ }
+ }
+ goto LABEL_54;
+ }
+
+/* Commented out in favour of using ScummVM cursor display
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, yp, v14, v13);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, pointeur_souris, v15 + 300, yp + 300, souris_n);
+*/
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(v15, yp, v12, v11);
+LABEL_54:
+ _vm->_globals.vitesse = 2;
+ do {
+ while (!_vm->shouldQuit()) {
+ checkForNextFrameCounter();
+
+ while (CASSE || _vm->_globals.iRegul != 1) {
+ if (CASSE != true)
+ goto LABEL_63;
+ if (lItCounter > 1)
+ goto LABEL_65;
+ }
+ if (_vm->_globals.vitesse != 2)
+ break;
+ if (lItCounter > 9)
+ goto LABEL_65;
+ }
+LABEL_63:
+ ;
+ } while (!_vm->shouldQuit() && _vm->_globals.iRegul == 3 && lItCounter <= 15);
+LABEL_65:
+ _vm->_globals.vitesse = 2;
+ lItCounter = 0;
+ if (_vm->_graphicsManager.DOUBLE_ECRAN != true || _vm->_graphicsManager.no_scroll == 1) {
+ _vm->_graphicsManager.Affiche_Segment_Vesa();
+ } else {
+ if (_vm->_graphicsManager.no_scroll != 2) {
+ if (XMOUSE() > _vm->_graphicsManager.SCROLL + 620)
+ _vm->_graphicsManager.SCROLL += _vm->_graphicsManager.SPEED_SCROLL;
+ if (XMOUSE() < _vm->_graphicsManager.SCROLL + 10)
+ _vm->_graphicsManager.SCROLL -= _vm->_graphicsManager.SPEED_SCROLL;
+ }
+ if (_vm->_graphicsManager.SCROLL < 0)
+ _vm->_graphicsManager.SCROLL = 0;
+ if (_vm->_graphicsManager.SCROLL > 640)
+ _vm->_graphicsManager.SCROLL = 640;
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ v4 = _vm->_graphicsManager.Magic_Number(_vm->_graphicsManager.SCROLL);
+ else
+ v4 = _vm->_graphicsManager.SCROLL;
+ if (_vm->_graphicsManager.OLD_SCROLL == v4) {
+ _vm->_graphicsManager.Affiche_Segment_Vesa();
+ } else {
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.SDL_ECHELLE) {
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ v5 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, v5);
+ } else {
+ v6 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, v6);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.dstrect[0].left = _vm->_graphicsManager.Reel_Zoom(0, _vm->_graphicsManager.SDL_ECHELLE);
+ _vm->_graphicsManager.dstrect[0].top = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE);
+ _vm->_graphicsManager.dstrect[0].setWidth(_vm->_graphicsManager.Reel_Zoom(0x280u, _vm->_graphicsManager.SDL_ECHELLE));
+ _vm->_graphicsManager.dstrect[0].setHeight(_vm->_graphicsManager.Reel_Zoom(0x1B8u, _vm->_graphicsManager.SDL_ECHELLE));
+ } else {
+ if (_vm->_graphicsManager.Winbpp == 2)
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, 20);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, 20);
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.dstrect[0] = Common::Rect(0, 20, 640, 460);
+ }
+ if (!_vm->_globals.BPP_NOAFF) {
+// SDL_UpdateRects(LinuxScr, 1, dstrect);
+ }
+ if (_vm->_globals.NBBLOC) {
+ v7 = 1;
+ v10 = _vm->_globals.NBBLOC + 1;
+ do {
+ if (_vm->_globals.BLOC[v7].field0 == 1)
+ _vm->_globals.BLOC[v7].field0 = 0;
+ ++v7;
+ } while (v10 != v7);
+ }
+ _vm->_globals.NBBLOC = 0;
+ start_x = v4;
+ _vm->_graphicsManager.ofscroll = v4;
+ _vm->_graphicsManager.SCROLL = v4;
+ }
+ _vm->_graphicsManager.OLD_SCROLL = v4;
+ start_x = v4;
+ _vm->_graphicsManager.ofscroll = v4;
+ }
+ souris_bb = souris_b;
+ souris_b = 0;
+ if (souris_flag == true) {
+ if (btsouris != 23) {
+ if (yp < _vm->_graphicsManager.max_y && v15 < _vm->_graphicsManager.max_x && v14 > 1 && v13 > 1) {
+/* Commented out in favour of using ScummVM cursor display
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, yp, v14, v13);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(v15, yp, v12, v11);
+*/
+ goto LABEL_113;
+ }
+ if (btsouris != 23)
+ goto LABEL_113;
+ }
+ if (yp < _vm->_graphicsManager.max_y && v15 < _vm->_graphicsManager.max_x && v14 > 1 && v13 > 1) {
+/* Commented out in favour of using ScummVM cursor display
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.cache_souris, v15, yp, v14, v13);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(v15, yp, v14 + v15, yp + v13);
+*/
+ }
+ }
+LABEL_113:
+ _vm->_soundManager.VERIF_SOUND();
+ CONTROLE_MES();
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/events.h b/engines/hopkins/events.h
new file mode 100644
index 0000000000..364a74fcf8
--- /dev/null
+++ b/engines/hopkins/events.h
@@ -0,0 +1,89 @@
+/* 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_EVENTS_H
+#define HOPKINS_EVENTS_H
+
+#include "common/scummsys.h"
+#include "common/events.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+#define GAME_FRAME_RATE 50
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
+
+class HopkinsEngine;
+
+enum DIALOG_KEY { KEY_NONE = 0, KEY_INVENTORY = 1, KEY_OPTIONS = 2, KEY_SAVE = 3, KEY_LOAD = 4 };
+
+class EventsManager {
+private:
+ HopkinsEngine *_vm;
+
+ void pollEvents();
+ void handleKey(Common::Event &event);
+ void checkForNextFrameCounter();
+public:
+ bool souris_flag;
+ bool mouse_linux;
+ int souris_sizex, souris_sizey;
+ int ofset_souris_x, ofset_souris_y;
+ int start_x, start_y;
+ int souris_x, souris_y;
+ bool CASSE;
+ int OLD_ICONE;
+ int souris_n;
+ int souris_bb;
+ int souris_b;
+ byte *pointeur_souris;
+ uint32 _gameCounter;
+ uint32 lItCounter;
+ uint32 _priorCounterTime;
+ uint32 _priorFrameTime;
+ bool ESC_KEY;
+ bool NOESC;
+ DIALOG_KEY GAME_KEY;
+ int btsouris;
+public:
+ EventsManager();
+ void setParent(HopkinsEngine *vm);
+
+ void INSTALL_SOURIS();
+ void souris_on();
+ void souris_xy(int xp, int yp);
+ void souris_max();
+ int XMOUSE();
+ int YMOUSE();
+ int BMOUSE();
+ void MOUSE_ON();
+ void MOUSE_OFF();
+ void CHANGE_MOUSE(int id);
+
+ void CONTROLE_MES();
+ void delay(int delay);
+ void VBL();
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_EVENTS_H */
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
new file mode 100644
index 0000000000..79b672ca33
--- /dev/null
+++ b/engines/hopkins/files.cpp
@@ -0,0 +1,323 @@
+/* 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/files.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/globals.h"
+#include "common/system.h"
+#include "common/debug.h"
+#include "common/file.h"
+#include "common/str.h"
+#include "common/savefile.h"
+
+namespace Hopkins {
+
+FileManager::FileManager() {
+}
+
+void FileManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+// Load INI File
+void FileManager::Chage_Inifile(Common::StringMap &iniParams) {
+ // TODO: Review whether we can do something cleaner with ScummVM initialisation than
+ // just initialising the INI array as if it had read in the INI file
+
+ iniParams["FULLSCREEN"] = "NO";
+ iniParams["SETMODE"] = "1"; // 640x480
+ iniParams["ZOOM"] = "100"; // No zooming
+ iniParams["VIDEOMEM"] = "YES";
+ iniParams["FORCE8BITS"] = "NO";
+ iniParams["FORCE16BITS"] = "YES";
+ iniParams["SOUND"] = "YES";
+}
+
+// Load File
+byte *FileManager::CHARGE_FICHIER(const Common::String &file) {
+ DMESS1();
+
+ Common::File f;
+ if (!f.open(file))
+ error("Error opening %s", file.c_str());
+
+ // Allocate space for the file contents
+ size_t filesize = f.size();
+ byte *data = _vm->_globals.dos_malloc2(filesize);
+ if (!data)
+ error("Error allocating space for file being loaded - %s", file.c_str());
+
+ bload_it(f, data, filesize);
+ f.close();
+
+ return data;
+}
+
+// Load File 2
+void FileManager::CHARGE_FICHIER2(const Common::String &file, byte *buf) {
+ Common::File f;
+ size_t filesize;
+
+ DMESS1();
+ if (!f.open(file))
+ error("Error opening file - %s", file.c_str());
+
+ filesize = f.size();
+ _vm->_fileManager.bload_it(f, buf, filesize);
+ f.close();
+}
+
+// Guess: Debug Message
+void FileManager::DMESS() {
+ // No implementation in original
+}
+
+// Guess: Debug Message 1
+void FileManager::DMESS1() {
+ // No implementation in original
+}
+
+void FileManager::bload(const Common::String &file, byte *buf) {
+ Common::File f;
+ if (!f.open(file))
+ error("Error openinig file - %s", file.c_str());
+ int32 filesize = f.size();
+ _vm->_fileManager.bload_it(f, buf, filesize);
+ f.close();
+}
+
+int FileManager::bload_it(Common::ReadStream &stream, void *buf, size_t nbytes) {
+ return stream.read(buf, nbytes);
+}
+
+// Censorship
+void FileManager::F_Censure() {
+ _vm->_globals.CENSURE = false;
+
+ CONSTRUIT_SYSTEM("BLOOD.DAT");
+ char *data = (char *)CHARGE_FICHIER(_vm->_globals.NFICHIER);
+
+ if (*(data + 6) == 'f' && *(data + 7) == 'r')
+ _vm->_globals.CENSURE = false;
+ if (*(data + 6) == 'F' && *(data + 7) == 'R')
+ _vm->_globals.CENSURE = false;
+ if (*(data + 6) == 'u' && *(data + 7) == 'k')
+ _vm->_globals.CENSURE = true;
+ if (*(data + 6) == 'U' && *(data + 7) == 'K')
+ _vm->_globals.CENSURE = true;
+
+ free(data);
+}
+
+// Build System
+int FileManager::CONSTRUIT_SYSTEM(const Common::String &file) {
+ _vm->_globals.NFICHIER = Common::String::format("system/%s", file.c_str());
+ return _vm->_globals.NFICHIER.size();
+}
+
+// Build File
+void FileManager::CONSTRUIT_FICHIER(const Common::String &hop, const Common::String &file) {
+ // At this point, the original program did a big switch statement to determine
+ // whether to preprend the CD or installed directory path into REPJEU
+
+ if (hop[0] == 'A' && hop[1] == 'N' && hop[2] == 'N') {
+ error("TODO: CONSTRUIT_FICHIER");
+ }
+
+ _vm->_globals.NFICHIER = Common::String::format("%s/%s", hop.c_str(), file.c_str());
+}
+
+// Free File
+byte *FileManager::LIBERE_FICHIER(byte *ptr) {
+ free(ptr);
+ return g_PTRNUL;
+}
+
+// Search Cat
+byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
+ byte *ptr = NULL;
+ Common::File f;
+
+ Common::String filename = file;
+ filename.toUppercase();
+
+ switch (a2) {
+ case 1:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_INI.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_INI.RES");
+ break;
+
+ case 2:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_REP.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_REP.RES");
+ break;
+
+ case 3:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_LIN.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_LIN.RES");
+ break;
+
+ case 4:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_ANI.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_ANI.RES");
+ break;
+
+ case 5:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_PER.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_PER.RES");
+ break;
+
+ case 6:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ break;
+
+ case 7:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ break;
+
+ case 8:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.CAT");
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ break;
+
+ case 9:
+ switch (_vm->_globals.FR) {
+ case 0:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_VAN.CAT");
+ break;
+ case 1:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_VFR.CAT");
+ break;
+ case 2:
+ CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_VES.CAT");
+ break;
+ }
+
+ if (!f.exists(_vm->_globals.NFICHIER))
+ return g_PTRNUL;
+
+ ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ break;
+ // Deliberate fall-through to
+ default:
+ break;
+ }
+
+ // Scan for an entry in the catalogue
+ byte *result;
+ bool matchFlag = false;
+ int offsetVal = 0;
+
+ do {
+ Common::String name = (const char *)ptr + offsetVal;
+
+ if (name == filename) {
+ // Found entry for file, so get it's details from the catalogue entry
+ const byte *pData = ptr + offsetVal;
+ _vm->_globals.CAT_POSI = READ_LE_UINT32(pData + 15);
+ _vm->_globals.CAT_TAILLE = READ_LE_UINT32(pData + 19);
+ matchFlag = true;
+ }
+
+ if (name == "FINIS") {
+ _vm->_globals.dos_free2(ptr);
+ return false;
+ }
+
+ offsetVal += 23;
+ } while (!matchFlag);
+
+ _vm->_globals.dos_free2(ptr);
+
+ // TODO: Double check whether this really should be an unsigned int comparison
+ if ((uint16)(a2 - 6) > 1 && (uint16)(a2 - 8) > 1) {
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("CHARGE_FICHIER");
+
+ f.seek(_vm->_globals.CAT_POSI);
+
+ byte *catData = _vm->_globals.dos_malloc2(_vm->_globals.CAT_TAILLE);
+ if (catData == g_PTRNUL)
+ error("CHARGE_FICHIER");
+
+ bload_it(f, catData, _vm->_globals.CAT_TAILLE);
+ f.close();
+ result = catData;
+ } else {
+ result = NULL;
+ }
+
+ return result;
+}
+
+// File Size
+uint32 FileManager::FLONG(const Common::String &filename) {
+ Common::File f;
+ uint32 size;
+
+ if (!f.open(filename))
+ error("Could not find file %s", filename.c_str());
+
+ size = f.size();
+ f.close();
+
+ return size;
+}
+
+// Build Linux
+Common::String FileManager::CONSTRUIT_LINUX(const Common::String &file) {
+ _vm->_globals.NFICHIER = file;
+ return file;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h
new file mode 100644
index 0000000000..d9df4341ca
--- /dev/null
+++ b/engines/hopkins/files.h
@@ -0,0 +1,64 @@
+/* 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_FILES_H
+#define HOPKINS_FILES_H
+
+#include "common/scummsys.h"
+#include "common/hash-str.h"
+#include "common/str.h"
+#include "common/stream.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+class FileManager {
+public:
+ HopkinsEngine *_vm;
+public:
+ FileManager();
+ void setParent(HopkinsEngine *vm);
+
+ void Chage_Inifile(Common::StringMap &iniParams);
+ byte *CHARGE_FICHIER(const Common::String &file);
+ void CHARGE_FICHIER2(const Common::String &file, byte *a2);
+ void DMESS();
+ void DMESS1();
+ void bload(const Common::String &file, byte *buf);
+ int bload_it(Common::ReadStream &stream, void *buf, size_t nbytes);
+ void F_Censure();
+ int CONSTRUIT_SYSTEM(const Common::String &file);
+ void CONSTRUIT_FICHIER(const Common::String &hop, const Common::String &file);
+ byte *LIBERE_FICHIER(byte *ptr);
+ byte *RECHERCHE_CAT(const Common::String &file, int a2);
+ Common::String CONSTRUIT_LINUX(const Common::String &file);
+
+ /**
+ * Returns the size of a file. Throws an error if the file can't be found
+ */
+ uint32 FLONG(const Common::String &filename);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_GLOBALS_H */
diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp
new file mode 100644
index 0000000000..651d0d40f5
--- /dev/null
+++ b/engines/hopkins/font.cpp
@@ -0,0 +1,497 @@
+/* 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 "common/file.h"
+#include "common/textconsole.h"
+#include "hopkins/font.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/objects.h"
+
+namespace Hopkins {
+
+void FontManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+void FontManager::clearAll() {
+ for (int idx = 0; idx < 11; ++idx) {
+ Txt[idx].textOn = false;
+ Txt[idx].lineCount = 0;
+ Txt[idx].field3FC = 0;
+ Txt[idx].field3FE = 0;
+ Txt[idx].textBlock = NULL;
+ Txt[idx].width = 0;
+ Txt[idx].height = 0;
+ Txt[idx].textLoaded = false;
+
+ ListeTxt[idx].enabled = false;
+ }
+}
+
+// Text On
+void FontManager::TEXTE_ON(int idx) {
+ if ((idx - 5) > 11)
+ error("Attempted to display text > MAX_TEXT.");
+
+ TxtItem &txt = Txt[idx - 5];
+ txt.textOn = true;
+ txt.textLoaded = false;
+
+ if (txt.textBlock != g_PTRNUL) {
+ _vm->_globals.dos_free2(txt.textBlock);
+ txt.textBlock = g_PTRNUL;
+ }
+}
+
+// Text Off
+void FontManager::TEXTE_OFF(int idx) {
+ if ((idx - 5) > 11)
+ error("Attempted to display text > MAX_TEXT.");
+
+ TxtItem &txt = Txt[idx - 5];
+ txt.textOn = false;
+ txt.textLoaded = false;
+
+ if (txt.textBlock != g_PTRNUL) {
+ _vm->_globals.dos_free2(txt.textBlock);
+ txt.textBlock = g_PTRNUL;
+ }
+}
+
+// Text Color
+void FontManager::COUL_TXT(int idx, byte colByte) {
+ Txt[idx - 5].colour = colByte;
+}
+
+// Text Optimal Color
+void FontManager::OPTI_COUL_TXT(int idx1, int idx2, int idx3, int idx4) {
+ COUL_TXT(idx1, 255);
+ COUL_TXT(idx2, 255);
+ COUL_TXT(idx3, 255);
+ COUL_TXT(idx4, 253);
+}
+
+//
+void FontManager::DOS_TEXT(int idx, int messageId, const Common::String &filename, int xp, int yp, int a6, int a7, int a8, int a9, int colour) {
+ if ((idx - 5) > 11)
+ error("Attempted to display text > MAX_TEXT.");
+
+ TxtItem &txt = Txt[idx - 5];
+ txt.textOn = false;
+ txt.filename = filename;
+ txt.xp = xp;
+ txt.yp = yp;
+ txt.messageId = messageId;
+ txt.fieldE = a6;
+ txt.field10 = a7;
+ txt.field3FC = a8;
+ txt.field3FE = a9;
+ txt.colour = colour;
+}
+
+// Box
+void FontManager::BOITE(int idx, int messageId, const Common::String &filename, int xp, int yp) {
+ int filesize;
+ byte *v9;
+ const byte *v10;
+ int v11;
+ byte v13;
+ byte v14;
+ int v15;
+ byte v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ byte v24;
+ int v25;
+ int v27;
+ int v28;
+ int v29;
+ int v32;
+ int v34;
+ int v36;
+ int v37;
+ int ptrb;
+ int ptrc;
+ byte *ptrd;
+ byte *ptre;
+ Common::String s;
+ int v49;
+ int blockSize;
+ int v51;
+ int blockHeight;
+ int v53;
+ int blockWidth;
+ int v55;
+ int v56;
+ int lineSize;
+ int lineCount;
+ byte *v59;
+ byte *v60;
+ byte *v61;
+ int v62;
+ int v63;
+ int v64;
+ int v65;
+ int v66;
+ int v67;
+ int v68;
+ int v69;
+ int v70;
+ int v71;
+ int v73;
+ int i;
+ int v75;
+ Common::String file;
+ Common::File f;
+
+ v73 = xp;
+ v70 = yp;
+ lineCount = 0;
+ if (idx < 0)
+ error("Bad number for text");
+ _vm->_globals.police_l = 11;
+
+ _vm->_globals.largeur_boite = 11 * Txt[idx].field3FE;
+ if (Txt[idx].textLoaded) {
+ v34 = Txt[idx].field3FC;
+ if (v34 != 6 && v34 != 1 && v34 != 3 && v34 != 5) {
+ int yCurrent = yp + 5;
+ if (Txt[idx].lineCount > 0) {
+ for (int lineNum = 0; lineNum < Txt[idx].lineCount; ++lineNum) {
+ TEXT_NOW1(xp + 5, yCurrent, Txt[idx].lines[lineNum], Txt[idx].colour);
+ yCurrent += _vm->_globals.police_h + 1;
+ }
+ }
+ } else {
+ v36 = Txt[idx].height;
+ v37 = Txt[idx].width;
+ _vm->_graphicsManager.Restore_Mem(
+ _vm->_graphicsManager.VESA_BUFFER,
+ Txt[idx].textBlock,
+ xp,
+ yp,
+ Txt[idx].width,
+ Txt[idx].height);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(xp, yp, xp + v37, yp + v36);
+ }
+ } else {
+ v62 = 0;
+ do {
+ TRIER_TEXT[v62++] = 0;
+ } while (v62 <= 19);
+ Txt[idx].textLoaded = true;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename);
+
+ file = _vm->_globals.NFICHIER;
+ if (strncmp(file.c_str(), oldname.c_str(), strlen(file.c_str())) != 0) {
+ // Starting to access a new file, so read in the index file for the file
+ oldname = file;
+ nom_index = Common::String(file.c_str(), file.size() - 3);
+ nom_index += "IND";
+
+ if (!f.open(nom_index))
+ error("Error opening file - %s", nom_index.c_str());
+ filesize = f.size();
+ for (i = 0; i < (filesize / 4); ++i)
+ Index[i] = f.readUint32LE();
+ f.close();
+ }
+ if (filename[0] != 'Z' || filename[1] != 'O') {
+ if (!f.open(file))
+ error("Error opening file - %s", nom_index.c_str());
+
+ v69 = 2048;
+ f.seek(Index[messageId]);
+
+ texte_tmp = _vm->_globals.dos_malloc2(0x80Au);
+ if (texte_tmp == g_PTRNUL)
+ error("Error allocating text");
+
+ Common::fill(&texte_tmp[0], &texte_tmp[0x80a], 0);
+ f.read(texte_tmp, 0x800u);
+ f.close();
+ _vm->_globals.texte_long = 2048;
+ } else {
+ v69 = 100;
+ _vm->_globals.texte_long = 100;
+ v9 = _vm->_globals.dos_malloc2(0x6Eu);
+ Common::fill(&v9[0], &v9[0x6e], 0);
+
+ texte_tmp = v9;
+ v10 = _vm->_globals.BUF_ZONE + Index[messageId];
+ memcpy(v9, v10, 0x60u);
+ v11 = 0;
+ WRITE_LE_UINT16((uint16 *)v9 + 48, (int16)READ_LE_UINT16(v10 + 96));
+ }
+ v59 = texte_tmp;
+ v63 = 0;
+ if (!v69)
+ goto LABEL_43;
+ do {
+ v13 = *v59;
+ if ((byte)(*v59 + 46) > 0x1Bu) {
+ if ((byte)(v13 + 80) > 0x1Bu) {
+ if ((byte)(v13 - 65) <= 0x19u || (byte)(v13 - 97) <= 0x19u)
+ v13 = 32;
+ } else {
+ v13 -= 79;
+ }
+ } else {
+ v13 += 111;
+ }
+ *v59 = v13;
+ v59 = v59 + 1;
+ ++v63;
+ } while (v63 < v69);
+
+ v60 = texte_tmp;
+ v64 = 0;
+ if (v69) {
+ while (1) {
+ v14 = *(v60 + v64);
+ if (v14 == '\r' || v14 == '\n') {
+ *(v60 + v64) = 0;
+ if (!Txt[idx].field3FE)
+ break;
+ }
+ ++v64;
+ if (v69 <= v64)
+ goto LABEL_43;
+ }
+ Txt[idx].field3FE = v64;
+ _vm->_globals.largeur_boite = 0;
+
+ v15 = 0;
+ if (v64 + 1 > 0) {
+ do {
+ v16 = *(v60 + v15);
+ if ((byte)v16 <= 0x1Fu)
+ v16 = 32;
+ _vm->_globals.largeur_boite += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, (byte)v16 - 32);
+ ++v15;
+ } while (v15 < v64 + 1);
+ }
+ _vm->_globals.largeur_boite += 2;
+ v17 = _vm->_globals.largeur_boite / 2;
+ if (v17 < 0)
+ v17 = -v17;
+ Txt[idx].xp = 320 - v17;
+ v73 = _vm->_eventsManager.start_x + 320 - v17;
+ lineCount = 1;
+ v18 = 0;
+ if (v64 + 1 > 0) {
+ Txt[idx].lines[0] = Common::String((const char *)v60, v64);
+ }
+ } else {
+LABEL_43:
+ if (!_vm->_globals.largeur_boite)
+ _vm->_globals.largeur_boite = 240;
+ v65 = 0;
+ v61 = texte_tmp;
+ do {
+ v19 = 0;
+ ptrb = _vm->_globals.largeur_boite - 4;
+ while (1) {
+ lineSize = v19;
+ do
+ v11 = *(v61 + v65 + v19++);
+ while (v11 != 32 && v11 != 37);
+ if (v19 >= ptrb / _vm->_globals.police_l)
+ break;
+ if (v11 == '%') {
+ if (v19 < ptrb / _vm->_globals.police_l)
+ goto LABEL_55;
+ break;
+ }
+ }
+ if (v11 != '%')
+ goto LABEL_57;
+ v11 = 32;
+LABEL_55:
+ if (v11 == '%')
+ lineSize = v19;
+LABEL_57:
+ v20 = lineCount;
+ v21 = v11;
+
+ // WORKAROUND: Perhaps due to the usage of ScummVM strings here, recalculate what the
+ // actual length of the line to be copied will be. Otherwise, you can see artifacts,
+ // such as a single character beyond the end of string NULL.
+ int actualSize = 0;
+ while (actualSize < lineSize && *(v61 + v65 + actualSize))
+ ++actualSize;
+
+ Txt[idx].lines[v20] = Common::String((const char *)v61 + v65, actualSize);
+ TRIER_TEXT[lineCount++] = lineSize;
+
+ v65 += lineSize;
+ v11 = v21;
+ } while (v21 != 37);
+ v66 = 0;
+ do {
+ v22 = TRIER_TEXT[v66];
+ if (v22 <= 0) {
+ TRIER_TEXT[v66] = 0;
+ } else {
+ ptrc = 0;
+ v23 = 0;
+ if (v22 - 1 > 0) {
+ do {
+ Common::String &line = Txt[idx].lines[v66];
+ v24 = (v23 >= (int)line.size()) ? '\0' : line[v23];
+ if ((byte)v24 <= 0x1Fu)
+ v24 = 32;
+ ptrc += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, (byte)v24 - 32);
+ ++v23;
+ } while (v23 < TRIER_TEXT[v66] - 1);
+ }
+ TRIER_TEXT[v66] = ptrc;
+ }
+ ++v66;
+ } while (v66 <= 19);
+ v67 = 0;
+ do {
+ v25 = v67;
+ do {
+ ++v25;
+ if (v25 == 20)
+ v25 = 0;
+ if (TRIER_TEXT[v67] < TRIER_TEXT[v25])
+ TRIER_TEXT[v67] = 0;
+ } while (v25 != (int16)v67);
+ ++v67;
+ } while (v67 <= 19);
+ v68 = 0;
+ do {
+ if (TRIER_TEXT[v68])
+ _vm->_globals.largeur_boite = TRIER_TEXT[v68];
+ ++v68;
+ } while (v68 <= 19);
+
+ if ((uint16)(Txt[idx].field3FC - 2) > 1u) {
+ for (i = xp - _vm->_eventsManager.start_x; _vm->_globals.largeur_boite + i > 638 && i > -2 && Txt[idx].field3FC; i -= 2)
+ ;
+ Txt[idx].xp = i;
+ v73 = _vm->_eventsManager.start_x + i;
+ } else {
+ if (_vm->_globals.nbrligne == (SCREEN_WIDTH - 1)) {
+ while (_vm->_globals.largeur_boite + v73 > 638 && v73 > -2)
+ v73 -= 2;
+ }
+ if (_vm->_globals.nbrligne == (SCREEN_WIDTH * 2)) {
+ while (_vm->_globals.largeur_boite + v73 > 1278 && v73 > -2)
+ v73 -= 2;
+ }
+ Txt[idx].xp = v73;
+ }
+ }
+ _vm->_globals.hauteur_boite = (_vm->_globals.police_h + 1) * lineCount + 2;
+ v56 = v73;
+ v55 = yp;
+ v53 = _vm->_globals.largeur_boite + 10;
+ v51 = (_vm->_globals.police_h + 1) * lineCount + 12;
+ if (Txt[idx].field3FC == 6) {
+ v27 = v53 / 2;
+ if (v27 < 0)
+ v27 = -v27;
+ Txt[idx].xp = 315 - v27;
+ v28 = _vm->_eventsManager.start_x + 315 - v27;
+ v73 = _vm->_eventsManager.start_x + 315 - v27;
+ Txt[idx].yp = 50;
+ v70 = 50;
+ v55 = 50;
+ v56 = v28;
+ }
+ v29 = Txt[idx].field3FC;
+ if (v29 == 1 || v29 == 3 || (uint16)(v29 - 5) <= 1u) {
+ v49 = v51 * v53;
+ ptrd = _vm->_globals.dos_malloc2(v51 * v53);
+ if (ptrd == g_PTRNUL) {
+ error("Cutting a block for text box (%d)", v49);
+ }
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, ptrd, v56, v55, v53, v51);
+ _vm->_graphicsManager.Trans_bloc2(ptrd, _vm->_graphicsManager.TABLE_COUL, v49);
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, ptrd, v56, v55, v53, v51);
+ _vm->_globals.dos_free2(ptrd);
+
+ _vm->_graphicsManager.Plot_Hline(_vm->_graphicsManager.VESA_BUFFER, v56, v55, v53, (byte)-2);
+ _vm->_graphicsManager.Plot_Hline(_vm->_graphicsManager.VESA_BUFFER, v56, v51 + v55, v53, (byte)-2);
+ _vm->_graphicsManager.Plot_Vline(_vm->_graphicsManager.VESA_BUFFER, v56, v70, v51, (byte)-2);
+ _vm->_graphicsManager.Plot_Vline(_vm->_graphicsManager.VESA_BUFFER, v53 + v56, v70, v51, (byte)-2);
+ }
+ Txt[idx].lineCount = lineCount;
+ v75 = v73 + 5;
+ v71 = v70 + 5;
+
+ if (lineCount > 0) {
+ for (int lineNum = 0; lineNum < lineCount; ++lineNum) {
+ TEXT_NOW1(v75, v71, Txt[idx].lines[lineNum], Txt[idx].colour);
+ v71 += _vm->_globals.police_h + 1;
+ }
+ }
+
+ blockWidth = v53 + 1;
+ blockHeight = v51 + 1;
+
+ Txt[idx].width = blockWidth;
+ Txt[idx].height = blockHeight;
+ v32 = Txt[idx].field3FC;
+ if (v32 == 6 || v32 == 1 || v32 == 3 || v32 == 5) {
+ if (Txt[idx].textBlock != g_PTRNUL)
+ Txt[idx].textBlock = _vm->_globals.dos_free2(Txt[idx].textBlock);
+ blockSize = blockHeight * blockWidth;
+ ptre = _vm->_globals.dos_malloc2(blockSize + 20);
+ if (ptre == g_PTRNUL)
+ error("Cutting a block for text box (%d)", blockSize);
+
+ Txt[idx].textBlock = ptre;
+ Txt[idx].width = blockWidth;
+ Txt[idx].height = blockHeight;
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, Txt[idx].textBlock, v56, v55, Txt[idx].width, blockHeight);
+ }
+ texte_tmp = _vm->_globals.dos_free2(texte_tmp);
+ }
+}
+
+void FontManager::TEXT_NOW1(int xp, int yp, const Common::String &message, int colour) {
+ for (uint idx = 0; idx < message.size(); ++idx) {
+ char currentChar = message[idx];
+
+ if (currentChar > 31) {
+ int characterIndex = currentChar - 32;
+ _vm->_graphicsManager.Affiche_Fonte(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.police,
+ xp, yp, characterIndex, colour);
+ xp += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, characterIndex);
+ }
+ }
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/font.h b/engines/hopkins/font.h
new file mode 100644
index 0000000000..90201902a6
--- /dev/null
+++ b/engines/hopkins/font.h
@@ -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.
+ *
+ */
+
+#ifndef HOPKINS_FONT_H
+#define HOPKINS_FONT_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+struct TxtItem {
+ bool textOn;
+ int field2;
+ Common::String filename;
+ int16 xp;
+ int16 yp;
+ int messageId;
+ int fieldE;
+ int field10;
+ int lineCount;
+ Common::String lines[10];
+ int field3FC;
+ int field3FE;
+ byte *textBlock;
+ int16 width;
+ int16 height;
+ bool textLoaded;
+ int colour;
+};
+
+struct ListeTxtItem {
+ bool enabled;
+ int16 xp;
+ int16 yp;
+ int16 width;
+ int16 height;
+};
+
+
+class FontManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ TxtItem Txt[12];
+ ListeTxtItem ListeTxt[12];
+ int TRIER_TEXT[21];
+ Common::String oldname;
+ Common::String nom_index;
+ int Index[4048];
+ byte *texte_tmp;
+public:
+ void setParent(HopkinsEngine *vm);
+ void clearAll();
+
+ void TEXTE_ON(int idx);
+ void TEXTE_OFF(int idx);
+ void COUL_TXT(int idx, byte colByte);
+ void OPTI_COUL_TXT(int idx1, int idx2, int idx3, int idx4);
+ void DOS_TEXT(int idx, int messageId, const Common::String &filename, int xp, int yp, int a6, int a7, int a8, int a9, int a10);
+ void BOITE(int idx, int messageId, const Common::String &filename, int xp, int yp);
+ void TEXT_NOW1(int xp, int yp, const Common::String &message, int colour);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_FONT_H */
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp
new file mode 100644
index 0000000000..0dd8caec9f
--- /dev/null
+++ b/engines/hopkins/globals.cpp
@@ -0,0 +1,595 @@
+/* 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/textconsole.h"
+#include "common/file.h"
+#include "hopkins/globals.h"
+#include "hopkins/files.h"
+#include "hopkins/font.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+// 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
+byte *g_PTRNUL;
+
+// Default data for the Hopkins array
+
+const int HOPKINS_PERSO_0[] = {
+ 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,
+ 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[] = {
+ 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,
+ 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[] = {
+ 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,
+ 0, 2, 0, 2, 0, 2, 0, 1, 0, 2, 0, 2
+};
+
+Globals::Globals() {
+ // Set up the special g_PTRNUL variable
+ g_PTRNUL = (byte *)malloc(16);
+ strcpy((char *)g_PTRNUL, "POINTERNULL");
+
+ // Initialise array properties
+ for (int i = 0; i < 6; ++i)
+ CACHE_BANQUE[i] = g_PTRNUL;
+ 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);
+ for (int i = 0; i < 30; ++i)
+ 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;
+ BOBZONE_FLAG[i] = false;
+ }
+ 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);
+
+ for (int i = 0; i < 36; ++i)
+ INVENTAIRE[i] = 0;
+ for (int i = 0; i < 51; ++i)
+ Common::fill((byte *)&Tri[i], (byte *)&Tri[i] + sizeof(TriItem), 0);
+
+ // Initialise fields
+ FR = 0;
+ SVGA = 2;
+ internet = 1;
+ PUBEXIT = 0;
+ vitesse = 1;
+ INSTALL_TYPE = 1;
+ MUSICVOL = 6;
+ SOUNDVOL = 6;
+ VOICEVOL = 6;
+ XSETMODE = 0;
+ XZOOM = 0;
+ lItCounter = 0;
+ lOldItCounter = 0;
+ g_old_anim = 0;
+ g_old_sens = 0;
+ g_old_sens2 = 0;
+ last_sens = 0;
+ police_l = police_h = 0;
+ TETE = NULL;
+ texte_long = 0;
+ TEXTE_FORMATE = 0;
+ OBJET_EN_COURS = 0;
+ NUM_FICHIER_OBJ = 0;
+ nbrligne = 0;
+ largeur_boite = 0;
+ hauteur_boite = 0;
+ FORET = 0;
+ OBJL = OBJH = 0;
+ HELICO = 0;
+ CAT_POSI = 0;
+ CAT_TAILLE = 0;
+ Nouv_objet = 0;
+ iRegul = 0;
+ SORTIE = 0;
+ PLANX = PLANY = 0;
+ PLANI = 0;
+ PERSO = 0;
+ PASSWORD = 0;
+ ECRAN = 0;
+ NOSPRECRAN = 0;
+ OLD_ECRAN = 0;
+ Max_Propre_Gen = 0;
+ Max_Ligne_Long = 0;
+ Max_Perso_Y = 0;
+ Max_Propre = 0;
+ NBBLOC = 0;
+ 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;
+ AFFLI = 0;
+ AFFIVBL = 0;
+ NOT_VERIF = 0;
+ PERSO_TYPE = 0;
+ GOACTION = 0;
+ NECESSAIRE = 0;
+ Compteur = 0;
+ ACTION_SENS = 0;
+ ACTION_SENS = 0;
+ SegmentEnCours = 0;
+ STOP_BUG = 0;
+ MAX_COMPTE = 0;
+
+ // 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;
+ Bufferobjet = 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;
+ police = NULL;
+ PERSO = NULL;
+ OPTION_SPR = NULL;
+
+ // Reset flags
+ MUSICOFF = false;
+ SOUNDOFF = false;
+ VOICEOFF = false;
+ XFULLSCREEN = false;
+ XFORCE16 = false;
+ XFORCE8 = false;
+ CARD_SB = false;
+ SOUNDOFF = false;
+ MUSICOFF = false;
+ VOICEOFF = false;
+ CENSURE = false;
+ GESTE_FLAG = false;
+ BPP_NOAFF = false;
+ DESACTIVE_INVENT = false;
+ FLAG_VISIBLE = false;
+ netscape = false;
+ NOMARCHE = false;
+ NO_VISU = false;
+ OPTION_FLAG = false;
+ CACHEFLAG = false;
+ NOPARLE = false;
+
+ // 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;
+ j_104 = 0;
+}
+
+Globals::~Globals() {
+ free(ICONE);
+ dos_free2(BUF_ZONE);
+ dos_free2(CACHE_BANQUE[6]);
+ dos_free2(texte_tmp);
+ dos_free2(SPRITE_ECRAN);
+ dos_free2((byte *)SAUVEGARDE);
+ dos_free2(BUFFERTAPE);
+ dos_free2(Bufferobjet);
+ dos_free2(inventaire2);
+ dos_free2(GESTE);
+ dos_free2(INVENTAIRE_OBJET);
+ dos_free2(FORETSPR);
+ dos_free2(COUCOU);
+ dos_free2(cache_souris);
+ dos_free2(Bufferdecor);
+ dos_free2(ADR_FICHIER_OBJ);
+ dos_free2(PERSO);
+
+ free(g_PTRNUL);
+}
+
+void Globals::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+void Globals::setConfig() {
+ HOPIMAGE = "BUFFER";
+ HOPANIM = "ANIM";
+ HOPLINK = "LINK";
+ HOPSAVE = "SAVE";
+ HOPSOUND = "SOUND";
+ HOPMUSIC = "MUSIC";
+ HOPVOICE = "VOICE";
+ HOPANM = "ANM";
+ HOPSEQ = "SEQ";
+
+ 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;
+ }
+}
+
+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
+
+ for (int idx = 0; idx < 6; ++idx)
+ CACHE_BANQUE[idx] = g_PTRNUL;
+
+ nbrligne = 80;
+ INIT_ANIM();
+
+ texte_tmp = g_PTRNUL;
+ texte_long = 0;
+ police = g_PTRNUL;
+ police_h = 0;
+ police_l = 0;
+ hauteur_boite = 0;
+ largeur_boite = 0;
+
+ _vm->_fontManager.clearAll();
+
+ INIT_VBOB();
+ ADR_FICHIER_OBJ = g_PTRNUL;
+ NUM_FICHIER_OBJ = 0;
+ Bufferdecor = g_PTRNUL;
+ Bufferobjet = g_PTRNUL;
+ _vm->_dialogsManager.Winventaire = g_PTRNUL;
+ _vm->_dialogsManager.inventaire2 = g_PTRNUL;
+ COUCOU = g_PTRNUL;
+ SPRITE_ECRAN = g_PTRNUL;
+ SAUVEGARDE = (Sauvegarde *)g_PTRNUL;
+ OBJET_EN_COURS = 0;
+
+ for (int idx = 0; idx < 105; ++idx) {
+ ZONEP[idx].destX = 0;
+ ZONEP[idx].destY = 0;
+ ZONEP[idx].field4 = 0;
+ }
+
+ essai0 = (int16 *)g_PTRNUL;
+ essai1 = (int16 *)g_PTRNUL;
+ essai2 = (int16 *)g_PTRNUL;
+ BufLig = (int16 *)g_PTRNUL;
+ chemin = (int16 *)g_PTRNUL;
+
+ for (int idx = 0; idx < 400; ++idx) {
+ _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;
+ _vm->_linesManager.Ligne[idx].lineData = (int16 *)g_PTRNUL;
+
+ _vm->_linesManager.LigneZone[idx].count = 0;
+ _vm->_linesManager.LigneZone[idx].field2 = 0;
+ _vm->_linesManager.LigneZone[idx].zoneData = (int16 *)g_PTRNUL;
+ }
+
+ for (int idx = 0; idx < 100; ++idx) {
+ CarreZone[idx].field0 = 0;
+ }
+
+ texte_long = 0;
+ texte_tmp = g_PTRNUL;
+ BUFFERTAPE = dos_malloc2(85000);
+
+ SAUVEGARDE = (Sauvegarde *)malloc(sizeof(Sauvegarde));
+ memset(SAUVEGARDE, 0, sizeof(Sauvegarde));
+
+ essai0 = (int16 *)BUFFERTAPE;
+ essai1 = (int16 *)(BUFFERTAPE + 25000);
+ essai2 = (int16 *)(BUFFERTAPE + 50000);
+ BufLig = (int16 *)(BUFFERTAPE + 75000);
+ largeur_boite = 240;
+ TEXTE_FORMATE = 300;
+
+ Bufferobjet = dos_malloc2(2500);
+ INVENTAIRE_OBJET = dos_malloc2(2500);
+
+ ADR_FICHIER_OBJ = g_PTRNUL;
+ FORETSPR = g_PTRNUL;
+ FORET = 0;
+
+ cache_souris = dos_malloc2(2500);
+ GESTE = g_PTRNUL;
+ GESTE_FLAG = false;
+}
+
+void Globals::HOPKINS_DATA() {
+ 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++;
+ }
+
+ g_old_anim = -1;
+ g_old_sens = -1;
+}
+
+void Globals::INIT_ANIM() {
+ for (int idx = 0; idx < 35; ++idx) {
+ Bqe_Anim[idx].data = g_PTRNUL;
+ Bqe_Anim[idx].field4 = 0;
+ }
+
+ for (int idx = 0; idx < 8; ++idx) {
+ Bank[idx].data = g_PTRNUL;
+ Bank[idx].field4 = 0;
+ Bank[idx].filename1 = "";
+ Bank[idx].fileHeader = 0;
+ Bank[idx].field1C = 0;
+ Bank[idx].filename2 = "";
+ }
+}
+
+void Globals::INIT_VBOB() {
+ for (int idx = 0; idx < 30; ++idx) {
+ VBob[idx].field4 = 0;
+ VBob[idx].xp = 0;
+ VBob[idx].yp = 0;
+ VBob[idx].frameIndex = 0;
+ VBob[idx].fieldC = 0;
+ VBob[idx].surface = g_PTRNUL;
+ VBob[idx].spriteData = g_PTRNUL;
+ VBob[idx].oldSpriteData = g_PTRNUL;
+ }
+}
+
+void Globals::CLEAR_VBOB() {
+ for (int idx = 0; idx < 30; ++idx) {
+ VBob[idx].field4 = 0;
+ VBob[idx].xp = 0;
+ VBob[idx].yp = 0;
+ VBob[idx].frameIndex = 0;
+ VBob[idx].fieldC = 0;
+ VBob[idx].surface = g_PTRNUL;
+ VBob[idx].spriteData = g_PTRNUL;
+ VBob[idx].oldSpriteData = g_PTRNUL;
+ }
+}
+
+// Load Object
+void Globals::CHARGE_OBJET() {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("OBJET.DAT");
+ byte *data = _vm->_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::dos_malloc2(int count) {
+ byte *result = (byte *)malloc(count);
+ if (!result)
+ result = g_PTRNUL;
+ return result;
+}
+
+byte *Globals::dos_free2(byte *p) {
+ if (p != g_PTRNUL)
+ free(p);
+ return g_PTRNUL;
+}
+
+// Free File
+byte *Globals::LIBERE_FICHIER(byte *p) {
+ dos_free2(p);
+ return g_PTRNUL;
+}
+
+// Reset Cache
+void Globals::RESET_CACHE() {
+ byte *dataP;
+
+ for (int idx = 1; idx <= 5; ++idx) {
+ dataP = CACHE_BANQUE[idx];
+ if (dataP != g_PTRNUL && dataP)
+ CACHE_BANQUE[idx] = dos_free2(CACHE_BANQUE[idx]);
+ CACHE_BANQUE[idx] = g_PTRNUL;
+ }
+
+ for (int idx = 0; idx <= 20; ++idx) {
+ Cache[idx].fieldC = g_PTRNUL;
+ 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;
+ }
+
+ CACHEFLAG = false;
+}
+
+void Globals::CACHE_ON() {
+ CACHEFLAG = true;
+}
+
+// TODO: Find why some calls have a parameter value
+void Globals::CACHE_OFF(int v1) {
+ CACHEFLAG = false;
+}
+
+void Globals::CACHE_SUB(int idx) {
+ Cache[idx].fieldA = 0;
+}
+
+void Globals::CACHE_ADD(int idx) {
+ Cache[idx].fieldA = 1;
+}
+
+// Load Cache
+void Globals::CHARGE_CACHE(const Common::String &file) {
+ byte *v2 = g_PTRNUL;
+ int v4;
+ int v5;
+ int v6;
+ int v8;
+ int v9;
+ int v11;
+ byte *spriteData;
+ byte *ptr;
+ int v14;
+ int v15;
+ Common::String v16;
+ Common::File f;
+
+ RESET_CACHE();
+ _vm->_fileManager.CONSTRUIT_FICHIER(HOPLINK, file);
+ ptr = _vm->_fileManager.CHARGE_FICHIER(NFICHIER);
+ v16 = Common::String((const char *)ptr);
+
+ _vm->_fileManager.CONSTRUIT_FICHIER(HOPLINK, v16);
+
+ if (f.exists(NFICHIER)) {
+ spriteData = _vm->_fileManager.CHARGE_FICHIER(NFICHIER);
+ CACHE_BANQUE[1] = spriteData;
+ v15 = 60;
+ v14 = 0;
+ do {
+ v11 = (int16)READ_LE_UINT16((uint16 *)ptr + v15);
+ v4 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 1);
+ v5 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 2);
+ v6 = v14;
+ Cache[v6].field14 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 4);
+ Cache[v6].field2 = v11;
+ Cache[v6].field0 = v4;
+ Cache[v6].field4 = v5;
+ Cache[v6].field12 = 1;
+ if (spriteData == g_PTRNUL) {
+ Cache[v14].fieldA = 0;
+ } else {
+ v8 = _vm->_objectsManager.Get_Largeur(spriteData, v11);
+ v9 = _vm->_objectsManager.Get_Hauteur(spriteData, v11);
+ Cache[v14].fieldC = spriteData;
+ Cache[v14].field6 = v8;
+ Cache[v14].field8 = v9;
+ Cache[v14].fieldA = 1;
+ }
+
+ if ( !Cache[v14].field0 && !Cache[v14].field4 && !Cache[v14].field2)
+ Cache[v14].fieldA = 0;
+ v15 += 5;
+ ++v14;
+ } while (v14 <= 21);
+ CACHE_ON();
+ v2 = ptr;
+ }
+ dos_free2(v2);
+}
+
+void Globals::B_CACHE_OFF(int idx) {
+ Bob[idx].field34 = 1;
+}
+
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h
new file mode 100644
index 0000000000..26d219a816
--- /dev/null
+++ b/engines/hopkins/globals.h
@@ -0,0 +1,483 @@
+/* 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_GLOBALS_H
+#define HOPKINS_GLOBALS_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+struct ZonePItem {
+ int destX;
+ int destY;
+ int field4;
+ int field6;
+ int field7;
+ int field8;
+ int field9;
+ int fieldA;
+ int fieldB;
+ int fieldC;
+ int fieldD;
+ int fieldE;
+ int fieldF;
+ int field10;
+ int field12;
+ int field16;
+};
+
+struct CarreZoneItem {
+ int field0;
+ int field2;
+ int field4;
+ int field6;
+ int field8;
+ int fieldA;
+ int fieldC;
+ int fieldE;
+};
+
+struct BqeAnimItem {
+ byte *data;
+ int field4;
+};
+
+struct BankItem {
+ byte *data;
+ int8 field4;
+ Common::String filename1;
+ int fileHeader;
+ int field1A;
+ uint32 field1C;
+ Common::String filename2;
+};
+
+struct ListeItem {
+ int field0;
+ int field2;
+ int field4;
+ int width;
+ int height;
+ int fieldA;
+};
+
+struct Liste2Item {
+ int field0;
+ int xp;
+ int yp;
+ int width;
+ int height;
+};
+
+struct BobItem {
+ int field0;
+ byte *spriteData;
+ int xp;
+ int yp;
+ int frameIndex;
+ int fieldE;
+ int field10;
+ int field12;
+ int field14;
+ int field16;
+ byte *animData;
+ int field1C;
+ int field1E;
+ int field20;
+ int field22;
+ int offsetY;
+ int field26;
+ int field28;
+ int field2A;
+ int field2C;
+ byte *field30;
+ int field34;
+ int field36;
+ int field38;
+ bool isSprite;
+ bool isActive;
+ int oldX;
+ int oldY;
+ int oldWidth;
+ int oldHeight;
+ int oldX2;
+ int oldY2;
+ int field4A;
+};
+
+struct BlAnimItem {
+ uint32 v1;
+ uint32 v2;
+};
+
+struct VBobItem {
+ byte *spriteData;
+ int field4;
+ int xp;
+ int yp;
+ int frameIndex;
+ int fieldC;
+ int fieldE;
+ byte *surface;
+ int oldX;
+ int oldY;
+ int oldFrameIndex;
+ byte *oldSpriteData;
+};
+
+struct ObjetWItem {
+ byte field0;
+ byte field1;
+ byte field2;
+ byte field3;
+ byte field4;
+ byte field5;
+ byte field6;
+ byte field7;
+};
+
+struct BlocItem {
+ uint16 field0;
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+};
+
+/**
+ * Mode for TriItem records
+ */
+enum TriMode { TRI_NONE = 0, TRI_BOB = 1, TRI_SPRITE = 2, TRI_CACHE = 3 };
+
+/**
+ * Structure to represent a pending display of either a Bob, Sprite, or Cache Item.
+ */
+struct TriItem {
+ TriMode triMode;
+ int index;
+ int priority;
+ int unused;
+};
+
+struct CacheItem {
+ int field0;
+ int field2;
+ int field4;
+ int field6;
+ int field8;
+ int fieldA;
+ byte *fieldC;
+ int field10;
+ int field12;
+ int field14;
+};
+
+struct SegmentItem {
+ int field0;
+ int field2;
+ int field4;
+};
+
+struct HopkinsItem {
+ int field0;
+ int field2;
+};
+
+struct Sauvegarde1 {
+ int field0;
+ int field1;
+ int field2;
+ int field3;
+ int field4;
+};
+
+enum SauvegardeOffset {
+ svField1 = 1
+ , svField2 = 2
+ , svField3 = 3
+ , svField4 = 4
+ , svField5 = 5
+ , svField6 = 6
+ , svField8 = 8
+ , svField9 = 9
+ , svField10 = 10
+ , svField13 = 13
+ , svField80 = 80
+ , svField94 = 94
+ , svField95 = 95
+ , svField121 = 121
+ , svField122 = 122
+ , svField132 = 132
+ , svField133 = 133
+ , svField170 = 170
+ , svField171 = 171
+ , svField172 = 172
+ , svField173 = 173
+ , svField176 = 176
+ , svField180 = 180
+ , svField181 = 181
+ , svField182 = 182
+ , svField183 = 183
+ , svField184 = 184
+ , svField185 = 185
+ , svField186 = 186
+ , svField187 = 187
+ , svField188 = 188
+ , svField189 = 189
+ , svField190 = 190
+ , svField191 = 191
+ , svField192 = 192
+ , svField193 = 193
+ , svField194 = 194
+ , svField228 = 228
+ , svField231 = 231
+ , svField253 = 253
+ , svField261 = 261
+ , svField270 = 270
+ , svField300 = 300
+ , svField318 = 318
+ , svField320 = 320
+ , svField333 = 333
+ , svField338 = 338
+ , svField339 = 339
+ , svField340 = 340
+ , svField341 = 341
+ , svField349 = 349
+ , svField352 = 352
+ , svField353 = 353
+ , svField354 = 354
+ , svField355 = 355
+ , svField356 = 356
+ , svField357 = 357
+ , svField399 = 399
+ , svField401 = 401
+};
+
+// TODO: Sauvegrade1 fields should really be mapped into data array
+struct Sauvegarde {
+ byte data[0x802];
+ Sauvegarde1 field360;
+ Sauvegarde1 field370;
+ Sauvegarde1 field380;
+ int16 inventory[35]; // Originally at offset 1300 of data array
+};
+
+class HopkinsEngine;
+
+/**
+ * Engine Globals
+ */
+class Globals {
+private:
+ HopkinsEngine *_vm;
+public:
+ byte *CACHE_BANQUE[6];
+ ZonePItem ZONEP[106];
+ CarreZoneItem CarreZone[101];
+ BqeAnimItem Bqe_Anim[35];
+ BankItem Bank[8];
+ BobItem Bob[36];
+ ListeItem Liste[6];
+ Liste2Item Liste2[35];
+ BlAnimItem BL_ANIM[30];
+ VBobItem VBob[30];
+ ObjetWItem ObjetW[300];
+ BlocItem BLOC[250];
+ CacheItem Cache[25];
+ SegmentItem Segment[101];
+ int BOBZONE[105];
+ bool BOBZONE_FLAG[105];
+ int STAILLE[500];
+ int16 super_parcours[32002];
+ int Param[2100];
+ HopkinsItem Hopkins[70];
+ int INVENTAIRE[36];
+ TriItem Tri[51];
+ int FR;
+ int SVGA;
+ int internet;
+ int PUBEXIT;
+ bool XFULLSCREEN;
+ int XSETMODE;
+ int XZOOM;
+ bool XFORCE16;
+ bool XFORCE8;
+ bool CARD_SB;
+ int PERSO_TYPE;
+ int vitesse;
+ int INSTALL_TYPE;
+ Common::String HOPIMAGE;
+ Common::String HOPANIM;
+ Common::String HOPLINK;
+ Common::String HOPSAVE;
+ Common::String HOPSOUND;
+ Common::String HOPMUSIC;
+ Common::String HOPVOICE;
+ Common::String HOPANM;
+ Common::String HOPSEQ;
+ Common::String FICH_ZONE;
+ Common::String FICH_TEXTE;
+ Common::String NFICHIER;
+ Common::String REP_SPR;
+ int SOUNDVOL;
+ int MUSICVOL;
+ int VOICEVOL;
+ bool SOUNDOFF;
+ bool MUSICOFF;
+ bool VOICEOFF;
+ bool CENSURE;
+ int lItCounter;
+ int lOldItCounter;
+ int g_old_anim;
+ int g_old_sens, g_old_sens2;
+ int last_sens;
+ byte *police;
+ int police_l;
+ int police_h;
+ byte *TETE;
+ byte *ICONE;
+ byte *BUF_ZONE;
+ byte *texte_tmp;
+ int texte_long;
+ int TEXTE_FORMATE;
+ byte *SPRITE_ECRAN;
+ Sauvegarde *SAUVEGARDE;
+ byte *BUFFERTAPE;
+ int16 *essai0;
+ int16 *essai1;
+ int16 *essai2;
+ byte *Bufferobjet;
+ byte *inventaire2;
+ byte *GESTE;
+ int OBJET_EN_COURS;
+ int NUM_FICHIER_OBJ;
+ int nbrligne;
+ int largeur_boite;
+ byte *INVENTAIRE_OBJET;
+ int hauteur_boite;
+ int GESTE_FLAG;
+ byte *FORETSPR;
+ int FORET;
+ byte *COUCOU;
+ int16 *chemin;
+ byte *cache_souris;
+ int16 *BufLig;
+ byte *Bufferdecor;
+ byte *ADR_FICHIER_OBJ;
+ byte *PERSO;
+ int OBJL, OBJH;
+ int Nouv_objet;
+ int HELICO;
+ uint32 CAT_POSI;
+ uint32 CAT_TAILLE;
+ bool CAT_FLAG;
+ int iRegul;
+ bool BPP_NOAFF;
+ int SORTIE;
+ int PLANX, PLANY;
+ int PLANI;
+ int PASSWORD;
+ int NOSPRECRAN;
+ int ECRAN;
+ int OLD_ECRAN;
+ int Max_Propre;
+ int Max_Propre_Gen;
+ int Max_Ligne_Long;
+ int Max_Perso_Y;
+ bool DESACTIVE_INVENT;
+ bool FLAG_VISIBLE;
+ bool netscape;
+ bool NOMARCHE;
+ int NBBLOC;
+ bool NO_VISU;
+ byte *OPTION_SPR;
+ bool OPTION_FLAG;
+ int opt_anm;
+ int opt_vitesse;
+ int opt_scrtype;
+ int opt_scrspeed;
+ int opt_sound;
+ int opt_voice;
+ int opt_music;
+ int opt_txt;
+ int NBTRI;
+ int AFFLI;
+ int AFFIVBL;
+ int NOT_VERIF;
+ bool CACHEFLAG;
+ bool NOPARLE;
+ bool PLAN_FLAG;
+ int GOACTION;
+ int NECESSAIRE;
+ int Compteur;
+ int ACTION_SENS;
+ int SegmentEnCours;
+
+ int STOP_BUG;
+ bool NO_OFFSET;
+ int MAX_COMPTE;
+
+ int force_to_data_0;
+ int oldzone_46;
+ int old_x1_65;
+ int old_y1_66;
+ int old_x2_67;
+ int old_zone_68;
+ int old_x_69, old_y_70;
+ int compteur_71;
+ int zozo_73;
+ int old_y2_68;
+ int old_z_69;
+ int j_104;
+
+ Globals();
+ ~Globals();
+ void setParent(HopkinsEngine *vm);
+
+ void setConfig();
+ void clearAll();
+ void HOPKINS_DATA();
+ void INIT_ANIM();
+ void INIT_VBOB();
+ void CLEAR_VBOB();
+ void CHARGE_OBJET();
+ byte *dos_malloc2(int count);
+ byte *dos_free2(byte *p);
+ byte *LIBERE_FICHIER(byte *p);
+
+ void RESET_CACHE();
+ void CACHE_ON();
+ void CACHE_OFF(int v1 = 0);
+ void CACHE_SUB(int idx);
+ void CACHE_ADD(int idx);
+ void CHARGE_CACHE(const Common::String &file);
+ void B_CACHE_OFF(int idx);
+};
+
+// Global null pointer
+extern byte *g_PTRNUL;
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_GLOBALS_H */
diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp
new file mode 100644
index 0000000000..718a428ba6
--- /dev/null
+++ b/engines/hopkins/graphics.cpp
@@ -0,0 +1,2507 @@
+/* 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 "graphics/palette.h"
+#include "common/file.h"
+#include "common/rect.h"
+#include "engines/util.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+GraphicsManager::GraphicsManager() {
+ _lockCtr = 0;
+ SDL_MODEYES = false;
+ SDL_ECHELLE = 0;
+ XSCREEN = YSCREEN = 0;
+ WinScan = 0;
+ Winbpp = 0;
+ PAL_PIXELS = NULL;
+ nbrligne = 0;
+ Linear = false;
+ VideoPtr = NULL;
+ ofscroll = 0;
+ SCROLL = 0;
+ PCX_L = PCX_H = 0;
+ DOUBLE_ECRAN = false;
+ OLD_SCROLL = 0;
+ MANU_SCROLL = 1;
+ SPEED_SCROLL = 16;
+ nbrligne2 = 0;
+ Agr_x = Agr_y = 0;
+ Agr_Flag_x = Agr_Flag_y = 0;
+ FADESPD = 15;
+ FADE_LINUX = 0;
+ NOLOCK = false;
+ no_scroll = 0;
+ REDRAW = false;
+ min_x = 0;
+ min_y = 20;
+ max_x = SCREEN_WIDTH * 2;
+ max_y = SCREEN_HEIGHT - 20;
+ clip_x = clip_y = 0;
+ clip_x1 = clip_y1 = 0;
+ clip_flag = false;
+ SDL_NBLOCS = 0;
+ Red_x = Red_y = 0;
+ Red = 0;
+ Largeur = 0;
+ Compteur_y = 0;
+ spec_largeur = 0;
+
+ Common::fill(&SD_PIXELS[0], &SD_PIXELS[PALETTE_SIZE * 2], 0);
+ Common::fill(&TABLE_COUL[0], &TABLE_COUL[PALETTE_EXT_BLOCK_SIZE], 0);
+ Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0);
+ Common::fill(&Palette[0], &Palette[PALETTE_EXT_BLOCK_SIZE], 0);
+ Common::fill(&OLD_PAL[0], &OLD_PAL[PALETTE_EXT_BLOCK_SIZE], 0);
+}
+
+GraphicsManager::~GraphicsManager() {
+ _vm->_globals.dos_free2(VESA_SCREEN);
+ _vm->_globals.dos_free2(VESA_BUFFER);
+}
+
+void GraphicsManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+void GraphicsManager::SET_MODE(int width, int height) {
+ if (!SDL_MODEYES) {
+ SDL_ECHELLE = 0;
+
+ if (_vm->_globals.XSETMODE == 1)
+ SDL_ECHELLE = 0;
+ if (_vm->_globals.XSETMODE == 2)
+ SDL_ECHELLE = 25;
+ if (_vm->_globals.XSETMODE == 3)
+ SDL_ECHELLE = 50;
+ if (_vm->_globals.XSETMODE == 4)
+ SDL_ECHELLE = 75;
+ if (_vm->_globals.XSETMODE == 5)
+ SDL_ECHELLE = _vm->_globals.XZOOM;
+
+ int bpp = 8;
+ if (_vm->_globals.XFORCE8 == true)
+ bpp = 8;
+ if (_vm->_globals.XFORCE16 == true)
+ bpp = 16;
+
+ if (SDL_ECHELLE) {
+ width = Reel_Zoom(width, SDL_ECHELLE);
+ height = Reel_Zoom(height, SDL_ECHELLE);
+ }
+
+ Graphics::PixelFormat pixelFormat16(2, 5, 6, 5, 0, 11, 5, 0, 0);
+
+ if (bpp == 8) {
+ initGraphics(width, height, true);
+ } else {
+ initGraphics(width, height, true, &pixelFormat16);
+ }
+
+ // Init surfaces
+ VESA_SCREEN = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
+ VESA_BUFFER = _vm->_globals.dos_malloc2(SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
+
+ VideoPtr = NULL;
+ XSCREEN = width;
+ YSCREEN = height;
+
+ Linear = true;
+ Winbpp = bpp / 8;
+ WinScan = width * Winbpp;
+
+ PAL_PIXELS = SD_PIXELS;
+ nbrligne = width;
+
+ Common::fill(&cmap[0], &cmap[256 * 3], 0);
+ SDL_MODEYES = true;
+ } else {
+ error("Called SET_MODE multiple times");
+ }
+}
+
+void GraphicsManager::DD_Lock() {
+ if (!NOLOCK) {
+ if (_lockCtr++ == 0)
+ VideoPtr = g_system->lockScreen();
+ }
+}
+
+void GraphicsManager::DD_Unlock() {
+ assert(VideoPtr);
+ if (--_lockCtr == 0) {
+ g_system->unlockScreen();
+ VideoPtr = NULL;
+ }
+}
+
+// Clear Screen
+void GraphicsManager::Cls_Video() {
+ assert(VideoPtr);
+
+ VideoPtr->fillRect(Common::Rect(0, 0, XSCREEN, YSCREEN), 0);
+}
+
+void GraphicsManager::LOAD_IMAGE(const Common::String &file) {
+ Common::String filename = Common::String::format("%s.PCX", file.c_str());
+ CHARGE_ECRAN(filename);
+ INIT_TABLE(165, 170, Palette);
+}
+
+// Load Screen
+void GraphicsManager::CHARGE_ECRAN(const Common::String &file) {
+ bool flag;
+ Common::File f;
+
+ _vm->_fileManager.DMESS1();
+
+ flag = true;
+ if (_vm->_fileManager.RECHERCHE_CAT(file, 6)) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file);
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("CHARGE_ECRAN - %s", file.c_str());
+
+ f.seek(0, SEEK_END);
+ f.close();
+ flag = false;
+ }
+
+ SCROLL_ECRAN(0);
+ A_PCX640_480((byte *)VESA_SCREEN, file, Palette, flag);
+
+ SCROLL = 0;
+ OLD_SCROLL = 0;
+ Cls_Pal();
+
+ if (!DOUBLE_ECRAN) {
+ _vm->_eventsManager.souris_max();
+ SCANLINE(SCREEN_WIDTH);
+ max_x = SCREEN_WIDTH;
+ DD_Lock();
+ Cls_Video();
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ } else if (Winbpp == 1) {
+ if (!SDL_ECHELLE)
+ m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+
+ DD_Unlock();
+ } else {
+ SCANLINE(SCREEN_WIDTH * 2);
+ max_x = SCREEN_WIDTH * 2;
+ DD_Lock();
+ Cls_Video();
+ DD_Unlock();
+
+ if (MANU_SCROLL == 1) {
+ DD_Lock();
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (Winbpp == 1) {
+ if (!SDL_ECHELLE)
+ m_scroll2(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll2A(VESA_SCREEN, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+
+ DD_Unlock();
+ }
+ }
+
+ memcpy(VESA_BUFFER, VESA_SCREEN, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
+}
+
+void GraphicsManager::INIT_TABLE(int minIndex, int maxIndex, byte *palette) {
+ for (int idx = 0; idx < 256; ++idx)
+ TABLE_COUL[idx] = idx;
+
+ Trans_bloc(TABLE_COUL, palette, 256, minIndex, maxIndex);
+
+ for (int idx = 0; idx < 256; ++idx) {
+ byte v = TABLE_COUL[idx];
+ if (v > 27)
+ TABLE_COUL[idx] = 0;
+ if (!v)
+ TABLE_COUL[idx] = 0;
+ }
+
+ TABLE_COUL[0] = 1;
+}
+
+// Scroll Screen
+int GraphicsManager::SCROLL_ECRAN(int amount) {
+ int result = CLIP(amount, 0, SCREEN_WIDTH);
+ _vm->_eventsManager.start_x = result;
+ ofscroll = result;
+ SCROLL = result;
+ return result;
+}
+
+void GraphicsManager::Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold) {
+ byte *destPosP;
+ int palIndex;
+ int srcOffset;
+ int col1, col2;
+
+ destPosP = destP;
+ for (int idx = 0; idx < count; ++idx) {
+ palIndex = *(byte *)destPosP++;
+ srcOffset = 3 * palIndex;
+ col1 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2);
+
+ for (int idx2 = 0; idx2 < 38; ++idx2) {
+ srcOffset = 3 * idx2;
+ col2 = *(srcP + srcOffset) + *(srcP + srcOffset + 1) + *(srcP + srcOffset + 2);
+
+ col2 += minThreshold;
+ if (col2 < col1)
+ continue;
+
+ col2 -= maxThreshold;
+ if (col2 > col1)
+ continue;
+
+ *(destPosP - 1) = (idx2 == 0) ? 1 : idx2;
+ break;
+ }
+ }
+}
+
+void GraphicsManager::Trans_bloc2(byte *surface, byte *col, int size) {
+ byte *dataP;
+ int count;
+ byte dataVal;
+
+ dataP = surface;
+ count = size - 1;
+ do {
+ dataVal = *dataP++;
+ *(dataP - 1) = *(dataVal + col);
+ --count;
+ } while (count);
+}
+
+// TODO: See if it's feasible and/or desirable to change this to use the Common PCX decoder
+void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag) {
+ int filesize;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ byte v12;
+ int v13;
+ int v14;
+ char v15;
+ int v18;
+ int v19;
+ int v20;
+ unsigned int v21;
+ int v22;
+ int32 v23;
+ byte *ptr;
+ Common::File f;
+
+ // Clear the passed surface
+ memset(surface, 0, SCREEN_WIDTH * 2 * SCREEN_HEIGHT);
+
+ if (typeFlag) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.RES");
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("(nom)Erreur en cours de lecture.");
+ f.seek(_vm->_globals.CAT_POSI);
+
+ v7 = _vm->_globals.CAT_TAILLE - 896;
+ v8 = f.read(HEADER_PCX, 128);
+
+ v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1;
+ v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1;
+ if (((int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1) <= SCREEN_WIDTH) {
+ DOUBLE_ECRAN = false;
+ } else {
+ v6 = SCREEN_WIDTH * 2;
+ DOUBLE_ECRAN = true;
+ }
+ if (v20 > SCREEN_HEIGHT)
+ v20 = SCREEN_HEIGHT;
+ PCX_L = v6;
+ PCX_H = v20;
+ if (v8 == -1)
+ error("Erreur en cours de lecture.");
+ } else {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file);
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("(nom)Erreur en cours de lecture.");
+
+ filesize = f.size();
+ int bytesRead = f.read(HEADER_PCX, 128);
+ if (bytesRead < 128)
+ error("Erreur en cours de lecture.");
+
+ v6 = (int16)READ_LE_UINT16(&HEADER_PCX[8]) + 1;
+ v20 = (int16)READ_LE_UINT16(&HEADER_PCX[10]) + 1;
+ if (v6 <= SCREEN_WIDTH) {
+ DOUBLE_ECRAN = false;
+ } else {
+ v6 = SCREEN_WIDTH * 2;
+ DOUBLE_ECRAN = true;
+ }
+ if (v20 > SCREEN_HEIGHT)
+ v20 = SCREEN_HEIGHT;
+ PCX_L = v6;
+ PCX_H = v20;
+ v7 = filesize - 896;
+ }
+
+ ptr = _vm->_globals.dos_malloc2(0xEE60u);
+ if (v7 >= 60000) {
+ v21 = v7 / 60000 + 1;
+ v23 = 60000 * (v7 / 60000) - v7;
+
+ if (((uint32)v23 & 0x80000000u) != 0)
+ v23 = -v23;
+ f.read(ptr, 60000);
+ v7 = 60000;
+ } else {
+ v21 = 1;
+ v23 = v7;
+ f.read(ptr, v7);
+ }
+ v22 = v21 - 1;
+ v18 = 0;
+ v9 = 0;
+ v10 = 0;
+ v19 = v6;
+
+ do {
+ if (v9 == v7) {
+ v9 = 0;
+ --v22;
+ v7 = 60000;
+ if ( !v22 )
+ v7 = v23;
+ v11 = v10;
+ f.read(ptr, v7);
+ v10 = v11;
+ }
+
+ v12 = *((byte *)ptr + v9++);
+ if (v12 > 0xC0u) {
+ v13 = v12 - 192;
+ if (v9 == v7) {
+ v9 = 0;
+ --v22;
+ v7 = 60000;
+ if ( v22 == 1 )
+ v7 = v23;
+ v14 = v10;
+ f.read(ptr, v7);
+ v10 = v14;
+ }
+ v15 = *((byte *)ptr + v9++);
+
+ do {
+ *((byte *)surface + v10++) = v15;
+ ++v18;
+ --v13;
+ } while (v13);
+ } else {
+ *((byte *)surface + v10++) = v12;
+ ++v18;
+ }
+ } while (v18 < v19 * v20);
+
+ if (typeFlag) {
+ f.seek(_vm->_globals.CAT_TAILLE + _vm->_globals.CAT_POSI - 768);
+ } else {
+ filesize = f.size();
+ f.seek(filesize - 768);
+ }
+
+ if (f.read(palette, PALETTE_BLOCK_SIZE) != (PALETTE_BLOCK_SIZE))
+ error("A_PCX640_480");
+
+ f.close();
+ _vm->_globals.dos_free2(ptr);
+}
+
+// Clear Palette
+void GraphicsManager::Cls_Pal() {
+ Common::fill(&cmap[0], &cmap[PALETTE_BLOCK_SIZE], 0);
+ SD_PIXELS[0] = 0;
+
+ if (Winbpp == 1) {
+ g_system->getPaletteManager()->setPalette(cmap, 0, 256);
+ }
+}
+
+void GraphicsManager::SCANLINE(int pitch) {
+ nbrligne = nbrligne2 = pitch;
+}
+
+void GraphicsManager::m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
+ const byte *srcP;
+ byte *destP;
+ int yNext;
+ int yCtr;
+ byte *dest2P;
+ const byte *src2P;
+ unsigned int widthRemaining;
+
+ assert(VideoPtr);
+ srcP = xs + nbrligne2 * ys + surface;
+ destP = destX + WinScan * destY + (byte *)VideoPtr->pixels;
+ yNext = height;
+ do {
+ yCtr = yNext;
+ memcpy((byte *)destP, (const byte *)srcP, 4 * (width >> 2));
+ src2P = (const byte *)(srcP + 4 * (width >> 2));
+ dest2P = (byte *)(destP + 4 * (width >> 2));
+ widthRemaining = width - 4 * (width >> 2);
+ memcpy(dest2P, src2P, widthRemaining);
+ destP = dest2P + widthRemaining + WinScan - width;
+ srcP = src2P + widthRemaining + nbrligne2 - width;
+ yNext = yCtr - 1;
+ } while (yCtr != 1);
+}
+
+void GraphicsManager::m_scroll2(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
+ const byte *srcP;
+ byte *destP;
+ int destPitch;
+ int srcPitch;
+ int yCtr;
+
+ assert(VideoPtr);
+ srcP = xs + nbrligne2 * ys + surface;
+ destP = destX + WinScan * destY + (byte *)VideoPtr->pixels;
+ destPitch = WinScan - SCREEN_WIDTH;
+ srcPitch = nbrligne2 - SCREEN_WIDTH;
+ yCtr = height;
+
+ do {
+ memcpy(destP, srcP, SCREEN_WIDTH);
+ destP = destP + destPitch + SCREEN_WIDTH;
+ srcP = srcP + srcPitch + SCREEN_WIDTH;
+ --yCtr;
+ } while (yCtr);
+}
+
+void GraphicsManager::m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
+ const byte *srcP;
+ byte *destP;
+ int yCtr;
+ int xCtr;
+ byte srcByte;
+ const byte *srcCopyP;
+ byte *destCopyP;
+
+ assert(VideoPtr);
+ srcP = xs + nbrligne2 * ys + surface;
+ destP = destX + WinScan * destY + (byte *)VideoPtr->pixels;
+ yCtr = height;
+ Agr_x = 0;
+ Agr_y = 0;
+ Agr_Flag_y = 0;
+ do {
+ for (;;) {
+ destCopyP = destP;
+ srcCopyP = srcP;
+ xCtr = width;
+ Agr_x = 0;
+ do {
+ srcByte = *srcP;
+ *destP++ = *srcP++;
+ Agr_x += SDL_ECHELLE;
+ if ((unsigned int)Agr_x >= 100) {
+ Agr_x -= 100;
+ *destP++ = srcByte;
+ }
+ --xCtr;
+ } while ( xCtr );
+
+ srcP = srcCopyP;
+ destP = WinScan + destCopyP;
+ if (Agr_Flag_y)
+ break;
+
+ Agr_y += SDL_ECHELLE;
+ if ((unsigned int)Agr_y < 100)
+ break;
+
+ Agr_y -= 100;
+ Agr_Flag_y = 1;
+ }
+
+ Agr_Flag_y = 0;
+ srcP = nbrligne2 + srcCopyP;
+ --yCtr;
+ } while (yCtr);
+}
+
+/**
+ * Copies data from a 8-bit palette surface into the 16-bit screen
+ */
+void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
+ DD_Lock();
+
+ assert(VideoPtr);
+ const byte *srcP = xs + nbrligne2 * ys + surface;
+ uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destX * 2 + WinScan * destY);
+
+ for (int yp = 0; yp < height; ++yp) {
+ // Copy over the line, using the source pixels as lookups into the pixels palette
+ const byte *lineSrcP = srcP;
+ uint16 *lineDestP = destP;
+
+ for (int xp = 0; xp < width; ++xp)
+ *lineDestP++ = *(uint16 *)&PAL_PIXELS[*lineSrcP++ * 2];
+
+ // Move to the start of the next line
+ srcP += nbrligne2;
+ destP += WinScan / 2;
+ }
+
+ DD_Unlock();
+}
+
+// TODO: See if PAL_PIXELS can be converted to a uint16 array
+void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY) {
+ const byte *srcP;
+ const byte *destP;
+ int yNext;
+ int xCtr;
+ const byte *palette;
+ int pixelWord;
+ int yCtr;
+ const byte *srcCopyP;
+ const byte *destCopyP;
+
+ assert(VideoPtr);
+ srcP = xs + nbrligne2 * ys + surface;
+ destP = destX + destX + WinScan * destY + (byte *)VideoPtr->pixels;
+ yNext = height;
+ Agr_x = 0;
+ Agr_y = 0;
+ Agr_Flag_y = 0;
+
+ do {
+ for (;;) {
+ destCopyP = destP;
+ srcCopyP = srcP;
+ xCtr = width;
+ yCtr = yNext;
+ palette = PAL_PIXELS;
+ Agr_x = 0;
+
+ do {
+ pixelWord = *(uint16 *)(palette + 2 * *srcP);
+ *(uint16 *)destP = pixelWord;
+ ++srcP;
+ destP += 2;
+ Agr_x += SDL_ECHELLE;
+ if ((unsigned int)Agr_x >= 100) {
+ Agr_x -= 100;
+ *(uint16 *)destP = pixelWord;
+ destP += 2;
+ }
+
+ --xCtr;
+ } while (xCtr);
+
+ yNext = yCtr;
+ srcP = srcCopyP;
+ destP = WinScan + destCopyP;
+ if (Agr_Flag_y == 1)
+ break;
+
+ Agr_y += SDL_ECHELLE;
+
+ if ((unsigned int)Agr_y < 100)
+ break;
+
+ Agr_y -= 100;
+ Agr_Flag_y = 1;
+ }
+
+ Agr_Flag_y = 0;
+ srcP = nbrligne2 + srcCopyP;
+ yNext = yCtr - 1;
+ } while (yCtr != 1);
+}
+
+void GraphicsManager::Copy_Vga(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) {
+ const byte *srcP;
+ byte *destP;
+ int yCount;
+ int xCount;
+ byte srcByte;
+ byte *loopDestP;
+ byte *loopSrcP;
+ byte *loopSrc2P;
+ byte *tempDestP;
+ const byte *tempSrcP;
+ int yCtr;
+
+ assert(VideoPtr);
+ srcP = xp + 320 * yp + surface;
+ destP = 30 * WinScan + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels;
+ yCount = height;
+
+ do {
+ yCtr = yCount;
+ xCount = width;
+ tempSrcP = srcP;
+ tempDestP = destP;
+ do {
+ srcByte = *srcP;
+ *destP = *srcP;
+ loopDestP = WinScan + destP;
+ *loopDestP = srcByte;
+ loopSrcP = loopDestP - WinScan + 1;
+ *loopSrcP = srcByte;
+ loopSrc2P = WinScan + loopSrcP;
+ *loopSrc2P = srcByte;
+ ++srcP;
+ destP = loopSrc2P - WinScan + 1;
+ --xCount;
+ } while (xCount);
+
+ destP = WinScan + WinScan + tempDestP;
+ srcP = tempSrcP + 320;
+ yCount = yCtr - 1;
+ } while (yCtr != 1);
+}
+
+void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) {
+ const byte *srcP;
+ uint16 *destP;
+ int yCount;
+ int xCount;
+ int xCtr;
+ const byte *palette;
+ uint16 *tempSrcP;
+ uint16 srcByte;
+ uint16 *tempDestP;
+ int savedXCount;
+ uint16 *loopDestP;
+ const byte *loopSrcP;
+ int yCtr;
+
+ assert(VideoPtr);
+ srcP = xp + 320 * yp + surface;
+ destP = (uint16 *)(30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY + (byte *)VideoPtr->pixels);
+ yCount = height;
+ xCount = width;
+
+ do {
+ yCtr = yCount;
+ xCtr = xCount;
+ loopSrcP = srcP;
+ loopDestP = destP;
+ savedXCount = xCount;
+ palette = PAL_PIXELS;
+
+ do {
+ tempSrcP = (uint16 *)(palette + 2 * *srcP);
+ srcByte = *tempSrcP;
+ *destP = *tempSrcP;
+ *(destP + 1) = srcByte;
+
+ tempDestP = (uint16 *)((byte *)destP + WinScan);
+ *tempDestP = srcByte;
+ *(tempDestP + 1) = srcByte;
+ ++srcP;
+ destP = (uint16 *)((byte *)tempDestP - WinScan + 4);
+ --xCtr;
+ } while (xCtr);
+
+ xCount = savedXCount;
+ destP = (uint16 *)((byte *)loopDestP + WinScan * 2);
+ srcP = loopSrcP + 320;
+ yCount = yCtr - 1;
+ } while (yCtr != 1);
+}
+
+void GraphicsManager::fade_in(const byte *palette, int step, const byte *surface) {
+ uint16 palData1[PALETTE_BLOCK_SIZE * 2];
+ byte palData2[PALETTE_BLOCK_SIZE];
+
+ // Initialise temporary palettes
+ Common::fill(&palData1[0], &palData1[PALETTE_BLOCK_SIZE], 0);
+ Common::fill(&palData2[0], &palData2[PALETTE_BLOCK_SIZE], 0);
+
+ // Set current palette to black
+ setpal_vga256(palData2);
+
+ // Loop through fading in the palette
+ uint16 *pTemp1 = &palData1[1];
+ for (int fadeIndex = 0; fadeIndex < FADESPD; ++fadeIndex) {
+ uint16 *pTemp2 = &palData1[2];
+
+ for (int palOffset = 0; palOffset < PALETTE_BLOCK_SIZE; palOffset += 3) {
+ if (palData2[palOffset] < palette[palOffset]) {
+ uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD;
+ palData1[palOffset] = v;
+ palData2[palOffset] = (v >> 8) & 0xff;
+ }
+
+ if (palData2[palOffset + 1] < palette[palOffset + 1]) {
+ uint16 *pDest = &pTemp1[palOffset];
+ uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest;
+ *pDest = v;
+ palData2[palOffset + 1] = (v >> 8) & 0xff;
+ }
+
+ if (palData2[palOffset + 2] < palette[palOffset + 2]) {
+ uint16 *pDest = &pTemp2[palOffset];
+ uint16 v = (palette[palOffset] & 0xff) * 256 / FADESPD + *pDest;
+ *pDest = v;
+ palData2[palOffset + 2] = (v >> 8) & 0xff;
+ }
+ }
+
+ setpal_vga256(palData2);
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ DD_VBL();
+ }
+ }
+
+ // Set the final palette
+ setpal_vga256(palette);
+
+ // Refresh the screen
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ DD_VBL();
+ }
+}
+
+void GraphicsManager::fade_out(const byte *palette, int step, const byte *surface) {
+ int palByte;
+ int palIndex;
+ int palDataIndex;
+ int palCtr3;
+ int palCtr4;
+ int palCtr5;
+ int palValue;
+ int palCtr2;
+ int palCtr1;
+ uint16 palMax;
+ byte palData[PALETTE_BLOCK_SIZE];
+ int tempPalette[PALETTE_BLOCK_SIZE];
+
+ palMax = palByte = FADESPD;
+ if (palette) {
+ palIndex = 0;
+ do {
+ palDataIndex = palIndex;
+ palByte = *(palIndex + palette);
+ palByte <<= 8;
+ tempPalette[palDataIndex] = palByte;
+ palData[palDataIndex] = *(palIndex++ + palette);
+ } while (palIndex < PALETTE_BLOCK_SIZE);
+
+ setpal_vga256(palData);
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ DD_VBL();
+ }
+
+ palCtr3 = 0;
+ if (palMax > 0) {
+ do {
+ palCtr4 = 0;
+ do {
+ palCtr5 = palCtr4;
+ palValue = tempPalette[palCtr4] - (*(palCtr4 + palette) << 8) / palMax;
+ tempPalette[palCtr5] = palValue;
+ palData[palCtr5] = (palValue >> 8) & 0xff;
+ ++palCtr4;
+ } while (palCtr4 < (PALETTE_BLOCK_SIZE));
+
+ setpal_vga256(palData);
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+
+ DD_VBL();
+ }
+ ++palCtr3;
+ } while (palMax > palCtr3);
+ }
+
+ palCtr2 = 0;
+ do {
+ palData[palCtr2++] = 0;
+ } while (palCtr2 < (PALETTE_BLOCK_SIZE));
+
+ setpal_vga256(palData);
+
+ if (Winbpp == 2) {
+ if (!SDL_ECHELLE) {
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ return DD_VBL();
+ }
+ goto LABEL_28;
+ }
+ } else {
+ palCtr1 = 0;
+ do {
+ palData[palCtr1++] = 0;
+ } while (palCtr1 < (PALETTE_BLOCK_SIZE));
+
+ setpal_vga256(palData);
+ if (Winbpp == 2) {
+ if (!SDL_ECHELLE) {
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ return DD_VBL();
+ }
+
+LABEL_28:
+ m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ return DD_VBL();
+ }
+ }
+}
+
+void GraphicsManager::FADE_INS() {
+ FADESPD = 1;
+ fade_in(Palette, 1, (const byte *)VESA_BUFFER);
+}
+
+void GraphicsManager::FADE_OUTS() {
+ FADESPD = 1;
+ fade_out(Palette, 1, (const byte *)VESA_BUFFER);
+}
+
+void GraphicsManager::FADE_INW() {
+ FADESPD = 15;
+ fade_in(Palette, 20, (const byte *)VESA_BUFFER);
+}
+
+void GraphicsManager::FADE_OUTW() {
+ FADESPD = 15;
+ fade_out(Palette, 20, (const byte *)VESA_BUFFER);
+}
+
+void GraphicsManager::setpal_vga256(const byte *palette) {
+ CHANGE_PALETTE(palette);
+}
+
+void GraphicsManager::setpal_vga256_linux(const byte *palette, const byte *surface) {
+ CHANGE_PALETTE(palette);
+
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(surface, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+
+ DD_VBL();
+ }
+}
+
+void GraphicsManager::SETCOLOR(int palIndex, int r, int g, int b) {
+ _vm->_graphicsManager.Palette[palIndex * 3] = 255 * r / 100;
+ _vm->_graphicsManager.Palette[palIndex * 3 + 1] = 255 * g / 100;
+ _vm->_graphicsManager.Palette[palIndex * 3 + 2] = 255 * b / 100;
+
+ setpal_vga256(Palette);
+}
+
+void GraphicsManager::SETCOLOR2(int palIndex, int r, int g, int b) {
+ return SETCOLOR(palIndex, r, g, b);
+}
+
+void GraphicsManager::SETCOLOR3(int palIndex, int r, int g, int b) {
+ Palette[palIndex * 3] = 255 * r / 100;
+ Palette[palIndex * 3 + 1] = 255 * g / 100;
+ Palette[palIndex * 3 + 2] = 255 * b / 100;
+}
+
+void GraphicsManager::SETCOLOR4(int palIndex, int r, int g, int b) {
+ int rv, gv, bv;
+ int palOffset;
+ int v8;
+
+ rv = 255 * r / 100;
+ gv = 255 * g / 100;
+ bv = 255 * b / 100;
+ palOffset = 3 * palIndex;
+ Palette[palOffset] = 255 * r / 100;
+ Palette[palOffset + 1] = gv;
+ Palette[palOffset + 2] = bv;
+
+ v8 = 4 * palIndex;
+ cmap[v8] = rv;
+ cmap[v8 + 1] = gv;
+ cmap[v8 + 2] = bv;
+
+ WRITE_LE_UINT16(&SD_PIXELS[2 * palIndex], MapRGB(rv, gv, bv));
+
+ if (Winbpp == 1)
+ g_system->getPaletteManager()->setPalette(cmap, palIndex, 1);
+}
+
+void GraphicsManager::CHANGE_PALETTE(const byte *palette) {
+ // Copy the palette into the PALPCX block
+// TODO: Likely either one or both of the destination arrays can be removed,
+// since PALPCX is only used in SAVE_IMAGE, and cmap in the original was a RGBA
+// array specifically intended just for passing to the SDL palette setter
+ Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &PALPCX[0]);
+ Common::copy(&palette[0], &palette[PALETTE_BLOCK_SIZE], &cmap[0]);
+
+ const byte *srcP = &palette[0];
+ for (int idx = 0; idx < PALETTE_SIZE; ++idx, srcP += 3) {
+ *(uint16 *)&SD_PIXELS[2 * idx] = MapRGB(*srcP, *(srcP + 1), *(srcP + 2));
+ }
+
+ if (Winbpp == 1)
+ g_system->getPaletteManager()->setPalette(cmap, 0, PALETTE_SIZE);
+}
+
+uint16 GraphicsManager::MapRGB(byte r, byte g, byte b) {
+ if (Winbpp == 1) {
+ error("TODO: Support in 8-bit graphics mode");
+ } else {
+ Graphics::PixelFormat format = g_system->getScreenFormat();
+
+ return (r >> format.rLoss) << format.rShift
+ | (g >> format.gLoss) << format.gShift
+ | (b >> format.bLoss) << format.bShift;
+ }
+}
+
+void GraphicsManager::DD_VBL() {
+ // TODO: Is this okay here?
+ g_system->updateScreen();
+}
+
+void GraphicsManager::FADE_OUTW_LINUX(const byte *surface) {
+ assert(surface);
+ fade_out(Palette, FADESPD, surface);
+}
+
+void GraphicsManager::FADE_INW_LINUX(const byte *surface) {
+ assert(surface);
+ fade_in(Palette, FADESPD, surface);
+}
+
+void GraphicsManager::Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface) {
+ int rleValue;
+ int destOffset;
+ const byte *srcP;
+ byte srcByte;
+ byte destLen1;
+ byte *destSlice1P;
+ byte destLen2;
+ byte *destSlice2P;
+
+ rleValue = 0;
+ destOffset = 0;
+ srcP = srcData;
+ for (;;) {
+ srcByte = *srcP;
+ if (*srcP < 0xDEu)
+ goto Video_Cont3_wVbe;
+ if (srcByte == (byte)-4)
+ return;
+
+ if (srcByte < 0xFBu) {
+ destOffset += (byte)(*srcP + 35);
+ srcByte = *(srcP++ + 1);
+ } else if (srcByte == (byte)-3) {
+ destOffset += *(srcP + 1);
+ srcByte = *(srcP + 2);
+ srcP += 2;
+ } else if (srcByte == (byte)-2) {
+ destOffset += READ_LE_UINT16(srcP + 1);
+ srcByte = *(srcP + 3);
+ srcP += 3;
+ } else {
+ destOffset += READ_LE_UINT32(srcP + 1);
+ srcByte = *(srcP + 5);
+ srcP += 5;
+ }
+Video_Cont3_wVbe:
+ if (srcByte > 0xD2u) {
+ if (srcByte == (byte)-45) {
+ destLen1 = *(srcP + 1);
+ rleValue = *(srcP + 2);
+ destSlice1P = destOffset + destSurface;
+ destOffset += destLen1;
+ memset(destSlice1P, rleValue, destLen1);
+ srcP += 3;
+ } else {
+ destLen2 = (byte)(*srcP + 45);
+ rleValue = *(srcP + 1);
+ destSlice2P = destOffset + destSurface;
+ destOffset += destLen2;
+ memset(destSlice2P, rleValue, destLen2);
+ srcP += 2;
+ }
+ } else {
+ *(destOffset + destSurface) = srcByte;
+ ++srcP;
+ ++destOffset;
+ }
+ }}
+
+void GraphicsManager::Copy_Video_Vbe3(const byte *srcData) {
+ int rleValue;
+ int destOffset;
+ const byte *srcP;
+ uint8 srcByte;
+ int destLen1;
+ byte *destSlice1P;
+ int destLen2;
+ byte *destSlice2P;
+
+ assert(VideoPtr);
+ rleValue = 0;
+ destOffset = 0;
+ srcP = srcData;
+ for (;;) {
+ srcByte = *srcP;
+ if (*srcP < 222)
+ goto Video_Cont3_Vbe;
+
+ if (srcByte == 252)
+ return;
+ if (srcByte < 251) {
+ destOffset += *srcP + 35;
+ srcByte = *(srcP++ + 1);
+ } else if (srcByte == (byte)-3) {
+ destOffset += *(srcP + 1);
+ srcByte = *(srcP + 2);
+ srcP += 2;
+ } else if (srcByte == (byte)-2) {
+ destOffset += READ_LE_UINT16(srcP + 1);
+ srcByte = *(srcP + 3);
+ srcP += 3;
+ } else {
+ destOffset += READ_LE_UINT32(srcP + 1);
+ srcByte = *(srcP + 5);
+ srcP += 5;
+ }
+Video_Cont3_Vbe:
+ if (srcByte > 210) {
+ if (srcByte == 211) {
+ destLen1 = *(srcP + 1);
+ rleValue = *(srcP + 2);
+ destSlice1P = destOffset + (byte *)VideoPtr->pixels;
+ destOffset += destLen1;
+ memset(destSlice1P, rleValue, destLen1);
+ srcP += 3;
+ } else {
+ destLen2 = (byte)(*srcP + 45);
+ rleValue = *(srcP + 1);
+ destSlice2P = (byte *)(destOffset + (byte *)VideoPtr->pixels);
+ destOffset += destLen2;
+ memset(destSlice2P, rleValue, destLen2);
+ srcP += 2;
+ }
+ } else {
+ *(destOffset + (byte *)VideoPtr->pixels) = srcByte;
+ ++srcP;
+ ++destOffset;
+ }
+ }
+}
+
+void GraphicsManager::Copy_Video_Vbe16(const byte *srcData) {
+ const byte *srcP = srcData;
+ int destOffset = 0;
+ assert(VideoPtr);
+
+ for (;;) {
+ byte srcByte = *srcP;
+ if (srcByte >= 222) {
+ if (srcByte == 252)
+ return;
+ if (srcByte < 251) {
+ destOffset += srcByte - 221;
+ srcByte = *++srcP;
+ } else if (srcByte == 253) {
+ destOffset += *(const byte *)(srcP + 1);
+ srcByte = *(const byte *)(srcP + 2);
+ srcP += 2;
+ } else if (srcByte == 254) {
+ destOffset += READ_LE_UINT16(srcP + 1);
+ srcByte = *(const byte *)(srcP + 3);
+ srcP += 3;
+ } else {
+ destOffset += READ_LE_UINT32(srcP + 1);
+ srcByte = *(const byte *)(srcP + 5);
+ srcP += 5;
+ }
+ }
+
+ if (srcByte > 210) {
+ if (srcByte == 211) {
+ int pixelCount = *(srcP + 1);
+ int pixelIndex = *(srcP + 2);
+ uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2);
+ uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex);
+ destOffset += pixelCount;
+
+ while (pixelCount--)
+ *destP++ = pixelValue;
+
+ srcP += 3;
+ } else {
+ int pixelCount = srcByte - 211;
+ int pixelIndex = *(srcP + 1);
+ uint16 *destP = (uint16 *)((byte *)VideoPtr->pixels + destOffset * 2);
+ uint16 pixelValue = *(uint16 *)(PAL_PIXELS + 2 * pixelIndex);
+ destOffset += pixelCount;
+
+ while (pixelCount--)
+ *destP++ = pixelValue;
+
+ srcP += 2;
+ }
+ } else {
+ *((uint16 *)VideoPtr->pixels + destOffset) = *(uint16 *)(PAL_PIXELS + 2 * srcByte);
+ ++srcP;
+ ++destOffset;
+ }
+ }
+}
+
+void GraphicsManager::Copy_Video_Vbe16a(const byte *srcData) {
+ int destOffset;
+ const byte *srcP;
+ byte pixelIndex;
+
+ destOffset = 0;
+ srcP = srcData;
+ for (;;) {
+ pixelIndex = *srcP;
+ if (*srcP < 0xFCu)
+ goto Video_Cont_Vbe16a;
+ if (pixelIndex == (byte)-4)
+ return;
+ if (pixelIndex == (byte)-3) {
+ destOffset += *(srcP + 1);
+ pixelIndex = *(srcP + 2);
+ srcP += 2;
+ } else if (pixelIndex == (byte)-2) {
+ destOffset += READ_LE_UINT16(srcP + 1);
+ pixelIndex = *(srcP + 3);
+ srcP += 3;
+ } else {
+ destOffset += READ_LE_UINT32(srcP + 1);
+ pixelIndex = *(srcP + 5);
+ srcP += 5;
+ }
+Video_Cont_Vbe16a:
+ WRITE_LE_UINT16((byte *)VideoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * pixelIndex));
+ ++srcP;
+ ++destOffset;
+ }
+}
+
+void GraphicsManager::Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height) {
+ const byte *srcP;
+ byte *destP;
+ int rowCount;
+ int i;
+ int rowCount2;
+
+ // TODO: This code in the original is potentially dangerous, as it doesn't clip the area to within
+ // the screen, and so thus can read areas outside of the allocated surface buffer
+ srcP = xs + nbrligne2 * ys + srcSurface;
+ destP = destSurface;
+ rowCount = height;
+ do {
+ rowCount2 = rowCount;
+ if (width & 1) {
+ memcpy(destP, srcP, width);
+ srcP += width;
+ destP += width;
+ } else if (width & 2) {
+ for (i = width >> 1; i; --i) {
+ *(uint16 *)destP = *(uint16 *)srcP;
+ srcP += 2;
+ destP += 2;
+ }
+ } else {
+ memcpy(destP, srcP, 4 * (width >> 2));
+ srcP += 4 * (width >> 2);
+ destP += 4 * (width >> 2);
+ }
+ srcP = nbrligne2 + srcP - width;
+ rowCount = rowCount2 - 1;
+ } while (rowCount2 != 1);
+}
+
+void GraphicsManager::Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex) {
+ // Get a pointer to the start of the desired sprite
+ const byte *spriteP = spriteData + 3;
+ for (int i = spriteIndex; i; --i)
+ spriteP += READ_LE_UINT32(spriteP) + 16;
+
+ clip_x = 0;
+ clip_y = 0;
+ clip_flag = false;
+
+ spriteP += 4;
+ int width = READ_LE_UINT16(spriteP);
+ spriteP += 2;
+ int height = READ_LE_UINT16(spriteP);
+
+ // Clip X
+ clip_x1 = width;
+ if ((xp + width) <= (min_x + 300))
+ return;
+ if (xp < (min_x + 300)) {
+ clip_x = min_x + 300 - xp;
+ clip_flag = true;
+ }
+
+ // Clip Y
+ // TODO: This is weird, but it's that way in the original. Original game bug?
+ if ((yp + height) <= height)
+ return;
+ if (yp < (min_y + 300)) {
+ clip_y = min_y + 300 - yp;
+ clip_flag = true;
+ }
+
+ // Clip X1
+ if (xp >= (max_x + 300))
+ return;
+ if ((xp + width) > (max_x + 300)) {
+ int xAmount = width + 10 - (xp + width - (max_x + 300));
+ if (xAmount <= 10)
+ return;
+
+ clip_x1 = xAmount - 10;
+ clip_flag = true;
+ }
+
+ // Clip Y1
+ if (yp >= (max_y + 300))
+ return;
+ if ((yp + height) > (max_y + 300)) {
+ int yAmount = height + 10 - (yp + height - (max_y + 300));
+ if (yAmount <= 10)
+ return;
+
+ clip_y1 = yAmount - 10;
+ clip_flag = true;
+ }
+
+ // Sprite display
+
+ // Set up source
+ spriteP += 6;
+ int srcOffset = READ_LE_UINT16(spriteP);
+ spriteP += 4;
+ const byte *srcP = spriteP;
+ spriteP += srcOffset;
+
+ // Set up surface destination
+ byte *destP = surface + (yp - 300) * nbrligne2 + (xp - 300);
+
+ // Handling for clipped versus non-clipped
+ if (clip_flag) {
+ // Clipped version
+ for (int yc = 0; yc < height; ++yc, destP += nbrligne2) {
+ byte *tempDestP = destP;
+ byte byteVal;
+ int xc = 0;
+
+ while ((byteVal = *srcP) != 253) {
+ ++srcP;
+ width = READ_LE_UINT16(srcP);
+ srcP += 2;
+
+ if (byteVal == 254) {
+ // Copy pixel range
+ for (int xv = 0; xv < width; ++xv, ++xc, ++spriteP, ++tempDestP) {
+ if (clip_y == 0 && xc >= clip_x && xc < clip_x1)
+ *tempDestP = *spriteP;
+ }
+ } else {
+ // Skip over bytes
+ tempDestP += width;
+ xc += width;
+ }
+ }
+
+ if (clip_y > 0)
+ --clip_y;
+ srcP += 3;
+ }
+ } else {
+ // Non-clipped
+ for (int yc = 0; yc < height; ++yc, destP += nbrligne2) {
+ byte *tempDestP = destP;
+ byte byteVal;
+
+ while ((byteVal = *srcP) != 253) {
+ ++srcP;
+ width = READ_LE_UINT16(srcP);
+ srcP += 2;
+
+ if (byteVal == 254) {
+ // Copy pixel range
+ Common::copy(spriteP, spriteP + width, tempDestP);
+ spriteP += width;
+ }
+
+ tempDestP += width;
+ }
+
+ // Skip over control byte and width
+ srcP += 3;
+ }
+ }
+}
+
+void GraphicsManager::FIN_VISU() {
+ for (int idx = 1; idx <= 20; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_OFF(idx);
+ }
+
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.VBL();
+
+ for (int idx = 1; idx <= 20; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_ZERO(idx);
+ }
+
+ for (int idx = 1; idx <= 29; ++idx) {
+ _vm->_globals.BL_ANIM[idx].v1 = 0;
+ }
+
+ for (int idx = 1; idx <= 20; ++idx) {
+ _vm->_globals.Bqe_Anim[idx].field4 = 0;
+ }
+}
+
+void GraphicsManager::VISU_ALL() {
+ for (int idx = 1; idx <= 20; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_VISU(idx);
+ }
+}
+
+void GraphicsManager::RESET_SEGMENT_VESA() {
+ int idx;
+ int blocCount;
+
+ if (_vm->_globals.NBBLOC > 0) {
+ idx = 0;
+ blocCount = _vm->_globals.NBBLOC;
+ do {
+ _vm->_globals.BLOC[idx++].field0 = 0;
+ } while (idx != blocCount);
+
+ _vm->_globals.NBBLOC = 0;
+ }
+}
+
+// Add VESA Segment
+void GraphicsManager::Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2) {
+ int tempX;
+ int blocCount;
+ int16 blocIndex;
+ bool addFlag;
+
+ tempX = x1;
+ addFlag = true;
+ if (x2 > max_x)
+ x2 = max_x;
+ if (y2 > max_y)
+ y2 = max_y;
+ if (x1 < min_x)
+ tempX = min_x;
+ if (y1 < min_y)
+ y1 = min_y;
+
+ blocCount = _vm->_globals.NBBLOC;
+ if (_vm->_globals.NBBLOC > 1) {
+
+ blocIndex = 0;
+ do {
+ BlocItem &bloc = _vm->_globals.BLOC[blocIndex];
+
+ if (bloc.field0 == 1
+ && tempX >= bloc.x1 && x2 <= bloc.x2
+ && y1 >= bloc.y1 && y2 <= bloc.y2)
+ addFlag = false;
+ ++blocIndex;
+ blocCount = blocIndex;
+ } while (_vm->_globals.NBBLOC + 1 != blocIndex);
+ }
+
+ if (addFlag) {
+ assert(_vm->_globals.NBBLOC < 50);
+ BlocItem &bloc = _vm->_globals.BLOC[++_vm->_globals.NBBLOC];
+
+ bloc.field0 = 1;
+ bloc.x1 = tempX;
+ bloc.x2 = x2;
+ bloc.y1 = y1;
+ bloc.y2 = y2;
+ }
+}
+
+int GraphicsManager::Magic_Number(signed int v) {
+ int result = v;
+
+ if (!v)
+ result = 4;
+ if (result & 1)
+ ++result;
+ if (result & 2)
+ result += 2;
+
+ return result;
+}
+
+// Display VESA Segment
+void GraphicsManager::Affiche_Segment_Vesa() {
+ if (_vm->_globals.NBBLOC == 0)
+ return;
+
+ SDL_NBLOCS = _vm->_globals.NBBLOC;
+ DD_Lock();
+
+ for (int idx = 1; idx <= _vm->_globals.NBBLOC; ++idx) {
+ BlocItem &bloc = _vm->_globals.BLOC[idx];
+ Common::Rect &dstRect = dstrect[idx - 1];
+ if (bloc.field0 != 1)
+ continue;
+
+ if (_vm->_eventsManager.CASSE != false) {
+ if (Winbpp == 1) {
+ Copy_Vga(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1);
+ } else if (Winbpp == 2) {
+ Copy_Vga16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1, bloc.x1, bloc.y1);
+ }
+
+ dstRect.left = bloc.x1 * 2;
+ dstRect.top = bloc.y1 * 2 + 30;
+ dstRect.setWidth((bloc.x2 - bloc.x1) * 2);
+ dstRect.setHeight((bloc.y2 - bloc.y1) * 2);
+ } else if (bloc.x2 > _vm->_eventsManager.start_x && bloc.x1 < (_vm->_eventsManager.start_x + SCREEN_WIDTH)) {
+ if (bloc.x1 < _vm->_eventsManager.start_x)
+ bloc.x1 = _vm->_eventsManager.start_x;
+ if (bloc.x2 > (_vm->_eventsManager.start_x + SCREEN_WIDTH))
+ bloc.x2 = _vm->_eventsManager.start_x + SCREEN_WIDTH;
+
+ if (SDL_ECHELLE) {
+ // Calculate the bounds
+ int xp = Magic_Number(bloc.x1) - 4;
+ if (xp < _vm->_eventsManager.start_x)
+ xp = _vm->_eventsManager.start_x;
+ int yp = Magic_Number(bloc.y1) - 4;
+ if (yp < 0)
+ yp = 0;
+ int width = Magic_Number(bloc.x2) + 4 - xp;
+ if (width < 4)
+ width = 4;
+ int height = Magic_Number(bloc.y2) + 4 - yp;
+ if (height < 4)
+ height = 4;
+
+ if ((xp - _vm->_eventsManager.start_x + width) > SCREEN_WIDTH)
+ xp -= 4;
+ if ((height - yp) > (SCREEN_HEIGHT - 40))
+ yp -= 4;
+
+ // WORKAROUND: Original didn't lock the screen for access
+ DD_Lock();
+
+ if (Winbpp == 2) {
+ m_scroll16A(VESA_BUFFER, xp, yp, width, height,
+ Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE));
+ } else {
+ m_scroll2A(VESA_BUFFER, xp, yp, width, height,
+ Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE), Reel_Zoom(yp, SDL_ECHELLE));
+ }
+
+ DD_Unlock();
+
+ dstRect.left = Reel_Zoom(xp - _vm->_eventsManager.start_x, SDL_ECHELLE);
+ dstRect.top = Reel_Zoom(yp, SDL_ECHELLE);
+ dstRect.setWidth(Reel_Zoom(width, SDL_ECHELLE));
+ dstRect.setHeight(Reel_Zoom(height, SDL_ECHELLE));
+ } else {
+ // WORKAROUND: Original didn't lock the screen for access
+ DD_Lock();
+
+ if (Winbpp == 2) {
+ m_scroll16(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1,
+ bloc.x1 - _vm->_eventsManager.start_x, bloc.y1);
+ } else {
+ m_scroll(VESA_BUFFER, bloc.x1, bloc.y1, bloc.x2 - bloc.x1, bloc.y2 - bloc.y1,
+ bloc.x1 - _vm->_eventsManager.start_x, bloc.y1);
+ }
+
+ dstRect.left = bloc.x1 - _vm->_eventsManager.start_x;
+ dstRect.top = bloc.y1;
+ dstRect.setWidth(bloc.x2 - bloc.x1);
+ dstRect.setHeight(bloc.y2 - bloc.y1);
+
+ DD_Unlock();
+ }
+ }
+
+ _vm->_globals.BLOC[idx].field0 = 0;
+ }
+
+ _vm->_globals.NBBLOC = 0;
+ DD_Unlock();
+ if (!_vm->_globals.BPP_NOAFF) {
+// SDL_UpdateRects(LinuxScr, SDL_NBLOCS, dstrect);
+ }
+ SDL_NBLOCS = 0;
+}
+
+void GraphicsManager::CopyAsm(const byte *surface) {
+ const byte *srcP;
+ byte srcByte;
+ byte *destP;
+ int yCtr;
+ int xCtr;
+ byte *dest1P;
+ byte *dest2P;
+ byte *dest3P;
+ byte *destPitch;
+ const byte *srcPitch;
+
+ assert(VideoPtr);
+ srcP = surface;
+ srcByte = 30 * WinScan;
+ destP = (byte *)VideoPtr->pixels + 30 * WinScan;
+ yCtr = 200;
+ do {
+ srcPitch = srcP;
+ destPitch = destP;
+ xCtr = 320;
+
+ do {
+ srcByte = *srcP;
+ *destP = *srcP;
+ dest1P = WinScan + destP;
+ *dest1P = srcByte;
+ dest2P = dest1P - WinScan + 1;
+ *dest2P = srcByte;
+ dest3P = WinScan + dest2P;
+ *dest3P = srcByte;
+ destP = dest3P - WinScan + 1;
+ ++srcP;
+ --xCtr;
+ } while (xCtr);
+
+ srcP = srcPitch + 320;
+ destP = WinScan + WinScan + destPitch;
+ --yCtr;
+ } while (yCtr);
+}
+
+void GraphicsManager::Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height) {
+ byte *destP;
+ int yNext;
+ const byte *srcP;
+ int i;
+ int yCtr;
+
+ destP = xp + nbrligne2 * yp + destSurface;
+ yNext = height;
+ srcP = src;
+ do {
+ yCtr = yNext;
+ if (width & 1) {
+ memcpy(destP, srcP, width);
+ srcP += width;
+ destP += width;
+ } else if (width & 2) {
+ for (i = width >> 1; i; --i) {
+ *(uint16 *)destP = *(uint16 *)srcP;
+ srcP += 2;
+ destP += 2;
+ }
+ } else {
+ memcpy(destP, srcP, 4 * (width >> 2));
+ srcP += 4 * (width >> 2);
+ destP += 4 * (width >> 2);
+ }
+ destP = nbrligne2 + destP - width;
+ yNext = yCtr - 1;
+ } while (yCtr != 1);
+}
+
+int GraphicsManager::Reel_Zoom(int v, int percentage) {
+ return Asm_Zoom(v, percentage);
+}
+
+int GraphicsManager::Asm_Zoom(int v, int percentage) {
+ if (v)
+ v += percentage * (long int)v / 100;
+
+ return v;
+}
+
+int GraphicsManager::Reel_Reduc(int v, int percentage) {
+ return Asm_Reduc(v, percentage);
+}
+
+int GraphicsManager::Asm_Reduc(int v, int percentage) {
+ if (v)
+ v -= percentage * (long int)v / 100;
+
+ return v;
+}
+
+// Display 'Perfect?'
+void GraphicsManager::Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8) {
+ const byte *spriteStartP;
+ int i;
+ const byte *spriteSizeP;
+ int spriteWidth;
+ int spriteHeight1;
+ const byte *spritePixelsP;
+ byte *dest1P;
+ int xCtr1;
+ byte *dest2P;
+ int xLeft;
+ int clippedWidth;
+ int xCtr2;
+ int v20;
+ int v21 = 0;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+ byte *v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33;
+ int v34;
+ int v35;
+ int spriteHeight2;
+ int v37;
+ int v38;
+ uint16 v39;
+ byte *v40;
+ int v41;
+ uint16 v42;
+ const byte *spritePixelsCopyP;
+ const byte *spritePixelsCopy2P;
+ const byte *v45;
+ const byte *v46;
+ byte *dest1CopyP;
+ byte *destCopy2P;
+ int v49;
+ int v50;
+ byte *v51;
+ int v52;
+ byte *v53;
+ byte *v54;
+ byte *v55;
+ int yCtr1;
+ int yCtr2;
+ int v58;
+ int v59;
+ int v60;
+ int v61;
+ int v62;
+ int v63;
+ int v64;
+ int v65;
+
+ spriteStartP = srcData + 3;
+ for (i = frameIndex; i; --i)
+ spriteStartP += READ_LE_UINT32(spriteStartP) + 16;
+
+ spriteWidth = 0;
+ spriteHeight1 = 0;
+ spriteSizeP = spriteStartP + 4;
+ spriteWidth = (int16)READ_LE_UINT16(spriteSizeP);
+ spriteSizeP += 2;
+ spriteHeight1 = spriteHeight2 = (int16)READ_LE_UINT16(spriteSizeP);
+ spritePixelsP = spriteSizeP + 10;
+ clip_x = 0;
+ clip_y = 0;
+ clip_x1 = 0;
+ clip_y1 = 0;
+ if ((uint16)xp300 > min_x) {
+ if ((uint16)xp300 < (uint16)(min_x + 300))
+ clip_x = min_x + 300 - xp300;
+ if ((uint16)yp300 > min_y) {
+ if ((uint16)yp300 < (uint16)(min_y + 300))
+ clip_y = min_y + 300 - yp300;
+ if ((uint16)xp300 < (uint16)(max_x + 300)) {
+ clip_x1 = max_x + 300 - xp300;
+ if ((uint16)yp300 < (uint16)(max_y + 300)) {
+ clip_y1 = max_y + 300 - yp300;
+ dest1P = xp300 + nbrligne2 * (yp300 - 300) - 300 + surface;
+ if (a7) {
+ Compteur_y = 0;
+ Agr_x = 0;
+ Agr_y = 0;
+ Agr_Flag_y = 0;
+ Agr_Flag_x = 0;
+ Largeur = spriteWidth;
+ v20 = Asm_Zoom(spriteWidth, a7);
+ v22 = Asm_Zoom(v21, a7);
+ if (a8) {
+ v29 = v20 + dest1P;
+ if (clip_y) {
+ if ((uint16)clip_y >= v22)
+ return;
+ v61 = v22;
+ v52 = v20;
+ v30 = 0;
+ v31 = (uint16)clip_y;
+ while (Asm_Zoom(v30 + 1, a7) < v31)
+ ;
+ v20 = v52;
+ spritePixelsP += Largeur * v30;
+ v29 += nbrligne2 * (uint16)clip_y;
+ v22 = v61 - (uint16)clip_y;
+ }
+ if (v22 > (uint16)clip_y1)
+ v22 = (uint16)clip_y1;
+ if (clip_x) {
+ if ((uint16)clip_x >= v20)
+ return;
+ v20 -= (uint16)clip_x;
+ }
+ if (v20 > (uint16)clip_x1) {
+ v32 = v20 - (uint16)clip_x1;
+ v29 -= v32;
+ v62 = v22;
+ v33 = 0;
+ while (Asm_Zoom(v33 + 1, a7) < v32)
+ ;
+ v34 = v33;
+ v22 = v62;
+ spritePixelsP += v34;
+ v20 = (uint16)clip_x1;
+ }
+ do {
+ while (1) {
+ v63 = v22;
+ v53 = v29;
+ v46 = spritePixelsP;
+ Agr_Flag_x = 0;
+ Agr_x = 0;
+ v35 = v20;
+ do {
+ while (1) {
+ if (*spritePixelsP)
+ *v29 = *spritePixelsP;
+ --v29;
+ ++spritePixelsP;
+ if (!Agr_Flag_x)
+ Agr_x = a7 + Agr_x;
+ if ((uint16)Agr_x < 0x64u)
+ break;
+ Agr_x = Agr_x - 100;
+ --spritePixelsP;
+ Agr_Flag_x = 1;
+ --v35;
+ if (!v35)
+ goto R_Aff_Zoom_Larg_Cont1;
+ }
+ Agr_Flag_x = 0;
+ --v35;
+ } while (v35);
+R_Aff_Zoom_Larg_Cont1:
+ spritePixelsP = Largeur + v46;
+ v29 = nbrligne2 + v53;
+ ++Compteur_y;
+ if (!Agr_Flag_y)
+ Agr_y = a7 + Agr_y;
+ if ((uint16)Agr_y < 0x64u)
+ break;
+ Agr_y = Agr_y - 100;
+ spritePixelsP = v46;
+ Agr_Flag_y = 1;
+ v22 = v63 - 1;
+ if (v63 == 1)
+ return;
+ }
+ Agr_Flag_y = 0;
+ v22 = v63 - 1;
+ } while (v63 != 1);
+ } else {
+ if (clip_y) {
+ if ((uint16)clip_y >= v22)
+ return;
+ v58 = v22;
+ v49 = v20;
+ v23 = 0;
+ v24 = (uint16)clip_y;
+ while (Asm_Zoom(v23 + 1, a7) < v24)
+ ;
+ v20 = v49;
+ spritePixelsP += Largeur * v23;
+ dest1P += nbrligne2 * (uint16)clip_y;
+ v22 = v58 - (uint16)clip_y;
+ }
+ if (v22 > (uint16)clip_y1)
+ v22 = (uint16)clip_y1;
+ if (clip_x) {
+ if ((uint16)clip_x >= v20)
+ return;
+ v59 = v22;
+ v50 = v20;
+ v25 = (uint16)clip_x;
+ v26 = 0;
+ while (Asm_Zoom(v26 + 1, a7) < v25)
+ ;
+ v27 = v26;
+ v22 = v59;
+ spritePixelsP += v27;
+ dest1P += (uint16)clip_x;
+ v20 = v50 - (uint16)clip_x;
+ }
+ if (v20 > (uint16)clip_x1)
+ v20 = (uint16)clip_x1;
+ do {
+ while (1) {
+ v60 = v22;
+ v51 = dest1P;
+ v45 = spritePixelsP;
+ v28 = v20;
+ Agr_Flag_x = 0;
+ Agr_x = 0;
+ do {
+ while (1) {
+ if (*spritePixelsP)
+ *dest1P = *spritePixelsP;
+ ++dest1P;
+ ++spritePixelsP;
+ if (!Agr_Flag_x)
+ Agr_x = a7 + Agr_x;
+ if ((uint16)Agr_x < 0x64u)
+ break;
+ Agr_x = Agr_x - 100;
+ --spritePixelsP;
+ Agr_Flag_x = 1;
+ --v28;
+ if (!v28)
+ goto Aff_Zoom_Larg_Cont1;
+ }
+ Agr_Flag_x = 0;
+ --v28;
+ } while (v28);
+Aff_Zoom_Larg_Cont1:
+ spritePixelsP = Largeur + v45;
+ dest1P = nbrligne2 + v51;
+ if (!Agr_Flag_y)
+ Agr_y = a7 + Agr_y;
+ if ((uint16)Agr_y < 0x64u)
+ break;
+ Agr_y = Agr_y - 100;
+ spritePixelsP = v45;
+ Agr_Flag_y = 1;
+ v22 = v60 - 1;
+ if (v60 == 1)
+ return;
+ }
+ Agr_Flag_y = 0;
+ v22 = v60 - 1;
+ } while (v60 != 1);
+ }
+ } else if (a6) {
+ Compteur_y = 0;
+ Red_x = 0;
+ Red_y = 0;
+ Largeur = spriteWidth;
+ Red = a6;
+ if (a6 < 100) {
+ v37 = Asm_Reduc(spriteWidth, Red);
+ if (a8) {
+ v40 = v37 + dest1P;
+ do {
+ v65 = spriteHeight2;
+ v55 = v40;
+ Red_y = Red + Red_y;
+ if ((uint16)Red_y < 0x64u) {
+ Red_x = 0;
+ v41 = Largeur;
+ v42 = v37;
+ do {
+ Red_x = Red + Red_x;
+ if ((uint16)Red_x < 0x64u) {
+ if (v42 >= clip_x && v42 < clip_x1 && *spritePixelsP)
+ *v40 = *spritePixelsP;
+ --v40;
+ ++spritePixelsP;
+ --v42;
+ } else {
+ Red_x = Red_x - 100;
+ ++spritePixelsP;
+ }
+ --v41;
+ } while (v41);
+ spriteHeight2 = v65;
+ v40 = nbrligne2 + v55;
+ } else {
+ Red_y = Red_y - 100;
+ spritePixelsP += Largeur;
+ }
+ --spriteHeight2;
+ } while (spriteHeight2);
+ } else {
+ do {
+ v64 = spriteHeight2;
+ v54 = dest1P;
+ Red_y = Red + Red_y;
+ if ((uint16)Red_y < 0x64u) {
+ Red_x = 0;
+ v38 = Largeur;
+ v39 = 0;
+ do {
+ Red_x = Red + Red_x;
+ if ((uint16)Red_x < 0x64u) {
+ if (v39 >= clip_x && v39 < clip_x1 && *spritePixelsP)
+ *dest1P = *spritePixelsP;
+ ++dest1P;
+ ++spritePixelsP;
+ ++v39;
+ } else {
+ Red_x = Red_x - 100;
+ ++spritePixelsP;
+ }
+ --v38;
+ } while (v38);
+ spriteHeight2 = v64;
+ dest1P = nbrligne2 + v54;
+ } else {
+ Red_y = Red_y - 100;
+ spritePixelsP += Largeur;
+ }
+ --spriteHeight2;
+ } while (spriteHeight2);
+ }
+ }
+ } else {
+ Largeur = spriteWidth;
+ Compteur_y = 0;
+ if (a8) {
+ dest2P = spriteWidth + dest1P;
+ spec_largeur = spriteWidth;
+ if (clip_y) {
+ if ((uint16)clip_y >= (unsigned int)spriteHeight1)
+ return;
+ spritePixelsP += spriteWidth * (uint16)clip_y;
+ dest2P += nbrligne2 * (uint16)clip_y;
+ spriteHeight1 -= (uint16)clip_y;
+ }
+ xLeft = (uint16)clip_y1;
+ if (spriteHeight1 > clip_y1)
+ spriteHeight1 = clip_y1;
+ xLeft = clip_x;
+ if (clip_x) {
+ if (xLeft >= spriteWidth)
+ return;
+ spriteWidth -= xLeft;
+ }
+ if (spriteWidth > (uint16)clip_x1) {
+ clippedWidth = spriteWidth - (uint16)clip_x1;
+ spritePixelsP += clippedWidth;
+ dest2P -= clippedWidth;
+ spriteWidth = (uint16)clip_x1;
+ }
+ do {
+ yCtr2 = spriteHeight1;
+ destCopy2P = dest2P;
+ spritePixelsCopy2P = spritePixelsP;
+ xCtr2 = spriteWidth;
+ do {
+ if (*spritePixelsP)
+ *dest2P = *spritePixelsP;
+ ++spritePixelsP;
+ --dest2P;
+ --xCtr2;
+ } while (xCtr2);
+ spritePixelsP = spec_largeur + spritePixelsCopy2P;
+ dest2P = nbrligne2 + destCopy2P;
+ spriteHeight1 = yCtr2 - 1;
+ } while (yCtr2 != 1);
+ } else {
+ spec_largeur = spriteWidth;
+ if (clip_y) {
+ if ((uint16)clip_y >= (unsigned int)spriteHeight1)
+ return;
+ spritePixelsP += spriteWidth * (uint16)clip_y;
+ dest1P += nbrligne2 * (uint16)clip_y;
+ spriteHeight1 -= (uint16)clip_y;
+ }
+ if (spriteHeight1 > clip_y1)
+ spriteHeight1 = clip_y1;
+ if (clip_x) {
+ if ((uint16)clip_x >= spriteWidth)
+ return;
+ spritePixelsP += (uint16)clip_x;
+ dest1P += (uint16)clip_x;
+ spriteWidth -= (uint16)clip_x;
+ }
+ if (spriteWidth > (uint16)clip_x1)
+ spriteWidth = (uint16)clip_x1;
+ do {
+ yCtr1 = spriteHeight1;
+ dest1CopyP = dest1P;
+ spritePixelsCopyP = spritePixelsP;
+ xCtr1 = spriteWidth;
+ do {
+ if (*spritePixelsP)
+ *dest1P = *spritePixelsP;
+ ++dest1P;
+ ++spritePixelsP;
+ --xCtr1;
+ } while (xCtr1);
+ spritePixelsP = spec_largeur + spritePixelsCopyP;
+ dest1P = nbrligne2 + dest1CopyP;
+ spriteHeight1 = yCtr1 - 1;
+ } while (yCtr1 != 1);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+// Display Speed
+void GraphicsManager::AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex) {
+ int width, height;
+
+ width = _vm->_objectsManager.Get_Largeur(spriteData, spriteIndex);
+ height = _vm->_objectsManager.Get_Hauteur(spriteData, spriteIndex);
+ if (*spriteData == 78) {
+ Affiche_Perfect(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0);
+ Affiche_Perfect(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex, 0, 0, 0);
+ } else {
+ Sprite_Vesa(VESA_BUFFER, spriteData, xp + 300, yp + 300, spriteIndex);
+ Sprite_Vesa(VESA_SCREEN, spriteData, xp + 300, yp + 300, spriteIndex);
+ }
+ if (!_vm->_globals.NO_VISU)
+ Ajoute_Segment_Vesa(xp, yp, xp + width, yp + height);
+}
+
+void GraphicsManager::SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) {
+ int top;
+ int croppedWidth;
+ int croppedHeight;
+ int xRight;
+ int height2;
+ int top2;
+ int left;
+
+ left = x1;
+ top = y1;
+ croppedWidth = width;
+ croppedHeight = height;
+
+ if (x1 < min_x) {
+ croppedWidth = width - (min_x - x1);
+ left = min_x;
+ }
+ if (y1 < min_y) {
+ croppedHeight = height - (min_y - y1);
+ top = min_y;
+ }
+ top2 = top;
+ if (top + croppedHeight > max_y)
+ croppedHeight = max_y - top;
+ xRight = left + croppedWidth;
+ if (xRight > max_x)
+ croppedWidth = max_x - left;
+
+ if (croppedWidth > 0 && croppedHeight > 0) {
+ height2 = croppedHeight;
+ Copy_Mem(surface, left, top2, croppedWidth, croppedHeight, destSurface, destX, destY);
+ Ajoute_Segment_Vesa(left, top2, left + croppedWidth, top2 + height2);
+ }
+}
+
+void GraphicsManager::Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY) {
+ const byte *srcP;
+ byte *destP;
+ int yp;
+ int yCurrent;
+ byte *dest2P;
+ const byte *src2P;
+ unsigned int pitch;
+
+ srcP = x1 + nbrligne2 * y1 + srcSurface;
+ destP = destX + nbrligne2 * destY + destSurface;
+ yp = height;
+ do {
+ yCurrent = yp;
+ memcpy(destP, srcP, 4 * (width >> 2));
+ src2P = (srcP + 4 * (width >> 2));
+ dest2P = (destP + 4 * (width >> 2));
+ pitch = width - 4 * (width >> 2);
+ memcpy(dest2P, src2P, pitch);
+ destP = (dest2P + pitch + nbrligne2 - width);
+ srcP = (src2P + pitch + nbrligne2 - width);
+ yp = yCurrent - 1;
+ } while (yCurrent != 1);
+}
+
+// Display Font
+void GraphicsManager::Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp,
+ int characterIndex, int colour) {
+ const byte *spriteDataP;
+ int i;
+ const byte *spriteSizeP;
+ int spriteWidth;
+ int spriteHeight;
+ const byte *spritePixelsP;
+ byte *destP;
+ int xCtr;
+ byte destByte;
+ byte *destLineP;
+ int yCtr;
+
+ spriteDataP = spriteData + 3;
+ for (i = characterIndex; i; --i)
+ spriteDataP += READ_LE_UINT32(spriteDataP) + 16;
+
+ spriteWidth = 0;
+ spriteHeight = 0;
+ spriteSizeP = spriteDataP + 4;
+ spriteWidth = (int16)READ_LE_UINT16(spriteSizeP);
+ spriteSizeP += 2;
+ spriteHeight = (int16)READ_LE_UINT16(spriteSizeP);
+ spritePixelsP = spriteSizeP + 10;
+ destP = surface + xp + nbrligne2 * yp;
+ Largeur = spriteWidth;
+
+ do {
+ yCtr = spriteHeight;
+ destLineP = destP;
+ xCtr = spriteWidth;
+ do {
+ destByte = *spritePixelsP;
+ if (*spritePixelsP) {
+ if (destByte == (byte)-4)
+ destByte = colour;
+ *destP = destByte;
+ }
+
+ ++destP;
+ ++spritePixelsP;
+ --xCtr;
+ } while (xCtr);
+ destP = nbrligne2 + destLineP;
+ spriteHeight = yCtr - 1;
+ } while (yCtr != 1);
+}
+
+// Init Screen
+void GraphicsManager::INI_ECRAN(const Common::String &file) {
+ OPTI_INI(file, 0);
+}
+
+// Init Screen 2
+void GraphicsManager::INI_ECRAN2(const Common::String &file) {
+ OPTI_INI(file, 2);
+}
+
+void GraphicsManager::OPTI_INI(const Common::String &file, int mode) {
+ int dataOffset;
+ int dataVal1;
+ bool doneFlag;
+ byte *ptr;
+ Common::String filename;
+
+ dataOffset = 1;
+
+ filename = file + ".ini";
+ ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1);
+ if (ptr == g_PTRNUL) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename);
+ ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (!mode) {
+ filename = file + ".spr";
+ if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN)
+ _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN);
+ if (!_vm->_globals.NOSPRECRAN) {
+ _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(filename, 8);
+ if (_vm->_globals.SPRITE_ECRAN) {
+ _vm->_globals.CAT_FLAG = false;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename);
+ } else {
+ _vm->_globals.CAT_FLAG = true;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES");
+ }
+ _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ _vm->_globals.CAT_FLAG = false;
+ }
+ }
+ if (*ptr != 'I' || *(ptr + 1) != 'N' || *(ptr + 2) != 'I') {
+ error("Error, file not ini");
+ } else {
+ doneFlag = false;
+ do {
+ dataVal1 = _vm->_scriptManager.Traduction(ptr + 20 * dataOffset);
+ if (_vm->shouldQuit())
+ return;
+
+ if (dataVal1 == 2)
+ dataOffset = _vm->_scriptManager.Control_Goto((ptr + 20 * dataOffset));
+ if (dataVal1 == 3)
+ dataOffset = _vm->_scriptManager.Control_If(ptr, dataOffset);
+ if (dataOffset == -1)
+ error("Error, defective IFF");
+ if (dataVal1 == 1 || dataVal1 == 4)
+ ++dataOffset;
+ if (!dataVal1 || dataVal1 == 5)
+ doneFlag = true;
+ } while (!doneFlag);
+ }
+ _vm->_globals.dos_free2(ptr);
+ if (mode != 1) {
+ if (g_PTRNUL != _vm->_globals.COUCOU)
+ _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU);
+
+ filename = file + ".rep";
+ byte *dataP = _vm->_fileManager.RECHERCHE_CAT(filename, 2);
+ _vm->_globals.COUCOU = dataP;
+ if (g_PTRNUL == dataP) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename);
+ dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ _vm->_globals.COUCOU = dataP;
+ }
+ }
+ _vm->_objectsManager.FORCEZONE = 1;
+ _vm->_objectsManager.CHANGEVERBE = 0;
+}
+
+void GraphicsManager::NB_SCREEN() {
+ byte *destP;
+ const byte *srcP;
+
+ if (!_vm->_globals.NECESSAIRE)
+ INIT_TABLE(50, 65, Palette);
+ if (nbrligne == SCREEN_WIDTH)
+ Trans_bloc2(VESA_BUFFER, TABLE_COUL, 307200);
+ if (nbrligne == 1280)
+ Trans_bloc2(VESA_BUFFER, TABLE_COUL, 614400);
+ _vm->_graphicsManager.DD_Lock();
+ if (Winbpp == 2) {
+ if (SDL_ECHELLE)
+ m_scroll16A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll16(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ if (Winbpp == 1) {
+ if (SDL_ECHELLE)
+ m_scroll2A(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ else
+ m_scroll2(VESA_BUFFER, _vm->_eventsManager.start_x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+
+ destP = VESA_SCREEN;
+ srcP = VESA_BUFFER;
+ memcpy(VESA_SCREEN, VESA_BUFFER, 0x95FFCu);
+ srcP = srcP + 614396;
+ destP = destP + 614396;
+ *destP = *srcP;
+ *(destP + 2) = *(srcP + 2);
+ DD_VBL();
+}
+
+void GraphicsManager::SHOW_PALETTE() {
+ setpal_vga256(Palette);
+}
+
+void GraphicsManager::videkey() {
+ // Empty in original
+}
+
+void GraphicsManager::Copy_WinScan_Vbe(const byte *src, byte *dest) {
+ int result;
+ int destOffset;
+ const byte *srcPtr;
+ byte byteVal;
+
+ result = 0;
+ destOffset = 0;
+ srcPtr = src;
+ while (1) {
+ byteVal = *srcPtr;
+ if (*srcPtr < 0xFCu)
+ goto Video_Cont_wVbe;
+ if (byteVal == (byte)-4)
+ return;
+ if (byteVal == (byte)-3) {
+ destOffset += *(srcPtr + 1);
+ byteVal = *(srcPtr + 2);
+ srcPtr += 2;
+ } else if (byteVal == (byte)-2) {
+ destOffset += READ_LE_UINT16(srcPtr + 1);
+ byteVal = *(srcPtr + 3);
+ srcPtr += 3;
+ } else {
+ destOffset += READ_LE_UINT32(srcPtr + 1);
+ byteVal = *(srcPtr + 5);
+ srcPtr += 5;
+ }
+Video_Cont_wVbe:
+ *(dest + destOffset) = byteVal;
+ ++srcPtr;
+ ++destOffset;
+ }
+}
+
+void GraphicsManager::Copy_Video_Vbe(const byte *src) {
+ int destOffset;
+ const byte *srcP;
+ byte byteVal;
+
+ assert(VideoPtr);
+ destOffset = 0;
+ srcP = src;
+ while (1) {
+ byteVal = *srcP;
+ if (*srcP < 0xFCu)
+ goto Video_Cont_Vbe;
+ if (byteVal == (byte)-4)
+ return;
+ if (byteVal == (byte)-3) {
+ destOffset += *(srcP + 1);
+ byteVal = *(srcP + 2);
+ srcP += 2;
+ } else if (byteVal == (byte)-2) {
+ destOffset += READ_LE_UINT16(srcP + 1);
+ byteVal = *(srcP + 3);
+ srcP += 3;
+ } else {
+ destOffset += READ_LE_UINT32(srcP + 1);
+ byteVal = *(srcP + 5);
+ srcP += 5;
+ }
+Video_Cont_Vbe:
+ *((byte *)VideoPtr->pixels + destOffset) = byteVal;
+ ++srcP;
+ ++destOffset;
+ }
+}
+
+// Reduce Screen
+void GraphicsManager::Reduc_Ecran(const byte *srcSurface, byte *destSurface, int xp, int yp, int width, int height, int zoom) {
+ const byte *srcP;
+ byte *destP;
+ const byte *lineSrcP;
+
+ srcP = xp + nbrligne2 * yp + srcSurface;
+ destP = destSurface;
+ Red = zoom;
+ Largeur = width;
+ Red_x = 0;
+ Red_y = 0;
+ if (zoom < 100) {
+ Reduc_Ecran_L = Asm_Reduc(width, Red);
+ Reduc_Ecran_H = Asm_Reduc(height, Red);
+
+ for (int yCtr = 0; yCtr < height; ++yCtr, srcP += nbrligne2) {
+ Red_y += Red;
+ if (Red_y < 100) {
+ Red_x = 0;
+ lineSrcP = srcP;
+
+ for (int xCtr = 0; xCtr < Largeur; ++xCtr) {
+ Red_x += Red;
+ if (Red_x < 100) {
+ *destP++ = *lineSrcP++;
+ } else {
+ Red_x -= 100;
+ ++lineSrcP;
+ }
+ }
+ } else {
+ Red_y -= 100;
+ }
+ }
+ }
+}
+
+void GraphicsManager::Plot_Hline(byte *surface, int xp, int yp, unsigned int width, byte col) {
+ memset(surface + xp + nbrligne2 * yp, col, width);
+}
+
+void GraphicsManager::Plot_Vline(byte *surface, int xp, int yp, int height, byte col) {
+ byte *destP;
+ int yCtr;
+
+ destP = surface + xp + nbrligne2 * yp;
+ yCtr = height;
+ do {
+ *destP = col;
+ destP += nbrligne2;
+ --yCtr;
+ } while (yCtr);
+}
+
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h
new file mode 100644
index 0000000000..8b93efcbc6
--- /dev/null
+++ b/engines/hopkins/graphics.h
@@ -0,0 +1,192 @@
+/* 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/rect.h"
+#include "common/str.h"
+#include "graphics/surface.h"
+
+namespace Hopkins {
+
+#define PALETTE_SIZE 256
+#define PALETTE_BLOCK_SIZE (PALETTE_SIZE * 3)
+#define PALETTE_EXT_BLOCK_SIZE 800
+
+struct RGB8 {
+ byte r;
+ byte g;
+ byte b;
+};
+
+class HopkinsEngine;
+
+class GraphicsManager {
+private:
+ HopkinsEngine *_vm;
+
+ void CHARGE_ECRAN(const Common::String &file);
+ int Asm_Zoom(int v, int percentage);
+ int Asm_Reduc(int v, int percentage);
+public:
+ int _lockCtr;
+ bool SDL_MODEYES;
+ int SDL_ECHELLE;
+ int XSCREEN;
+ int YSCREEN;
+ int WinScan;
+ int Winbpp;
+ byte SD_PIXELS[PALETTE_SIZE * 2];
+ byte *PAL_PIXELS;
+ int nbrligne;
+ byte TABLE_COUL[PALETTE_EXT_BLOCK_SIZE];
+ byte cmap[PALETTE_BLOCK_SIZE];
+ byte Palette[PALETTE_EXT_BLOCK_SIZE];
+ byte OLD_PAL[PALETTE_EXT_BLOCK_SIZE];
+ bool Linear;
+ Graphics::Surface *VideoPtr;
+ byte *VESA_SCREEN;
+ byte *VESA_BUFFER;
+ int ofscroll;
+ int SCROLL;
+ byte HEADER_PCX[128];
+ int PCX_L, PCX_H;
+ bool DOUBLE_ECRAN;
+ int OLD_SCROLL;
+ int MANU_SCROLL;
+ int SPEED_SCROLL;
+ int nbrligne2;
+ int Agr_x, Agr_y;
+ int Agr_Flag_x, Agr_Flag_y;
+ int FADESPD;
+ byte PALPCX[PALETTE_EXT_BLOCK_SIZE];
+ int FADE_LINUX;
+ bool NOLOCK;
+ int no_scroll;
+ Common::Rect dstrect[50];
+ int REDRAW;
+ int min_x, min_y;
+ int max_x, max_y;
+ int clip_x, clip_y;
+ int clip_x1, clip_y1;
+ bool clip_flag;
+ int SDL_NBLOCS;
+ int Red_x, Red_y;
+ int Red;
+ int Largeur;
+ int Compteur_y;
+ int spec_largeur;
+ bool NOFADE;
+ int Reduc_Ecran_L, Reduc_Ecran_H;
+public:
+ GraphicsManager();
+ ~GraphicsManager();
+ void setParent(HopkinsEngine *vm);
+
+ void SET_MODE(int width, int height);
+ void DD_Lock();
+ void DD_Unlock();
+ void DD_LOCK() { DD_Lock(); }
+ void DD_UNLOCK() { DD_Unlock(); }
+ void Cls_Video();
+ void LOAD_IMAGE(const Common::String &file);
+ void INIT_TABLE(int minIndex, int maxIndex, byte *palette);
+ int SCROLL_ECRAN(int amount);
+ void Trans_bloc(byte *destP, const byte *srcP, int count, int minThreshold, int maxThreshold);
+ void Trans_bloc2(byte *surface, byte *col, int size);
+ void A_PCX640_480(byte *surface, const Common::String &file, byte *palette, bool typeFlag);
+ void Cls_Pal();
+ void SCANLINE(int pitch);
+ void m_scroll(const byte *surface, int xs, int ys, int width, int height, int destX, int destY);
+ void m_scroll2(const byte *surface, int xs, int ys, int width, int height, int destX, int destY);
+ void m_scroll2A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY);
+ void m_scroll16(const byte *surface, int xs, int ys, int width, int height, int destX, int destY);
+ void m_scroll16A(const byte *surface, int xs, int ys, int width, int height, int destX, int destY);
+ void Copy_Vga(const byte *surface, int xp, int yp, int width, int height, int destX, int destY);
+ void Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY);
+ void fade_in(const byte *palette, int step, const byte *surface);
+ void fade_out(const byte *palette, int step, const byte *surface);
+ void FADE_INS();
+ void FADE_OUTS();
+ void FADE_INW();
+ void FADE_OUTW();
+ void FADE_OUTW_LINUX(const byte *surface);
+ void FADE_INW_LINUX(const byte *surface);
+ void setpal_vga256(const byte *palette);
+ void setpal_vga256_linux(const byte *palette, const byte *surface);
+ void SETCOLOR(int palIndex, int r, int g, int b);
+ void SETCOLOR2(int palIndex, int r, int g, int b);
+ void SETCOLOR3(int palIndex, int r, int g, int b);
+ void SETCOLOR4(int palIndex, int r, int g, int b);
+ void CHANGE_PALETTE(const byte *palette);
+ uint16 MapRGB(byte r, byte g, byte b);
+ void DD_VBL();
+ void Copy_WinScan_Vbe3(const byte *srcData, byte *destSurface);
+ void Copy_Video_Vbe3(const byte *srcData);
+ void Copy_Video_Vbe16(const byte *srcData);
+ void Copy_Video_Vbe16a(const byte *srcData);
+ void Capture_Mem(const byte *srcSurface, byte *destSurface, int xs, int ys, int width, int height);
+
+ /**
+ * Draws a sprite onto the screen
+ * @param surface Destination surface
+ * @param spriteData The raw data for a sprite set
+ * @param xp X co-ordinate. For some reason, starts from 300 = first column
+ * @param yp Y co-ordinate. FOr some reason, starts from 300 = top row
+ * @param spriteIndex Index of the sprite to draw
+ */
+ void Sprite_Vesa(byte *surface, const byte *spriteData, int xp, int yp, int spriteIndex);
+
+ void FIN_VISU();
+ void VISU_ALL();
+ void RESET_SEGMENT_VESA();
+ void Ajoute_Segment_Vesa(int x1, int y1, int x2, int y2);
+ int Magic_Number(int v);
+ void Affiche_Segment_Vesa();
+ void CopyAsm(const byte *surface);
+ void Restore_Mem(byte *destSurface, const byte *src, int xp, int yp, int width, int height);
+ int Reel_Zoom(int v, int percentage);
+ int Reel_Reduc(int v, int percentage);
+ void Affiche_Perfect(byte *surface, const byte *srcData, int xp300, int yp300, int frameIndex, int a6, int a7, int a8);
+ void AFFICHE_SPEED(const byte *spriteData, int xp, int yp, int spriteIndex);
+ void SCOPY(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY);
+ void Copy_Mem(const byte *srcSurface, int x1, int y1, unsigned int width, int height, byte *destSurface, int destX, int destY);
+ void Affiche_Fonte(byte *surface, const byte *spriteData, int xp, int yp, int characterIndex, int colour);
+ void INI_ECRAN(const Common::String &file);
+ void INI_ECRAN2(const Common::String &file);
+ void OPTI_INI(const Common::String &file, int mode);
+ void NB_SCREEN();
+ void SHOW_PALETTE();
+ void videkey();
+ void Copy_WinScan_Vbe(const byte *srcP, byte *destP);
+ void Copy_Video_Vbe(const byte *src);
+ void Reduc_Ecran(const byte *srcSruface, byte *destSurface, int xp, int yp, int width, int height, int zoom);
+ void Plot_Hline(byte *surface, int xp, int yp, unsigned int width, byte col);
+ void Plot_Vline(byte *surface, int xp, int yp, int height, byte col);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_GRAPHICS_H */
diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp
new file mode 100644
index 0000000000..ba3c1da752
--- /dev/null
+++ b/engines/hopkins/hopkins.cpp
@@ -0,0 +1,1015 @@
+/* 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/scummsys.h"
+#include "common/config-manager.h"
+#include "common/debug-channels.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/files.h"
+#include "hopkins/saveload.h"
+#include "hopkins/sound.h"
+#include "hopkins/talk.h"
+
+namespace Hopkins {
+
+HopkinsEngine *g_vm;
+
+HopkinsEngine::HopkinsEngine(OSystem *syst, const HopkinsGameDescription *gameDesc) : Engine(syst),
+ _gameDescription(gameDesc), _randomSource("Hopkins"), _animationManager() {
+ g_vm = this;
+ _debugger.setParent(this);
+ _animationManager.setParent(this);
+ _dialogsManager.setParent(this);
+ _eventsManager.setParent(this);
+ _fileManager.setParent(this);
+ _fontManager.setParent(this);
+ _globals.setParent(this);
+ _graphicsManager.setParent(this);
+ _linesManager.setParent(this);
+ _menuManager.setParent(this);
+ _objectsManager.setParent(this);
+ _saveLoadManager.setParent(this);
+ _scriptManager.setParent(this);
+ _soundManager.setParent(this);
+ _talkManager.setParent(this);
+}
+
+HopkinsEngine::~HopkinsEngine() {
+}
+
+Common::String HopkinsEngine::generateSaveName(int slot) {
+ return Common::String::format("%s.%03d", _targetName.c_str(), slot);
+}
+
+/**
+ * Returns true if it is currently okay to restore a game
+ */
+bool HopkinsEngine::canLoadGameStateCurrently() {
+ return !_globals.SORTIE && !_globals.PLAN_FLAG;
+}
+
+/**
+ * Returns true if it is currently okay to save the game
+ */
+bool HopkinsEngine::canSaveGameStateCurrently() {
+ return !_globals.SORTIE && !_globals.PLAN_FLAG;
+}
+
+/**
+ * Load the savegame at the specified slot index
+ */
+Common::Error HopkinsEngine::loadGameState(int slot) {
+ return _saveLoadManager.restore(slot);
+}
+
+/**
+ * Save the game to the given slot index, and with the given name
+ */
+Common::Error HopkinsEngine::saveGameState(int slot, const Common::String &desc) {
+ return _saveLoadManager.save(slot, desc);
+}
+
+Common::Error HopkinsEngine::run() {
+ _saveLoadManager.initSaves();
+
+ Common::StringMap iniParams;
+ _fileManager.Chage_Inifile(iniParams);
+ processIniParams(iniParams);
+
+ _globals.setConfig();
+ _fileManager.F_Censure();
+ INIT_SYSTEM();
+
+ _soundManager.WSOUND_INIT();
+
+ _globals.CHARGE_OBJET();
+ _objectsManager.CHANGE_OBJET(14);
+ _objectsManager.AJOUTE_OBJET(14);
+
+ _globals.HELICO = 0;
+ _eventsManager.MOUSE_OFF();
+
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+
+ _graphicsManager.LOAD_IMAGE("LINUX");
+
+ _graphicsManager.FADE_INW();
+ _eventsManager.delay(1500);
+ _graphicsManager.FADE_OUTW();
+
+ if (!_globals.internet) {
+ _graphicsManager.FADE_LINUX = 2;
+ _animationManager.PLAY_ANM("MP.ANM", 10, 16, 200);
+ }
+
+ _graphicsManager.LOAD_IMAGE("H2");
+ _graphicsManager.FADE_INW();
+ _eventsManager.delay(500);
+ _graphicsManager.FADE_OUTW();
+
+ if (!_eventsManager.ESC_KEY)
+ INTRORUN();
+
+ _globals.iRegul = 0;
+ _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR");
+ _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+ _globals.PERSO_TYPE = 0;
+ _globals.PLANX = _globals.PLANY = 0;
+ memset(_globals.SAUVEGARDE, 0, 2000);
+ _globals.SORTIE = 0;
+ _globals.PASSWORD = 1;
+
+LABEL_12:
+ if (_globals.SORTIE == 300)
+LABEL_13:
+ _globals.SORTIE = 0;
+
+ if (!_globals.SORTIE) {
+ _globals.SORTIE = _menuManager.MENU();
+ if (_globals.SORTIE == -1) {
+ if (!g_system->getEventManager()->shouldQuit())
+ PUBQUIT();
+ _globals.PERSO = _globals.dos_free2(_globals.PERSO);
+ REST_SYSTEM();
+ }
+ }
+
+ for (;;) {
+ for (;;) {
+ for (;;) {
+ for (;;) {
+ for (;;) {
+ for (;;) {
+ for (;;) {
+ for (;;) {
+ if (g_system->getEventManager()->shouldQuit())
+ return Common::kNoError;
+
+ if (_globals.SORTIE == 300)
+ goto LABEL_13;
+ if (_globals.SORTIE == 18)
+ PASS();
+ if (_globals.SORTIE == 23)
+ PASS();
+ if (_globals.SORTIE == 22)
+ PASS();
+ if (_globals.SORTIE == 19)
+ PASS();
+ if (_globals.SORTIE == 20)
+ PASS();
+ if (_globals.SORTIE != 1)
+ break;
+
+ _globals.Max_Propre = 50;
+ _globals.Max_Ligne_Long = 40;
+ _globals.Max_Propre_Gen = 20;
+ _globals.Max_Perso_Y = 435;
+ _objectsManager.PERSONAGE2("IM01", "IM01", "ANIM01", "IM01", 1);
+ }
+
+ if (_globals.SORTIE != 3)
+ break;
+
+ if (!*((byte *)_globals.SAUVEGARDE + 170)) {
+ _soundManager.WSOUND(3);
+ if (_globals.FR == 1)
+ _graphicsManager.LOAD_IMAGE("fondfr");
+ if (!_globals.FR)
+ _graphicsManager.LOAD_IMAGE("fondan");
+ if (_globals.FR == 2)
+ _graphicsManager.LOAD_IMAGE("fondes");
+ _graphicsManager.FADE_INW();
+ _eventsManager.delay(500);
+ _graphicsManager.FADE_OUTW();
+ _globals.iRegul = 1;
+ _soundManager.SPECIAL_SOUND = 2;
+
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.Cls_Pal();
+ _graphicsManager.FADE_LINUX = 2;
+
+ if (!_globals.CENSURE)
+ _animationManager.PLAY_ANM("BANQUE.ANM", 200, 28, 200);
+ if (_globals.CENSURE == 1)
+ _animationManager.PLAY_ANM("BANKUK.ANM", 200, 28, 200);
+ _soundManager.SPECIAL_SOUND = 0;
+ _soundManager.DEL_SAMPLE(1);
+ _soundManager.DEL_SAMPLE(2);
+ _soundManager.DEL_SAMPLE(3);
+ _soundManager.DEL_SAMPLE(4);
+ *((byte *)_globals.SAUVEGARDE + 170) = 1;
+ }
+
+ _globals.Max_Propre = 5;
+ _globals.Max_Ligne_Long = 5;
+ _globals.Max_Propre_Gen = 5;
+ _globals.Max_Perso_Y = 450;
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE2("IM03", "IM03", "ANIM03", "IM03", 2);
+ }
+
+ if (_globals.SORTIE != 4)
+ break;
+ _globals.DESACTIVE_INVENT = true;
+ _objectsManager.PLAN_BETA();
+ _globals.DESACTIVE_INVENT = false;
+ }
+
+ if (_globals.SORTIE != 5)
+ break;
+ _globals.Max_Propre = 5;
+ _globals.Max_Ligne_Long = 5;
+ _globals.Max_Propre_Gen = 5;
+ _globals.Max_Perso_Y = 455;
+ _globals.NOSPRECRAN = 1;
+ byte v1 = *((byte *)_globals.SAUVEGARDE + 80);
+ if (v1) {
+ if (v1 == 1)
+ _objectsManager.PERSONAGE2("IM05", "IM05A", "ANIM05B", "IM05", 3);
+ } else {
+ _objectsManager.PERSONAGE2("IM05", "IM05", "ANIM05", "IM05", 3);
+ }
+
+ _globals.NOSPRECRAN = 0;
+ }
+
+ if (_globals.SORTIE != 8)
+ break;
+
+ _globals.Max_Propre = 15;
+ _globals.Max_Ligne_Long = 15;
+ _globals.Max_Propre_Gen = 10;
+ _globals.Max_Perso_Y = 450;
+ _objectsManager.PERSONAGE2("IM08", "IM08", "ANIM08", "IM08", 2);
+ }
+
+ if (_globals.SORTIE != 6)
+ break;
+ _globals.Max_Propre = 15;
+ _globals.Max_Ligne_Long = 20;
+ _globals.Max_Propre_Gen = 10;
+ _globals.Max_Perso_Y = 460;
+ _objectsManager.PERSONAGE2("IM06", "IM06", "ANIM06", "IM06", 2);
+ }
+
+ if (_globals.SORTIE != 7)
+ break;
+ if (*((byte *)_globals.SAUVEGARDE + 220))
+ _objectsManager.PERSONAGE("BOMBEB", "BOMBE", "BOMBE", "BOMBE", 2);
+ else
+ _objectsManager.PERSONAGE("BOMBEA", "BOMBE", "BOMBE", "BOMBE", 2);
+ }
+
+ if (_globals.SORTIE == 9) {
+ _globals.Max_Propre = 15;
+ _globals.Max_Ligne_Long = 20;
+ _globals.Max_Propre_Gen = 10;
+ _globals.Max_Perso_Y = 440;
+
+ if (!*((byte *)_globals.SAUVEGARDE + 225))
+ goto LABEL_109;
+ _objectsManager.PERSONAGE2("IM09", "IM09", "ANIM09", "IM09", 10);
+ } else {
+ if (_globals.SORTIE == 10) {
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE("IM10", "IM10", "ANIM10", "IM10", 9);
+ goto LABEL_124;
+ }
+
+ if (_globals.SORTIE == 11) {
+ _globals.NOSPRECRAN = 1;
+ _globals.Max_Propre = 15;
+ _globals.Max_Ligne_Long = 20;
+ _globals.Max_Propre_Gen = 10;
+ _globals.Max_Perso_Y = 450;
+ _objectsManager.PERSONAGE2("IM11", "IM11", "ANIM11", "IM11", 2);
+ goto LABEL_124;
+ }
+
+ switch (_globals.SORTIE) {
+ case 12:
+ _globals.Max_Propre = 15;
+ _globals.Max_Ligne_Long = 20;
+ _globals.Max_Propre_Gen = 10;
+ _globals.Max_Perso_Y = 450;
+ if (*((byte *)_globals.SAUVEGARDE + 225)) {
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE2("IM12", "IM12", "ANIM12", "IM12", 1);
+ } else {
+LABEL_109:
+ BOOM();
+ }
+ break;
+ case 13:
+ _globals.Max_Propre = 50;
+ _globals.Max_Ligne_Long = 40;
+ _globals.Max_Propre_Gen = 20;
+ _globals.Max_Perso_Y = 440;
+ _objectsManager.PERSONAGE2("IM13", "IM13", "ANIM13", "IM13", 1);
+ break;
+ case 14:
+ _globals.Max_Propre = 50;
+ _globals.Max_Ligne_Long = 40;
+ _globals.Max_Propre_Gen = 20;
+ _globals.Max_Perso_Y = 440;
+ _objectsManager.PERSONAGE2("IM14", "IM14", "ANIM14", "IM14", 1);
+ break;
+ default:
+ if (_globals.SORTIE == 15) {
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE("IM15", "IM15", "ANIM15", "IM15", 29);
+ goto LABEL_124;
+ }
+ if (_globals.SORTIE == 16) {
+ _globals.Max_Propre = 5;
+ _globals.Max_Ligne_Long = 5;
+ _globals.Max_Propre_Gen = 5;
+ _globals.Max_Perso_Y = 450;
+
+ byte v2 = *((byte *)_globals.SAUVEGARDE + 113);
+ if (v2 == 1) {
+ _objectsManager.PERSONAGE2("IM16", "IM16A", "ANIM16", "IM16", 7);
+ } else if (!v2) {
+ _objectsManager.PERSONAGE2("IM16", "IM16", "ANIM16", "IM16", 7);
+ }
+ } else {
+ if (_globals.SORTIE == 17)
+ PASS();
+ if (_globals.SORTIE == 24)
+ PASS();
+ if (_globals.SORTIE == 25) {
+ _globals.Max_Propre = 15;
+ _globals.Max_Ligne_Long = 20;
+ _globals.Max_Propre_Gen = 10;
+ _globals.Max_Perso_Y = 445;
+ _objectsManager.PERSONAGE2("IM25", "IM25", "ANIM25", "IM25", 30);
+ } else {
+ if (_globals.SORTIE == 33) {
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE("IM33", "IM33", "ANIM33", "IM33", 8);
+ goto LABEL_124;
+ }
+
+ if (_globals.SORTIE == 26) {
+ _globals.Max_Propre = 50;
+ _globals.Max_Ligne_Long = 40;
+ _globals.Max_Propre_Gen = 20;
+ _globals.Max_Perso_Y = 435;
+ _objectsManager.PERSONAGE2("IM26", "IM26", "ANIM26", "IM26", 30);
+ } else {
+ if (_globals.SORTIE == 27)
+ PASS();
+ if (_globals.SORTIE == 28)
+ PASS();
+ if (_globals.SORTIE == 29)
+ PASS();
+ if (_globals.SORTIE == 30)
+ PASS();
+ if (_globals.SORTIE == 31)
+ PASS();
+ if (_globals.SORTIE == 35)
+ ENDEMO();
+ if (_globals.SORTIE == 32)
+ PASS();
+ if (_globals.SORTIE == 34)
+ PASS();
+
+ if ((uint16)(_globals.SORTIE - 51) <= 38)
+ PASS();
+ if (_globals.SORTIE == 111) {
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE("IM111", "IM111", "ANIM111", "IM111", 10);
+ goto LABEL_124;
+ }
+
+ if (_globals.SORTIE == 112) {
+ _globals.NOSPRECRAN = 1;
+ _objectsManager.PERSONAGE("IM112", "IM112", "ANIM112", "IM112", 10);
+LABEL_124:
+ _globals.NOSPRECRAN = 0;
+ } else if (_globals.SORTIE == 113) {
+ _globals.SORTIE = 0;
+ _globals.OLD_ECRAN = _globals.ECRAN;
+ *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN;
+ _globals.ECRAN = 113;
+ *((byte *)_globals.SAUVEGARDE + 5) = 113;
+ _menuManager.COMPUT_HOPKINS(1);
+
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.DD_VBL();
+ memset(_graphicsManager.VESA_BUFFER, 0, 0x4B000u);
+ memset(_graphicsManager.VESA_SCREEN, 0, 0x4B000u);
+ _graphicsManager.Cls_Pal();
+ _graphicsManager.RESET_SEGMENT_VESA();
+ } else {
+ if (_globals.SORTIE == 114) {
+ _globals.SORTIE = 0;
+ _globals.OLD_ECRAN = _globals.ECRAN;
+ *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN;
+ _globals.ECRAN = 114;
+ *((byte *)_globals.SAUVEGARDE + 5) = 114;
+ _menuManager.COMPUT_HOPKINS(2);
+ goto LABEL_128;
+ }
+ if (_globals.SORTIE == 115) {
+ _globals.SORTIE = 0;
+ _globals.OLD_ECRAN = _globals.ECRAN;
+ *((byte *)_globals.SAUVEGARDE + 6) = _globals.ECRAN;
+ _globals.ECRAN = 115;
+ *((byte *)_globals.SAUVEGARDE + 5) = 115;
+ _menuManager.COMPUT_HOPKINS(3);
+
+LABEL_128:
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ } else if ((uint16)(_globals.SORTIE - 194) > 5) {
+ if (_globals.SORTIE == 151) {
+ _soundManager.WSOUND(16);
+ _globals.iRegul = 1;
+
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.Cls_Pal();
+ _graphicsManager.FADE_LINUX = 2;
+ _animationManager.PLAY_ANM("JOUR3A.anm", 12, 12, 2000);
+ _globals.iRegul = 0;
+ _globals.SORTIE = 300;
+ }
+
+ if (_globals.SORTIE == 150) {
+ _soundManager.WSOUND(16);
+ _globals.iRegul = 1;
+
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.Cls_Pal();
+ _graphicsManager.FADE_LINUX = 2;
+ _animationManager.PLAY_ANM("JOUR1A.anm", 12, 12, 2000);
+ _globals.iRegul = 0;
+ _globals.SORTIE = 300;
+ }
+
+ if (_globals.SORTIE == 152) {
+ _soundManager.WSOUND(16);
+ _globals.iRegul = 1;
+
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.Cls_Pal();
+ _graphicsManager.FADE_LINUX = 2;
+ _animationManager.PLAY_ANM("JOUR4A.anm", 12, 12, 2000);
+ _globals.iRegul = 0;
+ _globals.SORTIE = 300;
+ }
+ goto LABEL_12;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ // Stub event loop
+ Common::Event evt;
+ while (!g_system->getEventManager()->shouldQuit()) {
+ while (g_system->getEventManager()->pollEvent(evt))
+ g_system->updateScreen();
+ }
+
+ return Common::kNoError;
+}
+
+bool HopkinsEngine::shouldQuit() const {
+ return g_system->getEventManager()->shouldQuit();
+}
+
+int HopkinsEngine::getRandomNumber(int maxNumber) {
+ return _randomSource.getRandomNumber(maxNumber);
+}
+
+void HopkinsEngine::processIniParams(Common::StringMap &iniParams) {
+ _globals.XFULLSCREEN = iniParams["FULLSCREEN"] == "YES";
+
+ _globals.XSETMODE = 1;
+ if (iniParams.contains("SETMODE")) {
+ int setMode = atoi(iniParams["SETMODE"].c_str());
+ _globals.XSETMODE = CLIP(setMode, 1, 5);
+ }
+
+ _globals.XZOOM = 0;
+ if (_globals.XSETMODE == 5 && iniParams.contains("ZOOM")) {
+ int zoom = atoi(iniParams["ZOOM"].c_str());
+ _globals.XZOOM = CLIP(zoom, 25, 100);
+ }
+
+ _globals.XFORCE16 = iniParams["FORCE16BITS"] == "YES";
+ _globals.XFORCE8 = iniParams["FORCE8BITS"] == "YES";
+ _globals.CARD_SB = iniParams["SOUND"] == "YES";
+}
+
+void HopkinsEngine::INIT_SYSTEM() {
+ // Set graphics mode
+ _graphicsManager.SET_MODE(640, 480);
+
+ if (getPlatform() == Common::kPlatformLinux)
+ _eventsManager.mouse_linux = true;
+ else
+ _eventsManager.mouse_linux = false;
+
+ switch (_globals.FR) {
+ case 0:
+ if (!_eventsManager.mouse_linux)
+ _fileManager.CONSTRUIT_SYSTEM("SOUAN.SPR");
+ else
+ _fileManager.CONSTRUIT_SYSTEM("LSOUAN.SPR");
+ break;
+ case 1:
+ if (!_eventsManager.mouse_linux)
+ _fileManager.CONSTRUIT_SYSTEM("SOUFR.SPR");
+ else
+ _fileManager.CONSTRUIT_SYSTEM("LSOUFR.SPR");
+ break;
+ case 2:
+ _fileManager.CONSTRUIT_SYSTEM("SOUES.SPR");
+ break;
+ }
+
+ if (_eventsManager.mouse_linux) {
+ _eventsManager.souris_sizex = 52;
+ _eventsManager.souris_sizey = 32;
+ } else {
+ _eventsManager.souris_sizex = 34;
+ _eventsManager.souris_sizey = 20;
+ }
+ _eventsManager.pointeur_souris = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+
+ _globals.clearAll();
+
+ _fileManager.CONSTRUIT_SYSTEM("FONTE3.SPR");
+ _globals.police = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+ _globals.police_l = 12;
+ _globals.police_h = 21;
+ _fileManager.CONSTRUIT_SYSTEM("ICONE.SPR");
+ _globals.ICONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+ _fileManager.CONSTRUIT_SYSTEM("TETE.SPR");
+ _globals.TETE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+
+ switch (_globals.FR) {
+ case 0:
+ _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "ZONEAN.TXT");
+ _globals.BUF_ZONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+ break;
+ case 1:
+ _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "ZONE01.TXT");
+ _globals.BUF_ZONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+ break;
+ case 2:
+ _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "ZONEES.TXT");
+ _globals.BUF_ZONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER);
+ break;
+ }
+
+ _eventsManager.INSTALL_SOURIS();
+ _eventsManager.souris_on();
+ _eventsManager.souris_flag = false;
+ _eventsManager.souris_max();
+
+ _globals.HOPKINS_DATA();
+
+ _eventsManager.ofset_souris_x = 0;
+ _eventsManager.ofset_souris_y = 0;
+ _globals.lItCounter = 0;
+ _globals.lOldItCounter = 0;
+}
+
+void HopkinsEngine::INTRORUN() {
+ signed int v2;
+ signed int v3;
+ uint16 v4;
+ signed int v5;
+ int i;
+ int v7;
+ signed int v8;
+ signed int v9;
+ signed int v11;
+ int v12;
+ signed int v13;
+ signed int v14;
+ int j;
+ int k;
+ int l;
+ int m;
+ int v21;
+ char v22;
+ char v23;
+ byte paletteData[PALETTE_EXT_BLOCK_SIZE];
+ byte paletteData2[PALETTE_EXT_BLOCK_SIZE];
+
+ memset(&paletteData, 0, PALETTE_EXT_BLOCK_SIZE);
+ _eventsManager.VBL();
+ _eventsManager.souris_flag = false;
+ _globals.iRegul = 1;
+ _eventsManager.VBL();
+ _soundManager.WSOUND(16);
+ _animationManager.CLS_ANM = true;
+ _animationManager.PLAY_ANM("J1.anm", 12, 12, 50);
+ if (!_eventsManager.ESC_KEY) {
+ _soundManager.VOICE_MIX(1, 3);
+ _animationManager.PLAY_ANM("J2.anm", 12, 12, 50);
+
+ if (!_eventsManager.ESC_KEY) {
+ _soundManager.VOICE_MIX(2, 3);
+ _animationManager.PLAY_ANM("J3.anm", 12, 12, 50);
+
+ if (!_eventsManager.ESC_KEY) {
+ _soundManager.VOICE_MIX(3, 3);
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.Cls_Pal();
+ _graphicsManager.DD_VBL();
+ _soundManager.WSOUND(11);
+ _graphicsManager.LOAD_IMAGE("intro1");
+ _graphicsManager.SCROLL_ECRAN(0);
+ _graphicsManager.ofscroll = 0;
+ _graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _globals.BPP_NOAFF = true;
+ v2 = 0;
+ do {
+ _eventsManager.VBL();
+ ++v2;
+ } while (v2 <= 4);
+
+ _globals.BPP_NOAFF = false;
+ _globals.iRegul = 1;
+ _graphicsManager.FADE_INW();
+ if (_graphicsManager.DOUBLE_ECRAN == true) {
+ _graphicsManager.no_scroll = 2;
+ v3 = 0;
+ _graphicsManager.SCROLL = 0;
+
+ do {
+ _graphicsManager.SCROLL += 2;
+ if (_graphicsManager.SCROLL > (SCREEN_WIDTH - 2)) {
+ _graphicsManager.SCROLL = SCREEN_WIDTH;
+ v3 = 1;
+ }
+
+ if (_eventsManager.XMOUSE() < _graphicsManager.SCROLL + 10) {
+ v4 = _eventsManager.YMOUSE();
+ _eventsManager.souris_xy(_eventsManager.souris_x + 4, v4);
+ }
+ _eventsManager.VBL();
+ } while (!shouldQuit() && v3 != 1 && _graphicsManager.SCROLL != SCREEN_WIDTH);
+
+ _eventsManager.VBL();
+ _graphicsManager.no_scroll = 0;
+
+ if (shouldQuit())
+ return;
+ }
+
+ _soundManager.VOICE_MIX(4, 3);
+ _graphicsManager.FADE_OUTW();
+ _graphicsManager.no_scroll = 0;
+ _graphicsManager.LOAD_IMAGE("intro2");
+ _graphicsManager.SCROLL_ECRAN(0);
+ _animationManager.CHARGE_ANIM("INTRO2");
+ _graphicsManager.VISU_ALL();
+ _soundManager.WSOUND(23);
+ _objectsManager.BOBANIM_OFF(3);
+ _objectsManager.BOBANIM_OFF(5);
+ _graphicsManager.ofscroll = 0;
+ _graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _globals.BPP_NOAFF = true;
+ v5 = 0;
+
+ do {
+ _eventsManager.VBL();
+ ++v5;
+ } while (v5 <= 4);
+
+ _globals.BPP_NOAFF = false;
+ _globals.iRegul = 1;
+ _graphicsManager.FADE_INW();
+ for (i = 0; i < 200 / _globals.vitesse; ++i)
+ _eventsManager.VBL();
+
+ _objectsManager.BOBANIM_ON(3);
+ _soundManager.VOICE_MIX(5, 3);
+ _objectsManager.BOBANIM_OFF(3);
+ _eventsManager.VBL();
+ memcpy(&paletteData2, _graphicsManager.Palette, 796);
+ v21 = *(uint16 *)&_graphicsManager.Palette[796];
+ v22 = _graphicsManager.Palette[798];
+ v7 = (int)&v23;
+ _graphicsManager.setpal_vga256_linux(paletteData, _graphicsManager.VESA_BUFFER);
+ _graphicsManager.FIN_VISU();
+
+ if (shouldQuit())
+ return;
+
+ _soundManager.SPECIAL_SOUND = 5;
+ _graphicsManager.FADE_LINUX = 2;
+ _animationManager.PLAY_ANM("ELEC.ANM", 10, 26, 200);
+ if (shouldQuit())
+ return;
+
+ _soundManager.SPECIAL_SOUND = 0;
+
+ if (!_eventsManager.ESC_KEY) {
+ _graphicsManager.LOAD_IMAGE("intro2");
+ _graphicsManager.SCROLL_ECRAN(0);
+ _animationManager.CHARGE_ANIM("INTRO2");
+ _graphicsManager.VISU_ALL();
+ _soundManager.WSOUND(23);
+ _objectsManager.BOBANIM_OFF(3);
+ _objectsManager.BOBANIM_OFF(5);
+ _objectsManager.BOBANIM_OFF(1);
+ _graphicsManager.ofscroll = 0;
+ _graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _globals.BPP_NOAFF = true;
+ v8 = 0;
+
+ do {
+ _eventsManager.VBL();
+ ++v8;
+ } while (v8 <= 3);
+
+ _globals.BPP_NOAFF = false;
+ _globals.iRegul = 1;
+ _graphicsManager.setpal_vga256_linux(paletteData2, _graphicsManager.VESA_BUFFER);
+ v9 = 0;
+
+ while (!shouldQuit() && !_eventsManager.ESC_KEY) {
+ if (v9 == 12) {
+ _objectsManager.BOBANIM_ON(3);
+ _eventsManager.VBL();
+ _soundManager.VOICE_MIX(6, 3);
+ _eventsManager.VBL();
+ _objectsManager.BOBANIM_OFF(3);
+ }
+
+ Common::copy(&paletteData2[0], &paletteData2[PALETTE_BLOCK_SIZE], &_graphicsManager.Palette[0]);
+
+ v11 = 1;
+ v12 = 4 * v9;
+ do {
+ if (_graphicsManager.Palette[v11] > v12)
+ _graphicsManager.Palette[v11] -= v12;
+ ++v11;
+ } while ( v11 <= PALETTE_BLOCK_SIZE);
+
+ _graphicsManager.setpal_vga256_linux(_graphicsManager.Palette, _graphicsManager.VESA_BUFFER);
+ v13 = 1;
+
+ if (2 * v9 > 1) {
+ v7 = 2 * v9;
+
+ do {
+ _eventsManager.VBL();
+ ++v13;
+ } while (v13 < v7);
+ }
+
+ _graphicsManager.setpal_vga256_linux(paletteData2, _graphicsManager.VESA_BUFFER);
+ v14 = 1;
+ if (20 - v9 > 1) {
+ v7 = 20 - v9;
+
+ do {
+ _eventsManager.VBL();
+ ++v14;
+ } while (v14 < v7);
+ }
+
+ v9 += 2;
+ if (v9 > 15) {
+ _graphicsManager.setpal_vga256_linux(paletteData, _graphicsManager.VESA_BUFFER);
+ for (j = 1; j < 100 / _globals.vitesse; ++j)
+ _eventsManager.VBL();
+
+ _objectsManager.BOBANIM_ON(3);
+ _soundManager.VOICE_MIX(7, 3);
+ _objectsManager.BOBANIM_OFF(3);
+
+ for (k = 1; k < 60 / _globals.vitesse; ++k)
+ _eventsManager.VBL();
+ _objectsManager.BOBANIM_ON(5);
+ for (l = 0; l < 20 / _globals.vitesse; ++l)
+ _eventsManager.VBL();
+
+ Common::copy(&paletteData2[0], &paletteData2[PALETTE_BLOCK_SIZE], &_graphicsManager.Palette[0]);
+ _graphicsManager.setpal_vga256_linux(_graphicsManager.Palette, _graphicsManager.VESA_BUFFER);
+
+ for (m = 0; m < 50 / _globals.vitesse; ++m) {
+ if (m == 30 / _globals.vitesse) {
+ _objectsManager.BOBANIM_ON(3);
+ _soundManager.VOICE_MIX(8, 3);
+ _objectsManager.BOBANIM_OFF(3);
+ }
+
+ _eventsManager.VBL();
+ }
+
+ _graphicsManager.FADE_OUTW();
+ _graphicsManager.FIN_VISU();
+ _animationManager.CLS_ANM = true;
+ _soundManager.WSOUND(3);
+ _soundManager.SPECIAL_SOUND = 1;
+ _animationManager.PLAY_ANM("INTRO1.anm", 10, 24, 18);
+ if (shouldQuit())
+ return;
+
+ _soundManager.SPECIAL_SOUND = 0;
+
+ if (!_eventsManager.ESC_KEY) {
+ _animationManager.PLAY_ANM("INTRO2.anm", 10, 24, 18);
+ if (shouldQuit())
+ return;
+
+ if (!_eventsManager.ESC_KEY) {
+ _animationManager.PLAY_ANM("INTRO3.anm", 10, 24, 200);
+ if (shouldQuit())
+ return;
+
+ if (!_eventsManager.ESC_KEY) {
+ _animationManager.CLS_ANM = false;
+ _graphicsManager.FADE_LINUX = 2;
+ _animationManager.PLAY_ANM("J4.anm", 12, 12, 1000);
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ _eventsManager.ESC_KEY = false;
+}
+
+void HopkinsEngine::PASS() {
+ if (_globals.FR == 1)
+ _graphicsManager.LOAD_IMAGE("ndfr");
+ else
+ _graphicsManager.LOAD_IMAGE("nduk");
+
+ _graphicsManager.FADE_INW();
+ if (_soundManager.VOICEOFF)
+ _eventsManager.delay(500);
+ else
+ _soundManager.VOICE_MIX(628, 4);
+
+ _graphicsManager.FADE_OUTW();
+ _globals.SORTIE = 4;
+}
+
+void HopkinsEngine::ENDEMO() {
+ _soundManager.WSOUND(28);
+ if (_globals.FR == 1)
+ _graphicsManager.LOAD_IMAGE("endfr");
+ else
+ _graphicsManager.LOAD_IMAGE("enduk");
+
+ _graphicsManager.FADE_INW();
+ _eventsManager.delay(1500);
+ _graphicsManager.FADE_OUTW();
+ _globals.SORTIE = 0;
+}
+
+void HopkinsEngine::BOOM() {
+ _graphicsManager.nbrligne = 640;
+ _graphicsManager.SCANLINE(640);
+ _graphicsManager.DD_Lock();
+ _graphicsManager.Cls_Video();
+ _graphicsManager.DD_Unlock();
+ _graphicsManager.Cls_Pal();
+
+ _globals.iRegul = 1;
+ _soundManager.SPECIAL_SOUND = 199;
+ _graphicsManager.FADE_LINUX = 2;
+ if (_globals.SVGA == 1)
+ _animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500);
+ if (_globals.SVGA == 2)
+ _animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500);
+
+ _soundManager.SPECIAL_SOUND = 0;
+ _graphicsManager.LOAD_IMAGE("IM15");
+ _animationManager.CHARGE_ANIM("ANIM15");
+ _graphicsManager.VISU_ALL();
+ _objectsManager.BOBANIM_OFF(7);
+ _globals.BPP_NOAFF = true;
+
+ for (int idx = 0; idx < 5; ++idx) {
+ _eventsManager.VBL();
+ }
+
+ _globals.BPP_NOAFF = false;
+ _graphicsManager.FADE_INW();
+ _eventsManager.MOUSE_OFF();
+
+ for (int idx = 0; idx < 20; ++idx) {
+ _eventsManager.VBL();
+ }
+
+ _globals.NOPARLE = true;
+ _talkManager.PARLER_PERSO2("vire.pe2");
+ _globals.NOPARLE = false;
+ _objectsManager.BOBANIM_ON(7);
+
+ for (int idx = 0; idx < 100; ++idx) {
+ _eventsManager.VBL();
+ }
+
+ _graphicsManager.FADE_OUTW();
+ _graphicsManager.FIN_VISU();
+ _globals.iRegul = 0;
+ _globals.SORTIE = 151;
+}
+
+void HopkinsEngine::REST_SYSTEM() {
+ quitGame();
+ _eventsManager.CONTROLE_MES();
+}
+
+void HopkinsEngine::PUBQUIT() {
+ _globals.PUBEXIT = 1;
+ _graphicsManager.RESET_SEGMENT_VESA();
+ _globals.FORET = 0;
+ _eventsManager.CASSE = false;
+ _globals.DESACTIVE_INVENT = true;
+ _globals.FLAG_VISIBLE = false;
+ _graphicsManager.LOAD_IMAGE("BOX");
+ _soundManager.WSOUND(28);
+ _graphicsManager.FADE_INW();
+ _eventsManager.MOUSE_ON();
+ _eventsManager.CHANGE_MOUSE(0);
+ _eventsManager.btsouris = 0;
+ _eventsManager.souris_n = 0;
+ _globals.netscape = true;
+
+ bool mouseClicked = false;
+ int xp, yp;
+ do {
+ xp = _eventsManager.XMOUSE();
+ yp = _eventsManager.YMOUSE();
+ _eventsManager.VBL();
+
+ if (_eventsManager.BMOUSE() == 1)
+ mouseClicked = true;
+ } while (!mouseClicked && !g_system->getEventManager()->shouldQuit());
+
+ // Original tried to open a web browser link here. Since ScummVM doesn't support
+ // that, it's being skipped in favour of simply exitting
+
+ _graphicsManager.FADE_OUTW();
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h
new file mode 100644
index 0000000000..1399a80498
--- /dev/null
+++ b/engines/hopkins/hopkins.h
@@ -0,0 +1,147 @@
+/* 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_H
+#define HOPKINS_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/error.h"
+#include "common/random.h"
+#include "common/hash-str.h"
+#include "common/util.h"
+#include "engines/engine.h"
+#include "graphics/surface.h"
+#include "hopkins/anim.h"
+#include "hopkins/debugger.h"
+#include "hopkins/dialogs.h"
+#include "hopkins/events.h"
+#include "hopkins/files.h"
+#include "hopkins/font.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/lines.h"
+#include "hopkins/menu.h"
+#include "hopkins/objects.h"
+#include "hopkins/saveload.h"
+#include "hopkins/script.h"
+#include "hopkins/sound.h"
+#include "hopkins/talk.h"
+
+/**
+ * This is the namespace of the Hopkins engine.
+ *
+ * Status of this engine: In Development
+ *
+ * Games using this engine:
+ * - Hopkins FBI
+ */
+namespace Hopkins {
+
+enum {
+ kHopkinsDebugAnimations = 1 << 0,
+ kHopkinsDebugActions = 1 << 1,
+ kHopkinsDebugSound = 1 << 2,
+ kHopkinsDebugMusic = 1 << 3,
+ kHopkinsDebugScripts = 1 << 4
+};
+
+#define DEBUG_BASIC 1
+#define DEBUG_INTERMEDIATE 2
+#define DEBUG_DETAILED 3
+
+#define SCREEN_WIDTH 640
+#define SCREEN_HEIGHT 480
+
+struct HopkinsGameDescription;
+
+class HopkinsEngine : public Engine {
+private:
+ const HopkinsGameDescription *_gameDescription;
+ Common::RandomSource _randomSource;
+
+ /**
+ * Processes the loaded list of ini file parameters
+ */
+ void processIniParams(Common::StringMap &iniParams);
+
+ void INIT_SYSTEM();
+
+ void PASS();
+ void REST_SYSTEM();
+ void PUBQUIT();
+ void ENDEMO();
+ void BOOM();
+protected:
+ // Engine APIs
+ virtual Common::Error run();
+ virtual bool hasFeature(EngineFeature f) const;
+
+public:
+ Debugger _debugger;
+ AnimationManager _animationManager;
+ DialogsManager _dialogsManager;
+ EventsManager _eventsManager;
+ FontManager _fontManager;
+ Globals _globals;
+ FileManager _fileManager;
+ GraphicsManager _graphicsManager;
+ LinesManager _linesManager;
+ MenuManager _menuManager;
+ ObjectsManager _objectsManager;
+ SaveLoadManager _saveLoadManager;
+ ScriptManager _scriptManager;
+ SoundManager _soundManager;
+ TalkManager _talkManager;
+public:
+ HopkinsEngine(OSystem *syst, const HopkinsGameDescription *gameDesc);
+ virtual ~HopkinsEngine();
+ void GUIError(const Common::String &msg);
+
+ uint32 getFeatures() const;
+ Common::Language getLanguage() const;
+ Common::Platform getPlatform() const;
+ uint16 getVersion() const;
+ bool getIsDemo() const;
+ bool shouldQuit() const;
+
+ int getRandomNumber(int maxNumber);
+ Common::String generateSaveName(int slotNumber);
+ virtual bool canLoadGameStateCurrently();
+ virtual bool canSaveGameStateCurrently();
+ virtual Common::Error loadGameState(int slot);
+ virtual Common::Error saveGameState(int slot, const Common::String &desc);
+
+ /**
+ * Run the introduction sequence
+ */
+ void INTRORUN();
+};
+
+// Global reference to the HopkinsEngine object
+extern HopkinsEngine *g_vm;
+
+#define GLOBALS g_vm->_globals
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_H */
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
new file mode 100644
index 0000000000..2ba89962d7
--- /dev/null
+++ b/engines/hopkins/lines.cpp
@@ -0,0 +1,3927 @@
+/* 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 "common/textconsole.h"
+#include "hopkins/lines.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+LinesManager::LinesManager() {
+ for (int i = 0; i < 400; ++i) {
+ Common::fill((byte *)&LigneZone[i], (byte *)&LigneZone[i] + sizeof(LigneZoneItem), 0);
+ Common::fill((byte *)&Ligne[i], (byte *)&Ligne[i] + sizeof(LigneItem), 0);
+ }
+ for (int i = 0; i < 4000; ++i) {
+ Common::fill((byte *)&SMOOTH[i], (byte *)&SMOOTH[i] + sizeof(SmoothItem), 0);
+ }
+
+ next_ligne = 0;
+ TOTAL_LIGNES = 0;
+ NV_LIGNEDEP = 0;
+ NV_LIGNEOFS = 0;
+ NV_POSI = 0;
+ NVPX = 0;
+ NVPY = 0;
+ SMOOTH_SENS = 0;
+ SMOOTH_X = SMOOTH_Y = 0;
+}
+
+void LinesManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+void LinesManager::CLEAR_ZONE() {
+ for (int idx = 0; idx < 400; ++idx)
+ RETIRE_LIGNE_ZONE(idx);
+
+ next_ligne = 0;
+}
+
+// Object Zone
+int LinesManager::ZONE_OBJET(int a1, int a2) {
+ int v2;
+
+ v2 = 0;
+ if ((uint)(a2 - 120) <= 0x21u)
+ v2 = OPTI_ZONE(a1, 1, 0);
+ if ((uint)(a2 - 154) <= 0x25u)
+ v2 = OPTI_ZONE(a1, 7, 0);
+ if ((uint)(a2 - 192) <= 0x25u)
+ v2 = OPTI_ZONE(a1, 13, 0);
+ if ((uint)(a2 - 230) <= 0x25u)
+ v2 = OPTI_ZONE(a1, 19, 0);
+ if ((uint)(a2 - 268) <= 0x25u)
+ v2 = OPTI_ZONE(a1, 25, 1);
+ if ((uint)(a2 - 268) <= 0x14u && a1 >= _vm->_graphicsManager.ofscroll + 424 && a1 <= _vm->_graphicsManager.ofscroll + 478)
+ v2 = 30;
+ if ((uint)(a2 - 290) <= 0x10u && a1 >= _vm->_graphicsManager.ofscroll + 424 && a1 <= _vm->_graphicsManager.ofscroll + 478)
+ v2 = 31;
+ if (a1 < _vm->_graphicsManager.ofscroll + 152 || a1 > _vm->_graphicsManager.ofscroll + 484)
+ v2 = 32;
+ if ((uint)(a2 - 114) > 0xC0u)
+ v2 = 32;
+ return v2;
+}
+
+int LinesManager::OPTI_ZONE(int a1, int a2, int a3) {
+ int v3;
+ signed int v4;
+
+ v3 = a2;
+ v4 = 0;
+ if (a1 >= _vm->_graphicsManager.ofscroll + 158 && a1 <= _vm->_graphicsManager.ofscroll + 208)
+ v4 = 1;
+ if (!v4) {
+ if (a1 >= _vm->_graphicsManager.ofscroll + 208 && a1 <= _vm->_graphicsManager.ofscroll + 266) {
+ v3 = a2 + 1;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (a1 >= _vm->_graphicsManager.ofscroll + 266 && a1 <= _vm->_graphicsManager.ofscroll + 320) {
+ v3 += 2;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (a1 >= _vm->_graphicsManager.ofscroll + 320 && a1 <= _vm->_graphicsManager.ofscroll + 370) {
+ v3 += 3;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (a1 >= _vm->_graphicsManager.ofscroll + 370 && a1 <= _vm->_graphicsManager.ofscroll + 424) {
+ v3 += 4;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (!a3 && a1 >= _vm->_graphicsManager.ofscroll + 424 && a1 <= _vm->_graphicsManager.ofscroll + 478) {
+ v3 += 5;
+ v4 = 1;
+ }
+ if (!v4)
+ v3 = 0;
+ }
+ }
+ }
+ }
+ }
+ return v3;
+}
+
+// Remove Line Zone
+void LinesManager::RETIRE_LIGNE_ZONE(int idx) {
+ if (idx > 400)
+ error("Attempting to add a line obstacle > MAX_LIGNE.");
+ if (_vm->_linesManager.LigneZone[idx].zoneData != (int16 *)g_PTRNUL)
+ _vm->_globals.dos_free2((byte *)_vm->_linesManager.LigneZone[idx].zoneData);
+
+ _vm->_linesManager.LigneZone[idx].zoneData = (int16 *)g_PTRNUL;
+}
+
+// Add Line Zone
+void LinesManager::AJOUTE_LIGNE_ZONE(int idx, int a2, int a3, int a4, int a5, int a6) {
+ int v8;
+ int v9;
+ int16 *zoneData;
+ int16 *dataP;
+ int v11;
+ int v13;
+ int v14;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+
+ if (a2 != a3 || a3 != a4 || a3 != a5) {
+ if (idx > 400)
+ error("Attempting to add a line obstacle > MAX_LIGNE.");
+
+ if (LigneZone[idx].zoneData != (int16 *)g_PTRNUL)
+ LigneZone[idx].zoneData = (int16 *)_vm->_globals.dos_free2((byte *)LigneZone[idx].zoneData);
+ v8 = a2 - a4;
+ if (a2 - a4 < 0)
+ v8 = -v8;
+ v19 = v8;
+ v9 = a3 - a5;
+ if (a3 - a5 < 0)
+ v9 = -v9;
+ v18 = v9;
+ if (v19 <= v9)
+ v20 = v9 + 1;
+ else
+ v20 = v19 + 1;
+
+ zoneData = (int16 *)_vm->_globals.dos_malloc2(2 * sizeof(int16) * v20 + (4 * sizeof(int16)));
+ v11 = idx;
+ LigneZone[v11].zoneData = zoneData;
+ if (zoneData == (int16 *)g_PTRNUL)
+ error("AJOUTE LIGNE ZONE");
+
+ dataP = zoneData;
+ v23 = 1000 * v19 / v20;
+ v22 = 1000 * v18 / v20;
+ if (a4 < a2)
+ v23 = -v23;
+ if (a5 < a3)
+ v22 = -v22;
+ v13 = 1000 * a2;
+ v16 = 1000 * a3;
+ v17 = 1000 * a2 / 1000;
+ v21 = 1000 * a3 / 1000;
+ v14 = 0;
+ if (v20 > 0) {
+ do {
+ *dataP++ = v17;
+ *dataP++ = v21;
+
+ v13 += v23;
+ v16 += v22;
+ v17 = v13 / 1000;
+ v21 = v16 / 1000;
+ ++v14;
+ } while (v20 > v14);
+ }
+ *dataP++ = -1;
+ *dataP++ = -1;
+
+ LigneZone[idx].count = v20;
+ LigneZone[idx].field2 = a6;
+ } else {
+ _vm->_globals.BOBZONE_FLAG[a6] = true;
+ _vm->_globals.BOBZONE[a6] = a3;
+ }
+}
+
+
+void LinesManager::RESET_OBSTACLE() {
+ for (int idx =0; idx < 400; ++idx) {
+ RETIRE_LIGNE(idx);
+ Ligne[idx].field0 = 0;
+ Ligne[idx].lineData = (int16 *)g_PTRNUL;
+ }
+}
+
+// Remove Line
+void LinesManager::RETIRE_LIGNE(int idx) {
+ if (idx > 400)
+ error("Attempting to add a line obstacle > MAX_LIGNE.");
+ if (Ligne[idx].lineData != (int16 *)g_PTRNUL)
+ _vm->_globals.dos_free2((byte *)Ligne[idx].lineData);
+ Ligne[idx].lineData = (int16 *)g_PTRNUL;
+}
+
+// Add Line
+void LinesManager::AJOUTE_LIGNE(int idx, int a2, int a3, int a4, int a5, int a6, int a7) {
+ int v7;
+ int v8;
+ int v9;
+ byte *v10;
+ int v11;
+ int v12;
+ int v13;
+ int v24;
+ int v25;
+ int v26;
+ int16 *v27;
+ int v30;
+ int v31;
+ int16 *v32;
+ int v33;
+ int v34;
+ int v35;
+ int v36;
+ int v37;
+ int v38;
+ int v39;
+ int v40;
+
+ if (idx > 400)
+ error("Attempting to add a line obstacle > MAX_LIGNE.");
+ if (TOTAL_LIGNES < idx)
+ TOTAL_LIGNES = idx;
+
+ if (Ligne[idx].lineData != (int16 *)g_PTRNUL)
+ _vm->_globals.dos_free2((byte *)Ligne[idx].lineData);
+ v7 = a3 - a5;
+ if (a3 - a5 < 0)
+ v7 = -v7;
+ v8 = v7 + 1;
+ v9 = a4 - a6;
+ if (a4 - a6 < 0)
+ v9 = -v9;
+ v34 = v9 + 1;
+ v33 = v9 + 1;
+ if (v8 > (int)(v9 + 1))
+ v34 = v8;
+
+ v10 = _vm->_globals.dos_malloc2(4 * v34 + 8);
+ if (v10 == g_PTRNUL)
+ error("AJOUTE LIGNE OBSTACLE");
+
+ Common::fill(v10, v10 + 4 * v34 + 8, 0);
+ Ligne[idx].lineData = (int16 *)v10;
+
+ v32 = Ligne[idx].lineData;
+ v36 = 1000 * v8;
+ v39 = 1000 * v8 / (v34 - 1);
+ v37 = 1000 * v33 / (v34 - 1);
+ if (a5 < a3)
+ v39 = -v39;
+ if (a6 < a4)
+ v37 = -v37;
+ v11 = (int)v39 / 1000;
+ v12 = (int)v37 / 1000;
+ v13 = (int)v37 / 1000;
+ if (!((int)v39 / 1000)) {
+ if (v12 == -1) {
+ Ligne[idx].field6 = 1;
+ Ligne[idx].field8 = 5;
+ }
+ if (v12 == 1) {
+ Ligne[idx].field6 = 5;
+ Ligne[idx].field8 = 1;
+ }
+ }
+ if (v11 == 1) {
+ if (v12 == -1) {
+ Ligne[idx].field6 = 2;
+ Ligne[idx].field8 = 6;
+ }
+ if (!v13) {
+ Ligne[idx].field6 = 3;
+ Ligne[idx].field8 = 7;
+ }
+ if (v13 == 1) {
+ Ligne[idx].field6 = 4;
+ Ligne[idx].field8 = 8;
+ }
+ }
+ if (v11 == -1) {
+ if (v13 == 1) {
+ Ligne[idx].field6 = 6;
+ Ligne[idx].field8 = 2;
+ }
+ if (!v13) {
+ Ligne[idx].field6 = 7;
+ Ligne[idx].field8 = 3;
+ }
+ if (v13 == -1) {
+ Ligne[idx].field6 = 8;
+ Ligne[idx].field8 = 4;
+ }
+ }
+ if (v11 == 1 && (unsigned int)(v37 - 251) <= 0x2EC) {
+ Ligne[idx].field6 = 4;
+ Ligne[idx].field8 = 8;
+ }
+ if (v11 == -1 && (unsigned int)(v37 - 251) <= 0x2EC) {
+ Ligne[idx].field6 = 6;
+ Ligne[idx].field8 = 2;
+ }
+ if (v11 == 1 && (unsigned int)(v37 + 999) <= 0x2EC) {
+ Ligne[idx].field6 = 2;
+ Ligne[idx].field8 = 6;
+ }
+ if (v11 == -1 && v37 <= 249 && v37 > 1000) {
+ Ligne[idx].field6 = 8;
+ Ligne[idx].field8 = 4;
+ }
+ v40 = v36 / v34;
+ v38 = 1000 * v33 / v34;
+ if (a5 < a3)
+ v40 = -v40;
+ if (a6 < a4)
+ v38 = -v38;
+ v24 = 1000 * a3;
+ v25 = 1000 * a4;
+ v31 = 1000 * a3 / 1000;
+ v30 = 1000 * a4 / 1000;
+ v35 = v34 - 1;
+ v26 = 0;
+ if (v35 > 0) {
+ do {
+ v32[0] = v31;
+ v32[1] = v30;
+ v32 += 2;
+
+ v24 += v40;
+ v25 += v38;
+ v31 = v24 / 1000;
+ v30 = v25 / 1000;
+ ++v26;
+ } while (v35 > v26);
+ }
+ v32[0] = a5;
+ v32[1] = a6;
+
+ v27 = v32 + 2;
+ v27[0] = -1;
+ v27[1] = -1;
+
+ Ligne[idx].field0 = v35 + 1;
+ Ligne[idx].field2 = a7;
+ Ligne[idx].field4 = a2;
+}
+
+// Line Collision 2
+int LinesManager::colision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6) {
+ int v6;
+ int16 *v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int16 *v13;
+ int v14;
+ int result;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+
+ v24 = a5;
+ v6 = a5;
+ if (a5 >= a6 + 1) {
+LABEL_29:
+ result = 0;
+ } else {
+ v22 = a1 + 4;
+ v21 = a1 - 4;
+ v20 = a2 + 4;
+ v19 = a2 - 4;
+ while (1) {
+ v7 = Ligne[v6].lineData;
+
+ if (v7 != (int16 *)g_PTRNUL) {
+ v23 = 1;
+ v8 = 2 * Ligne[v6].field0;
+ v9 = v7[0];
+ v16 = v7[1];
+ v10 = v7[v8 - 2];
+ v18 = v7[v8 - 1];
+ if (v7[0] >= v10)
+ goto LABEL_32;
+ if (v22 < v9 || v21 > v10)
+ v23 = 0;
+ if (v9 >= v10) {
+LABEL_32:
+ if (v21 > v9 || v22 < v10)
+ v23 = 0;
+ }
+ if (v16 >= v18)
+ goto LABEL_33;
+ if (v20 < v16 || v19 > v18)
+ v23 = 0;
+ if (v16 >= v18) {
+LABEL_33:
+ if (v19 > v16 || v20 < v18)
+ v23 = 0;
+ }
+ if (v23 == 1) {
+ v11 = 0;
+ v17 = Ligne[v24].field0;
+ if (v17 > 0)
+ break;
+ }
+ }
+LABEL_28:
+ ++v24;
+ v6 = v24;
+ if (v24 >= a6 + 1)
+ goto LABEL_29;
+ }
+ while (1) {
+ v12 = v7[0];
+
+ v13 = v7 + 1;
+ v14 = v13[0];
+ v7 = v13 + 1;
+
+ if (a1 == v12 || a1 + 1 == v12) {
+ if (a2 == v14 || a2 + 1 == v14)
+ break;
+ }
+ ++v11;
+ if (v17 <= v11)
+ goto LABEL_28;
+ }
+ *a3 = v11;
+ *a4 = v24;
+ result = 1;
+ }
+ return result;
+}
+
+int LinesManager::Scolision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6) {
+ int v6;
+ int16 *v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int16 *v13;
+ int result;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+
+ v24 = a5;
+ v6 = a5;
+ if (a5 >= a6 + 1) {
+LABEL_47:
+ result = 0;
+ } else {
+ v22 = a1 + 10;
+ v21 = a1 - 10;
+ v20 = a2 + 10;
+ v19 = a2 - 10;
+ for (;;) {
+ v7 = Ligne[v6].lineData;
+
+ if (v7 != (int16 *)g_PTRNUL) {
+ v23 = 1;
+ v8 = 2 * Ligne[v6].field0;
+ v9 = v7[0];
+ v15 = v7[1];
+ v10 = v7[v8 - 2];
+ v17 = v7[v8 - 1];
+ if (v7[0] >= v10)
+ goto LABEL_50;
+ if (v22 < v9 || v21 > v10)
+ v23 = 0;
+ if (v9 >= v10) {
+LABEL_50:
+ if (v21 > v9 || v22 < v10)
+ v23 = 0;
+ }
+ if (v15 >= v17)
+ goto LABEL_51;
+ if (v20 < v15 || v19 > v17)
+ v23 = 0;
+ if (v15 >= v17) {
+LABEL_51:
+ if (v19 > v15 || v20 < v17)
+ v23 = 0;
+ }
+ if (v23 == 1) {
+ v11 = 0;
+ v18 = Ligne[v24].field0;
+ if (v18 > 0)
+ break;
+ }
+ }
+LABEL_46:
+ ++v24;
+ v6 = v24;
+ if (v24 >= a6 + 1)
+ goto LABEL_47;
+ }
+ while (1) {
+ v12 = v7[0];
+ v13 = v7 + 1;
+ v16 = v13[0];
+ v7 = v13 + 1;
+ if (a1 == v12
+ || v12 == a1 + 1
+ || v12 == a1 + 2
+ || v12 == a1 + 3
+ || v12 == a1 + 4
+ || v12 == a1 + 5
+ || v12 == a1 + 6
+ || v12 == a1 + 7
+ || v12 == a1 + 8
+ || v12 == a1 + 9
+ || a1 + 10 == v12) {
+ if (v16 == a2
+ || v16 == a2 + 1
+ || v16 == a2 + 2
+ || v16 == a2 + 3
+ || v16 == a2 + 4
+ || v16 == a2 + 5
+ || v16 == a2 + 6
+ || v16 == a2 + 7
+ || v16 == a2 + 8
+ || v16 == a2 + 9
+ || a2 + 10 == v16)
+ break;
+ }
+ ++v11;
+ if (v18 <= v11)
+ goto LABEL_46;
+ }
+ *a3 = v11;
+ *a4 = v24;
+ result = 1;
+ }
+ return result;
+}
+
+// Init route
+void LinesManager::INIPARCOURS() {
+ int v0;
+ int v1;
+ int v2;
+ int16 *v3;
+ int v4;
+ int v5;
+ int v6;
+ int16 *v7;
+ int v8;
+ int v9;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+
+ v15 = Ligne[0].lineData[0];
+ v14 = Ligne[0].lineData[1];
+
+ v0 = 1;
+ v1 = 0;
+ do {
+ v2 = Ligne[v0].field0;
+ v3 = Ligne[v0].lineData;
+
+ v4 = v3[2 * v2 - 2];
+ v5 = v3[2 * v2 - 1];
+ if (_vm->_graphicsManager.max_x == v4 || _vm->_graphicsManager.max_y == v5 || _vm->_graphicsManager.min_x == v4
+ || _vm->_graphicsManager.min_y == v5)
+ v1 = 1;
+ if (v15 == v4 && v14 == v5)
+ v1 = 1;
+ if (v0 == 400) {
+ v6 = v1;
+ error("ERROR - LAST LINE NOT FOUND");
+ v1 = v6;
+ }
+ v7 = Ligne[v0 + 1].lineData;
+ if (v7[0] != v4 && v7[1] != v5)
+ v1 = 1;
+ if (!v1)
+ ++v0;
+ } while (v1 != 1);
+
+ _vm->_objectsManager.DERLIGNE = v0;
+ v8 = 1;
+ v13 = _vm->_globals.Max_Ligne_Long;
+ v9 = _vm->_objectsManager.DERLIGNE + 1;
+ do {
+ v11 = v8;
+ if (Ligne[v11].field0 < v13) {
+ if (v8 != v9) {
+ v12 = v8 - 1;
+ Ligne[v11].field6 = Ligne[v12].field6;
+ Ligne[v11].field8 = Ligne[v12].field8;
+ }
+ }
+ ++v8;
+ } while (v8 != 400);
+}
+
+// Avoid
+int LinesManager::CONTOURNE(int a1, int a2, int a3, int a4, int a5, int16 *a6, int a7) {
+ int v7;
+ int v8;
+ int i;
+ int16 *v10;
+ int v11;
+ int v12;
+ int v13;
+ int16 *v14;
+ int v15;
+ int v16;
+ int j;
+ int16 *v18;
+ int v19;
+ int v20;
+ int k;
+ int16 *v22;
+ int v23;
+ int v24;
+ int v25;
+ int16 *v26;
+ int v27;
+ int v28;
+ int v29;
+ int16 *v30;
+ int v31;
+ int v32;
+ int v34;
+ int v35;
+ int v36;
+ int v50;
+
+ v36 = a1;
+ v7 = a2;
+ v8 = a3;
+ if (a1 < a4) {
+ for (i = a2; Ligne[a1].field0 > i; ++i) {
+ v10 = Ligne[a1].lineData;
+ v11 = v10[2 * i];
+ v50 = v10[2 * i + 1];
+
+ v12 = v8;
+ a6[v12] = v11;
+ a6[v12 + 1] = v50;
+ a6[v12 + 2] = Ligne[a1].field6;
+ v8 += a7;
+ }
+ v34 = a1 + 1;
+ if ((int)(a1 + 1) < a4) {
+ do {
+ v13 = 0;
+ if (Ligne[v34].field0 > 0) {
+ do {
+ v14 = Ligne[v34].lineData;
+ v15 = v14[2 * v13];
+ v50 = v14[2 * v13 + 1];
+ v16 = v8;
+
+ a6[v16] = v15;
+ a6[v16 + 1] = v50;
+ a6[v16 + 2] = Ligne[v34].field6;
+ v8 += a7;
+ ++v13;
+ } while (Ligne[v34].field0 > v13);
+ }
+ ++v34;
+ } while (v34 < a4);
+ }
+ v7 = 0;
+ v36 = a4;
+ }
+ if (v36 > a4) {
+ for (j = v7; j > 0; --j) {
+ v18 = Ligne[v36].lineData;
+ v19 = v18[2 * j];
+ v50 = v18[2 * j + 1];
+
+ v20 = v8;
+ a6[v20] = v19;
+ a6[v20 + 1] = v50;
+ a6[v20 + 2] = Ligne[v36].field8;
+ v8 += a7;
+ }
+ v35 = v36 - 1;
+ if ((int)(v36 - 1) > a4) {
+ do {
+ for (k = Ligne[v35].field0 - 1; k > 0; --k) {
+ v22 = Ligne[v35].lineData;
+ v23 = v22[2 * k];
+ v50 = v22[2 * k + 1];
+
+ v24 = v8;
+ a6[v24] = v23;
+ a6[v24 + 1] = v50;
+ a6[v24 + 2] = Ligne[v35].field8;
+ v8 += a7;
+ }
+ --v35;
+ } while (v35 > a4);
+ }
+ v7 = Ligne[a4].field0 - 1;
+ v36 = a4;
+ }
+ if (v36 == a4) {
+ if (a5 >= v7) {
+ if (a5 > v7) {
+ v29 = v7;
+ do {
+ v30 = Ligne[a4].lineData;
+ v31 = v30[2 * v29];
+ v50 = v30[2 * v29 + 1];
+
+ v32 = v8;
+ a6[v32] = v31;
+ a6[v32 + 1] = v50;
+ a6[v32 + 2] = Ligne[a4].field6;
+ v8 += a7;
+ ++v29;
+ } while (a5 > v29);
+ }
+ } else {
+ v25 = v7;
+ do {
+ v26 = Ligne[a4].lineData;
+ v27 = v26[2 * v25];
+ v50 = v26[2 * v25 + 1];
+
+ v28 = v8;
+ a6[v28] = v27;
+ a6[v28 + 1] = v50;
+ a6[v28 + 2] = Ligne[a4].field8;
+ v8 += a7;
+ --v25;
+ } while (a5 < v25);
+ }
+ }
+ return v8;
+}
+
+// Avoid 1
+int LinesManager::CONTOURNE1(int a1, int a2, int a3, int a4, int a5, int16 *a6, int a7, int a8, int a9) {
+ int v9;
+ int v10;
+ int i;
+ int16 *v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int16 *v17;
+ int v18;
+ int v19;
+ int j;
+ int16 *v21;
+ int v22;
+ int v23;
+ int v24;
+ int k;
+ int16 *v26;
+ int v27;
+ int v28;
+ int v29;
+ int16 *v30;
+ int v31;
+ int v32;
+ int v33;
+ int16 *v34;
+ int v35;
+ int v36;
+ int v38;
+ int v39;
+ int v40;
+ int v50;
+
+ v9 = a1;
+ v10 = a2;
+ v40 = a3;
+ if (a4 < a1) {
+ for (i = a2; Ligne[a1].field0 > i; ++i) {
+ v12 = Ligne[a1].lineData;
+ v13 = v12[2 * i];
+ v50 = v12[2 * i + 1];
+
+ v14 = v40;
+ a6[v14] = v13;
+ a6[v14 + 1] = v50;
+ a6[v14 + 2] = Ligne[a1].field6;
+ v40 += a7;
+ }
+ v15 = a1 + 1;
+ if ((int)(a1 + 1) == a9 + 1)
+ v15 = a8;
+ while (a4 != v15) {
+ v16 = 0;
+ if (Ligne[v15].field0 > 0) {
+ do {
+ v17 = Ligne[v15].lineData;
+ v18 = v17[2 * v16];
+ v50 = v17[2 * v16 + 1];
+
+ v19 = v40;
+ a6[v19] = v18;
+ a6[v19 + 1] = v50;
+ a6[v19 + 2] = Ligne[v15].field6;
+ v40 += a7;
+ ++v16;
+ } while (Ligne[v15].field0 > v16);
+ }
+ ++v15;
+ if (a9 + 1 == v15)
+ v15 = a8;
+ }
+ v10 = 0;
+ v9 = a4;
+ }
+ if (a4 > v9) {
+ for (j = v10; j > 0; --j) {
+ v21 = Ligne[v9].lineData;
+ v22 = v21[2 * j];
+ v50 = v21[2 * j + 1];
+
+ v23 = v40;
+ a6[v23] = v22;
+ a6[v23 + 1] = v50;
+ a6[v23 + 2] = Ligne[v9].field8;
+ v40 += a7;
+ }
+ v24 = v9 - 1;
+ if (v24 == a8 - 1)
+ v24 = a9;
+ while (a4 != v24) {
+ for (k = Ligne[v24].field0 - 1; k > 0; --k) {
+ v26 = Ligne[v24].lineData;
+ v27 = v26[2 * k];
+ v50 = v26[2 * k + 1];
+
+ v28 = v40;
+ a6[v28] = v27;
+ a6[v28 + 1] = v50;
+ a6[v28 + 2] = Ligne[v24].field8;
+ v40 += a7;
+ }
+ --v24;
+ if (a8 - 1 == v24)
+ v24 = a9;
+ }
+ v10 = Ligne[a4].field0 - 1;
+ v9 = a4;
+ }
+ if (a4 == v9) {
+ if (a5 >= v10) {
+ if (a5 > v10) {
+ v33 = v10;
+ v39 = a4;
+ do {
+ v34 = Ligne[v39].lineData;
+ v35 = v34[2 * v33];
+ v50 = v34[2 * v33 + 1];
+
+ v36 = v40;
+ a6[v36] = v35;
+ a6[v36 + 1] = v50;
+ a6[v36 + 2] = Ligne[v39].field6;
+ v40 += a7;
+ ++v33;
+ } while (a5 > v33);
+ }
+ } else {
+ v29 = v10;
+ v38 = a4;
+ do {
+ v30 = Ligne[v38].lineData;
+ v31 = v30[2 * v29];
+ v50 = v30[2 * v29 + 1];
+
+ v32 = v40;
+ a6[v32] = v31;
+ a6[v32 + 1] = v50;
+ a6[v32 + 2] = Ligne[v38].field8;
+ v40 += a7;
+ --v29;
+ } while (a5 < v29);
+ }
+ }
+ return v40;
+}
+
+int LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int i;
+ int v12;
+ int v13;
+ int j;
+ int v15;
+ int v16;
+ int k;
+ int v18;
+ int v19;
+ int l;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33;
+ int v35 = 0;
+ int v36 = 0;
+ int v37;
+ int v38;
+ int v39;
+ int v40;
+ int v41;
+ int v42 = 0;
+ int v43 = 0;
+ int v44 = 0;
+ int v45 = 0;
+ int v46 = 0;
+ int v47 = 0;
+ int v48 = 0;
+ int v49 = 0;
+ int v50;
+ int v51;
+
+ v5 = a1;
+ v6 = a2;
+ v50 = a3;
+ v7 = a5;
+ if (colision2_ligne(a1, a2, &v51, &v50, 0, TOTAL_LIGNES) == 1) {
+ v8 = Ligne[v50].field4;
+ if (v8 == 1)
+ v6 = a2 - 2;
+ if (v8 == 2) {
+ v6 -= 2;
+ v5 = a1 + 2;
+ }
+ if (v8 == 3)
+ v5 += 2;
+ if (v8 == 4) {
+ v6 += 2;
+ v5 += 2;
+ }
+ if (v8 == 5)
+ v6 += 2;
+ if (v8 == 6) {
+ v6 += 2;
+ v5 -= 2;
+ }
+ if (v8 == 7)
+ v5 -= 2;
+ if (v8 == 8) {
+ v6 -= 2;
+ v5 -= 2;
+ }
+ }
+ v41 = v5;
+ v40 = v6;
+ v9 = 0;
+ v10 = v40;
+ for (i = v40; v40 + 200 > v10; i = v10) {
+ if (colision2_ligne(v41, i, &v49, &v48, 0, _vm->_objectsManager.DERLIGNE) == 1 && v48 <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v49 = 0;
+ v48 = -1;
+ ++v9;
+ ++v10;
+ }
+ v37 = v9;
+ v12 = 0;
+ v13 = v40;
+ for (j = v40; v40 - 200 < v13; j = v13) {
+ if (colision2_ligne(v41, j, &v47, &v46, 0, _vm->_objectsManager.DERLIGNE) == 1 && v46 <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v47 = 0;
+ v46 = -1;
+ ++v12;
+ --v13;
+ }
+ v39 = v12;
+ v15 = 0;
+ v16 = v41;
+ for (k = v41; v41 + 200 > v16; k = v16) {
+ if (colision2_ligne(k, v40, &v45, &v44, 0, _vm->_objectsManager.DERLIGNE) == 1 && v44 <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v45 = 0;
+ v44 = -1;
+ ++v15;
+ ++v16;
+ }
+ v38 = v15;
+ v18 = 0;
+ v19 = v41;
+ for (l = v41; v41 - 200 < v19; l = v19) {
+ if (colision2_ligne(l, v40, &v43, &v42, 0, _vm->_objectsManager.DERLIGNE) == 1 && v42 <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v43 = 0;
+ v42 = -1;
+ ++v18;
+ --v19;
+ }
+ if (a4 > v50) {
+ if (v46 != -1 && v46 <= v50)
+ v46 = -1;
+ if (v44 != -1 && v50 >= v44)
+ v44 = -1;
+ if (v48 != -1 && v50 >= v48)
+ v48 = -1;
+ if (v42 != -1 && v50 >= v42)
+ v42 = -1;
+ if (v46 != -1 && a4 < v46)
+ v46 = -1;
+ if (v44 != -1 && a4 < v44)
+ v44 = -1;
+ if (v48 != -1 && a4 < v48)
+ v48 = -1;
+ if (v42 != -1 && a4 < v42)
+ v42 = -1;
+ }
+ if (a4 < v50) {
+ if (v46 != -1 && v46 >= v50)
+ v46 = -1;
+ if (v44 != -1 && v50 <= v44)
+ v44 = -1;
+ if (v48 != -1 && v50 <= v48)
+ v48 = -1;
+ if (v42 != -1 && v50 <= v42)
+ v42 = -1;
+ if (v46 != -1 && a4 > v46)
+ v46 = -1;
+ if (v44 != -1 && a4 > v44)
+ v44 = -1;
+ if (v48 != -1 && a4 > v48)
+ v48 = -1;
+ if (v42 != -1 && a4 > v42)
+ v42 = -1;
+ }
+ if (v46 != -1 || v44 != -1 || v48 != -1 || v42 != -1) {
+ v21 = 0;
+ if (a4 > v50) {
+ if (v48 <= v46 && v44 <= v46 && v42 <= v46 && v46 > v50)
+ v21 = 1;
+ if (v48 <= v44 && v46 <= v44 && v42 <= v44 && v50 < v44)
+ v21 = 3;
+ if (v46 <= v48 && v44 <= v48 && v42 <= v48 && v50 < v48)
+ v21 = 5;
+ if (v48 <= v42 && v44 <= v42 && v46 <= v42 && v50 < v42)
+ v21 = 7;
+ }
+ if (a4 < v50) {
+ if (v46 == -1)
+ v46 = 1300;
+ if (v44 == -1)
+ v44 = 1300;
+ if (v48 == -1)
+ v48 = 1300;
+ if (v42 == -1)
+ v42 = 1300;
+ if (v46 != 1300 && v48 >= v46 && v44 >= v46 && v42 >= v46 && v46 < v50)
+ v21 = 1;
+ if (v44 != 1300 && v48 >= v44 && v46 >= v44 && v42 >= v44 && v50 > v44)
+ v21 = 3;
+ if (v48 != 1300 && v46 >= v48 && v44 >= v48 && v42 >= v48 && v50 > v48)
+ v21 = 5;
+ if (v42 != 1300 && v48 >= v42 && v44 >= v42 && v46 >= v42 && v50 > v42)
+ v21 = 7;
+ }
+ if (v21) {
+ if (v21 == 1) {
+ v36 = v46;
+ v35 = v47;
+ }
+ if (v21 == 3) {
+ v36 = v44;
+ v35 = v45;
+ }
+ if (v21 == 5) {
+ v36 = v48;
+ v35 = v49;
+ }
+ if (v21 == 7) {
+ v36 = v42;
+ v35 = v43;
+ }
+ if (v21 == 1) {
+ v22 = 0;
+ if (v39 > 0) {
+ do {
+ if (colision2_ligne(v41, v40 - v22, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v46) {
+ v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &_vm->_globals.super_parcours[0], 4);
+ if (v23 == -1)
+ return 0;
+ v7 = v23;
+ if (NVPY != -1)
+ v22 = NVPY - v40;
+ }
+ v24 = v7;
+ _vm->_globals.super_parcours[v24] = v41;
+ _vm->_globals.super_parcours[v24 + 1] = v40 - v22;
+ _vm->_globals.super_parcours[v24 + 2] = 1;
+ _vm->_globals.super_parcours[v24 + 3] = 0;
+ v7 += 4;
+ ++v22;
+ } while (v39 > v22);
+ }
+LABEL_186:
+ NV_LIGNEDEP = v36;
+ NV_LIGNEOFS = v35;
+ NV_POSI = v7;
+ return 1;
+ }
+ if (v21 == 5) {
+ v25 = 0;
+ if (v37 > 0) {
+ do {
+ if (colision2_ligne(v41, v25 + v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v46) {
+ v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &_vm->_globals.super_parcours[0], 4);
+ if (v26 == -1)
+ return 0;
+ v7 = v26;
+ if (NVPY != -1)
+ v25 = v40 - NVPY;
+ }
+ v27 = v7;
+ _vm->_globals.super_parcours[v27] = v41;
+ _vm->_globals.super_parcours[v27 + 1] = v25 + v40;
+ _vm->_globals.super_parcours[v27 + 2] = 5;
+ _vm->_globals.super_parcours[v27 + 3] = 0;
+ v7 += 4;
+ ++v25;
+ } while (v37 > v25);
+ }
+ goto LABEL_186;
+ }
+ if (v21 == 7) {
+ v28 = 0;
+ if (v18 > 0) {
+ do {
+ if (colision2_ligne(v41 - v28, v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v46) {
+ v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &_vm->_globals.super_parcours[0], 4);
+ if (v29 == -1)
+ return 0;
+ v7 = v29;
+ if (NVPX != -1)
+ v28 = v41 - NVPX;
+ }
+ v30 = v7;
+ _vm->_globals.super_parcours[v30] = v41 - v28;
+ _vm->_globals.super_parcours[v30 + 1] = v40;
+ _vm->_globals.super_parcours[v30 + 2] = 7;
+ _vm->_globals.super_parcours[v30 + 3] = 0;
+ v7 += 4;
+ ++v28;
+ } while (v18 > v28);
+ }
+ goto LABEL_186;
+ }
+ if (v21 == 3) {
+ v31 = 0;
+ if (v38 > 0) {
+ do {
+ if (colision2_ligne(v31 + v41, v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v46) {
+ v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &_vm->_globals.super_parcours[0], 4);
+ if (v32 == -1)
+ return 0;
+ v7 = v32;
+ if (NVPX != -1)
+ v31 = NVPX - v41;
+ }
+ v33 = v7;
+ _vm->_globals.super_parcours[v33] = v31 + v41;
+ _vm->_globals.super_parcours[v33 + 1] = v40;
+ _vm->_globals.super_parcours[v33 + 2] = 3;
+ _vm->_globals.super_parcours[v33 + 3] = 0;
+ v7 += 4;
+ ++v31;
+ } while (v38 > v31);
+ }
+ goto LABEL_186;
+ }
+ }
+ }
+ return 0;
+}
+
+int LinesManager::GENIAL(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int16 *a8, int a9) {
+ int v9;
+ int16 *v10;
+ int v11;
+ int16 *v12;
+ int16 *v13;
+ int v14;
+ int v15;
+ int16 *v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int16 *v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33;
+ int v34;
+ int v35 = 0;
+ int v36 = 0;
+ int v37;
+ int v38;
+ int v40;
+ int v41;
+ int v42 = 0;
+ int v43 = 0;
+ int v44 = 0;
+ int v45 = 0;
+ int v46 = 0;
+ int v47 = 0;
+ int v48 = 0;
+ int v49 = 0;
+ int v50;
+ int16 *v51;
+ int v52;
+ int v53;
+ int v54;
+ int v55;
+ int v56;
+ int v57;
+ int v58;
+ int v59;
+ int v60;
+ int v61;
+ int v62;
+ int v63;
+ int v64;
+ int v65;
+ int v66 = 0;
+ int v67;
+ int v68 = 0;
+ int v69;
+ int v70 = 0;
+ int v71;
+ int v72 = 0;
+ int v73;
+ int v74;
+ int v75;
+ int v76;
+ int v77 = 0;
+ int v78 = 0;
+ int v79 = 0;
+ int v80;
+ int v81;
+ int v82;
+ int v83;
+ int v84;
+ int v85;
+ int v86;
+ int v87;
+ int v88;
+ int v89;
+ int i;
+ int v91;
+ int v92;
+ int v93;
+ int v94;
+ int v95;
+ int v96;
+ int v97;
+ int v98;
+ int v99;
+ int v100;
+ int v101;
+
+ v99 = a7;
+ v80 = -1;
+ ++_vm->_globals.STOP_BUG;
+ if (_vm->_globals.STOP_BUG > 10) {
+ v9 = a7;
+LABEL_112:
+ a8[v9] = -1;
+ a8[v9 + 1] = -1;
+ a8[v9 + 2] = -1;
+ return -1;
+ }
+ v10 = Ligne[a1].lineData;
+ v98 = v10[0];
+ v97 = v10[1];
+ v92 = a1;
+
+ while (1) {
+ v86 = v92 - 1;
+ v11 = 2 * Ligne[v92 - 1].field0;
+
+ v12 = Ligne[v92 - 1].lineData;
+ if (v12 == (int16 *)g_PTRNUL)
+ break;
+ while (v12[v11 - 2] != v98 || v97 != v12[v11 - 1]) {
+ --v86;
+ if (_vm->_objectsManager.DERLIGNE - 1 != v86) {
+ v11 = 2 * Ligne[v86].field0;
+ v12 = Ligne[v86].lineData;
+ if (v12 != (int16 *)g_PTRNUL)
+ continue;
+ }
+ goto LABEL_11;
+ }
+
+ v92 = v86;
+ v98 = v12[0];
+ v97 = v12[1];
+ }
+LABEL_11:
+ v13 = Ligne[a1].lineData;
+ v14 = 2 * Ligne[a1].field0;
+ v95 = v13[v14 - 2];
+ v93 = v13[v14 - 1];
+ v91 = a1;
+
+ for (;;) {
+ v87 = v91 + 1;
+ v15 = 2 * Ligne[v91 + 1].field0;
+ v16 = Ligne[v91 + 1].lineData;
+ if (v16 == (int16 *)g_PTRNUL)
+ break;
+ while (1) {
+ v65 = v15;
+ v17 = v16[v15 - 2];
+ if (v16[0] == v95) {
+ if (v93 == v16[1])
+ break;
+ }
+ ++v87;
+ if (v87 != TOTAL_LIGNES + 1) {
+ v15 = 2 * Ligne[v87].field0;
+ v16 = Ligne[v87].lineData;
+ if (v16 != (int16 *)g_PTRNUL)
+ continue;
+ }
+ goto LABEL_17;
+ }
+ v91 = v87;
+ v95 = v17;
+ v93 = v16[v65 - 1];
+ }
+LABEL_17:
+ v18 = a3 - a5;
+ if (a3 - a5 < 0)
+ v18 = -v18;
+ v58 = v18 + 1;
+ v19 = a4 - a6;
+ if (a4 - a6 < 0)
+ v19 = -v19;
+ v85 = v19 + 1;
+ v20 = v19 + 1;
+ if (v58 > v20)
+ v85 = v18 + 1;
+ v84 = 1000 * v58 / v85;
+ v83 = 1000 * v20 / v85;
+ v21 = 1000 * a3;
+ v22 = 1000 * a4;
+ v82 = v21 / 1000;
+ v81 = v22 / 1000;
+ if (a5 < a3)
+ v84 = -v84;
+ if (a6 < a4)
+ v83 = -v83;
+ if (v85 > 800)
+ v85 = 800;
+
+ Common::fill(&_vm->_globals.BufLig[0], &_vm->_globals.BufLig[1000], 0);
+ v23 = 0;
+ v88 = 0;
+ if (v85 + 1 > 0) {
+ v51 = _vm->_globals.BufLig;
+ do {
+ v24 = v23;
+ v51[v24] = v82;
+ v51[v24 + 1] = v81;
+ v21 += v84;
+ v22 += v83;
+ v82 = v21 / 1000;
+ v81 = v22 / 1000;
+ v23 += 2;
+ ++v88;
+ } while (v88 < v85 + 1);
+ }
+ v25 = v23 - 2;
+ v26 = 0;
+ v89 = v85 + 1;
+ if ((int)(v85 + 1) > 0) {
+ do {
+ v96 = _vm->_globals.BufLig[v25];
+ v94 = _vm->_globals.BufLig[v25 + 1];
+ if (colision2_ligne(v96, v94, &v101, &v100, v92, v91) == 1 && _vm->_objectsManager.DERLIGNE < v100) {
+ v80 = v100;
+ v77 = v101;
+ v78 = v96;
+ v79 = v94;
+ v26 = 1;
+ }
+ if (v26 == 1)
+ break;
+ v25 -= 2;
+ --v89;
+ } while (v89 > 0);
+ }
+ for (i = v92; i < v91 + 1; ++i) {
+ v27 = 2 * Ligne[i].field0;
+ v28 = Ligne[i].lineData;
+ if (v28 == (int16 *)g_PTRNUL)
+ error("error in genial routine");
+ v29 = v28[0];
+ v30 = v28[1];
+ v59 = v28[1];
+ v31 = v27;
+ v32 = v28[v27 - 2];
+ v33 = v28[v31 - 1];
+ if (i == v92) {
+ v72 = v33;
+ if (v30 <= v33)
+ v72 = v30;
+ v70 = v33;
+ if (v59 >= v33)
+ v70 = v59;
+ v68 = v32;
+ if (v29 <= v32)
+ v68 = v29;
+ v66 = v32;
+ if (v29 >= v32)
+ v66 = v29;
+ } else {
+ if (v59 < v33 && v59 < v72)
+ v72 = v59;
+ if (v33 < v59 && v33 < v72)
+ v72 = v33;
+ if (v59 > v33 && v59 > v70)
+ v70 = v59;
+ if (v33 > v59 && v33 > v70)
+ v70 = v33;
+ if (v29 < v32 && v68 > v29)
+ v68 = v29;
+ if (v32 < v29 && v68 > v32)
+ v68 = v32;
+ if (v29 > v32 && v66 < v29)
+ v66 = v29;
+ if (v32 > v29 && v66 < v32)
+ v66 = v32;
+ }
+ }
+ v69 = v68 - 2;
+ v73 = v72 - 2;
+ v67 = v66 + 2;
+ v71 = v70 + 2;
+ if (a5 >= v69 && a5 <= v67 && a6 >= v73 && a6 <= v71) {
+ v34 = a6;
+ v76 = -1;
+ do {
+ --v34;
+ v60 = colision2_ligne(a5, v34, &v101, &v100, v92, v91);
+ if (v60 == 1)
+ v76 = v100;
+ if (!v34 || v73 > v34)
+ v60 = 1;
+ } while (v60 != 1);
+ v35 = a6;
+ v75 = -1;
+ do {
+ ++v35;
+ v61 = colision2_ligne(a5, v35, &v101, &v100, v92, v91);
+ if (v61 == 1)
+ v75 = v100;
+ if (_vm->_globals.Max_Perso_Y <= v35 || v71 <= v35)
+ v61 = 1;
+ } while (v61 != 1);
+ v36 = a5;
+ v74 = -1;
+ do {
+ ++v36;
+ v62 = colision2_ligne(v36, a6, &v101, &v100, v92, v91);
+ if (v62 == 1)
+ v74 = v100;
+ if (_vm->_graphicsManager.max_x <= v36 || v67 <= v36)
+ v62 = 1;
+ } while (v62 != 1);
+ v37 = a5;
+ v38 = -1;
+ do {
+ --v37;
+ v63 = colision2_ligne(v37, a6, &v101, &v100, v92, v91);
+ if (v63 == 1)
+ v38 = v100;
+ if (v37 <= 0 || v69 >= v37)
+ v63 = 1;
+ } while (v63 != 1);
+ if (v74 != -1 && v38 != -1 && v76 != -1 && v75 != -1) {
+ v9 = a7;
+ goto LABEL_112;
+ }
+ }
+ if (v78 < a3 - 1 || v78 > a3 + 1 || v79 < a4 - 1 || v79 > a4 + 1) {
+ NVPX = v78;
+ NVPY = v79;
+ if (a1 < v80) {
+ v40 = v80 - a1;
+ if (v80 - a1 < 0)
+ v40 = -v40;
+ v41 = v40;
+ v42 = a1;
+ v43 = 0;
+ v52 = v92 - 1;
+ do {
+ if (v52 == v42)
+ v42 = v91;
+ ++v43;
+ --v42;
+ if (v52 == v42)
+ v42 = v91;
+ } while (v80 != v42);
+ if (v41 == v43) {
+ v44 = Ligne[a1].field0 / 2;
+ v54 = Ligne[a1].field0 / 2;
+ if (v44 < 0)
+ v54 = -v44;
+ if (a2 > v54) {
+ v55 = Ligne[a1].field0 / 2;
+ if (v44 < 0)
+ v55 = -v44;
+ if (a2 >= v55)
+ v99 = CONTOURNE(a1, a2, a7, v80, v77, a8, a9);
+ } else {
+ v99 = CONTOURNE1(a1, a2, a7, v80, v77, a8, a9, v92, v91);
+ }
+ }
+ if (v41 < v43)
+ v99 = CONTOURNE(a1, a2, v99, v80, v77, a8, a9);
+ if (v43 < v41)
+ v99 = CONTOURNE1(a1, a2, v99, v80, v77, a8, a9, v92, v91);
+ }
+ if (a1 > v80) {
+ v45 = a1 - v80;
+ if (a1 - v80 < 0)
+ v45 = -v45;
+ v46 = v45;
+ v47 = a1;
+ v48 = 0;
+ v53 = v91 + 1;
+ do {
+ if (v53 == v47)
+ v47 = v92;
+ ++v48;
+ ++v47;
+ if (v53 == v47)
+ v47 = v92;
+ } while (v80 != v47);
+ if (v46 == v48) {
+ v49 = Ligne[a1].field0 / 2;
+ v56 = Ligne[a1].field0 / 2;
+ if (v49 < 0)
+ v56 = -v49;
+ if (a2 > v56) {
+ v57 = Ligne[a1].field0 / 2;
+ if (v49 < 0)
+ v57 = -v49;
+ if (a2 >= v57)
+ v99 = CONTOURNE1(a1, a2, v99, v80, v77, a8, a9, v92, v91);
+ } else {
+ v99 = CONTOURNE(a1, a2, v99, v80, v77, a8, a9);
+ }
+ }
+ if (v46 < v48)
+ v99 = CONTOURNE(a1, a2, v99, v80, v77, a8, a9);
+ if (v48 < v46)
+ v99 = CONTOURNE1(a1, a2, v99, v80, v77, a8, a9, v92, v91);
+ }
+ if (a1 == v80)
+ v99 = CONTOURNE(a1, a2, v99, a1, v77, a8, a9);
+ do {
+ v64 = colision2_ligne(NVPX, NVPY, &v101, &v100, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES);
+ if (v64 == 1) {
+ v50 = v100;
+ if (Ligne[v50].field4 == 1)
+ --NVPY;
+ if (Ligne[v50].field4 == 2) {
+ --NVPY;
+ ++NVPX;
+ }
+ if (Ligne[v50].field4 == 3)
+ ++NVPX;
+ if (Ligne[v50].field4 == 4) {
+ ++NVPY;
+ ++NVPX;
+ }
+ if (Ligne[v50].field4 == 5)
+ ++NVPY;
+ if (Ligne[v50].field4 == 6) {
+ ++NVPY;
+ --NVPX;
+ }
+ if (Ligne[v50].field4 == 7)
+ --NVPX;
+ if (Ligne[v50].field4 == 8) {
+ --NVPY;
+ --NVPX;
+ }
+ }
+ } while (v64);
+ } else {
+ NVPX = -1;
+ NVPY = -1;
+ }
+ return v99;
+}
+
+// Avoid 2
+int16 *LinesManager::PARCOURS2(int a1, int a2, int destX, int destY) {
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+ int v29;
+ int v31;
+ int v32;
+ int v33;
+ int v34;
+ int v35;
+ int v36;
+ int v37;
+ int v38;
+ int v39;
+ int v40;
+ int v41;
+ int v42;
+ int v43;
+ int v44;
+ int v45;
+ int v46;
+ int v47;
+ int v48;
+ int v49;
+ int v50;
+ int v51;
+ int v52;
+ int v53;
+ int v54;
+ int v55;
+ int v56;
+ int v57;
+ int v58;
+ int v59;
+ int v60;
+ int v61;
+ int v62;
+ int v63;
+ int v64;
+ int v65;
+ int v66;
+ int v67;
+ int v68;
+ int i;
+ int16 *v70;
+ int v71;
+ int v72;
+ int j;
+ int16 *v74;
+ int v75;
+ int v76;
+ int v77;
+ int v78;
+ int v79;
+ int v80;
+ int16 *v81;
+ int v82;
+ int v83;
+ int16 *v84;
+ int v85;
+ int v86;
+ int v87;
+ int v88;
+ int v89;
+ int v90;
+ int16 *v91;
+ int v92;
+ int v93;
+ int v94;
+ int16 *v95;
+ int v96;
+ int v97;
+ int v98;
+ int v99;
+ int v100;
+ int v101;
+ int v102;
+ int v103;
+ int v104;
+ int v105;
+ int v106;
+ int v107;
+ int v108;
+ int v109;
+ int v110;
+ int v111;
+ int v112;
+ int v113;
+ int v114;
+ int v115;
+ int v116;
+ int v117;
+ int v118 = 0;
+ int v119 = 0;
+ int v120;
+ int v121;
+ int v122;
+ int v123;
+ int v124;
+ int v125;
+ int v126[10];
+ int v131[10];
+ int v136[10];
+ int v141[10];
+
+ v123 = destX;
+ v122 = destY;
+ v121 = 0;
+ v120 = 0;
+ v115 = 0;
+ v114 = 0;
+ v113 = 0;
+ v111 = 0;
+ if (destY <= 24)
+ v122 = 25;
+ if (!_vm->_globals.NOT_VERIF) {
+ v4 = a1 - _vm->_globals.old_x1_65;
+ if (v4 < 0)
+ v4 = -v4;
+ if (v4 <= 4) {
+ v5 = a2 - _vm->_globals.old_y1_66;
+ if (v5 < 0)
+ v5 = -v5;
+ if (v5 <= 4) {
+ v6 = _vm->_globals.old_x2_67 - destX;
+ if (v6 < 0)
+ v6 = -v6;
+ if (v6 <= 4) {
+ v7 = _vm->_globals.old_y2_68 - v122;
+ if (v7 < 0)
+ v7 = -v7;
+ if (v7 <= 4)
+ return (int16 *)g_PTRNUL;
+ }
+ }
+ }
+ v8 = a1 - destX;
+ if (v8 < 0)
+ v8 = -v8;
+ if (v8 <= 4) {
+ v9 = a2 - v122;
+ if (v9 < 0)
+ v9 = -v9;
+ if (v9 <= 4)
+ return (int16 *)g_PTRNUL;
+ }
+ if (_vm->_globals.old_z_69 > 0 && _vm->_objectsManager.NUMZONE > 0 && _vm->_globals.old_z_69 == _vm->_objectsManager.NUMZONE)
+ return (int16 *)g_PTRNUL;
+ }
+ _vm->_globals.NOT_VERIF = 0;
+ _vm->_globals.old_z_69 = _vm->_objectsManager.NUMZONE;
+ _vm->_globals.old_x1_65 = a1;
+ _vm->_globals.old_x2_67 = destX;
+ _vm->_globals.old_y1_66 = a2;
+ _vm->_globals.old_y2_68 = v122;
+ _vm->_globals.STOP_BUG = 0;
+ v112 = 0;
+ if (destX <= 19)
+ v123 = 20;
+ if (v122 <= 19)
+ v122 = 20;
+ if (v123 > _vm->_graphicsManager.max_x - 10)
+ v123 = _vm->_graphicsManager.max_x - 10;
+ if (v122 > _vm->_globals.Max_Perso_Y)
+ v122 = _vm->_globals.Max_Perso_Y;
+ v10 = a1 - v123;
+ if (v10 < 0)
+ v10 = -v10;
+ if (v10 <= 3) {
+ v11 = a2 - v122;
+ if (v11 < 0)
+ v11 = -v11;
+ if (v11 <= 3)
+ return (int16 *)g_PTRNUL;
+ }
+
+ for (v12 = 0; v12 <= 8; ++v12) {
+ v141[v12] = -1;
+ v136[v12] = 0;
+ v131[v12] = 1300;
+ v126[v12] = 1300;
+ ++v12;
+ }
+
+ if (PARC_PERS(a1, a2, v123, v122, -1, -1, 0) != 1) {
+ v14 = 0;
+ v15 = v122;
+ if (_vm->_graphicsManager.max_y > v122) {
+ v16 = 5;
+ do {
+ v101 = v16;
+ v17 = colision2_ligne(v123, v15, &v136[3], &v141[3], 0, _vm->_objectsManager.DERLIGNE);
+ v16 = v101;
+ if (v17 == 1 && v141[v101] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v101] = 0;
+ v141[v101] = -1;
+ ++v14;
+ ++v15;
+ } while (_vm->_graphicsManager.max_y > v15);
+ }
+ v131[3] = v14;
+ v18 = 0;
+ v19 = v122;
+ if (_vm->_graphicsManager.min_y < v122) {
+ v20 = 1;
+ do {
+ v102 = v20;
+ v21 = colision2_ligne(v123, v19, &v136[1], &v141[1], 0, _vm->_objectsManager.DERLIGNE);
+ v20 = v102;
+ if (v21 == 1 && v141[v102] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v102] = 0;
+ v141[v102] = -1;
+ if (v131[3] < v18) {
+ if (v141[3] != -1)
+ break;
+ }
+ ++v18;
+ --v19;
+ } while (_vm->_graphicsManager.min_y < v19);
+ }
+ v131[1] = v18;
+ v22 = 0;
+ v23 = v123;
+ if (_vm->_graphicsManager.max_x > v123) {
+ v24 = 3;
+ do {
+ v103 = v24;
+ v25 = colision2_ligne(v23, v122, &v136[2], &v141[2], 0, _vm->_objectsManager.DERLIGNE);
+ v24 = v103;
+ if (v25 == 1 && v141[v103] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v103] = 0;
+ v141[v103] = -1;
+ ++v22;
+ if (v131[1] < v22) {
+ if (v141[1] != -1)
+ break;
+ }
+ if (v131[3] < v22 && v141[3] != -1)
+ break;
+ ++v23;
+ } while (_vm->_graphicsManager.max_x > v23);
+ }
+ v131[2] = v22;
+ v26 = 0;
+ v27 = v123;
+ if (_vm->_graphicsManager.min_x < v123) {
+ v28 = 7;
+ do {
+ v104 = v28;
+ v29 = colision2_ligne(v27, v122, &v136[4], &v141[4], 0, _vm->_objectsManager.DERLIGNE);
+ v28 = v104;
+ if (v29 == 1 && v141[v104] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v104] = 0;
+ v141[v104] = -1;
+ ++v26;
+ if (v131[1] < v26) {
+ if (v141[1] != -1)
+ break;
+ }
+ if (v131[3] < v26 && v141[3] != -1)
+ break;
+ if (v131[2] < v26 && v141[2] != -1)
+ break;
+ --v27;
+ } while (_vm->_graphicsManager.min_x < v27);
+ }
+ v131[4] = v26;
+ if (v141[1] < 0 || _vm->_objectsManager.DERLIGNE < v141[1])
+ v141[1] = -1;
+ if (v141[2] < 0 || _vm->_objectsManager.DERLIGNE < v141[2])
+ v141[2] = -1;
+ if (v141[3] < 0 || _vm->_objectsManager.DERLIGNE < v141[3])
+ v141[3] = -1;
+ if (v141[4] < 0 || _vm->_objectsManager.DERLIGNE < v141[4])
+ v141[4] = -1;
+ if (v141[1] < 0)
+ v131[1] = 1300;
+ if (v141[2] < 0)
+ v131[2] = 1300;
+ if (v141[3] < 0)
+ v131[3] = 1300;
+ if (v141[4] < 0)
+ v131[4] = 1300;
+ if (v141[1] == -1 && v141[2] == -1 && v141[3] == -1 && v141[4] == -1)
+ return (int16 *)g_PTRNUL;
+ v31 = 0;
+ if (v141[3] != -1 && v131[1] >= v131[3] && v131[2] >= v131[3] && v131[4] >= v131[3]) {
+ v121 = v141[3];
+ v120 = v136[3];
+ v31 = 1;
+ }
+ if (v141[1] != -1 && !v31 && v131[3] >= v131[1] && v131[2] >= v131[1] && v131[4] >= v131[1]) {
+ v121 = v141[1];
+ v120 = v136[1];
+ v31 = 1;
+ }
+ if (v141[2] != -1 && !v31 && v131[1] >= v131[2] && v131[3] >= v131[2] && v131[4] >= v131[2]) {
+ v121 = v141[2];
+ v120 = v136[2];
+ v31 = 1;
+ }
+ if (v141[4] != -1 && !v31 && v131[3] >= v131[4] && v131[2] >= v131[4] && v131[1] >= v131[4]) {
+ v121 = v141[4];
+ v120 = v136[4];
+ }
+ v32 = 0;
+ do {
+ v33 = v32;
+ v141[v33] = -1;
+ v136[v33] = 0;
+ v131[v33] = 1300;
+ v126[v33] = 1300;
+ ++v32;
+ } while (v32 <= 8);
+
+ v34 = 0;
+ v35 = a2;
+ if (_vm->_graphicsManager.max_y > a2) {
+ v36 = 5;
+ do {
+ v105 = v36;
+ v37 = colision2_ligne(a1, v35, &v136[3], &v141[3], 0, _vm->_objectsManager.DERLIGNE);
+ v36 = v105;
+ if (v37 == 1 && v141[v105] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v105] = 0;
+ v141[v105] = -1;
+ ++v34;
+ ++v35;
+ } while (_vm->_graphicsManager.max_y > v35);
+ }
+ v131[3] = v34 + 1;
+ v38 = 0;
+ v39 = a2;
+ if (_vm->_graphicsManager.min_y < a2) {
+ v40 = 1;
+ do {
+ v106 = v40;
+ v41 = colision2_ligne(a1, v39, &v136[1], &v141[1], 0, _vm->_objectsManager.DERLIGNE);
+ v40 = v106;
+ if (v41 == 1 && v141[v106] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v106] = 0;
+ v141[v106] = -1;
+ ++v38;
+ if (v141[3] != -1) {
+ if (v38 > 80)
+ break;
+ }
+ --v39;
+ } while (_vm->_graphicsManager.min_y < v39);
+ }
+ v131[1] = v38 + 1;
+ v42 = 0;
+ v43 = a1;
+ if (_vm->_graphicsManager.max_x > a1) {
+ v44 = 3;
+ do {
+ v107 = v44;
+ v45 = colision2_ligne(v43, a2, &v136[2], &v141[2], 0, _vm->_objectsManager.DERLIGNE);
+ v44 = v107;
+ if (v45 == 1 && v141[v107] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v107] = 0;
+ v141[v107] = -1;
+ ++v42;
+ if (v141[3] != -1 || v141[1] != -1) {
+ if (v42 > 100)
+ break;
+ }
+ ++v43;
+ } while (_vm->_graphicsManager.max_x > v43);
+ }
+ v131[2] = v42 + 1;
+ v46 = 0;
+ v47 = a1;
+ if (_vm->_graphicsManager.min_x < a1) {
+ v48 = 7;
+ do {
+ v108 = v48;
+ v49 = colision2_ligne(v47, a2, &v136[4], &v141[4], 0, _vm->_objectsManager.DERLIGNE);
+ v48 = v108;
+ if (v49 == 1 && v141[v108] <= _vm->_objectsManager.DERLIGNE)
+ break;
+ v136[v108] = 0;
+ v141[v108] = -1;
+ ++v46;
+ if (v141[3] != -1 || v141[1] != -1 || v141[2] != -1) {
+ if (v46 > 100)
+ break;
+ }
+ --v47;
+ } while (_vm->_graphicsManager.min_x < v47);
+ }
+ v131[4] = v46 + 1;
+ if (v141[1] != -1) {
+ v50 = v141[1] - v121;
+ if (v50 < 0)
+ v50 = -v50;
+ v126[1] = v50;
+ }
+ if (v141[2] != -1) {
+ v51 = v141[2] - v121;
+ if (v51 < 0)
+ v51 = -v51;
+ v126[2] = v51;
+ }
+ if (v141[3] != -1) {
+ v52 = v141[3] - v121;
+ if (v52 < 0)
+ v52 = -v52;
+ v126[3] = v52;
+ }
+ if (v141[4] != -1) {
+ v53 = v141[4] - v121;
+ if (v53 < 0)
+ v53 = -v53;
+ v126[4] = v53;
+ }
+ if (v141[1] == -1 && v141[2] == -1 && v141[3] == -1 && v141[4] == -1)
+ error("ERREUR POINT PLUS PROCHE Du perso NON TROUVE");
+ v54 = 0;
+ if (v141[1] != -1 && v126[2] >= v126[1] && v126[3] >= v126[1] && v126[4] >= v126[1]) {
+ v54 = 1;
+ v115 = v141[1];
+ v111 = v131[1];
+ v113 = 1;
+ v114 = v136[1];
+ }
+ if (!v54) {
+ if (v141[3] != -1 && v126[2] >= v126[3] && v126[1] >= v126[3] && v126[4] >= v126[3]) {
+ v54 = 1;
+ v115 = v141[3];
+ v111 = v131[3];
+ v113 = 5;
+ v114 = v136[3];
+ }
+ if (!v54) {
+ if (v141[2] != -1 && v126[1] >= v126[2] && v126[3] >= v126[2] && v126[4] >= v126[2]) {
+ v54 = 1;
+ v115 = v141[2];
+ v111 = v131[2];
+ v113 = 3;
+ v114 = v136[2];
+ }
+ if (!v54 && v141[4] != -1 && v126[1] >= v126[4] && v126[3] >= v126[4] && v126[2] >= v126[4]) {
+ v115 = v141[4];
+ v111 = v131[4];
+ v113 = 7;
+ v114 = v136[4];
+ }
+ }
+ }
+ v55 = PARC_PERS(a1, a2, v123, v122, v115, v121, 0);
+ if (v55 != 1) {
+ if (v55 == 2) {
+LABEL_201:
+ v115 = NV_LIGNEDEP;
+ v114 = NV_LIGNEOFS;
+ v112 = NV_POSI;
+ } else {
+ if (v113 == 1) {
+ v56 = 0;
+ if (v111 > 0) {
+ do {
+ if ((uint16)colision2_ligne(a1, a2 - v56, &v125, &v124, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v124) {
+ v57 = v112;
+ v58 = GENIAL(v124, v125, a1, a2 - v56, a1, a2 - v111, v112, &_vm->_globals.super_parcours[0], 4);
+ if (v58 == -1)
+ goto LABEL_282;
+ v112 = v58;
+ if (NVPY != -1)
+ v56 = a2 - NVPY;
+ }
+ v59 = v112;
+ _vm->_globals.super_parcours[v59] = a1;
+ _vm->_globals.super_parcours[v59 + 1] = a2 - v56;
+ _vm->_globals.super_parcours[v59 + 2] = 1;
+ _vm->_globals.super_parcours[v59 + 3] = 0;
+ v112 += 4;
+ ++v56;
+ } while (v111 > v56);
+ }
+ }
+ if (v113 == 5) {
+ v60 = 0;
+ if (v111 > 0) {
+ do {
+ if ((uint16)colision2_ligne(a1, v60 + a2, &v125, &v124, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v124) {
+ v57 = v112;
+ v61 = GENIAL(v124, v125, a1, v60 + a2, a1, v111 + a2, v112, &_vm->_globals.super_parcours[0], 4);
+ if (v61 == -1)
+ goto LABEL_282;
+ v112 = v61;
+ if (NVPY != -1)
+ v60 = NVPY - a2;
+ }
+ v62 = v112;
+ _vm->_globals.super_parcours[v62] = a1;
+ _vm->_globals.super_parcours[v62 + 1] = v60 + a2;
+ _vm->_globals.super_parcours[v62 + 2] = 5;
+ _vm->_globals.super_parcours[v62 + 3] = 0;
+ v112 += 4;
+ ++v60;
+ } while (v111 > v60);
+ }
+ }
+ if (v113 == 7) {
+ v63 = 0;
+ if (v111 > 0) {
+ do {
+ if ((uint16)colision2_ligne(a1 - v63, a2, &v125, &v124, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v124) {
+ v57 = v112;
+ v64 = GENIAL(v124, v125, a1 - v63, a2, a1 - v111, a2, v112, &_vm->_globals.super_parcours[0], 4);
+ if (v64 == -1)
+ goto LABEL_282;
+ v112 = v64;
+ if (NVPX != -1)
+ v63 = a1 - NVPX;
+ }
+ v65 = v112;
+ _vm->_globals.super_parcours[v65] = a1 - v63;
+ _vm->_globals.super_parcours[v65 + 1] = a2;
+ _vm->_globals.super_parcours[v65 + 2] = 7;
+ _vm->_globals.super_parcours[v65 + 3] = 0;
+ v112 += 4;
+ ++v63;
+ } while (v111 > v63);
+ }
+ }
+ if (v113 == 3) {
+ v66 = 0;
+ if (v111 > 0) {
+ do {
+ if ((uint16)colision2_ligne(v66 + a1, a2, &v125, &v124, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1
+ && _vm->_objectsManager.DERLIGNE < v124) {
+ v57 = v112;
+ v67 = GENIAL(v124, v125, v66 + a1, a2, v111 + a1, a2, v112, &_vm->_globals.super_parcours[0], 4);
+ if (v67 == -1)
+ goto LABEL_282;
+ v112 = v67;
+ if (NVPX != -1)
+ v66 = NVPX - a1;
+ }
+ v68 = v112;
+ _vm->_globals.super_parcours[v68] = v66 + a1;
+ _vm->_globals.super_parcours[v68 + 1] = a2;
+ _vm->_globals.super_parcours[v68 + 2] = 3;
+ _vm->_globals.super_parcours[v68 + 3] = 0;
+ v112 += 4;
+ ++v66;
+ } while (v111 > v66);
+ }
+ }
+ }
+LABEL_234:
+ if (v115 < v121) {
+ for (i = v114; Ligne[v115].field0 > i; ++i) {
+ v70 = Ligne[v115].lineData;
+ v119 = v70[2 * i];
+ v118 = v70[2 * i + 1];
+ v71 = v112;
+ _vm->_globals.super_parcours[v71] = v119;
+ _vm->_globals.super_parcours[v71 + 1] = v118;
+ _vm->_globals.super_parcours[v71 + 2] = Ligne[v115].field6;
+ _vm->_globals.super_parcours[v71 + 3] = 0;
+ v112 += 4;
+ }
+ v116 = v115 + 1;
+ if ((v115 + 1) < v121) {
+ do {
+ v72 = 0;
+ v110 = v116;
+ for (j = v116; Ligne[j].field0 > v72; j = v116) {
+ v74 = Ligne[v110].lineData;
+ v119 = v74[2 * v72];
+ v118 = v74[2 * v72 + 1];
+ v75 = v112;
+ _vm->_globals.super_parcours[v75] = v119;
+ _vm->_globals.super_parcours[v75 + 1] = v118;
+ _vm->_globals.super_parcours[v75 + 2] = Ligne[v110].field6;
+ _vm->_globals.super_parcours[v75 + 3] = 0;
+ v112 += 4;
+ v76 = Ligne[v110].field0;
+ if (v76 > 30) {
+ v77 = v76 / 2;
+ if (v77 < 0)
+ v77 = -v77;
+ if (v72 == v77) {
+ v78 = PARC_PERS(v119, v118, v123, v122, v110, v121, v112);
+ if (v78 == 1)
+ return &_vm->_globals.super_parcours[0];
+ if (v78 == 2)
+ goto LABEL_200;
+ if (MIRACLE(v119, v118, v110, v121, v112) == 1)
+ goto LABEL_201;
+ }
+ }
+ ++v72;
+ v110 = v116;
+ }
+ v79 = PARC_PERS(v119, v118, v123, v122, v116, v121, v112);
+ if (v79 == 1)
+ return &_vm->_globals.super_parcours[0];
+ if (v79 == 2) {
+LABEL_200:
+ v115 = NV_LIGNEDEP;
+ v114 = NV_LIGNEOFS;
+ v112 = NV_POSI;
+ goto LABEL_234;
+ }
+ if (MIRACLE(v119, v118, v116, v121, v112) == 1)
+ goto LABEL_201;
+ ++v116;
+ } while (v116 < v121);
+ }
+ v114 = 0;
+ v115 = v121;
+ }
+ if (v115 > v121) {
+ v80 = v114;
+ if (v114 > 0) {
+ v98 = v115;
+ do {
+ v81 = Ligne[v98].lineData;
+ v119 = v81[2 * v80];
+ v118 = v81[2 * v80 + 1];
+
+ v82 = v112;
+ _vm->_globals.super_parcours[v82] = v119;
+ _vm->_globals.super_parcours[v82 + 1] = v118;
+ _vm->_globals.super_parcours[v82 + 2] = Ligne[v98].field8;
+ _vm->_globals.super_parcours[v82 + 3] = 0;
+ v112 += 4;
+ --v80;
+ } while (v80 > 0);
+ }
+ v117 = v115 - 1;
+ if ((v115 - 1) > v121) {
+ do {
+ v83 = Ligne[v117].field0 - 1;
+ if (v83 > -1) {
+ v109 = v117;
+ do {
+ v84 = Ligne[v109].lineData;
+ v119 = v84[2 * v83];
+ v118 = v84[2 * v83 + 1];
+ v85 = v112;
+ _vm->_globals.super_parcours[v85] = v119;
+ _vm->_globals.super_parcours[v85 + 1] = v118;
+ _vm->_globals.super_parcours[v85 + 2] = Ligne[v109].field8;
+ _vm->_globals.super_parcours[v85 + 3] = 0;
+ v112 += 4;
+ v86 = Ligne[v109].field0;
+ if (v86 > 30) {
+ v87 = v86 / 2;
+ if (v87 < 0)
+ v87 = -v87;
+ if (v83 == v87) {
+ v88 = PARC_PERS(v119, v118, v123, v122, v117, v121, v112);
+ if (v88 == 1)
+ return &_vm->_globals.super_parcours[0];
+ if (v88 == 2)
+ goto LABEL_200;
+ if (MIRACLE(v119, v118, v117, v121, v112) == 1)
+ goto LABEL_201;
+ }
+ }
+ --v83;
+ } while (v83 > -1);
+ }
+ v89 = PARC_PERS(v119, v118, v123, v122, v117, v121, v112);
+ if (v89 == 1)
+ return &_vm->_globals.super_parcours[0];
+ if (v89 == 2)
+ goto LABEL_200;
+ if (MIRACLE(v119, v118, v117, v121, v112) == 1)
+ goto LABEL_201;
+ --v117;
+ } while (v117 > v121);
+ }
+ v114 = Ligne[v121].field0 - 1;
+ v115 = v121;
+ }
+ if (v115 == v121) {
+ if (v114 <= v120) {
+ if (v114 < v120) {
+ v94 = v114;
+ v100 = v121;
+ do {
+ v95 = Ligne[v100].lineData;
+ v96 = v95[2 * v94 + 1];
+ v97 = v112;
+ _vm->_globals.super_parcours[v97] = v95[2 * v94];
+ _vm->_globals.super_parcours[v97 + 1] = v96;
+ _vm->_globals.super_parcours[v97 + 2] = Ligne[v100].field6;
+ _vm->_globals.super_parcours[v97 + 3] = 0;
+ v112 += 4;
+ ++v94;
+ } while (v120 > v94);
+ }
+ } else {
+ v90 = v114;
+ v99 = v121;
+ do {
+ v91 = Ligne[v99].lineData;
+ v92 = v91[2 * v90 + 1];
+ v93 = v112;
+ _vm->_globals.super_parcours[v93] = v91[2 * v90];
+ _vm->_globals.super_parcours[v93 + 1] = v92;
+ _vm->_globals.super_parcours[v93 + 2] = Ligne[v99].field8;
+ _vm->_globals.super_parcours[v93 + 3] = 0;
+ v112 += 4;
+ --v90;
+ } while (v120 < v90);
+ }
+ }
+ v57 = v112;
+ if (PARC_PERS(
+ _vm->_globals.super_parcours[v112 - 4],
+ _vm->_globals.super_parcours[v112 - 3],
+ v123,
+ v122,
+ -1,
+ -1,
+ v112) != 1) {
+LABEL_282:
+ _vm->_globals.super_parcours[v57] = -1;
+ _vm->_globals.super_parcours[v57 + 1] = -1;
+ _vm->_globals.super_parcours[v57 + 2] = -1;
+ _vm->_globals.super_parcours[v57 + 3] = -1;
+ }
+ return &_vm->_globals.super_parcours[0];
+ }
+ }
+ return &_vm->_globals.super_parcours[0];
+}
+
+int LinesManager::PARC_PERS(int a1, int a2, int a3, int a4, int a5, int a6, int a7) {
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int16 *v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int16 *v26;
+ int v27;
+ int16 *v28;
+ int16 *v29;
+ int v30;
+ int v31;
+ int16 *v32;
+ int v33;
+ int v34;
+ int16 *v35;
+ int v36;
+ int v37;
+ int16 *v38;
+ int v39;
+ int v40;
+ int v41;
+ int16 *v42;
+ int v43;
+ int v44;
+ int v45;
+ int v46;
+ int16 *v47;
+ int v48;
+ int16 *v49;
+ int16 *v50;
+ int v51;
+ int v52;
+ int16 *v53;
+ int v54;
+ int v55;
+ int v56;
+ int16 *v57;
+ int v58;
+ int v59;
+ int16 *v60;
+ int v61;
+ int v62;
+ int v63;
+ int16 *v64;
+ int v65;
+ int v66;
+ int v67;
+ int v68;
+ int16 *v69;
+ int v70;
+ int16 *v71;
+ int16 *v72;
+ int v73;
+ int v74;
+ int v76;
+ int16 *v77;
+ int16 *v78;
+ int v79;
+ int16 *v80;
+ int v81;
+ int16 *v82;
+ int v83;
+ int16 *v84;
+ int v85;
+ int16 *v86;
+ int v87;
+ int16 *v88;
+ int v89;
+ int v90;
+ int v91;
+ int v92;
+ int v93;
+ int v94;
+ int v95;
+ int v96;
+ int v97;
+ int v98;
+ int v99;
+ int v100;
+ int v101;
+ int v102;
+ int v103;
+ int v104;
+ int v105;
+ int v106;
+ int v107;
+ int v108;
+ int v109;
+ int v110;
+ int v111;
+ int v112;
+ int v113;
+ int v114;
+ int v115;
+ int v116;
+ int v117;
+ int v118;
+ int v119;
+ int v120;
+ int v121;
+ int v122;
+ int v123;
+ int v124;
+ int v125;
+ int v126 = 0;
+ int v127;
+ int v128;
+ int v129;
+ int v130;
+ int v131;
+ int v132;
+ int v133;
+ int v134;
+ int v135;
+ int v136;
+ int v137;
+ int v138;
+ int v139;
+ int v140;
+ int v141;
+ int v142;
+ int v143;
+ int v144;
+ int v145;
+ int colResult = 0;
+
+ v7 = a1;
+ v90 = a2;
+ v137 = a7;
+ v136 = 0;
+ if (a5 == -1 && a6 == -1)
+ v136 = 1;
+ v144 = a5;
+ if (colision2_ligne(a1, a2, &v145, &v144, 0, TOTAL_LIGNES) == 1) {
+ v8 = Ligne[v144].field4;
+ if (v8 == 1)
+ v90 = a2 - 2;
+ if (v8 == 2) {
+ v90 -= 2;
+ v7 = a1 + 2;
+ }
+ if (v8 == 3)
+ v7 += 2;
+ if (v8 == 4) {
+ v90 += 2;
+ v7 += 2;
+ }
+ if (v8 == 5)
+ v90 += 2;
+ if (v8 == 6) {
+ v90 += 2;
+ v7 -= 2;
+ }
+ if (v8 == 7)
+ v7 -= 2;
+ if (v8 == 8) {
+ v90 -= 2;
+ v7 -= 2;
+ }
+ }
+ v98 = v7;
+ v97 = v90;
+ v115 = 0;
+ v142 = -1;
+ v140 = -1;
+ v138 = -1;
+
+ for (;;) {
+ v111 = v7;
+ v109 = v90;
+ if (a3 >= v7 - 2 && a3 <= v7 + 2 && a4 >= v90 - 2 && a4 <= v90 + 2) {
+LABEL_149:
+ v27 = v115;
+ v28 = _vm->_globals.essai0;
+ v28[v27] = -1;
+ v28[v27 + 1] = -1;
+ v28[v27 + 2] = -1;
+
+LABEL_150:
+ if (v115) {
+ v127 = 0;
+ v116 = 0;
+ v29 = _vm->_globals.essai0;
+ do {
+ v30 = v137;
+ _vm->_globals.super_parcours[v30] = v29[v116];
+ _vm->_globals.super_parcours[v30 + 1] = v29[v116 + 1];
+ _vm->_globals.super_parcours[v30 + 2] = v29[v116 + 2];
+ _vm->_globals.super_parcours[v30 + 3] = 0;
+ v116 += 3;
+ v137 += 4;
+
+ if (v29[v116] == -1) {
+ if (v29[v116 + 1] == -1)
+ v127 = 1;
+ }
+ } while (v127 != 1);
+ }
+ goto LABEL_248;
+ }
+ v9 = v7 - a3;
+ if (v7 - a3 < 0)
+ v9 = -v9;
+ v10 = v9 + 1;
+ v11 = v90 - a4;
+ if (v90 - a4 < 0)
+ v11 = -v11;
+ v107 = v11 + 1;
+ if (v10 > (int16)(v11 + 1))
+ v107 = v10;
+ v12 = v107 - 1;
+ v101 = 1000 * v10 / v12;
+ v99 = 1000 * (int16)(v11 + 1) / v12;
+ if (a3 < v7)
+ v101 = -v101;
+ if (a4 < v90)
+ v99 = -v99;
+ v13 = (int16)v101 / 1000;
+ v94 = (int16)v99 / 1000;
+ v91 = -1;
+ if ((int16)v99 / 1000 == -1 && (unsigned int)v101 <= 0x96)
+ v91 = 1;
+ if (v13 == 1) {
+ if ((unsigned int)(v99 + 1) <= 0x97)
+ v91 = 3;
+ if ((unsigned int)v99 <= 0x96)
+ v91 = 3;
+ }
+ if (v94 == 1) {
+ if ((unsigned int)v101 <= 0x96)
+ v91 = 5;
+ if ((unsigned int)(v101 + 150) <= 0x96)
+ v91 = 5;
+ }
+ if (v13 == -1) {
+ if ((unsigned int)v99 <= 0x96)
+ v91 = 7;
+ if ((unsigned int)(v99 + 150) <= 0x96)
+ v91 = 7;
+ }
+ if (v94 == -1 && (unsigned int)(v101 + 150) <= 0x96)
+ v91 = 1;
+ if (v91 == -1 && !VERIF_SMOOTH(v7, v109, a3, a4) && SMOOTH_MOVE(v7, v109, a3, a4) != -1)
+ break;
+LABEL_72:
+ v19 = v111 - a3;
+ if (v111 - a3 < 0)
+ v19 = -v19;
+ v20 = v19 + 1;
+ v95 = v109 - a4;
+ if (v95 < 0)
+ v95 = -(v109 - a4);
+ v108 = v95 + 1;
+ if (v20 > (int16)(v95 + 1))
+ v108 = v20;
+ if (v108 <= 10)
+ goto LABEL_149;
+ v21 = v108 - 1;
+ v102 = 1000 * v20 / v21;
+ v100 = 1000 * (int16)(v95 + 1) / v21;
+ if (a3 < v111)
+ v102 = -v102;
+ if (a4 < v109)
+ v100 = -v100;
+ v22 = (int16)v102 / 1000;
+ v96 = (int16)v100 / 1000;
+ v106 = 1000 * v111;
+ v105 = 1000 * v109;
+ v104 = 1000 * v111 / 1000;
+ v103 = v105 / 1000;
+ if (!((int16)v102 / 1000) && v96 == -1)
+ v91 = 1;
+ if (v22 == 1) {
+ if (v96 == -1)
+ v91 = 2;
+ if (!v96)
+ v91 = 3;
+ if (v96 == 1)
+ v91 = 4;
+ }
+ if (!v22 && v96 == 1)
+ v91 = 5;
+ if (v22 != -1)
+ goto LABEL_103;
+ if (v96 == 1)
+ v91 = 6;
+ if (!v96)
+ v91 = 7;
+ if (v96 == -1) {
+ v91 = 8;
+LABEL_103:
+ if (v96 == -1) {
+ if ((unsigned int)v102 <= 0x1FE)
+ v91 = 1;
+ if ((unsigned int)(v102 - 510) <= 0x1EA)
+ v91 = 2;
+ }
+ }
+ if (v22 == 1) {
+ if ((unsigned int)(v100 + 1) <= 0x1FF)
+ v91 = 2;
+ if ((unsigned int)(v100 + 510) <= 0x1FE)
+ v91 = 3;
+ if ((unsigned int)v100 <= 0x1FE)
+ v91 = 3;
+ if ((unsigned int)(v100 - 510) <= 0x1EA)
+ v91 = 4;
+ }
+ if (v96 == 1) {
+ if ((unsigned int)(v102 - 510) <= 0x1EA)
+ v91 = 4;
+ if ((unsigned int)v102 <= 0x1FE)
+ v91 = 5;
+ if (v102 >= -1 && v102 <= -510)
+ v91 = 6;
+ if ((unsigned int)(v102 + 510) <= 0x1FE)
+ v91 = 5;
+ }
+ if (v22 == -1) {
+ if ((unsigned int)(v100 - 510) <= 0x1EA)
+ v91 = 6;
+ if ((unsigned int)v100 <= 0x1FE)
+ v91 = 7;
+ if ((unsigned int)(v100 + 1000) <= 0x1EA)
+ v91 = 8;
+ if ((unsigned int)(v100 + 510) <= 0x1FE)
+ v91 = 7;
+ }
+ if (v96 == -1) {
+ if ((unsigned int)(v102 + 1000) <= 0x1EA)
+ v91 = 8;
+ if ((unsigned int)(v102 + 510) <= 0x1FE)
+ v91 = 1;
+ }
+ v23 = 0;
+ if (v108 + 1 <= 0)
+ goto LABEL_149;
+ while (colision2_ligne(v104, v103, &v143, &v142, 0, TOTAL_LIGNES) != 1) {
+ v25 = v115;
+ v26 = _vm->_globals.essai0;
+ v26[v25] = v104;
+ v26[v25 + 1] = v103;
+ v26[v25 + 2] = v91;
+ v106 += v102;
+ v105 += v100;
+ v104 = v106 / 1000;
+ v103 = v105 / 1000;
+ v115 += 3;
+ ++v23;
+ if (v23 >= v108 + 1)
+ goto LABEL_149;
+ }
+ if (_vm->_objectsManager.DERLIGNE >= v142)
+ goto LABEL_157;
+ v24 = GENIAL(v142, v143, v104, v103, a3, a4, v115, _vm->_globals.essai0, 3);
+ if (v24 == -1)
+ goto LABEL_150;
+ v115 = v24;
+ if (NVPX != -1 || NVPY != -1) {
+LABEL_67:
+ v142 = -1;
+ goto LABEL_157;
+ }
+ v7 = -1;
+ v90 = -1;
+ }
+ v91 = SMOOTH_SENS;
+ v14 = 0;
+ while (1) {
+ v15 = SMOOTH[v14].field0;
+ v112 = v15;
+ v110 = SMOOTH[v14].field2;
+ if (v15 == -1 || SMOOTH[v14].field2 == -1) {
+ v126 = 1;
+ goto LABEL_70;
+ }
+ if (colision2_ligne(v15, v110, &v143, &v142, 0, TOTAL_LIGNES) == 1)
+ break;
+ v16 = v115;
+
+ v17 = _vm->_globals.essai0;
+ v17[v16] = v112;
+ v17[v16 + 1] = v110;
+ v17[v16 + 2] = v91;
+ v115 += 3;
+ ++v14;
+LABEL_70:
+ if (v126 == 1) {
+ v18 = v14 - 1;
+ v111 = SMOOTH[v18].field0;
+ v109 = SMOOTH[v18].field2;
+ goto LABEL_72;
+ }
+ }
+ if (v142 > _vm->_objectsManager.DERLIGNE)
+ goto LABEL_67;
+LABEL_157:
+ v31 = v115;
+ v32 = _vm->_globals.essai0;
+ v32[v31] = -1;
+ v32[v31 + 1] = -1;
+ v32[v31 + 2] = -1;
+
+ v117 = 0;
+ v33 = v98;
+ v92 = v97;
+LABEL_158:
+ v113 = v33;
+ if (a3 >= v33 - 2 && a3 <= v33 + 2 && a4 >= v92 - 2 && a4 <= v92 + 2)
+ goto LABEL_194;
+ if (v33 >= a3) {
+LABEL_165:
+ if (v113 > a3) {
+ v36 = v113;
+ while (colision2_ligne(v36, v92, &v141, &v140, 0, TOTAL_LIGNES) != 1) {
+ v37 = v117;
+ v38 = _vm->_globals.essai1;
+ v38[v37] = v36;
+ v38[v37 + 1] = v92;
+ v38[v37 + 2] = 7;
+ v117 += 3;
+ --v36;
+ if (a3 >= v36)
+ goto LABEL_171;
+ }
+ goto LABEL_168;
+ }
+LABEL_171:
+ if (v92 >= a4) {
+LABEL_181:
+ if (v92 > a4) {
+ v43 = v92;
+ do {
+ if (colision2_ligne(a3, v43, &v141, &v140, 0, TOTAL_LIGNES) == 1) {
+ if (_vm->_objectsManager.DERLIGNE < v140) {
+ v44 = GENIAL(v140, v141, a3, v43, a3, a4, v117, _vm->_globals.essai1, 3);
+ if (v44 == -1)
+ goto LABEL_195;
+ v117 = v44;
+ if (NVPX != -1) {
+ if (NVPY != -1) {
+ v33 = NVPX;
+ v92 = NVPY;
+ v45 = colision2_ligne(NVPX, NVPY, &v141, &v140, 0, _vm->_objectsManager.DERLIGNE);
+ goto LABEL_189;
+ }
+ }
+ }
+ if (v140 <= _vm->_objectsManager.DERLIGNE)
+ goto LABEL_202;
+ }
+ v46 = v117;
+ v47 = _vm->_globals.essai1;
+ v47[v46] = a3;
+ v47[v46 + 1] = v43;
+ v47[v46 + 2] = 1;
+ v117 += 3;
+ --v43;
+ } while (a4 < v43);
+ }
+LABEL_194:
+ v48 = v117;
+ v49 = _vm->_globals.essai1;
+ v49[v48] = -1;
+ v49[v48 + 1] = -1;
+ v49[v48 + 2] = -1;
+LABEL_195:
+ if (v117) {
+ v128 = 0;
+ v118 = 0;
+ v50 = _vm->_globals.essai1;
+ do {
+ v51 = v137;
+ _vm->_globals.super_parcours[v51] = v50[v118];
+ _vm->_globals.super_parcours[v51 + 1] = v50[v118 + 1];
+ _vm->_globals.super_parcours[v51 + 2] = v50[v118 + 2];
+ _vm->_globals.super_parcours[v51 + 3] = 0;
+ v118 += 3;
+ v137 += 4;
+ if (v50[v118] == -1 && v50[v118 + 1] == -1)
+ v128 = 1;
+ } while (v128 != 1);
+ }
+ goto LABEL_248;
+ }
+ v39 = v92;
+ while (1) {
+ if (colision2_ligne(a3, v39, &v141, &v140, 0, TOTAL_LIGNES) == 1) {
+ if (_vm->_objectsManager.DERLIGNE < v140) {
+ v40 = GENIAL(v140, v141, a3, v39, a3, a4, v117, _vm->_globals.essai1, 3);
+ if (v40 == -1)
+ goto LABEL_195;
+ v117 = v40;
+ if (NVPX != -1) {
+ if (NVPY != -1) {
+ v33 = NVPX;
+ v92 = NVPY;
+ v45 = colision2_ligne(NVPX, NVPY, &v141, &v140, 0, _vm->_objectsManager.DERLIGNE);
+LABEL_189:
+ if (v45 == 1 && v140 <= _vm->_objectsManager.DERLIGNE)
+ goto LABEL_202;
+ goto LABEL_158;
+ }
+ }
+ }
+ if (v140 <= _vm->_objectsManager.DERLIGNE)
+ goto LABEL_202;
+ }
+ v41 = v117;
+
+ v42 = _vm->_globals.essai1;
+ v42[v41] = a3;
+ v42[v41 + 1] = v39;
+ v42[v41 + 2] = 5;
+ v117 += 3;
+ ++v39;
+ if (a4 <= v39)
+ goto LABEL_181;
+ }
+ }
+ while (colision2_ligne(v33, v92, &v141, &v140, 0, TOTAL_LIGNES) != 1) {
+ v34 = v117;
+ v35 = _vm->_globals.essai1;
+ v35[v34] = v33;
+ v35[v34 + 1] = v92;
+ v35[v34 + 2] = 3;
+ v117 += 3;
+ ++v33;
+ if (a3 <= v33)
+ goto LABEL_165;
+ }
+LABEL_168:
+ if (v140 > _vm->_objectsManager.DERLIGNE)
+ v140 = -1;
+LABEL_202:
+ v52 = v117;
+ v53 = _vm->_globals.essai1;
+ v53[v52] = -1;
+ v53[v52 + 1] = -1;
+ v53[v52 + 2] = -1;
+ v117 = 0;
+ v54 = v98;
+ v93 = v97;
+LABEL_203:
+ v114 = v54;
+ if (a3 >= v54 - 2 && a3 <= v54 + 2 && a4 >= v93 - 2 && a4 <= v93 + 2)
+ goto LABEL_241;
+ if (v93 < a4) {
+ v55 = v93;
+ while (colision2_ligne(v114, v55, &v139, &v138, 0, TOTAL_LIGNES) != 1) {
+ v56 = v117;
+ v57 = _vm->_globals.essai2;
+ v57[v56] = v114;
+ v57[v56 + 1] = v55;
+ v57[v56 + 2] = 5;
+ v117 += 3;
+ ++v55;
+ if (a4 <= v55)
+ goto LABEL_211;
+ }
+ goto LABEL_214;
+ }
+LABEL_211:
+ if (v93 > a4) {
+ v58 = v93;
+ while (colision2_ligne(v114, v58, &v139, &v138, 0, TOTAL_LIGNES) != 1) {
+ v59 = v117;
+ v60 = _vm->_globals.essai2;
+ v60[v59] = v114;
+ v60[v59 + 1] = v58;
+ v60[v59 + 2] = 1;
+ v117 += 3;
+ --v58;
+ if (a4 >= v58)
+ goto LABEL_217;
+ }
+LABEL_214:
+ if (v138 > _vm->_objectsManager.DERLIGNE)
+ v138 = -1;
+LABEL_249:
+ v76 = v117;
+ v77 = _vm->_globals.essai2;
+ v77[v76] = -1;
+ v77[v76 + 1] = -1;
+ v77[v76 + 2] = -1;
+
+ if (v136 != 1) {
+ if (a6 > v144) {
+ if (_vm->_globals.essai0[0] != -1 && v142 > v144 && v140 <= v142 && v138 <= v142 && a6 >= v142) {
+ NV_LIGNEDEP = v142;
+ NV_LIGNEOFS = v143;
+ v130 = 0;
+ v120 = 0;
+ v78 = _vm->_globals.essai0;
+ do {
+ v79 = v137;
+ _vm->_globals.super_parcours[v79] = v78[v120];
+ _vm->_globals.super_parcours[v79 + 1] = v78[v120 + 1];
+ _vm->_globals.super_parcours[v79 + 2] = v78[v120 + 2];
+ _vm->_globals.super_parcours[v79 + 3] = 0;
+ v120 += 3;
+ v137 += 4;
+ if (v78[v120] == -1 && v78[v120 + 1] == -1)
+ v130 = 1;
+ } while (v130 != 1);
+LABEL_323:
+ NV_POSI = v137;
+ return 2;
+ }
+ v80 = _vm->_globals.essai1;
+ if (_vm->_globals.essai1[0] != -1 && v144 < v140 && v138 <= v140 && v142 <= v140 && a6 >= v140) {
+ NV_LIGNEDEP = v140;
+ NV_LIGNEOFS = v141;
+ v131 = 0;
+ v121 = 0;
+ do {
+ assert(137 <= 32000);
+ v81 = v137;
+ _vm->_globals.super_parcours[v81] = v80[v121];
+ _vm->_globals.super_parcours[v81 + 1] = v80[v121 + 1];
+ _vm->_globals.super_parcours[v81 + 2] = v80[v121 + 2];
+ _vm->_globals.super_parcours[v81 + 3] = 0;
+ v121 += 3;
+ v137 += 4;
+ if (v80[v121] == -1 && v80[v121 + 1] == -1)
+ v131 = 1;
+ } while (v131 != 1);
+LABEL_301:
+ NV_POSI = v137;
+ return 2;
+ }
+ v82 = _vm->_globals.essai2;
+ if (_vm->_globals.essai2[0] != -1) {
+ if (v144 < v138 && v140 < v138 && v142 < v138 && a6 >= v138) {
+ NV_LIGNEDEP = v138;
+ NV_LIGNEOFS = v139;
+ v132 = 0;
+ v122 = 0;
+ do {
+ assert(v137 <= 32000);
+ v83 = v137;
+ _vm->_globals.super_parcours[v83] = v82[v122];
+ _vm->_globals.super_parcours[v83 + 1] = v82[v122 + 1];
+ _vm->_globals.super_parcours[v83 + 2] = v82[v122 + 2];
+ _vm->_globals.super_parcours[v83 + 3] = 0;
+ v122 += 3;
+ v137 += 4;
+ if (v82[v122] == -1 && v82[v122 + 1] == -1)
+ v132 = 1;
+ } while (v132 != 1);
+LABEL_312:
+ NV_POSI = v137;
+ return 2;
+ }
+ }
+ }
+ if (a6 < v144) {
+ if (v142 == -1)
+ v142 = 1300;
+ if (v140 == -1)
+ v142 = 1300;
+ if (v138 == -1)
+ v142 = 1300;
+ if (_vm->_globals.essai1[0] != -1 && v140 < v144 && v138 >= v140 && v142 >= v140 && a6 <= v140) {
+ NV_LIGNEDEP = v140;
+ NV_LIGNEOFS = v141;
+ v133 = 0;
+ v123 = 0;
+ v84 = _vm->_globals.essai1;
+ do {
+ assert(137 <= 32000);
+ v85 = v137;
+ _vm->_globals.super_parcours[v85] = v84[v123];
+ _vm->_globals.super_parcours[v85 + 1] = v84[v123 + 1];
+ _vm->_globals.super_parcours[v85 + 2] = v84[v123 + 2];
+ _vm->_globals.super_parcours[v85 + 3] = 0;
+ v123 += 3;
+ v137 += 4;
+ if (v84[v123] == -1 && v84[v123 + 1] == -1)
+ v133 = 1;
+ } while (v133 != 1);
+ goto LABEL_301;
+ }
+ v86 = _vm->_globals.essai2;
+ if (_vm->_globals.essai2[0] != -1 && v144 > v138 && v140 >= v138 && v142 >= v138 && a6 <= v138) {
+ NV_LIGNEDEP = v138;
+ NV_LIGNEOFS = v139;
+ v134 = 0;
+ v124 = 0;
+ do {
+ assert(137 <= 32000);
+ v87 = v137;
+ _vm->_globals.super_parcours[v87] = v86[v124];
+ _vm->_globals.super_parcours[v87 + 1] = v86[v124 + 1];
+ _vm->_globals.super_parcours[v87 + 2] = v86[v124 + 2];
+ _vm->_globals.super_parcours[v87 + 3] = 0;
+ v124 += 3;
+ v137 += 4;
+ if (v86[v124] == -1 && v86[v124 + 1] == -1)
+ v134 = 1;
+ } while (v134 != 1);
+ goto LABEL_312;
+ }
+ if (_vm->_globals.essai1[0] != -1 && v144 > v142 && v140 >= v142 && v138 >= v142 && a6 <= v142) {
+ NV_LIGNEDEP = v142;
+ NV_LIGNEOFS = v143;
+ v135 = 0;
+ v125 = 0;
+ v88 = _vm->_globals.essai0;
+ do {
+ assert(137 <= 32000);
+ v89 = v137;
+ _vm->_globals.super_parcours[v89] = v88[v125];
+ _vm->_globals.super_parcours[v89 + 1] = v88[v125 + 1];
+ _vm->_globals.super_parcours[v89 + 2] = v88[v125 + 2];
+ _vm->_globals.super_parcours[v89 + 3] = 0;
+ v125 += 3;
+ v137 += 4;
+ if (v88[v125] == -1 && v88[v125 + 1] == -1)
+ v135 = 1;
+ } while (v135 != 1);
+ goto LABEL_323;
+ }
+ }
+ }
+ return 0;
+ }
+LABEL_217:
+ if (v114 < a3) {
+ v61 = v114;
+ do {
+ if (colision2_ligne(v61, a4, &v139, &v138, 0, TOTAL_LIGNES) == 1) {
+ if (_vm->_objectsManager.DERLIGNE < v138) {
+ v62 = GENIAL(v138, v139, v61, a4, a3, a4, v117, _vm->_globals.essai2, 3);
+ if (v62 == -1)
+ goto LABEL_195;
+ v117 = v62;
+ if (NVPX != -1) {
+ if (NVPY != -1) {
+ v54 = NVPX;
+ v93 = NVPY;
+ colResult = colision2_ligne(NVPX, NVPY, &v139, &v138, 0, _vm->_objectsManager.DERLIGNE);
+LABEL_235:
+ if (colResult == 1 && v138 <= _vm->_objectsManager.DERLIGNE)
+ goto LABEL_249;
+ goto LABEL_203;
+ }
+ }
+ }
+ if (v138 <= _vm->_objectsManager.DERLIGNE)
+ goto LABEL_249;
+ }
+ v63 = v117;
+
+ v64 = _vm->_globals.essai2;
+ v64[v63] = v61;
+ v64[v63 + 1] = a4;
+ v64[v63 + 2] = 3;
+ v117 += 3;
+ ++v61;
+ } while (a3 > v61);
+ }
+ if (v114 > a3) {
+ v65 = v114;
+ do {
+ if (colision2_ligne(v65, a4, &v139, &v138, 0, TOTAL_LIGNES) == 1) {
+ if (_vm->_objectsManager.DERLIGNE < v138) {
+ v66 = GENIAL(v138, v139, v65, a4, a3, a4, v117, _vm->_globals.essai2, 3);
+ if (v66 == -1)
+ goto LABEL_242;
+ v117 = v66;
+ if (NVPX != -1) {
+ if (NVPY != -1) {
+ v54 = NVPX;
+ v93 = NVPY;
+ v67 = colision2_ligne(NVPX, NVPY, &v139, &v138, 0, _vm->_objectsManager.DERLIGNE);
+ goto LABEL_235;
+ }
+ }
+ }
+ if (v138 <= _vm->_objectsManager.DERLIGNE)
+ goto LABEL_249;
+ }
+ v68 = v117;
+ v69 = _vm->_globals.essai2;
+ v69[v68] = v65;
+ v69[v68 + 1] = a4;
+ v69[v68 + 2] = 7;
+ v117 += 3;
+ --v65;
+ } while (a3 < v65);
+ }
+ v138 = -1;
+LABEL_241:
+ v70 = v117;
+ v71 = _vm->_globals.essai2;
+ v71[v70] = -1;
+ v71[v70 + 1] = -1;
+ v71[v70 + 2] = -1;
+LABEL_242:
+ if (v117) {
+ v129 = 0;
+ v119 = 0;
+ v72 = _vm->_globals.essai2;
+ do {
+ v73 = v137;
+ _vm->_globals.super_parcours[v73] = v72[v119];
+ _vm->_globals.super_parcours[v73 + 1] = v72[v119 + 1];
+ _vm->_globals.super_parcours[v73 + 2] = v72[v119 + 2];
+ _vm->_globals.super_parcours[v73 + 3] = 0;
+ v119 += 3;
+ v137 += 4;
+ if (v72[v119] == -1 && v72[v119 + 1] == -1)
+ v129 = 1;
+ } while (v129 != 1);
+ }
+LABEL_248:
+ v74 = v137;
+ _vm->_globals.super_parcours[v74] = -1;
+ _vm->_globals.super_parcours[v74 + 1] = -1;
+ _vm->_globals.super_parcours[v74 + 2] = -1;
+ _vm->_globals.super_parcours[v74 + 3] = -1;
+ return 1;
+}
+
+int LinesManager::VERIF_SMOOTH(int a1, int a2, int a3, int a4) {
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+
+ v4 = a1 - a3;
+ if (a1 - a3 < 0)
+ v4 = -v4;
+ v5 = v4 + 1;
+ v11 = a2 - a4;
+ if (a2 - a4 < 0)
+ v11 = -(a2 - a4);
+ v13 = v11 + 1;
+ if (v5 > (int)(v11 + 1))
+ v13 = v5;
+ if (v13 <= 10)
+ return -1;
+ v6 = v13 - 1;
+ v16 = 1000 * v5 / v6;
+ v15 = 1000 * (int)(v11 + 1) / v6;
+ if (a3 < a1)
+ v16 = -v16;
+ if (a4 < a2)
+ v15 = -v15;
+ v7 = 1000 * a1;
+ v8 = 1000 * a2;
+ v9 = 1000 * a1 / 1000;
+ v12 = 1000 * a2 / 1000;
+ v14 = 0;
+ if (v13 + 1 > 0) {
+ while (colision2_ligne(v9, v12, &v18, &v17, 0, TOTAL_LIGNES) != 1 || v17 > _vm->_objectsManager.DERLIGNE) {
+ v7 += v16;
+ v8 += v15;
+ v9 = v7 / 1000;
+ v12 = v8 / 1000;
+ ++v14;
+ if (v14 >= v13 + 1)
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+int LinesManager::SMOOTH_MOVE(int a3, int a4, int a5, int a6) {
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33;
+ int v34;
+ int v35;
+ int v37;
+ int v38;
+ int v39;
+ int v40;
+ int v41;
+ int v42;
+ int v43;
+ int v44;
+ int v45;
+ int v46;
+ int v47;
+ int v48;
+ int v49 = 0;
+ int v50;
+ int v51;
+ int v52;
+ int v53;
+ int v54;
+ int v55;
+ int v56;
+ int v57;
+ int v58;
+ int v59;
+ int v60;
+ int v61;
+ int v62;
+ int v63;
+
+ v62 = a3;
+ v63 = a4;
+ if (a3 >= a5 || a6 >= a4) {
+ if (a3 <= a5 || a6 >= a4) {
+ if (a3 >= a5 || a6 <= a4) {
+ if (a3 > a5 && a6 > a4) {
+ v53 = 36;
+ v61 = 0;
+ v57 = 0;
+ do {
+ v25 = _vm->_globals.Hopkins[v53].field0;
+ v40 = _vm->_globals.Hopkins[v53].field2;
+ v26 = _vm->_globals.STAILLE[v63];
+ if (v26 < 0) {
+ v27 = v26;
+ v28 = v26;
+ if (v26 < 0)
+ v28 = -v26;
+ v48 = _vm->_globals.STAILLE[v63];
+ v45 = v63;
+ v25 = _vm->_graphicsManager.Reel_Reduc(v25, v28);
+ v29 = v27;
+ if ((v27 & 0x80000000u) != 0)
+ v29 = -v27;
+ v40 = _vm->_graphicsManager.Reel_Reduc(v40, v29);
+ v63 = v45;
+ v26 = v48;
+ }
+ if (v26 > 0) {
+ v30 = v26;
+ v31 = v26;
+ if (v26 < 0)
+ v31 = -v26;
+ v46 = v63;
+ v25 = _vm->_graphicsManager.Reel_Zoom(v25, v31);
+ v32 = v30;
+ if ((v30 & 0x80000000u) != 0)
+ v32 = -v30;
+ v40 = _vm->_graphicsManager.Reel_Zoom(v40, v32);
+ v63 = v46;
+ }
+ v33 = v63 + v40;
+ v34 = 0;
+ if (v25 > 0) {
+ do {
+ --v62;
+ SMOOTH[v61].field0 = v62;
+ if (v63 != v33)
+ v63 = v63 + 1;
+ SMOOTH[v61++].field2 = v63;
+ ++v34;
+ } while (v34 < v25);
+ }
+ ++v53;
+ if (v53 == 48)
+ v53 = 36;
+ ++v57;
+ if (v62 <= a5 || a6 <= v63)
+ v49 = 1;
+ } while (v49 != 1);
+ if (v57 > 5) {
+ v35 = v61;
+ SMOOTH[v35].field0 = -1;
+ SMOOTH[v35].field2 = -1;
+ _vm->_linesManager.SMOOTH_SENS = 6;
+ goto LABEL_85;
+ }
+ }
+ } else {
+ v52 = 36;
+ v60 = 0;
+ v56 = 0;
+ do {
+ v14 = _vm->_globals.Hopkins[v52].field0;
+ v39 = _vm->_globals.Hopkins[v52].field2;
+ v15 = _vm->_globals.STAILLE[v63];
+ if (v15 < 0) {
+ v16 = v15;
+ v17 = v15;
+ if (v15 < 0)
+ v17 = -v15;
+ v47 = _vm->_globals.STAILLE[v63];
+ v43 = v63;
+ v14 = _vm->_graphicsManager.Reel_Reduc(v14, v17);
+ v18 = v16;
+ if ((v16 & 0x80000000u) != 0)
+ v18 = -v16;
+ v39 = _vm->_graphicsManager.Reel_Reduc(v39, v18);
+ v63 = v43;
+ v15 = v47;
+ }
+ if (v15 > 0) {
+ v19 = v15;
+ v20 = v15;
+ if (v15 < 0)
+ v20 = -v15;
+ v44 = v63;
+ v14 = _vm->_graphicsManager.Reel_Zoom(v14, v20);
+ v21 = v19;
+ if ((v19 & 0x80000000u) != 0)
+ v21 = -v19;
+ v39 = _vm->_graphicsManager.Reel_Zoom(v39, v21);
+ v63 = v44;
+ }
+ v22 = v63 + v39;
+ v23 = 0;
+ if (v14 > 0) {
+ do {
+ ++v62;
+ SMOOTH[v60].field0 = v62;
+ if (v63 != v22)
+ v63 = v63 + 1;
+ SMOOTH[v60++].field2 = v63;
+ ++v23;
+ } while (v23 < v14);
+ }
+ ++v52;
+ if (v52 == 48)
+ v52 = 36;
+ ++v56;
+ if (v62 >= a5 || a6 <= (int)v63)
+ v49 = 1;
+ } while (v49 != 1);
+ if (v56 > 5) {
+ v24 = v60;
+ SMOOTH[v24].field0 = -1;
+ SMOOTH[v24].field2 = -1;
+ _vm->_linesManager.SMOOTH_SENS = 4;
+ goto LABEL_85;
+ }
+ }
+ } else {
+ v51 = 12;
+ v59 = 0;
+ v55 = 0;
+ do {
+ v10 = _vm->_globals.Hopkins[v51].field2;
+ v42 = v63;
+ v11 = _vm->_graphicsManager.Reel_Reduc(_vm->_globals.Hopkins[v51].field0, 0x19u);
+ v38 = _vm->_graphicsManager.Reel_Reduc(v10, 0x19u);
+ v63 = v42;
+ v12 = 0;
+ if (v11 > 0) {
+ do {
+ --v62;
+ SMOOTH[v59].field0 = v62;
+ if ((uint16)v63 != (uint16)v42 + v38)
+ v63 = v63 - 1;
+ SMOOTH[v59++].field2 = v63;
+ ++v12;
+ } while (v12 < v11);
+ }
+ ++v51;
+ if (v51 == 24)
+ v51 = 12;
+ ++v55;
+ if (v62 <= a5 || a6 >= (int)v63)
+ v49 = 1;
+ } while (v49 != 1);
+ if (v55 > 5) {
+ v13 = 4 * v59;
+ SMOOTH[v13].field0 = -1;
+ SMOOTH[v13].field2 = -1;
+ _vm->_linesManager.SMOOTH_SENS = 8;
+ goto LABEL_85;
+ }
+ }
+ } else {
+ v50 = 12;
+ v58 = 0;
+ v54 = 0;
+ do {
+ v6 = _vm->_globals.Hopkins[v50].field2;
+ v41 = v63;
+ v7 = _vm->_graphicsManager.Reel_Reduc(_vm->_globals.Hopkins[v50].field0, 0x19u);
+ v37 = _vm->_graphicsManager.Reel_Reduc(v6, 0x19u);
+ v63 = v41;
+ v8 = 0;
+ if (v7 > 0) {
+ do {
+ ++v62;
+ SMOOTH[v58].field0 = v62;
+ if ((uint16)v63 != (uint16)v41 + v37)
+ v63 = v63 - 1;
+ SMOOTH[v58++].field2 = v63;
+ ++v8;
+ } while (v8 < v7);
+ }
+ ++v50;
+ if (v50 == 24)
+ v50 = 12;
+ ++v54;
+ if (v62 >= a5 || a6 >= (int)v63)
+ v49 = 1;
+ } while (v49 != 1);
+ if (v54 > 5) {
+ v9 = v58;
+ SMOOTH[v9].field0 = -1;
+ SMOOTH[v9].field2 = -1;
+ _vm->_linesManager.SMOOTH_SENS = 2;
+LABEL_85:
+ SMOOTH_X = v62;
+ SMOOTH_Y = v63;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int LinesManager::PLAN_TEST(int a1, int a2, int a3, int a4, int a5, int a6) {
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int16 *v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int16 *v20;
+ int v21;
+ int v22;
+ int v23;
+ int16 *v25;
+ int16 *v26;
+ int v27;
+ int v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33 = 0;
+ int v34 = 0;
+ int v35;
+ int v36;
+ int v37;
+ int v38;
+ int v39;
+ int v40;
+ int v41;
+ int v42;
+ int v43;
+ int v44;
+ int v45;
+ int v46;
+ int v47;
+ int v48;
+ int v49;
+ int v50;
+ int v51;
+ int v52;
+ int v53;
+
+ v41 = a3;
+ v40 = TEST_LIGNE(a1, a2 - 2, &v42, &v50, &v46);
+ v39 = TEST_LIGNE(a1, a2 + 2, &v43, &v51, &v47);
+ v38 = TEST_LIGNE(a1 - 2, a2, &v44, &v52, &v48);
+ v6 = TEST_LIGNE(a1 + 2, a2, &v45, &v53, &v49);
+ v37 = v6;
+ if (v40 == -1 && v39 == -1 && v38 == -1 && v6 == -1)
+ return -1;
+ if (a4 == -1 || a5 == -1) {
+ v8 = 0;
+ if (v40 != -1)
+ v8 = 1;
+ if (v8)
+ goto LABEL_60;
+ if (v39 != -1)
+ v8 = 2;
+ if (v8)
+ goto LABEL_60;
+ if (v38 != -1)
+ v8 = 3;
+ if (v8)
+ goto LABEL_60;
+ if (v6 != -1)
+ v8 = 4;
+ goto LABEL_59;
+ }
+ v28 = 100;
+ v7 = 100;
+ v35 = 100;
+ v27 = 100;
+ v8 = 0;
+ v9 = a4 - a5;
+ if (a4 - a5 < 0)
+ v9 = -v9;
+ v36 = v9;
+ if (v40 != -1) {
+ v10 = v50 - a5;
+ if (v50 - a5 < 0)
+ v10 = -v10;
+ v28 = v10;
+ }
+ if (v39 != -1) {
+ v11 = v51 - a5;
+ if (v11 < 0)
+ v11 = -v11;
+ v7 = v11;
+ }
+ if (v38 != -1) {
+ v12 = v52 - a5;
+ if (v12 < 0)
+ v12 = -v12;
+ v35 = v12;
+ }
+ if (v37 != -1) {
+ v13 = v53 - a5;
+ if (v13 < 0)
+ v13 = -v13;
+ v27 = v13;
+ }
+ if (v28 < v36 && v28 <= v7 && v28 <= v35 && v28 <= v27)
+ v8 = 1;
+ if (v8)
+ goto LABEL_60;
+ if (v36 > v7 && v28 >= v7 && v35 >= v7 && v27 >= v7)
+ v8 = 2;
+ if (v8)
+ goto LABEL_60;
+ if (v35 < v36 && v35 <= v28 && v35 <= v7 && v35 <= v27)
+ v8 = 3;
+ if (v8)
+ goto LABEL_60;
+ if (v27 >= v36 || v27 > v28 || v27 > v7 || v27 > v35) {
+LABEL_59:
+ if (v8)
+ goto LABEL_60;
+ return -1;
+ }
+ v8 = 4;
+LABEL_60:
+ if (v8 == 1) {
+ v34 = v40;
+ v33 = v42;
+ NV_LIGNEDEP = v50;
+ NV_LIGNEOFS = v46;
+ }
+ if (v8 == 2) {
+ v34 = v39;
+ v33 = v43;
+ NV_LIGNEDEP = v51;
+ NV_LIGNEOFS = v47;
+ }
+ if (v8 == 3) {
+ v34 = v38;
+ v33 = v44;
+ NV_LIGNEDEP = v52;
+ NV_LIGNEOFS = v48;
+ }
+ if (v8 == 4) {
+ v34 = v37;
+ v33 = v45;
+ NV_LIGNEDEP = v53;
+ NV_LIGNEOFS = v49;
+ }
+ if (v33 == 1) {
+ v14 = 0;
+ if (Ligne[v34].field0 > 0) {
+ v32 = v34;
+ v25 = _vm->_globals.essai0;
+ do {
+ v15 = Ligne[v32].lineData;
+ v16 = v15[2 * v14];
+ v29 = v15[2 * v14 + 1];
+ if (!a6) {
+ v17 = v41;
+ _vm->_globals.super_parcours[v17] = v16;
+ _vm->_globals.super_parcours[v17 + 1] = v29;
+ _vm->_globals.super_parcours[v17 + 2] = Ligne[v32].field6;
+ _vm->_globals.super_parcours[v17 + 3] = 0;
+ }
+ if (a6 == 1) {
+ v18 = v41;
+ v25[v18] = v16;
+ v25[v18 + 1] = v29;
+ v25[v18 + 2] = Ligne[v32].field6;
+ v25[v18 + 3] = 0;
+ }
+ v41 += 4;
+ ++v14;
+ } while (Ligne[v32].field0 > v14);
+ }
+ }
+ if (v33 == 2) {
+ v19 = Ligne[v34].field0 - 1;
+ if (v19 > -1) {
+ v31 = v34;
+ v26 = _vm->_globals.essai0;
+ do {
+ v20 = Ligne[v31].lineData;
+ v21 = v20[2 * v19];
+ v30 = v20[2 * v19 + 1];
+ if (a6) {
+ v23 = v41;
+ v26[v23] = v21;
+ v26[v23 + 1] = v30;
+ v26[v23 + 2] = Ligne[v31].field8;
+ v26[v23 + 3] = 0;
+ } else {
+ v22 = v41;
+ _vm->_globals.super_parcours[v22] = v21;
+ _vm->_globals.super_parcours[v22 + 1] = v30;
+ _vm->_globals.super_parcours[v22 + 2] = Ligne[v31].field8;
+ _vm->_globals.super_parcours[v22 + 3] = 0;
+ }
+ v41 += 4;
+ --v19;
+ } while (v19 > -1);
+ }
+ }
+ NV_POSI = v41;
+ return 1;
+}
+
+// Test line
+int LinesManager::TEST_LIGNE(int a1, int a2, int *a3, int *a4, int *a5) {
+ int i;
+ int v6;
+ int16 *v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int16 *v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int16 *v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int result;
+ int v23;
+ int v24 = 0;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+
+ v26 = 0;
+ v25 = _vm->_objectsManager.DERLIGNE + 1;
+ for (i = (int)(_vm->_objectsManager.DERLIGNE + 1); i < _vm->_linesManager.TOTAL_LIGNES + 1; i = v25) {
+ v6 = i;
+ v7 = Ligne[i].lineData;
+ v8 = Ligne[v6].field0;
+ v23 = v7[2 * v8 - 2];
+ v9 = v7[2 * v8 - 1];
+ if (v7[0] == a1 && a2 == v7[1]) {
+ v24 = v25;
+ v26 = 1;
+ *a3 = 1;
+ }
+ if (v23 == a1 && a2 == v9) {
+ v24 = v25;
+ v26 = 1;
+ *a3 = 2;
+ }
+ if (v26 == 1)
+ goto LABEL_12;
+ ++v25;
+ }
+ if (v26 != 1)
+ goto LABEL_33;
+LABEL_12:
+ if (*a3 == 1) {
+ v10 = v24;
+ v11 = Ligne[v10].field0;
+ v12 = Ligne[v10].lineData;
+ v13 = v12[2 * v11 - 2];
+ v14 = v12[2 * v11 - 1];
+ v15 = Ligne[v10].field6;
+ if (v15 == 5 || v15 == 1)
+ v14 += 2;
+ v16 = v24;
+ if (Ligne[v16].field6 == 3 || Ligne[v16].field8 == 7)
+ v13 += 2;
+ if (!colision2_ligne(v13, v14, &v28, &v27, 0, _vm->_objectsManager.DERLIGNE))
+ error("error");
+ *a4 = v27;
+ *a5 = v28;
+ }
+ if (v26 == 1 && *a3 == 2) {
+ v17 = Ligne[v25].lineData;
+ v18 = v17[0];
+ v19 = v17[1];
+ v20 = Ligne[v24].field6;
+ if (v20 == 5 || v20 == 1)
+ v19 -= 2;
+ v21 = v24;
+ if (Ligne[v21].field6 == 3 || Ligne[v21].field8 == 7)
+ v18 -= 2;
+ if (!colision2_ligne(v18, v19, &v28, &v27, 0, _vm->_objectsManager.DERLIGNE))
+ error("erreure");
+ *a4 = v27;
+ *a5 = v28;
+ }
+LABEL_33:
+ if (v26)
+ result = v24;
+ else
+ result = -1;
+ return result;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h
new file mode 100644
index 0000000000..20a1bccb65
--- /dev/null
+++ b/engines/hopkins/lines.h
@@ -0,0 +1,98 @@
+/* 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_LINES_H
+#define HOPKINS_LINES_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+struct LigneZoneItem {
+ int count;
+ int field2;
+ int16 *zoneData;
+};
+
+struct LigneItem {
+ int field0;
+ int field2;
+ int field4;
+ int field6;
+ int field8;
+ int16 *lineData;
+};
+
+struct SmoothItem {
+ int field0;
+ int field2;
+};
+
+class LinesManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ LigneZoneItem LigneZone[401];
+ LigneItem Ligne[400];
+ SmoothItem SMOOTH[4000];
+ int next_ligne;
+ int TOTAL_LIGNES;
+ int NV_LIGNEDEP;
+ int NV_LIGNEOFS;
+ int NV_POSI;
+ int NVPX;
+ int NVPY;
+ int SMOOTH_SENS;
+ int SMOOTH_X, SMOOTH_Y;
+public:
+ LinesManager();
+ void setParent(HopkinsEngine *vm);
+
+ void CLEAR_ZONE();
+ int ZONE_OBJET(int a1, int a2);
+ int OPTI_ZONE(int a1, int a2, int a3);
+ void RETIRE_LIGNE_ZONE(int idx);
+ void AJOUTE_LIGNE_ZONE(int idx, int a2, int a3, int a4, int a5, int a6);
+ void RESET_OBSTACLE();
+ void RETIRE_LIGNE(int idx);
+ void AJOUTE_LIGNE(int idx, int a2, int a3, int a4, int a5, int a6, int a7);
+ int colision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6);
+ int Scolision2_ligne(int a1, int a2, int *a3, int *a4, int a5, int a6);
+ void INIPARCOURS();
+ int CONTOURNE1(int a1, int a2, int a3, int a4, int a5, int16 *a6, int a7, int a8, int a9);
+ int CONTOURNE(int a1, int a2, int a3, int a4, int a5, int16 *a6, int a7);
+ int MIRACLE(int a1, int a2, int a3, int a4, int a5);
+ int GENIAL(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int16 *a8, int a9);
+ int16 *PARCOURS2(int a1, int a2, int a3, int a4);
+ int PARC_PERS(int a1, int a2, int a3, int a4, int a5, int a6, int a7);
+ int VERIF_SMOOTH(int a1, int a2, int a3, int a4);
+ int SMOOTH_MOVE(int a3, int a4, int a5, int a6);
+ int PLAN_TEST(int a1, int a2, int a3, int a4, int a5, int a6);
+ int TEST_LIGNE(int a1, int a2, int *a3, int *a4, int *a5);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_FONT_H */
diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp
new file mode 100644
index 0000000000..56b73c1fa1
--- /dev/null
+++ b/engines/hopkins/menu.cpp
@@ -0,0 +1,434 @@
+/* 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/scummsys.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/util.h"
+#include "hopkins/menu.h"
+#include "hopkins/dialogs.h"
+#include "hopkins/files.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/globals.h"
+#include "hopkins/events.h"
+#include "hopkins/graphics.h"
+#include "hopkins/sound.h"
+
+namespace Hopkins {
+
+void MenuManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+enum MenuSelection { MENU_NONE = 0, PLAY_GAME = 1, LOAD_GAME = 2, OPTIONS = 3, INTRODUCTION = 4, QUIT = 5 };
+
+int MenuManager::MENU() {
+ byte *spriteData = NULL;
+ MenuSelection menuIndex;
+ Common::Point mousePos;
+ signed int result;
+ int frame5Index;
+ int frame4Index;
+ int frame3Index;
+ int frame2Index;
+ int frame1Index;
+
+ result = 0;
+ while (!g_system->getEventManager()->shouldQuit()) {
+ _vm->_globals.FORET = 0;
+ _vm->_eventsManager.CASSE = false;
+ _vm->_globals.DESACTIVE_INVENT = true;
+ _vm->_globals.FLAG_VISIBLE = false;
+ _vm->_globals.SORTIE = 0;
+
+ for (int idx = 0; idx < 31; ++idx)
+ _vm->_globals.INVENTAIRE[idx] = 0;
+
+ memset(_vm->_globals.SAUVEGARDE, 0, 2000);
+ _vm->_objectsManager.AJOUTE_OBJET(14);
+ frame5Index = 0;
+ frame4Index = 0;
+ frame3Index = 0;
+ frame2Index = 0;
+ frame1Index = 0;
+
+
+ if (_vm->_globals.FR == 0)
+ _vm->_graphicsManager.LOAD_IMAGE("MENUAN");
+ else if (_vm->_globals.FR == 1)
+ _vm->_graphicsManager.LOAD_IMAGE("MENUFR");
+ else if (_vm->_globals.FR == 2)
+ _vm->_graphicsManager.LOAD_IMAGE("MENUES");
+
+ _vm->_graphicsManager.FADE_INW();
+ if (_vm->_globals.FR == 0)
+ _vm->_fileManager.CONSTRUIT_SYSTEM("MENUAN.SPR");
+ if (_vm->_globals.FR == 1)
+ _vm->_fileManager.CONSTRUIT_SYSTEM("MENUFR.SPR");
+ if (_vm->_globals.FR == 2)
+ _vm->_fileManager.CONSTRUIT_SYSTEM("MENUES.SPR");
+
+ spriteData = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_eventsManager.MOUSE_ON();
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+ _vm->_eventsManager.btsouris = 0;
+ _vm->_eventsManager.souris_n = 0;
+
+ for (;;) {
+ for (;;) {
+ _vm->_soundManager.WSOUND(28);
+
+ // Loop to make menu selection
+ bool selectionMade = false;
+ do {
+ if (g_system->getEventManager()->shouldQuit())
+ return -1;
+
+ menuIndex = MENU_NONE;
+ mousePos = Common::Point(_vm->_eventsManager.XMOUSE(), _vm->_eventsManager.YMOUSE());
+
+ if ((uint16)(mousePos.x - 232) <= 176) {
+ if ((uint16)(mousePos.y - 261) <= 23)
+ menuIndex = PLAY_GAME;
+ if ((uint16)(mousePos.y - 293) <= 23)
+ menuIndex = LOAD_GAME;
+ if ((uint16)(mousePos.y - 325) <= 22)
+ menuIndex = OPTIONS;
+ if ((uint16)(mousePos.y - 356) <= 23)
+ menuIndex = INTRODUCTION;
+
+ if ((uint16)(mousePos.y - 388) <= 23)
+ menuIndex = QUIT;
+ }
+
+ switch (menuIndex) {
+ case MENU_NONE:
+ frame1Index = 0;
+ frame2Index = 0;
+ frame3Index = 0;
+ frame4Index = 0;
+ frame5Index = 0;
+ break;
+ case PLAY_GAME:
+ frame1Index = 1;
+ frame2Index = 0;
+ frame3Index = 0;
+ frame4Index = 0;
+ frame5Index = 0;
+ break;
+ case LOAD_GAME:
+ frame1Index = 0;
+ frame2Index = 1;
+ frame3Index = 0;
+ frame4Index = 0;
+ frame5Index = 0;
+ break;
+ case OPTIONS:
+ frame1Index = 0;
+ frame2Index = 0;
+ frame3Index = 1;
+ frame4Index = 0;
+ frame5Index = 0;
+ break;
+ case INTRODUCTION:
+ frame1Index = 0;
+ frame2Index = 0;
+ frame3Index = 0;
+ frame4Index = 1;
+ frame5Index = 0;
+ break;
+ case QUIT:
+ frame1Index = 0;
+ frame2Index = 0;
+ frame3Index = 0;
+ frame4Index = 0;
+ frame5Index = 1;
+ }
+
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 259, frame1Index);
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 291, frame2Index + 2);
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 322, frame3Index + 4);
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 354, frame4Index + 6);
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 386, frame5Index + 8);
+ _vm->_eventsManager.VBL();
+
+ if (_vm->_eventsManager.BMOUSE() == 1 && menuIndex != MENU_NONE)
+ selectionMade = 1;
+ } while (!selectionMade);
+
+ if (menuIndex == PLAY_GAME) {
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 259, 10);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.delay(200);
+ result = 1;
+ }
+ if (menuIndex != LOAD_GAME)
+ break;
+
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 291, 11);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.delay(200);
+
+ _vm->_globals.SORTIE = -1;
+ _vm->_dialogsManager.CHARGE_PARTIE();
+
+ if (_vm->_globals.SORTIE != -1) {
+ result = _vm->_globals.SORTIE;
+ break;
+ }
+ _vm->_globals.SORTIE = 0;
+ }
+
+ if (menuIndex != OPTIONS)
+ break;
+
+ // Options menu item selected
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 322, 12);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.delay(200);
+
+ // Show the options dialog
+ _vm->_dialogsManager.showOptionsDialog();
+ }
+ if (menuIndex == INTRODUCTION) {
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 354, 13);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.delay(200);
+ _vm->INTRORUN();
+ continue;
+ }
+
+ if ( menuIndex == QUIT) {
+ _vm->_graphicsManager.AFFICHE_SPEED(spriteData, 230, 386, 14);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.delay(200);
+ result = -1;
+ }
+ break;
+ }
+
+ _vm->_globals.LIBERE_FICHIER(spriteData);
+ _vm->_globals.DESACTIVE_INVENT = false;
+ _vm->_globals.FLAG_VISIBLE = false;
+ _vm->_graphicsManager.FADE_OUTW();
+ return result;
+}
+
+void MenuManager::COMPUT_HOPKINS(int idx) {
+ // This is a text mode display?
+ warning("TODO: COMPUT_HOPKINS");
+ /*
+ int v2;
+ char *v3;
+ int v4;
+ char v5;
+ char *v6;
+ int v7;
+ char v8;
+ char *v9;
+ int v10;
+ char v11;
+ int v12;
+ Common::String s;
+ Common::String s2;
+
+ _vm->_eventsManager.ESC_KEY = 0;
+ v2 = 0;
+ _vm->_graphicsManager.RESET_SEGMENT_VESA();
+ setvideomode();
+ settextcolor(4);
+ _vm->_graphicsManager.videkey();
+ settextposition(2, 4);
+ if (idx == 1)
+ outtext((const char *)&MenuText[10]);
+ if (idx == 2)
+ outtext((const char *)&MenuText[0xDE]);
+ if (idx == 3)
+ outtext((const char *)&MenuText[0x1B2]);
+ settextcolor(1);
+ if (idx == 3) {
+ settextposition(10, 8);
+ outtext((const char *)&MenuText[0x286]);
+ }
+ settextposition(12, 28);
+ outtext((const char *)&MenuText[0x35A]);
+ settextposition(14, 35);
+ v3 = &s;
+ memset(&s, 0, 8u);
+ TXT4(280, 224, 8);
+ s = Sup_string;
+ if (idx == 1) {
+ s2 = "HOPKINS";
+ v4 = 8;
+ v5 = 1;
+ do {
+ if (!v4)
+ break;
+ v5 = *v3++ == *s2++;
+ --v4;
+ } while (v5);
+ if (v5)
+ v2 = 1;
+ }
+ if (idx == 2) {
+ v6 = &s;
+ s2 = "328MHZA";
+ v7 = 8;
+ v8 = 1;
+ do {
+ if (!v7)
+ break;
+ v8 = *v6++ == *s2++;
+ --v7;
+ } while (v8);
+ if (v8)
+ v2 = 1;
+ }
+ if (idx == 3) {
+ v9 = &s;
+ s2 = "ALLFREE";
+ v10 = 8;
+ v11 = 1;
+ do {
+ if (!v10)
+ break;
+ v11 = *v9++ == *s2++;
+ --v10;
+ } while (v11);
+ if (v11)
+ v2 = 1;
+ }
+ if (v2) {
+ while (1) {
+ ESC_KEY = 0;
+ _vm->_graphicsManager.videkey();
+ clearscreen();
+ settextcolor(4);
+ settextposition(2, 4);
+ if (idx == 1)
+ outtext((const char *)&MenuText[10]);
+ if (idx == 2)
+ outtext((const char *)&MenuText[0xDE]);
+ if (idx == 3)
+ outtext((const char *)&MenuText[0x1B2]);
+ settextcolor(15);
+ settextposition(8, 25);
+ settextcolor(15);
+ outtext2((const char *)&MenuText[0x502]);
+ settextposition(20, 25);
+ outtext2((const char *)&MenuText[0x5D6]);
+ if (idx == 1) {
+ settextposition(10, 25);
+ outtext2((const char *)&MenuText[0x6AA]);
+ settextposition(12, 25);
+ outtext2((const char *)&MenuText[0x77E]);
+ settextposition(14, 25);
+ outtext2((const char *)&MenuText[0x852]);
+ settextposition(16, 25);
+ outtext2((const char *)&MenuText[0x926]);
+ }
+ if (idx == 2) {
+ _vm->_graphicsManager.videkey();
+ settextposition(10, 25);
+ outtext2((const char *)&MenuText[0x95A]);
+ settextposition(12, 25);
+ outtext2((const char *)&MenuText[0xACE]);
+ settextposition(14, 25);
+ outtext2((const char *)&MenuText[0xBA2]);
+ settextposition(16, 25);
+ outtext2((const char *)&MenuText[0xC76]);
+ settextposition(18, 25);
+ outtext2((const char *)&MenuText[0xD4A]);
+ }
+ do {
+ v12 = (byte)keywin(v2, s2);
+ v2 = 0;
+ if ((uint16)(v12 - 48) <= 8u)
+ v2 = 1;
+ } while (v2 != 1);
+ if (v12 == 48)
+ break;
+ if (v12 == 49) {
+ GAMES(s2);
+ } else if (idx == 1) {
+ _vm->_graphicsManager.videkey();
+ clearscreen();
+ settextcolor(4);
+ settextposition(2, 4);
+ outtext((const char *)&MenuText[10]);
+ settextcolor(15);
+ if (v12 == 50)
+ LIT_TEXTE(1);
+ if (v12 == 51)
+ LIT_TEXTE(2);
+ if (v12 == 52)
+ LIT_TEXTE(3);
+ if (v12 == 53)
+ LIT_TEXTE(4);
+ } else if (idx == 2) {
+ clearscreen();
+ settextcolor(4);
+ settextposition(2, 4);
+ outtext((const char *)&MenuText[0xDE]);
+ settextcolor(15);
+ if (v12 == 50)
+ LIT_TEXTE(6);
+ if (v12 == 51)
+ LIT_TEXTE(7);
+ if (v12 == 52)
+ LIT_TEXTE(8);
+ if (v12 == 53)
+ LIT_TEXTE(9);
+ if (v12ii == 54) {
+ LIT_TEXTE(10);
+ _vm->_globals.SAUVEGARDE->data[svField270] = 4;
+ }
+ }
+ }
+ _vm->_graphicsManager.DD_Lock();
+ Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ RESTORE_POLICE();
+ } else {
+ settextcolor(4);
+ settextposition(16, 25);
+ outtext((const char *)&MenuText[0x42E]);
+ _vm->_eventsManager.VBL();
+ memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x4AFFFu);
+ _vm->_graphicsManager.DD_Lock();
+ Cls_Video();
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.DD_VBL();
+ RESTORE_POLICE();
+ _vm->_eventsManager.MOUSE_OFF();
+ }
+ if (idx == 1)
+ _vm->_globals.SORTIE = 13;
+ if ((uint16)(idx - 2) <= 1u)
+ _vm->_globals.SORTIE = 14;
+ return _vm->_graphicsManager.RESET_SEGMENT_VESA();
+ */
+}
+
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/menu.h b/engines/hopkins/menu.h
new file mode 100644
index 0000000000..58788fca46
--- /dev/null
+++ b/engines/hopkins/menu.h
@@ -0,0 +1,48 @@
+/* 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_MENU_H
+#define HOPKINS_MENU_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/error.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+class MenuManager {
+private:
+ HopkinsEngine *_vm;
+
+ byte MenuTxt[10600];
+public:
+ void setParent(HopkinsEngine *vm);
+
+ int MENU();
+ void COMPUT_HOPKINS(int a1);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_MENU_H */
diff --git a/engines/hopkins/module.mk b/engines/hopkins/module.mk
new file mode 100644
index 0000000000..109104f229
--- /dev/null
+++ b/engines/hopkins/module.mk
@@ -0,0 +1,28 @@
+MODULE := engines/hopkins
+
+MODULE_OBJS := \
+ anim.o \
+ debugger.o \
+ detection.o \
+ dialogs.o \
+ events.o \
+ files.o \
+ font.o \
+ graphics.o \
+ globals.o \
+ hopkins.o \
+ lines.o \
+ menu.o \
+ objects.o \
+ saveload.o \
+ script.o \
+ sound.o \
+ talk.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_HOPKINS), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
new file mode 100644
index 0000000000..bc592b34ce
--- /dev/null
+++ b/engines/hopkins/objects.cpp
@@ -0,0 +1,5824 @@
+/* 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 "graphics/palette.h"
+#include "common/file.h"
+#include "common/rect.h"
+#include "engines/util.h"
+#include "hopkins/objects.h"
+#include "hopkins/dialogs.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+ObjectsManager::ObjectsManager() {
+ for (int i = 0; i < 6; ++i) {
+ Common::fill((byte *)&Sprite[i], (byte *)&Sprite[i] + sizeof(SpriteItem), 0);
+ }
+
+ PRIORITY = 0;
+ old_cadx = old_cady = old_cadi = 0;
+ cadx = cady = cadi = 0;
+ SL_X = SL_Y = 0;
+ I_old_x = I_old_y = 0;
+ g_old_x = g_old_y = 0;
+ FLAG_VISIBLE_EFFACE = 0;
+ SL_SPR = g_PTRNUL;
+ SL_SPR2 = g_PTRNUL;
+ sprite_ptr = g_PTRNUL;
+ S_old_spr = g_PTRNUL;
+ PERSO_ON = false;
+ SL_FLAG = false;
+ SL_MODE = false;
+ FLAG_VISIBLE = false;
+ DESACTIVE_CURSOR = 0;
+ BOBTOUS = false;
+ my_anim = 0;
+ NUMZONE = 0;
+ ARRET_PERSO_FLAG = 0;
+ ARRET_PERSO_NUM = 0;
+ FORCEZONE = 0;
+ CHANGEVERBE = 0;
+ verbe = 0;
+ Vold_taille = 0;
+ SPEED_FLAG = false;
+ SPEED_X = SPEED_Y = 0;
+ SPEED_IMAGE = 0;
+ SPEED_PTR = g_PTRNUL;
+ DERLIGNE = 0;
+ A_ANIM = 0;
+ MA_ANIM = 0;
+ MA_ANIM1 = 0;
+ A_DEPA = 0;
+ MAX_DEPA = 0;
+ MAX_DEPA1 = 0;
+ CH_TETE = 0;
+ T_RECTIF = 0;
+ DESACTIVE = false;
+ DEUXPERSO = false;
+ PERX = PERY = 0;
+ PERI = 0;
+ RECALL = 0;
+ PTAILLE = 0;
+ PEROFX = 0;
+ PEROFY = 0;
+ OBSSEUL = 0;
+ NVVERBE = 0;
+ NVZONE = 0;
+ S_old_ani = 0;
+ S_old_ret = 0;
+ nouveau_x = nouveau_y = 0;
+ nouveau_sens = 0;
+ nouveau_anim = 0;
+}
+
+void ObjectsManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+// Change Object
+byte *ObjectsManager::CHANGE_OBJET(int objIndex) {
+ byte *result = CAPTURE_OBJET(objIndex, 1);
+ _vm->_globals.Bufferobjet = result;
+ _vm->_globals.Nouv_objet = 1;
+ _vm->_globals.OBJET_EN_COURS = objIndex;
+ return result;
+}
+
+byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) {
+ byte *dataP;
+
+ dataP = 0;
+ int val1 = _vm->_globals.ObjetW[objIndex].field0;
+ int val2 = _vm->_globals.ObjetW[objIndex].field1;
+
+ if (mode == 1)
+ ++val2;
+ if (val1 != _vm->_globals.NUM_FICHIER_OBJ) {
+ if (_vm->_globals.ADR_FICHIER_OBJ != g_PTRNUL)
+ ObjectsManager::DEL_FICHIER_OBJ();
+ if (val1 == 1) {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("OBJET1.SPR");
+ _vm->_globals.ADR_FICHIER_OBJ = ObjectsManager::CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ }
+ _vm->_globals.NUM_FICHIER_OBJ = val1;
+ }
+
+ int width = ObjectsManager::Get_Largeur(_vm->_globals.ADR_FICHIER_OBJ, val2);
+ int height = ObjectsManager::Get_Hauteur(_vm->_globals.ADR_FICHIER_OBJ, val2);
+ _vm->_globals.OBJL = width;
+ _vm->_globals.OBJH = height;
+
+ switch (mode) {
+ case 0:
+ dataP = _vm->_globals.dos_malloc2(height * width);
+ if (dataP == g_PTRNUL)
+ error("CAPTURE_OBJET");
+
+ capture_mem_sprite(_vm->_globals.ADR_FICHIER_OBJ, dataP, val2);
+ break;
+
+ case 1:
+ sprite_alone(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.Bufferobjet, val2);
+ dataP = _vm->_globals.Bufferobjet;
+ break;
+
+ case 3:
+ capture_mem_sprite(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.INVENTAIRE_OBJET, val2);
+ dataP = _vm->_globals.INVENTAIRE_OBJET;
+ break;
+
+ default:
+ break;
+ }
+
+ return dataP;
+}
+
+// Delete Object
+void ObjectsManager::DELETE_OBJET(int objIndex) {
+ int v1;
+ int v2;
+ int i;
+
+ v1 = 0;
+ v2 = 0;
+ do {
+ ++v2;
+ if (_vm->_globals.INVENTAIRE[v2] == objIndex)
+ v1 = 1;
+ if (v2 > 32)
+ v1 = 1;
+ } while (v1 != 1);
+ if (v2 <= 32) {
+ if (v2 == 32) {
+ _vm->_globals.INVENTAIRE[32] = 0;
+ } else {
+ for (i = v2; i < 32; ++i)
+ _vm->_globals.INVENTAIRE[i] = _vm->_globals.INVENTAIRE[i + 1];
+ }
+ }
+ CHANGE_OBJET(14);
+
+}
+
+void ObjectsManager::set_offsetxy(byte *data, int idx, int xp, int yp, bool isSize) {
+ byte *startP = data + 3;
+ for (int i = idx; i; --i)
+ startP += READ_LE_UINT32(startP) + 16;
+
+ byte *rectP = startP + 8;
+ if (isSize == 1) {
+ // Set size
+ byte *pointP = rectP + 4;
+ WRITE_LE_UINT16(pointP, xp);
+ WRITE_LE_UINT16(pointP + 2, yp);
+ } else {
+ // Set position
+ WRITE_LE_UINT16(rectP, xp);
+ WRITE_LE_UINT16(rectP + 2, yp);
+ }
+}
+
+int ObjectsManager::get_offsetx(const byte *spriteData, int spriteIndex, bool isSize) {
+ const byte *v3 = spriteData + 3;
+ for (int i = spriteIndex; i; --i)
+ v3 += READ_LE_UINT32(v3) + 16;
+
+ const byte *v5 = v3 + 8;
+ int result = (int16)READ_LE_UINT16(v5);
+ if (isSize)
+ result = (int16)READ_LE_UINT16(v5 + 4);
+
+ return result;
+}
+
+int ObjectsManager::get_offsety(const byte *spriteData, int spriteIndex, bool isSize) {
+ const byte *v3 = spriteData + 3;
+ for (int i = spriteIndex; i; --i)
+ v3 += READ_LE_UINT32(v3) + 16;
+
+ const byte *v5 = v3 + 10;
+ int result = (int16)READ_LE_UINT16(v5);
+ if (isSize)
+ result = (int16)READ_LE_UINT16(v5 + 4);
+
+ return result;
+}
+
+// Get Width
+int ObjectsManager::Get_Largeur(const byte *objectData, int idx) {
+ const byte *rectP = objectData + 3;
+ for (int i = idx; i; --i)
+ rectP += READ_LE_UINT32(rectP) + 16;
+
+ return (int16)READ_LE_UINT16(rectP + 4);
+}
+
+// Get height
+int ObjectsManager::Get_Hauteur(const byte *objectData, int idx) {
+ const byte *rectP = objectData + 3;
+ for (int i = idx; i; --i)
+ rectP += READ_LE_UINT32(rectP) + 16;
+
+ return (int16)READ_LE_UINT16(rectP + 6);
+}
+
+int ObjectsManager::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 = (int16)READ_LE_UINT16(objP) * (int16)READ_LE_UINT16(objP + 2);
+
+ memcpy(sprite + 3, objP - 4, result + 16);
+ return result;
+}
+
+byte *ObjectsManager::DEL_FICHIER_OBJ() {
+ _vm->_globals.NUM_FICHIER_OBJ = 0;
+ if (_vm->_globals.ADR_FICHIER_OBJ != g_PTRNUL)
+ _vm->_globals.ADR_FICHIER_OBJ = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.ADR_FICHIER_OBJ);
+
+ byte *result = g_PTRNUL;
+ _vm->_globals.ADR_FICHIER_OBJ = g_PTRNUL;
+ return result;
+}
+
+// Load Sprite
+byte *ObjectsManager::CHARGE_SPRITE(const Common::String &file) {
+ _vm->_fileManager.DMESS1();
+ return _vm->_fileManager.CHARGE_FICHIER(file);
+}
+
+int ObjectsManager::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 = (int16)READ_LE_UINT16(objP) * (int16)READ_LE_UINT16(objP + 2);
+
+ memcpy(sprite, objP + 12, result);
+ return result;
+}
+
+// Add Object
+int ObjectsManager::AJOUTE_OBJET(int objIndex) {
+ bool flag = false;
+ int arrIndex = 0;
+ do {
+ ++arrIndex;
+ if (!_vm->_globals.INVENTAIRE[arrIndex])
+ flag = true;
+ if (arrIndex == 32)
+ flag = true;
+ } while (!flag);
+
+ _vm->_globals.INVENTAIRE[arrIndex] = objIndex;
+ return arrIndex;
+}
+
+// Display Sprite
+void ObjectsManager::AFF_SPRITES() {
+ int v1;
+ int v2;
+ int destX;
+ int destY;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v11;
+ uint16 *v12;
+ int v13;
+ int v20;
+ int v21;
+ int y1_1;
+ int y1_2;
+ int v25;
+ int v26;
+ int v27;
+ int x1_1;
+ int x1_2;
+ int v33;
+ int v34;
+ int v35;
+ uint16 arr[50];
+
+ // Handle copying any background areas that text are going to be drawn on
+ _vm->_globals.NBTRI = 0;
+ for (int idx = 0; idx <= 10; ++idx) {
+ if (_vm->_fontManager.ListeTxt[idx].enabled && _vm->_fontManager.Txt[idx].field3FC != 2) {
+ v1 = _vm->_fontManager.ListeTxt[idx].xp;
+ x1_1 = v1 - 2;
+
+ if ((int16)(v1 - 2) < _vm->_graphicsManager.min_x)
+ x1_1 = _vm->_graphicsManager.min_x;
+ v2 = _vm->_fontManager.ListeTxt[idx].yp;
+ y1_1 = v2 - 2;
+
+ if ((int16)(v2 - 2) < _vm->_graphicsManager.min_y)
+ y1_1 = _vm->_graphicsManager.min_y;
+ destX = v1 - 2;
+ if (destX < _vm->_graphicsManager.min_x)
+ destX = _vm->_graphicsManager.min_x;
+ destY = v2 - 2;
+ if (destY < _vm->_graphicsManager.min_y)
+ destY = _vm->_graphicsManager.min_y;
+
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, x1_1, y1_1,
+ _vm->_fontManager.ListeTxt[idx].width + 4, _vm->_fontManager.ListeTxt[idx].height + 4,
+ _vm->_graphicsManager.VESA_BUFFER,
+ destX, destY);
+ _vm->_fontManager.ListeTxt[idx].enabled = false;
+ }
+ }
+
+ if (!PERSO_ON) {
+ for (int idx = 0; idx < 5; ++idx) {
+ if (_vm->_globals.Liste[idx].field0) {
+ v6 = _vm->_globals.Liste[idx].field2;
+ x1_2 = v6 - 2;
+ if ((int16)(v6 - 2) < _vm->_graphicsManager.min_x)
+ x1_2 = _vm->_graphicsManager.min_x;
+ v7 = _vm->_globals.Liste[idx].field4;
+ y1_2 = v7 - 2;
+ if ((int16)(v7 - 2) < _vm->_graphicsManager.min_y)
+ y1_2 = _vm->_graphicsManager.min_y;
+ v8 = v6 - 2;
+ if (v8 < _vm->_graphicsManager.min_x)
+ v8 = _vm->_graphicsManager.min_x;
+ v9 = v7 - 2;
+ if (v9 < _vm->_graphicsManager.min_y)
+ v9 = _vm->_graphicsManager.min_y;
+
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, x1_2, y1_2,
+ _vm->_globals.Liste[idx].width + 4, _vm->_globals.Liste[idx].height + 4,
+ _vm->_graphicsManager.VESA_BUFFER, v8, v9);
+ _vm->_globals.Liste[idx].field0 = 0;
+ }
+ }
+ }
+
+ AFF_BOB_ANIM();
+ AFF_VBOB();
+
+ if (!PERSO_ON) {
+ // Handle drawing characters on the screen
+ for (int idx = 0; idx < 5; ++idx) {
+ _vm->_globals.Liste[idx].field0 = 0;
+ if (Sprite[idx].field0 == 1) {
+ CALCUL_SPRITE(idx);
+ if (Sprite[idx].field2A == 1)
+ AvantTri(TRI_SPRITE, idx, Sprite[idx].field32 + Sprite[idx].field2E);
+ }
+ }
+
+ if (_vm->_globals.CACHEFLAG)
+ VERIFCACHE();
+ }
+
+ if (PRIORITY == 1 && _vm->_globals.NBTRI) {
+ v33 = 1;
+ do {
+ arr[v33] = v33;
+ ++v33;
+ } while (v33 <= 48);
+
+ v25 = _vm->_globals.NBTRI;
+ do {
+ v27 = 0;
+ v34 = 1;
+ if (v25 > 1) {
+ v26 = _vm->_globals.NBTRI;
+
+ do {
+ v11 = arr[v34];
+ v12 = &arr[v34 + 1];
+ if (_vm->_globals.Tri[arr[v34]].priority > _vm->_globals.Tri[*v12].priority) {
+ arr[v34] = *v12;
+ *v12 = v11;
+ ++v27;
+ }
+ ++v34;
+ } while (v34 < v26);
+ }
+ } while (v27);
+
+ v35 = 1;
+ if (_vm->_globals.NBTRI + 1 > 1) {
+ do {
+ v13 = arr[v35];
+ switch (_vm->_globals.Tri[v13].triMode) {
+ case TRI_BOB:
+ DEF_BOB(_vm->_globals.Tri[v13].index);
+ break;
+ case TRI_SPRITE:
+ DEF_SPRITE(_vm->_globals.Tri[v13].index);
+ break;
+ case TRI_CACHE:
+ DEF_CACHE(_vm->_globals.Tri[v13].index);
+ break;
+ default:
+ break;
+ }
+ _vm->_globals.Tri[v13].triMode = TRI_NONE;
+ ++v35;
+ } while (v35 < _vm->_globals.NBTRI + 1);
+ }
+ } else {
+ if (_vm->_globals.NBTRI + 1 > 1) {
+ for (int idx = 1; idx < (_vm->_globals.NBTRI + 1); ++idx) {
+ switch (_vm->_globals.Tri[idx].triMode) {
+ case TRI_BOB:
+ DEF_BOB(_vm->_globals.Tri[idx].index);
+ break;
+ case TRI_SPRITE:
+ DEF_SPRITE(_vm->_globals.Tri[idx].index);
+ break;
+ case TRI_CACHE:
+ DEF_CACHE(_vm->_globals.Tri[idx].index);
+ break;
+ default:
+ break;
+ }
+ _vm->_globals.Tri[idx].triMode = TRI_NONE;
+ }
+ }
+ }
+
+ // Reset the Tri array
+ for (int idx = 0; idx < 50; ++idx) {
+ _vm->_globals.Tri[idx].triMode = TRI_NONE;
+ _vm->_globals.Tri[idx].index = 0;
+ _vm->_globals.Tri[idx].priority = 0;
+ _vm->_globals.Tri[idx].unused = 0;
+ }
+
+ _vm->_globals.NBTRI = 0;
+ if (_vm->_dialogsManager.AFFINVEN) {
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire, _vm->_dialogsManager.inventairex, _vm->_dialogsManager.inventairey, _vm->_dialogsManager.inventairel, _vm->_dialogsManager.inventaireh);
+ if (old_cadx && old_cady)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.inventaire2, old_cadx + 300, old_cady + 300, old_cadi + 1);
+ if (cadx && cady)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.inventaire2, cadx + 300, cady + 300, cadi);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_dialogsManager.inventairex, _vm->_dialogsManager.inventairey, _vm->_dialogsManager.inventairex + _vm->_dialogsManager.inventairel, _vm->_dialogsManager.inventairey + _vm->_dialogsManager.inventaireh);
+ }
+
+ if (SL_FLAG == true) {
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, SL_SPR, _vm->_eventsManager.start_x + 183, 60, 0x112u, 353);
+ if (SL_X && SL_Y)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, SL_SPR2, SL_X + _vm->_eventsManager.start_x + 300, SL_Y + 300, 0);
+
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 183, 60, _vm->_eventsManager.start_x + 457, 413);
+ }
+
+ // If the Options dialog is activated, draw the elements
+ if (_vm->_globals.OPTION_FLAG) {
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 464, 407, 0);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 657, 556, _vm->_globals.opt_vitesse);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 731, 495, _vm->_globals.opt_txt);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 731, 468, _vm->_globals.opt_voice);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 731, 441, _vm->_globals.opt_sound);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 731, 414, _vm->_globals.opt_music);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 600, 522, _vm->_globals.opt_anm);
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.OPTION_SPR,
+ _vm->_eventsManager.start_x + 611, 502, _vm->_globals.opt_scrspeed);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_eventsManager.start_x + 164, 107, _vm->_eventsManager.start_x + 498, 320);
+ }
+
+ // Loop to draw any on-screen text
+ for (int idx = 0; idx <= 10; ++idx) {
+ if (_vm->_fontManager.Txt[idx].textOn) {
+ if ((uint16)(_vm->_fontManager.Txt[idx].field3FC - 2) > 1)
+ _vm->_fontManager.BOITE(idx,
+ _vm->_fontManager.Txt[idx].messageId, _vm->_fontManager.Txt[idx].filename,
+ _vm->_eventsManager.start_x + _vm->_fontManager.Txt[idx].xp, _vm->_fontManager.Txt[idx].yp);
+ else
+ _vm->_fontManager.BOITE(
+ idx,
+ _vm->_fontManager.Txt[idx].messageId,
+ _vm->_fontManager.Txt[idx].filename,
+ _vm->_fontManager.Txt[idx].xp,
+ _vm->_fontManager.Txt[idx].yp);
+ _vm->_fontManager.ListeTxt[idx].enabled = true;
+
+ if ((uint16)(_vm->_fontManager.Txt[idx].field3FC - 2) > 1)
+ _vm->_fontManager.ListeTxt[idx].xp = _vm->_eventsManager.start_x + _vm->_fontManager.Txt[idx].xp;
+ else
+ _vm->_fontManager.ListeTxt[idx].xp = _vm->_fontManager.Txt[idx].xp;
+
+ _vm->_fontManager.ListeTxt[idx].yp = _vm->_fontManager.Txt[idx].yp;
+ _vm->_fontManager.ListeTxt[idx].width = _vm->_fontManager.Txt[idx].width;
+ _vm->_fontManager.ListeTxt[idx].height = _vm->_fontManager.Txt[idx].height;
+
+ if (_vm->_fontManager.ListeTxt[idx].xp < _vm->_graphicsManager.min_x)
+ _vm->_fontManager.ListeTxt[idx].xp = _vm->_graphicsManager.min_x - 1;
+ if (_vm->_fontManager.ListeTxt[idx].yp < _vm->_graphicsManager.min_y)
+ _vm->_fontManager.ListeTxt[idx].yp = _vm->_graphicsManager.min_y - 1;
+
+ v20 = _vm->_fontManager.ListeTxt[idx].xp;
+ if (_vm->_fontManager.ListeTxt[idx].width + v20 > _vm->_graphicsManager.max_x)
+ _vm->_fontManager.ListeTxt[idx].width = _vm->_graphicsManager.max_x - v20;
+ v21 = _vm->_fontManager.ListeTxt[idx].yp;
+ if (_vm->_fontManager.ListeTxt[idx].height + v21 > _vm->_graphicsManager.max_y)
+ _vm->_fontManager.ListeTxt[idx].height = _vm->_graphicsManager.max_y - v21;
+ if (_vm->_fontManager.ListeTxt[idx].width <= 0 || _vm->_fontManager.ListeTxt[idx].height <= 0)
+ _vm->_fontManager.ListeTxt[idx].enabled = false;
+ }
+ }
+
+ _vm->_dialogsManager.INVENT_ANIM();
+}
+
+void ObjectsManager::INIT_BOB() {
+ for (int idx = 0; idx < 35; ++idx) {
+ BOB_ZERO(idx);
+ }
+}
+
+void ObjectsManager::BOB_ZERO(int idx) {
+ BobItem &bob = _vm->_globals.Bob[idx];
+ Liste2Item &item = _vm->_globals.Liste2[idx];
+
+ bob.field0 = 0;
+ bob.spriteData = g_PTRNUL;
+ bob.xp = 0;
+ bob.yp = 0;
+ bob.frameIndex = 0;
+ bob.fieldE = 0;
+ bob.field10 = 0;
+ bob.field12 = 0;
+ bob.field14 = 0;
+ bob.field16 = 0;
+ bob.animData = g_PTRNUL;
+ bob.field1C = 0;
+ bob.field1E = 0;
+ bob.field20 = 0;
+ bob.field22 = 0;
+ bob.offsetY = 0;
+ bob.field26 = 0;
+ bob.field28 = 0;
+ bob.field2A = 0;
+ bob.field2C = 0;
+ bob.field30 = g_PTRNUL;
+ bob.field34 = 0;
+ bob.field36 = 0;
+ bob.field38 = 0;
+ bob.oldX2 = 0;
+
+ item.field0 = 0;
+ item.xp = 0;
+ item.yp = 0;
+ item.width = 0;
+ item.height = 0;
+}
+
+void ObjectsManager::DEF_BOB(int idx) {
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int xp;
+ int yp;
+
+ if (_vm->_globals.Bob[idx].isActive) {
+ xp = _vm->_globals.Bob[idx].oldX;
+ yp = _vm->_globals.Bob[idx].oldY;
+
+ if (_vm->_globals.Bob[idx].isSprite)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Bob[idx].spriteData,
+ xp + 300, yp + 300, _vm->_globals.Bob[idx].frameIndex);
+ else
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER,
+ _vm->_globals.Bob[idx].spriteData, xp + 300, yp + 300, _vm->_globals.Bob[idx].frameIndex,
+ _vm->_globals.Bob[idx].field4A, _vm->_globals.Bob[idx].oldY2,
+ _vm->_globals.Bob[idx].field38);
+
+ _vm->_globals.Liste2[idx].field0 = 1;
+ _vm->_globals.Liste2[idx].xp = xp;
+ _vm->_globals.Liste2[idx].yp = yp;
+
+ _vm->_globals.Liste2[idx].width = _vm->_globals.Bob[idx].oldWidth;
+ _vm->_globals.Liste2[idx].height = _vm->_globals.Bob[idx].oldHeight;
+
+ v5 = _vm->_globals.Liste2[idx].xp;
+ v6 = _vm->_graphicsManager.min_x;
+ if (v5 < _vm->_graphicsManager.min_x) {
+ _vm->_globals.Liste2[idx].width -= _vm->_graphicsManager.min_x - v5;
+ _vm->_globals.Liste2[idx].xp = v6;
+ }
+
+ v7 = _vm->_globals.Liste2[idx].yp;
+ v8 = _vm->_graphicsManager.min_y;
+ if (v7 < _vm->_graphicsManager.min_y) {
+ _vm->_globals.Liste2[idx].height -= _vm->_graphicsManager.min_y - v7;
+ _vm->_globals.Liste2[idx].yp = v8;
+ }
+
+ v9 = _vm->_globals.Liste2[idx].xp;
+ if (_vm->_globals.Liste2[idx].width + v9 > _vm->_graphicsManager.max_x)
+ _vm->_globals.Liste2[idx].width = _vm->_graphicsManager.max_x - v9;
+ v10 = _vm->_globals.Liste2[idx].yp;
+ if (_vm->_globals.Liste2[idx].height + v10 > _vm->_graphicsManager.max_y)
+ _vm->_globals.Liste2[idx].height = _vm->_graphicsManager.max_y - v10;
+
+ if (_vm->_globals.Liste2[idx].width <= 0 || _vm->_globals.Liste2[idx].height <= 0)
+ _vm->_globals.Liste2[idx].field0 = 0;
+
+ if (_vm->_globals.Liste2[idx].field0 == 1)
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(
+ _vm->_globals.Liste2[idx].xp,
+ _vm->_globals.Liste2[idx].yp,
+ _vm->_globals.Liste2[idx].xp + _vm->_globals.Liste2[idx].width,
+ _vm->_globals.Liste2[idx].yp + _vm->_globals.Liste2[idx].height);
+ }
+}
+
+void ObjectsManager::BOB_VISU(int idx) {
+ int v1;
+ const byte *data;
+ int16 v6;
+ int16 offsetY;
+ int16 v8;
+ int16 v9;
+
+ PRIORITY = 1;
+
+ if (!_vm->_globals.Bob[idx].field0) {
+ BOB_ZERO(idx);
+
+ data = _vm->_globals.Bqe_Anim[idx].data;
+ v1 = (int16)READ_LE_UINT16(data);
+ v9 = (int16)READ_LE_UINT16(data + 2);
+ v8 = (int16)READ_LE_UINT16(data + 4);
+ offsetY = (int16)READ_LE_UINT16(data + 6);
+ v6 = (int16)READ_LE_UINT16(data + 8);
+ if ((int16)READ_LE_UINT16(data)) {
+ if (_vm->_globals.Bank[v1].field4) {
+ if (!v9)
+ v9 = 1;
+ if (!v6)
+ v6 = -1;
+
+ if ((int16)READ_LE_UINT16(data + 24)) {
+ _vm->_globals.Bob[idx].isSprite = false;
+
+ if (_vm->_globals.Bank[v1].fileHeader == 1) {
+ _vm->_globals.Bob[idx].isSprite = true;
+ _vm->_globals.Bob[idx].field36 = 0;
+ _vm->_globals.Bob[idx].field38 = 0;
+ }
+
+ _vm->_globals.Bob[idx].animData = _vm->_globals.Bqe_Anim[idx].data;
+ _vm->_globals.Bob[idx].field0 = 10;
+ _vm->_globals.Bob[idx].spriteData = _vm->_globals.Bank[v1].data;
+
+ _vm->_globals.Bob[idx].field1E = v9;
+ _vm->_globals.Bob[idx].field20 = v6;
+ _vm->_globals.Bob[idx].field22 = v8;
+ _vm->_globals.Bob[idx].offsetY = offsetY;
+ }
+ }
+ }
+ }
+}
+
+void ObjectsManager::BOB_OFF(int idx) {
+ if (_vm->_globals.Bob[idx].field0 == 3)
+ _vm->_globals.Bob[idx].field0 = 4;
+ else if (_vm->_globals.Bob[idx].field0 == 10)
+ _vm->_globals.Bob[idx].field0 = 11;
+}
+
+void ObjectsManager::BOB_OFFSET(int idx, int v) {
+ _vm->_globals.Bob[idx].oldX2 = v;
+}
+
+void ObjectsManager::BOB_ADJUST(int idx, int v) {
+ _vm->_globals.Bob[idx].oldX2 = v;
+}
+
+void ObjectsManager::BOB_OFFSETY(int idx, int v) {
+ _vm->_globals.Bob[idx].offsetY = v;
+}
+
+void ObjectsManager::SCBOB(int idx) {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+
+ v1 = idx;
+ if (_vm->_globals.Cache[idx].fieldA > 0) {
+ v8 = 0;
+ do {
+ v1 = v8;
+ if (_vm->_globals.Bob[v1].field0) {
+ if (!_vm->_globals.Bob[v8].field16) {
+ if (!_vm->_globals.Bob[v8].field34) {
+ if ( _vm->_globals.Bob[v8].frameIndex != 250) {
+ v2 = _vm->_globals.Bob[v8].oldWidth;
+ v9 = _vm->_globals.Bob[v8].oldX + _vm->_globals.Bob[v8].oldWidth;
+ v6 = _vm->_globals.Bob[v8].oldY + _vm->_globals.Bob[v8].oldHeight;
+ v3 =_vm->_globals.Cache[idx].field0;
+ v4 =_vm->_globals.Cache[idx].field4;
+ v7 =_vm->_globals.Cache[idx].field6 + v3;
+ v1 =_vm->_globals.Cache[idx].field14 +_vm->_globals.Cache[idx].field8 + v4;
+
+ if (v6 > v4) {
+ if (v6 < v1) {
+ v1 = 0;
+ if (v9 >= v3 && v9 <= (_vm->_globals.Cache[idx].field6 + v3)) {
+ ++_vm->_globals.Cache[idx].fieldA;
+ v1 = 1;
+ }
+
+ if (!(uint16)v1) {
+ if (v2 >= v3 && v7 >= v2) {
+ ++_vm->_globals.Cache[idx].fieldA;
+ v1 = 1;
+ }
+ if (!(uint16)v1) {
+ if ( v7 >= v2 && v2 >= v3 ) {
+ ++_vm->_globals.Cache[idx].fieldA;
+ v1 = 1;
+ }
+ if (!(uint16)v1) {
+ if (v2 >= v3 && v9 <= v7) {
+ ++_vm->_globals.Cache[idx].fieldA;
+ v1 = 1;
+ }
+ if (!(uint16)v1 && v2 <= v3 && v9 >= v7)
+ ++_vm->_globals.Cache[idx].fieldA;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ++v8;
+ } while (v8 <= 20);
+ }
+}
+
+void ObjectsManager::CALCUL_BOB(int idx) {
+ int result;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v13;
+ int v14;
+ int v15;
+ int v17;
+ int v20;
+ int v21;
+ int v22;
+
+ _vm->_globals.Bob[idx].isActive = false;
+ if (_vm->_globals.Bob[idx].isSprite) {
+ _vm->_globals.Bob[idx].field38 = 0;
+ _vm->_globals.Bob[idx].field36 = 0;
+ }
+
+ result = _vm->_globals.Bob[idx].frameIndex;
+ if (result != 250) {
+ if (_vm->_globals.Bob[idx].field38) {
+ v4 = get_offsetx(_vm->_globals.Bob[idx].spriteData, result, 1);
+ v22 = v4;
+ v15 = v4;
+ v5 = get_offsety(_vm->_globals.Bob[idx].spriteData, _vm->_globals.Bob[idx].frameIndex, 1);
+ } else {
+ v3 = get_offsetx(_vm->_globals.Bob[idx].spriteData, result, 0);
+ v22 = v3;
+ v15 = v3;
+ v5 = get_offsety(_vm->_globals.Bob[idx].spriteData, _vm->_globals.Bob[idx].frameIndex, 0);
+ }
+
+ v17 = v5;
+ v6 = v5;
+ v21 = 0;
+ v20 = 0;
+ v7 = _vm->_globals.Bob[idx].field36;
+
+ if (v7 < 0) {
+ v7 = v7;
+ if (v7 < 0)
+ v7 = -v7;
+ v20 = v7;
+ if (v7 > 95)
+ v20 = 95;
+ }
+ if (_vm->_globals.Bob[idx].field36 > 0)
+ v21 = _vm->_globals.Bob[idx].field36;
+ if (v21) {
+ if (v15 >= 0) {
+ v22 = _vm->_graphicsManager.Reel_Zoom(v15, v21);
+ } else {
+ v8 = v15;
+ if (v15 < 0)
+ v8 = -v15;
+ v15 = v8;
+ v22 = -_vm->_graphicsManager.Reel_Zoom(v8, v21);
+ }
+ if (v6 >= 0) {
+ v17 = _vm->_graphicsManager.Reel_Zoom(v6, v21);
+ } else {
+ v9 = v15;
+ if (v15 < 0)
+ v9 = -v15;
+ v6 = v9;
+ v17 = -_vm->_graphicsManager.Reel_Zoom(v9, v21);
+ }
+ }
+
+ if (v20) {
+ if (v15 >= 0) {
+ v22 = _vm->_graphicsManager.Reel_Reduc(v15, v20);
+ } else {
+ v10 = v15;
+ if (v15 < 0)
+ v10 = -v15;
+ v15 = v10;
+ v22 = -_vm->_graphicsManager.Reel_Reduc(v10, v20);
+ }
+ if (v6 >= 0) {
+ v17 = _vm->_graphicsManager.Reel_Reduc(v6, v20);
+ } else {
+ v11 = v15;
+ if (v15 < 0)
+ v11 = -v15;
+ v17 = -_vm->_graphicsManager.Reel_Reduc(v11, v20);
+ }
+ }
+
+ v13 = _vm->_globals.Bob[idx].xp - v22;
+ v14 = _vm->_globals.Bob[idx].yp - v17;
+ _vm->_globals.Bob[idx].isActive = true;
+ _vm->_globals.Bob[idx].oldX = v13;
+ _vm->_globals.Bob[idx].oldY = v14;
+ _vm->_globals.Bob[idx].oldY2 = v21;
+ _vm->_globals.Bob[idx].field4A = v20;
+
+ _vm->_globals.Liste2[idx].field0 = 1;
+ _vm->_globals.Liste2[idx].xp = v13;
+ _vm->_globals.Liste2[idx].yp = v14;
+
+ int width = Get_Largeur(_vm->_globals.Bob[idx].spriteData, _vm->_globals.Bob[idx].frameIndex);
+ int height = Get_Hauteur(_vm->_globals.Bob[idx].spriteData, _vm->_globals.Bob[idx].frameIndex);
+
+ if (v21) {
+ width = _vm->_graphicsManager.Reel_Zoom(width, v21);
+ height = _vm->_graphicsManager.Reel_Zoom(height, v21);
+ }
+ if (v20) {
+ height = _vm->_graphicsManager.Reel_Reduc(height, v20);
+ width = _vm->_graphicsManager.Reel_Reduc(width, v20);
+ }
+
+ _vm->_globals.Liste2[idx].width = width;
+ _vm->_globals.Liste2[idx].height = height;
+ _vm->_globals.Bob[idx].oldWidth = width;
+ _vm->_globals.Bob[idx].oldHeight = height;
+ }
+}
+
+void ObjectsManager::VERIFCACHE() {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+
+ v8 = 0;
+ do {
+ if (_vm->_globals.Cache[v8].fieldA > 0) {
+ v7 = _vm->_globals.Cache[v8].fieldA;
+ v10 = 0;
+ do {
+ if (Sprite[v10].field0 == 1) {
+ if (Sprite[v10].spriteIndex != 250) {
+ v1 = Sprite[v10].field2C;
+ v11 = Sprite[v10].field30 + v1;
+ v2 = Sprite[v10].field32 + Sprite[v10].field2E;
+ v6 = _vm->_globals.Cache[v8].field0;
+ v3 = _vm->_globals.Cache[v8].field4;
+ v9 = _vm->_globals.Cache[v8].field6 + v6;
+
+ if (v2 > v3) {
+ if (v2 < (_vm->_globals.Cache[v8].field14 + _vm->_globals.Cache[v8].field8 + v3)) {
+ v4 = 0;
+ if (v11 >= v6 && v11 <= v9) {
+ ++_vm->_globals.Cache[v8].fieldA;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (v6 <= v1 && v9 >= v1) {
+ ++_vm->_globals.Cache[v8].fieldA;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (v9 >= v1 && v6 <= v1) {
+ ++_vm->_globals.Cache[v8].fieldA;
+ v4 = 1;
+ }
+ if (!v4) {
+ if (v6 <= v1 && v11 <= v9) {
+ ++_vm->_globals.Cache[v8].fieldA;
+ v4 = 1;
+ }
+ if (!v4 && v6 >= v1 && v11 >= v9)
+ ++_vm->_globals.Cache[v8].fieldA;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ ++v10;
+ } while (v10 <= 4);
+
+ SCBOB(v8);
+ if (_vm->_globals.Cache[v8].fieldA == v7) {
+ if (_vm->_globals.Cache[v8].field10 == 1) {
+ _vm->_globals.Cache[v8].field10 = 0;
+ _vm->_globals.Cache[v8].fieldA = 1;
+ }
+ } else {
+ v5 = _vm->_globals.Cache[v8].field14 + _vm->_globals.Cache[v8].field8 +
+ _vm->_globals.Cache[v8].field4;
+ if (v5 > 440)
+ v5 = 500;
+
+ AvantTri(TRI_CACHE, v8, v5);
+ _vm->_globals.Cache[v8].fieldA = 1;
+ _vm->_globals.Cache[v8].field10 = 1;
+ }
+ }
+ ++v8;
+ } while (v8 <= 19);
+}
+
+void ObjectsManager::DEF_SPRITE(int idx) {
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+
+ v2 = idx;
+ if (Sprite[v2].field2A) {
+ v3 = Sprite[v2].field2C;
+ v4 = Sprite[v2].field2E;
+ if (Sprite[v2].field28)
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, Sprite[v2].spriteData,
+ v3 + 300, v4 + 300, Sprite[v2].spriteIndex);
+ else
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, Sprite[v2].spriteData,
+ v3 + 300, v4 + 300, Sprite[v2].spriteIndex, Sprite[v2].field36, Sprite[v2].field34, Sprite[v2].fieldE);
+
+ v5 = idx;
+ v6 = idx;
+ _vm->_globals.Liste[v5].width = Sprite[v6].field30;
+ _vm->_globals.Liste[v5].height = Sprite[v6].field32;
+ v7 = _vm->_globals.Liste[v5].field2;
+ v8 = _vm->_graphicsManager.min_x;
+
+ if (v7 < _vm->_graphicsManager.min_x) {
+ _vm->_globals.Liste[v5].width -= _vm->_graphicsManager.min_x - v7;
+ _vm->_globals.Liste[v5].field2 = v8;
+ }
+
+ v9 = _vm->_globals.Liste[v5].field4;
+ v10 = _vm->_graphicsManager.min_y;
+ if (v9 < _vm->_graphicsManager.min_y) {
+ _vm->_globals.Liste[v5].height -= _vm->_graphicsManager.min_y - v9;
+ _vm->_globals.Liste[v5].field4 = v10;
+ }
+ v11 = _vm->_globals.Liste[v5].field2;
+ if (_vm->_globals.Liste[v5].width + v11 > _vm->_graphicsManager.max_x)
+ _vm->_globals.Liste[v5].width = _vm->_graphicsManager.max_x - v11;
+ v12 = _vm->_globals.Liste[v5].field4;
+ if ( _vm->_globals.Liste[v5].height + v12 > _vm->_graphicsManager.max_y)
+ _vm->_globals.Liste[v5].height = _vm->_graphicsManager.max_y - v12;
+ if ( _vm->_globals.Liste[v5].width <= 0 || _vm->_globals.Liste[v5].height <= 0)
+ _vm->_globals.Liste[v5].field0 = 0;
+
+ v13 = idx;
+ if (_vm->_globals.Liste[v13].field0 == 1)
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(
+ _vm->_globals.Liste[v13].field2,
+ _vm->_globals.Liste[v13].field4,
+ _vm->_globals.Liste[v13].field2 + _vm->_globals.Liste[v13].width,
+ _vm->_globals.Liste[v13].field4 + _vm->_globals.Liste[v13].height);
+ }
+}
+
+void ObjectsManager::DEF_CACHE(int idx) {
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.CACHE_BANQUE[1],
+ _vm->_globals.Cache[idx].field0 + 300, _vm->_globals.Cache[idx].field4 + 300,
+ _vm->_globals.Cache[idx].field2);
+
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_globals.Cache[idx].field0,
+ _vm->_globals.Cache[idx].field4,
+ _vm->_globals.Cache[idx].field0 + _vm->_globals.Cache[idx].field6,
+ _vm->_globals.Cache[idx].field4 + _vm->_globals.Cache[idx].field8);
+}
+
+// Compute Sprite
+void ObjectsManager::CALCUL_SPRITE(int idx) {
+ int width, height;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v15;
+ int v16;
+ int v17;
+ int v22;
+
+ Sprite[idx].field2A = 0;
+ int spriteIndex = Sprite[idx].spriteIndex;
+ if (spriteIndex != 250) {
+ if (Sprite[idx].fieldE) {
+ v5 = get_offsetx(Sprite[idx].spriteData, spriteIndex, 1);
+ v22 = Sprite[idx].field12 + v5;
+ v4 = Sprite[idx].field12 + v5;
+ v6 = get_offsety(Sprite[idx].spriteData, Sprite[idx].spriteIndex, 1);
+ } else {
+ v3 = get_offsetx(Sprite[idx].spriteData, spriteIndex, 0);
+ v22 = Sprite[idx].field12 + v3;
+ v4 = Sprite[idx].field12 + v3;
+ v6 = get_offsety(Sprite[idx].spriteData, Sprite[idx].spriteIndex, 0);
+ }
+
+ v9 = Sprite[idx].field14 + v6;
+ v7 = v9;
+ v8 = v9;
+ int zoomPercent = 0;
+ int reducePercent = 0;
+
+ v9 = Sprite[idx].fieldC;
+ if (v9 < 0) {
+ v9 = v9;
+ if (v9 < 0)
+ v9 = -v9;
+ reducePercent = v9;
+ if (v9 > 95)
+ reducePercent = 95;
+ }
+ if (Sprite[idx].fieldC > 0)
+ zoomPercent = Sprite[idx].fieldC;
+
+ if (zoomPercent) {
+ if (v4 >= 0) {
+ v22 = _vm->_graphicsManager.Reel_Zoom(v4, zoomPercent);
+ } else {
+ v10 = v4;
+
+ if (v4 < 0)
+ v10 = -v4;
+ v4 = v10;
+ v22 = -_vm->_graphicsManager.Reel_Zoom(v10, zoomPercent);
+ }
+
+ if (v8 >= 0) {
+ v7 = _vm->_graphicsManager.Reel_Zoom(v8, zoomPercent);
+ } else {
+ v11 = v4;
+ if (v4 < 0)
+ v11 = -v4;
+ v8 = v11;
+ v7 = -_vm->_graphicsManager.Reel_Zoom(v11, zoomPercent);
+ }
+ }
+ if (reducePercent) {
+ if (v4 >= 0) {
+ v22 = _vm->_graphicsManager.Reel_Reduc(v4, reducePercent);
+ } else {
+ v12 = v4;
+ if (v4 < 0)
+ v12 = -v4;
+ v4 = v12;
+ v22 = -_vm->_graphicsManager.Reel_Reduc(v12, reducePercent);
+ }
+ if (v8 >= 0) {
+ v7 = _vm->_graphicsManager.Reel_Reduc(v8, reducePercent);
+ } else {
+ v13 = v4;
+ if (v4 < 0)
+ v13 = -v4;
+ v7 = -_vm->_graphicsManager.Reel_Reduc(v13, reducePercent);
+ }
+ }
+
+ v15 = Sprite[idx].spritePos.x - v22;
+ v16 = Sprite[idx].spritePos.y - v7;
+ Sprite[idx].field2C = v15;
+ Sprite[idx].field2E = v16;
+ Sprite[idx].field2A = 1;
+ Sprite[idx].field34 = zoomPercent;
+ Sprite[idx].field36 = reducePercent;
+
+ v17 = idx;
+ _vm->_globals.Liste[v17].field0 = 1;
+ _vm->_globals.Liste[v17].field2 = v15;
+ _vm->_globals.Liste[v17].field4 = v16;
+ width = Get_Largeur(Sprite[idx].spriteData, Sprite[idx].spriteIndex);
+ height = Get_Hauteur(Sprite[idx].spriteData, Sprite[idx].spriteIndex);
+
+ if (zoomPercent) {
+ width = _vm->_graphicsManager.Reel_Zoom(width, zoomPercent);
+ height = _vm->_graphicsManager.Reel_Zoom(height, zoomPercent);
+ }
+
+ if (reducePercent) {
+ height = _vm->_graphicsManager.Reel_Reduc(height, reducePercent);
+ width = _vm->_graphicsManager.Reel_Reduc(width, reducePercent);
+ }
+
+ Sprite[idx].field30 = width;
+ Sprite[idx].field32 = height;
+ }
+}
+
+// Before Sort
+int ObjectsManager::AvantTri(TriMode triMode, int index, int priority) {
+ int result;
+
+ ++_vm->_globals.NBTRI;
+ if (_vm->_globals.NBTRI > 48)
+ error("NBTRI too high");
+
+ result = _vm->_globals.NBTRI;
+ _vm->_globals.Tri[result].triMode = triMode;
+ _vm->_globals.Tri[result].index = index;
+ _vm->_globals.Tri[result].priority = priority;
+
+ return result;
+}
+
+// Display BOB Anim
+void ObjectsManager::AFF_BOB_ANIM() {
+ int v1;
+ int v2;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v18;
+ int v19;
+ byte *v20;
+ byte *v21;
+ int v22;
+ int v24;
+ int v26;
+ int v27;
+ int v28;
+
+ int idx = 0;
+ do {
+ ++idx;
+ if (idx <= 20 && PERSO_ON == true) {
+ _vm->_globals.Bob[idx].field1C = 0;
+ continue;
+ }
+
+ if (_vm->_globals.Bob[idx].field0 == 10) {
+ _vm->_globals.Bob[idx].field1C = 0;
+ v1 = _vm->_globals.Bob[idx].field20;
+ if (v1 == -1)
+ v1 = 50;
+ if (_vm->_globals.Bob[idx].animData == g_PTRNUL || _vm->_globals.Bob[idx].field16 || v1 <= 0)
+ goto LABEL_38;
+
+ v2 = _vm->_globals.Bob[idx].field14;
+ if (_vm->_globals.Bob[idx].field12 == v2) {
+ _vm->_globals.Bob[idx].field1C = 1;
+ } else {
+ _vm->_globals.Bob[idx].field14 = v2 + 1;
+ _vm->_globals.Bob[idx].field1C = 0;
+ }
+
+ if (_vm->_globals.Bob[idx].field1C != 1)
+ goto LABEL_38;
+
+ v20 = _vm->_globals.Bob[idx].animData + 20;
+ v24 = _vm->_globals.Bob[idx].field10;
+ _vm->_globals.Bob[idx].xp = (int16)READ_LE_UINT16(v20 + 2 * v24);
+ if (_vm->_globals.BL_ANIM[idx].v1 == 1)
+ _vm->_globals.Bob[idx].xp = _vm->_globals.BL_ANIM[idx].v2;
+ if ( PERSO_ON == true && idx > 20 )
+ _vm->_globals.Bob[idx].xp += _vm->_eventsManager.start_x;
+
+ _vm->_globals.Bob[idx].yp = (int16)READ_LE_UINT16(v20 + 2 * v24 + 2);
+ _vm->_globals.Bob[idx].field12 = (int16)READ_LE_UINT16(v20 + 2 * v24 + 4);
+ _vm->_globals.Bob[idx].field36 = (int16)READ_LE_UINT16(v20 + 2 * v24 + 6);
+ _vm->_globals.Bob[idx].frameIndex = *(v20 + 2 * v24 + 8);
+ _vm->_globals.Bob[idx].field38 = *(v20 + 2 * v24 + 9);
+ _vm->_globals.Bob[idx].field10 += 5;
+ v5 = _vm->_globals.Bob[idx].field12;
+
+ if (v5 > 0) {
+ v6 = v5 / _vm->_globals.vitesse;
+ _vm->_globals.Bob[idx].field12 = v5 / _vm->_globals.vitesse;
+ if (v6 > 0) {
+LABEL_37:
+ _vm->_globals.Bob[idx].field14 = 1;
+LABEL_38:
+ v12 = idx;
+
+ if ((unsigned int)(_vm->_globals.Bob[v12].field1E - 1) <= 1u)
+ _vm->_globals.Bob[v12].field1C = 1;
+ continue;
+ }
+
+ _vm->_globals.Bob[idx].field12 = 1;
+ }
+ if (!_vm->_globals.Bob[idx].field12) {
+ v7 = _vm->_globals.Bob[idx].field20;
+ if (v7 > 0)
+ _vm->_globals.Bob[idx].field20 = v7 - 1;
+ v8 = _vm->_globals.Bob[idx].field20;
+ if (v8 != -1 && v8 <= 0) {
+ _vm->_globals.Bob[idx].field0 = 11;
+ } else {
+ _vm->_globals.Bob[idx].field10 = 0;
+ v21 = _vm->_globals.Bob[idx].animData + 20;
+ _vm->_globals.Bob[idx].xp = (int16)READ_LE_UINT16(v21);
+
+ if (_vm->_globals.BL_ANIM[idx].v1 == 1)
+ _vm->_globals.Bob[idx].xp = _vm->_globals.BL_ANIM[idx].v2;
+ if (PERSO_ON == true && idx > 20)
+ _vm->_globals.Bob[idx].xp += _vm->_eventsManager.start_x;
+
+ _vm->_globals.Bob[idx].yp = (int16)READ_LE_UINT16(v21 + 2);
+ _vm->_globals.Bob[idx].field12 = (int16)READ_LE_UINT16(v21 + 4);
+ _vm->_globals.Bob[idx].field36 = (int16)READ_LE_UINT16(v21 + 6);
+ _vm->_globals.Bob[idx].frameIndex = *(v21 + 8);
+ _vm->_globals.Bob[idx].field38 = *(v21 + 9);
+ _vm->_globals.Bob[idx].field10 += 5;
+ v10 = _vm->_globals.Bob[idx].field12;
+
+ if (v10 > 0) {
+ v11 = v10 / _vm->_globals.vitesse;
+ _vm->_globals.Bob[idx].field12 = v10 / _vm->_globals.vitesse;
+ if (v11 <= 0)
+ _vm->_globals.Bob[idx].field12 = 1;
+ }
+ }
+ }
+
+ goto LABEL_37;
+ }
+ } while (idx != 35);
+
+ if (!PERSO_ON && BOBTOUS == true) {
+ v26 = 0;
+ do {
+ v13 = v26;
+ if (_vm->_globals.Bob[v13].field0 == 10 && !_vm->_globals.Bob[v13].field16)
+ _vm->_globals.Bob[v13].field1C = 1;
+ ++v26;
+ } while (v26 != 35);
+ }
+
+ BOBTOUS = false;
+ v27 = 0;
+
+ do {
+ ++v27;
+ if (v27 > 20 || PERSO_ON != true) {
+ if (_vm->_globals.Bob[v27].field0 == 10) {
+ if (_vm->_globals.Bob[v27].field1C == 1) {
+ v14 = _vm->_globals.Bob[v27].field1E;
+
+ if (v14 != 2) {
+ if (v14 != 4) {
+ if (_vm->_globals.Liste2[v27].field0) {
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN,
+ _vm->_globals.Liste2[v27].xp, _vm->_globals.Liste2[v27].yp,
+ _vm->_globals.Liste2[v27].width, _vm->_globals.Liste2[v27].height,
+ _vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Liste2[v27].xp,
+ _vm->_globals.Liste2[v27].yp);
+ _vm->_globals.Liste2[v27].field0 = 0;
+ }
+ }
+ }
+ }
+ }
+
+ v22 = v27;
+ if (_vm->_globals.Bob[v22].field0 == 11) {
+ if (_vm->_globals.Liste2[v27].field0) {
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN,
+ _vm->_globals.Liste2[v27].xp, _vm->_globals.Liste2[v27].yp,
+ _vm->_globals.Liste2[v27].width, _vm->_globals.Liste2[v27].height,
+ _vm->_graphicsManager.VESA_BUFFER,
+ _vm->_globals.Liste2[v27].xp, _vm->_globals.Liste2[v27].yp);
+ _vm->_globals.Liste2[v27].field0 = 0;
+ }
+
+ _vm->_globals.Bob[v22].field0 = 0;
+ }
+ }
+ } while (v27 != 35);
+
+ v28 = 0;
+ do {
+ ++v28;
+ v18 = v28;
+ _vm->_globals.Bob[v18].oldY = 0;
+ if (_vm->_globals.Bob[v18].field0 == 10 && !_vm->_globals.Bob[v18].field16 && _vm->_globals.Bob[v18].field1C == 1) {
+ CALCUL_BOB(v28);
+ int v = _vm->_globals.Bob[v18].oldHeight + _vm->_globals.Bob[v18].oldY;
+ v19 = _vm->_globals.Bob[v18].oldX2 + v;
+
+ if (v19 > 450)
+ v19 = 600;
+
+ if (_vm->_globals.Bob[v18].isActive)
+ AvantTri(TRI_BOB, v28, v19);
+ }
+ } while (v28 != 35);
+}
+
+// Display VBOB
+void ObjectsManager::AFF_VBOB() {
+ int width, height;
+
+ int idx = 0;
+ do {
+ if (_vm->_globals.VBob[idx].field4 == 4) {
+ width = Get_Largeur(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx].frameIndex);
+ height = Get_Hauteur(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx].frameIndex);
+
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_SCREEN,
+ _vm->_globals.VBob[idx].surface, _vm->_globals.VBob[idx].xp,
+ _vm->_globals.VBob[idx].yp, width, height);
+
+ _vm->_graphicsManager.Restore_Mem(
+ _vm->_graphicsManager.VESA_BUFFER, _vm->_globals.VBob[idx].surface,
+ _vm->_globals.VBob[idx].xp, _vm->_globals.VBob[idx].yp,
+ width, height);
+
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(
+ _vm->_globals.VBob[idx].xp, _vm->_globals.VBob[idx].yp,
+ _vm->_globals.VBob[idx].xp + width, height + _vm->_globals.VBob[idx].yp);
+
+ if (_vm->_globals.VBob[idx].surface != g_PTRNUL)
+ _vm->_globals.dos_free2(_vm->_globals.VBob[idx].surface);
+
+ _vm->_globals.VBob[idx].field4 = 0;
+ _vm->_globals.VBob[idx].surface = g_PTRNUL;
+ _vm->_globals.VBob[idx].spriteData = g_PTRNUL;
+ _vm->_globals.VBob[idx].xp = 0;
+ _vm->_globals.VBob[idx].yp = 0;
+ _vm->_globals.VBob[idx].oldX = 0;
+ _vm->_globals.VBob[idx].oldY = 0;
+ _vm->_globals.VBob[idx].frameIndex = 0;
+ _vm->_globals.VBob[idx].oldFrameIndex = 0;
+ _vm->_globals.VBob[idx].oldSpriteData = g_PTRNUL;
+ }
+
+ if (_vm->_globals.VBob[idx].field4 == 3) {
+ width = Get_Largeur(_vm->_globals.VBob[idx].oldSpriteData, _vm->_globals.VBob[idx].oldFrameIndex);
+ height = Get_Hauteur(_vm->_globals.VBob[idx].oldSpriteData, _vm->_globals.VBob[idx].oldFrameIndex);
+
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_SCREEN,
+ _vm->_globals.VBob[idx].surface, _vm->_globals.VBob[idx].oldX,
+ _vm->_globals.VBob[idx].oldY,
+ width, height);
+
+ _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER,
+ _vm->_globals.VBob[idx].surface, _vm->_globals.VBob[idx].oldX,
+ _vm->_globals.VBob[idx].oldY, width, height);
+
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_globals.VBob[idx].oldX,
+ _vm->_globals.VBob[idx].oldY, _vm->_globals.VBob[idx].oldX + width,
+ _vm->_globals.VBob[idx].oldY + height);
+
+ _vm->_globals.VBob[idx].field4 = 1;
+ _vm->_globals.VBob[idx].oldSpriteData = _vm->_globals.VBob[idx].spriteData;
+
+ if (_vm->_globals.VBob[idx].surface != g_PTRNUL)
+ _vm->_globals.dos_free2(_vm->_globals.VBob[idx].surface);
+
+ _vm->_globals.VBob[idx].surface = g_PTRNUL;
+ _vm->_globals.VBob[idx].oldX = _vm->_globals.VBob[idx].xp;
+ _vm->_globals.VBob[idx].oldY = _vm->_globals.VBob[idx].yp;
+ _vm->_globals.VBob[idx].oldFrameIndex = _vm->_globals.VBob[idx].frameIndex;
+ }
+
+ if (_vm->_globals.VBob[idx].field4 == 1) {
+ width = Get_Largeur(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx].frameIndex);
+ height = Get_Hauteur(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx].frameIndex);
+
+ if (_vm->_globals.VBob[idx].surface != g_PTRNUL)
+ _vm->_globals.dos_free2(_vm->_globals.VBob[idx].surface);
+
+ byte *surface = _vm->_globals.dos_malloc2(height * width);
+ _vm->_globals.VBob[idx].surface = surface;
+
+ _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_SCREEN, surface,
+ _vm->_globals.VBob[idx].xp, _vm->_globals.VBob[idx].yp, width, height);
+
+ byte *v10 = _vm->_globals.VBob[idx].spriteData;
+ if (*v10 == 78) {
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_SCREEN, v10,
+ _vm->_globals.VBob[idx].xp + 300, _vm->_globals.VBob[idx].yp + 300,
+ _vm->_globals.VBob[idx].frameIndex,
+ 0, 0, 0);
+
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER,
+ _vm->_globals.VBob[idx].spriteData,
+ _vm->_globals.VBob[idx].xp + 300, _vm->_globals.VBob[idx].yp + 300,
+ _vm->_globals.VBob[idx].frameIndex,
+ 0, 0, 0);
+ } else {
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER,
+ v10, _vm->_globals.VBob[idx].xp + 300, _vm->_globals.VBob[idx].yp + 300,
+ _vm->_globals.VBob[idx].frameIndex);
+
+ _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_SCREEN, _vm->_globals.VBob[idx].spriteData,
+ _vm->_globals.VBob[idx].xp + 300, _vm->_globals.VBob[idx].yp + 300,
+ _vm->_globals.VBob[idx].frameIndex);
+ }
+
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_globals.VBob[idx].xp,
+ _vm->_globals.VBob[idx].yp , _vm->_globals.VBob[idx].xp + width,
+ _vm->_globals.VBob[idx].yp + height);
+ _vm->_globals.VBob[idx].field4 = 2;
+ }
+ ++idx;
+ } while ( idx <= 29 );
+}
+
+int ObjectsManager::XSPR(int idx) {
+ if (idx > 5)
+ error("request of the Coord. x a sprite > MAX_SPRITE.");
+ return Sprite[idx].spritePos.x;
+}
+
+int ObjectsManager::YSPR(int idx) {
+ if (idx > 5)
+ error("request of the Coord. y a sprite > MAX_SPRITE.");
+ return Sprite[idx].spritePos.y;
+}
+
+void ObjectsManager::SPRITE_NOW(const byte *spriteData, int a2, int a3, int a4, int a5, int a6, int a7, int a8) {
+ _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, spriteData, a2, a3, a5, a6, a7, a8);
+}
+
+void ObjectsManager::CLEAR_SPR() {
+ int idx;
+
+ idx = 0;
+ do {
+ Sprite[idx].field1C = g_PTRNUL;
+ Sprite[idx].spriteData = g_PTRNUL;
+ Sprite[idx].field0 = 0;
+ ++idx;
+ } while (idx <= 4);
+
+ idx = 0;
+ do {
+ _vm->_globals.Liste[idx].field0 = 0;
+ _vm->_globals.Liste[idx].field2 = 0;
+ _vm->_globals.Liste[idx].field4 = 0;
+ _vm->_globals.Liste[idx].width = 0;
+ _vm->_globals.Liste[idx].height = 0;
+ _vm->_globals.Liste[idx].fieldA = 0;
+ ++idx;
+ } while (idx <= 4);
+}
+
+void ObjectsManager::SPRITE_ON(int idx) {
+ if (idx > 5)
+ error("Attempt to display a sprite > MAX_SPRITE.");
+
+ Sprite[idx].field0 = 1;
+}
+
+void ObjectsManager::SPRITE(const byte *spriteData, int xp, int yp, int idx, int spriteIndex, int a6, int a7, int a8, int a9) {
+ if (idx > 5)
+ error("Attempt to display a sprite > MAX_SPRITE.");
+ Sprite[idx].spriteData = spriteData;
+ Sprite[idx].spritePos = Common::Point(xp, yp);
+ Sprite[idx].spriteIndex = spriteIndex;
+ Sprite[idx].fieldC = a6;
+ Sprite[idx].field12 = a8;
+ Sprite[idx].field14 = a9;
+ Sprite[idx].field1C = g_PTRNUL;
+ Sprite[idx].field20 = 0;
+ Sprite[idx].field24 = 0;
+ Sprite[idx].field26 = 0;
+ Sprite[idx].field22 = 0;
+ Sprite[idx].field0 = 0;
+ Sprite[idx].field28 = 0;
+ Sprite[idx].fieldE = a7;
+ if (*spriteData == 'R' && *(spriteData + 1) == 'L' && *(spriteData + 2) == 'E')
+ Sprite[idx].field28 = 1;
+
+ if (Sprite[idx].field28 == 1) {
+ Sprite[idx].fieldC = 0;
+ Sprite[idx].fieldE = 0;
+ }
+}
+
+void ObjectsManager::SPRITE2(const byte *spriteData, int idx, byte *a3, int a4, int a5) {
+ Sprite[idx].spriteData = spriteData;
+ Sprite[idx].field1C = a3;
+ Sprite[idx].field20 = a4;
+ Sprite[idx].field24 = 0;
+ Sprite[idx].field26 = 0;
+ Sprite[idx].fieldC = 0;
+ Sprite[idx].fieldE = 0;
+ Sprite[idx].field0 = 1;
+ Sprite[idx].field22 = 0;
+ Sprite[idx].field14 = a5;
+ if (*spriteData == 'R' && *(spriteData + 1) == 'L' && *(spriteData + 2) == 'E')
+ Sprite[idx].field28 = 1;
+
+ if (Sprite[idx].field28 == 1) {
+ Sprite[idx].fieldC = 0;
+ Sprite[idx].fieldE = 0;
+ }
+}
+
+void ObjectsManager::SPRITE_OFF(int idx) {
+ Sprite[idx].field0 = 3;
+ if (Sprite[idx].field1C != g_PTRNUL)
+ _vm->_globals.dos_free2(Sprite[idx].field1C);
+ Sprite[idx].field1C = g_PTRNUL;
+}
+
+void ObjectsManager::SPRITE_GEL(int idx) {
+ Sprite[idx].field0 = 3;
+}
+
+int ObjectsManager::SXSPR(int idx) {
+ if (idx > 5)
+ error("request of the size of a sprite x > MAX_SPRITE.");
+ return Get_Largeur(Sprite[idx].spriteData, Sprite[idx].spriteIndex);
+}
+
+int ObjectsManager::SYSPR(int idx) {
+ if (idx > 5)
+ error("request of the size of a sprite y > MAX_SPRITE.");
+ return Get_Hauteur(Sprite[idx].spriteData, Sprite[idx].spriteIndex);
+}
+
+int ObjectsManager::POSISPR(int idx) {
+ return Sprite[idx].field22 / 6;
+}
+
+void ObjectsManager::SETPOSISPR(int idx, int a2) {
+ Sprite[idx].field22 = 6 * a2;
+ Sprite[idx].field24 = 0;
+ Sprite[idx].field26 = 0;
+}
+
+void ObjectsManager::SETXSPR(int idx, int xp) {
+ if (idx > 5)
+ error("Set the Coord. x a sprite> MAX_SPRITE.");
+ Sprite[idx].spritePos.x = xp;
+}
+
+void ObjectsManager::SETANISPR(int idx, int spriteIndex) {
+ if (idx > 5)
+ error("Set the Coord. x a sprite> MAX_SPRITE.");
+
+ Sprite[idx].spriteIndex = spriteIndex;
+}
+
+void ObjectsManager::SETYSPR(int idx, int yp) {
+ if ( idx > 5 )
+ error("Set the Coord. y a sprite> MAX_SPRITE.");
+ Sprite[idx].spritePos.y = yp;
+}
+
+// Set Sprite Size
+void ObjectsManager::SETTAILLESPR(int idx, int a2) {
+ if (idx > 5)
+ error("Set the Coord. there a sprite> MAX_SPRITE.");
+
+ if (Sprite[idx].field28 != 1)
+ Sprite[idx].fieldC = a2;
+}
+
+void ObjectsManager::SETFLIPSPR(int idx, int a2) {
+ if (Sprite[idx].field28 != 1) {
+ if (idx > 5)
+ error("Set the Coord. there a sprite> MAX_SPRITE.");
+ Sprite[idx].fieldE = a2;
+ }
+}
+
+void ObjectsManager::VERIFZONE() {
+ int v0;
+ int v1;
+ int v2;
+ uint16 v3;
+ int v4;
+
+ v0 = _vm->_eventsManager.XMOUSE();
+ v1 = _vm->_eventsManager.YMOUSE();
+ v2 = v1;
+ if (_vm->_globals.PLAN_FLAG
+ || _vm->_eventsManager.start_x >= v0
+ || (v1 = _vm->_graphicsManager.ofscroll + 54, v0 >= v1)
+ || (v1 = v2 - 1, (uint16)(v2 - 1) > 0x3Bu)) {
+ if (FLAG_VISIBLE == true)
+ FLAG_VISIBLE_EFFACE = 4;
+ FLAG_VISIBLE = false;
+ } else {
+ FLAG_VISIBLE = true;
+ }
+ if (FORCEZONE == 1) {
+ _vm->_globals.compteur_71 = 100;
+ _vm->_globals.old_zone_68 = -1;
+ _vm->_globals.old_x_69 = -200;
+ _vm->_globals.old_y_70 = -220;
+ FORCEZONE = 0;
+ }
+ v3 = _vm->_globals.compteur_71 + 1;
+ _vm->_globals.compteur_71 = v3;
+ if (v3 > 1u) {
+ if (_vm->_globals.NOMARCHE || (_vm->_globals.chemin == (int16 *)g_PTRNUL) || v3 > 4u) {
+ _vm->_globals.compteur_71 = 0;
+ if (_vm->_globals.old_x_69 != v0 || _vm->_globals.old_y_70 != v2) {
+ v4 = MZONE();
+ } else {
+ v4 = _vm->_globals.old_zone_68;
+ }
+ if (_vm->_globals.old_zone_68 != v4) {
+ _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ if (_vm->_globals.zozo_73 == 1) {
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_globals.zozo_73 = 0;
+ return;
+ }
+ if (_vm->_globals.old_zone_68 != v4)
+ goto LABEL_54;
+ }
+ if (v4 != -1) {
+LABEL_54:
+ if (v4 != -1
+ && ((_vm->_globals.ZONEP[v4].field6)
+ || _vm->_globals.ZONEP[v4].field7
+ || _vm->_globals.ZONEP[v4].field8
+ || _vm->_globals.ZONEP[v4].field9
+ || _vm->_globals.ZONEP[v4].fieldA
+ || _vm->_globals.ZONEP[v4].fieldB
+ || _vm->_globals.ZONEP[v4].fieldC
+ || _vm->_globals.ZONEP[v4].fieldD
+ || _vm->_globals.ZONEP[v4].fieldE
+ || _vm->_globals.ZONEP[v4].fieldF)) {
+ if (_vm->_globals.old_zone_68 != v4) {
+ _vm->_fontManager.DOS_TEXT(5, _vm->_globals.ZONEP[v4].field12, _vm->_globals.FICH_ZONE, 0, 430, 20, 25, 0, 0, 252);
+ _vm->_fontManager.TEXTE_ON(5);
+ _vm->_globals.zozo_73 = 1;
+ }
+ _vm->_globals.force_to_data_0 += 25;
+ if (_vm->_globals.force_to_data_0 > 100)
+ _vm->_globals.force_to_data_0 = 0;
+ _vm->_graphicsManager.SETCOLOR4(251, _vm->_globals.force_to_data_0, _vm->_globals.force_to_data_0,
+ _vm->_globals.force_to_data_0);
+ if (_vm->_eventsManager.btsouris == 4) {
+ v1 = 5 * v4;
+ if (_vm->_globals.ZONEP[v4].field6 == 2) {
+ _vm->_eventsManager.CHANGE_MOUSE(16);
+ _vm->_eventsManager.btsouris = 16;
+ verbe = 16;
+ }
+ }
+ } else {
+ _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ }
+ }
+ NUMZONE = v4;
+ _vm->_globals.old_x_69 = v0;
+ _vm->_globals.old_y_70 = v2;
+ _vm->_globals.old_zone_68 = v4;
+ if (_vm->_globals.NOMARCHE == true) {
+ if (_vm->_eventsManager.btsouris == 4) {
+ v1 = v4 + 1;
+ if ((uint16)(v4 + 1) > 1u)
+ BTDROITE();
+ }
+ }
+ if ((_vm->_globals.PLAN_FLAG == true && v4 == -1) || !v4) {
+ verbe = 0;
+ _vm->_eventsManager.btsouris = 0;
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+ }
+ }
+ }
+}
+
+void ObjectsManager::GOHOME() {
+ int16 v0;
+ int16 v1;
+ int16 v3;
+ int16 v4;
+ unsigned int v5;
+ unsigned int v6;
+ unsigned int v7;
+ unsigned int v8;
+ int16 v9;
+ int16 v10;
+ unsigned int v11;
+ unsigned int v12;
+ unsigned int v13;
+ unsigned int v14;
+ int v15;
+ int16 v16;
+ unsigned int v17;
+ unsigned int v18;
+ int v19;
+ int16 v20;
+ unsigned int v21;
+ unsigned int v22;
+ int16 v23;
+ int16 v24;
+ unsigned int v25;
+ unsigned int v26;
+ unsigned int v27;
+ unsigned int v28;
+ int16 v29;
+ int16 v30;
+ unsigned int v31;
+ unsigned int v32;
+ unsigned int v33;
+ unsigned int v34;
+ int16 v35;
+ int16 v36;
+ unsigned int v37;
+ unsigned int v38;
+ unsigned int v39;
+ unsigned int v40;
+ int16 v41;
+ int16 v42;
+ unsigned int v43;
+ unsigned int v44;
+ unsigned int v45;
+ unsigned int v46;
+ int16 v47;
+ int16 v48;
+ int16 v49;
+ int v50;
+ int16 v51;
+ int16 v52;
+ int16 v54;
+ int v55;
+ int16 v56;
+ int16 v57;
+ int16 v58;
+
+ v0 = 0;
+ v58 = 0;
+ v1 = 0;
+
+ if (_vm->_globals.chemin == (int16 *)g_PTRNUL)
+ return;
+ if (_vm->_globals.Compteur > 1) {
+ --_vm->_globals.Compteur;
+ return;
+ }
+ _vm->_globals.Compteur = 0;
+ if (_vm->_globals.g_old_sens == -1) {
+ VERIFTAILLE();
+ nouveau_x = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ nouveau_y = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ nouveau_sens = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ nouveau_anim = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ if (nouveau_x != -1 || nouveau_y != -1) {
+ _vm->_globals.g_old_sens = nouveau_sens;
+ _vm->_globals.g_old_sens2 = nouveau_sens;
+ _vm->_globals.g_old_anim = 0;
+ g_old_x = nouveau_x;
+ g_old_y = nouveau_y;
+ } else {
+ SETANISPR(0, _vm->_globals.g_old_sens + 59);
+ _vm->_globals.ACTION_SENS = 0;
+ if (_vm->_globals.GOACTION == 1)
+ v54 = _vm->_globals.SAUVEGARDE->data[svField2];
+ else
+ v54 = NUMZONE;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ VERIFTAILLE();
+ SETFLIPSPR(0, 0);
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.g_old_sens = -1;
+ if (v54 > 0) {
+ v55 = v54;
+ if (_vm->_globals.ZONEP[v55].destX) {
+ v56 = _vm->_globals.ZONEP[v55].destY;
+ if (v56) {
+ if (v56 != 31) {
+ v57 = _vm->_globals.ZONEP[v55].field4;
+ if (v57 == -1) {
+ _vm->_globals.ZONEP[v55].destX = 0;
+ _vm->_globals.ZONEP[v55].destY = 0;
+ _vm->_globals.ZONEP[v55].field4 = 0;
+ } else {
+ SETANISPR(0, v57);
+ _vm->_globals.ACTION_SENS = _vm->_globals.ZONEP[v55].field4 - 59;
+ }
+ }
+ }
+ }
+ }
+ }
+LABEL_241:
+ _vm->_globals.Compteur = 0;
+ return;
+ }
+ if (_vm->_globals.g_old_sens == 3) {
+ if ((uint16)(_vm->_globals.g_old_anim - 24) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v3 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field0;
+ v4 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+
+ if (Sprite[0].fieldC < 0) {
+ v5 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v5 = -Sprite[0].fieldC;
+ v3 = _vm->_graphicsManager.Reel_Reduc(v3, v5);
+ v6 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v6 = -Sprite[0].fieldC;
+ v4 = _vm->_graphicsManager.Reel_Reduc(v4, v6);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v7 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v7 = -Sprite[0].fieldC;
+ v3 = _vm->_graphicsManager.Reel_Zoom(v3, v7);
+ v8 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v8 = -Sprite[0].fieldC;
+ v4 = _vm->_graphicsManager.Reel_Zoom(v4, v8);
+ }
+ v0 = v3 + g_old_x;
+ v58 = g_old_y + v4;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 35)
+ goto LABEL_23;
+ }
+ v1 = 24;
+LABEL_23:
+ _vm->_globals.Compteur = 5 / _vm->_globals.vitesse;
+ }
+ if (_vm->_globals.g_old_sens != 7)
+ goto LABEL_43;
+ if ((uint16)(_vm->_globals.g_old_anim - 24) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v9 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field0;
+ v10 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (Sprite[0].fieldC < 0) {
+ v11 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v11 = -Sprite[0].fieldC;
+ v9 = _vm->_graphicsManager.Reel_Reduc(v9, v11);
+ v12 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v12 = -Sprite[0].fieldC;
+ v10 = _vm->_graphicsManager.Reel_Reduc(v10, v12);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v13 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v13 = -Sprite[0].fieldC;
+ v9 = _vm->_graphicsManager.Reel_Zoom(v9, v13);
+ v14 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v14 = -Sprite[0].fieldC;
+ v10 = _vm->_graphicsManager.Reel_Zoom(v10, v14);
+ }
+ v0 = g_old_x - v9;
+ v58 = g_old_y - v10;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 35)
+ goto LABEL_42;
+ }
+ v1 = 24;
+LABEL_42:
+ _vm->_globals.Compteur = 5 / _vm->_globals.vitesse;
+LABEL_43:
+ if (_vm->_globals.g_old_sens != 1)
+ goto LABEL_60;
+ if (_vm->_globals.g_old_anim > 11) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v15 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (v15 < 0)
+ v15 = -v15;
+ v16 = v15;
+ if (Sprite[0].fieldC < 0) {
+ v17 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v17 = -Sprite[0].fieldC;
+ v16 = _vm->_graphicsManager.Reel_Reduc(v16, v17);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v18 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v18 = -Sprite[0].fieldC;
+ v16 = _vm->_graphicsManager.Reel_Zoom(v16, v18);
+ }
+ v0 = g_old_x;
+ v58 = g_old_y - v16;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 11)
+ goto LABEL_59;
+ }
+ v1 = 0;
+LABEL_59:
+ _vm->_globals.Compteur = 4 / _vm->_globals.vitesse;
+LABEL_60:
+ if (_vm->_globals.g_old_sens != 5)
+ goto LABEL_77;
+ if ((uint16)(_vm->_globals.g_old_anim - 48) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v19 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (v19 < 0)
+ v19 = -v19;
+ v20 = v19;
+ if (Sprite[0].fieldC < 0) {
+ v21 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v21 = -Sprite[0].fieldC;
+ v20 = _vm->_graphicsManager.Reel_Reduc(v20, v21);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v22 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v22 = -Sprite[0].fieldC;
+ v20 = _vm->_graphicsManager.Reel_Zoom(v20, v22);
+ }
+ v0 = g_old_x;
+ v58 = v20 + g_old_y;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 59)
+ goto LABEL_76;
+ }
+ v1 = 48;
+LABEL_76:
+ _vm->_globals.Compteur = 4 / _vm->_globals.vitesse;
+LABEL_77:
+ if (_vm->_globals.g_old_sens != 2)
+ goto LABEL_96;
+ if ((uint16)(_vm->_globals.g_old_anim - 12) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v23 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field0;
+ v24 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (Sprite[0].fieldC < 0) {
+ v25 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v25 = -Sprite[0].fieldC;
+ v23 = _vm->_graphicsManager.Reel_Reduc(v23, v25);
+ v26 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v26 = -Sprite[0].fieldC;
+ v24 = _vm->_graphicsManager.Reel_Reduc(v24, v26);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v27 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v27 = -Sprite[0].fieldC;
+ v23 = _vm->_graphicsManager.Reel_Zoom(v23, v27);
+ v28 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v28 = -Sprite[0].fieldC;
+ v24 = _vm->_graphicsManager.Reel_Zoom(v24, v28);
+ }
+ v0 = v23 + g_old_x;
+ v58 = g_old_y + v24;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 23)
+ goto LABEL_95;
+ }
+ v1 = 12;
+LABEL_95:
+ _vm->_globals.Compteur = 5 / _vm->_globals.vitesse;
+LABEL_96:
+ if (_vm->_globals.g_old_sens != 8)
+ goto LABEL_115;
+ if ((uint16)(_vm->_globals.g_old_anim - 12) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v29 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field0;
+ v30 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (Sprite[0].fieldC < 0) {
+ v31 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v31 = -Sprite[0].fieldC;
+ v29 = _vm->_graphicsManager.Reel_Reduc(v29, v31);
+ v32 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v32 = -Sprite[0].fieldC;
+ v30 = _vm->_graphicsManager.Reel_Reduc(v30, v32);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v33 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v33 = -Sprite[0].fieldC;
+ v29 = _vm->_graphicsManager.Reel_Zoom(v29, v33);
+ v34 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v34 = -Sprite[0].fieldC;
+ v30 = _vm->_graphicsManager.Reel_Zoom(v30, v34);
+ }
+ v0 = g_old_x - v29;
+ v58 = g_old_y + v30;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 23)
+ goto LABEL_114;
+ }
+ v1 = 12;
+LABEL_114:
+ _vm->_globals.Compteur = 5 / _vm->_globals.vitesse;
+LABEL_115:
+ if (_vm->_globals.g_old_sens != 4)
+ goto LABEL_134;
+ if ((uint16)(_vm->_globals.g_old_anim - 36) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v35 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field0;
+ v36 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (Sprite[0].fieldC < 0) {
+ v37 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v37 = -Sprite[0].fieldC;
+ v35 = _vm->_graphicsManager.Reel_Reduc(v35, v37);
+ v38 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v38 = -Sprite[0].fieldC;
+ v36 = _vm->_graphicsManager.Reel_Reduc(v36, v38);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v39 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v39 = -Sprite[0].fieldC;
+ v35 = _vm->_graphicsManager.Reel_Zoom(v35, v39);
+ v40 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v40 = -Sprite[0].fieldC;
+ v36 = _vm->_graphicsManager.Reel_Zoom(v36, v40);
+ }
+ v0 = v35 + g_old_x;
+ v58 = g_old_y + v36;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 47)
+ goto LABEL_133;
+ }
+ v1 = 36;
+LABEL_133:
+ _vm->_globals.Compteur = 5 / _vm->_globals.vitesse;
+LABEL_134:
+ if (_vm->_globals.g_old_sens != 6)
+ goto LABEL_153;
+ if ((uint16)(_vm->_globals.g_old_anim - 36) > 0xBu) {
+ v0 = g_old_x;
+ v58 = g_old_y;
+ } else {
+ v41 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field0;
+ v42 = _vm->_globals.Hopkins[_vm->_globals.g_old_anim].field2;
+ if (Sprite[0].fieldC < 0) {
+ v43 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v43 = -Sprite[0].fieldC;
+ v41 = _vm->_graphicsManager.Reel_Reduc(v41, v43);
+ v44 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v44 = -Sprite[0].fieldC;
+ v42 = _vm->_graphicsManager.Reel_Reduc(v42, v44);
+ }
+ if (Sprite[0].fieldC > 0) {
+ v45 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v45 = -Sprite[0].fieldC;
+ v41 = _vm->_graphicsManager.Reel_Zoom(v41, v45);
+ v46 = Sprite[0].fieldC;
+ if (Sprite[0].fieldC < 0)
+ v46 = -Sprite[0].fieldC;
+ v42 = _vm->_graphicsManager.Reel_Zoom(v42, v46);
+ }
+ v0 = g_old_x - v41;
+ v58 = g_old_y + v42;
+ v1 = _vm->_globals.g_old_anim + 1;
+ if (_vm->_globals.g_old_anim != 47)
+ goto LABEL_152;
+ }
+ v1 = 36;
+LABEL_152:
+ _vm->_globals.Compteur = 5 / _vm->_globals.vitesse;
+LABEL_153:
+ v47 = 0;
+ do {
+ nouveau_x = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ v48 = *_vm->_globals.chemin;
+ nouveau_y = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ nouveau_sens = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+ nouveau_anim = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ if (nouveau_x == -1 && v48 == -1) {
+ if (_vm->_globals.GOACTION == 1)
+ v49 = _vm->_globals.SAUVEGARDE->data[svField2];
+ else
+ v49 = NUMZONE;
+ SETANISPR(0, _vm->_globals.g_old_sens + 59);
+ _vm->_globals.ACTION_SENS = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ VERIFTAILLE();
+ SETFLIPSPR(0, 0);
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.g_old_sens = -1;
+ g_old_x = XSPR(0);
+ g_old_y = YSPR(0);
+
+ if (v49 > 0) {
+ v50 = v49;
+ if (_vm->_globals.ZONEP[v50].destX) {
+ v51 = _vm->_globals.ZONEP[v50].destY;
+ if (v51) {
+ if (v51 != 31) {
+ v52 = _vm->_globals.ZONEP[v50].field4;
+ if (v52 == -1) {
+ _vm->_globals.ZONEP[v50].destX = 0;
+ _vm->_globals.ZONEP[v50].destY = 0;
+ _vm->_globals.ZONEP[v50].field4 = 0;
+ } else {
+ SETANISPR(0, v52);
+ _vm->_globals.ACTION_SENS = _vm->_globals.ZONEP[v50].field4 - 59;
+ }
+ }
+ }
+ }
+ }
+ goto LABEL_241;
+ }
+ if (_vm->_globals.g_old_sens != nouveau_sens)
+ break;
+ if (nouveau_sens == 3 && nouveau_x >= v0)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 7 && nouveau_x <= v0)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 1 && nouveau_y <= v58)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 5 && nouveau_y >= v58)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 2 && nouveau_x >= v0)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 8 && nouveau_x <= v0)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 4 && nouveau_x >= v0)
+ v47 = 1;
+ if (_vm->_globals.g_old_sens == 6 && nouveau_x <= v0)
+ v47 = 1;
+ } while (v47 != 1);
+ if (v47 == 1) {
+ VERIFTAILLE();
+ if (_vm->_globals.g_old_sens == 7)
+ SETFLIPSPR(0, 1);
+ if (_vm->_globals.g_old_sens == 3)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 1)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 5)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 2)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 8)
+ SETFLIPSPR(0, 1);
+ if (_vm->_globals.g_old_sens == 4)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 6)
+ SETFLIPSPR(0, 1);
+ SETXSPR(0, nouveau_x);
+ SETYSPR(0, nouveau_y);
+ SETANISPR(0, v1);
+ } else {
+ if (_vm->_globals.g_old_sens == 7)
+ SETFLIPSPR(0, 1);
+ if (_vm->_globals.g_old_sens == 3)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 1)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 5)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 2)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 8)
+ SETFLIPSPR(0, 1);
+ if (_vm->_globals.g_old_sens == 4)
+ SETFLIPSPR(0, 0);
+ if (_vm->_globals.g_old_sens == 6)
+ SETFLIPSPR(0, 1);
+ _vm->_globals.Compteur = 0;
+ }
+ _vm->_globals.g_old_sens = nouveau_sens;
+ _vm->_globals.g_old_sens2 = nouveau_sens;
+ _vm->_globals.g_old_anim = v1;
+ g_old_x = nouveau_x;
+ g_old_y = nouveau_y;
+}
+
+void ObjectsManager::GOHOME2() {
+ signed int v0;
+ int16 v2;
+
+ v0 = 2;
+ if (_vm->_globals.chemin != (int16 *)g_PTRNUL) {
+ if (_vm->_globals.vitesse == 2)
+ v0 = 4;
+ if (_vm->_globals.vitesse == 3)
+ v0 = 6;
+ _vm->_globals.j_104 = 0;
+ if (v0) {
+ while (1) {
+ nouveau_x = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ v2 = *_vm->_globals.chemin;
+ nouveau_y = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ nouveau_sens = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+ nouveau_anim = *_vm->_globals.chemin;
+ _vm->_globals.chemin++;
+
+ if (nouveau_x == -1) {
+ if (v2 == -1)
+ break;
+ }
+ ++_vm->_globals.j_104;
+ if (_vm->_globals.j_104 >= v0)
+ goto LABEL_19;
+ }
+ if (_vm->_globals.last_sens == 1)
+ SETANISPR(0, 0);
+ if (_vm->_globals.last_sens == 3)
+ SETANISPR(0, 1);
+ if (_vm->_globals.last_sens == 5)
+ SETANISPR(0, 2);
+ if (_vm->_globals.last_sens == 7)
+ SETANISPR(0, 3);
+
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ my_anim = 0;
+ A_ANIM = 0;
+ A_DEPA = 0;
+ } else {
+LABEL_19:
+ _vm->_globals.last_sens = nouveau_sens;
+ SETXSPR(0, nouveau_x);
+ SETYSPR(0, nouveau_y);
+ if (_vm->_globals.last_sens == 1)
+ SETANISPR(0, 4);
+ if (_vm->_globals.last_sens == 3)
+ SETANISPR(0, 5);
+ if (_vm->_globals.last_sens == 5)
+ SETANISPR(0, 6);
+ if (_vm->_globals.last_sens == 7)
+ SETANISPR(0, 7);
+
+ if (my_anim++ > 1)
+ my_anim = 0;
+ }
+ }
+}
+
+// Load Obstacle
+void ObjectsManager::CHARGE_OBSTACLE(const Common::String &file) {
+ int16 v1;
+ byte *ptr;
+ int16 v4;
+ int16 v5;
+
+ _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_linesManager.TOTAL_LIGNES = 0;
+ DERLIGNE = 0;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file);
+ ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ v4 = 0;
+ v5 = 0;
+ do {
+ v1 = (int16)READ_LE_UINT16((uint16 *)ptr + v4);
+ if (v1 != -1) {
+ _vm->_linesManager.AJOUTE_LIGNE(
+ v5,
+ v1,
+ (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 1),
+ (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 2),
+ (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 3),
+ (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 4),
+ 1);
+ ++_vm->_linesManager.TOTAL_LIGNES;
+ }
+ v4 += 5;
+ ++v5;
+ } while (v1 != -1);
+ _vm->_linesManager.INIPARCOURS();
+ _vm->_globals.dos_free2(ptr);
+}
+
+// Load Zone
+void ObjectsManager::CHARGE_ZONE(const Common::String &file) {
+ signed int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int16 v7;
+ int v8;
+ byte *v9;
+ int v10;
+ signed int v11;
+ int v12;
+ byte *v13;
+ int v14;
+ signed int v15;
+ int16 v17;
+ int16 v18;
+ byte *ptr;
+
+ v1 = 1;
+ do {
+ v2 = v1;
+ _vm->_globals.ZONEP[v2].destX = 0;
+ _vm->_globals.ZONEP[v2].destY = 0;
+ _vm->_globals.ZONEP[v2].field4 = 0;
+ _vm->_globals.ZONEP[v2].field6 = 0;
+ _vm->_globals.ZONEP[v2].field7 = 0;
+ _vm->_globals.ZONEP[v2].field8 = 0;
+ _vm->_globals.ZONEP[v2].field9 = 0;
+ _vm->_globals.ZONEP[v2].fieldA = 0;
+ _vm->_globals.ZONEP[v2].fieldB = 0;
+ _vm->_globals.ZONEP[v2].fieldC = 0;
+ _vm->_globals.ZONEP[v2].fieldD = 0;
+ _vm->_globals.ZONEP[v2].fieldE = 0;
+ _vm->_globals.ZONEP[v2].fieldF = 0;
+ _vm->_globals.ZONEP[v2].field12 = 0;
+ _vm->_globals.ZONEP[v2].field10 = 0;
+ ++v1;
+ } while (v1 <= 100);
+
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file);
+
+ Common::File f;
+ if (!f.exists(_vm->_globals.NFICHIER))
+ error("File not found : %s", _vm->_globals.NFICHIER.c_str());
+
+ ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ v4 = 0;
+ v18 = 0;
+ v17 = 0;
+ do {
+ v3 = (int16)READ_LE_UINT16((uint16 *)ptr + v4);
+ if (v3 != -1) {
+ v5 = v3;
+ v6 = v3;
+ _vm->_linesManager.AJOUTE_LIGNE_ZONE(
+ v18,
+ READ_LE_UINT16((uint16 *)ptr + v4 + 1),
+ READ_LE_UINT16((uint16 *)ptr + v4 + 2),
+ READ_LE_UINT16((uint16 *)ptr + v4 + 3),
+ READ_LE_UINT16((uint16 *)ptr + v4 + 4),
+ v3);
+ _vm->_globals.ZONEP[v5].field10 = 1;
+ v3 = v6;
+ }
+ v4 += 5;
+ ++v18;
+ ++v17;
+ } while (v3 != -1);
+ v7 = 1;
+ do {
+ v8 = v7;
+ _vm->_globals.ZONEP[v8].destX = (int16)READ_LE_UINT16((uint16 *)ptr + v4);
+ _vm->_globals.ZONEP[v8].destY = (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 1);
+ _vm->_globals.ZONEP[v8].field4 = (int16)READ_LE_UINT16((uint16 *)ptr + v4 + 2);
+ v4 += 3;
+ ++v7;
+ } while (v7 <= 100);
+
+ v9 = (ptr + 10 * v17 + 606);
+ v10 = 0;
+ v11 = 1;
+ do {
+ v12 = v11;
+
+ _vm->_globals.ZONEP[v12].field6 = *(v10 + v9);
+ _vm->_globals.ZONEP[v12].field7 = *(v9 + v10 + 1);
+ _vm->_globals.ZONEP[v12].field8 = *(v9 + v10 + 2);
+ _vm->_globals.ZONEP[v12].field9 = *(v9 + v10 + 3);
+ _vm->_globals.ZONEP[v12].fieldA = *(v9 + v10 + 4);
+ _vm->_globals.ZONEP[v12].fieldB = *(v9 + v10 + 5);
+ _vm->_globals.ZONEP[v12].fieldC = *(v9 + v10 + 6);
+ _vm->_globals.ZONEP[v12].fieldD = *(v9 + v10 + 7);
+ _vm->_globals.ZONEP[v12].fieldE = *(v9 + v10 + 8);
+ _vm->_globals.ZONEP[v12].fieldF = *(v9 + v10 + 9);
+
+ v10 += 10;
+ ++v11;
+ } while (v11 <= 100);
+ v13 = v9 + 1010;
+ v14 = 0;
+ v15 = 1;
+ do
+ _vm->_globals.ZONEP[v15++].field12 = READ_LE_UINT16(v13 + 2 * v14++);
+ while (v15 <= 100);
+
+ _vm->_globals.dos_free2(ptr);
+ CARRE_ZONE();
+}
+
+// Square Zone
+void ObjectsManager::CARRE_ZONE() {
+ int16 *dataP;
+ int v4;
+ int v5;
+ int v7;
+ int v8;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+
+ for (int idx = 0; idx < 100; ++idx) {
+ _vm->_globals.CarreZone[idx].field0 = 0;
+ _vm->_globals.CarreZone[idx].fieldE = 0;
+ _vm->_globals.CarreZone[idx].field2 = 1280;
+ _vm->_globals.CarreZone[idx].field4 = 0;
+ _vm->_globals.CarreZone[idx].field6 = 460;
+ _vm->_globals.CarreZone[idx].field8 = 0;
+ _vm->_globals.CarreZone[idx].fieldA = 401;
+ _vm->_globals.CarreZone[idx].fieldC = 0;
+ }
+
+ for (int idx = 0; idx < 400; ++idx) {
+ dataP = _vm->_linesManager.LigneZone[idx].zoneData;
+ if (dataP != (int16 *)g_PTRNUL) {
+ v4 = _vm->_linesManager.LigneZone[idx].field2;
+ _vm->_globals.CarreZone[v4].field0 = 1;
+ if (_vm->_globals.CarreZone[v4].fieldC < idx)
+ _vm->_globals.CarreZone[v4].fieldC = idx;
+ if (_vm->_globals.CarreZone[v4].fieldA > idx)
+ _vm->_globals.CarreZone[v4].fieldA = idx;
+
+ v13 = 0;
+ v12 = _vm->_linesManager.LigneZone[idx].count;
+ if (v12 > 0) {
+ do {
+ v5 = *dataP++;
+ v11 = *dataP++;
+
+ if (_vm->_globals.CarreZone[v4].field2 >= v5)
+ _vm->_globals.CarreZone[v4].field2 = v5;
+ if (_vm->_globals.CarreZone[v4].field4 <= v5)
+ _vm->_globals.CarreZone[v4].field4 = v5;
+ if (_vm->_globals.CarreZone[v4].field6 >= v11)
+ _vm->_globals.CarreZone[v4].field6 = v11;
+ if (_vm->_globals.CarreZone[v4].field8 <= v11)
+ _vm->_globals.CarreZone[v4].field8 = v11;
+ ++v13;
+ } while (v13 < v12);
+ }
+ }
+ }
+
+ v7 = 0;
+ do {
+ v8 = v7;
+ v10 = _vm->_globals.CarreZone[v8].field2 - _vm->_globals.CarreZone[v8].field4;
+ if (v10 < 0)
+ v10 = -v10;
+ v14 = _vm->_globals.CarreZone[v8].field6 - _vm->_globals.CarreZone[v8].field8;
+ if (v14 < 0)
+ v14 = -v14;
+ if (v10 == v14)
+ _vm->_globals.CarreZone[v8].fieldE = 1;
+ ++v7;
+ } while (v7 <= 99);
+}
+
+void ObjectsManager::PLAN_BETA() {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+
+ v1 = 0;
+ _vm->_dialogsManager.INVENTFLAG = false;
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+ _vm->_globals.Max_Propre = 1;
+ _vm->_globals.Max_Ligne_Long = 1;
+ _vm->_globals.Max_Propre_Gen = 1;
+ _vm->_globals.Max_Perso_Y = 440;
+ _vm->_globals.NOSPRECRAN = 1;
+ _vm->_globals.PLAN_FLAG = true;
+ _vm->_graphicsManager.NOFADE = false;
+ _vm->_globals.NOMARCHE = false;
+ sprite_ptr = g_PTRNUL;
+ _vm->_globals.SORTIE = 0;
+ _vm->_globals.AFFLI = 0;
+ _vm->_globals.AFFIVBL = 0;
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_soundManager.WSOUND(31);
+ _vm->_globals.iRegul = 1;
+ _vm->_graphicsManager.LOAD_IMAGE("PLAN");
+ CHARGE_OBSTACLE("PLAN.OB2");
+ _vm->_globals.CHARGE_CACHE("PLAN.CA2");
+ CHARGE_ZONE("PLAN.ZO2");
+ _vm->_fileManager.CONSTRUIT_SYSTEM("VOITURE.SPR");
+ sprite_ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ _vm->_animationManager.CHARGE_ANIM("PLAN");
+ _vm->_graphicsManager.VISU_ALL();
+ _vm->_graphicsManager.INI_ECRAN2("PLAN");
+ v2 = 0;
+ do {
+ _vm->_globals.CACHE_OFF(v2++);
+ } while (v2 <= 15);
+ _vm->_globals.CACHE_OFF(19);
+ _vm->_globals.CACHE_OFF(20);
+ _vm->_globals.CACHE_ON();
+
+ if (!_vm->_globals.PLANX && !_vm->_globals.PLANY) {
+ _vm->_globals.PLANX = 900;
+ _vm->_globals.PLANY = 319;
+ _vm->_globals.PLANI = 1;
+ }
+ SPRITE(sprite_ptr, _vm->_globals.PLANX, _vm->_globals.PLANY, 0, _vm->_globals.PLANI, 0, 0, 5, 5);
+ _vm->_eventsManager.souris_xy(_vm->_globals.PLANX, _vm->_globals.PLANY);
+ my_anim = 0;
+ _vm->_eventsManager.MOUSE_ON();
+ v3 = XSPR(0);
+ _vm->_graphicsManager.SCROLL_ECRAN(v3 - 320);
+ _vm->_graphicsManager.ofscroll = XSPR(0) - 320;
+ SPRITE_ON(0);
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _vm->_globals.BPP_NOAFF = true;
+
+ v4 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v4;
+ } while (v4 <= 4);
+
+ _vm->_globals.BPP_NOAFF = false;
+ _vm->_globals.iRegul = 1;
+ _vm->_graphicsManager.FADE_INW();
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ _vm->_graphicsManager.NOFADE = false;
+
+ do {
+ v5 = _vm->_eventsManager.BMOUSE();
+ if (v5) {
+ if (_vm->_globals.SAUVEGARDE->data[svField170] == 1 && !_vm->_globals.SAUVEGARDE->data[svField171]) {
+ _vm->_globals.SAUVEGARDE->data[svField171] = 1;
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("APPEL1.pe2");
+ _vm->_globals.NOPARLE = false;
+ v5 = 0;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField180] == 1 && !_vm->_globals.SAUVEGARDE->data[svField172]) {
+ _vm->_globals.SAUVEGARDE->data[svField172] = 1;
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("APPEL2.pe2");
+ _vm->_globals.NOPARLE = false;
+ v5 = 0;
+ _vm->_eventsManager.souris_bb = false;
+ }
+ if (v5 == 1)
+ BTGAUCHE();
+ }
+
+ VERIFZONE();
+ GOHOME2();
+
+ if (_vm->_globals.chemin == (int16 *)g_PTRNUL && _vm->_globals.GOACTION == 1)
+ PARADISE();
+ _vm->_eventsManager.VBL();
+
+ if (_vm->_globals.SORTIE)
+ v1 = 1;
+ } while (!_vm->shouldQuit() && v1 != 1);
+
+ if (!_vm->_graphicsManager.NOFADE)
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_globals.iRegul = 0;
+ _vm->_graphicsManager.NOFADE = false;
+ _vm->_globals.PLANX = XSPR(0);
+ _vm->_globals.PLANY = YSPR(0);
+ _vm->_globals.PLANI = 1;
+ SPRITE_OFF(0);
+ _vm->_globals.AFFLI = 0;
+ sprite_ptr = _vm->_globals.LIBERE_FICHIER(sprite_ptr);
+ CLEAR_ECRAN();
+ _vm->_globals.NOSPRECRAN = 0;
+ _vm->_globals.PLAN_FLAG = false;
+}
+
+// Left Button
+void ObjectsManager::BTGAUCHE() {
+ int srcX, srcY;
+ int destX, destY;
+ int v1;
+ int v2;
+ int16 *v3;
+ int16 *v4;
+ int16 *v5;
+ int zoneCount;
+ int zoneX;
+ int zoneY;
+ int16 *v9;
+ int v10;
+ int v11;
+ int v12;
+ int16 *v13;
+ int16 *v16;
+ int v17;
+ int v18;
+
+ _vm->_fontManager.TEXTE_OFF(9);
+ destX = _vm->_eventsManager.XMOUSE();
+ destY = _vm->_eventsManager.YMOUSE();
+
+ if (!_vm->_dialogsManager.INVENTFLAG && !_vm->_globals.PLAN_FLAG && destX > _vm->_graphicsManager.ofscroll - 30 && destX < _vm->_graphicsManager.ofscroll + 50 && (uint16)(destY + 29) <= 0x4Eu) {
+ v1 = _vm->_eventsManager.btsouris;
+ _vm->_dialogsManager.INVENTFLAG = true;
+ _vm->_dialogsManager.showInventory();
+ _vm->_dialogsManager.INVENTFLAG = false;
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+ if (!_vm->_globals.SORTIE) {
+ _vm->_dialogsManager.INVENTFLAG = false;
+ _vm->_eventsManager.btsouris = v1;
+ }
+ return;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField354] == 1
+ && !_vm->_globals.PLAN_FLAG
+ && (uint16)(destX - 533) <= 0x1Au
+ && (uint16)(destY - 26) <= 0x21u) {
+ CHANGE_TETE(1, 0);
+ return;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField356] == 1
+ && !_vm->_globals.PLAN_FLAG
+ && (uint16)(destX - 533) <= 0x1Au
+ && (uint16)(destY - 26) <= 0x21u) {
+ CHANGE_TETE(2, 0);
+ return;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField357] == 1) {
+ if (_vm->_globals.SAUVEGARDE->data[svField353] == 1
+ && !_vm->_globals.PLAN_FLAG
+ && (uint16)(destX - 533) <= 0x1Au
+ && (uint16)(destY - 26) <= 0x21u) {
+ CHANGE_TETE(0, 1);
+ return;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField355] == 1
+ && !_vm->_globals.PLAN_FLAG
+ && (uint16)(destX - 567) <= 0x1Au
+ && (uint16)(destY - 26) <= 0x21u) {
+ CHANGE_TETE(0, 2);
+ return;
+ }
+ }
+ if (_vm->_globals.PLAN_FLAG == true) {
+ if (_vm->_globals.GOACTION != 1)
+ goto LABEL_38;
+ VERIFZONE();
+ if (NUMZONE <= 0)
+ return;
+ v2 = 0;
+ v3 = _vm->_globals.essai2;
+ v4 = _vm->_globals.chemin;
+ do {
+ v3[v2] = v4[v2];
+ ++v2;
+ } while (v4[v2] != -1);
+
+ v5 = _vm->_globals.essai2;
+ v5[v2] = -1;
+ v5[v2 + 1] = -1;
+ v5[v2 + 2] = -1;
+ v5[v2 + 3] = -1;
+ }
+ if (_vm->_globals.GOACTION == 1) {
+ VERIFZONE();
+ _vm->_globals.GOACTION = 0;
+ _vm->_globals.SAUVEGARDE->data[svField1] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField2] = 0;
+ }
+LABEL_38:
+ if (_vm->_globals.PLAN_FLAG == true && (_vm->_eventsManager.btsouris != 4 || NUMZONE <= 0))
+ return;
+ if ((uint16)(NUMZONE + 1) > 1u) {
+ zoneCount = NUMZONE;
+ zoneX = _vm->_globals.ZONEP[zoneCount].destX;
+ if (zoneX) {
+ zoneY = _vm->_globals.ZONEP[zoneCount].destY;
+ if (zoneY) {
+ if (zoneY != 31) {
+ destX = zoneX;
+ destY = zoneY;
+ }
+ }
+ }
+ }
+ _vm->_globals.GOACTION = 0;
+ v9 = _vm->_globals.chemin;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ if (_vm->_globals.FORET && ((uint16)(NUMZONE - 20) <= 1u || (uint16)(NUMZONE - 22) <= 1u)) {
+ if (YSPR(0) <= 374 || YSPR(0) > 410) {
+ v10 = XSPR(0);
+ v11 = YSPR(0);
+ v12 = XSPR(0);
+ v13 = _vm->_linesManager.PARCOURS2(v12, v11, v10, 390);
+ _vm->_globals.chemin = v13;
+ if (v13 != (int16 *)g_PTRNUL)
+ PACOURS_PROPRE(v13);
+ g_old_x = XSPR(0);
+ g_old_y = YSPR(0);
+ _vm->_globals.Compteur = 0;
+ if (_vm->_globals.chemin != (int16 *)g_PTRNUL || v9 == _vm->_globals.chemin) {
+LABEL_64:
+ _vm->_globals.g_old_sens = -1;
+ goto LABEL_65;
+ }
+ goto LABEL_63;
+ }
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ SETANISPR(0, _vm->_globals.g_old_sens2 + 59);
+ _vm->_globals.ACTION_SENS = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ VERIFTAILLE();
+ SETFLIPSPR(0, 0);
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.g_old_sens = -1;
+ goto LABEL_65;
+ }
+ if (!_vm->_globals.NOMARCHE) {
+ if (!_vm->_globals.PLAN_FLAG) {
+ srcY = YSPR(0);
+ srcX = XSPR(0);
+ v16 = _vm->_linesManager.PARCOURS2(srcX, srcY, destX, destY);
+ _vm->_globals.chemin = v16;
+ if (v16 != (int16 *)g_PTRNUL)
+ PACOURS_PROPRE(v16);
+ g_old_x = XSPR(0);
+ g_old_y = YSPR(0);
+ _vm->_globals.Compteur = 0;
+ if (_vm->_globals.chemin != (int16 *)g_PTRNUL || v9 == _vm->_globals.chemin)
+ goto LABEL_64;
+LABEL_63:
+ _vm->_globals.chemin = v9;
+ }
+LABEL_65:
+ if (!_vm->_globals.NOMARCHE && _vm->_globals.PLAN_FLAG == true) {
+ v17 = YSPR(0);
+ v18 = XSPR(0);
+ _vm->_globals.chemin = PARC_VOITURE(v18, v17, destX, destY);
+ }
+ }
+ if ((uint16)(NUMZONE + 1) > 1u) {
+ // TODO: Reformat the weird if statement generated by the decompiler
+ if (_vm->_eventsManager.btsouris == 23 || (_vm->_globals.SAUVEGARDE->data[svField1] = _vm->_eventsManager.btsouris, _vm->_eventsManager.btsouris == 23))
+ _vm->_globals.SAUVEGARDE->data[svField1] = 5;
+ if (_vm->_globals.PLAN_FLAG == true)
+ _vm->_globals.SAUVEGARDE->data[svField1] = 6;
+ _vm->_globals.SAUVEGARDE->data[svField2] = NUMZONE;
+ _vm->_globals.SAUVEGARDE->data[svField3] = _vm->_globals.OBJET_EN_COURS;
+ _vm->_globals.GOACTION = 1;
+ }
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
+ ARRET_PERSO_FLAG = 0;
+ if (_vm->_eventsManager.btsouris == 21 && _vm->_globals.BOBZONE[NUMZONE]) {
+ ARRET_PERSO_FLAG = 1;
+ ARRET_PERSO_NUM = _vm->_globals.BOBZONE[NUMZONE];
+ }
+ if (_vm->_globals.ECRAN == 20 && _vm->_globals.SAUVEGARDE->data[svField13] == 1 && _vm->_globals.OBJET_EN_COURS == 20 && NUMZONE == 12
+ && _vm->_eventsManager.btsouris == 23) {
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ XSPR(0);
+ YSPR(0);
+ }
+}
+
+void ObjectsManager::PARADISE() {
+ int v1;
+ char result;
+ int v3;
+ uint16 v4;
+ int v5;
+ uint16 v6;
+
+ v1 = 0;
+ ARRET_PERSO_FLAG = 0;
+ ARRET_PERSO_NUM = 0;
+ result = _vm->_globals.SAUVEGARDE->data[svField1];
+ if (result && _vm->_globals.SAUVEGARDE->data[svField2] && result != 4 && result > 3) {
+ _vm->_fontManager.TEXTE_OFF(5);
+ if (_vm->_globals.FORET != 1 || ((uint16)(NUMZONE - 20) > 1u && (uint16)(NUMZONE - 22) > 1u)) {
+ if (_vm->_graphicsManager.DOUBLE_ECRAN == true) {
+ _vm->_graphicsManager.no_scroll = 2;
+ if (_vm->_eventsManager.start_x >= XSPR(0) - 320)
+ goto LABEL_64;
+ v3 = _vm->_eventsManager.start_x + 320 - XSPR(0);
+ if (v3 < 0)
+ v3 = -v3;
+ if (v3 <= 160) {
+LABEL_64:
+ if (_vm->_eventsManager.start_x > XSPR(0) - 320) {
+ v5 = _vm->_eventsManager.start_x + 320 - XSPR(0);
+ if (v5 < 0)
+ v5 = -v5;
+ if (v5 > 160) {
+ _vm->_graphicsManager.no_scroll = 2;
+ do {
+ _vm->_graphicsManager.SCROLL -= _vm->_graphicsManager.SPEED_SCROLL;
+ if (_vm->_graphicsManager.SCROLL < 0) {
+ _vm->_graphicsManager.SCROLL = 0;
+ v1 = 1;
+ }
+ if (_vm->_graphicsManager.SCROLL > 640) {
+ _vm->_graphicsManager.SCROLL = 640;
+ v1 = 1;
+ }
+ if (_vm->_eventsManager.XMOUSE() > _vm->_graphicsManager.SCROLL + 620) {
+ v6 = _vm->_eventsManager.YMOUSE();
+ _vm->_eventsManager.souris_xy(_vm->_eventsManager.souris_x - 4, v6);
+ }
+ _vm->_eventsManager.VBL();
+ } while (v1 != 1 && _vm->_eventsManager.start_x > XSPR(0) - 320);
+ }
+ }
+ } else {
+ do {
+ _vm->_graphicsManager.SCROLL += _vm->_graphicsManager.SPEED_SCROLL;
+ if (_vm->_graphicsManager.SCROLL < 0) {
+ _vm->_graphicsManager.SCROLL = 0;
+ v1 = 1;
+ }
+ if (_vm->_graphicsManager.SCROLL > 640) {
+ _vm->_graphicsManager.SCROLL = 640;
+ v1 = 1;
+ }
+ if (_vm->_eventsManager.XMOUSE() < _vm->_graphicsManager.SCROLL + 10) {
+ v4 = _vm->_eventsManager.YMOUSE();
+ _vm->_eventsManager.souris_xy(_vm->_eventsManager.souris_x + 4, v4);
+ }
+ _vm->_eventsManager.VBL();
+ } while (v1 != 1 && _vm->_eventsManager.start_x < XSPR(0) - 320);
+ }
+ if (_vm->_eventsManager.XMOUSE() > _vm->_graphicsManager.SCROLL + 620)
+ _vm->_eventsManager.souris_xy(_vm->_graphicsManager.SCROLL + 610, 0);
+ if (_vm->_eventsManager.XMOUSE() < _vm->_graphicsManager.SCROLL + 10)
+ _vm->_eventsManager.souris_xy(_vm->_graphicsManager.SCROLL + 10, 0);
+ _vm->_eventsManager.VBL();
+ _vm->_graphicsManager.no_scroll = 0;
+ }
+ _vm->_talkManager.REPONSE(_vm->_globals.SAUVEGARDE->data[svField2], _vm->_globals.SAUVEGARDE->data[svField1]);
+ } else {
+ _vm->_talkManager.REPONSE2(_vm->_globals.SAUVEGARDE->data[svField2], _vm->_globals.SAUVEGARDE->data[svField1]);
+ }
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ if ((uint16)(NUMZONE + 1) > 1u && !_vm->_globals.ZONEP[NUMZONE].field16) {
+ NUMZONE = -1;
+ FORCEZONE = 1;
+ }
+ if (NUMZONE != _vm->_globals.SAUVEGARDE->data[svField2] || (uint16)(NUMZONE + 1) <= 1u) {
+ _vm->_eventsManager.btsouris = 4;
+ CHANGEVERBE = 0;
+ } else {
+ _vm->_eventsManager.btsouris = _vm->_globals.SAUVEGARDE->data[svField1];
+ if (CHANGEVERBE == 1) {
+ VERBEPLUS();
+ CHANGEVERBE = 0;
+ }
+ if (_vm->_eventsManager.btsouris == 5)
+ _vm->_eventsManager.btsouris = 4;
+ }
+ if (_vm->_eventsManager.btsouris != 23)
+ _vm->_eventsManager.CHANGE_MOUSE(_vm->_eventsManager.btsouris);
+ NUMZONE = 0;
+ _vm->_globals.SAUVEGARDE->data[svField1] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField2] = 0;
+ }
+ if (_vm->_globals.PLAN_FLAG == true) {
+ _vm->_eventsManager.btsouris = 0;
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+ }
+ if (_vm->_globals.NOMARCHE == true) {
+ if (_vm->_eventsManager.btsouris == 4) {
+ result = NUMZONE + 1;
+ if ((uint16)(NUMZONE + 1) > 1u)
+ BTDROITE();
+ }
+ }
+ _vm->_globals.GOACTION = 0;
+}
+
+// Clear Screen
+void ObjectsManager::CLEAR_ECRAN() {
+ int v1;
+ int v2;
+
+ CLEAR_SPR();
+ _vm->_graphicsManager.FIN_VISU();
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_globals.CLEAR_VBOB();
+ _vm->_animationManager.CLEAR_ANIM();
+ _vm->_linesManager.CLEAR_ZONE();
+ _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_globals.RESET_CACHE();
+
+ v1 = 0;
+ do {
+ v2 = v1;
+ _vm->_globals.BOBZONE[v2] = 0;
+ _vm->_globals.BOBZONE_FLAG[v2] = false;
+ ++v1;
+ } while (v1 <= 48);
+ _vm->_eventsManager.btsouris = 4;
+ verbe = 4;
+ NUMZONE = 0;
+ Vold_taille = 0;
+ SPEED_FLAG = false;
+ SPEED_PTR = g_PTRNUL;
+ SPEED_X = 0;
+ SPEED_Y = 0;
+ SPEED_IMAGE = 0;
+ FORCEZONE = 1;
+ _vm->_linesManager.TOTAL_LIGNES = 0;
+ DERLIGNE = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ if (_vm->_globals.COUCOU != g_PTRNUL)
+ _vm->_globals.COUCOU = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.COUCOU);
+ if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN)
+ _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN);
+ _vm->_eventsManager.start_x = 0;
+ _vm->_eventsManager.souris_n = 0;
+ Vold_taille = 200;
+ _vm->_globals.SAUVEGARDE->data[svField1] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField2] = 0;
+ _vm->_globals.GOACTION = 0;
+ FORCEZONE = 1;
+ CHANGEVERBE = 0;
+ _vm->_globals.NOSPRECRAN = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.g_old_sens = -1;
+ my_anim = 1;
+ A_ANIM = 0;
+ MA_ANIM = 0;
+ MA_ANIM1 = 0;
+ A_DEPA = 0;
+ MAX_DEPA = 0;
+ MAX_DEPA1 = 0;
+ _vm->_graphicsManager.RESET_SEGMENT_VESA();
+}
+
+// Change Face/Head
+void ObjectsManager::CHANGE_TETE(int a1, int a2) {
+ int v2;
+ Sauvegarde1 *v3;
+ Sauvegarde1 *v4;
+ Sauvegarde1 *v5;
+ Sauvegarde1 *v6;
+ Sauvegarde1 *v7;
+ Sauvegarde1 *v8;
+ Sauvegarde1 *v9;
+
+ CH_TETE = 1;
+ _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, 532, 25, 65, 40, _vm->_graphicsManager.VESA_BUFFER, 532, 25);
+ _vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 597, 65);
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ if (a1 == 2) {
+ if (!a2) {
+ if (_vm->_globals.SAUVEGARDE->data[svField188] == _vm->_globals.ECRAN) {
+ CH_TETE = 0;
+ v3 = &_vm->_globals.SAUVEGARDE->field380;
+ v3->field0 = XSPR(0);
+ v3->field1 = YSPR(0);
+ v3->field2 = 64;
+ v3->field3 = _vm->_globals.ECRAN;
+ v3->field4 = Sprite[0].field0;
+ SPRITE_OFF(1);
+ SPRITE(_vm->_globals.TETE, v3->field0, v3->field1, 1, 3, v3->field4, 0, 20, 127);
+ SPRITE_ON(1);
+ SPRITE_OFF(0);
+ _vm->_globals.SAUVEGARDE->data[svField354] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField356] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField357] = 1;
+ T_RECTIF = 0;
+ v4 = &_vm->_globals.SAUVEGARDE->field370;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 0;
+ SPRITE(_vm->_globals.PERSO, v4->field0, v4->field1, 0, 64, v4->field4, 0, 34, 190);
+LABEL_9:
+ SPRITE_ON(0);
+ return;
+ }
+ }
+ }
+ if (!a1) {
+ if (a2 == 2 && _vm->_globals.SAUVEGARDE->data[svField193] == _vm->_globals.ECRAN) {
+ CH_TETE = 0;
+ v5 = &_vm->_globals.SAUVEGARDE->field370;
+ v5->field0 = XSPR(0);
+ v5->field1 = YSPR(0);
+ v5->field2 = 64;
+ v5->field3 = _vm->_globals.ECRAN;
+ v5->field4 = Sprite[0].fieldC;
+ SPRITE_OFF(1);
+ SPRITE(_vm->_globals.TETE, v5->field0, v5->field1, 1, 2, v5->field4, 0, 34, 190);
+ SPRITE_ON(1);
+ SPRITE_OFF(0);
+ _vm->_globals.SAUVEGARDE->data[svField354] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField356] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField357] = 0;
+ v6 = &_vm->_globals.SAUVEGARDE->field380;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PSAMAN.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 2;
+ SPRITE(_vm->_globals.PERSO, v6->field0, v6->field1, 0, 64, v6->field4, 0, 20, 127);
+ goto LABEL_9;
+ }
+ v7 = &_vm->_globals.SAUVEGARDE->field370;
+ v7->field0 = XSPR(0);
+ v7->field1 = YSPR(0);
+ v7->field2 = 64;
+ v7->field3 = _vm->_globals.ECRAN;
+ v7->field4 = Sprite[0].fieldC;
+ }
+ if (a1 == 1) {
+ v8 = &_vm->_globals.SAUVEGARDE->field360;
+ v8->field0 = XSPR(0);
+ v8->field1 = YSPR(0);
+ v8->field2 = 64;
+ v8->field3 = _vm->_globals.ECRAN;
+ v8->field4 = Sprite[0].fieldC;
+ }
+ if (a1 == 2) {
+ v9 = &_vm->_globals.SAUVEGARDE->field380;
+ v9->field0 = XSPR(0);
+ v9->field1 = YSPR(0);
+ v9->field2 = 64;
+ v9->field3 = _vm->_globals.ECRAN;
+ v9->field4 = Sprite[0].fieldC;
+ }
+ if (!a2) {
+ _vm->_globals.SAUVEGARDE->data[svField121] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField354] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField356] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField357] = 1;
+ _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField188];
+ }
+ if (a2 == 1) {
+ _vm->_globals.SAUVEGARDE->data[svField121] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField354] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField356] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField357] = 0;
+ _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField183];
+ }
+ if (a2 == 2) {
+ _vm->_globals.SAUVEGARDE->data[svField121] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField354] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField356] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField357] = 0;
+ v2 = _vm->_globals.SAUVEGARDE->data[svField193];
+ _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField193];
+ }
+}
+
+// Check Size
+void ObjectsManager::VERIFTAILLE() {
+ int v0;
+ int v1;
+ int v2;
+
+ v0 = _vm->_globals.STAILLE[YSPR(0)];
+ if (_vm->_globals.PERSO_TYPE == 1) {
+ v1 = v0;
+ if (v0 < 0)
+ v1 = -v0;
+ v0 = 20 * (5 * v1 - 100) / -80;
+ }
+ if (_vm->_globals.PERSO_TYPE == 2) {
+ v2 = v0;
+ if (v0 < 0)
+ v2 = -v0;
+ v0 = 20 * (5 * v2 - 165) / -67;
+ }
+ SETTAILLESPR(0, v0);
+}
+
+void ObjectsManager::PACOURS_PROPRE(int16 *a1) {
+ int v1;
+ int v2;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+
+ v1 = 0;
+ v13 = 0;
+ v14 = -1;
+ v2 = a1[1];
+ v15 = a1[2];
+ if (a1[0] != -1 || v2 != -1) {
+ for (;;) {
+ if (v14 != -1 && v15 != v14) {
+ v11 = v1;
+ v12 = 0;
+ v10 = CALC_PROPRE(v2);
+ v4 = a1[v1];
+ v9 = a1[v1];
+ v5 = a1[v1 + 1];
+ v6 = 0;
+ while (v4 != -1 || v5 != -1) {
+ int idx = v1;
+ v1 += 4;
+ ++v12;
+ if (a1[idx + 2] != v15)
+ v6 = 1;
+ if (v6 == 1)
+ break;
+ v4 = a1[v1];
+ v9 = a1[v1];
+ v5 = a1[v1 + 1];
+ }
+ if (v12 < v10) {
+ v7 = v11;
+ v8 = 0;
+ if (v12 > 0) {
+ do {
+ a1[v7 + 2] = v14;
+ v7 += 4;
+ ++v8;
+ } while (v12 > v8);
+ }
+ v15 = v14;
+ }
+ v1 = v11;
+ if (v9 == -1 && v5 == -1)
+ v13 = 1;
+ }
+ v1 += 4;
+ if (v13 == 1)
+ break;
+ v14 = v15;
+ v2 = a1[v1 + 1];
+ v15 = a1[v1 + 2];
+ if (a1[v1] == -1) {
+ if (v2 == -1)
+ break;
+ }
+ }
+ }
+}
+
+int16 *ObjectsManager::PARC_VOITURE(int a1, int a2, int a3, int a4) {
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int16 *result;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int16 *v33;
+ int v34;
+ int v35;
+ int i;
+ int16 *v37;
+ int v39;
+ int v40;
+ int16 *v41;
+ int v43;
+ int k;
+ int16 *v45;
+ int v47;
+ int v48;
+ int v49;
+ int16 *v50;
+ int v52;
+ int v53;
+ int16 *v54;
+ int v56;
+ int v57;
+ int16 *v58;
+ int v60;
+ int v61;
+ int v62;
+ int v63;
+ int v64;
+ int v65;
+ int v66;
+ int v67;
+ int v68;
+ int v69;
+ int j;
+ int l;
+ int v72;
+ int v73;
+ int v74;
+ int v75;
+ int v76[10];
+ int v77[10];
+ int v82[10];
+ int v87[10];
+
+ v4 = a3;
+ v5 = a4;
+ v67 = 0;
+ if (a3 <= 14)
+ v4 = 15;
+ if (a4 <= 14)
+ v5 = 15;
+ if (v4 > _vm->_graphicsManager.max_x - 10)
+ v4 = _vm->_graphicsManager.max_x - 10;
+ if (v5 > 445)
+ v5 = 440;
+ v75 = v4;
+ v74 = v5;
+ v6 = 0;
+ v7 = v74;
+ if (_vm->_graphicsManager.max_y > v74) {
+ v8 = 5;
+ do {
+ v62 = v8;
+ v9 = _vm->_linesManager.colision2_ligne(v75, v7, &v82[5], &v87[5], 0, DERLIGNE);
+ v8 = v62;
+ if (v9 == 1 && v87[v62] <= DERLIGNE)
+ break;
+ v82[v62] = 0;
+ v87[v62] = -1;
+ ++v6;
+ ++v7;
+ } while (_vm->_graphicsManager.max_y > v7);
+ }
+ v77[5] = v6;
+ v10 = 0;
+ v11 = v74;
+ if (_vm->_graphicsManager.min_y < v74) {
+ v12 = 1;
+ do {
+ v63 = v12;
+ v13 = _vm->_linesManager.colision2_ligne(v75, v11, &v82[1], &v87[1], 0, DERLIGNE);
+ v12 = v63;
+ if (v13 == 1 && v87[v63] <= DERLIGNE)
+ break;
+ v82[v63] = 0;
+ v87[v63] = -1;
+ if (v77[5] < v10) {
+ if (v87[5] != -1)
+ break;
+ }
+ ++v10;
+ --v11;
+ } while (_vm->_graphicsManager.min_y < v11);
+ }
+ v77[1] = v10;
+ v14 = 0;
+ v15 = v75;
+ if (_vm->_graphicsManager.max_x > v75) {
+ v16 = 3;
+ do {
+ v64 = v16;
+ v17 = _vm->_linesManager.colision2_ligne(v15, v74, &v82[3], &v87[3], 0, DERLIGNE);
+ v16 = v64;
+ if (v17 == 1 && v87[v64] <= DERLIGNE)
+ break;
+ v82[v64] = 0;
+ v87[v64] = -1;
+ ++v14;
+ if (v77[1] < v14) {
+ if (v87[1] != -1)
+ break;
+ }
+ if (v77[5] < v14 && v87[5] != -1)
+ break;
+ ++v15;
+ } while (_vm->_graphicsManager.max_x > v15);
+ }
+ v77[3] = v14;
+ v18 = 0;
+ v19 = v75;
+ if (_vm->_graphicsManager.min_x < v75) {
+ v20 = 7;
+ do {
+ v65 = v20;
+ v21 = _vm->_linesManager.colision2_ligne(v19, v74, &v82[7], &v87[7], 0, DERLIGNE);
+ v20 = v65;
+ if (v21 == 1 && v87[v65] <= DERLIGNE)
+ break;
+ v82[v65] = 0;
+ v87[v65] = -1;
+ ++v18;
+ if (v77[1] < v18) {
+ if (v87[1] != -1)
+ break;
+ }
+ if (v77[5] < v18 && v87[5] != -1)
+ break;
+ if (v77[3] < v18 && v87[3] != -1)
+ break;
+ --v19;
+ } while (_vm->_graphicsManager.min_x < v19);
+ }
+ v77[7] = v18;
+ if (v87[1] == -1)
+ v77[1] = 1300;
+ if (v87[3] == -1)
+ v77[3] = 1300;
+ if (v87[5] == -1)
+ v77[5] = 1300;
+ if (v87[7] == -1)
+ v77[7] = 1300;
+ if (v87[1] != -1 || v87[3] != -1 || v87[5] != -1 || v87[7] != -1) {
+ v23 = 0;
+ if (v87[5] != -1 && v77[1] >= v77[5] && v77[3] >= v77[5] && v77[7] >= v77[5]) {
+ v73 = v87[5];
+ v72 = v82[5];
+ v23 = 1;
+ }
+ if (v87[1] != -1 && !v23 && v77[5] >= v77[1] && v77[3] >= v77[1] && v77[7] >= v77[1]) {
+ v73 = v87[1];
+ v72 = v82[1];
+ v23 = 1;
+ }
+ if (v87[3] != -1 && !v23 && v77[1] >= v77[3] && v77[5] >= v77[3] && v77[7] >= v77[3]) {
+ v73 = v87[3];
+ v72 = v82[3];
+ v23 = 1;
+ }
+ if (v87[7] != -1 && !v23 && v77[5] >= v77[7] && v77[3] >= v77[7] && v77[1] >= v77[7]) {
+ v73 = v87[7];
+ v72 = v82[7];
+ }
+ v24 = 0;
+ do {
+ v25 = v24;
+ v87[v25] = -1;
+ v82[v25] = 0;
+ v77[v25] = 1300;
+ v76[v25] = 1300;
+ ++v24;
+ } while (v24 <= 8);
+ v26 = _vm->_linesManager.colision2_ligne(a1, a2, &v82[1], &v87[1], 0, DERLIGNE);
+ if (v26 == 1) {
+ v69 = v87[1];
+ v68 = v82[1];
+ }
+ if (!v26) {
+ if (_vm->_linesManager.colision2_ligne(a1, a2, &v82[1], &v87[1], 0, _vm->_linesManager.TOTAL_LIGNES) == 1) {
+ v27 = 0;
+ for (;;) {
+ v28 = _vm->_globals.essai2[v27];
+ v29 = _vm->_globals.essai2[v27 + 1];
+ v66 = _vm->_globals.essai2[v27 + 2];
+ v27 = v27 + 4;
+ v30 = v27;
+ v31 = _vm->_linesManager.colision2_ligne(v28, v29, &v82[1], &v87[1], 0, DERLIGNE);
+ v27 = v30;
+ if (v31)
+ break;
+ v32 = v67;
+ _vm->_globals.super_parcours[v32] = v28;
+ _vm->_globals.super_parcours[v32 + 1] = v29;
+ _vm->_globals.super_parcours[v32 + 2] = v66;
+ _vm->_globals.super_parcours[v32 + 3] = 0;
+
+ v33 = _vm->_globals.essai0;
+ _vm->_globals.essai0[v32] = v28;
+ v33[v32 + 1] = v29;
+ v33[v32 + 2] = v66;
+ v33[v32 + 3] = 0;
+ v67 += 4;
+ if (v28 == -1)
+ goto LABEL_90;
+ }
+ v69 = v87[1];
+ v68 = v82[1];
+ } else {
+ v69 = 1;
+ v68 = 1;
+ v67 = 0;
+ }
+ }
+LABEL_90:
+ if (v69 < v73) {
+ v34 = v68;
+ v35 = v68;
+ for (i = _vm->_linesManager.Ligne[v69].field0; v35 < i - 2; i = _vm->_linesManager.Ligne[v69].field0) {
+ v37 = _vm->_linesManager.Ligne[v69].lineData;
+ v39 = v67;
+ _vm->_globals.super_parcours[v39] = v37[2 * v35];
+ _vm->_globals.super_parcours[v39 + 1] = v37[2 * v35 + 1];
+ _vm->_globals.super_parcours[v39 + 2] = _vm->_linesManager.Ligne[v69].field6;
+ _vm->_globals.super_parcours[v39 + 3] = 0;
+ v67 += 4;
+ ++v34;
+ v35 = v34;
+ }
+ for (j = v69 + 1; j < v73; ++j) {
+ if (_vm->_linesManager.PLAN_TEST(
+ _vm->_linesManager.Ligne[j].lineData[0],
+ _vm->_linesManager.Ligne[j].lineData[1],
+ v67,
+ j,
+ v73,
+ 0) == 1) {
+LABEL_88:
+ v69 = _vm->_linesManager.NV_LIGNEDEP;
+ v68 = _vm->_linesManager.NV_LIGNEOFS;
+ v67 = _vm->_linesManager.NV_POSI;
+ goto LABEL_90;
+ }
+ v40 = 0;
+ if (_vm->_linesManager.Ligne[j].field0 - 2 > 0) {
+ do {
+ v41 = _vm->_linesManager.Ligne[j].lineData;
+ v43 = v67;
+ _vm->_globals.super_parcours[v43] = v41[2 * v40];
+ _vm->_globals.super_parcours[v43 + 1] = v41[2 * v40 + 1];
+ _vm->_globals.super_parcours[v43 + 2] = _vm->_linesManager.Ligne[j].field6;
+ _vm->_globals.super_parcours[v43 + 3] = 0;
+ v67 += 4;
+ ++v40;
+ } while (v40 < _vm->_linesManager.Ligne[j].field0 - 2);
+ }
+ }
+ v68 = 0;
+ v69 = v73;
+ }
+ if (v69 > v73) {
+ for (k = v68; k > 0; --k) {
+ v45 = _vm->_linesManager.Ligne[v69].lineData;
+ v47 = v67;
+ _vm->_globals.super_parcours[v47] = v45[2 * k];
+ _vm->_globals.super_parcours[v47 + 1] = v45[2 * k + 1];
+ _vm->_globals.super_parcours[v47 + 2] = _vm->_linesManager.Ligne[v69].field8;
+ _vm->_globals.super_parcours[v47 + 3] = 0;
+ v67 += 4;
+ }
+ for (l = v69 - 1; l > v73; --l) {
+ v48 = l;
+ if (_vm->_linesManager.PLAN_TEST(
+ _vm->_linesManager.Ligne[l].lineData[2 * _vm->_linesManager.Ligne[v48].field0 - 2],
+ _vm->_linesManager.Ligne[l].lineData[2 * _vm->_linesManager.Ligne[v48].field0 - 1],
+ v67,
+ l,
+ v73,
+ 0) == 1)
+ goto LABEL_88;
+ v49 = _vm->_linesManager.Ligne[v48].field0 - 2;
+ if ((_vm->_linesManager.Ligne[v48].field0 - 2) > 0) {
+ do {
+ v50 = _vm->_linesManager.Ligne[l].lineData;
+ v52 = v67;
+ _vm->_globals.super_parcours[v52] = v50[2 * v49];
+ _vm->_globals.super_parcours[v52 + 1] = v50[2 * v49 + 1];
+ _vm->_globals.super_parcours[v52 + 2] = _vm->_linesManager.Ligne[l].field8;
+ _vm->_globals.super_parcours[v52 + 3] = 0;
+ v67 += 4;
+ --v49;
+ } while (v49 > 0);
+ }
+ }
+ v68 = _vm->_linesManager.Ligne[v73].field0 - 1;
+ v69 = v73;
+ }
+ if (v69 == v73) {
+ if (v68 <= v72) {
+ if (v68 < v72) {
+ v57 = v68;
+ do {
+ v58 = _vm->_linesManager.Ligne[v73].lineData;
+ v60 = v67;
+ _vm->_globals.super_parcours[v60] = v58[2 * v57];
+ _vm->_globals.super_parcours[v60 + 1] = v58[2 * v57 + 1];
+ _vm->_globals.super_parcours[v60 + 2] = _vm->_linesManager.Ligne[v73].field6;
+ _vm->_globals.super_parcours[v60 + 3] = 0;
+ v67 += 4;
+ ++v57;
+ } while (v72 > v57);
+ }
+ } else {
+ v53 = v68;
+ do {
+ v54 = _vm->_linesManager.Ligne[v73].lineData;
+ v56 = v67;
+ _vm->_globals.super_parcours[v56] = v54[2 * v53];
+ _vm->_globals.super_parcours[v56 + 1] = v54[2 * v53 + 1];
+ _vm->_globals.super_parcours[v56 + 2] = _vm->_linesManager.Ligne[v73].field8;
+ _vm->_globals.super_parcours[v56 + 3] = 0;
+ v67 += 4;
+ --v53;
+ } while (v72 < v53);
+ }
+ }
+ v61 = v67;
+ _vm->_globals.super_parcours[v61] = -1;
+ _vm->_globals.super_parcours[v61 + 1] = -1;
+ _vm->_globals.super_parcours[v61 + 2] = -1;
+ _vm->_globals.super_parcours[v61 + 3] = -1;
+ result = &_vm->_globals.super_parcours[0];
+ } else {
+ result = (int16 *)g_PTRNUL;
+ }
+ return result;
+}
+
+void ObjectsManager::VERBEPLUS() {
+ int v;
+
+ v = _vm->_eventsManager.btsouris + 1;
+ _vm->_eventsManager.btsouris = v;
+ if (v == 4)
+ goto LABEL_24;
+ if (v == 5)
+ goto LABEL_28;
+ if (v == 6)
+ goto LABEL_29;
+ if (v == 7)
+ goto LABEL_31;
+ if (v == 8)
+ goto LABEL_33;
+ if (v == 9)
+ goto LABEL_35;
+ if (v == 10)
+ goto LABEL_37;
+ if (v == 11)
+ goto LABEL_39;
+ if (v == 12)
+ goto LABEL_41;
+ if (v == 13)
+ goto LABEL_43;
+ if (v == 14)
+ goto LABEL_45;
+ if (v == 15)
+ goto LABEL_47;
+ if (v == 16)
+ goto LABEL_49;
+ if (v == 17)
+ goto LABEL_51;
+ if (v == 18)
+ goto LABEL_53;
+ if (v == 19)
+ goto LABEL_55;
+ if (v == 20)
+ goto LABEL_57;
+ if (v == 21)
+ goto LABEL_59;
+ if (v == 22)
+ goto LABEL_61;
+ if (v == 23)
+ goto LABEL_63;
+ if (v == 24)
+ goto LABEL_65;
+ if (v == 25)
+ goto LABEL_67;
+ do {
+ do {
+ _vm->_eventsManager.btsouris = 4;
+LABEL_24:
+ if (_vm->_globals.NOMARCHE != true || (v = NUMZONE + 1, (uint16)(NUMZONE + 1) <= 1u)) {
+ if (_vm->_eventsManager.btsouris == 4)
+ return;
+ } else {
+ _vm->_eventsManager.btsouris = 5;
+ }
+LABEL_28:
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 6) {
+LABEL_29:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field6 == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 7) {
+LABEL_31:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field7 == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 8) {
+LABEL_33:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field8 == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 9) {
+LABEL_35:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field9 == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 10) {
+LABEL_37:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldA == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 11) {
+LABEL_39:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldB == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 12) {
+LABEL_41:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldC == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 13) {
+LABEL_43:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldD == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 14) {
+LABEL_45:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldE == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 15) {
+LABEL_47:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldF == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 16) {
+LABEL_49:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field6 == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 17) {
+LABEL_51:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field9 == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 18) {
+LABEL_53:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldA == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 19) {
+LABEL_55:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldB == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 20) {
+LABEL_57:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldC == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 21) {
+LABEL_59:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldF == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 22) {
+LABEL_61:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].fieldD == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 23) {
+LABEL_63:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field8 == 2)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 24) {
+LABEL_65:
+ v = 5 * NUMZONE;
+ if (_vm->_globals.ZONEP[NUMZONE].field9 == 3)
+ return;
+ }
+ v = _vm->_eventsManager.btsouris + 1;
+ _vm->_eventsManager.btsouris = v;
+ } while (v != 25);
+LABEL_67:
+ v = 5 * NUMZONE;
+ } while (_vm->_globals.ZONEP[NUMZONE].fieldE != 2);
+}
+
+void ObjectsManager::BTDROITE() {
+ if ((uint16)(NUMZONE + 1) > 1u) {
+ VERBEPLUS();
+ if (_vm->_eventsManager.btsouris != 23)
+ _vm->_eventsManager.CHANGE_MOUSE(_vm->_eventsManager.btsouris);
+ verbe = _vm->_eventsManager.btsouris;
+ }
+}
+
+int ObjectsManager::MZONE() {
+ signed int result;
+ int16 v1;
+ int16 v2;
+ int v3;
+ int16 v4;
+ int16 v5;
+ int v6;
+ int16 v7;
+ int v8;
+ int v9;
+ int16 yCurrent;
+ int16 v11;
+ int16 j;
+ int16 k;
+ int16 xCurrent;
+ int v15;
+ int16 v16;
+ int16 v17;
+ int16 v18;
+ int16 v19;
+ int16 yp;
+ int16 xp;
+
+ v19 = 0;
+ v18 = 0;
+ v17 = 0;
+ v16 = 0;
+ xp = _vm->_eventsManager.souris_x + _vm->_eventsManager.ofset_souris_x;
+ yp = _vm->_eventsManager.souris_y + _vm->_eventsManager.ofset_souris_y;
+ if ((_vm->_eventsManager.souris_y + _vm->_eventsManager.ofset_souris_y) > 19) {
+ v1 = 0;
+ do {
+ v2 = _vm->_globals.BOBZONE[v1];
+ if (v2) {
+ if (_vm->_globals.BOBZONE_FLAG[v1]) {
+ v3 = v2;
+ v15 = v3;
+ if (_vm->_globals.Bob[v3].field0) {
+ if (_vm->_globals.Bob[v3].frameIndex != 250) {
+ if (!_vm->_globals.Bob[v3].field16) {
+ v4 = _vm->_globals.Bob[v3].oldX;
+ if (xp > v4) {
+ if (xp < _vm->_globals.Bob[v3].oldWidth + v4) {
+ v5 = _vm->_globals.Bob[v3].oldY;
+ if (yp > v5) {
+ if (yp < _vm->_globals.Bob[v3].oldHeight + v5) {
+ v6 = v1;
+ if (_vm->_globals.ZONEP[v1].field4 == -1) {
+ _vm->_globals.ZONEP[v6].destX = 0;
+ _vm->_globals.ZONEP[v1].destY = 0;
+ }
+ if (!_vm->_globals.ZONEP[v6].destX) {
+ if (!_vm->_globals.ZONEP[v1].destY) {
+ _vm->_globals.ZONEP[v6].destX = _vm->_globals.Bob[v15].oldWidth + _vm->_globals.Bob[v15].oldX;
+ _vm->_globals.ZONEP[v1].destY = _vm->_globals.Bob[v15].oldHeight + _vm->_globals.Bob[v15].oldY + 6;
+ _vm->_globals.ZONEP[v1].field4 = -1;
+ }
+ }
+ return v1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ++v1;
+ } while (v1 <= 48);
+ _vm->_globals.SegmentEnCours = 0;
+ v7 = 0;
+ do {
+ if (_vm->_globals.ZONEP[v7].field10 == 1) {
+ v8 = v7;
+ if (_vm->_globals.CarreZone[v8].field0 == 1) {
+ if (_vm->_globals.CarreZone[v7].field2 <= xp
+ && _vm->_globals.CarreZone[v7].field4 >= xp
+ && _vm->_globals.CarreZone[v7].field6 <= yp
+ && _vm->_globals.CarreZone[v7].field8 >= yp) {
+ if (_vm->_globals.CarreZone[v7].fieldE == 1) {
+ _vm->_globals.oldzone_46 = _vm->_linesManager.LigneZone[_vm->_globals.CarreZone[v7].fieldA].field2;
+ return _vm->_globals.oldzone_46;
+ }
+ v9 = _vm->_globals.SegmentEnCours;
+ _vm->_globals.Segment[v9].field2 = _vm->_globals.CarreZone[v7].fieldA;
+ _vm->_globals.Segment[v9].field4 = _vm->_globals.CarreZone[v7].fieldC;
+ ++_vm->_globals.SegmentEnCours;
+ }
+ }
+ }
+ ++v7;
+ } while (v7 <= 99);
+ if (!_vm->_globals.SegmentEnCours)
+ goto LABEL_58;
+
+ for (yCurrent = yp; yCurrent >= 0; --yCurrent) {
+ v11 = colision(xp, yCurrent);
+ v19 = v11;
+ if (v11 != -1 && _vm->_globals.ZONEP[v11].field10 == 1)
+ break;
+ }
+ if (v19 == -1)
+ goto LABEL_58;
+ for (j = yp; j < _vm->_graphicsManager.max_y; ++j) {
+ v18 = colision(xp, j);
+ if (v18 != -1 && _vm->_globals.ZONEP[v19].field10 == 1)
+ break;
+ }
+ if (v18 == -1)
+ goto LABEL_58;
+ for (k = xp; k >= 0; --k) {
+ v16 = colision(k, yp);
+ if (v16 != -1 && _vm->_globals.ZONEP[v19].field10 == 1)
+ break;
+ }
+ if (v16 == -1)
+ goto LABEL_58;
+
+ for (xCurrent = xp; _vm->_graphicsManager.max_x > xCurrent; ++xCurrent) {
+ v17 = colision(xCurrent, yp);
+ if (v17 != -1 && _vm->_globals.ZONEP[v19].field10 == 1)
+ break;
+ }
+ if (v19 == v18 && v19 == v16 && v19 == v17) {
+ _vm->_globals.oldzone_46 = v19;
+ result = v19;
+ } else {
+LABEL_58:
+ _vm->_globals.oldzone_46 = -1;
+ result = -1;
+ }
+ } else {
+ result = 0;
+ }
+ return result;
+}
+
+void ObjectsManager::PARAMCADRE(int a1) {
+ old_cadx = cadx;
+ old_cady = cady;
+ old_cadi = cadi;
+ if ((uint16)(a1 - 1) <= 5u)
+ cady = 120;
+ if ((uint16)(a1 - 7) <= 5u)
+ cady = 158;
+ if ((uint16)(a1 - 13) <= 5u)
+ cady = 196;
+ if ((uint16)(a1 - 19) <= 5u)
+ cady = 234;
+ if ((uint16)(a1 - 25) <= 4u)
+ cady = 272;
+ if (a1 == 1 || a1 == 7 || a1 == 13 || a1 == 19 || a1 == 25)
+ cadx = _vm->_graphicsManager.ofscroll + 158;
+ if (a1 == 2 || a1 == 8 || a1 == 14 || a1 == 20 || a1 == 26)
+ cadx = _vm->_graphicsManager.ofscroll + 212;
+ if (a1 == 3 || a1 == 9 || a1 == 15 || a1 == 21 || a1 == 27)
+ cadx = _vm->_graphicsManager.ofscroll + 266;
+ if (a1 == 4 || a1 == 10 || a1 == 16 || a1 == 22 || a1 == 28)
+ cadx = _vm->_graphicsManager.ofscroll + 320;
+ if (a1 == 5 || a1 == 11 || a1 == 17 || a1 == 23 || a1 == 29)
+ cadx = _vm->_graphicsManager.ofscroll + 374;
+ if (a1 == 6 || a1 == 12 || a1 == 18 || a1 == 24 || (uint16)(a1 - 30) <= 1u)
+ cadx = _vm->_graphicsManager.ofscroll + 428;
+ if ((uint16)(a1 - 1) <= 0x1Cu)
+ cadi = 0;
+ if ((uint16)(a1 - 30) <= 1u)
+ cadi = 2;
+ if (a1 == 30)
+ cady = 272;
+ if (a1 == 31)
+ cady = 290;
+ if (!a1 || a1 == 32) {
+ cadx = 0;
+ cady = 0;
+ cadi = 0;
+ }
+ if (!a1)
+ _vm->_eventsManager.btsouris = 0;
+ if (a1 == 32)
+ _vm->_eventsManager.btsouris = 16;
+ if (a1 == 30)
+ _vm->_eventsManager.btsouris = 2;
+ if (a1 == 31)
+ _vm->_eventsManager.btsouris = 3;
+ if ((uint16)(a1 - 1) <= 0x1Cu)
+ _vm->_eventsManager.btsouris = 8;
+ if (a1 == 29)
+ _vm->_eventsManager.btsouris = 1;
+ if ((uint16)(a1 - 1) <= 0x1Bu && !_vm->_globals.INVENTAIRE[a1]) {
+ _vm->_eventsManager.btsouris = 0;
+ cadx = 0;
+ cady = 0;
+ cadi = 0;
+ }
+ if (_vm->_eventsManager.btsouris != 23)
+ _vm->_eventsManager.CHANGE_MOUSE(_vm->_eventsManager.btsouris);
+ _vm->_eventsManager.XMOUSE();
+ _vm->_eventsManager.YMOUSE();
+}
+
+void ObjectsManager::OBJETPLUS(int idx) {
+ int v1;
+ int v2;
+ int v3;
+
+ v1 = _vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris && _vm->_eventsManager.btsouris != 16 && (uint16)(_vm->_eventsManager.btsouris - 2) > 1u) {
+ v2 = _vm->_eventsManager.btsouris++ + 1;
+ if (v1 == 5)
+ goto LABEL_24;
+ if (v2 == 7)
+ goto LABEL_26;
+ if (v2 != 8) {
+ if (v2 == 9)
+ _vm->_eventsManager.btsouris = 10;
+ if (_vm->_eventsManager.btsouris == 10)
+ goto LABEL_29;
+ if (_vm->_eventsManager.btsouris == 11)
+ goto LABEL_31;
+ if (_vm->_eventsManager.btsouris == 12)
+ _vm->_eventsManager.btsouris = 13;
+ if (_vm->_eventsManager.btsouris == 13)
+ goto LABEL_33;
+ if (_vm->_eventsManager.btsouris == 14)
+ _vm->_eventsManager.btsouris = 15;
+ if (_vm->_eventsManager.btsouris == 15)
+ goto LABEL_35;
+ if ((uint16)(_vm->_eventsManager.btsouris - 16) <= 6u)
+ _vm->_eventsManager.btsouris = 23;
+ if (_vm->_eventsManager.btsouris == 23)
+ goto LABEL_37;
+ if (_vm->_eventsManager.btsouris == 24)
+ _vm->_eventsManager.btsouris = 25;
+ if (_vm->_eventsManager.btsouris == 25)
+ goto LABEL_39;
+ do {
+ _vm->_eventsManager.btsouris = 6;
+LABEL_24:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field2 == 1)
+ break;
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 7) {
+LABEL_26:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field3 == 1)
+ return;
+ }
+ v3 = _vm->_eventsManager.btsouris++;
+ if (_vm->_eventsManager.btsouris == 8)
+ break;
+ _vm->_eventsManager.btsouris = v3 + 3;
+ if (v3 == 7) {
+LABEL_29:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field7 == 1)
+ return;
+ }
+ ++_vm->_eventsManager.btsouris;
+ if (_vm->_eventsManager.btsouris == 11) {
+LABEL_31:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field4 == 1)
+ return;
+ }
+ _vm->_eventsManager.btsouris += 2;
+ if (_vm->_eventsManager.btsouris == 13) {
+LABEL_33:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field5 == 1)
+ return;
+ }
+ _vm->_eventsManager.btsouris += 2;
+ if (_vm->_eventsManager.btsouris == 15) {
+LABEL_35:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field6 == 1)
+ return;
+ }
+ _vm->_eventsManager.btsouris = 23;
+LABEL_37:
+ if (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field6 == 2)
+ break;
+ _vm->_eventsManager.btsouris = 25;
+LABEL_39:
+ ;
+ } while (_vm->_globals.ObjetW[_vm->_globals.INVENTAIRE[idx]].field7 != 2);
+ }
+ }
+}
+
+void ObjectsManager::VALID_OBJET(int a1) {
+ if (_vm->_eventsManager.btsouris == 8)
+ CHANGE_OBJET(a1);
+}
+
+void ObjectsManager::OPTI_OBJET() {
+ byte *data;
+ Common::String file;
+ int v0 = 1;
+ int v5;
+ int v7;
+
+ file = "OBJET1.ini";
+ data = _vm->_fileManager.RECHERCHE_CAT(file, 1);
+ if (data == g_PTRNUL) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file);
+ data = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+
+ if ((data == g_PTRNUL) || *data != 'I' || *(data + 1) != 'N' || *(data + 2) != 'I') {
+ error("Not an INI file");
+ } else {
+ v7 = 0;
+ do {
+ v5 = _vm->_scriptManager.Traduction(data + 20 * v0);
+ if (_vm->shouldQuit())
+ return;
+
+ if (v5 == 2)
+ v0 = _vm->_scriptManager.Control_Goto(data + 20 * v0);
+ if (v5 == 3)
+ v0 = _vm->_scriptManager.Control_If(data, v0);
+ if (v0 == -1)
+ error("defective IFF function");
+ if (v5 == 1 || v5 == 4)
+ ++v0;
+ if (!v5 || v5 == 5)
+ v7 = 1;
+ } while (v7 != 1);
+ }
+ _vm->_globals.dos_free2(data);
+}
+
+void ObjectsManager::SPECIAL_JEU() {
+ byte *v1;
+ byte *v2;
+ byte *v3;
+
+ if ((uint16)(_vm->_globals.ECRAN - 35) <= 6u) {
+ if (_vm->_globals.OLD_ECRAN == 16 && _vm->_globals.ECRAN == 35)
+ TEST_FORET(35, 500, 555, 100, 440, 1);
+ if (_vm->_globals.OLD_ECRAN == 36 && _vm->_globals.ECRAN == 35)
+ TEST_FORET(35, 6, 84, 100, 440, 4);
+ if (_vm->_globals.OLD_ECRAN == 35 && _vm->_globals.ECRAN == 36)
+ TEST_FORET(36, 551, 633, 100, 440, 2);
+ if (_vm->_globals.OLD_ECRAN == 37 && _vm->_globals.ECRAN == 36)
+ TEST_FORET(36, 6, 84, 100, 440, 4);
+ if (_vm->_globals.OLD_ECRAN == 36 && _vm->_globals.ECRAN == 37)
+ TEST_FORET(37, 551, 633, 100, 440, 1);
+ if (_vm->_globals.OLD_ECRAN == 38 && _vm->_globals.ECRAN == 37)
+ TEST_FORET(37, 392, 529, 100, 440, 2);
+ if (_vm->_globals.OLD_ECRAN == 37 && _vm->_globals.ECRAN == 38)
+ TEST_FORET(38, 133, 252, 100, 440, 4);
+ if (_vm->_globals.OLD_ECRAN == 39 && _vm->_globals.ECRAN == 38)
+ TEST_FORET(38, 6, 84, 100, 440, 3);
+ if (_vm->_globals.OLD_ECRAN == 38 && _vm->_globals.ECRAN == 39)
+ TEST_FORET(39, 551, 633, 100, 440, 2);
+ if (_vm->_globals.OLD_ECRAN == 40 && _vm->_globals.ECRAN == 39)
+ TEST_FORET(39, 6, 84, 100, 440, 3);
+ if (_vm->_globals.OLD_ECRAN == 39 && _vm->_globals.ECRAN == 40)
+ TEST_FORET(40, 133, 252, 100, 440, 4);
+ if (_vm->_globals.OLD_ECRAN == 41 && _vm->_globals.ECRAN == 40)
+ TEST_FORET(40, 392, 529, 100, 440, 2);
+ if (_vm->_globals.OLD_ECRAN == 40 && _vm->_globals.ECRAN == 41)
+ TEST_FORET(41, 551, 633, 100, 440, 1);
+ if (_vm->_globals.OLD_ECRAN == 17 && _vm->_globals.ECRAN == 41)
+ TEST_FORET(41, 6, 84, 100, 440, 3);
+ }
+ if (_vm->_globals.ECRAN == 5) {
+ if (YSPR(0) <= 399) {
+ if (!_vm->_globals.SAUVEGARDE->data[svField173]) {
+ _vm->_globals.SAUVEGARDE->data[svField173] = 1;
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("flicspe1.pe2");
+ _vm->_globals.NOPARLE = false;
+ if (!_vm->_globals.CENSURE) {
+ v1 = _vm->_globals.dos_malloc2(0x3E8u);
+ memcpy(v1, _vm->_graphicsManager.Palette, 0x301u);
+
+ _vm->_saveLoadManager.SAUVE_FICHIER("TEMP1.SCR", _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+
+ if (!_vm->_graphicsManager.nbrligne)
+ _vm->_graphicsManager.ofscroll = 0;
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_soundManager.SPECIAL_SOUND = 198;
+ PERSO_ON = true;
+ _vm->_animationManager.NO_SEQ = true;
+ _vm->_animationManager.CLS_ANM = false;
+ _vm->_animationManager.PLAY_ANM("otage.ANM", 1, 24, 500);
+ _vm->_animationManager.NO_SEQ = false;
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_globals.NECESSAIRE = 1;
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_globals.NECESSAIRE = 0;
+
+ _vm->_saveLoadManager.bload("TEMP1.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP1.SCR");
+
+ PERSO_ON = false;
+ memcpy(_vm->_graphicsManager.Palette, v1, 0x301u);
+ _vm->_graphicsManager.SHOW_PALETTE();
+ _vm->_globals.dos_free2(v1);
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ v2 = _vm->_graphicsManager.VESA_BUFFER;
+ v3 = _vm->_graphicsManager.VESA_SCREEN;
+ memcpy(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.VESA_SCREEN, 0x95FFCu);
+ v3 = v3 + 614396;
+ v2 = v2 + 614396;
+ *v2 = *v3;
+ v2 = v2 + 2;
+ *v2 = *(v3 + 2);
+
+ _vm->_graphicsManager.no_scroll = 0;
+ _vm->_graphicsManager.DD_VBL();
+ }
+ }
+ }
+ }
+ if (_vm->_globals.ECRAN == 20)
+ _vm->_globals.SAUVEGARDE->data[svField132] = XSPR(0) > 65
+ && XSPR(0) <= 124
+ && YSPR(0) > 372
+ && YSPR(0) <= 398;
+ if (_vm->_globals.ECRAN == 57) {
+ _vm->_globals.DESACTIVE_INVENT = true;
+ if (_vm->_globals.SAUVEGARDE->data[svField261] == 1 && BOBPOSI(5) == 37) {
+ BOBANIM_OFF(5);
+ SET_BOBPOSI(5, 0);
+ BOBANIM_ON(6);
+ _vm->_globals.SAUVEGARDE->data[svField261] = 2;
+ ZONE_OFF(15);
+ _vm->_soundManager.PLAY_SOUND("SOUND75.WAV");
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField261] == 2 && BOBPOSI(6) == 6) {
+ BOBANIM_OFF(6);
+ SET_BOBPOSI(6, 0);
+ BOBANIM_ON(7);
+ ZONE_ON(14);
+ _vm->_globals.SAUVEGARDE->data[svField261] = 3;
+ }
+ _vm->_globals.DESACTIVE_INVENT = false;
+ }
+ if (_vm->_globals.ECRAN == 93 && !_vm->_globals.SAUVEGARDE->data[svField333]) {
+ _vm->_globals.DESACTIVE_INVENT = true;
+ do
+ _vm->_eventsManager.VBL();
+ while (BOBPOSI(8) != 3);
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("GM3.PE2");
+ BOBANIM_OFF(8);
+ _vm->_globals.SAUVEGARDE->data[svField333] = 1;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ }
+}
+
+void ObjectsManager::BOB_VIVANT(int idx) {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+
+ v1 = 5 * idx;
+ v2 = (int16)READ_LE_UINT16(_vm->_talkManager.ADR_ANIM + 2 * v1);
+ v3 = (int16)READ_LE_UINT16(_vm->_talkManager.ADR_ANIM + 2 * v1 + 2);
+ v4 = *(_vm->_talkManager.ADR_ANIM + 2 * v1 + 8);
+ if ((int16)READ_LE_UINT16(_vm->_talkManager.ADR_ANIM + 2 * v1 + 4)) {
+ if (!_vm->_globals.NO_OFFSET)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_talkManager.PERSOSPR,
+ _vm->_graphicsManager.ofscroll + v2, v3,
+ *(_vm->_talkManager.ADR_ANIM + 2 * v1 + 8));
+ if (_vm->_globals.NO_OFFSET)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_talkManager.PERSOSPR, v2, v3, v4);
+ }
+}
+
+void ObjectsManager::VBOB(byte *src, int idx, int xp, int yp, int frameIndex) {
+ if (idx > 29)
+ error("MAX_VBOB exceeded");
+
+ if (_vm->_globals.VBob[idx].field4 <= 1) {
+ _vm->_globals.VBob[idx].field4 = 1;
+ _vm->_globals.VBob[idx].xp = xp;
+ _vm->_globals.VBob[idx].yp = yp;
+ _vm->_globals.VBob[idx].frameIndex = frameIndex;
+ _vm->_globals.VBob[idx].oldX = xp;
+ _vm->_globals.VBob[idx].oldY = yp;
+ _vm->_globals.VBob[idx].oldFrameIndex = frameIndex;
+ _vm->_globals.VBob[idx].spriteData = src;
+ _vm->_globals.VBob[idx].oldSpriteData = src;
+ if (_vm->_globals.VBob[idx].surface != g_PTRNUL)
+ _vm->_globals.VBob[idx].surface = _vm->_globals.dos_free2(_vm->_globals.VBob[idx].surface);
+ }
+
+ int f4 = _vm->_globals.VBob[idx].field4;
+ if (f4 == 2 || f4 == 4) {
+ _vm->_globals.VBob[idx].field4 = 3;
+ _vm->_globals.VBob[idx].oldX = _vm->_globals.VBob[idx].xp;
+ _vm->_globals.VBob[idx].oldY = _vm->_globals.VBob[idx].yp;
+ _vm->_globals.VBob[idx].oldSpriteData = _vm->_globals.VBob[idx].spriteData;
+ _vm->_globals.VBob[idx].oldFrameIndex = _vm->_globals.VBob[idx].frameIndex;
+ _vm->_globals.VBob[idx].xp = xp;
+ _vm->_globals.VBob[idx].yp = yp;
+ _vm->_globals.VBob[idx].frameIndex = frameIndex;
+ _vm->_globals.VBob[idx].spriteData = src;
+ }
+}
+
+void ObjectsManager::VBOB_OFF(int idx) {
+ if (idx > 29)
+ error("MAX_VBOB exceeded");
+
+ if (_vm->_globals.VBob[idx].field4 <= 1)
+ _vm->_globals.VBob[idx].field4 = 0;
+ else
+ _vm->_globals.VBob[idx].field4 = 4;
+}
+
+void ObjectsManager::ACTION_DOS(int idx) {
+ if (_vm->_globals.GESTE_FLAG != 1) {
+ if (g_PTRNUL != _vm->_globals.GESTE)
+ _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE);
+ _vm->_globals.GESTE_FLAG = 1;
+
+ _vm->_fileManager.CONSTRUIT_SYSTEM("DOS.SPR");
+ _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (idx == 1)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0);
+ if (idx == 2)
+ SPACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,-1,", 0, 0, 8, 0);
+ if (idx == 3)
+ SPACTION1(_vm->_globals.GESTE, "12,11,10,9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8);
+ if (idx == 4)
+ ACTION(
+ _vm->_globals.GESTE,
+ "0,1,2,3,4,5,6,7,8,8,8,8,8,8,9,10,11,12,13,12,11,12,13,12,11,12,13,12,11,10,9,8,7,6,5,4,3,2,1,0,-1,",
+ 0,
+ 0,
+ 8,
+ 0);
+ if (idx == 5)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20,21,-1,", 0, 0, 8, 0);
+ if (idx == 6)
+ SPACTION1(_vm->_globals.GESTE, "20,19,18,17,16,15,-1,", 0, 0, 8);
+ if (idx == 7)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20,21,22,23,24,-1,", 0, 0, 8, 0);
+ if (idx == 8)
+ SPACTION1(_vm->_globals.GESTE, "23,22,21,20,19,18,17,16,15,-1,", 0, 0, 8);
+ if (idx == 9)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20,21,22,23,24,-1,", 0, 0, 8, 0);
+ if (idx == 10)
+ SPACTION1(_vm->_globals.GESTE, "23,22,21,20,19,18,17,16,15,-1,", 0, 0, 8);
+}
+
+void ObjectsManager::ACTION_DROITE(int idx) {
+ if (_vm->_globals.GESTE_FLAG != 3) {
+ if (_vm->_globals.GESTE != g_PTRNUL)
+ _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE);
+ _vm->_globals.GESTE_FLAG = 3;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PROFIL.SPR");
+ _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (idx == 1)
+ ACTION(_vm->_globals.GESTE, "20,19,18,17,16,15,14,13,13,13,13,13,14,15,16,17,18,19,20,-1,", 0, 0, 8, 0);
+ if (idx == 2)
+ SPACTION(_vm->_globals.GESTE, "1,2,3,4,5,6,7,8,-1,", 0, 0, 8, 0);
+ if (idx == 3)
+ SPACTION1(_vm->_globals.GESTE, "9,10,11,12,13,14,15,16,17,18,19,20,-1,", 0, 0, 8);
+ if (idx == 4)
+ ACTION(_vm->_globals.GESTE, "1,2,3,4,5,6,7,8,8,7,6,5,4,3,2,1,-1,", 0, 0, 8, 0);
+ if (idx == 5)
+ SPACTION(_vm->_globals.GESTE, "23,24,25,-1,", 0, 0, 8, 0);
+ if (idx == 6)
+ SPACTION1(_vm->_globals.GESTE, "24,,23,-1,", 0, 0, 8);
+ if (idx == 7)
+ SPACTION(_vm->_globals.GESTE, "23,24,25,26,27,-1,", 0, 0, 8, 0);
+ if (idx == 8)
+ SPACTION1(_vm->_globals.GESTE, "26,25,24,23,-1,", 0, 0, 8);
+ if (idx == 9)
+ SPACTION(_vm->_globals.GESTE, "23,24,25,26,27,28,29,-1,", 0, 0, 8, 0);
+ if (idx == 10)
+ SPACTION1(_vm->_globals.GESTE, "28,27,26,25,24,23,-1,", 0, 0, 8);
+}
+
+void ObjectsManager::Q_DROITE(int idx) {
+ if (_vm->_globals.GESTE_FLAG != 4) {
+ if (_vm->_globals.GESTE != g_PTRNUL)
+ _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE);
+ _vm->_globals.GESTE_FLAG = 4;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("3Q.SPR");
+ _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (idx == 1)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0);
+ if (idx == 2)
+ SPACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,9,10,11,12,-1,", 0, 0, 8, 0);
+ if (idx == 3)
+ SPACTION1(_vm->_globals.GESTE, "11,10,9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8);
+ if (idx == 4)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,9,10,11,12,11,12,11,12,11,12,11,10,9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0);
+ if (idx == 5)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,-1,", 0, 0, 8, 0);
+ if (idx == 6)
+ SPACTION1(_vm->_globals.GESTE, "17,16,15,-1,", 0, 0, 8);
+ if (idx == 7)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20-1,", 0, 0, 8, 0);
+ if (idx == 8)
+ SPACTION1(_vm->_globals.GESTE, "19,18,17,16,15,-1,", 0, 0, 8);
+ if (idx == 9)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20,21,-1,", 0, 0, 8, 0);
+ if (idx == 10)
+ SPACTION1(_vm->_globals.GESTE, "20,19,18,17,15,-1,", 0, 0, 8);
+}
+
+void ObjectsManager::ACTION_FACE(int idx) {
+ if (_vm->_globals.GESTE_FLAG != 2) {
+ if (_vm->_globals.GESTE != g_PTRNUL)
+ _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE);
+ _vm->_globals.GESTE_FLAG = 2;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("FACE.SPR");
+ _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (idx == 1)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,9,9,9,9,9,9,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0);
+ if (idx == 2)
+ SPACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,-1,", 0, 0, 8, 0);
+ if (idx == 3)
+ SPACTION1(_vm->_globals.GESTE, "14,13,12,11,10,9,7,6,5,4,3,2,1,0,-1,", 0, 0, 8);
+ if (idx == 4)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,9,10,11,12,13,14,13,12,11,10,9,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0);
+}
+
+void ObjectsManager::Q_GAUCHE(int idx) {
+ if (_vm->_globals.GESTE_FLAG != 4) {
+ if (_vm->_globals.GESTE != g_PTRNUL)
+ _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE);
+ _vm->_globals.GESTE_FLAG = 4;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("3Q.SPR");
+ _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (idx == 1)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 1);
+ if (idx == 2)
+ SPACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,9,10,11,12,-1,", 0, 0, 8, 1);
+ if (idx == 3)
+ SPACTION1(_vm->_globals.GESTE, "11,10,9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8);
+ if (idx == 4)
+ ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,9,10,11,12,11,12,11,12,11,12,11,10,9,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 1);
+ if (idx == 5)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,-1,", 0, 0, 8, 1);
+ if (idx == 6)
+ SPACTION1(_vm->_globals.GESTE, "17,16,15,-1,", 0, 0, 8);
+ if (idx == 7)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20-1,", 0, 0, 8, 1);
+ if (idx == 8)
+ SPACTION1(_vm->_globals.GESTE, "19,18,17,16,15,-1,", 0, 0, 8);
+ if (idx == 9)
+ SPACTION(_vm->_globals.GESTE, "15,16,17,18,19,20,21,-1,", 0, 0, 8, 1);
+ if (idx == 10)
+ SPACTION1(_vm->_globals.GESTE, "20,19,18,17,15,-1,", 0, 0, 8);
+}
+
+void ObjectsManager::ACTION_GAUCHE(int idx) {
+ if (_vm->_globals.GESTE_FLAG != 3) {
+ if (_vm->_globals.GESTE != g_PTRNUL)
+ _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE);
+ _vm->_globals.GESTE_FLAG = 3;
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PROFIL.SPR");
+ _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ }
+ if (idx == 1)
+ ACTION(_vm->_globals.GESTE, "20,19,18,17,16,15,14,13,13,13,13,13,14,15,16,17,18,19,20,-1,", 0, 0, 8, 1);
+ if (idx == 2)
+ SPACTION(_vm->_globals.GESTE, "1,2,3,4,5,6,7,8,-1,", 0, 0, 8, 1);
+ if (idx == 3)
+ SPACTION1(_vm->_globals.GESTE, "9,10,11,12,13,14,15,16,17,18,19,20,-1,", 0, 0, 8);
+ if (idx == 4)
+ ACTION(_vm->_globals.GESTE, "1,2,3,4,5,6,7,8,8,7,6,5,4,3,2,1,-1,", 0, 0, 8, 1);
+ if (idx == 5)
+ SPACTION(_vm->_globals.GESTE, "23,24,25,-1,", 0, 0, 8, 1);
+ if (idx == 6)
+ SPACTION1(_vm->_globals.GESTE, "24,,23,-1,", 0, 0, 8);
+ if (idx == 7)
+ SPACTION(_vm->_globals.GESTE, "23,24,25,26,27,-1,", 0, 0, 8, 1);
+ if (idx == 8)
+ SPACTION1(_vm->_globals.GESTE, "26,25,24,23,-1,", 0, 0, 8);
+ if (idx == 9)
+ SPACTION(_vm->_globals.GESTE, "23,24,25,26,27,28,29,-1,", 0, 0, 8, 1);
+ if (idx == 10)
+ SPACTION1(_vm->_globals.GESTE, "28,27,26,25,24,23,-1,", 0, 0, 8);
+}
+
+void ObjectsManager::ZONE_ON(int idx) {
+ if (_vm->_globals.BOBZONE[idx]) {
+ _vm->_globals.BOBZONE_FLAG[idx] = true;
+ } else {
+ _vm->_globals.ZONEP[idx].field10 = 1;
+ }
+}
+
+void ObjectsManager::ZONE_OFF(int idx) {
+ if (_vm->_globals.BOBZONE[idx]) {
+ _vm->_globals.BOBZONE_FLAG[idx] = false;
+ } else {
+ _vm->_globals.ZONEP[idx].field10 = 0;
+ }
+
+}
+
+void ObjectsManager::OPTI_ONE(int idx, int a2, int a3, int a4) {
+ if (a4 != 3) {
+ BOBANIM_ON(idx);
+ SET_BOBPOSI(idx, a2);
+ }
+
+ do {
+ _vm->_eventsManager.VBL();
+ } while (a3 != BOBPOSI(idx));
+
+ if (!a4)
+ BOBANIM_OFF(idx);
+ if (a4 == 4) {
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.Bob[idx].spriteData,
+ _vm->_globals.Bob[idx].oldX, _vm->_globals.Bob[idx].oldY, _vm->_globals.Bob[idx].frameIndex);
+ BOBANIM_OFF(idx);
+ _vm->_eventsManager.VBL();
+ }
+}
+
+
+void ObjectsManager::AFFICHE_SPEED1(byte *speedData, int xp, int yp, int img) {
+ SPEED_FLAG = true;
+ SPEED_PTR = speedData;
+ SPEED_X = xp;
+ SPEED_Y = yp;
+ SPEED_IMAGE = img;
+}
+
+int ObjectsManager::BOBPOSI(int idx) {
+ return _vm->_globals.Bob[idx].field10 / 5;
+}
+
+void ObjectsManager::BOBANIM_ON(int idx) {
+ if (_vm->_globals.Bob[idx].field16) {
+ _vm->_globals.Bob[idx].field16 = 0;
+ _vm->_globals.Bob[idx].field10 = 5;
+ _vm->_globals.Bob[idx].frameIndex = 250;
+ _vm->_globals.Bob[idx].field12 = 0;
+ _vm->_globals.Bob[idx].field14 = 0;
+ }
+}
+
+void ObjectsManager::BOBANIM_OFF(int idx) {
+ _vm->_globals.Bob[idx].field16 = 1;
+
+}
+
+void ObjectsManager::SET_BOBPOSI(int idx, int a2) {
+ _vm->_globals.Bob[idx].field10 = 5 * a2;
+ _vm->_globals.Bob[idx].field12 = 0;
+ _vm->_globals.Bob[idx].field14 = 0;
+}
+
+int ObjectsManager::BOBX(int idx) {
+ return _vm->_globals.Bob[idx].xp;
+}
+
+int ObjectsManager::BOBY(int idx) {
+ return _vm->_globals.Bob[idx].yp;
+}
+
+int ObjectsManager::BOBA(int idx) {
+ return _vm->_globals.Bob[idx].frameIndex;
+}
+
+void ObjectsManager::INILINK(const Common::String &file) {
+ int v1;
+ int v2;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ byte *v13;
+ int v14;
+ int v15;
+ byte *v16;
+ byte *v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ byte *v22;
+ int v23;
+ int v24;
+ int v25;
+ int16 v27;
+ int16 v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33;
+ int v34;
+ int v35;
+ int v36;
+ byte *v37;
+ int v40;
+ size_t v41;
+ size_t v42;
+ size_t nbytes;
+ byte *ptr;
+ Common::String filename, filename2;
+ Common::File f;
+
+ v1 = 0;
+ v2 = 0;
+
+ filename = file + ".LNK";
+ ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 3);
+ nbytes = _vm->_globals.CAT_TAILLE;
+ if (ptr == g_PTRNUL) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename);
+
+ if (!f.open(_vm->_globals.NFICHIER))
+ error("Error opening file - %s", _vm->_globals.NFICHIER.c_str());
+
+ nbytes = f.size();
+ ptr = _vm->_globals.dos_malloc2(nbytes);
+ if (g_PTRNUL == ptr)
+ error("INILINK");
+ _vm->_fileManager.bload_it(f, ptr, nbytes);
+ f.close();
+ }
+ if (!OBSSEUL) {
+ for (int idx = 0; idx < 500; ++idx)
+ _vm->_globals.STAILLE[idx] = (int16)READ_LE_UINT16((uint16 *)ptr + idx);
+
+ _vm->_globals.RESET_CACHE();
+
+ filename2 = Common::String((const char *)ptr + 1000);
+ if (!filename2.empty()) {
+ _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.RECHERCHE_CAT(filename2, 8);
+
+ if (_vm->_globals.CACHE_BANQUE[1] || _vm->_globals.CACHE_BANQUE[1] == g_PTRNUL) {
+ _vm->_globals.CAT_FLAG = false;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename2);
+ } else {
+ _vm->_globals.CAT_FLAG = true;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES");
+ }
+
+ _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ _vm->_globals.CAT_FLAG = false;
+ v36 = 60;
+ v37 = ptr + 1000;
+ v40 = 0;
+
+ do {
+ v8 = (int16)READ_LE_UINT16(v37 + 2 * v36);
+ v9 = (int16)READ_LE_UINT16(v37 + 2 * v36 + 2);
+ v10 = (int16)READ_LE_UINT16(v37 + 2 * v36 + 4);
+ v11 = v40;
+
+ _vm->_globals.Cache[v11].field14 = (int16)READ_LE_UINT16(v37 + 2 * v36 + 8);
+ _vm->_globals.Cache[v11].field2 = v8;
+ _vm->_globals.Cache[v11].field0 = v9;
+ _vm->_globals.Cache[v11].field4 = v10;
+ _vm->_globals.Cache[v11].field12 = 1;
+
+ if (!_vm->_globals.CACHE_BANQUE[1]) {
+ _vm->_globals.Cache[v40].fieldA = 0;
+ } else {
+ v12 = v8;
+ v13 = _vm->_globals.CACHE_BANQUE[1];
+ v14 = Get_Largeur(v13, v8);
+ v15 = Get_Hauteur(v13, v12);
+ _vm->_globals.Cache[v40].fieldC = v13;
+ _vm->_globals.Cache[v40].field6 = v14;
+ _vm->_globals.Cache[v40].field8 = v15;
+ _vm->_globals.Cache[v40].fieldA = 1;
+ }
+ if (!_vm->_globals.Cache[v40].field0 && !_vm->_globals.Cache[v40].field4
+ && !_vm->_globals.Cache[v40].field2)
+ _vm->_globals.Cache[v40].fieldA = 0;
+
+ v36 += 5;
+ ++v40;
+ } while (v40 <= 21);
+ _vm->_globals.CACHE_ON();
+ }
+ }
+
+ _vm->_linesManager.RESET_OBSTACLE();
+ v41 = 0;
+ if (nbytes) {
+ do {
+ if (*(ptr + v41) == 'O' && *(ptr + v41 + 1) == 'B' && *(ptr + v41 + 2) == '2') {
+ v16 = ptr + v41 + 4;
+ v32 = 0;
+ v34 = 0;
+ _vm->_linesManager.TOTAL_LIGNES = 0;
+ do {
+ v27 = (int16)READ_LE_UINT16(v16 + 2 * v32);
+ if (v27 != -1) {
+ _vm->_linesManager.AJOUTE_LIGNE(
+ v34,
+ v27,
+ (int16)READ_LE_UINT16(v16 + 2 * v32 + 2),
+ (int16)READ_LE_UINT16(v16 + 2 * v32 + 4),
+ (int16)READ_LE_UINT16(v16 + 2 * v32 + 6),
+ (int16)READ_LE_UINT16(v16 + 2 * v32 + 8),
+ 1);
+ ++_vm->_linesManager.TOTAL_LIGNES;
+ }
+ v32 += 5;
+ ++v34;
+ } while (v27 != -1);
+ _vm->_linesManager.INIPARCOURS();
+ }
+ ++v41;
+ } while (nbytes > v41);
+ }
+ if (!OBSSEUL) {
+ v42 = 0;
+ if (nbytes) {
+ do {
+ if (*(ptr + v42) == 'Z' && *(ptr + v42 + 1) == 'O' && *(ptr + v42 + 2) == '2') {
+ v17 = ptr + v42 + 4;
+ v33 = 0;
+ v35 = 0;
+ v18 = 1;
+ do {
+ v19 = v18;
+ _vm->_globals.ZONEP[v19].destX = 0;
+ _vm->_globals.ZONEP[v19].destY = 0;
+ _vm->_globals.ZONEP[v19].field4 = 0;
+ _vm->_globals.ZONEP[v19].field6 = 0;
+ _vm->_globals.ZONEP[v19].field7 = 0;
+ _vm->_globals.ZONEP[v19].field8 = 0;
+ _vm->_globals.ZONEP[v19].field9 = 0;
+ _vm->_globals.ZONEP[v19].fieldA = 0;
+ _vm->_globals.ZONEP[v19].fieldB = 0;
+ _vm->_globals.ZONEP[v19].fieldC = 0;
+ _vm->_globals.ZONEP[v19].fieldD = 0;
+ _vm->_globals.ZONEP[v19].fieldE = 0;
+ _vm->_globals.ZONEP[v19].fieldF = 0;
+ _vm->_globals.ZONEP[v19].field12 = 0;
+ ++v18;
+ } while (v18 <= 100);
+
+ v31 = 0;
+ do {
+ v28 = (int16)READ_LE_UINT16(v17 + 2 * v33);
+ if (v28 != -1) {
+ _vm->_linesManager.AJOUTE_LIGNE_ZONE(
+ v35,
+ (int16)READ_LE_UINT16(v17 + 2 * v33 + 2),
+ (int16)READ_LE_UINT16(v17 + 2 * v33 + 4),
+ (int16)READ_LE_UINT16(v17 + 2 * v33 + 6),
+ (int16)READ_LE_UINT16(v17 + 2 * v33 + 8),
+ v28);
+ _vm->_globals.ZONEP[v28].field10 = 1;
+ }
+ v33 += 5;
+ ++v35;
+ ++v31;
+ } while (v28 != -1);
+ v20 = 1;
+ do {
+ v21 = v20;
+ _vm->_globals.ZONEP[v21].destX = (int16)READ_LE_UINT16(v17 + 2 * v33);
+ _vm->_globals.ZONEP[v21].destY = (int16)READ_LE_UINT16(v17 + 2 * v33 + 2);
+ _vm->_globals.ZONEP[v21].field4 = (int16)READ_LE_UINT16(v17 + 2 * v33 + 4);
+ v33 += 3;
+ ++v20;
+ } while (v20 <= 100);
+
+ v22 = ptr + v42 + (10 * v31 + 606) + 4;
+ v29 = 0;
+ v23 = 1;
+ do {
+ v24 = v23;
+ _vm->_globals.ZONEP[v24].field6 = *(v29 + v22);
+ _vm->_globals.ZONEP[v24].field7 = *(v22 + v29 + 1);
+ _vm->_globals.ZONEP[v24].field8 = *(v22 + v29 + 2);
+ _vm->_globals.ZONEP[v24].field9 = *(v22 + v29 + 3);
+ _vm->_globals.ZONEP[v24].fieldA = *(v22 + v29 + 4);
+ _vm->_globals.ZONEP[v24].fieldB = *(v22 + v29 + 5);
+ _vm->_globals.ZONEP[v24].fieldC = *(v22 + v29 + 6);
+ _vm->_globals.ZONEP[v24].fieldD = *(v22 + v29 + 7);
+ _vm->_globals.ZONEP[v24].fieldE = *(v22 + v29 + 8);
+ _vm->_globals.ZONEP[v24].fieldF = *(v22 + v29 + 9);
+ v29 += 10;
+ ++v23;
+ } while (v23 <= 100);
+ v30 = 0;
+ v25 = 1;
+ do
+ _vm->_globals.ZONEP[v25].field12 = (int16)READ_LE_UINT16(v22 + 1010 + 2 * v30++);
+ while (++v25 <= 100);
+ CARRE_ZONE();
+ }
+ ++v42;
+ } while (nbytes > v42);
+ }
+ }
+ _vm->_globals.dos_free2(ptr);
+}
+
+void ObjectsManager::SPECIAL_INI(const Common::String &a1) {
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+
+ if (_vm->_globals.ECRAN == 73 && !_vm->_globals.SAUVEGARDE->data[svField318]) {
+ _vm->_globals.CACHE_SUB(0);
+ _vm->_globals.CACHE_SUB(1);
+ }
+ if ((uint16)(_vm->_globals.ECRAN - 35) <= 6u) {
+ _vm->_globals.BOBZONE[20] = 1;
+ _vm->_globals.BOBZONE[21] = 2;
+ _vm->_globals.BOBZONE[22] = 3;
+ _vm->_globals.BOBZONE[23] = 4;
+ _vm->_globals.BOBZONE_FLAG[20] = true;
+ _vm->_globals.BOBZONE_FLAG[21] = true;
+ _vm->_globals.BOBZONE_FLAG[22] = true;
+ _vm->_globals.BOBZONE_FLAG[23] = true;
+ VERBE_ON(20, 5);
+ VERBE_ON(21, 5);
+ VERBE_ON(22, 5);
+ VERBE_ON(23, 5);
+ _vm->_globals.ZONEP[20].field12 = 30;
+ _vm->_globals.ZONEP[21].field12 = 30;
+ _vm->_globals.ZONEP[22].field12 = 30;
+ _vm->_globals.ZONEP[23].field12 = 30;
+ v2 = 200;
+ do {
+ if (_vm->_globals.SAUVEGARDE->data[v2] != 2)
+ _vm->_globals.SAUVEGARDE->data[v2] = 0;
+ ++v2;
+ } while (v2 <= 214);
+ }
+ if (_vm->_globals.ECRAN == 93) {
+ if (!_vm->_globals.SAUVEGARDE->data[svField333])
+ BOBANIM_ON(8);
+ }
+ if (_vm->_globals.ECRAN == 18 && _vm->_globals.OLD_ECRAN == 17) {
+ _vm->_eventsManager.souris_n = 4;
+ _vm->_globals.BPP_NOAFF = true;
+ v3 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v3;
+ } while (v3 <= 4);
+ _vm->_globals.BPP_NOAFF = false;
+ _vm->_graphicsManager.FADE_INW();
+ _vm->_globals.iRegul = 1;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("MAGE1.pe2");
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ }
+ if (_vm->_globals.ECRAN == 17 && _vm->_globals.OLD_ECRAN == 20) {
+ _vm->_globals.DESACTIVE_INVENT = true;
+ _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _vm->_globals.BPP_NOAFF = true;
+ v4 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v4;
+ } while (v4 <= 4);
+ _vm->_globals.BPP_NOAFF = false;
+ _vm->_graphicsManager.FADE_INW();
+ SPRITE_ON(0);
+ v5 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v5;
+ } while (v5 <= 4);
+ VBOB(_vm->_globals.SPRITE_ECRAN, 5, 15, 28, 1);
+ _vm->_fontManager.TEXTE_OFF(9);
+ if (!_vm->_soundManager.TEXTOFF) {
+ _vm->_fontManager.DOS_TEXT(9, 383, _vm->_globals.FICH_TEXTE, 220, 72, 20, 25, 6, 36, 253);
+ if (!_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.TEXTE_ON(9);
+ }
+ if (!_vm->_soundManager.VOICEOFF)
+ _vm->_soundManager.VOICE_MIX(383, 4);
+ _vm->_globals.SAUVEGARDE->data[svField270] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField300] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField320] = 1;
+ if (_vm->_soundManager.VOICEOFF == 1) {
+ v6 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v6;
+ } while (v6 <= 199);
+ }
+ _vm->_fontManager.TEXTE_OFF(9);
+ VBOB_OFF(5);
+ v7 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v7;
+ } while (v7 <= 3);
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ }
+}
+
+void ObjectsManager::OPTI_BOBON(int a1, int a2, int a3, int a4, int a5, int a6, int a7) {
+ if (a1 != -1)
+ BOBANIM_ON(a1);
+ if (a2 != -1)
+ BOBANIM_ON(a2);
+ if (a3 != -1)
+ BOBANIM_ON(a3);
+ if (!a7) {
+ if (a1 != -1)
+ SET_BOBPOSI(a1, a4);
+ if (a2 != -1)
+ SET_BOBPOSI(a2, a5);
+ if (a3 != -1)
+ SET_BOBPOSI(a3, a6);
+ }
+}
+
+void ObjectsManager::SCI_OPTI_ONE(int a1, int a2, int a3, int a4) {
+ _vm->_eventsManager.souris_bb = 0;
+ _vm->_eventsManager.souris_b = 0;
+
+ if (a4 != 3) {
+ BOBANIM_ON(a1);
+ SET_BOBPOSI(a1, a2);
+ }
+
+ do {
+ _vm->_eventsManager.VBL();
+ if (_vm->_eventsManager.souris_bb)
+ break;
+ } while (a3 != BOBPOSI(a1));
+ if (!a4)
+ BOBANIM_OFF(a1);
+}
+
+void ObjectsManager::VERBE_OFF(int idx, int a2) {
+ if (a2 == 6) {
+ _vm->_globals.ZONEP[idx].field6 = 0;
+ }
+ if (a2 == 7) {
+ _vm->_globals.ZONEP[idx].field7 = 0;
+ }
+ if (a2 == 8) {
+ _vm->_globals.ZONEP[idx].field8 = 0;
+ }
+ if (a2 == 9) {
+ _vm->_globals.ZONEP[idx].field9 = 0;
+ }
+ if (a2 == 10) {
+ _vm->_globals.ZONEP[idx].fieldA = 0;
+ }
+ if (a2 == 11) {
+ _vm->_globals.ZONEP[idx].fieldB = 0;
+ }
+ if (a2 == 12) {
+ _vm->_globals.ZONEP[idx].fieldC = 0;
+ }
+ if (a2 == 13) {
+ _vm->_globals.ZONEP[idx].fieldD = 0;
+ }
+ if (a2 == 14 || a2 == 25) {
+ _vm->_globals.ZONEP[idx].fieldE = 0;
+ }
+ if (a2 == 15) {
+ _vm->_globals.ZONEP[idx].fieldF = 0;
+ }
+ if (a2 == 16) {
+ _vm->_globals.ZONEP[idx].field6 = 0;
+ }
+ if (a2 == 5) {
+ _vm->_globals.ZONEP[idx].field8 = 0;
+ }
+ if (a2 == 17) {
+ _vm->_globals.ZONEP[idx].field9 = 0;
+ }
+ if (a2 == 18) {
+ _vm->_globals.ZONEP[idx].fieldA = 0;
+ }
+ if (a2 == 19) {
+ _vm->_globals.ZONEP[idx].fieldB = 0;
+ }
+ if (a2 == 20) {
+ _vm->_globals.ZONEP[idx].fieldC = 0;
+ }
+ if (a2 == 22) {
+ _vm->_globals.ZONEP[idx].fieldD = 0;
+ }
+ if (a2 == 21) {
+ _vm->_globals.ZONEP[idx].fieldE = 0;
+ }
+ if (a2 == 24) {
+ _vm->_globals.ZONEP[idx].field9 = 0;
+ }
+ CHANGEVERBE = 1;
+}
+
+void ObjectsManager::VERBE_ON(int idx, int a2) {
+ if (a2 == 6) {
+ _vm->_globals.ZONEP[idx].field6 = 1;
+ }
+ if (a2 == 7) {
+ _vm->_globals.ZONEP[idx].field7 = 1;
+ }
+ if (a2 == 8) {
+ _vm->_globals.ZONEP[idx].field8 = 1;
+ }
+ if (a2 == 9) {
+ _vm->_globals.ZONEP[idx].field9 = 1;
+ }
+ if (a2 == 10) {
+ _vm->_globals.ZONEP[idx].fieldA = 1;
+ }
+ if (a2 == 11) {
+ _vm->_globals.ZONEP[idx].fieldB = 1;
+ }
+ if (a2 == 12) {
+ _vm->_globals.ZONEP[idx].fieldC = 1;
+ }
+ if (a2 == 13) {
+ _vm->_globals.ZONEP[idx].fieldD = 1;
+ }
+ if (a2 == 14) {
+ _vm->_globals.ZONEP[idx].fieldD = 1;
+ }
+ if (a2 == 15) {
+ _vm->_globals.ZONEP[idx].fieldE = 1;
+ }
+ if (a2 == 16) {
+ _vm->_globals.ZONEP[idx].field6 = 2;
+ }
+ if (a2 == 5) {
+ _vm->_globals.ZONEP[idx].field8 = 2;
+ }
+ if (a2 == 17) {
+ _vm->_globals.ZONEP[idx].field9 = 2;
+ }
+ if (a2 == 18) {
+ _vm->_globals.ZONEP[idx].fieldA = 2;
+ }
+ if (a2 == 19) {
+ _vm->_globals.ZONEP[idx].fieldB = 2;
+ }
+ if (a2 == 20) {
+ _vm->_globals.ZONEP[idx].fieldC = 2;
+ }
+ if (a2 == 22) {
+ _vm->_globals.ZONEP[idx].fieldD = 2;
+ }
+ if (a2 == 21) {
+ _vm->_globals.ZONEP[idx].fieldE = 2;
+ }
+ if (a2 == 24) {
+ _vm->_globals.ZONEP[idx].field9 = 3;
+ }
+ if (a2 == 25) {
+ _vm->_globals.ZONEP[idx].fieldE = 2;
+ }
+}
+
+int ObjectsManager::CALC_PROPRE(int idx) {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+
+ v1 = 25;
+ v2 = _vm->_globals.STAILLE[idx];
+ if (_vm->_globals.PERSO_TYPE == 1) {
+ v3 = _vm->_globals.STAILLE[idx];
+ if (v2 < 0)
+ v3 = -v2;
+ v2 = 20 * (5 * v3 - 100) / -80;
+ }
+ if (_vm->_globals.PERSO_TYPE == 2) {
+ v4 = v2;
+ if (v2 < 0)
+ v4 = -v2;
+ v2 = 20 * (5 * v4 - 165) / -67;
+ }
+ if (v2 < 0)
+ return _vm->_graphicsManager.Reel_Reduc(0x19u, -v2);
+ if (v2 > 0)
+ return _vm->_graphicsManager.Reel_Zoom(0x19u, v2);
+
+ return v1;
+}
+
+int ObjectsManager::colision(int xp, int yp) {
+ if (_vm->_globals.SegmentEnCours <= 0)
+ return -1;
+
+ int xMax = xp + 4;
+ int xMin = xp - 4;
+
+ for (int idx = 0; idx <= _vm->_globals.SegmentEnCours; ++idx) {
+ int field2 = _vm->_globals.Segment[idx].field2;
+ if (_vm->_globals.Segment[idx].field4 < field2)
+ continue;
+
+ int yMax = yp + 4;
+ int yMin = yp - 4;
+
+ do {
+ int16 *dataP = _vm->_linesManager.LigneZone[field2].zoneData;
+ if (dataP != (int16 *)g_PTRNUL) {
+ int count = _vm->_linesManager.LigneZone[field2].count;
+ int v1 = *dataP;
+ int v2 = *(dataP + 1);
+ int v3 = *(dataP + count * 2 - 2);
+ int v4 = *(dataP + count * 2 - 1);
+
+ bool flag = true;
+ if (v1 < v3 && (xMax < v1 || xMin > v3))
+ flag = false;
+ if (v1 >= v3 && (xMin > v1 || xMax < v3))
+ flag = false;
+ if (v2 < v4 && (yMax < v2 || yMin > v4))
+ flag = false;
+ if (v2 >= v4 && (yMin > v2 || yMax < v4))
+ flag = false;
+
+ if (flag && _vm->_linesManager.LigneZone[field2].count > 0) {
+ for (int v5 = 0; v5 < count; ++v5) {
+ int xCheck = *dataP++;
+ int yCheck = *dataP++;
+
+ if ((xp == xCheck || (xp + 1) == xCheck) && (yp == yCheck))
+ return _vm->_linesManager.LigneZone[field2].field2;
+ }
+ }
+ }
+ } while (++field2 <= _vm->_globals.Segment[idx].field4);
+ }
+
+ return -1;
+}
+
+void ObjectsManager::ACTION(const byte *spriteData, const Common::String &a2, int a3, int a4, int a5, int a6) {
+ int v6;
+ int v7;
+ char v8;
+ int v9;
+ int v10;
+ int v11;
+ int v13;
+ const byte *v14;
+ char v15;
+ int v16;
+ int spriteIndex;
+ int v18;
+ Common::String v19;
+
+ v18 = 0;
+ v6 = 0;
+ v13 = 0;
+ v15 = a5;
+ v19 = " ";
+ if (_vm->_globals.vitesse == 2)
+ v15 = a5 / 2;
+ if (_vm->_globals.vitesse == 3)
+ v15 = a5 / 3;
+ v14 = Sprite[0].spriteData;
+ spriteIndex = Sprite[0].spriteIndex;
+ v16 = Sprite[0].fieldE;
+ Sprite[0].field12 += a3;
+ Sprite[0].field14 += a4;
+ Sprite[0].fieldE = a6;
+
+ for (;;) {
+ v7 = 0;
+ v8 = a2[v18];
+ if (v8 == ',') {
+ v9 = atoi(v19.c_str());
+ v13 = v9;
+ v6 = 0;
+ v19 = " ";
+ v7 = 1;
+ } else {
+ v9 = v6;
+ v19 += v8;
+ v6 = v6 + 1;
+ }
+ ++v18;
+ if (v7 == 1) {
+ if (v13 == -1) {
+ Sprite[0].spriteData = v14;
+ Sprite[0].spriteIndex = spriteIndex;
+ Sprite[0].field12 -= a3;
+ Sprite[0].field14 -= a4;
+ Sprite[0].fieldE = v16;
+ } else {
+ Sprite[0].spriteData = spriteData;
+ Sprite[0].spriteIndex = v13;
+ }
+ v10 = 0;
+ v9 = v15;
+ if (v15 > 0) {
+ do {
+ v11 = v9;
+ _vm->_eventsManager.VBL();
+ ++v10;
+ v9 = v11;
+ } while (v10 < v11);
+ }
+ if (v13 == -1)
+ break;
+ }
+ }
+}
+
+void ObjectsManager::SPACTION(byte *a1, const Common::String &a2, int a3, int a4, int a5, int a6) {
+ int v6;
+ int16 v7;
+ char v8;
+ int v9;
+ int16 v10;
+ int v11;
+ int spriteIndex;
+ char v14;
+ int16 v15;
+ Common::String v16;
+
+ v15 = 0;
+ v6 = 0;
+ spriteIndex = 0;
+ v16 = " ";
+ v14 = a5;
+ if (_vm->_globals.vitesse == 2)
+ v14 = a5 / 2;
+ if (_vm->_globals.vitesse == 3)
+ v14 = a5 / 3;
+ S_old_spr = Sprite[0].spriteData;
+ S_old_ani = Sprite[0].spriteIndex;
+ S_old_ret = Sprite[0].fieldE;
+ Sprite[0].field12 += a3;
+ Sprite[0].field14 += a4;
+ Sprite[0].fieldE = a6;
+ do {
+ do {
+ v7 = 0;
+ v8 = a2[v15];
+ if (v8 == ',') {
+ v9 = atoi(v16.c_str());
+ spriteIndex = v9;
+ v6 = 0;
+ v16 = " ";
+ v7 = 1;
+ } else {
+ v9 = v6;
+ v16.setChar(v8, v6);
+ v6 = v6 + 1;
+ }
+ ++v15;
+ } while (v7 != 1);
+ if (spriteIndex != -1) {
+ Sprite[0].spriteData = a1;
+ Sprite[0].spriteIndex = spriteIndex;
+ }
+ v10 = 0;
+ v9 = v14;
+ if (v14 > 0) {
+ do {
+ v11 = v9;
+ _vm->_eventsManager.VBL();
+ ++v10;
+ v9 = v11;
+ } while (v10 < v11);
+ }
+ } while (spriteIndex != -1);
+}
+
+void ObjectsManager::SPACTION1(byte *a1, const Common::String &a2, int a3, int a4, int a5) {
+ int v5;
+ int v6;
+ char v7;
+ int v8;
+ int v9;
+ int v10;
+ int spriteIndex;
+ int v13;
+ int v14;
+ Common::String v15;
+ int v16;
+
+ v14 = 0;
+ v5 = 0;
+ spriteIndex = 0;
+ v15 = " ";
+ v13 = a5;
+ if (_vm->_globals.vitesse == 2)
+ v13 = a5 / 2;
+ if (_vm->_globals.vitesse == 3)
+ v13 = a5 / 3;
+ while (1) {
+ v6 = 0;
+ v7 = a2[v14];
+ if (v7 == 44) {
+ v8 = atoi(v15.c_str());
+ spriteIndex = v8;
+ v5 = 0;
+ v15 = " ";
+ v6 = 1;
+ } else {
+ v8 = v5;
+ v15.setChar(v7, v5);
+ v5 = v5 + 1;
+ }
+ ++v14;
+ if (v6 == 1) {
+ if (spriteIndex == -1) {
+ Sprite[0].spriteData = S_old_spr;
+ Sprite[0].spriteIndex = S_old_ani;
+ Sprite[0].field12 -= a3;
+ Sprite[0].field14 -= a4;
+ Sprite[0].fieldE = S_old_ret;
+ } else {
+ Sprite[0].spriteData = a1;
+ Sprite[0].spriteIndex = spriteIndex;
+ }
+
+ v9 = 0;
+ v16 = v13;
+ if (v13 > 0) {
+ do {
+ v10 = v8;
+ _vm->_eventsManager.VBL();
+ ++v9;
+ v16 = v10;
+ } while (v9 < v10);
+ }
+ if (spriteIndex == -1)
+ break;
+ }
+ }
+}
+
+void ObjectsManager::TEST_FORET(int a1, int a2, int a3, int a4, int a5, int a6) {
+ signed int v6;
+ char v7;
+
+ v6 = a1;
+ if (_vm->_globals.ECRAN == a1) {
+ if (a1 == 35) {
+ if (a6 > 2 || (v6 = 200, a6 > 2))
+ v6 = 201;
+ }
+ if (_vm->_globals.ECRAN == 36) {
+ if (a6 > 2 || (v6 = 202, a6 > 2))
+ v6 = 203;
+ }
+ if (_vm->_globals.ECRAN == 37) {
+ if (a6 > 2 || (v6 = 204, a6 > 2))
+ v6 = 205;
+ }
+ if (_vm->_globals.ECRAN == 38) {
+ if (a6 > 2 || (v6 = 206, a6 > 2))
+ v6 = 207;
+ }
+ if (_vm->_globals.ECRAN == 39) {
+ if (a6 > 2 || (v6 = 208, a6 > 2))
+ v6 = 209;
+ }
+ if (_vm->_globals.ECRAN == 40) {
+ if (a6 > 2 || (v6 = 210, a6 > 2))
+ v6 = 211;
+ }
+ if (_vm->_globals.ECRAN == 41) {
+ if (a6 > 2 || (v6 = 212, a6 > 2))
+ v6 = 213;
+ }
+ v7 = _vm->_globals.SAUVEGARDE->data[v6];
+ if (v7 != 2) {
+ if (v7) {
+ if (v7 == 1) {
+ if (a6 == 1 && BOBPOSI(1) == 26) {
+ _vm->_dialogsManager.VIRE_INVENT = true;
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ _vm->_globals.SAUVEGARDE->data[v6] = 4;
+ }
+ if (a6 == 2 && BOBPOSI(2) == 26) {
+ _vm->_dialogsManager.VIRE_INVENT = true;
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ _vm->_globals.SAUVEGARDE->data[v6] = 4;
+ }
+ if (a6 == 3 && BOBPOSI(3) == 27) {
+ _vm->_dialogsManager.VIRE_INVENT = true;
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ _vm->_globals.SAUVEGARDE->data[v6] = 4;
+ }
+ if (a6 == 4 && BOBPOSI(4) == 27) {
+ _vm->_dialogsManager.VIRE_INVENT = true;
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ _vm->_dialogsManager.VIRE_INVENT = true;
+ _vm->_globals.SAUVEGARDE->data[v6] = 4;
+ }
+ }
+ if (_vm->_globals.SAUVEGARDE->data[v6] == 4) {
+ if (a6 == 1 && (signed int)BOBPOSI(1) > 30)
+ _vm->_globals.SAUVEGARDE->data[v6] = 3;
+ if (a6 == 2 && (signed int)BOBPOSI(2) > 30)
+ _vm->_globals.SAUVEGARDE->data[v6] = 3;
+ if (a6 == 3 && (signed int)BOBPOSI(3) > 30)
+ _vm->_globals.SAUVEGARDE->data[v6] = 3;
+ if (a6 == 4 && (signed int)BOBPOSI(4) > 30)
+ _vm->_globals.SAUVEGARDE->data[v6] = 3;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[v6] == 3) {
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_animationManager.PLAY_ANM("CREVE2.ANM", 100, 24, 500);
+ _vm->_globals.SORTIE = 150;
+ _vm->_graphicsManager.NOFADE = true;
+ BOB_OFF(1);
+ BOB_OFF(2);
+ BOB_OFF(3);
+ BOB_OFF(4);
+ }
+ } else if (a2 < XSPR(0)
+ && a3 > XSPR(0)
+ && a4 < YSPR(0)
+ && a5 > YSPR(0)) {
+ if (a6 == 1)
+ BOBANIM_ON(1);
+ if (a6 == 2)
+ BOBANIM_ON(2);
+ if (a6 == 3)
+ BOBANIM_ON(3);
+ if (a6 == 4)
+ BOBANIM_ON(4);
+ _vm->_globals.SAUVEGARDE->data[v6] = 1;
+ }
+ }
+ }
+}
+
+void ObjectsManager::BLOQUE_ANIMX(int idx, int a2) {
+ _vm->_globals.BL_ANIM[idx].v1 = 1;
+ _vm->_globals.BL_ANIM[idx].v2 = a2;
+}
+
+void ObjectsManager::PERSONAGE(const Common::String &s1, const Common::String &s2, const Common::String &s3,
+ const Common::String &s4, int v) {
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+
+ v5 = 0;
+ _vm->_dialogsManager.INVENTFLAG = false;
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+ _vm->_dialogsManager.VIRE_INVENT = false;
+ _vm->_graphicsManager.ofscroll = 0;
+ _vm->_globals.PLAN_FLAG = false;
+ _vm->_globals.iRegul = 1;
+ _vm->_soundManager.WSOUND(v);
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.NOMARCHE = true;
+ _vm->_globals.SORTIE = 0;
+ _vm->_globals.AFFLI = 0;
+ _vm->_globals.AFFIVBL = 0;
+ if (!s1.empty())
+ _vm->_graphicsManager.LOAD_IMAGE(s1);
+ if (!s2.empty())
+ INILINK(s2);
+ if (!s3.empty())
+ _vm->_animationManager.CHARGE_ANIM(s3);
+ _vm->_graphicsManager.VISU_ALL();
+ if (!s4.empty()) {
+ if (!_vm->_globals.NOSPRECRAN)
+ _vm->_graphicsManager.INI_ECRAN(s4);
+ if (!s4.empty() && _vm->_globals.NOSPRECRAN == 1)
+ _vm->_graphicsManager.INI_ECRAN2(s4);
+ }
+ _vm->_eventsManager.MOUSE_ON();
+ if (_vm->_globals.ECRAN == 61) {
+ SPRITE(_vm->_globals.PERSO, 330, 418, 0, 60, 0, 0, 34, 190);
+ SPRITE_ON(0);
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ VERIFTAILLE();
+ }
+ _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ _vm->_globals.BPP_NOAFF = true;
+ v6 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v6;
+ } while (v6 <= 4);
+ _vm->_globals.BPP_NOAFF = false;
+ _vm->_graphicsManager.FADE_INW();
+ if (_vm->_globals.ECRAN == 61) {
+ _vm->_animationManager.PLAY_SEQ(0, "OUVRE.SEQ", 10, 4, 10);
+ BOBANIM_OFF(3);
+ _vm->_globals.NOT_VERIF = 1;
+ g_old_x = XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ v7 = YSPR(0);
+ v8 = XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v8, v7, 330, 345);
+ _vm->_globals.NOT_VERIF = 1;
+ do {
+ GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ SETANISPR(0, 64);
+ }
+ do {
+ v9 = _vm->_eventsManager.BMOUSE();
+ if (v9 == 1) {
+ BTGAUCHE();
+ v9 = 1;
+ }
+ if (v9 == 2)
+ BTDROITE();
+ _vm->_dialogsManager.TestForDialogOpening();
+ VERIFZONE();
+ if (_vm->_globals.GOACTION == 1)
+ PARADISE();
+ if (!_vm->_globals.SORTIE) {
+ _vm->_eventsManager.VBL();
+ if (!_vm->_globals.SORTIE)
+ continue;
+ }
+ v5 = 1;
+ } while (!_vm->shouldQuit() && v5 != 1);
+ if (_vm->shouldQuit())
+ return;
+
+ _vm->_graphicsManager.FADE_OUTW();
+ if (!s3.empty())
+ _vm->_graphicsManager.FIN_VISU();
+ if (_vm->_globals.ECRAN == 61)
+ SPRITE_OFF(0);
+ CLEAR_ECRAN();
+ _vm->_globals.iRegul = 0;
+}
+
+void ObjectsManager::PERSONAGE2(const Common::String &s1, const Common::String &s2, const Common::String &s3,
+ const Common::String &s4, int v) {
+ int mouseButtons;
+ bool breakFlag;
+ int xp, yp;
+
+ _vm->_dialogsManager.INVENTFLAG = false;
+ _vm->_eventsManager.GAME_KEY = KEY_NONE;
+ verbe = 4;
+ _vm->_globals.MAX_COMPTE = 6;
+ _vm->_graphicsManager.ofscroll = 0;
+ _vm->_dialogsManager.VIRE_INVENT = false;
+ _vm->_globals.PLAN_FLAG = false;
+ _vm->_graphicsManager.NOFADE = false;
+ _vm->_globals.NOMARCHE = false;
+ _vm->_globals.SORTIE = 0;
+ _vm->_globals.AFFLI = 0;
+ _vm->_globals.AFFIVBL = 0;
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_soundManager.WSOUND(v);
+ _vm->_globals.iRegul = 1;
+ if (!s1.empty())
+ _vm->_graphicsManager.LOAD_IMAGE(s1);
+ if (!s2.empty())
+ INILINK(s2);
+ if (!s3.empty()) {
+ _vm->_animationManager.CHARGE_ANIM(s3);
+ _vm->_graphicsManager.VISU_ALL();
+ }
+ if (!s4.empty()) {
+ if (!_vm->_globals.NOSPRECRAN)
+ _vm->_graphicsManager.INI_ECRAN(s4);
+ if (!s4.empty() && _vm->_globals.NOSPRECRAN == 1)
+ _vm->_graphicsManager.INI_ECRAN2(s4);
+ }
+ _vm->_eventsManager.MOUSE_ON();
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ if (!_vm->_globals.PERSO_TYPE)
+ goto LABEL_70;
+ if (!_vm->_globals.SAUVEGARDE->data[svField122] && !_vm->_globals.SAUVEGARDE->data[svField356]) {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 0;
+ }
+ if (!_vm->_globals.PERSO_TYPE) {
+LABEL_70:
+ if (_vm->_globals.SAUVEGARDE->data[svField122] == 1) {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("HOPFEM.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 1;
+ }
+ }
+ if (_vm->_globals.PERSO_TYPE != 2 && _vm->_globals.SAUVEGARDE->data[svField356] == 1) {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PSAMAN.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 2;
+ }
+ _vm->_globals.HOPKINS_DATA();
+ if (!_vm->_globals.PERSO_TYPE)
+ SPRITE(_vm->_globals.PERSO, PERX, PERY, 0, PERI, 0, 0, 34, 190);
+ if (_vm->_globals.PERSO_TYPE == 1)
+ SPRITE(_vm->_globals.PERSO, PERX, PERY, 0, PERI, 0, 0, 28, 155);
+ if (_vm->_globals.PERSO_TYPE == 2)
+ SPRITE(_vm->_globals.PERSO, PERX, PERY, 0, PERI, 0, 0, 20, 127);
+ _vm->_eventsManager.souris_xy(PERX, PERY);
+ if (_vm->_graphicsManager.DOUBLE_ECRAN == true)
+ _vm->_graphicsManager.SCROLL = (int16)XSPR(0) - 320;
+ VERIFTAILLE();
+ SPRITE_ON(0);
+ _vm->_globals.CACHE_ON();
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ VERIFTAILLE();
+ SPECIAL_INI(s2);
+ _vm->_eventsManager.souris_n = 4;
+ g_old_x = PERX;
+ g_old_y = PERY;
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.BPP_NOAFF = true;
+
+ for (int idx = 0; idx < 5; ++idx) {
+ _vm->_eventsManager.VBL();
+ }
+
+ _vm->_globals.BPP_NOAFF = false;
+ _vm->_globals.iRegul = 1;
+ if (!_vm->_graphicsManager.NOFADE)
+ _vm->_graphicsManager.FADE_INW();
+ _vm->_graphicsManager.NOFADE = false;
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+
+ int xCheck = 0;
+ int yCheck = 0;
+
+ breakFlag = false;
+ while (!_vm->shouldQuit() && !breakFlag) {
+ mouseButtons = _vm->_eventsManager.BMOUSE();
+ if (mouseButtons) {
+ if (mouseButtons == 1) {
+ if (verbe == 16 && _vm->_eventsManager.btsouris == 16) {
+ xp = _vm->_eventsManager.XMOUSE();
+ yp = _vm->_eventsManager.YMOUSE();
+
+ if (xCheck == xp) {
+ if (yCheck == yp) {
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ PARADISE();
+ if (_vm->_globals.SORTIE)
+ breakFlag = true;
+ }
+ }
+ xCheck = xp;
+ yCheck = yp;
+ }
+ BTGAUCHE();
+ } else if (mouseButtons == 2) {
+ BTDROITE();
+ }
+ }
+ if (!_vm->_globals.SORTIE) {
+ _vm->_dialogsManager.TestForDialogOpening();
+ VERIFZONE();
+ if (_vm->_globals.chemin == (int16 *)g_PTRNUL
+ || (GOHOME(), _vm->_globals.chemin == (int16 *)g_PTRNUL)) {
+ if (_vm->_globals.GOACTION == 1)
+ PARADISE();
+ }
+ SPECIAL_JEU();
+ _vm->_eventsManager.VBL();
+ if (!_vm->_globals.SORTIE)
+ continue;
+ }
+ breakFlag = true;
+ }
+
+ if (_vm->_globals.SORTIE != 8 || _vm->_globals.ECRAN != 5 || _vm->_globals.HELICO != 1) {
+ if (!_vm->_graphicsManager.NOFADE)
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_graphicsManager.NOFADE = false;
+ SPRITE_OFF(0);
+ _vm->_globals.AFFLI = 0;
+ if (DEUXPERSO == true) {
+ SPRITE_OFF(1);
+ DEUXPERSO = false;
+ }
+ if (!s3.empty())
+ _vm->_graphicsManager.FIN_VISU();
+ CLEAR_ECRAN();
+ } else {
+ _vm->_globals.HELICO = 0;
+ }
+ _vm->_globals.iRegul = 0;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h
new file mode 100644
index 0000000000..60ace316da
--- /dev/null
+++ b/engines/hopkins/objects.h
@@ -0,0 +1,248 @@
+/* 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_OBJECTS_H
+#define HOPKINS_OBJECTS_H
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/str.h"
+#include "hopkins/globals.h"
+
+namespace Hopkins {
+
+struct SpriteItem {
+ int field0;
+ const byte *spriteData;
+ Common::Point spritePos;
+ int spriteY;
+ int fieldC;
+ int fieldE;
+ int spriteIndex;
+ int field12;
+ int field14;
+ byte *field1C;
+ int field20;
+ int field22;
+ int field24;
+ int field26;
+ int field28;
+ int field2A;
+ int field2C;
+ int field2E;
+ int field30;
+ int field32;
+ int field34;
+ int field36;
+};
+
+class HopkinsEngine;
+
+class ObjectsManager {
+private:
+ HopkinsEngine *_vm;
+
+public:
+ SpriteItem Sprite[6];
+ int PRIORITY;
+ int old_cadx, old_cady, old_cadi;
+ int cadx, cady, cadi;
+ int SL_X, SL_Y;
+ int I_old_x, I_old_y;
+ int g_old_x, g_old_y;
+ int FLAG_VISIBLE_EFFACE;
+ byte *SL_SPR;
+ byte *SL_SPR2;
+ byte *sprite_ptr;
+ const byte *S_old_spr;
+ bool PERSO_ON;
+ bool SL_FLAG;
+ int SL_MODE;
+ bool FLAG_VISIBLE;
+ int DESACTIVE_CURSOR;
+ bool BOBTOUS;
+ int my_anim;
+ int NUMZONE;
+ int ARRET_PERSO_FLAG;
+ int ARRET_PERSO_NUM;
+ int FORCEZONE;
+ int CHANGEVERBE;
+ int verbe;
+ int Vold_taille;
+ bool SPEED_FLAG;
+ int SPEED_X, SPEED_Y;
+ int SPEED_IMAGE;
+ byte *SPEED_PTR;
+ int DERLIGNE;
+ int A_ANIM;
+ int MA_ANIM;
+ int MA_ANIM1;
+ int A_DEPA;
+ int MAX_DEPA;
+ int MAX_DEPA1;
+ int CH_TETE;
+ int T_RECTIF;
+ bool DESACTIVE;
+ bool DEUXPERSO;
+ int PERX, PERY;
+ int PERI;
+ int RECALL;
+ int PTAILLE;
+ int PEROFX;
+ int PEROFY;
+ int OBSSEUL;
+ int NVVERBE;
+ int NVZONE;
+ int S_old_ani;
+ int S_old_ret;
+ int nouveau_x, nouveau_y;
+ int nouveau_sens;
+ int nouveau_anim;
+public:
+ ObjectsManager();
+ void setParent(HopkinsEngine *vm);
+
+ byte *CHANGE_OBJET(int objIndex);
+ byte *CAPTURE_OBJET(int objIndex, int mode);
+ void DELETE_OBJET(int objIndex);
+
+ int Get_Largeur(const byte *objectData, int idx);
+ int Get_Hauteur(const byte *objectData, int idx);
+ int sprite_alone(const byte *objectData, byte *sprite, int objIndex);
+ byte *DEL_FICHIER_OBJ();
+
+ byte *CHARGE_SPRITE(const Common::String &file);
+ void set_offsetxy(byte *data, int idx, int xp, int yp, bool isSize);
+ int get_offsetx(const byte *spriteData, int spriteIndex, bool isSize);
+ int get_offsety(const byte *spriteData, int spriteIndex, bool isSize);
+ void AFF_SPRITES();
+
+ int capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex);
+ int AJOUTE_OBJET(int objIndex);
+
+ void INIT_BOB();
+ void BOB_ZERO(int idx);
+ void DEF_BOB(int idx);
+ void BOB_VISU(int idx);
+ void BOB_OFF(int idx);
+ void BOB_OFFSET(int idx, int v);
+ void BOB_ADJUST(int idx, int v);
+ void BOB_OFFSETY(int idx, int v);
+ void SCBOB(int idx);
+ void CALCUL_BOB(int idx);
+
+ void VERIFCACHE();
+ void DEF_SPRITE(int idx);
+ void DEF_CACHE(int idx);
+ void CALCUL_SPRITE(int idx);
+ int AvantTri(TriMode triMode, int index, int priority);
+ void AFF_BOB_ANIM();
+ void AFF_VBOB();
+
+ int XSPR(int idx);
+ int YSPR(int idx);
+ void SPRITE_NOW(const byte *spriteData, int a2, int a3, int a4, int a5, int a6, int a7, int a8);
+
+ void CLEAR_SPR();
+ void SPRITE_ON(int idx);
+ void SPRITE(const byte *spriteData, int xp, int yp, int idx, int spriteIndex, int a6, int a7, int a8, int a9);
+ void SPRITE2(const byte *spriteData, int idx, byte *a3, int a4, int a5);
+ void SPRITE_OFF(int idx);
+ void SPRITE_GEL(int idx);
+ int SXSPR(int idx);
+ int SYSPR(int idx);
+ int POSISPR(int idx);
+ void SETPOSISPR(int idx, int a2);
+ void SETXSPR(int idx, int xp);
+ void SETANISPR(int idx, int spriteIndex);
+ void SETYSPR(int idx, int yp);
+ void SETTAILLESPR(int idx, int a2);
+ void SETFLIPSPR(int idx, int a2);
+
+ void VERIFZONE();
+ void GOHOME();
+ void GOHOME2();
+ void CHARGE_OBSTACLE(const Common::String &file);
+ void CHARGE_ZONE(const Common::String &file);
+ void CARRE_ZONE();
+ void PLAN_BETA();
+ void BTGAUCHE();
+ void PARADISE();
+ void CLEAR_ECRAN();
+
+ void CHANGE_TETE(int a1, int a2);
+ void VERIFTAILLE();
+ void PACOURS_PROPRE(int16 *a1);
+ int16 *PARC_VOITURE(int a1, int a2, int a3, int a4);
+ void VERBEPLUS();
+ void BTDROITE();
+ int MZONE();
+ void PARAMCADRE(int a1);
+ void OBJETPLUS(int a1);
+ void VALID_OBJET(int a1);
+ void OPTI_OBJET();
+ void SPECIAL_JEU();
+ void BOB_VIVANT(int a1);
+ void VBOB(byte *src, int idx, int xp, int yp, int frameIndex);
+ void VBOB_OFF(int idx);
+ void ACTION_DOS(int idx);
+ void ACTION_DROITE(int idx);
+ void Q_DROITE(int idx);
+ void ACTION_FACE(int idx);
+ void Q_GAUCHE(int idx);
+ void ACTION_GAUCHE(int idx);
+
+ void ZONE_ON(int idx);
+ void ZONE_OFF(int idx);
+ void OPTI_ONE(int a1, int a2, int a3, int a4);
+ void AFFICHE_SPEED1(byte *speedData, int xp, int yp, int img);
+ int BOBPOSI(int idx);
+ void BOBANIM_ON(int idx);
+ void BOBANIM_OFF(int idx);
+ void SET_BOBPOSI(int idx, int a2);
+ int BOBX(int idx);
+ int BOBY(int idx);
+ int BOBA(int idx);
+
+ void INILINK(const Common::String &file);
+ void SPECIAL_INI(const Common::String &a1);
+ void OPTI_BOBON(int a1, int a2, int a3, int a4, int a5, int a6, int a7);
+ void SCI_OPTI_ONE(int a1, int a2, int a3, int a4);
+ void VERBE_OFF(int idx, int a2);
+ void VERBE_ON(int idx, int a2);
+ int CALC_PROPRE(int idx);
+ int colision(int xp, int yp);
+
+ void ACTION(const byte *spriteData, const Common::String &a2, int a3, int a4, int a5, int a6);
+ void SPACTION(byte *a1, const Common::String &a2, int a3, int a4, int a5, int a6);
+ void SPACTION1(byte *a1, const Common::String &a2, int a3, int a4, int a5);
+ void TEST_FORET(int a1, int a2, int a3, int a4, int a5, int a6);
+ void BLOQUE_ANIMX(int idx, int a2);
+ void PERSONAGE(const Common::String &s1, const Common::String &s2, const Common::String &s3,
+ const Common::String &s4, int v);
+ void PERSONAGE2(const Common::String &s1, const Common::String &s2, const Common::String &s3,
+ const Common::String &s4, int v);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_OBJECTS_H */
diff --git a/engines/hopkins/saveload.cpp b/engines/hopkins/saveload.cpp
new file mode 100644
index 0000000000..cd7c32c345
--- /dev/null
+++ b/engines/hopkins/saveload.cpp
@@ -0,0 +1,254 @@
+/* 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 "common/savefile.h"
+#include "graphics/surface.h"
+#include "graphics/scaler.h"
+#include "graphics/thumbnail.h"
+#include "hopkins/saveload.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+const char *SAVEGAME_STR = "HOPKINS";
+#define SAVEGAME_STR_SIZE 13
+
+void SaveLoadManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+bool SaveLoadManager::bsave(const Common::String &file, const void *buf, size_t n) {
+ Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(file);
+
+ if (f) {
+ size_t bytesWritten = f->write(buf, n);
+ f->finalize();
+ delete f;
+
+ return bytesWritten == n;
+ } else
+ return false;
+}
+
+// Save File
+bool SaveLoadManager::SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n) {
+ return bsave(file, buf, n);
+}
+
+void SaveLoadManager::initSaves() {
+ Common::String dataFilename = "HISCORE.DAT";
+ byte data[100];
+ Common::fill(&data[0], &data[100], 0);
+
+ SAUVE_FICHIER(dataFilename, data, 100);
+}
+
+void SaveLoadManager::bload(const Common::String &file, byte *buf) {
+ Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(file);
+ if (f == NULL)
+ error("Error openinig file - %s", file.c_str());
+
+ int32 filesize = f->size();
+ f->read(buf, filesize);
+ delete f;
+}
+
+bool SaveLoadManager::readSavegameHeader(Common::InSaveFile *in, hopkinsSavegameHeader &header) {
+ char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
+ header.thumbnail = NULL;
+
+ // Validate the header Id
+ in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
+ if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE))
+ return false;
+
+ header.version = in->readByte();
+ if (header.version > HOPKINS_SAVEGAME_VERSION)
+ return false;
+
+ // Read in the string
+ header.saveName.clear();
+ char ch;
+ while ((ch = (char)in->readByte()) != '\0') header.saveName += ch;
+
+ // Get the thumbnail
+ header.thumbnail = Graphics::loadThumbnail(*in);
+ if (!header.thumbnail)
+ return false;
+
+ // Read in save date/time
+ header.saveYear = in->readSint16LE();
+ header.saveMonth = in->readSint16LE();
+ header.saveDay = in->readSint16LE();
+ header.saveHour = in->readSint16LE();
+ header.saveMinutes = in->readSint16LE();
+ header.totalFrames = in->readUint32LE();
+
+ return true;
+}
+
+void SaveLoadManager::writeSavegameHeader(Common::OutSaveFile *out, hopkinsSavegameHeader &header) {
+ // Write out a savegame header
+ out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1);
+
+ out->writeByte(HOPKINS_SAVEGAME_VERSION);
+
+ // Write savegame name
+ out->write(header.saveName.c_str(), header.saveName.size() + 1);
+
+ // Create a thumbnail and save it
+ Graphics::Surface *thumb = new Graphics::Surface();
+ createThumbnail(thumb);
+ Graphics::saveThumbnail(*out, *thumb);
+ thumb->free();
+ delete thumb;
+
+ // Write out the save date/time
+ TimeDate td;
+ g_system->getTimeAndDate(td);
+ out->writeSint16LE(td.tm_year + 1900);
+ out->writeSint16LE(td.tm_mon + 1);
+ out->writeSint16LE(td.tm_mday);
+ out->writeSint16LE(td.tm_hour);
+ out->writeSint16LE(td.tm_min);
+ out->writeUint32LE(_vm->_eventsManager._gameCounter);
+}
+
+Common::Error SaveLoadManager::save(int slot, const Common::String &saveName) {
+ /* Pack any necessary data into the savegame data structure */
+ // Set the selected slot number
+ _vm->_globals.SAUVEGARDE->data[svField10] = slot;
+
+ // Set up the inventory
+ for (int i = 0; i < 35; ++i)
+ _vm->_globals.SAUVEGARDE->inventory[i] = _vm->_globals.INVENTAIRE[i];
+
+ /* Create the savegame */
+ Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(
+ _vm->generateSaveName(slot));
+ if (!saveFile)
+ return Common::kCreatingFileFailed;
+
+ // Set up the serializer
+ Common::Serializer serializer(NULL, saveFile);
+
+ // Write out the savegame header
+ hopkinsSavegameHeader header;
+ header.saveName = saveName;
+ header.version = HOPKINS_SAVEGAME_VERSION;
+ writeSavegameHeader(saveFile, header);
+
+ // Write out the savegame data
+ syncSavegameData(serializer);
+
+ // Save file complete
+ saveFile->finalize();
+ delete saveFile;
+
+ return Common::kNoError;
+}
+
+Common::Error SaveLoadManager::restore(int slot) {
+ // Try and open the save file for reading
+ Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
+ _vm->generateSaveName(slot));
+ if (!saveFile)
+ return Common::kReadingFailed;
+
+ // Set up the serializer
+ Common::Serializer serializer(saveFile, NULL);
+
+ // Read in the savegame header
+ hopkinsSavegameHeader header;
+ readSavegameHeader(saveFile, header);
+ if (header.thumbnail)
+ header.thumbnail->free();
+ delete header.thumbnail;
+
+ // Read in the savegame data
+ syncSavegameData(serializer);
+
+ // Loading save file complete
+ delete saveFile;
+
+ // Unpack the inventory
+ for (int i = 0; i < 35; ++i)
+ _vm->_globals.INVENTAIRE[i] = _vm->_globals.SAUVEGARDE->inventory[i];
+
+ // Set variables from loaded data as necessary
+ _vm->_globals.SAUVEGARDE->data[svField10] = slot;
+ _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField5];
+ _vm->_globals.SAUVEGARDE->data[svField6] = 0;
+ _vm->_globals.ECRAN = 0;
+
+ return Common::kNoError;
+}
+
+bool SaveLoadManager::readSavegameHeader(int slot, hopkinsSavegameHeader &header) {
+ // Try and open the save file for reading
+ Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
+ g_vm->generateSaveName(slot));
+ if (!saveFile)
+ return false;
+
+ bool result = readSavegameHeader(saveFile, header);
+ delete saveFile;
+ return result;
+}
+
+#define REDUCE_AMOUNT 80
+
+void SaveLoadManager::createThumbnail(Graphics::Surface *s) {
+ int w = _vm->_graphicsManager.Reel_Reduc(SCREEN_WIDTH, REDUCE_AMOUNT);
+ int h = _vm->_graphicsManager.Reel_Reduc(SCREEN_HEIGHT - 40, REDUCE_AMOUNT);
+
+ s->create(w, h, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
+
+ _vm->_graphicsManager.Reduc_Ecran(_vm->_graphicsManager.VESA_BUFFER, (byte *)s->pixels,
+ _vm->_eventsManager.start_x, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 40, 80);
+ _vm->_graphicsManager.INIT_TABLE(45, 80, _vm->_graphicsManager.Palette);
+// _vm->_graphicsManager.Trans_bloc2((byte *)s->pixels, _vm->_graphicsManager.TABLE_COUL, 11136);
+}
+
+void SaveLoadManager::syncSavegameData(Common::Serializer &s) {
+ s.syncBytes(&_vm->_globals.SAUVEGARDE->data[0], 0x802);
+ syncSauvegarde1(s, _vm->_globals.SAUVEGARDE->field360);
+ syncSauvegarde1(s, _vm->_globals.SAUVEGARDE->field370);
+ syncSauvegarde1(s, _vm->_globals.SAUVEGARDE->field380);
+
+ for (int i = 0; i < 35; ++i)
+ s.syncAsSint16LE(_vm->_globals.SAUVEGARDE->inventory[i]);
+}
+
+void SaveLoadManager::syncSauvegarde1(Common::Serializer &s, Sauvegarde1 &item) {
+ s.syncAsSint16LE(item.field0);
+ s.syncAsSint16LE(item.field1);
+ s.syncAsSint16LE(item.field2);
+ s.syncAsSint16LE(item.field3);
+ s.syncAsSint16LE(item.field4);
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/saveload.h b/engines/hopkins/saveload.h
new file mode 100644
index 0000000000..647c64d2e7
--- /dev/null
+++ b/engines/hopkins/saveload.h
@@ -0,0 +1,71 @@
+/* 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_SAVELOAD_H
+#define HOPKINS_SAVELOAD_H
+
+#include "common/scummsys.h"
+#include "common/savefile.h"
+#include "common/serializer.h"
+#include "common/str.h"
+#include "hopkins/globals.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+#define HOPKINS_SAVEGAME_VERSION 1
+
+struct hopkinsSavegameHeader {
+ uint8 version;
+ Common::String saveName;
+ Graphics::Surface *thumbnail;
+ int saveYear, saveMonth, saveDay;
+ int saveHour, saveMinutes;
+ int totalFrames;
+};
+
+class SaveLoadManager {
+private:
+ HopkinsEngine *_vm;
+
+ void createThumbnail(Graphics::Surface *s);
+ void syncSavegameData(Common::Serializer &s);
+ void syncSauvegarde1(Common::Serializer &s, Sauvegarde1 &item);
+public:
+ void setParent(HopkinsEngine *vm);
+
+ void initSaves();
+ bool bsave(const Common::String &file, const void *buf, size_t n);
+ bool SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n);
+ void bload(const Common::String &file, byte *buf);
+
+ static bool readSavegameHeader(Common::InSaveFile *in, hopkinsSavegameHeader &header);
+ void writeSavegameHeader(Common::OutSaveFile *out, hopkinsSavegameHeader &header);
+ static bool readSavegameHeader(int slot, hopkinsSavegameHeader &header);
+ Common::Error save(int slot, const Common::String &saveName);
+ Common::Error restore(int slot);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_SAVELOAD_H */
diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp
new file mode 100644
index 0000000000..57b691a129
--- /dev/null
+++ b/engines/hopkins/script.cpp
@@ -0,0 +1,2586 @@
+/* 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 "graphics/palette.h"
+#include "common/file.h"
+#include "common/rect.h"
+#include "engines/util.h"
+#include "hopkins/objects.h"
+#include "hopkins/dialogs.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/sound.h"
+#include "hopkins/hopkins.h"
+
+namespace Hopkins {
+
+ScriptManager::ScriptManager() {
+ TRAVAILOBJET = 0;
+}
+
+void ScriptManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+int ScriptManager::Traduction(byte *a1) {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+ int v26;
+ int v27;
+ int v28;
+ int v29;
+ int v30;
+ int v31;
+ int v32;
+ int v33;
+ int v34;
+ int v35;
+ int v36;
+ int v37;
+ int v38;
+ int v39;
+ int v40;
+ int v41;
+ int v42;
+ int v43;
+ int v44;
+ int v45;
+ int v46;
+ char v47;
+ char v48;
+ char v49;
+ int v50;
+ Sauvegarde1 *v51;
+ int v52;
+ Sauvegarde1 *v53;
+ int v54;
+ int v55;
+ int v56;
+ int v57;
+ int v58;
+ int v59;
+ int v60;
+ int v65;
+ int v66;
+ int v67;
+ int v68;
+ int v69;
+ int v70;
+ int v71;
+ int v72;
+ int v73;
+ int v74;
+ int v75;
+ int v76;
+ Common::String v77;
+ Common::String s;
+
+ v1 = 0;
+ v70 = 0;
+ if (*a1 != 'F' || *(a1 + 1) != 'C')
+ return 0;
+ if (*(a1 + 2) == 'T' && *(a1 + 3) == 'X' && *(a1 + 4) == 'T') {
+ v70 = *(a1 + 6);
+ v2 = *(a1 + 7);
+ v69 = *(a1 + 8);
+ v67 = (int16)READ_LE_UINT16(a1 + 9);
+ v65 = (int16)READ_LE_UINT16(a1 + 11);
+ v3 = (int16)READ_LE_UINT16(a1 + 13);
+ v1 = 1;
+ if (!TRAVAILOBJET) {
+ if (_vm->_globals.SAUVEGARDE->data[svField356] == 1) {
+ if (v3 == 53)
+ v3 = 644;
+ if (v3 == 624)
+ v3 = 639;
+ if (v3 == 627)
+ v3 = 630;
+ if (v3 == 625)
+ v3 = 639;
+ if (v3 == 8)
+ v3 = 637;
+ if (v3 == 53)
+ v3 = 644;
+ if (v3 == 557)
+ v3 = 636;
+ if (v3 == 51)
+ v3 = 644;
+ if (v3 == 287)
+ v3 = 636;
+ if (v3 == 619)
+ v3 = 633;
+ if (v3 == 620)
+ v3 = 634;
+ if (v3 == 622)
+ v3 = 644;
+ if (v3 == 297)
+ v3 = 636;
+ if (v3 == 612)
+ v3 = 636;
+ if ((uint16)(v3 - 613) <= 1u || v3 == 134)
+ v3 = 636;
+ if (v3 == 615)
+ v3 = 635;
+ if (v3 == 618)
+ v3 = 632;
+ if (v3 == 611)
+ v3 = 642;
+ if (v3 == 610)
+ v3 = 641;
+ if (v3 == 18)
+ v3 = 643;
+ if (v3 == 602)
+ v3 = 645;
+ if (v3 == 603)
+ v3 = 646;
+ if (v3 == 604)
+ v3 = 647;
+ if (v3 == 51)
+ v3 = 644;
+ if (v3 == 607)
+ v3 = 650;
+ if (v3 == 605)
+ v3 = 648;
+ if (v3 == 606)
+ v3 = 649;
+ if (v3 == 601)
+ v3 = 652;
+ if (v3 == 37)
+ v3 = 636;
+ if (v3 == 595)
+ v3 = 633;
+ if (v3 == 596)
+ v3 = 634;
+ if (v3 == 532)
+ v3 = 636;
+ if (v3 == 599)
+ v3 = 636;
+ if (v3 == 363)
+ v3 = 636;
+ }
+ if (!_vm->_soundManager.SOUNDOFF && _vm->_soundManager.SOUND_FLAG == 1) {
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+ _vm->_eventsManager.VBL();
+ } while (_vm->_soundManager.SOUND_FLAG);
+ }
+ if (!_vm->_soundManager.TEXTOFF) {
+ _vm->_fontManager.DOS_TEXT(9, v3, _vm->_globals.FICH_TEXTE, 2 * v67, 2 * v65 + 40, 20, 25, 6, v2, 253);
+ if (!_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.TEXTE_ON(9);
+ }
+ if (!_vm->_soundManager.VOICEOFF)
+ _vm->_soundManager.VOICE_MIX(v3, 4);
+ }
+ if (TRAVAILOBJET == 1) {
+ if (_vm->_globals.SAUVEGARDE->data[svField356]) {
+ _vm->_fontManager.DOS_TEXT(9, 635, _vm->_globals.FICH_TEXTE, 55, 20, 20, 25, v69, 35, 253);
+ if (!_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.TEXTE_ON(9);
+ if (!_vm->_soundManager.VOICEOFF)
+ _vm->_soundManager.VOICE_MIX(635, 4);
+ goto LABEL_104;
+ }
+ if (_vm->_globals.FR == 1 && !_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.DOS_TEXT(9, v3, "OBJET1.TXT", 2 * v67, 60, 20, 25, 6, v2, 253);
+ if (!_vm->_globals.FR && !_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.DOS_TEXT(9, v3, "OBJETAN.TXT", 2 * v67, 60, 20, 25, 6, v2, 253);
+ if (_vm->_globals.FR == 2) {
+ if (_vm->_soundManager.TEXTOFF) {
+LABEL_98:
+ if (!_vm->_soundManager.VOICEOFF)
+ _vm->_soundManager.VOICE_MIX(v3, 5);
+ goto LABEL_104;
+ }
+ _vm->_fontManager.DOS_TEXT(9, v3, "OBJETES.TXT", 2 * v67, 60, 20, 25, 6, v2, 253);
+ }
+ if (!_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.TEXTE_ON(9);
+ goto LABEL_98;
+ }
+ }
+LABEL_104:
+ if (*(a1 + 2) == 'B' && *(a1 + 3) == 'O' && *(a1 + 4) == 'B') {
+ if (_vm->_objectsManager.DESACTIVE != true) {
+ v72 = *(a1 + 5);
+ v70 = *(a1 + 6);
+ v4 = *(a1 + 7);
+ v68 = (int16)READ_LE_UINT16(a1 + 8);
+ v66 = (int16)READ_LE_UINT16(a1 + 10);
+ if (v72 == 52) {
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, v68, (int16)READ_LE_UINT16(a1 + 10), v70);
+ } else if (v72 == 51) {
+ _vm->_objectsManager.BOB_VIVANT(v70);
+ } else {
+ if (v72 == 50)
+ goto LABEL_1141;
+ _vm->_objectsManager.VBOB(_vm->_globals.SPRITE_ECRAN, v72, v68, v66, v70);
+ if (v4)
+ v4 /= _vm->_globals.vitesse;
+ if (v4 > 1) {
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ --v4;
+ _vm->_eventsManager.VBL();
+ } while (v4);
+ }
+ if (v72 == 50)
+LABEL_1141:
+ _vm->_objectsManager.AFFICHE_SPEED1(_vm->_globals.SPRITE_ECRAN, v68, v66, v70);
+ }
+ }
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'S') {
+ if (*(a1 + 3) == 'T' && *(a1 + 4) == 'P') {
+ if (_vm->_objectsManager.DESACTIVE != true) {
+ _vm->_objectsManager.DEUXPERSO = false;
+ v5 = *(a1 + 5);
+ v6 = (int16)READ_LE_UINT16(a1 + 8);
+ _vm->_objectsManager.PERX = (int16)READ_LE_UINT16(a1 + 6);
+ _vm->_objectsManager.PERY = v6;
+ _vm->_objectsManager.PERI = v5;
+ if (_vm->_objectsManager.CH_TETE == 1) {
+ if (_vm->_globals.SAUVEGARDE->data[svField354] == 1
+ && _vm->_globals.SAUVEGARDE->data[svField180]
+ && _vm->_globals.SAUVEGARDE->data[svField181]
+ && _vm->_globals.SAUVEGARDE->data[svField182]
+ && _vm->_globals.SAUVEGARDE->data[svField183]) {
+ _vm->_objectsManager.PERX = _vm->_globals.SAUVEGARDE->data[svField180];
+ _vm->_objectsManager.PERY = _vm->_globals.SAUVEGARDE->data[svField181];
+ _vm->_objectsManager.PERI = _vm->_globals.SAUVEGARDE->data[svField182];
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField356] == 1
+ && _vm->_globals.SAUVEGARDE->data[svField190]
+ && _vm->_globals.SAUVEGARDE->data[svField191]
+ && _vm->_globals.SAUVEGARDE->data[svField192]
+ && _vm->_globals.SAUVEGARDE->data[svField193]) {
+ _vm->_objectsManager.PERX = _vm->_globals.SAUVEGARDE->data[svField190];
+ _vm->_objectsManager.PERY = _vm->_globals.SAUVEGARDE->data[svField191];
+ _vm->_objectsManager.PERI = _vm->_globals.SAUVEGARDE->data[svField192];
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField357] == 1
+ && _vm->_globals.SAUVEGARDE->data[svField185]
+ && _vm->_globals.SAUVEGARDE->data[svField186]
+ && _vm->_globals.SAUVEGARDE->data[svField187]
+ && _vm->_globals.SAUVEGARDE->data[svField188]) {
+ _vm->_objectsManager.PERX = _vm->_globals.SAUVEGARDE->data[svField185];
+ _vm->_objectsManager.PERY = _vm->_globals.SAUVEGARDE->data[svField186];
+ _vm->_objectsManager.PERI = _vm->_globals.SAUVEGARDE->data[svField187];
+ }
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField356] == 1 && _vm->_globals.SAUVEGARDE->data[svField188] == _vm->_globals.ECRAN) {
+ _vm->_objectsManager.SPRITE(
+ _vm->_globals.TETE,
+ _vm->_globals.SAUVEGARDE->data[svField185],
+ _vm->_globals.SAUVEGARDE->data[svField186],
+ 1,
+ 2,
+ _vm->_globals.SAUVEGARDE->data[svField189],
+ 0,
+ 34,
+ 190);
+ _vm->_objectsManager.SPRITE_ON(1);
+ _vm->_objectsManager.DEUXPERSO = true;
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField357] == 1
+ && _vm->_globals.SAUVEGARDE->data[svField355] == 1
+ && _vm->_globals.SAUVEGARDE->data[svField193] == _vm->_globals.ECRAN) {
+ _vm->_objectsManager.SPRITE(
+ _vm->_globals.TETE,
+ _vm->_globals.SAUVEGARDE->data[svField190],
+ _vm->_globals.SAUVEGARDE->data[svField191],
+ 1,
+ 3,
+ _vm->_globals.SAUVEGARDE->data[svField194],
+ 0,
+ 20,
+ 127);
+ _vm->_objectsManager.SPRITE_ON(1);
+ _vm->_objectsManager.DEUXPERSO = true;
+ }
+ }
+ v1 = 1;
+ _vm->_objectsManager.CH_TETE = 0;
+ }
+ if (*(a1 + 2) == 'S' && *(a1 + 3) == 'T' && *(a1 + 4) == 'E') {
+ if (_vm->_objectsManager.DESACTIVE != true) {
+ v7 = *(a1 + 5);
+ v70 = *(a1 + 6);
+ v8 = *(a1 + 7);
+ v9 = *(a1 + 8);
+ _vm->_objectsManager.RECALL = 0;
+ _vm->_globals.OLD_ECRAN = _vm->_globals.ECRAN;
+ _vm->_globals.SAUVEGARDE->data[svField6] = _vm->_globals.ECRAN;
+ _vm->_globals.ECRAN = v7;
+ _vm->_globals.SAUVEGARDE->data[svField5] = v7;
+ _vm->_objectsManager.PTAILLE = v70;
+ _vm->_objectsManager.PEROFX = v8;
+ _vm->_objectsManager.PEROFY = v9;
+ }
+ v1 = 1;
+ }
+ }
+ if (*(a1 + 2) == 'B' && *(a1 + 3) == 'O' && *(a1 + 4) == 'F') {
+ if (_vm->_objectsManager.DESACTIVE != true)
+ _vm->_objectsManager.VBOB_OFF((int16)READ_LE_UINT16(a1 + 5));
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'P' && *(a1 + 3) == 'E' && *(a1 + 4) == 'R') {
+ v73 = (int16)READ_LE_UINT16(a1 + 5);
+ if (!_vm->_globals.SAUVEGARDE->data[svField122] && !_vm->_globals.SAUVEGARDE->data[svField356]) {
+ v70 = 0;
+ if ((int16)READ_LE_UINT16(a1 + 5) == 14)
+ v73 = 1;
+ if (v73 == 17)
+ v73 = 7;
+ if (v73 == 18)
+ v73 = 8;
+ if (v73 == 19)
+ v73 = 4;
+ if (v73 == 15)
+ v73 = 11;
+ if (v73 == 16)
+ v73 = 12;
+ if (v73 == 1) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(4);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(4);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(4);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(4);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(4);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(4);
+ }
+ if (v73 == 2) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(7);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(7);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(7);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(7);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(7);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(7);
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(8);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(8);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(8);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(8);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(8);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(8);
+ }
+ if (v73 == 4) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(1);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(1);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(1);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(1);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(1);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(1);
+ }
+ if (v73 == 5) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(5);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(5);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(5);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(5);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(5);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(5);
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(6);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(6);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(6);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(6);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(6);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(6);
+ }
+ if (v73 == 7) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(2);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(2);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(2);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(2);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(2);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(2);
+ }
+ if (v73 == 8) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(3);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(3);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(3);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(3);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(3);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(3);
+ }
+ if (v73 == 9) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(5);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(5);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(5);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(5);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(5);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(5);
+ }
+ if (v73 == 10) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(6);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(6);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(6);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(6);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(6);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(6);
+ }
+ if (v73 == 11) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(7);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(7);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(7);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(7);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(7);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(7);
+ }
+ if (v73 == 12) {
+ if (_vm->_globals.ACTION_SENS == 1)
+ _vm->_objectsManager.ACTION_DOS(8);
+ if (_vm->_globals.ACTION_SENS == 3)
+ _vm->_objectsManager.ACTION_DROITE(8);
+ if (_vm->_globals.ACTION_SENS == 2)
+ _vm->_objectsManager.Q_DROITE(8);
+ if (_vm->_globals.ACTION_SENS == 5)
+ _vm->_objectsManager.ACTION_FACE(8);
+ if (_vm->_globals.ACTION_SENS == 8)
+ _vm->_objectsManager.Q_GAUCHE(8);
+ if (_vm->_globals.ACTION_SENS == 7)
+ _vm->_objectsManager.ACTION_GAUCHE(8);
+ }
+ }
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'M' && *(a1 + 3) == 'U' && *(a1 + 4) == 'S')
+ v1 = 1;
+ if (*(a1 + 2) == 'W' && *(a1 + 3) == 'A' && *(a1 + 4) == 'I') {
+ v74 = (int16)READ_LE_UINT16(a1 + 5) / _vm->_globals.vitesse;
+ if (!v74)
+ v74 = 1;
+ v10 = 0;
+ if (v74 + 1 > 0) {
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ ++v10;
+ } while (v10 < v74 + 1);
+ }
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'O') {
+ if (*(a1 + 3) == 'B' && *(a1 + 4) == 'P') {
+ v1 = 1;
+ _vm->_objectsManager.AJOUTE_OBJET((int16)READ_LE_UINT16(a1 + 5));
+ }
+ if (*(a1 + 2) == 'O' && *(a1 + 3) == 'B' && *(a1 + 4) == 'M') {
+ v1 = 1;
+ _vm->_objectsManager.DELETE_OBJET((int16)READ_LE_UINT16(a1 + 5));
+ }
+ }
+ if (*(a1 + 2) == 'G' && *(a1 + 3) == 'O' && *(a1 + 4) == 'T')
+ v1 = 2;
+ if (*(a1 + 2) == 'Z') {
+ if (*(a1 + 3) == 'O' && *(a1 + 4) == 'N') {
+ _vm->_objectsManager.ZONE_ON((int16)READ_LE_UINT16(a1 + 5));
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'Z' && *(a1 + 3) == 'O' && *(a1 + 4) == 'F') {
+ _vm->_objectsManager.ZONE_OFF((int16)READ_LE_UINT16(a1 + 5));
+ v1 = 1;
+ }
+ }
+ if (*(a1 + 2) == 'E' && *(a1 + 3) == 'X' && *(a1 + 4) == 'I')
+ v1 = 5;
+ if (*(a1 + 2) == 'S' && *(a1 + 3) == 'O' && *(a1 + 4) == 'R') {
+ _vm->_globals.SORTIE = (int16)READ_LE_UINT16(a1 + 5);
+ v1 = 5;
+ }
+ if (*(a1 + 2) == 'B' && *(a1 + 3) == 'C' && *(a1 + 4) == 'A') {
+ _vm->_globals.CACHE_OFF((int16)READ_LE_UINT16(a1 + 5));
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'A' && *(a1 + 3) == 'N' && *(a1 + 4) == 'I') {
+ v75 = (int16)READ_LE_UINT16(a1 + 5);
+ if (v75 <= 100)
+ _vm->_objectsManager.BOBANIM_ON(v75);
+ else
+ _vm->_objectsManager.BOBANIM_OFF(v75 - 100);
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'S' && *(a1 + 3) == 'P' && *(a1 + 4) == 'E') {
+ v76 = (int16)READ_LE_UINT16(a1 + 5);
+ if (v76 == 7)
+ _vm->_talkManager.PARLER_PERSO("rueh1.pe2");
+ if (v76 == 8)
+ _vm->_talkManager.PARLER_PERSO("ruef1.pe2");
+ if (v76 == 6) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.OPTI_ONE(20, 0, 14, 4);
+ }
+ if (v76 == 12) {
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.VBL();
+ _vm->_talkManager.PARLER_PERSO("bqetueur.pe2");
+ }
+ if (v76 == 600) {
+ if (!_vm->_globals.internet) {
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_graphicsManager.FADESPD = 1;
+ if (_vm->_globals.SVGA == 2)
+ _vm->_animationManager.PLAY_ANM("BOMBE1A.ANM", 100, 18, 100);
+ if (_vm->_globals.SVGA == 1)
+ _vm->_animationManager.PLAY_ANM("BOMBE1.ANM", 100, 18, 100);
+ }
+ _vm->_graphicsManager.LOAD_IMAGE("BOMBEB");
+ _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0);
+ _vm->_graphicsManager.OPTI_INI("BOMBE", 2);
+ _vm->_graphicsManager.FADE_INS();
+ }
+ if (v76 == 601) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 163, 7);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.OPTI_ONE(2, 0, 16, 4);
+ }
+ if (v76 == 602) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 163, 7);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.OPTI_ONE(4, 0, 16, 4);
+ }
+ if (v76 == 603) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 163, 7);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.OPTI_ONE(3, 0, 16, 4);
+ _vm->_soundManager.SPECIAL_SOUND = 199;
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ if (_vm->_globals.SVGA == 1)
+ _vm->_animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500);
+ if (_vm->_globals.SVGA == 2)
+ _vm->_animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x96000u);
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_globals.SORTIE = 151;
+ }
+ if (v76 == 604) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 163, 7);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.OPTI_ONE(1, 0, 16, 4);
+ _vm->_soundManager.SPECIAL_SOUND = 199;
+ if (_vm->_globals.SVGA == 1)
+ _vm->_animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500);
+ if (_vm->_globals.SVGA == 2)
+ _vm->_animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_graphicsManager.NOFADE = true;
+ memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x96000u);
+ _vm->_globals.SORTIE = 151;
+ }
+ if (v76 == 605) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 163, 7);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.OPTI_ONE(5, 0, 16, 4);
+ _vm->_graphicsManager.FADE_OUTS();
+ _vm->_soundManager.SPECIAL_SOUND = 199;
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ if (_vm->_globals.SVGA == 1)
+ _vm->_animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500);
+ if (_vm->_globals.SVGA == 2)
+ _vm->_animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_graphicsManager.NOFADE = true;
+ memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x96000u);
+ _vm->_globals.SORTIE = 151;
+ }
+ if (v76 == 606) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 163, 7);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.OPTI_ONE(6, 0, 16, 4);
+ if (_vm->_globals.SVGA == 1)
+ _vm->_animationManager.PLAY_ANM("BOMBE3.ANM", 50, 14, 500);
+ if (_vm->_globals.SVGA == 2)
+ _vm->_animationManager.PLAY_ANM("BOMBE3A.ANM", 50, 14, 500);
+ memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x96000u);
+ _vm->_globals.SORTIE = 6;
+ }
+ if (v76 == 607) {
+ if (!_vm->_globals.internet) {
+ memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u);
+ v1 = _vm->_graphicsManager.OLD_PAL[769];
+ _vm->_animationManager.PLAY_ANM2("plan.ANm", 50, 10, 800);
+ }
+ _vm->_globals.NBBLOC = 0;
+ }
+ if (v76 == 608) {
+ _vm->_objectsManager.BOBANIM_OFF(2);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_objectsManager.BOBANIM_OFF(6);
+ _vm->_objectsManager.BOBANIM_OFF(11);
+ _vm->_objectsManager.BOBANIM_OFF(10);
+ }
+ if (v76 == 609) {
+ _vm->_objectsManager.BOBANIM_ON(2);
+ _vm->_objectsManager.BOBANIM_ON(3);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ _vm->_objectsManager.BOBANIM_ON(6);
+ _vm->_objectsManager.BOBANIM_ON(11);
+ _vm->_objectsManager.BOBANIM_ON(10);
+ }
+ if (v76 == 611) {
+ _vm->_objectsManager.BOBANIM_ON(5);
+ _vm->_objectsManager.BOBANIM_ON(7);
+ _vm->_objectsManager.BOBANIM_ON(8);
+ _vm->_objectsManager.BOBANIM_ON(9);
+ _vm->_objectsManager.BOBANIM_ON(12);
+ _vm->_objectsManager.BOBANIM_ON(13);
+ }
+ if (v76 == 610) {
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ _vm->_objectsManager.BOBANIM_OFF(7);
+ _vm->_objectsManager.BOBANIM_OFF(8);
+ _vm->_objectsManager.BOBANIM_OFF(9);
+ _vm->_objectsManager.BOBANIM_OFF(12);
+ _vm->_objectsManager.BOBANIM_OFF(13);
+ }
+ if (v76 == 10)
+ _vm->_talkManager.PARLER_PERSO("bqeflic1.pe2");
+ if (v76 == 11)
+ _vm->_talkManager.PARLER_PERSO("bqeflic2.pe2");
+ if (v76 == 16)
+ _vm->_talkManager.PARLER_PERSO("ftoubib.pe2");
+ if (v76 == 17)
+ _vm->_talkManager.PARLER_PERSO("flic2b.pe2");
+ if (v76 == 18)
+ _vm->_talkManager.PARLER_PERSO("fjour.pe2");
+ if (v76 == 13) {
+ _vm->_eventsManager.souris_b = _vm->_eventsManager.souris_bb;
+ _vm->_globals.DESACTIVE_INVENT = true;
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_globals.CACHE_OFF();
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_graphicsManager.FIN_VISU();
+ _vm->_objectsManager.CLEAR_ECRAN();
+ _vm->_soundManager.PLAY_SOUND("SOUND17.WAV");
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_animationManager.PLAY_SEQ2("HELICO.SEQ", 10, 4, 10);
+ _vm->_animationManager.CHARGE_ANIM("otage");
+ _vm->_graphicsManager.LOAD_IMAGE("IM05");
+ _vm->_graphicsManager.VISU_ALL();
+ v11 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ ++v11;
+ } while (v11 <= 4);
+ _vm->_eventsManager.MOUSE_OFF();
+ _vm->_graphicsManager.FADE_INW_LINUX(_vm->_graphicsManager.VESA_BUFFER);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(3) != 100);
+ _vm->_graphicsManager.FADE_OUTW_LINUX(_vm->_graphicsManager.VESA_BUFFER);
+ _vm->_graphicsManager.FIN_VISU();
+ if (!_vm->_globals.CENSURE) {
+ _vm->_soundManager.SPECIAL_SOUND = 16;
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_animationManager.PLAY_ANM("EGORGE.ANM", 50, 28, 500);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ }
+ _vm->_animationManager.CHARGE_ANIM("ASCEN");
+ _vm->_eventsManager.MOUSE_OFF();
+ _vm->_graphicsManager.LOAD_IMAGE("ASCEN");
+ _vm->_graphicsManager.VISU_ALL();
+ v12 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ ++v12;
+ } while (v12 <= 4);
+ _vm->_eventsManager.MOUSE_OFF();
+ _vm->_graphicsManager.FADE_INW_LINUX(_vm->_graphicsManager.VESA_BUFFER);
+ _vm->_objectsManager.SCI_OPTI_ONE(1, 0, 17, 3);
+ _vm->_graphicsManager.FADE_OUTW_LINUX(_vm->_graphicsManager.VESA_BUFFER);
+ _vm->_graphicsManager.FIN_VISU();
+ _vm->_soundManager.SPECIAL_SOUND = 14;
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_animationManager.PLAY_SEQ2("ASSOM.SEQ", 10, 4, 500);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ _vm->_globals.HELICO = 1;
+ }
+ if (v76 == 36) {
+ if (_vm->_globals.SAUVEGARDE->data[svField270] == 2 && _vm->_globals.SAUVEGARDE->data[svField94] == 1 && _vm->_globals.SAUVEGARDE->data[svField95] == 1)
+ _vm->_globals.SAUVEGARDE->data[svField270] = 3;
+ if (!_vm->_globals.SAUVEGARDE->data[svField270])
+ _vm->_talkManager.PARLER_PERSO2("PATRON0.pe2");
+ if (_vm->_globals.SAUVEGARDE->data[svField270] == 1)
+ _vm->_talkManager.PARLER_PERSO2("PATRON1.pe2");
+ if (_vm->_globals.SAUVEGARDE->data[svField270] == 2)
+ _vm->_talkManager.PARLER_PERSO2("PATRON2.pe2");
+ if (_vm->_globals.SAUVEGARDE->data[svField270] == 3)
+ _vm->_talkManager.PARLER_PERSO2("PATRON3.pe2");
+ if (_vm->_globals.SAUVEGARDE->data[svField270] > 3) {
+ _vm->_talkManager.PARLER_PERSO2("PATRON4.pe2");
+ _vm->_globals.SAUVEGARDE->data[svField270] = 5;
+ }
+ }
+ if (v76 == 37) {
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_animationManager.PLAY_SEQ2("corde.SEQ", 32, 32, 100);
+ _vm->_graphicsManager.NOFADE = true;
+ }
+ if (v76 == 38) {
+ _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND44.WAV");
+ _vm->_soundManager.CHARGE_SAMPLE(2, "SOUND42.WAV");
+ _vm->_soundManager.CHARGE_SAMPLE(3, "SOUND41.WAV");
+ _vm->_soundManager.SPECIAL_SOUND = 17;
+ _vm->_animationManager.PLAY_SEQ(v1, "grenade.SEQ", 1, 32, 100);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_graphicsManager.FADE_LINUX = 2;
+ _vm->_animationManager.PLAY_ANM("CREVE17.ANM", 24, 24, 200);
+ _vm->_soundManager.DEL_SAMPLE(1);
+ _vm->_soundManager.DEL_SAMPLE(2);
+ _vm->_soundManager.DEL_SAMPLE(3);
+ _vm->_graphicsManager.NOFADE = true;
+ }
+ if (v76 == 29) {
+ _vm->_globals.DESACTIVE_INVENT = true;
+ _vm->_talkManager.OBJET_VIVANT("TELEP.pe2");
+ _vm->_globals.DESACTIVE_INVENT = false;
+ }
+ if (v76 == 22)
+ _vm->_talkManager.OBJET_VIVANT("CADAVRE1.pe2");
+ if (v76 == 20)
+ _vm->_talkManager.PARLER_PERSO("PUNK.pe2");
+ if (v76 == 23)
+ _vm->_talkManager.PARLER_PERSO2("CHERCHE1.pe2");
+ if (v76 == 35) {
+ if (!_vm->_soundManager.SOUNDOFF) {
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_soundManager.SOUND_FLAG);
+ }
+ _vm->_talkManager.PARLER_PERSO("PTLAB.pe2");
+ }
+ if (v76 == 46) {
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ v13 = _vm->_objectsManager.YSPR(0);
+ v14 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v14, v13, 564, 420);
+ _vm->_objectsManager.NUMZONE = -1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND44.WAV");
+ _vm->_soundManager.CHARGE_SAMPLE(2, "SOUND45.WAV");
+ _vm->_objectsManager.OPTI_BOBON(9, 10, -1, 0, 0, 0, 0);
+ v15 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(9) == 4 && !v15) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v15 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(9) == 5)
+ v15 = 0;
+ if (_vm->_objectsManager.BOBPOSI(9) == 16 && !v15) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v15 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(9) == 17)
+ v15 = 0;
+ if (_vm->_objectsManager.BOBPOSI(9) == 28 && !v15) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v15 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(9) == 29)
+ v15 = 0;
+ if (_vm->_objectsManager.BOBPOSI(10) == 10 && !v15) {
+ _vm->_soundManager.PLAY_SAMPLE2(2);
+ v15 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(10) == 11)
+ v15 = 0;
+ if (_vm->_objectsManager.BOBPOSI(10) == 22 && !v15) {
+ _vm->_soundManager.PLAY_SAMPLE2(2);
+ v15 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(10) == 23)
+ v15 = 0;
+ if (_vm->_objectsManager.BOBPOSI(10) == 33 && !v15) {
+ _vm->_soundManager.PLAY_SAMPLE2(2);
+ v15 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(10) == 34)
+ v15 = 0;
+ if (_vm->_objectsManager.BOBPOSI(10) == 12)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 249, 1);
+ if (_vm->_objectsManager.BOBPOSI(10) == 23)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 249, 2);
+ if (_vm->_objectsManager.BOBPOSI(10) == 34)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 513, 249, 3);
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(9) != 36);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.BOBANIM_OFF(9);
+ _vm->_objectsManager.BOBANIM_OFF(10);
+ _vm->_soundManager.DEL_SAMPLE(1);
+ _vm->_soundManager.DEL_SAMPLE(2);
+ }
+ if (v76 == 59) {
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.g_old_x = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ v16 = _vm->_objectsManager.YSPR(0);
+ v17 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v17, v16, 445, 332);
+ _vm->_globals.NOT_VERIF = 1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(7);
+ _vm->_objectsManager.SET_BOBPOSI(7, 0);
+ v18 = 0;
+ _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND40.WAV");
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(7) == 10 && !v18) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v18 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(7) == 11)
+ v18 = 0;
+ if (_vm->_objectsManager.BOBPOSI(7) == 18 && !v18) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v18 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(7) == 19)
+ v18 = 0;
+ if (_vm->_objectsManager.BOBPOSI(7) == 19)
+ _vm->_objectsManager.BOBANIM_ON(3);
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(3) != 48);
+ _vm->_soundManager.DEL_SAMPLE(1);
+ _vm->_objectsManager.SETANISPR(0, 62);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.BOBANIM_ON(6);
+ _vm->_objectsManager.BOBANIM_OFF(7);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ }
+ if (v76 == 50) {
+ _vm->_soundManager.PLAY_SOUND("SOUND46.WAv");
+ _vm->_objectsManager.OPTI_ONE(11, 0, 23, 0);
+ }
+ if (v76 == 49) {
+ _vm->_globals.CACHE_OFF();
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.OPTI_BOBON(9, 10, -1, 0, 0, 0, 0);
+ v19 = 12;
+ if (_vm->_globals.SAUVEGARDE->data[svField133] == 1)
+ v19 = 41;
+ v20 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(9) == 4 && !v20) {
+ _vm->_soundManager.PLAY_SOUND2("SOUND44.WAV");
+ v20 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(9) == 5)
+ v20 = 0;
+ if (_vm->_objectsManager.BOBPOSI(9) == 18 && !v20) {
+ _vm->_soundManager.PLAY_SOUND2("SOUND46.WAV");
+ v20 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(9) == 19)
+ v20 = 0;
+ if (_vm->_objectsManager.BOBPOSI(10) == 11 && !v20) {
+ _vm->_soundManager.PLAY_SOUND2("SOUND45.WAV");
+ v20 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(10) == 12)
+ v20 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(9) != v19);
+ if (v19 == 12) {
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.BOBANIM_OFF(9);
+ }
+ _vm->_globals.CACHE_ON();
+ }
+ if (v76 == 80) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(12);
+ _vm->_objectsManager.BOBANIM_ON(13);
+ _vm->_objectsManager.SET_BOBPOSI(12, 0);
+ _vm->_objectsManager.SET_BOBPOSI(13, 0);
+ v21 = 0;
+ _vm->_soundManager.LOAD_WAV("SOUND44.WAV", 1);
+ _vm->_soundManager.LOAD_WAV("SOUND71.WAV", 2);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(12) == 4 && !v21) {
+ _vm->_soundManager.PLAY_WAV(1);
+ v21 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(12) == 5)
+ v21 = 0;
+ if (_vm->_objectsManager.BOBPOSI(4) == 5 && !v21) {
+ _vm->_soundManager.PLAY_WAV(2);
+ v21 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(4) == 6)
+ v21 = 0;
+ if (_vm->_objectsManager.BOBPOSI(13) == 8) {
+ _vm->_objectsManager.BOBANIM_OFF(13);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ _vm->_objectsManager.SET_BOBPOSI(4, 0);
+ _vm->_objectsManager.SET_BOBPOSI(13, 0);
+ }
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 16);
+ _vm->_objectsManager.BOBANIM_OFF(12);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.OBSSEUL = 1;
+ _vm->_objectsManager.INILINK("IM27a");
+ _vm->_objectsManager.OBSSEUL = 0;
+ }
+ if (v76 == 81) {
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.g_old_x = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ v22 = _vm->_objectsManager.YSPR(0);
+ v23 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v23, v22, 119, 268);
+ _vm->_globals.NOT_VERIF = 1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(11);
+ _vm->_objectsManager.BOBANIM_ON(8);
+ _vm->_objectsManager.SET_BOBPOSI(11, 0);
+ _vm->_objectsManager.SET_BOBPOSI(8, 0);
+ _vm->_soundManager.LOAD_WAV("SOUND44.WAV", 1);
+ _vm->_soundManager.LOAD_WAV("SOUND48.WAV", 2);
+ _vm->_soundManager.LOAD_WAV("SOUND49.WAV", 3);
+ v24 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(11) == 4 && !v24) {
+ _vm->_soundManager.PLAY_WAV(1);
+ v24 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(11) == 5)
+ v24 = 0;
+ if (_vm->_objectsManager.BOBPOSI(8) == 11 && !v24) {
+ _vm->_soundManager.PLAY_WAV(2);
+ v24 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(8) == 12)
+ v24 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(8) != 32);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 201, 14, 1);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.BOBANIM_OFF(11);
+ _vm->_objectsManager.BOBANIM_OFF(8);
+ _vm->_objectsManager.BOBANIM_ON(5);
+ _vm->_objectsManager.BOBANIM_ON(6);
+ _vm->_objectsManager.SET_BOBPOSI(5, 0);
+ _vm->_objectsManager.SET_BOBPOSI(6, 0);
+ _vm->_soundManager.PLAY_WAV(3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 74);
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ _vm->_objectsManager.BOBANIM_OFF(6);
+ _vm->_objectsManager.BOBANIM_ON(9);
+ _vm->_objectsManager.BOBANIM_ON(7);
+ }
+ if (v76 == 95) {
+ _vm->_objectsManager.BOBANIM_ON(9);
+ _vm->_objectsManager.BOBANIM_ON(10);
+ _vm->_objectsManager.BOBANIM_ON(12);
+ _vm->_objectsManager.SET_BOBPOSI(9, 0);
+ _vm->_objectsManager.SET_BOBPOSI(10, 0);
+ _vm->_objectsManager.SET_BOBPOSI(12, 0);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(9) != 15);
+ _vm->_objectsManager.BOBANIM_OFF(9);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_soundManager.PLAY_SOUND("SOUND50.WAV");
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(12) != 117);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 830, 122, 0);
+ _vm->_objectsManager.BOBANIM_OFF(12);
+ _vm->_objectsManager.BOBANIM_OFF(10);
+ _vm->_objectsManager.BOBANIM_ON(11);
+ }
+ if (v76 == 85) {
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_objectsManager.BOBANIM_ON(5);
+ _vm->_objectsManager.SET_BOBPOSI(5, 0);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 6);
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ _vm->_objectsManager.BOBANIM_ON(6);
+ _vm->_objectsManager.OBSSEUL = 1;
+ _vm->_objectsManager.INILINK("IM24a");
+ _vm->_objectsManager.OBSSEUL = 0;
+ }
+ if (v76 == 88) {
+ if (_vm->_globals.SAUVEGARDE->data[svField183] == 1) {
+ _vm->_objectsManager.SET_BOBPOSI(1, 0);
+ _vm->_objectsManager.SET_BOBPOSI(2, 0);
+ _vm->_objectsManager.BOBANIM_ON(1);
+ _vm->_objectsManager.BOBANIM_ON(2);
+ _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND40.WAV");
+ v25 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(1) == 1 && !v25) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v25 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 2)
+ v25 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 3 && !v25) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v25 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 4)
+ v25 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 5 && !v25) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v25 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 6)
+ v25 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 7 && !v25) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v25 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 8)
+ v25 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(1) != 9);
+ _vm->_objectsManager.BOBANIM_OFF(1);
+ _vm->_objectsManager.BOBANIM_OFF(2);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 283, 160, 6);
+ _vm->_soundManager.DEL_SAMPLE(1);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField183] == 2) {
+ _vm->_objectsManager.SET_BOBPOSI(1, 0);
+ _vm->_objectsManager.SET_BOBPOSI(3, 0);
+ _vm->_objectsManager.BOBANIM_ON(1);
+ _vm->_objectsManager.BOBANIM_ON(3);
+ _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND40.WAV");
+ v26 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(1) == 1 && !v26) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v26 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 2)
+ v26 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 3 && !v26) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v26 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 4)
+ v26 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 5 && !v26) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v26 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 6)
+ v26 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 7 && !v26) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v26 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 8)
+ v26 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(1) != 9);
+ _vm->_objectsManager.BOBANIM_OFF(1);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 283, 161, 8);
+ _vm->_soundManager.DEL_SAMPLE(1);
+ }
+ }
+ if (v76 == 90) {
+ _vm->_soundManager.PLAY_SOUND("SOUND52.WAV");
+ if (!_vm->_globals.SAUVEGARDE->data[svField186]) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB5A.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 0);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField186] == 1) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB5C.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 0);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 329, 87, 2);
+ }
+ }
+ if (v76 == 91) {
+ _vm->_soundManager.PLAY_SOUND("SOUND52.WAV");
+ if (!_vm->_globals.SAUVEGARDE->data[svField186]) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB5B.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 5);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField186] == 1) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB5D.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 5);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 283, 160, 6);
+ }
+ }
+ if (v76 == 92) {
+ _vm->_soundManager.PLAY_SOUND("SOUND52.WAV");
+ if (!_vm->_globals.SAUVEGARDE->data[svField184]) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB6A.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 0);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField184] == 1) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB6C.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 0);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 293, 139, 3);
+ }
+ }
+ if (v76 == 93) {
+ _vm->_soundManager.PLAY_SOUND("SOUND52.WAV");
+ if (!_vm->_globals.SAUVEGARDE->data[svField184]) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB6B.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 5);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField184] == 1) {
+ _vm->_animationManager.PLAY_SEQ(v1, "CIB6D.SEQ", 1, 12, 1);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 155, 29, 5);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 283, 161, 8);
+ }
+ }
+ if (v76 == 62)
+ _vm->_talkManager.OBJET_VIVANT("SBCADA.pe2");
+ if (v76 == 65)
+ _vm->_talkManager.OBJET_VIVANT("ScCADA.pe2");
+ if (v76 == 105) {
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.g_old_x = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ if (_vm->_globals.SAUVEGARDE->data[svField253] == 1) {
+ v27 = _vm->_objectsManager.YSPR(0);
+ v28 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v28, v27, 201, 294);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField253] == 2) {
+ v29 = _vm->_objectsManager.YSPR(0);
+ v30 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v30, v29, 158, 338);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField253] > 2) {
+ v31 = _vm->_objectsManager.YSPR(0);
+ v32 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v32, v31, 211, 393);
+ }
+ _vm->_globals.NOT_VERIF = 1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.SETANISPR(0, 60);
+ _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND63.WAV");
+ if (_vm->_globals.SAUVEGARDE->data[svField253] > 2) {
+ _vm->_objectsManager.BOBANIM_ON(4);
+ v33 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(4) == 9 && !v33) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v33 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(4) == 10)
+ v33 = 0;
+ if (_vm->_objectsManager.BOBPOSI(4) == 32 && !v33) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v33 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(4) == 33)
+ v33 = 0;
+ if (_vm->_objectsManager.BOBPOSI(4) == 55 && !v33) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v33 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(4) == 56)
+ v33 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 72);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField253] == 1) {
+ _vm->_objectsManager.BOBANIM_ON(6);
+ v34 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(6) == 9 && !v34) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v34 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(6) == 10)
+ v34 = 0;
+ if (_vm->_objectsManager.BOBPOSI(6) == 32 && !v34) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v34 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(6) == 33)
+ v34 = 0;
+ if (_vm->_objectsManager.BOBPOSI(6) == 55 && !v34) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v34 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(6) == 56)
+ v34 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(6) != 72);
+ _vm->_objectsManager.BOBANIM_OFF(6);
+ }
+ if (_vm->_globals.SAUVEGARDE->data[svField253] == 2) {
+ _vm->_objectsManager.BOBANIM_ON(5);
+ v35 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(5) == 9 && !v35) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v35 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(5) == 10)
+ v35 = 0;
+ if (_vm->_objectsManager.BOBPOSI(5) == 32 && !v35) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v35 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(5) == 33)
+ v35 = 0;
+ if (_vm->_objectsManager.BOBPOSI(5) == 55 && !v35) {
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ v35 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(5) == 56)
+ v35 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 72);
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ }
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.ACTION_DOS(1);
+ _vm->_soundManager.DEL_SAMPLE(1);
+ }
+ if (v76 == 106) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ _vm->_objectsManager.SET_BOBPOSI(4, 0);
+ _vm->_soundManager.LOAD_WAV("SOUND61.WAV", 1);
+ _vm->_soundManager.LOAD_WAV("SOUND62.WAV", 2);
+ _vm->_soundManager.LOAD_WAV("SOUND61.WAV", 3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 10);
+ _vm->_soundManager.PLAY_WAV(1);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 18);
+ _vm->_soundManager.PLAY_WAV(2);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 62);
+ _vm->_soundManager.PLAY_WAV(3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 77);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_objectsManager.SPRITE_ON(0);
+ }
+ if (v76 == 107) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(5);
+ _vm->_objectsManager.SET_BOBPOSI(5, 0);
+ _vm->_soundManager.LOAD_WAV("SOUND61.WAV", 1);
+ _vm->_soundManager.LOAD_WAV("SOUND62.WAV", 2);
+ _vm->_soundManager.LOAD_WAV("SOUND61.WAV", 3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 10);
+ _vm->_soundManager.PLAY_WAV(1);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 18);
+ _vm->_soundManager.PLAY_WAV(2);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 38);
+ _vm->_soundManager.PLAY_WAV(3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(5) != 53);
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ _vm->_objectsManager.SPRITE_ON(0);
+ }
+ if (v76 == 210) {
+ _vm->_animationManager.NO_SEQ = true;
+ _vm->_soundManager.SPECIAL_SOUND = 210;
+ _vm->_animationManager.PLAY_SEQ2("SECRET1.SEQ", 1, 12, 1);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 192, 152, 0);
+ _vm->_objectsManager.BOBANIM_ON(9);
+ _vm->_objectsManager.OBSSEUL = 1;
+ _vm->_objectsManager.INILINK("IM73a");
+ _vm->_objectsManager.OBSSEUL = 0;
+ _vm->_globals.CACHE_ON();
+ _vm->_animationManager.NO_SEQ = false;
+ _vm->_globals.CACHE_ADD(0);
+ _vm->_globals.CACHE_ADD(1);
+ _vm->_graphicsManager.SETCOLOR4(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR4(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR4(254, 0, 0, 0);
+ }
+ if (v76 == 211) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_globals.CACHE_OFF();
+ _vm->_animationManager.NO_SEQ = true;
+ _vm->_globals.NO_VISU = false;
+ _vm->_soundManager.SPECIAL_SOUND = 211;
+ _vm->_animationManager.PLAY_SEQ(v1, "SECRET2.SEQ", 1, 12, 100);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_animationManager.NO_SEQ = false;
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_graphicsManager.FADE_OUTW();
+ v36 = 1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ ++v36;
+ } while (v36 <= 39);
+ _vm->_graphicsManager.SETCOLOR4(252, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR4(253, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100);
+ _vm->_graphicsManager.SETCOLOR4(254, 0, 0, 0);
+ }
+ if (v76 == 207)
+ _vm->_talkManager.OBJET_VIVANT("PANNEAU.PE2");
+ if (v76 == 208) {
+ _vm->_globals.DESACTIVE_INVENT = true;
+ if (_vm->_globals.SAUVEGARDE->data[svField6] != _vm->_globals.SAUVEGARDE->data[svField401]) {
+ _vm->_soundManager.SPECIAL_SOUND = 208;
+ _vm->_eventsManager.NOESC = true;
+ _vm->_animationManager.PLAY_SEQ(v1, "SORT.SEQ", 10, 4, 10);
+ _vm->_eventsManager.NOESC = false;
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ }
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ v37 = _vm->_objectsManager.YSPR(0);
+ v38 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v38, v37, 330, 418);
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.NUMZONE = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SETANISPR(0, 64);
+ _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField401];
+ _vm->_globals.DESACTIVE_INVENT = false;
+ }
+ if (v76 == 209) {
+ _vm->_objectsManager.SET_BOBPOSI(1, 0);
+ _vm->_objectsManager.SET_BOBPOSI(2, 0);
+ _vm->_objectsManager.SETANISPR(0, 60);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_objectsManager.BOBANIM_ON(1);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(1) != 9);
+ _vm->_objectsManager.BOBANIM_OFF(1);
+ _vm->_globals.NO_VISU = true;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.NOT_VERIF = 1;
+ v39 = _vm->_objectsManager.YSPR(0);
+ v40 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v40, v39, 330, 314);
+ _vm->_objectsManager.NUMZONE = 0;
+ _vm->_globals.NOT_VERIF = 1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SETANISPR(0, 64);
+ _vm->_objectsManager.BOBANIM_ON(2);
+ _vm->_soundManager.PLAY_SOUND("SOUND66.WAV");
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(2) != 10);
+ _vm->_objectsManager.BOBANIM_OFF(2);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ }
+ if (v76 == 201) {
+ _vm->_objectsManager.BOBANIM_ON(3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(3) != 18);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ }
+ if (v76 == 203) {
+ _vm->_globals.NO_VISU = true;
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ if (_vm->_objectsManager.BOBPOSI(4) == 18)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 18, 334, 0);
+ } while (_vm->_objectsManager.BOBPOSI(4) != 26);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_globals.NO_VISU = false;
+ _vm->_objectsManager.SPRITE_ON(0);
+ }
+ if (v76 == 204) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(3);
+ _vm->_soundManager.LOAD_WAV("SOUND67.WAV", 1);
+ v41 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(3) == 10 && !v41) {
+ _vm->_soundManager.PLAY_WAV(1);
+ v41 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(3) == 11)
+ v41 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(3) != 50);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_objectsManager.SPRITE_ON(0);
+ }
+ if (v76 == 205) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(4);
+ _vm->_soundManager.LOAD_WAV("SOUND69.WAV", 1);
+ v42 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(4) == 10 && !v42) {
+ _vm->_soundManager.PLAY_WAV(1);
+ v42 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(4) == 11)
+ v42 = 0;
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(4) != 24);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_objectsManager.SPRITE_ON(0);
+ }
+ if (v76 == 175) {
+ _vm->_objectsManager.SETANISPR(0, 55);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(9);
+ _vm->_objectsManager.BOBANIM_ON(10);
+ _vm->_objectsManager.BOB_OFFSET(10, 300);
+ _vm->_soundManager.PLAY_SOUND("SOUND44.WAV");
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(10) != 7);
+ _vm->_objectsManager.BOBANIM_ON(6);
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(6) != 10);
+ _vm->_soundManager.PLAY_SOUND("SOUND71.WAV");
+ _vm->_objectsManager.BOBANIM_ON(7);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(7) != 15);
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ _vm->_objectsManager.BOBANIM_ON(8);
+ _vm->_soundManager.PLAY_SOUND("SOUND70.WAV");
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(8) != 76);
+ _vm->_objectsManager.BOBANIM_OFF(6);
+ _vm->_objectsManager.BOBANIM_OFF(7);
+ _vm->_objectsManager.BOBANIM_OFF(8);
+ _vm->_objectsManager.BOBANIM_OFF(9);
+ _vm->_objectsManager.BOBANIM_OFF(10);
+ _vm->_objectsManager.SPRITE_ON(0);
+ }
+ if (v76 == 229) {
+ _vm->_soundManager.SPECIAL_SOUND = 229;
+ _vm->_animationManager.PLAY_SEQ(v1, "MUR.SEQ", 1, 12, 1);
+ _vm->_soundManager.SPECIAL_SOUND = 0;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 340, 157, 2);
+ }
+ if (v76 == 230) {
+ _vm->_objectsManager.OBSSEUL = 1;
+ _vm->_objectsManager.INILINK("IM93a");
+ _vm->_objectsManager.OBSSEUL = 0;
+ _vm->_globals.CACHE_ON();
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.g_old_x = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.NOT_VERIF = 1;
+ v43 = _vm->_objectsManager.YSPR(0);
+ v44 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v44, v43, 488, 280);
+ _vm->_globals.NOT_VERIF = 1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_objectsManager.SPRITE_OFF(0);
+ v45 = 0;
+ _vm->_objectsManager.BOBANIM_ON(7);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(7) == 9 && !v45) {
+ v45 = 1;
+ _vm->_soundManager.PLAY_SOUND("SOUND81.WAV");
+ }
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(7) != 15);
+ _vm->_objectsManager.BOBANIM_OFF(7);
+ _vm->_objectsManager.SETXSPR(0, 476);
+ _vm->_objectsManager.SETYSPR(0, 278);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 337, 154, 3);
+ _vm->_objectsManager.OBSSEUL = 1;
+ _vm->_objectsManager.INILINK("IM93c");
+ _vm->_objectsManager.OBSSEUL = 0;
+ _vm->_globals.CACHE_ON();
+ }
+ if (v76 == 231) {
+ _vm->_globals.CACHE_OFF();
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(12);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(12) != 6);
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("PRMORT.pe2");
+ _vm->_globals.NOPARLE = false;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(12) != 12);
+ _vm->_objectsManager.SPRITE_ON(0);
+ _vm->_objectsManager.BOBANIM_OFF(12);
+ _vm->_globals.CACHE_ON();
+ }
+ if (v76 == 233) {
+ _vm->_globals.CACHE_OFF();
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.BOBANIM_ON(11);
+ v46 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ if (_vm->_objectsManager.BOBPOSI(11) == 10 && !v46)
+ v46 = 1;
+ } while (_vm->_objectsManager.BOBPOSI(11) != 13);
+ _vm->_objectsManager.BOBANIM_OFF(11);
+ _vm->_globals.CACHE_ON();
+ _vm->_objectsManager.BOBANIM_ON(13);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(13) != 48);
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("HRADIO.PE2");
+ _vm->_globals.NOPARLE = false;
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_objectsManager.BOBANIM_OFF(13);
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_globals.SORTIE = 94;
+ }
+ if (v76 == 52) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("GARDE.PE2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 53)
+ _vm->_talkManager.PARLER_PERSO("GARDE1.pe2");
+ if (v76 == 54)
+ _vm->_talkManager.PARLER_PERSO("GARDE2.pe2");
+ if (v76 == 40)
+ _vm->_talkManager.PARLER_PERSO("MAGE.pe2");
+ if (v76 == 236) {
+ v47 = _vm->_globals.SAUVEGARDE->data[svField341];
+ if (v47) {
+ if (v47 == 2)
+ v70 = 5;
+ if (v47 == 3)
+ v70 = 4;
+ if (v47 == 1)
+ v70 = 6;
+ _vm->_soundManager.PLAY_SOUND("SOUND83.WAV");
+ _vm->_objectsManager.OPTI_ONE(v70, 26, 50, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 1)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 27, 117, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 145, 166, 2);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 3)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 296, 212, 4);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 1)
+ _vm->_globals.SAUVEGARDE->data[svField338] = 0;
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2)
+ _vm->_globals.SAUVEGARDE->data[svField339] = 0;
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 3)
+ _vm->_globals.SAUVEGARDE->data[svField340] = 0;
+ }
+ _vm->_soundManager.PLAY_SOUND("SOUND83.WAV");
+ _vm->_objectsManager.OPTI_ONE(6, 0, 23, 0);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 27, 117, 1);
+ }
+ if (v76 == 237) {
+ v48 = _vm->_globals.SAUVEGARDE->data[svField341];
+ if (v48) {
+ if (v48 == 2)
+ v70 = 5;
+ if (v48 == 3)
+ v70 = 4;
+ if (v48 == 1)
+ v70 = 6;
+ _vm->_soundManager.PLAY_SOUND("SOUND83.WAV");
+ _vm->_objectsManager.OPTI_ONE(v70, 26, 50, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 1)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 27, 117, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 145, 166, 2);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 3)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 296, 212, 4);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 1)
+ _vm->_globals.SAUVEGARDE->data[svField338] = 0;
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2)
+ _vm->_globals.SAUVEGARDE->data[svField339] = 0;
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 3)
+ _vm->_globals.SAUVEGARDE->data[svField340] = 0;
+ }
+ _vm->_soundManager.PLAY_SOUND("SOUND83.WAV");
+ _vm->_objectsManager.OPTI_ONE(5, 0, 23, 0);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 145, 166, 3);
+ }
+ if (v76 == 238) {
+ v49 = _vm->_globals.SAUVEGARDE->data[svField341];
+ if (v49) {
+ if (v49 == 2)
+ v70 = 5;
+ if (v49 == 3)
+ v70 = 4;
+ if (v49 == 1)
+ v70 = 6;
+ _vm->_soundManager.PLAY_SOUND("SOUND83.WAV");
+ _vm->_objectsManager.OPTI_ONE(v70, 26, 50, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 1)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 27, 117, 0);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 145, 166, 2);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 3)
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 296, 212, 4);
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 1)
+ _vm->_globals.SAUVEGARDE->data[svField338] = 0;
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2)
+ _vm->_globals.SAUVEGARDE->data[svField339] = 0;
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 3)
+ _vm->_globals.SAUVEGARDE->data[svField340] = 0;
+ }
+ _vm->_soundManager.PLAY_SOUND("SOUND83.WAV");
+ _vm->_objectsManager.OPTI_ONE(4, 0, 23, 0);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 296, 212, 5);
+ }
+ if (v76 == 239) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_soundManager.PLAY_SOUND("SOUND84.WAV");
+ _vm->_objectsManager.OPTI_ONE(16, 0, 10, 0);
+ }
+ if (v76 == 240) {
+ _vm->_objectsManager.BOBANIM_ON(1);
+ v50 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ if (_vm->_objectsManager.BOBPOSI(1) == 12 && !v50) {
+ _vm->_soundManager.PLAY_SOUND("SOUND86.WAV");
+ v50 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 13)
+ v50 = 0;
+ if (_vm->_objectsManager.BOBPOSI(1) == 25 && !v50) {
+ _vm->_soundManager.PLAY_SOUND("SOUND85.WAV");
+ v50 = 1;
+ }
+ if (_vm->_objectsManager.BOBPOSI(1) == 25)
+ v50 = 0;
+ } while (_vm->_objectsManager.BOBPOSI(1) != 32);
+ _vm->_objectsManager.BOBANIM_OFF(1);
+ _vm->_objectsManager.BOBANIM_ON(2);
+ _vm->_fontManager.TEXTE_OFF(9);
+ if (!_vm->_soundManager.TEXTOFF) {
+ _vm->_fontManager.DOS_TEXT(9, 617, _vm->_globals.FICH_TEXTE, 91, 41, 20, 25, 3, 30, 253);
+ _vm->_fontManager.TEXTE_ON(9);
+ }
+ if (!_vm->_soundManager.VOICEOFF)
+ _vm->_soundManager.VOICE_MIX(617, 4);
+ v71 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_eventsManager.VBL();
+ ++v71;
+ } while (v71 <= 29);
+ v51 = &_vm->_globals.SAUVEGARDE->field370;
+ v51->field0 = _vm->_objectsManager.XSPR(0);
+ v51->field1 = _vm->_objectsManager.YSPR(0);
+ v51->field2 = 57;
+ v51->field3 = 97;
+ _vm->_globals.SAUVEGARDE->data[svField121] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField352] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField353] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField354] = 1;
+ }
+ if (v76 == 56) {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("HOPFEM.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 1;
+ _vm->_globals.SAUVEGARDE->data[svField122] = 1;
+ _vm->_globals.HOPKINS_DATA();
+ _vm->_objectsManager.Sprite[0].field12 = 28;
+ _vm->_objectsManager.Sprite[0].field14 = 155;
+ _vm->_objectsManager.VERIFTAILLE();
+ }
+ if (v76 == 57) {
+ _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR");
+ _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO);
+ _vm->_globals.PERSO_TYPE = 0;
+ _vm->_globals.SAUVEGARDE->data[svField122] = 0;
+ _vm->_globals.HOPKINS_DATA();
+ _vm->_objectsManager.Sprite[0].field12 = 34;
+ _vm->_objectsManager.Sprite[0].field14 = 190;
+ _vm->_objectsManager.VERIFTAILLE();
+ }
+ if (v76 == 25)
+ _vm->_talkManager.PARLER_PERSO("AGENT1.pe2");
+ if (v76 == 26)
+ _vm->_talkManager.PARLER_PERSO("AGENT2.pe2");
+ if (v76 == 87) {
+ if (_vm->_globals.SAUVEGARDE->data[svField188])
+ _vm->_talkManager.PARLER_PERSO("stand2.pe2");
+ else
+ _vm->_talkManager.PARLER_PERSO("stand1.pe2");
+ }
+ if (v76 == 86) {
+ if (_vm->_globals.SAUVEGARDE->data[svField231] == 1) {
+ _vm->_talkManager.PARLER_PERSO("chotess1.pe2");
+ } else {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("chotesse.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ }
+ if (v76 == 51) {
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_globals.CACHE_OFF();
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_graphicsManager.FIN_VISU();
+ _vm->_graphicsManager.LOAD_IMAGE("IM20f");
+ _vm->_animationManager.CHARGE_ANIM("ANIM20f");
+ _vm->_graphicsManager.VISU_ALL();
+ _vm->_eventsManager.MOUSE_OFF();
+ _vm->_graphicsManager.FADE_INW();
+ v52 = 0;
+ _vm->_soundManager.LOAD_WAV("SOUND46.WAV", 1);
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ if (_vm->_objectsManager.BOBPOSI(12) == 5 && !v52) {
+ _vm->_soundManager.PLAY_WAV(1);
+ v52 = 1;
+ }
+ _vm->_eventsManager.VBL();
+ } while (_vm->_objectsManager.BOBPOSI(12) != 34);
+ _vm->_objectsManager.BOBANIM_OFF(2);
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_globals.SORTIE = 20;
+ }
+ if (v76 == 41)
+ _vm->_talkManager.PARLER_PERSO("MORT3.pe2");
+ if (v76 == 44)
+ _vm->_talkManager.PARLER_PERSO("MORT3A.pe2");
+ if (v76 == 42)
+ _vm->_talkManager.PARLER_PERSO("MORT2.pe2");
+ if (v76 == 43)
+ _vm->_talkManager.PARLER_PERSO("MORT1.pe2");
+ if (v76 == 47)
+ _vm->_talkManager.PARLER_PERSO("BARMAN.pe2");
+ if (v76 == 45)
+ _vm->_talkManager.PARLER_PERSO("FEM3.pe2");
+ if (v76 == 48)
+ _vm->_talkManager.PARLER_PERSO("SAMAN2.pe2");
+ if (v76 == 21)
+ _vm->_talkManager.PARLER_PERSO("MEDLEG.pe2");
+ if (v76 == 94) {
+ if (!_vm->_globals.SAUVEGARDE->data[svField228])
+ _vm->_talkManager.PARLER_PERSO("flicn.pe2");
+ if (_vm->_globals.SAUVEGARDE->data[svField228] == 1)
+ _vm->_talkManager.PARLER_PERSO("flicn1.pe2");
+ }
+ if (v76 == 27) {
+ if (_vm->_globals.SAUVEGARDE->data[svField94] != 1 || _vm->_globals.SAUVEGARDE->data[svField95] != 1)
+ _vm->_talkManager.PARLER_PERSO("STANDAR.pe2");
+ else
+ _vm->_talkManager.PARLER_PERSO("STANDAR1.pe2");
+ }
+ if (v76 == 58) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("Gm1.PE2");
+ _vm->_globals.SAUVEGARDE->data[svField176] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField270] = 2;
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 200) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("Gm2.PE2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 84) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("CVIGIL1.PE2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 98) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("CVIGIL2.PE2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 83)
+ _vm->_talkManager.PARLER_PERSO("CVIGIL.pe2");
+ if (v76 == 32)
+ _vm->_talkManager.PARLER_PERSO("SAMAN.pe2");
+ if (v76 == 215) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("aviat.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 216) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("aviat1.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 170)
+ _vm->_talkManager.PARLER_PERSO("GRED.pe2");
+ if (v76 == 172)
+ _vm->_talkManager.PARLER_PERSO("GBLEU.pe2");
+ if (v76 == 100)
+ _vm->_talkManager.PARLER_PERSO("tourist.pe2");
+ if (v76 == 103) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("tourist1.pe2");
+ _vm->_globals.NOPARLE = false;
+ if (_vm->_globals.SVGA == 1)
+ _vm->_animationManager.PLAY_ANM2("T421.ANM", 100, 14, 500);
+ if (_vm->_globals.SVGA == 2)
+ _vm->_animationManager.PLAY_ANM2("T421a.ANM", 100, 14, 500);
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.VBL();
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("tourist2.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 104) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("tourist3.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 108) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("peche1.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 109) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("peche2.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 110) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("peche3.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 111) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("peche4.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 112) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("teint1.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 176) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("gred2.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 177) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("gbleu2.pe2");
+ _vm->_globals.NOPARLE = false;
+ }
+ if (v76 == 113)
+ _vm->_talkManager.PARLER_PERSO("teint.pe2");
+ if (v76 == 114)
+ _vm->_talkManager.PARLER_PERSO("tahibar.pe2");
+ if (v76 == 115)
+ _vm->_talkManager.PARLER_PERSO("ilebar.pe2");
+ if (v76 == 116)
+ _vm->_talkManager.PARLER_PERSO("Profred.pe2");
+ if (v76 == 101)
+ _vm->_talkManager.PARLER_PERSO("tahi1.pe2");
+ if (v76 == 243) {
+ _vm->_soundManager.PLAY_SOUND("SOUND88.WAV");
+ if (_vm->_globals.SAUVEGARDE->data[svField341] == 2) {
+ _vm->_animationManager.NO_SEQ = true;
+ _vm->_animationManager.PLAY_SEQ(v1, "RESU.SEQ", 2, 24, 2);
+ _vm->_animationManager.NO_SEQ = false;
+ } else {
+ _vm->_objectsManager.OPTI_ONE(7, 0, 14, 0);
+ }
+ }
+ if (v76 == 242) {
+ _vm->_soundManager.PLAY_SOUND("SOUND87.WAV");
+ _vm->_animationManager.NO_SEQ = true;
+ _vm->_animationManager.PLAY_SEQ(v1, "RESUF.SEQ", 1, 24, 1);
+ _vm->_animationManager.NO_SEQ = false;
+ v53 = &_vm->_globals.SAUVEGARDE->field380;
+ v53->field0 = 404;
+ v53->field1 = 395;
+ v53->field2 = 64;
+ v53->field3 = _vm->_globals.ECRAN;
+
+ v54 = _vm->_globals.STAILLE[790 / 2];
+ if (_vm->_globals.STAILLE[790 / 2] < 0)
+ v54 = -_vm->_globals.STAILLE[790 / 2];
+ v76 = -(100 * (67 - (100 - v54)) / 67);
+ v53->field4 = v76;
+ _vm->_globals.SAUVEGARDE->data[svField357] = 1;
+ _vm->_globals.SAUVEGARDE->data[svField354] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField356] = 0;
+ _vm->_globals.SAUVEGARDE->data[svField355] = 1;
+ _vm->_objectsManager.DEUXPERSO = true;
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 373, 191, 3);
+ _vm->_objectsManager.SPRITE(_vm->_globals.TETE, v53->field0, v53->field1, 1, 3, v53->field4, 0, 20, 127);
+ _vm->_objectsManager.SPRITE_ON(1);
+ }
+ if (v76 == 245) {
+ _vm->_soundManager.PLAY_SOUND("SOUND89.WAV");
+ _vm->_objectsManager.OPTI_ONE(5, 0, 6, 0);
+ _vm->_globals.ZONEP[4].destX = 276;
+ _vm->_objectsManager.VERBE_ON(4, 19);
+ _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 285, 379, 0);
+ _vm->_globals.SAUVEGARDE->data[svField399] = 1;
+ }
+ if (v76 == 246) {
+ _vm->_objectsManager.SPRITE_OFF(0);
+ _vm->_objectsManager.OPTI_ONE(6, 0, 15, 0);
+ _vm->_objectsManager.PERSO_ON = true;
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_animationManager.NO_SEQ = true;
+ _vm->_animationManager.PLAY_SEQ2("TUNNEL.SEQ", 1, 18, 20);
+ _vm->_animationManager.NO_SEQ = false;
+ _vm->_graphicsManager.NOFADE = true;
+ _vm->_graphicsManager.FADE_OUTW();
+ _vm->_objectsManager.PERSO_ON = false;
+ _vm->_globals.SORTIE = 100;
+ }
+ if (v76 == 55) {
+ _vm->_objectsManager.BOBANIM_OFF(1);
+ _vm->_objectsManager.OPTI_ONE(15, 0, 12, 0);
+ _vm->_objectsManager.BOBANIM_OFF(15);
+ _vm->_objectsManager.OBSSEUL = 1;
+ _vm->_objectsManager.INILINK("IM19a");
+ _vm->_objectsManager.OBSSEUL = 0;
+ }
+ if (v76 == 241)
+ _vm->_talkManager.PARLER_PERSO("RECEP.PE2");
+ if (v76 == 171) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("gred1.pe2");
+ _vm->_globals.NOPARLE = false;
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.g_old_x = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.NOT_VERIF = 1;
+ v55 = _vm->_objectsManager.YSPR(0);
+ v56 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v56, v55, 361, 325);
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.NUMZONE = -1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_globals.SORTIE = 59;
+ }
+ if (v76 == 173) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("gbleu1.pe2");
+ _vm->_globals.NOPARLE = false;
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.g_old_x = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.g_old_sens = -1;
+ _vm->_globals.Compteur = 0;
+ _vm->_globals.chemin = (int16 *)g_PTRNUL;
+ _vm->_globals.NOT_VERIF = 1;
+ v57 = _vm->_objectsManager.YSPR(0);
+ v58 = _vm->_objectsManager.XSPR(0);
+ _vm->_globals.chemin = _vm->_linesManager.PARCOURS2(v58, v57, 361, 325);
+ _vm->_globals.NOT_VERIF = 1;
+ _vm->_objectsManager.NUMZONE = -1;
+ do {
+ if (_vm->shouldQuit())
+ return -1; // Exiting game
+
+ _vm->_objectsManager.GOHOME();
+ _vm->_eventsManager.VBL();
+ } while (_vm->_globals.chemin != (int16 *)g_PTRNUL);
+ _vm->_globals.SORTIE = 59;
+ }
+ if (v76 == 174)
+ _vm->_talkManager.PARLER_PERSO("Profbl.pe2");
+ if (v76 == 202) {
+ _vm->_globals.NOPARLE = true;
+ _vm->_talkManager.PARLER_PERSO("SVGARD2.PE2");
+ _vm->_globals.NOPARLE = false;
+ }
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'E' && *(a1 + 3) == 'I' && *(a1 + 4) == 'F')
+ v1 = 4;
+ if (*(a1 + 2) == 'V' && *(a1 + 3) == 'A' && *(a1 + 4) == 'L') {
+ v1 = 1;
+ _vm->_globals.SAUVEGARDE->data[(int16)READ_LE_UINT16(a1 + 5)] = (int16)READ_LE_UINT16(a1 + 7);
+ }
+ if (*(a1 + 2) == 'A' && *(a1 + 3) == 'D' && *(a1 + 4) == 'D') {
+ v1 = 1;
+ _vm->_globals.SAUVEGARDE->data[(int16)READ_LE_UINT16(a1 + 5)] += *(a1 + 7);
+ }
+ if (*(a1 + 2) == 'B' && *(a1 + 3) == 'O' && *(a1 + 4) == 'S') {
+ v1 = 1;
+ _vm->_objectsManager.BOB_OFFSET((int16)READ_LE_UINT16(a1 + 5), (int16)READ_LE_UINT16(a1 + 7));
+ }
+ if (*(a1 + 2) == 'V' && *(a1 + 3) == 'O' && *(a1 + 4) == 'N') {
+ _vm->_objectsManager.VERBE_ON((int16)READ_LE_UINT16(a1 + 5), (int16)READ_LE_UINT16(a1 + 7));
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'Z' && *(a1 + 3) == 'C' && *(a1 + 4) == 'H') {
+ _vm->_globals.ZONEP[(int16)READ_LE_UINT16(a1 + 5)].field12 = (int16)READ_LE_UINT16(a1 + 7);
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'J' && *(a1 + 3) == 'U' && *(a1 + 4) == 'M') {
+ v59 = (int16)READ_LE_UINT16(a1 + 7);
+ _vm->_objectsManager.NVZONE = (int16)READ_LE_UINT16(a1 + 5);
+ _vm->_objectsManager.NVVERBE = v59;
+ v1 = 6;
+ }
+ if (*(a1 + 2) == 'S' && *(a1 + 3) == 'O' && *(a1 + 4) == 'U') {
+ v60 = (int16)READ_LE_UINT16(a1 + 5);
+ memset(&s, 0, 0x13u);
+
+ v77 = Common::String::format("SOUND%d.WAV", v60);
+ _vm->_soundManager.PLAY_SOUND(s);
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'V' && *(a1 + 3) == 'O' && *(a1 + 4) == 'F') {
+ _vm->_objectsManager.VERBE_OFF((int16)READ_LE_UINT16(a1 + 5), (int16)READ_LE_UINT16(a1 + 7));
+ v1 = 1;
+ }
+ if (*(a1 + 2) == 'I' && *(a1 + 3) == 'I' && *(a1 + 4) == 'F') {
+ v1 = 3;
+ }
+
+ return v1;
+}
+
+
+int ScriptManager::Control_Goto(const byte *dataP) {
+ return (int16)READ_LE_UINT16(dataP + 5);
+}
+
+int ScriptManager::Control_If(const byte *dataP, int a2) {
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ const byte *v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+
+ v2 = a2;
+LABEL_2:
+ v3 = v2;
+ do {
+ if (_vm->shouldQuit())
+ return 0; // Exiting game
+
+ ++v3;
+ v4 = Traduction2(dataP + 20 * v3);
+ if (v3 > 400) {
+ v5 = v4;
+ error("Control if failed");
+ v4 = v5;
+ }
+ } while (v4 != 4);
+ v20 = v3;
+ v6 = v2;
+ v7 = 0;
+ do {
+ if (_vm->shouldQuit())
+ return 0; // Exiting game
+
+ ++v6;
+ if (Traduction2(dataP + 20 * v6) == 3)
+ v7 = 1;
+ if (v6 > 400)
+ error("Control if failed ");
+ if (v7 == 1) {
+ v2 = v20;
+ goto LABEL_2;
+ }
+ } while (v20 != v6);
+ v8 = dataP + 20 * a2;
+ v9 = *(v8 + 13);
+ v17 = *(v8 + 14);
+ v16 = *(v8 + 15);
+ v10 = (int16)READ_LE_UINT16(v8 + 5);
+ v11 = (int16)READ_LE_UINT16(v8 + 7);
+ v19 = (int16)READ_LE_UINT16(v8 + 9);
+ v18 = (int16)READ_LE_UINT16(v8 + 11);
+ v14 = 0;
+ v15 = 0;
+ if (v9 == 1 && _vm->_globals.SAUVEGARDE->data[v10] == v11)
+ v14 = 1;
+ if (v9 == 2 && _vm->_globals.SAUVEGARDE->data[v10] != v11)
+ v14 = 1;
+ if (v9 == 3 && _vm->_globals.SAUVEGARDE->data[v10] <= v11)
+ v14 = 1;
+ if (v9 == 4 && _vm->_globals.SAUVEGARDE->data[v10] >= v11)
+ v14 = 1;
+ if (v9 == 5 && _vm->_globals.SAUVEGARDE->data[v10] > v11)
+ v14 = 1;
+ if (v9 == 6 && _vm->_globals.SAUVEGARDE->data[v10] < v11)
+ v14 = 1;
+ if (v16 == 3)
+ goto LABEL_68;
+ if (v17 == 1 && v18 == _vm->_globals.SAUVEGARDE->data[v19])
+ v15 = 1;
+ if (v17 == 2 && v18 != _vm->_globals.SAUVEGARDE->data[v19])
+ v15 = 1;
+ if (v17 == 3 && v18 >= _vm->_globals.SAUVEGARDE->data[v19])
+ v15 = 1;
+ if (v17 == 4 && v18 <= _vm->_globals.SAUVEGARDE->data[v19])
+ v15 = 1;
+ if (v17 == 5 && v18 < _vm->_globals.SAUVEGARDE->data[v19])
+ v15 = 1;
+ if (v17 == 6 && v18 > _vm->_globals.SAUVEGARDE->data[v19])
+ v15 = 1;
+ if (v16 == 3) {
+LABEL_68:
+ if (v14 == 1) {
+ v12 = a2;
+ return (v12 + 1);
+ }
+ if (!v14) {
+LABEL_63:
+ v12 = v20;
+ return (v12 + 1);
+ }
+ }
+ if (v16 == 1) {
+ if (v14 == 1 && v15 == 1) {
+ v12 = a2;
+ return (v12 + 1);
+ }
+ goto LABEL_63;
+ }
+ if (v16 == 2) {
+ if (v14 == 1 || v15 == 1) {
+ v12 = a2;
+ return (v12 + 1);
+ }
+ goto LABEL_63;
+ }
+ return -1;
+}
+
+int ScriptManager::Traduction2(const byte *dataP) {
+ int16 result;
+
+ result = 0;
+ if (*dataP != 'F' || *(dataP + 1) != 'C') {
+ result = 0;
+ } else {
+ if (*(dataP + 'T') == 84 && *(dataP + 3) == 'X' && *(dataP + 4) == 'T')
+ result = 1;
+ if (*(dataP + 2) == 'B') {
+ if (*(dataP + 3) == 'O' && *(dataP + 4) == 'B')
+ result = 1;
+ if (*(dataP + 2) == 'B' && *(dataP + 3) == 'O' && *(dataP + 4) == 'F')
+ result = 1;
+ }
+ if (*(dataP + 2) == 'P' && *(dataP + 3) == 'E' && *(dataP + 4) == 'R')
+ result = 1;
+ if (*(dataP + 2) == 'S' && *(dataP + 3) == 'O' && *(dataP + 4) == 'U')
+ result = 1;
+ if (*(dataP + 2) == 'M' && *(dataP + 3) == 'U' && *(dataP + 4) == 'S')
+ result = 1;
+ if (*(dataP + 2) == 'O') {
+ if (*(dataP + 3) == 'B' && *(dataP + 4) == 'P')
+ result = 1;
+ if (*(dataP + 2) == 'O' && *(dataP + 3) == 'B' && *(dataP + 4) == 'M')
+ result = 1;
+ }
+ if (*(dataP + 2) == 'G' && *(dataP + 3) == 'O' && *(dataP + 4) == 'T')
+ result = 2;
+ if (*(dataP + 2) == 'Z') {
+ if (*(dataP + 3) == 'O' && *(dataP + 4) == 'N')
+ result = 1;
+ if (*(dataP + 2) == 'Z' && *(dataP + 3) == 'O' && *(dataP + 4) == 'F')
+ result = 1;
+ }
+ if (*(dataP + 2) == 'E' && *(dataP + 3) == 'X' && *(dataP + 4) == 'I')
+ result = 5;
+ if (*(dataP + 2) == 'S' && *(dataP + 3) == 'O' && *(dataP + 4) == 'R')
+ result = 5;
+ if (*(dataP + 2) == 'A' && *(dataP + 3) == 'N' && *(dataP + 4) == 'I')
+ result = 1;
+ if (*(dataP + 2) == 'S' && *(dataP + 3) == 'P' && *(dataP + 4) == 'E')
+ result = 1;
+ if (*(dataP + 2) == 'E' && *(dataP + 3) == 'I' && *(dataP + 4) == 'F')
+ result = 4;
+ if (*(dataP + 2) == 'V') {
+ if (*(dataP + 3) == 'A' && *(dataP + 4) == 'L')
+ result = 1;
+ if (*(dataP + 2) == 'V') {
+ if (*(dataP + 3) == 'O' && *(dataP + 4) == 'N')
+ result = 1;
+ if (*(dataP + 2) == 'V' && *(dataP + 3) == 'O' && *(dataP + 4) == 'F')
+ result = 1;
+ }
+ }
+ if (*(dataP + 2) == 'I' && *(dataP + 3) == 'I' && *(dataP + 4) == 'F')
+ result = 3;
+ if (*(dataP + 2) == 'J' && *(dataP + 3) == 'U' && *(dataP + 4) == 'M')
+ result = 6;
+ if (*(dataP + 2) == 'B') {
+ if (*(dataP + 3) == 'C' && *(dataP + 4) == 'A')
+ result = 1;
+ if (*(dataP + 2) == 'B' && *(dataP + 3) == 'O' && *(dataP + 4) == 'S')
+ result = 1;
+ }
+ if (*(dataP + 2) == 'Z' && *(dataP + 3) == 'C') {
+ if (*(dataP + 4) == 'H')
+ result = 1;
+ }
+ }
+ return result;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/script.h b/engines/hopkins/script.h
new file mode 100644
index 0000000000..27f167ae1b
--- /dev/null
+++ b/engines/hopkins/script.h
@@ -0,0 +1,50 @@
+/* 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_SCRIPT_H
+#define HOPKINS_SCRIPT_H
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/str.h"
+#include "hopkins/globals.h"
+
+namespace Hopkins {
+
+class ScriptManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ int TRAVAILOBJET;
+public:
+ ScriptManager();
+ void setParent(HopkinsEngine *vm);
+
+ int Traduction(byte *a1);
+ int Traduction2(const byte *dataP);
+ int Control_Goto(const byte *dataP);
+ int Control_If(const byte *dataP, int a2);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_SCRIPT_H */
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp
new file mode 100644
index 0000000000..42eb98ec63
--- /dev/null
+++ b/engines/hopkins/sound.cpp
@@ -0,0 +1,114 @@
+/* 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 "common/textconsole.h"
+#include "hopkins/sound.h"
+
+namespace Hopkins {
+
+SoundManager::SoundManager() {
+ SPECIAL_SOUND = 0;
+ SOUNDVOL = 0;
+ VOICEVOL = 0;
+ MUSICVOL = 0;
+ OLD_SOUNDVOL = 0;
+ OLD_MUSICVOL = 0;
+ OLD_VOICEVOL = 0;
+ SOUNDOFF = true;
+ MUSICOFF = true;
+ VOICEOFF = true;
+ TEXTOFF = false;
+ SOUND_FLAG = false;
+}
+
+void SoundManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+ SPECIAL_SOUND = 0;
+}
+
+void SoundManager::WSOUND_INIT() {
+ warning("TODO: WSOUND_INIT");
+}
+
+void SoundManager::VERIF_SOUND() {
+// warning("TODO: VERIF_SOUND");
+}
+
+void SoundManager::LOAD_ANM_SOUND() {
+ warning("TODO: LOAD_ANIM_SOUND");
+}
+
+void SoundManager::LOAD_WAV(const Common::String &file, int a2) {
+ warning("TODO: LOAD_WAV");
+}
+
+void SoundManager::PLAY_ANM_SOUND(int soundNumber) {
+ warning("TODO: PLAAY_ANIM_SOUND");
+}
+
+void SoundManager::WSOUND(int soundNumber) {
+ warning("TODO: WSOUND");
+}
+
+bool SoundManager::VOICE_MIX(int a1, int a2) {
+ warning("TODO: VOICE_MIX");
+ return false;
+}
+
+void SoundManager::DEL_SAMPLE(int soundNumber) {
+ warning("TODO: DEL_SAMPLE");
+}
+
+void SoundManager::PLAY_SOUND(const Common::String &file) {
+ warning("TODO: PLAY_SOUND");
+}
+
+void SoundManager::PLAY_SOUND2(const Common::String &file) {
+ warning("TODO: PLAY_SOUND2");
+}
+
+void SoundManager::MODSetSampleVolume() {
+ warning("TODO MODSetSampleVolume");
+}
+
+void SoundManager::MODSetVoiceVolume() {
+ warning("TODO MODSetVoiceVolume");
+}
+
+void SoundManager::MODSetMusicVolume(int volume) {
+ warning("TODO MODSetMusicVolume");
+}
+
+void SoundManager::CHARGE_SAMPLE(int a1, const Common::String &file) {
+ warning("TODO: CHARGE_SAMPLE");
+}
+
+void SoundManager::PLAY_SAMPLE2(int idx) {
+ warning("PLAY_SAMPLE2");
+}
+
+void SoundManager::PLAY_WAV(int a1) {
+ warning("PLAY_WAV");
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h
new file mode 100644
index 0000000000..2dfdac7749
--- /dev/null
+++ b/engines/hopkins/sound.h
@@ -0,0 +1,73 @@
+/* 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 HopkinsEngine;
+
+class SoundManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ int SPECIAL_SOUND;
+ int SOUNDVOL;
+ int VOICEVOL;
+ int MUSICVOL;
+ int OLD_SOUNDVOL;
+ int OLD_MUSICVOL;
+ int OLD_VOICEVOL;
+ bool SOUNDOFF;
+ bool MUSICOFF;
+ bool VOICEOFF;
+ bool TEXTOFF;
+ bool SOUND_FLAG;
+public:
+ SoundManager();
+ void setParent(HopkinsEngine *vm);
+
+ void WSOUND_INIT();
+ void VERIF_SOUND();
+ void LOAD_ANM_SOUND();
+ void LOAD_WAV(const Common::String &file, int a2);
+ void PLAY_ANM_SOUND(int soundNumber);
+ void WSOUND(int soundNumber);
+ bool VOICE_MIX(int a1, int a2);
+ void DEL_SAMPLE(int soundNumber);
+ void PLAY_SOUND(const Common::String &file);
+ void PLAY_SOUND2(const Common::String &file2);
+ void MODSetSampleVolume();
+ void MODSetVoiceVolume();
+ void MODSetMusicVolume(int volume);
+ void CHARGE_SAMPLE(int a1, const Common::String &file);
+ void PLAY_SAMPLE2(int idx);
+ void PLAY_WAV(int a1);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_SOUND_H */
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
new file mode 100644
index 0000000000..3dc883c871
--- /dev/null
+++ b/engines/hopkins/talk.cpp
@@ -0,0 +1,1349 @@
+/* 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 "common/endian.h"
+#include "common/file.h"
+#include "common/textconsole.h"
+#include "hopkins/talk.h"
+#include "hopkins/files.h"
+#include "hopkins/globals.h"
+#include "hopkins/graphics.h"
+#include "hopkins/hopkins.h"
+#include "hopkins/objects.h"
+
+namespace Hopkins {
+
+TalkManager::TalkManager() {
+ BUFFERPERSO = NULL;
+ PALPERSO = NULL;
+ PERSOSPR = NULL;
+ ADR_ANIM = NULL;
+ TAILLEPERSO = 0;
+ STATI = 0;
+ PLIGNE1 = PLIGNE2 = 0;
+ PLIGNE3 = PLIGNE4 = 0;
+ PCHERCHE = 0;
+}
+
+void TalkManager::setParent(HopkinsEngine *vm) {
+ _vm = vm;
+}
+
+void TalkManager::PARLER_PERSO(const Common::String &filename) {
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ byte *v8;
+ byte *v9;
+ byte *v10;
+ int v11;
+ int v14;
+ int v15;
+ Common::String v16;
+
+ v15 = 0;
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_eventsManager.VBL();
+ _vm->_graphicsManager.no_scroll = 1;
+ bool old_DESACTIVE_INVENT = _vm->_globals.DESACTIVE_INVENT;
+ _vm->_globals.DESACTIVE_INVENT = true;
+ BUFFERPERSO = _vm->_fileManager.RECHERCHE_CAT(filename, 5);
+ TAILLEPERSO = _vm->_globals.CAT_TAILLE;
+ if (BUFFERPERSO == g_PTRNUL) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename);
+ BUFFERPERSO = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ TAILLEPERSO = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER);
+ }
+ _vm->_globals.SAUVEGARDE->data[svField4] = 0;
+ RENVOIE_FICHIER(40, v16, (const char *)BUFFERPERSO);
+ RENVOIE_FICHIER(0, FQUEST, (const char *)BUFFERPERSO);
+ RENVOIE_FICHIER(20, FREPON, (const char *)BUFFERPERSO);
+ if (_vm->_globals.FR == 1) {
+ FREPON = FQUEST = "RUE.TXT";
+ } else if (!_vm->_globals.FR) {
+ FREPON = FQUEST = "RUEAN.TXT";
+ } else if (_vm->_globals.FR == 2) {
+ FREPON = FQUEST = "RUEES.TXT";
+ }
+ v2 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 40);
+ v3 = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110;
+ PCHERCHE = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110;
+ PERSOSPR = _vm->_fileManager.RECHERCHE_CAT(v16, 7);
+ if (PERSOSPR) {
+ _vm->_globals.CAT_FLAG = false;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, v16);
+ } else {
+ _vm->_globals.CAT_FLAG = true;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.RES");
+ }
+ PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_globals.CAT_FLAG = false;
+
+ _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
+ if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2))
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+
+ if (!_vm->_graphicsManager.nbrligne)
+ _vm->_graphicsManager.ofscroll = 0;
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_objectsManager.PERSO_ON = true;
+ CHERCHE_PAL(v3, 0);
+ CHERCHE_ANIM0(v3, 0);
+ ANIM_PERSO_INIT();
+ PLIGNE1 = v2;
+ PLIGNE2 = v2 + 1;
+ PLIGNE3 = v2 + 2;
+ PLIGNE4 = v2 + 3;
+ v14 = _vm->_eventsManager.btsouris;
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+ if (!_vm->_globals.NOPARLE) {
+ v4 = v2 + 3;
+ do {
+ v5 = DIALOGUE();
+ if (v5 != v4)
+ v15 = DIALOGUE_REP(v5);
+ if (v15 == -1)
+ v5 = v2 + 3;
+ _vm->_eventsManager.VBL();
+ } while (v5 != v4);
+ }
+ if (_vm->_globals.NOPARLE == true) {
+ v6 = 1;
+ do
+ v7 = DIALOGUE_REP(v6++);
+ while (v7 != -1);
+ }
+ CLEAR_ANIM_PERSO();
+ _vm->_globals.NOPARLE = false;
+ _vm->_globals.NECESSAIRE = 1;
+ BUFFERPERSO = _vm->_globals.LIBERE_FICHIER(BUFFERPERSO);
+ PERSOSPR = _vm->_globals.LIBERE_FICHIER(PERSOSPR);
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_globals.NECESSAIRE = 0;
+
+ _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ _vm->_objectsManager.PERSO_ON = false;
+ _vm->_eventsManager.btsouris = v14;
+
+ _vm->_eventsManager.CHANGE_MOUSE(v14);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.INIT_TABLE(145, 150, _vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.DD_LOCK();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ }
+ _vm->_graphicsManager.DD_UNLOCK();
+ v8 = _vm->_graphicsManager.VESA_BUFFER;
+ v9 = _vm->_graphicsManager.VESA_SCREEN;
+ memcpy(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.VESA_SCREEN, 0x95FFCu);
+ v9 = v9 + 614396;
+ v8 = v8 + 614396;
+ *v8 = *v9;
+ v8 = v8 + 2;
+ *v8 = *(v9 + 2);
+ v10 = v8 + 1;
+ _vm->_globals.DESACTIVE_INVENT = old_DESACTIVE_INVENT;
+ _vm->_graphicsManager.DD_VBL();
+ v11 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v11;
+ } while (v11 <= 4);
+ _vm->_graphicsManager.no_scroll = 0;
+}
+
+void TalkManager::PARLER_PERSO2(const Common::String &filename) {
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ byte v7;
+ int v8;
+ int v9;
+
+ v9 = 0;
+ _vm->_objectsManager.DESACTIVE_CURSOR = 1;
+ STATI = 1;
+ v7 = _vm->_dialogsManager.DESACTIVE_INVENT;
+ _vm->_dialogsManager.DESACTIVE_INVENT = 1;
+ BUFFERPERSO = _vm->_fileManager.RECHERCHE_CAT(filename, 5);
+ TAILLEPERSO = _vm->_globals.CAT_TAILLE;
+ if (BUFFERPERSO == g_PTRNUL) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename);
+ BUFFERPERSO = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ TAILLEPERSO = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER);
+ }
+
+ _vm->_globals.SAUVEGARDE->data[svField4] = 0;
+ RENVOIE_FICHIER(0, FQUEST, (const char *)BUFFERPERSO);
+ RENVOIE_FICHIER(20, FREPON, (const char *)BUFFERPERSO);
+
+ switch (_vm->_globals.FR) {
+ case 0:
+ FQUEST = "RUEAN.TXT";
+ FREPON = "RUEAN.TXT";
+ break;
+ case 1:
+ FQUEST = "RUE.TXT";
+ FREPON = "RUE.TXT";
+ break;
+ case 2:
+ FQUEST = "RUEES.TXT";
+ FREPON = "RUEES.TXT";
+ break;
+ }
+
+ v1 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 40);
+ PCHERCHE = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110;
+ CHERCHE_PAL(PCHERCHE, 0);
+ PLIGNE1 = v1;
+ PLIGNE2 = v1 + 1;
+ PLIGNE3 = v1 + 2;
+ PLIGNE4 = v1 + 3;
+ v8 = _vm->_eventsManager.btsouris;
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+
+ if (!_vm->_globals.NOPARLE) {
+ v2 = v1 + 3;
+ do {
+ v3 = DIALOGUE();
+ if (v3 != v2)
+ v9 = DIALOGUE_REP(v3);
+
+ if (v9 == -1)
+ v3 = v1 + 3;
+ } while (v3 != v2);
+ }
+
+ if (_vm->_globals.NOPARLE) {
+ v4 = 1;
+ do
+ v5 = DIALOGUE_REP(v4++);
+ while (v5 != -1);
+ }
+
+ BUFFERPERSO = _vm->_globals.LIBERE_FICHIER(BUFFERPERSO);
+ _vm->_eventsManager.btsouris = v8;
+
+ _vm->_eventsManager.CHANGE_MOUSE(v8);
+ _vm->_graphicsManager.INIT_TABLE(145, 150, _vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ _vm->_objectsManager.DESACTIVE_CURSOR = 0;
+ _vm->_dialogsManager.DESACTIVE_INVENT = v7;
+ STATI = 0;
+}
+
+void TalkManager::RENVOIE_FICHIER(int srcStart, Common::String &dest, const char *srcData) {
+ dest = Common::String(srcData + srcStart);
+}
+
+int TalkManager::DIALOGUE() {
+ byte *v0;
+ int v1;
+ int v2;
+ int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ byte *v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+
+ if (STATI) {
+ v0 = BUFFERPERSO;
+ v1 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 48);
+ if (v1)
+ _vm->_objectsManager.BOBANIM_ON(v1);
+ if ((int16)READ_LE_UINT16((uint16 *)v0 + 48) != 1)
+ _vm->_objectsManager.BOBANIM_ON((int16)READ_LE_UINT16((uint16 *)v0 + 49));
+ if ((int16)READ_LE_UINT16((uint16 *)v0 + 48) != 2)
+ _vm->_objectsManager.BOBANIM_ON((int16)READ_LE_UINT16((uint16 *)v0 + 50));
+ if ( (int16)READ_LE_UINT16((uint16 *)v0 + 48) != 3)
+ _vm->_objectsManager.BOBANIM_ON((int16)READ_LE_UINT16((uint16 *)v0 + 51));
+ if ((int16)READ_LE_UINT16((uint16 *)v0 + 48) != 4)
+ _vm->_objectsManager.BOBANIM_ON((int16)READ_LE_UINT16((uint16 *)v0 + 52));
+ } else {
+ VISU_WAIT();
+ }
+
+ v19 = VERIF_BOITE(PLIGNE1, FQUEST, 65);
+ v2 = VERIF_BOITE(PLIGNE2, FQUEST, 65);
+ v3 = VERIF_BOITE(PLIGNE3, FQUEST, 65);
+ v20 = 420 - 20 * VERIF_BOITE(PLIGNE4, FQUEST, 65);
+ v21 = v20 - 20 * v3;
+ v18 = v20 - 20 * v3 - 1;
+ v4 = v20 - 20 * v3 - 20 * v2;
+ _vm->_fontManager.DOS_TEXT(5, PLIGNE1, FQUEST, 5, v4 - 20 * v19, 0, 0, 0, 65, 255);
+ _vm->_fontManager.DOS_TEXT(6, PLIGNE2, FQUEST, 5, v4, 0, 0, 0, 65, 255);
+ _vm->_fontManager.DOS_TEXT(7, PLIGNE3, FQUEST, 5, v21, 0, 0, 0, 65, 255);
+ _vm->_fontManager.DOS_TEXT(8, PLIGNE4, FQUEST, 5, v20, 0, 0, 0, 65, 255);
+ _vm->_fontManager.TEXTE_ON(5);
+ _vm->_fontManager.TEXTE_ON(6);
+ _vm->_fontManager.TEXTE_ON(7);
+ _vm->_fontManager.TEXTE_ON(8);
+
+ v5 = -1;
+ v6 = 0;
+ do {
+ v7 = _vm->_eventsManager.YMOUSE();
+ if ((v4 - 20 * v19) < v7 && (v4 - 1) > v7) {
+ v8 = v7;
+ _vm->_fontManager.OPTI_COUL_TXT(6, 7, 8, 5);
+ v5 = PLIGNE1;
+ v7 = v8;
+ }
+ if (v7 > v4 && v18 > v7) {
+ v9 = v7;
+ _vm->_fontManager.OPTI_COUL_TXT(5, 7, 8, 6);
+ v5 = PLIGNE2;
+ v7 = v9;
+ }
+ if (v21 < v7 && (v20 - 1) > v7) {
+ v10 = v7;
+ _vm->_fontManager.OPTI_COUL_TXT(5, 6, 8, 7);
+ v5 = PLIGNE3;
+ v7 = v10;
+ }
+ if (v20 < v7 && v7 < 419) {
+ _vm->_fontManager.OPTI_COUL_TXT(5, 6, 7, 8);
+ v5 = PLIGNE4;
+ }
+
+ _vm->_eventsManager.VBL();
+ if (_vm->_eventsManager.BMOUSE())
+ v6 = 1;
+ if (v5 == -1)
+ v6 = 0;
+ } while (!_vm->shouldQuit() && v6 != 1);
+
+ _vm->_soundManager.VOICE_MIX(v5, 1);
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_fontManager.TEXTE_OFF(6);
+ _vm->_fontManager.TEXTE_OFF(7);
+ _vm->_fontManager.TEXTE_OFF(8);
+
+ if (STATI) {
+ v11 = BUFFERPERSO;
+ v12 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 48);
+ if (v12)
+ _vm->_objectsManager.BOBANIM_OFF(v12);
+ v13 = (int16)READ_LE_UINT16((uint16 *)v11 + 49);
+ if (v13 != 1)
+ _vm->_objectsManager.BOBANIM_OFF(v13);
+ v14 = (int16)READ_LE_UINT16((uint16 *)v11 + 50);
+ if (v14 != 2)
+ _vm->_objectsManager.BOBANIM_OFF(v14);
+ v15 = (int16)READ_LE_UINT16((uint16 *)v11 + 51);
+ if (v15 != 3)
+ _vm->_objectsManager.BOBANIM_OFF(v15);
+ v16 = (int16)READ_LE_UINT16((uint16 *)v11 + 52);
+ if (v16 != 4)
+ _vm->_objectsManager.BOBANIM_OFF(v16);
+ } else {
+ FIN_VISU_WAIT();
+ }
+
+ _vm->_eventsManager.VBL();
+ return v5;
+}
+
+int TalkManager::DIALOGUE_REP(int idx) {
+ int v1;
+ int v2;
+ byte *v3;
+ int i;
+ int v6;
+ int v7;
+ byte *v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+ int v13;
+ int v14;
+ void *v15;
+ int v16;
+ int v17;
+ int v18;
+ int v19;
+ int v20;
+ int v21;
+ int v22;
+ int v23;
+ int v24;
+ int v25;
+
+ v1 = 0;
+ v2 = 0;
+ v3 = BUFFERPERSO + 110;
+ for (i = idx; (int16)READ_LE_UINT16(v3) != idx; v3 = BUFFERPERSO + 20 * v1 + 110) {
+ ++v1;
+ if ((int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) < v1)
+ v2 = 1;
+ if (v2 == 1)
+ return -1;
+// HIWORD(i) = HIWORD(BUFFERPERSO);
+ }
+ if (v2 == 1)
+ return -1;
+
+ v22 = (int16)READ_LE_UINT16((uint16 *)v3 + 1);
+ v25 = (int16)READ_LE_UINT16((uint16 *)v3 + 2);
+ v24 = (int16)READ_LE_UINT16((uint16 *)v3 + 3);
+ i = (int16)READ_LE_UINT16((uint16 *)v3 + 4);
+ v23 = (int16)READ_LE_UINT16((uint16 *)v3 + 4);
+ PLIGNE1 = (int16)READ_LE_UINT16((uint16 *)v3 + 5);
+ PLIGNE2 = (int16)READ_LE_UINT16((uint16 *)v3 + 6);
+ PLIGNE3 = (int16)READ_LE_UINT16((uint16 *)v3 + 7);
+ v6 = (int16)READ_LE_UINT16((uint16 *)v3 + 8);
+ v7 = (int16)READ_LE_UINT16((uint16 *)v3 + 9);
+
+ if (v7)
+ _vm->_globals.SAUVEGARDE->data[svField4] = v7;
+
+ if (!v6)
+ v6 = 10;
+ if (STATI) {
+ v8 = BUFFERPERSO;
+ v9 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 43);
+ if (v9)
+ _vm->_objectsManager.BOBANIM_ON(v9);
+ v10 = (int16)READ_LE_UINT16((uint16 *)v8 + 44);
+ if (v10)
+ _vm->_objectsManager.BOBANIM_ON(v10);
+ v11 = (int16)READ_LE_UINT16((uint16 *)v8 + 45);
+ if (v11)
+ _vm->_objectsManager.BOBANIM_ON(v11);
+ v12 = (int16)READ_LE_UINT16((uint16 *)v8 + 46);
+ if (v12)
+ _vm->_objectsManager.BOBANIM_ON(v12);
+ v13 = (int16)READ_LE_UINT16((uint16 *)v8 + 47);
+ if (v13)
+ _vm->_objectsManager.BOBANIM_ON(v13);
+ } else {
+ VISU_PARLE();
+ }
+
+ if (!_vm->_soundManager.TEXTOFF) {
+ _vm->_fontManager.DOS_TEXT(9, v22, FREPON, v25, v24, 20, 25, 5, v23, 252);
+ _vm->_fontManager.TEXTE_ON(9);
+ }
+ if (!_vm->_soundManager.VOICE_MIX(v22, 1)) {
+ v14 = 0;
+ _vm->_eventsManager.souris_bb = false;
+ _vm->_eventsManager.souris_b = false;
+
+ do {
+ _vm->_eventsManager.VBL();
+ ++v14;
+ } while (v14 != v6);
+ }
+
+ if (!_vm->_soundManager.TEXTOFF)
+ _vm->_fontManager.TEXTE_OFF(9);
+ if (STATI) {
+ v15 = BUFFERPERSO;
+ v16 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 43);
+ if (v16)
+ _vm->_objectsManager.BOBANIM_OFF(v16);
+ v17 = (int16)READ_LE_UINT16((uint16 *)v15 + 44);
+ if (v17)
+ _vm->_objectsManager.BOBANIM_OFF(v17);
+ v18 = (int16)READ_LE_UINT16((uint16 *)v15 + 45);
+ if (v18)
+ _vm->_objectsManager.BOBANIM_OFF(v18);
+ v19 = (int16)READ_LE_UINT16((uint16 *)v15 + 46);
+ if (v19)
+ _vm->_objectsManager.BOBANIM_OFF(v19);
+ v20 = (int16)READ_LE_UINT16((uint16 *)v15 + 47);
+ if (v20)
+ _vm->_objectsManager.BOBANIM_OFF(v20);
+ } else {
+ FIN_VISU_PARLE();
+ }
+ v21 = 0;
+ if (!PLIGNE1)
+ v21 = -1;
+
+ return v21;
+}
+
+void TalkManager::CHERCHE_PAL(int a1, int a2) {
+ int v2;
+ size_t v4;
+ unsigned int v5;
+ byte *palette;
+ int v8;
+
+ v2 = 0;
+ v8 = 0;
+ v4 = a1;
+ for (;;) {
+ if ( *(BUFFERPERSO + v4) == 'P'
+ && *(BUFFERPERSO + v4 + 1) == 'A'
+ && *(BUFFERPERSO + v4 + 2) == 'L') {
+ v8 = 1;
+ v2 = v4;
+ }
+ ++v4;
+ if (v8 == 1)
+ break;
+ if (TAILLEPERSO == v4)
+ return;
+ }
+
+ v5 = v2 + 5;
+ palette = BUFFERPERSO + v5;
+ PALPERSO = BUFFERPERSO + v5;
+ if (a2 == 0) {
+ *(palette + 762) = 0;
+ *(palette + 763) = 0;
+ *(palette + 764) = 0;
+ *(palette + 765) = 0xe0;
+ *(palette + 766) = 0xe0;
+ *(palette + 767) = 0xff;
+ *(palette + 759) = 0xff;
+ *(palette + 760) = 0xff;
+ *(palette + 761) = 86;
+ *palette = 0;
+ *(palette + 1) = 0;
+ *(palette + 2) = 0;
+ }
+ if (a2 == 1) {
+ *(palette + 765) = 0xe0;
+ *(palette + 766) = 0xe0;
+ *(palette + 767) = 0xff;
+ *(palette + 759) = 0xff;
+ *(palette + 760) = 0xff;
+ *(palette + 761) = 0xff;
+ *palette = 0;
+ *(palette + 1) = 0;
+ *(palette + 2) = 0;
+ *(palette + 762) = 0;
+ *(palette + 763) = 0;
+ *(palette + 764) = 0;
+ }
+
+ _vm->_graphicsManager.setpal_vga256(palette);
+ _vm->_graphicsManager.INIT_TABLE(145, 150, palette);
+}
+
+void TalkManager::VISU_WAIT() {
+ for (int idx = 26; idx <= 30; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ BOB_VISU_PARLE(idx);
+ }
+}
+
+void TalkManager::FIN_VISU_WAIT() {
+ for (int idx = 26; idx <= 30; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_OFF(idx);
+ }
+
+ for (int idx = 26; idx <= 30; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_ZERO(idx);
+ }
+}
+
+void TalkManager::FIN_VISU_PARLE() {
+ for (int idx = 21; idx <= 25; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_OFF(idx);
+ }
+
+ _vm->_eventsManager.VBL();
+ _vm->_eventsManager.VBL();
+
+ for (int idx = 21; idx <= 25; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ _vm->_objectsManager.BOB_ZERO(idx);
+ }
+}
+
+int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) {
+ int v6;
+ int v7;
+ char v8;
+ int v9;
+ int v10;
+ char v11;
+ char v13;
+ char v14;
+ int v15;
+ byte *ptr;
+ int v17;
+ int v18;
+ byte *v19;
+ uint32 indexData[4047];
+ Common::String filename;
+ Common::String dest;
+ Common::File f;
+ int filesize;
+
+ v18 = 0;
+ _vm->_globals.police_l = 11;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file);
+
+ // Build up the filename
+ filename = dest = _vm->_globals.NFICHIER;
+ while (filename.lastChar() != '.')
+ filename.deleteLastChar();
+ filename += "IND";
+
+ if (!f.open(filename))
+ error("Could not open file - %s", filename.c_str());
+ filesize = f.size();
+ assert(filesize < 16188);
+
+ for (int i = 0; i < (filesize / 4); ++i)
+ indexData[i] = f.readUint32LE();
+ f.close();
+
+ if (!f.open(dest))
+ error("Error opening file - %s", dest.c_str());
+
+ f.seek(indexData[idx]);
+ ptr = _vm->_globals.dos_malloc2(2058);
+ if (ptr == g_PTRNUL)
+ error("temporary TEXT");
+ f.read(ptr, 2048);
+ f.close();
+
+ v19 = ptr;
+ v6 = 0;
+ do {
+ v13 = *v19;
+ if ((byte)(*v19 + 46) > 0x1Bu) {
+ if ((byte)(v13 + 80) > 0x1Bu) {
+ if ((byte)(v13 - 65) <= 0x19u || (byte)(v13 - 97) <= 0x19u)
+ v13 = 32;
+ } else {
+ v13 -= 79;
+ }
+ } else {
+ v13 = *v19 + 111;
+ }
+ *v19 = v13;
+ v19 = v19 + 1;
+ ++v6;
+ } while ((unsigned int)v6 < 0x800);
+
+ v7 = 0;
+ do {
+ v8 = *(ptr + v7);
+ if ( v8 == 10 || v8 == 13 )
+ *(ptr + v7) = 0;
+ ++v7;
+ } while ((unsigned int)v7 < 0x800);
+
+ v9 = 0;
+ v15 = (11 * a3) - 4;
+ do {
+ v10 = 0;
+ for (;;) {
+ v17 = v10;
+ do {
+ v11 = *(ptr + v9 + v10);
+ v14 = v11;
+ ++v10;
+ } while (v11 != 32 && v11 != 37);
+ if (v10 >= v15 / _vm->_globals.police_l)
+ break;
+ if (v11 == 37) {
+ if (v10 < v15 / _vm->_globals.police_l)
+ goto LABEL_31;
+ break;
+ }
+ }
+ if (v11 != 37)
+ goto LABEL_33;
+ v14 = 32;
+LABEL_31:
+ if (v14 == 37)
+ v17 = v10;
+LABEL_33:
+ ++v18;
+ v9 += v17;
+ } while (v14 != 37);
+ free(ptr);
+ return v18;
+}
+
+void TalkManager::VISU_PARLE() {
+ for (int idx = 21; idx <= 25; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].field4 == 1)
+ BOB_VISU_PARLE(idx);
+ }
+}
+
+void TalkManager::BOB_VISU_PARLE(int idx) {
+ int v4;
+ byte *v5;
+
+ _vm->_objectsManager.PRIORITY = 1;
+ if (!_vm->_globals.Bob[idx].field0) {
+ _vm->_objectsManager.BOB_ZERO(idx);
+ v5 = _vm->_globals.Bqe_Anim[idx].data;
+ v4 = (int16)READ_LE_UINT16(v5 + 2);
+ if (!v4)
+ v4 = 1;
+ if ((int16)READ_LE_UINT16(v5 + 24)) {
+ _vm->_globals.Bob[idx].isSprite = true;
+ _vm->_globals.Bob[idx].field36 = 0;
+ _vm->_globals.Bob[idx].field38 = 0;
+ _vm->_globals.Bob[idx].animData = _vm->_globals.Bqe_Anim[idx].data;
+ _vm->_globals.Bob[idx].field0 = 10;
+ v5 = PERSOSPR;
+ _vm->_globals.Bob[idx].spriteData = PERSOSPR;
+ _vm->_globals.Bob[idx].field1E = v4;
+ _vm->_globals.Bob[idx].field20 = -1;
+ _vm->_globals.Bob[idx].field22 = 0;
+ _vm->_globals.Bob[idx].offsetY = 0;
+ }
+ }
+}
+
+void TalkManager::CHERCHE_ANIM0(int a1, int a2) {
+ size_t v2;
+ int v3;
+ size_t v4;
+ unsigned int v5;
+ unsigned int v6;
+ int v7;
+ byte *v8;
+ byte *v9;
+
+ v2 = 0;
+ v3 = 0;
+ v4 = a1;
+ while (1) {
+ if (*(BUFFERPERSO + v4) == 'A'
+ && *(BUFFERPERSO + v4 + 1) == 'N'
+ && *(BUFFERPERSO + v4 + 2) == 'I'
+ && *(BUFFERPERSO + v4 + 3) == 'M'
+ && *(BUFFERPERSO + v4 + 4) == 1) {
+ v3 = 1;
+ v2 = v4;
+ }
+ ++v4;
+ if (v3 == 1)
+ break;
+ if (TAILLEPERSO == v4)
+ return;
+ }
+ v5 = v2 + 25;
+ v9 = BUFFERPERSO + v5;
+ v8 = BUFFERPERSO + v5;
+ ADR_ANIM = BUFFERPERSO + v5;
+ if (!a2) {
+ v6 = 0;
+ do {
+ v7 = (int16)READ_LE_UINT16(&v8[2 * v6 + 4]);
+ if (v7 && _vm->_globals.vitesse != 501)
+ _vm->_graphicsManager.AFFICHE_SPEED(PERSOSPR, _vm->_eventsManager.start_x + (int16)READ_LE_UINT16(&v8[2 * v6]),
+ (int16)READ_LE_UINT16(&v8[2 * v6 + 2]), v9[2 * v6 + 8]);
+ v6 += 5;
+ } while (_vm->_globals.vitesse != 501 && v7);
+ }
+}
+
+void TalkManager::ANIM_PERSO_INIT() {
+ byte *v0;
+ byte *v1;
+ int v2;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+ int v12;
+
+ v0 = BUFFERPERSO;
+ v1 = BUFFERPERSO + 110;
+ v2 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 43);
+ if (v2)
+ RECHERCHE_ANIM_PERSO(21, (BUFFERPERSO + 110), v2, TAILLEPERSO);
+ v4 = (int16)READ_LE_UINT16((uint16 *)v0 + 44);
+ if (v4)
+ RECHERCHE_ANIM_PERSO(22, v1, v4, TAILLEPERSO);
+ v5 = (int16)READ_LE_UINT16((uint16 *)v0 + 45);
+ if (v5)
+ RECHERCHE_ANIM_PERSO(23, v1, v5, TAILLEPERSO);
+ v6 = (int16)READ_LE_UINT16((uint16 *)v0 + 46);
+ if (v6)
+ RECHERCHE_ANIM_PERSO(24, v1, v6, TAILLEPERSO);
+ v7 = (int16)READ_LE_UINT16((uint16 *)v0 + 47);
+ if (v7)
+ RECHERCHE_ANIM_PERSO(25, v1, v7, TAILLEPERSO);
+ v8 = (int16)READ_LE_UINT16((uint16 *)v0 + 48);
+ if (v8)
+ RECHERCHE_ANIM_PERSO(26, v1, v8, TAILLEPERSO);
+ v9 = (int16)READ_LE_UINT16((uint16 *)v0 + 49);
+ if (v9)
+ RECHERCHE_ANIM_PERSO(27, v1, v9, TAILLEPERSO);
+ v10 = (int16)READ_LE_UINT16((uint16 *)v0 + 50);
+ if (v10)
+ RECHERCHE_ANIM_PERSO(28, v1, v10, TAILLEPERSO);
+ v11 = (int16)READ_LE_UINT16((uint16 *)v0 + 51);
+ if (v11)
+ RECHERCHE_ANIM_PERSO(29, v1, v11, TAILLEPERSO);
+ v12 = (int16)READ_LE_UINT16((uint16 *)v0 + 52);
+ if (v12)
+ RECHERCHE_ANIM_PERSO(30, v1, v12, TAILLEPERSO);
+}
+
+void TalkManager::CLEAR_ANIM_PERSO() {
+ for (int idx = 21; idx <= 34; ++idx) {
+ if (_vm->_globals.Bqe_Anim[idx].data != g_PTRNUL)
+ _vm->_globals.Bqe_Anim[idx].data = _vm->_globals.dos_free2(_vm->_globals.Bqe_Anim[idx].data);
+
+ _vm->_globals.Bqe_Anim[idx].data = g_PTRNUL;
+ _vm->_globals.Bqe_Anim[idx].field4 = 0;
+ }
+}
+
+bool TalkManager::RECHERCHE_ANIM_PERSO(int a1, const byte *bufPerso, int a3, int a4) {
+ bool result;
+ const byte *v5;
+ int v6;
+ int v7;
+ byte *v8;
+ byte *v9;
+ int v10;
+ int v11;
+ int v12;
+ char v13;
+ int v14;
+ int v15;
+ int v16;
+ char v17;
+ int v18;
+ int v19;
+ int v20;
+ int v22;
+ int v23;
+ const byte *v24;
+
+ v22 = 0;
+ result = false;
+
+ v20 = a1;
+ do {
+ if (*(v22 + bufPerso) == 'A' && *(bufPerso + v22 + 1) == 'N' && *(bufPerso + v22 + 2) == 'I' && *(bufPerso + v22 + 3) == 'M'
+ && *(bufPerso + v22 + 4) == a3) {
+ v5 = v22 + bufPerso + 5;
+ v18 = v22 + 5;
+ v6 = 0;
+ v7 = 0;
+ do {
+ if (*v5 == 'A' && *(v5 + 1) == 'N' && *(v5 + 2) == 'I' && *(v5 + 3) == 'M')
+ v7 = 1;
+ if (*v5 == 'F' && *(v5 + 1) == 'I' && *(v5 + 2) == 'N')
+ v7 = 1;
+ if (v18 > a4) {
+ _vm->_globals.Bqe_Anim[a1].field4 = 0;
+ result = g_PTRNUL;
+ _vm->_globals.Bqe_Anim[v20].data = g_PTRNUL;
+ }
+ ++v18;
+ ++v6;
+ ++v5;
+ } while (v7 != 1);
+ _vm->_globals.Bqe_Anim[v20].data = _vm->_globals.dos_malloc2(v6 + 50);
+ _vm->_globals.Bqe_Anim[a1].field4 = 1;
+ memcpy(_vm->_globals.Bqe_Anim[v20].data, (const byte *)(v22 + bufPerso + 5), 20);
+ v8 = _vm->_globals.Bqe_Anim[v20].data;
+
+ v9 = v8 + 20;
+ v24 = v22 + bufPerso + 25;
+ v10 = (int16)READ_LE_UINT16(v22 + bufPerso + 25);
+ v11 = (int16)READ_LE_UINT16(v22 + bufPerso + 27);
+ v23 = (int16)READ_LE_UINT16(v22 + bufPerso + 29);
+ v12 = (int16)READ_LE_UINT16(v22 + bufPerso + 31);
+ v13 = *(v22 + bufPerso + 33);
+ *(v8 + 29) = *(v22 + bufPerso + 34);
+ WRITE_LE_UINT16(v8 + 20, v10);
+ WRITE_LE_UINT16(v8 + 22, v11);
+ WRITE_LE_UINT16(v8 + 24, v23);
+ WRITE_LE_UINT16(v8 + 26, v12);
+ *(v8 + 28) = v13;
+ v19 = 1;
+ do {
+ v9 += 10;
+ v24 += 10;
+ if (!v23)
+ break;
+ v14 = (int16)READ_LE_UINT16(v24);
+ v15 = (int16)READ_LE_UINT16(v24 + 2);
+ v23 = (int16)READ_LE_UINT16(v24 + 4);
+ v16 = (int16)READ_LE_UINT16(v24 + 6);
+ v17 = *(v24 + 8);
+ *(v9 + 9) = *(v24 + 9);
+ WRITE_LE_UINT16(v9, v14);
+ WRITE_LE_UINT16(v9 + 2, v15);
+ WRITE_LE_UINT16(v9 + 4, v23);
+ WRITE_LE_UINT16(v9 + 6, v16);
+ *(v9 + 8) = v17;
+ ++v19;
+ } while (v19 <= 4999);
+ result = 1;
+ }
+ if (*(bufPerso + v22) == 'F' && *(bufPerso + v22 + 1) == 'I' && *(bufPerso + v22 + 2) == 'N')
+ result = true;
+ ++v22;
+ } while (v22 <= a4 && result != 1);
+
+ return result;
+}
+
+void TalkManager::REPONSE(int a1, int a2) {
+ byte v2;
+ byte v3;
+ byte *v5;
+ byte *v6;
+ uint16 v7;
+ byte *v8;
+ int v9;
+ int v10;
+ uint16 v11;
+ int v12;
+ int v13;
+ int v14;
+ int v15;
+ int v16;
+ int v17;
+ byte *ptr;
+
+ v2 = a1;
+ v3 = a2;
+LABEL_2:
+ v15 = 0;
+ if (_vm->_globals.COUCOU != g_PTRNUL) {
+ v5 = _vm->_globals.COUCOU;
+ while (1) {
+ if (*v5 == 'C') {
+ if (*(v5 + 1) == 'O') {
+ if (*(v5 + 2) == 'D') {
+ if (*(v5 + 3) == v2) {
+ if (*(v5 + 4) == v3)
+ v15 = 1;
+ }
+ }
+ }
+ }
+ if (*v5 == 'F' && *(v5 + 1) == 'I' && *(v5 + 2) == 'N')
+ break;
+ if (!v15)
+ v5 = v5 + 1;
+ if (v15 == 1) {
+ v6 = v5 + 5;
+ ptr = _vm->_globals.dos_malloc2(620);
+ if (g_PTRNUL == ptr)
+ error("TRADUC");
+ memset(ptr, 0, 620);
+ v7 = 0;
+ v12 = 0;
+ v14 = 0;
+ do {
+ v16 = 0;
+ if (*(v7 + v6) == 'F' && *(v6 + v7 + 1) == 'C') {
+ ++v12;
+ assert(v12 < (620 / 20));
+
+ v8 = (ptr + 20 * v12);
+ v11 = 0;
+ do {
+ assert(v11 < 20);
+ *(v11++ + v8) = *(v7++ + v6);
+ if (*(v7 + v6) == 'F' && *(v6 + v7 + 1) == 'F') {
+ v16 = 1;
+ v9 = v11;
+ *(v9 + v8) = 'F';
+ *(v8 + v9 + 1) = 'F';
+ ++v7;
+ }
+ } while (v16 != 1);
+ }
+ if (v16 != 1) {
+ if (*(v7 + v6) == 'C' && *(v6 + v7 + 1) == 'O' && *(v6 + v7 + 2) == 'D')
+ v14 = 1;
+ if (v16 != 1 && *(v7 + v6) == 'F' && *(v6 + v7 + 1) == 'I' && *(v6 + v7 + 2) == 'N')
+ v14 = 1;
+ }
+ v6 += v7 + 1;
+ v7 = 0;
+ } while (v14 != 1);
+ v17 = 0;
+ v13 = 1;
+ do {
+ v10 = _vm->_scriptManager.Traduction(ptr + 20 * v13);
+ if (_vm->shouldQuit())
+ return;
+
+ if (v10 == 2)
+ v13 = _vm->_scriptManager.Control_Goto(ptr + 20 * v13);
+ if (v10 == 3)
+ v13 = _vm->_scriptManager.Control_If(ptr, v13);
+ if (v13 == -1)
+ error("Invalid IFF function");
+ if (v10 == 1 || v10 == 4)
+ ++v13;
+ if (!v10 || v10 == 5)
+ v17 = 1;
+ if (v10 == 6) {
+ _vm->_globals.dos_free2(ptr);
+ v2 = _vm->_objectsManager.NVZONE;
+ v3 = _vm->_objectsManager.NVVERBE;
+ goto LABEL_2;
+ }
+ } while (v17 != 1);
+ _vm->_globals.dos_free2(ptr);
+ _vm->_globals.SAUVEGARDE->data[svField2] = 0;
+ return;
+ }
+ }
+ }
+}
+
+void TalkManager::REPONSE2(int a1, int a2) {
+ signed int v3;
+ int v4;
+ int v5;
+ int v6;
+ int v7;
+ int v8;
+ int v9;
+ int v10;
+ int v11;
+
+ v3 = 0;
+ if (a2 == 5 && _vm->_globals.SAUVEGARDE->data[svField3] == 4) {
+ if ((uint16)(a1 - 22) <= 1u) {
+ _vm->_objectsManager.SETFLIPSPR(0, 0);
+ _vm->_objectsManager.SETANISPR(0, 62);
+ _vm->_objectsManager.SPACTION(_vm->_globals.FORETSPR, "2,3,4,5,6,7,8,9,10,11,12,-1,", 0, 0, 4, 0);
+ if (a1 == 22) {
+ v4 = _vm->_objectsManager.BOBX(3);
+ _vm->_objectsManager.BLOQUE_ANIMX(6, v4);
+ }
+ if (a1 == 23) {
+ v5 = _vm->_objectsManager.BOBX(4);
+ _vm->_objectsManager.BLOQUE_ANIMX(6, v5);
+ }
+ if (a1 == 22) {
+ v6 = _vm->_objectsManager.BOBX(3);
+ _vm->_objectsManager.BLOQUE_ANIMX(8, v6);
+ }
+ if (a1 == 23) {
+ v7 = _vm->_objectsManager.BOBX(4);
+ _vm->_objectsManager.BLOQUE_ANIMX(8, v7);
+ }
+ _vm->_objectsManager.BOBANIM_OFF(3);
+ _vm->_objectsManager.BOBANIM_OFF(4);
+ _vm->_objectsManager.BOBANIM_ON(6);
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ _vm->_objectsManager.SPACTION1(_vm->_globals.FORETSPR, "13,14,15,14,13,12,13,14,15,16,-1,", 0, 0, 4);
+ do
+ _vm->_eventsManager.VBL();
+ while (_vm->_objectsManager.BOBPOSI(6) <= 12 && _vm->_objectsManager.BOBPOSI(6) != 12);
+ _vm->_objectsManager.BOBANIM_OFF(6);
+ _vm->_objectsManager.BOBANIM_ON(8);
+ if (_vm->_globals.ECRAN == 35)
+ v3 = 201;
+ if (_vm->_globals.ECRAN == 36)
+ v3 = 203;
+ if (_vm->_globals.ECRAN == 37)
+ v3 = 205;
+ if (_vm->_globals.ECRAN == 38)
+ v3 = 207;
+ if (_vm->_globals.ECRAN == 39)
+ v3 = 209;
+ if (_vm->_globals.ECRAN == 40)
+ v3 = 211;
+ if (_vm->_globals.ECRAN == 41)
+ v3 = 213;
+ _vm->_globals.SAUVEGARDE->data[v3] = 2;
+ _vm->_objectsManager.ZONE_OFF(22);
+ _vm->_objectsManager.ZONE_OFF(23);
+ }
+ if ((uint16)(a1 - 20) <= 1u) {
+ _vm->_objectsManager.SETFLIPSPR(0, 1);
+ _vm->_objectsManager.SETANISPR(0, 62);
+ _vm->_objectsManager.SPACTION(_vm->_globals.FORETSPR, "2,3,4,5,6,7,8,9,10,11,12,-1,", 0, 0, 4, 1);
+ if (a1 == 20) {
+ v8 = _vm->_objectsManager.BOBX(1);
+ _vm->_objectsManager.BLOQUE_ANIMX(5, v8);
+ }
+ if (a1 == 21) {
+ v9 = _vm->_objectsManager.BOBX(2);
+ _vm->_objectsManager.BLOQUE_ANIMX(5, v9);
+ }
+ if (a1 == 20) {
+ v10 = _vm->_objectsManager.BOBX(1);
+ _vm->_objectsManager.BLOQUE_ANIMX(7, v10);
+ }
+ if (a1 == 21) {
+ v11 = _vm->_objectsManager.BOBX(2);
+ _vm->_objectsManager.BLOQUE_ANIMX(7, v11);
+ }
+ _vm->_objectsManager.BOBANIM_OFF(1);
+ _vm->_objectsManager.BOBANIM_OFF(2);
+ _vm->_objectsManager.BOBANIM_ON(5);
+ _vm->_soundManager.PLAY_SAMPLE2(1);
+ _vm->_objectsManager.SPACTION1(_vm->_globals.FORETSPR, "13,14,15,14,13,12,13,14,15,16,-1,", 0, 0, 4);
+ do
+ _vm->_eventsManager.VBL();
+ while (_vm->_objectsManager.BOBPOSI(5) <= 12 && _vm->_objectsManager.BOBPOSI(5) != 12);
+ _vm->_objectsManager.BOBANIM_OFF(5);
+ _vm->_objectsManager.BOBANIM_ON(7);
+ if (_vm->_globals.ECRAN == 35)
+ v3 = 200;
+ if (_vm->_globals.ECRAN == 36)
+ v3 = 202;
+ if (_vm->_globals.ECRAN == 37)
+ v3 = 204;
+ if (_vm->_globals.ECRAN == 38)
+ v3 = 206;
+ if (_vm->_globals.ECRAN == 39)
+ v3 = 208;
+ if (_vm->_globals.ECRAN == 40)
+ v3 = 210;
+ if (_vm->_globals.ECRAN == 41)
+ v3 = 212;
+ _vm->_globals.SAUVEGARDE->data[v3] = 2;
+ _vm->_objectsManager.ZONE_OFF(21);
+ _vm->_objectsManager.ZONE_OFF(20);
+ }
+ }
+}
+
+void TalkManager::OBJET_VIVANT(const Common::String &a2) {
+ int v2;
+ const char *v4;
+ int v5;
+ bool v6;
+ int v10;
+ byte *v11;
+ int v12;
+ int v13;
+ byte *v14;
+ byte *v15;
+ byte *v16;
+ int v17;
+ Common::String s;
+ Common::String v20;
+ Common::String v22;
+ Common::String v23;
+
+ _vm->_fontManager.TEXTE_OFF(5);
+ _vm->_fontManager.TEXTE_OFF(9);
+ _vm->_eventsManager.VBL();
+ _vm->_graphicsManager.no_scroll = 1;
+ _vm->_linesManager.CLEAR_ZONE();
+ _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_globals.RESET_CACHE();
+ v2 = 0;
+ do
+ _vm->_globals.BOBZONE[v2++] = 0;
+ while (v2 <= 44);
+ _vm->_objectsManager.NUMZONE = -1;
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(0);
+ BUFFERPERSO = _vm->_fileManager.RECHERCHE_CAT(a2, 5);
+ TAILLEPERSO = _vm->_globals.CAT_TAILLE;
+ if (BUFFERPERSO == g_PTRNUL) {
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, a2);
+ BUFFERPERSO = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER);
+ TAILLEPERSO = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER);
+ }
+ RENVOIE_FICHIER(40, v23, (const char *)BUFFERPERSO);
+ RENVOIE_FICHIER(0, v22, (const char *)BUFFERPERSO);
+ RENVOIE_FICHIER(20, v20, (const char *)BUFFERPERSO);
+ v4 = "NULL";
+ v5 = 5;
+
+ v6 = v20 != v4;
+ if (!v6) {
+ v20 = Common::String::format("IM%d", _vm->_globals.ECRAN);
+ }
+ PERSOSPR = _vm->_fileManager.RECHERCHE_CAT(v23, 7);
+ if (PERSOSPR) {
+ _vm->_globals.CAT_FLAG = false;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, v23);
+ } else {
+ _vm->_globals.CAT_FLAG = true;
+ _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.RES");
+ }
+ PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER);
+ _vm->_globals.CAT_FLAG = false;
+
+ _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR");
+ if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH)
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u);
+ if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2))
+ _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u);
+
+ if (!_vm->_graphicsManager.nbrligne)
+ _vm->_graphicsManager.ofscroll = 0;
+ _vm->_graphicsManager.NB_SCREEN();
+ v10 = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110;
+ PCHERCHE = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110;
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_objectsManager.PERSO_ON = true;
+ CHERCHE_PAL(v10, 1);
+ CHERCHE_ANIM0(v10, 0);
+ v11 = _vm->_globals.COUCOU;
+ _vm->_globals.COUCOU = g_PTRNUL;
+ _vm->_globals.NOMARCHE = true;
+ _vm->_objectsManager.INILINK(v22);
+ _vm->_objectsManager.PERSO_ON = true;
+ _vm->_globals.GOACTION = 0;
+ _vm->_objectsManager.NUMZONE = -1;
+ ANIM_PERSO_INIT();
+ VISU_PARLE();
+ VISU_WAIT();
+ _vm->_graphicsManager.INI_ECRAN2(v22);
+ _vm->_globals.NOMARCHE = true;
+ _vm->_objectsManager.FORCEZONE = 1;
+ _vm->_objectsManager.NUMZONE = -1;
+ do {
+ v12 = _vm->_eventsManager.BMOUSE();
+ if (v12 == 1) {
+ _vm->_objectsManager.BTGAUCHE();
+ v12 = 1;
+ }
+ if (v12 == 2)
+ _vm->_objectsManager.BTDROITE();
+ _vm->_objectsManager.VERIFZONE();
+ if (_vm->_globals.GOACTION == 1)
+ _vm->_objectsManager.PARADISE();
+ _vm->_eventsManager.VBL();
+ } while (!_vm->_globals.SORTIE);
+ FIN_VISU_PARLE();
+ FIN_VISU_WAIT();
+ CLEAR_ANIM_PERSO();
+ CLEAR_ANIM_PERSO();
+ _vm->_globals.NOPARLE = false;
+ _vm->_globals.NECESSAIRE = 1;
+ BUFFERPERSO = _vm->_globals.LIBERE_FICHIER(BUFFERPERSO);
+ PERSOSPR = _vm->_globals.LIBERE_FICHIER(PERSOSPR);
+ _vm->_graphicsManager.NB_SCREEN();
+ _vm->_globals.NECESSAIRE = 0;
+ _vm->_linesManager.CLEAR_ZONE();
+ _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_globals.RESET_CACHE();
+ v13 = 0;
+ do
+ _vm->_globals.BOBZONE[v13++] = 0;
+ while (v13 <= 44);
+ _vm->_globals.LIBERE_FICHIER(_vm->_globals.COUCOU);
+ _vm->_globals.COUCOU = v11;
+ _vm->_objectsManager.DESACTIVE = true;
+ _vm->_objectsManager.INILINK(v20);
+ _vm->_graphicsManager.INI_ECRAN2(v20);
+ _vm->_objectsManager.DESACTIVE = false;
+ _vm->_globals.NOMARCHE = false;
+ if (_vm->_globals.SORTIE == 101)
+ _vm->_globals.SORTIE = 0;
+
+ _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager.VESA_SCREEN);
+ g_system->getSavefileManager()->removeSavefile("TEMP.SCR");
+
+ _vm->_objectsManager.PERSO_ON = false;
+ _vm->_eventsManager.btsouris = 4;
+ _vm->_eventsManager.CHANGE_MOUSE(4);
+ _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100);
+ _vm->_graphicsManager.INIT_TABLE(145, 150, _vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ _vm->_graphicsManager.DD_Lock();
+ if (_vm->_graphicsManager.Winbpp == 2) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ }
+ if (_vm->_graphicsManager.Winbpp == 1) {
+ if (_vm->_graphicsManager.SDL_ECHELLE)
+ _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ else
+ _vm->_graphicsManager.m_scroll2(_vm->_graphicsManager.VESA_SCREEN, _vm->_eventsManager.start_x, 0, 640, 480, 0, 0);
+ }
+ _vm->_graphicsManager.DD_Unlock();
+ _vm->_graphicsManager.setpal_vga256(_vm->_graphicsManager.Palette);
+ v14 = _vm->_graphicsManager.VESA_BUFFER;
+ v15 = _vm->_graphicsManager.VESA_SCREEN;
+ memcpy(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.VESA_SCREEN, 0x95FFCu);
+ v15 = v15 + 614396;
+ v14 = v14 + 614396;
+ WRITE_LE_UINT16(v14, (int16)READ_LE_UINT16(v15));
+ v14 = v14 + 2;
+ *v14 = *(v15 + 2);
+ v16 = v14 + 1;
+ _vm->_globals.DESACTIVE_INVENT = false;
+ _vm->_graphicsManager.DD_VBL();
+ v17 = 0;
+ do {
+ _vm->_eventsManager.VBL();
+ ++v17;
+ } while (v17 <= 4);
+ _vm->_graphicsManager.no_scroll = 0;
+}
+
+} // End of namespace Hopkins
diff --git a/engines/hopkins/talk.h b/engines/hopkins/talk.h
new file mode 100644
index 0000000000..3c13bf81d4
--- /dev/null
+++ b/engines/hopkins/talk.h
@@ -0,0 +1,75 @@
+/* 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_TALK_H
+#define HOPKINS_TALK_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Hopkins {
+
+class HopkinsEngine;
+
+class TalkManager {
+private:
+ HopkinsEngine *_vm;
+public:
+ Common::String FQUEST;
+ Common::String FREPON;
+ byte *BUFFERPERSO;
+ byte *PALPERSO;
+ byte *PERSOSPR;
+ byte *ADR_ANIM;
+ size_t TAILLEPERSO;
+ int STATI;
+ int PLIGNE1, PLIGNE2;
+ int PLIGNE3, PLIGNE4;
+ int PCHERCHE;
+public:
+ TalkManager();
+ void setParent(HopkinsEngine *vm);
+
+ void PARLER_PERSO2(const Common::String &filename);
+ void PARLER_PERSO(const Common::String &filename);
+ void RENVOIE_FICHIER(int srcStart, Common::String &dest, const char *srcData);
+ int DIALOGUE();
+ int DIALOGUE_REP(int idx);
+ void CHERCHE_PAL(int a1, int a2);
+ void VISU_WAIT();
+ void FIN_VISU_WAIT();
+ void FIN_VISU_PARLE();
+ int VERIF_BOITE(int a1, const Common::String &a2, int a3);
+ void VISU_PARLE();
+ void BOB_VISU_PARLE(int idx);
+ void CHERCHE_ANIM0(int a1, int a2);
+ void ANIM_PERSO_INIT();
+ void CLEAR_ANIM_PERSO();
+ bool RECHERCHE_ANIM_PERSO(int a1, const byte *a2, int a3, int a4);
+ void REPONSE(int a1, int a2);
+ void REPONSE2(int a1, int a2);
+ void OBJET_VIVANT(const Common::String &a2);
+};
+
+} // End of namespace Hopkins
+
+#endif /* HOPKINS_TALK_H */