diff options
-rw-r--r-- | engines/hopkins/events.cpp | 24 | ||||
-rw-r--r-- | engines/hopkins/events.h | 3 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 1 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 1 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 81 | ||||
-rw-r--r-- | engines/hopkins/objects.h | 3 |
6 files changed, 65 insertions, 48 deletions
diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index 8a1ebdfd7c..9bcdeda735 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -21,7 +21,6 @@ */ #include "common/system.h" -#include "common/events.h" #include "common/textconsole.h" #include "hopkins/events.h" #include "hopkins/files.h" @@ -44,6 +43,7 @@ EventsManager::EventsManager() { pointeur_souris = NULL; lItCounter = 0; ESC_KEY = false; + KEY_INVENT = false; btsouris = 0; OLD_ICONE = 0; @@ -236,14 +236,7 @@ void EventsManager::pollEvents() { return; case Common::EVENT_KEYDOWN: - ESC_KEY = event.kbd.keycode == Common::KEYCODE_ESCAPE; - - // 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(); - } + handleKey(event); return; case Common::EVENT_LBUTTONDOWN: @@ -263,6 +256,19 @@ void EventsManager::pollEvents() { } } +void EventsManager::handleKey(Common::Event &event) { + ESC_KEY = event.kbd.keycode == Common::KEYCODE_ESCAPE; + KEY_INVENT = event.kbd.keycode == Common::KEYCODE_i || event.kbd.keycode == Common::KEYCODE_TAB; + + // 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; diff --git a/engines/hopkins/events.h b/engines/hopkins/events.h index 835a9d95c3..3181b77d5f 100644 --- a/engines/hopkins/events.h +++ b/engines/hopkins/events.h @@ -24,6 +24,7 @@ #define HOPKINS_EVENTS_H #include "common/scummsys.h" +#include "common/events.h" #include "common/str.h" namespace Hopkins { @@ -38,6 +39,7 @@ private: HopkinsEngine *_vm; void pollEvents(); + void handleKey(Common::Event &event); void checkForNextFrameCounter(); public: bool souris_flag; @@ -57,6 +59,7 @@ public: uint32 _priorFrameTime; bool ESC_KEY; bool NOESC; + bool KEY_INVENT; int btsouris; public: EventsManager(); diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 78cbf31919..1123b7eb34 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -172,7 +172,6 @@ Globals::Globals() { AFFLI = 0; AFFIVBL = 0; NOT_VERIF = 0; - AFFINVEN = 0; PERSO_TYPE = 0; GOACTION = 0; NECESSAIRE = 0; diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 3b2ef8efa5..193807d0d4 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -428,7 +428,6 @@ public: int AFFIVBL; int NOT_VERIF; bool CACHEFLAG; - int AFFINVEN; bool NOPARLE; bool PLAN_FLAG; int GOACTION; diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 42647f338c..9ddb4f3693 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -61,7 +61,7 @@ ObjectsManager::ObjectsManager() { DESACTIVE_CURSOR = 0; BOBTOUS = false; INVENTFLAG = false; - KEY_INVENT = 0; + AFFINVEN = false; my_anim = 0; GOACTION = 0; NUMZONE = 0; @@ -83,7 +83,6 @@ ObjectsManager::ObjectsManager() { MAX_DEPA = 0; MAX_DEPA1 = 0; VIRE_INVENT = 0; - AFFINVEN = 0; CH_TETE = 0; T_RECTIF = 0; DESACTIVE = 0; @@ -110,7 +109,7 @@ void ObjectsManager::setParent(HopkinsEngine *vm) { // Change Object byte *ObjectsManager::CHANGE_OBJET(int objIndex) { - byte *result = ObjectsManager::CAPTURE_OBJET(objIndex, 1); + byte *result = CAPTURE_OBJET(objIndex, 1); _vm->_globals.Bufferobjet = result; _vm->_globals.Nouv_objet = 1; _vm->_globals.OBJET_EN_COURS = objIndex; @@ -118,7 +117,6 @@ byte *ObjectsManager::CHANGE_OBJET(int objIndex) { } byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { - byte *result = NULL; byte *dataP; dataP = 0; @@ -148,25 +146,24 @@ byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { if (dataP == g_PTRNUL) error("CAPTURE_OBJET"); - ObjectsManager::capture_mem_sprite(_vm->_globals.ADR_FICHIER_OBJ, dataP, val2); + capture_mem_sprite(_vm->_globals.ADR_FICHIER_OBJ, dataP, val2); break; case 1: - ObjectsManager::sprite_alone(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.Bufferobjet, val2); - result = _vm->_globals.Bufferobjet; + sprite_alone(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.Bufferobjet, val2); + dataP = _vm->_globals.Bufferobjet; break; case 3: - ObjectsManager::capture_mem_sprite(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.INVENTAIRE_OBJET, val2); - result = _vm->_globals.INVENTAIRE_OBJET; + capture_mem_sprite(_vm->_globals.ADR_FICHIER_OBJ, _vm->_globals.INVENTAIRE_OBJET, val2); + dataP = _vm->_globals.INVENTAIRE_OBJET; break; default: - result = dataP; break; } - return result; + return dataP; } // Delete Object @@ -494,7 +491,7 @@ void ObjectsManager::AFF_SPRITES() { } _vm->_globals.NBTRI = 0; - if (_vm->_globals.AFFINVEN == 1) { + if (_vm->_objectsManager.AFFINVEN) { _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Winventaire, inventairex, inventairey, inventairel, inventaireh); if (old_cadx && old_cady) _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, inventaire2, old_cadx + 300, old_cady + 300, old_cadi + 1); @@ -2684,7 +2681,7 @@ void ObjectsManager::PLAN_BETA() { v1 = 0; INVENTFLAG = false; - KEY_INVENT = 0; + _vm->_eventsManager.KEY_INVENT = 0; _vm->_globals.Max_Propre = 1; _vm->_globals.Max_Ligne_Long = 1; _vm->_globals.Max_Propre_Gen = 1; @@ -2827,7 +2824,7 @@ void ObjectsManager::BTGAUCHE() { INVENTFLAG = 1; INVENT(); INVENTFLAG = 0; - KEY_INVENT = 0; + _vm->_eventsManager.KEY_INVENT = 0; if (!_vm->_globals.SORTIE) { INVENTFLAG = 0; _vm->_eventsManager.btsouris = v1; @@ -3162,14 +3159,14 @@ void ObjectsManager::CLEAR_ECRAN() { void ObjectsManager::TEST_INVENT() { if (_vm->_globals.PLAN_FLAG) - KEY_INVENT = 0; - if (KEY_INVENT == 1) { + _vm->_eventsManager.KEY_INVENT = 0; + if (_vm->_eventsManager.KEY_INVENT == 1) { if (!INVENTFLAG) { - KEY_INVENT = 0; + _vm->_eventsManager.KEY_INVENT = 0; INVENTFLAG = 1; INVENT(); INVENTFLAG = 0; - KEY_INVENT = 0; + _vm->_eventsManager.KEY_INVENT = 0; } } } @@ -3197,7 +3194,7 @@ void ObjectsManager::INVENT() { Common::File f; v13 = 0; - if (VIRE_INVENT != 1 && AFFINVEN != 1 && _vm->_globals.DESACTIVE_INVENT != 1) { + if (VIRE_INVENT != 1 && !AFFINVEN && _vm->_globals.DESACTIVE_INVENT != 1) { _vm->_graphicsManager.no_scroll = 1; FLAG_VISIBLE_EFFACE = 4; FLAG_VISIBLE = 0; @@ -3210,17 +3207,24 @@ void ObjectsManager::INVENT() { ++v1; } while (v1 <= 1); _vm->_globals.Winventaire = g_PTRNUL; + LABEL_7: _vm->_eventsManager.souris_bb = 0; _vm->_eventsManager.souris_b = 0; _vm->_globals.DESACTIVE_INVENT = 1; _vm->_graphicsManager.SETCOLOR4(251, 100, 100, 100); - if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTFR.SPR"); - if (!_vm->_globals.FR) - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTAN.SPR"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTES.SPR"); + + 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()); @@ -3239,7 +3243,8 @@ LABEL_7: inventairey = 114; inventairel = v18; inventaireh = v17; - _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Winventaire, v19 + 300, 414, 0, 0, 0, 0); + _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Winventaire, + v19 + 300, 414, 0, 0, 0, 0); v15 = 0; v4 = 0; v14 = 1; @@ -3251,7 +3256,8 @@ LABEL_7: v6 = _vm->_globals.INVENTAIRE[v4]; if (v6 && v4 <= 29) { v7 = 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->_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; @@ -3263,8 +3269,12 @@ LABEL_7: _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.Winventaire, inventairex, inventairey, inventairel, inventaireh); _vm->_eventsManager.souris_bb = 0; v20 = 0; - while (1) { - AFFINVEN = 1; + + // 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(); @@ -3316,7 +3326,7 @@ LABEL_7: goto LABEL_7; } } else if (v20 != 1) { - AFFINVEN = 1; + AFFINVEN = true; } } } @@ -3329,16 +3339,17 @@ LABEL_7: SPECIAL_JEU(); } _vm->_fontManager.TEXTE_OFF(9); - if (AFFINVEN == 1) { - AFFINVEN = 0; + 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); BOBTOUS = 1; } - if (g_PTRNUL != _vm->_globals.Winventaire) + if (_vm->_globals.Winventaire != g_PTRNUL) _vm->_globals.Winventaire = _vm->_globals.dos_free2(_vm->_globals.Winventaire); inventaire2 = _vm->_globals.dos_free2(inventaire2); + if (_vm->_eventsManager.btsouris == 1) OptionsDialog::show(_vm); if (_vm->_eventsManager.btsouris == 3) @@ -5855,7 +5866,7 @@ void ObjectsManager::PERSONAGE(const Common::String &s1, const Common::String &s v5 = 0; INVENTFLAG = 0; - KEY_INVENT = 0; + _vm->_eventsManager.KEY_INVENT = 0; VIRE_INVENT = 0; _vm->_graphicsManager.ofscroll = 0; _vm->_globals.PLAN_FLAG = 0; @@ -5952,7 +5963,7 @@ void ObjectsManager::PERSONAGE2(const Common::String &s1, const Common::String & int xp, yp; INVENTFLAG = 0; - KEY_INVENT = 0; + _vm->_eventsManager.KEY_INVENT = 0; _vm->_objectsManager.verbe = 4; _vm->_globals.MAX_COMPTE = 6; _vm->_graphicsManager.ofscroll = 0; diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h index 9757d08612..abc0e97d8d 100644 --- a/engines/hopkins/objects.h +++ b/engines/hopkins/objects.h @@ -86,7 +86,7 @@ public: int DESACTIVE_CURSOR; bool BOBTOUS; bool INVENTFLAG; - int KEY_INVENT; + bool AFFINVEN; int my_anim; int GOACTION; int NUMZONE; @@ -108,7 +108,6 @@ public: int MAX_DEPA; int MAX_DEPA1; int VIRE_INVENT; - int AFFINVEN; int CH_TETE; int T_RECTIF; int DESACTIVE; |