diff options
author | Paul Gilbert | 2012-09-17 18:03:25 +1000 |
---|---|---|
committer | Paul Gilbert | 2012-09-17 18:03:25 +1000 |
commit | df410953c98ff5ca4a3ef9626d0ae680186378ac (patch) | |
tree | 1f4b48b039338f1f3f6b4a6be6c2e8bb46718d90 /engines/hopkins | |
parent | 0b610c45dff6b715f1f5e3e5161619dc57d19061 (diff) | |
download | scummvm-rg350-df410953c98ff5ca4a3ef9626d0ae680186378ac.tar.gz scummvm-rg350-df410953c98ff5ca4a3ef9626d0ae680186378ac.tar.bz2 scummvm-rg350-df410953c98ff5ca4a3ef9626d0ae680186378ac.zip |
HOPKINS: Initial implementation of main menu method
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/globals.cpp | 5 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 1 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 134 | ||||
-rw-r--r-- | engines/hopkins/graphics.h | 15 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 11 | ||||
-rw-r--r-- | engines/hopkins/hopkins.h | 19 | ||||
-rw-r--r-- | engines/hopkins/menu.cpp | 235 | ||||
-rw-r--r-- | engines/hopkins/menu.h | 49 | ||||
-rw-r--r-- | engines/hopkins/module.mk | 2 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 166 | ||||
-rw-r--r-- | engines/hopkins/objects.h | 49 |
11 files changed, 521 insertions, 165 deletions
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index cc96588f9a..aecad64dde 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -704,4 +704,9 @@ byte *Globals::dos_free2(byte *p) { return PTRNUL; } +byte *Globals::LIBERE_FICHIER(byte *p) { + dos_free2(p); + return PTRNUL; +} + } // End of namespace Hopkins diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index e73df7e159..47ea2b09ef 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -248,6 +248,7 @@ public: void CHARGE_OBJET(); byte *dos_malloc2(int count); byte *dos_free2(byte *p); + byte *LIBERE_FICHIER(byte *p); }; #define PTRNUL (byte *)NULL diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f183adee41..72fbd0319b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -969,138 +969,4 @@ void GraphicsManager::RESET_SEGMENT_VESA() { warning("TODO: RESET_SEGMENT_VESA"); } -/*------------------------------------------------------------------------*/ - -byte *ObjectManager::CHANGE_OBJET(int objIndex) { - byte *result = ObjectManager::CAPTURE_OBJET(objIndex, 1); - GLOBALS.Bufferobjet = result; - GLOBALS.Nouv_objet = 1; - GLOBALS.OBJET_EN_COURS = objIndex; - return result; -} - -byte *ObjectManager::CAPTURE_OBJET(int objIndex, int mode) { - byte *result = NULL; - byte *dataP; - - dataP = 0; - int val1 = GLOBALS.ObjetW[objIndex].field0; - int val2 = GLOBALS.ObjetW[objIndex].field1; - - if (mode == 1) - ++val2; - if (val1 != GLOBALS.NUM_FICHIER_OBJ) { - if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) - ObjectManager::DEL_FICHIER_OBJ(); - if (val1 == 1) { - FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR"); - GLOBALS.ADR_FICHIER_OBJ = ObjectManager::CHARGE_SPRITE(GLOBALS.NFICHIER); - } - GLOBALS.NUM_FICHIER_OBJ = val1; - } - - int width = ObjectManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, val2); - int height = ObjectManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, val2); - GLOBALS.OBJL = width; - GLOBALS.OBJH = height; - - switch (mode) { - case 0: - dataP = GLOBALS.dos_malloc2(height * width); - if (dataP == PTRNUL) - error("CAPTURE_OBJET"); - - ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, val2); - break; - - case 1: - ObjectManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, val2); - result = GLOBALS.Bufferobjet; - break; - - case 3: - ObjectManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, val2); - result = GLOBALS.INVENTAIRE_OBJET; - break; - - default: - result = dataP; - break; - } - - return result; -} - -int ObjectManager::Get_Largeur(const byte *objectData, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) - objP += READ_LE_UINT32(objP) + 16; - - return READ_LE_UINT16(objP + 4); -} - -int ObjectManager::Get_Hauteur(const byte *objectData, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) - objP += READ_LE_UINT32(objP) + 16; - - return READ_LE_UINT16(objP + 6); -} - -int ObjectManager::sprite_alone(const byte *objectData, byte *sprite, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) { - objP += READ_LE_UINT32(objP) + 16; - } - - objP += 4; - int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); - - memcpy(sprite + 3, objP - 4, result + 16); - return result; -} - -byte *ObjectManager::DEL_FICHIER_OBJ() { - GLOBALS.NUM_FICHIER_OBJ = 0; - if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) - GLOBALS.ADR_FICHIER_OBJ = FileManager::LIBERE_FICHIER(GLOBALS.ADR_FICHIER_OBJ); - - byte *result = PTRNUL; - GLOBALS.ADR_FICHIER_OBJ = PTRNUL; - return result; -} - -byte *ObjectManager::CHARGE_SPRITE(const Common::String &file) { - FileManager::DMESS1(); - return FileManager::CHARGE_FICHIER(file); -} - -int ObjectManager::capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex) { - const byte *objP = objectData + 3; - for (int i = objIndex; i; --i) { - objP += READ_LE_UINT32(objP) + 16; - } - - objP += 4; - int result = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); - - memcpy(sprite, objP + 12, result); - return result; -} - -int ObjectManager::AJOUTE_OBJET(int objIndex) { - bool flag = false; - int arrIndex = 0; - do { - ++arrIndex; - if (!GLOBALS.INVENTAIRE[arrIndex]) - flag = true; - if (arrIndex == 32) - flag = true; - } while (!flag); - - GLOBALS.INVENTAIRE[arrIndex] = objIndex; - return arrIndex; -} - } // End of namespace Hopkins diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h index 93b6ebcebd..be1bc751cd 100644 --- a/engines/hopkins/graphics.h +++ b/engines/hopkins/graphics.h @@ -122,21 +122,6 @@ public: void RESET_SEGMENT_VESA(); }; -class ObjectManager { -public: - static byte *CHANGE_OBJET(int objIndex); - static byte *CAPTURE_OBJET(int objIndex, int mode); - - static int Get_Largeur(const byte *objectData, int objIndex); - static int Get_Hauteur(const byte *objectData, int objIndex); - static int sprite_alone(const byte *objectData, byte *sprite, int objIndex); - static byte *DEL_FICHIER_OBJ(); - - static byte *CHARGE_SPRITE(const Common::String &file); - static int capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex); - static int AJOUTE_OBJET(int objIndex); -}; - } // End of namespace Hopkins #endif /* HOPKINS_GRAPHICS_H */ diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index ebfe694d28..460ae1355e 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -58,8 +58,8 @@ Common::Error HopkinsEngine::run() { _soundManager.WSOUND_INIT(); GLOBALS.CHARGE_OBJET(); - ObjectManager::CHANGE_OBJET(14); - ObjectManager::AJOUTE_OBJET(14); + _objectsManager.CHANGE_OBJET(14); + _objectsManager.AJOUTE_OBJET(14); GLOBALS.HELICO = 0; _eventsManager.MOUSE_OFF(); @@ -102,7 +102,7 @@ LABEL_13: GLOBALS.SORTIE = 0; if (!GLOBALS.SORTIE) { - GLOBALS.SORTIE = MENU(); + GLOBALS.SORTIE = _menuManager.MENU(); if (GLOBALS.SORTIE == -1) { PUBQUIT(); _globals.PERSO = _globals.dos_free2(_globals.PERSO); @@ -887,11 +887,6 @@ void HopkinsEngine::COMPUT_HOPKINS(int a1) { warning("TODO: COMPUT_HOPKINS"); } -int HopkinsEngine::MENU() { - warning("TODO: MENU"); - return 0; -} - void HopkinsEngine::ENDEMO() { warning("TODO: ENDEMO"); } diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h index 9dcd17c4f9..da62e43b0d 100644 --- a/engines/hopkins/hopkins.h +++ b/engines/hopkins/hopkins.h @@ -35,6 +35,8 @@ #include "hopkins/events.h" #include "hopkins/globals.h" #include "hopkins/graphics.h" +#include "hopkins/menu.h" +#include "hopkins/objects.h" #include "hopkins/sound.h" /** @@ -76,11 +78,6 @@ private: void INIT_SYSTEM(); - /** - * Run the introduction sequence - */ - void INTRORUN(); - void PASS(); void REST_SYSTEM(); void PLAN_BETA(); @@ -90,7 +87,6 @@ private: const Common::String &s4, int v); void PUBQUIT(); void COMPUT_HOPKINS(int a1); - int MENU(); void ENDEMO(); void BOOM(); protected: @@ -99,10 +95,12 @@ protected: virtual bool hasFeature(EngineFeature f) const; public: - Globals _globals; + AnimationManager _animationManager; EventsManager _eventsManager; + Globals _globals; GraphicsManager _graphicsManager; - AnimationManager _animationManager; + MenuManager _menuManager; + ObjectsManager _objectsManager; SoundManager _soundManager; public: HopkinsEngine(OSystem *syst, const HopkinsGameDescription *gameDesc); @@ -115,6 +113,11 @@ public: bool getIsDemo() const; int getRandomNumber(int maxNumber); + + /** + * Run the introduction sequence + */ + void INTRORUN(); }; // Global reference to the HopkinsEngine object diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp new file mode 100644 index 0000000000..5aa54b9fa6 --- /dev/null +++ b/engines/hopkins/menu.cpp @@ -0,0 +1,235 @@ +/* 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 _globals.FRee software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the _globals.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 _globals.FRee Software + * Foundation, Inc., 51 _globals.FRanklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "hopkins/menu.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; +} + +int MenuManager::MENU() { + signed int v0; + byte *v1; + signed int v2; + int v3; + int v4; + signed int v6; + signed __int16 v7; + signed __int16 v8; + signed __int16 v9; + signed __int16 v10; + __int16 v11; + signed int v12; + + v6 = 0; + for (;;) { + _vm->_globals.FORET = 0; + _vm->_eventsManager.CASSE = 0; + _vm->_globals.DESACTIVE_INVENT = 1; + _vm->_globals.FLAG_VISIBLE = 0; + _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); + v7 = 0; + v8 = 0; + v9 = 0; + v10 = 0; + v11 = 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) + FileManager::CONSTRUIT_SYSTEM("MENUAN.SPR"); + if (_vm->_globals.FR == 1) + FileManager::CONSTRUIT_SYSTEM("MENUFR.SPR"); + if (_vm->_globals.FR == 2) + FileManager::CONSTRUIT_SYSTEM("MENUES.SPR"); + + v1 = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER); + _vm->_eventsManager.MOUSE_ON(); + _vm->_eventsManager.CHANGE_MOUSE(0); + _vm->_globals.btsouris = 0; + _vm->_eventsManager.souris_n = 0; + + for (;;) { + for (;;) { + _vm->_soundManager.WSOUND(28); + v12 = 0; + + do { + v2 = 0; + v3 = _vm->_eventsManager.XMOUSE(); + v4 = _vm->_eventsManager.YMOUSE(); + + if ((unsigned int)(v3 - 232) <= 0xB0) { + if ((unsigned int)(v4 - 261) <= 23) + v2 = 1; + if ((unsigned int)(v4 - 293) <= 23) + v2 = 2; + if ((unsigned int)(v4 - 325) <= 22) + v2 = 3; + if ((unsigned int)(v4 - 356) <= 23) + v2 = 4; + + if ((unsigned int)(v4 - 388) <= 23) + v2 = 5; + } + + switch (v2) { + case 0: + v11 = 0; + v10 = 0; + v9 = 0; + v8 = 0; + v7 = 0; + break; + case 1: + v11 = 1; + v10 = 0; + v9 = 0; + v8 = 0; + v7 = 0; + break; + case 2: + v11 = 0; + v10 = 1; + v9 = 0; + v8 = 0; + v7 = 0; + break; + case 3: + v11 = 0; + v10 = 0; + v9 = 1; + v8 = 0; + v7 = 0; + break; + case 4: + v11 = 0; + v10 = 0; + v9 = 0; + v8 = 1; + v7 = 0; + break; + case 5: + v11 = 0; + v10 = 0; + v9 = 0; + v8 = 0; + v7 = 1; + default: + break; + } + + AFFICHE_SPEED(v1, 230, 259, v11); + AFFICHE_SPEED(v1, 230, 291, v10 + 2); + AFFICHE_SPEED(v1, 230, 322, v9 + 4); + AFFICHE_SPEED(v1, 230, 354, v8 + 6); + AFFICHE_SPEED(v1, 230, 386, v7 + 8); + _vm->_eventsManager.VBL(); + + if (_vm->_eventsManager.BMOUSE() == 1 && v2 > 0) + v12 = 1; + } while (v12 != 1); + + if (v2 == 1) { + AFFICHE_SPEED(v1, 230, 259, 10); + _vm->_eventsManager.VBL(); + _vm->_eventsManager.delay(200); + v6 = 1; + } + if (v2 != 2) + break; + + AFFICHE_SPEED(v1, 230, 291, 11); + _vm->_eventsManager.VBL(); + _vm->_eventsManager.delay(200); + + _vm->_globals.SORTIE = -1; + CHARGE_PARTIE(); + + if (_vm->_globals.SORTIE != -1) { + v6 = _vm->_globals.SORTIE; + break; + } + _vm->_globals.SORTIE = 0; + } + + if (v2 != 3) + break; + + AFFICHE_SPEED(v1, 230, 322, 12); + _vm->_eventsManager.VBL(); + _vm->_eventsManager.delay(200); + + CHOICE_OPTION(); + } + if (v2 == 4) { + AFFICHE_SPEED(v1, 230, 354, 13); + _vm->_eventsManager.VBL(); + _vm->_eventsManager.delay(200); + _vm->INTRORUN(); + continue; + } + break; + } + + _vm->_globals.LIBERE_FICHIER(v1); + _vm->_globals.DESACTIVE_INVENT = 0; + _vm->_globals.FLAG_VISIBLE = 0; + _vm->_graphicsManager.FADE_OUTW(); + return v6; +} + +void MenuManager::AFFICHE_SPEED(byte *a1, int a2, int a3, int a4) { + warning("AFFICHE_SPEED"); +} + +void MenuManager::CHOICE_OPTION() { + warning("CHOICE_OPTION"); +} + +void MenuManager::CHARGE_PARTIE() { + warning("CHARGE_PARTIE"); +} + +} // End of namespace Hopkins diff --git a/engines/hopkins/menu.h b/engines/hopkins/menu.h new file mode 100644 index 0000000000..a120157ebe --- /dev/null +++ b/engines/hopkins/menu.h @@ -0,0 +1,49 @@ +/* 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; + + void CHOICE_OPTION(); +public: + void setParent(HopkinsEngine *vm); + + int MENU(); + void AFFICHE_SPEED(byte *a1, int a2, int a3, int a4); + void CHARGE_PARTIE(); +}; + +} // End of namespace Hopkins + +#endif /* HOPKINS_MENU_H */ diff --git a/engines/hopkins/module.mk b/engines/hopkins/module.mk index b0b00f9aba..6768c6add2 100644 --- a/engines/hopkins/module.mk +++ b/engines/hopkins/module.mk @@ -8,6 +8,8 @@ MODULE_OBJS := \ graphics.o \ globals.o \ hopkins.o \ + menu.o \ + objects.o \ sound.o # This module can be built as a plugin diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp new file mode 100644 index 0000000000..441dc874b3 --- /dev/null +++ b/engines/hopkins/objects.cpp @@ -0,0 +1,166 @@ +/* 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/hopkins.h" + +namespace Hopkins { + +byte *ObjectsManager::CHANGE_OBJET(int objIndex) { + byte *result = ObjectsManager::CAPTURE_OBJET(objIndex, 1); + GLOBALS.Bufferobjet = result; + GLOBALS.Nouv_objet = 1; + GLOBALS.OBJET_EN_COURS = objIndex; + return result; +} + +byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { + byte *result = NULL; + byte *dataP; + + dataP = 0; + int val1 = GLOBALS.ObjetW[objIndex].field0; + int val2 = GLOBALS.ObjetW[objIndex].field1; + + if (mode == 1) + ++val2; + if (val1 != GLOBALS.NUM_FICHIER_OBJ) { + if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) + ObjectsManager::DEL_FICHIER_OBJ(); + if (val1 == 1) { + FileManager::CONSTRUIT_SYSTEM("OBJET1.SPR"); + GLOBALS.ADR_FICHIER_OBJ = ObjectsManager::CHARGE_SPRITE(GLOBALS.NFICHIER); + } + GLOBALS.NUM_FICHIER_OBJ = val1; + } + + int width = ObjectsManager::Get_Largeur(GLOBALS.ADR_FICHIER_OBJ, val2); + int height = ObjectsManager::Get_Hauteur(GLOBALS.ADR_FICHIER_OBJ, val2); + GLOBALS.OBJL = width; + GLOBALS.OBJH = height; + + switch (mode) { + case 0: + dataP = GLOBALS.dos_malloc2(height * width); + if (dataP == PTRNUL) + error("CAPTURE_OBJET"); + + ObjectsManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, dataP, val2); + break; + + case 1: + ObjectsManager::sprite_alone(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.Bufferobjet, val2); + result = GLOBALS.Bufferobjet; + break; + + case 3: + ObjectsManager::capture_mem_sprite(GLOBALS.ADR_FICHIER_OBJ, GLOBALS.INVENTAIRE_OBJET, val2); + result = GLOBALS.INVENTAIRE_OBJET; + break; + + default: + result = dataP; + break; + } + + return result; +} + +int ObjectsManager::Get_Largeur(const byte *objectData, int objIndex) { + const byte *objP = objectData + 3; + for (int i = objIndex; i; --i) + objP += READ_LE_UINT32(objP) + 16; + + return READ_LE_UINT16(objP + 4); +} + +int ObjectsManager::Get_Hauteur(const byte *objectData, int objIndex) { + const byte *objP = objectData + 3; + for (int i = objIndex; i; --i) + objP += READ_LE_UINT32(objP) + 16; + + return READ_LE_UINT16(objP + 6); +} + +int 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 = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); + + memcpy(sprite + 3, objP - 4, result + 16); + return result; +} + +byte *ObjectsManager::DEL_FICHIER_OBJ() { + GLOBALS.NUM_FICHIER_OBJ = 0; + if (GLOBALS.ADR_FICHIER_OBJ != PTRNUL) + GLOBALS.ADR_FICHIER_OBJ = FileManager::LIBERE_FICHIER(GLOBALS.ADR_FICHIER_OBJ); + + byte *result = PTRNUL; + GLOBALS.ADR_FICHIER_OBJ = PTRNUL; + return result; +} + +byte *ObjectsManager::CHARGE_SPRITE(const Common::String &file) { + FileManager::DMESS1(); + return 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 = READ_LE_UINT16(objP) * READ_LE_UINT16(objP + 2); + + memcpy(sprite, objP + 12, result); + return result; +} + +int ObjectsManager::AJOUTE_OBJET(int objIndex) { + bool flag = false; + int arrIndex = 0; + do { + ++arrIndex; + if (!GLOBALS.INVENTAIRE[arrIndex]) + flag = true; + if (arrIndex == 32) + flag = true; + } while (!flag); + + GLOBALS.INVENTAIRE[arrIndex] = objIndex; + return arrIndex; +} + +} // End of namespace Hopkins diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h new file mode 100644 index 0000000000..8f97a5a7bc --- /dev/null +++ b/engines/hopkins/objects.h @@ -0,0 +1,49 @@ +/* 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" + +namespace Hopkins { + +class ObjectsManager { +public: + byte *CHANGE_OBJET(int objIndex); + byte *CAPTURE_OBJET(int objIndex, int mode); + + int Get_Largeur(const byte *objectData, int objIndex); + int Get_Hauteur(const byte *objectData, int objIndex); + int sprite_alone(const byte *objectData, byte *sprite, int objIndex); + byte *DEL_FICHIER_OBJ(); + + byte *CHARGE_SPRITE(const Common::String &file); + int capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex); + int AJOUTE_OBJET(int objIndex); +}; + +} // End of namespace Hopkins + +#endif /* HOPKINS_OBJECTS_H */ |