diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hopkins/globals.cpp | 33 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 1 | ||||
-rw-r--r-- | engines/hopkins/lines.cpp | 119 | ||||
-rw-r--r-- | engines/hopkins/lines.h | 21 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 16 | ||||
-rw-r--r-- | engines/hopkins/objects.h | 2 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 4 |
7 files changed, 101 insertions, 95 deletions
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index e132457ac0..a8ee4e4063 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -161,14 +161,13 @@ Globals::Globals() { _oceanDirection = 0; - // Initialise pointers + // Initialize pointers ICONE = NULL; BUF_ZONE = NULL; for (int idx = 0; idx < 6; ++idx) CACHE_BANQUE[idx] = NULL; SPRITE_ECRAN = NULL; _saveData = NULL; - BUFFERTAPE = NULL; inventaire2 = NULL; GESTE = NULL; _inventoryObject = NULL; @@ -214,7 +213,6 @@ Globals::~Globals() { CACHE_BANQUE[idx] = freeMemory(CACHE_BANQUE[idx]); freeMemory(SPRITE_ECRAN); freeMemory((byte *)_saveData); - freeMemory(BUFFERTAPE); freeMemory(inventaire2); freeMemory(GESTE); freeMemory(_inventoryObject); @@ -299,38 +297,11 @@ void Globals::clearAll() { ZONEP[idx]._spriteIndex = 0; } - _vm->_linesManager.essai0 = (int16 *)g_PTRNUL; - _vm->_linesManager.essai1 = (int16 *)g_PTRNUL; - _vm->_linesManager.essai2 = (int16 *)g_PTRNUL; - _vm->_linesManager.BufLig = (int16 *)g_PTRNUL; - _vm->_linesManager._route = (int16 *)g_PTRNUL; - - for (int idx = 0; idx < MAX_LINES; ++idx) { - _vm->_linesManager.Ligne[idx]._lineDataEndIdx = 0; - _vm->_linesManager.Ligne[idx].field2 = 0; - _vm->_linesManager.Ligne[idx]._direction = 0; - _vm->_linesManager.Ligne[idx].field6 = 0; - _vm->_linesManager.Ligne[idx].field8 = 0; - _vm->_linesManager.Ligne[idx]._lineData = (int16 *)g_PTRNUL; - - _vm->_linesManager._zoneLine[idx]._count = 0; - _vm->_linesManager._zoneLine[idx].field2 = 0; - _vm->_linesManager._zoneLine[idx]._zoneData = (int16 *)g_PTRNUL; - } - - for (int idx = 0; idx < 100; ++idx) { - _vm->_linesManager.CarreZone[idx]._enabledFl = 0; - } - - BUFFERTAPE = allocMemory(85000); + _vm->_linesManager.clearAll(); _saveData = (Sauvegarde *)malloc(sizeof(Sauvegarde)); memset(_saveData, 0, sizeof(Sauvegarde)); - _vm->_linesManager.essai0 = (int16 *)BUFFERTAPE; - _vm->_linesManager.essai1 = (int16 *)(BUFFERTAPE + 25000); - _vm->_linesManager.essai2 = (int16 *)(BUFFERTAPE + 50000); - _vm->_linesManager.BufLig = (int16 *)(BUFFERTAPE + 75000); _boxWidth = 240; _vm->_eventsManager._objectBuf = allocMemory(2500); diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 55bd3c7455..f17156cee9 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -315,7 +315,6 @@ public: byte *BUF_ZONE; byte *SPRITE_ECRAN; Sauvegarde *_saveData; - byte *BUFFERTAPE; byte *inventaire2; byte *GESTE; int NUM_FICHIER_OBJ; diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp index b1a289ab53..fe01446742 100644 --- a/engines/hopkins/lines.cpp +++ b/engines/hopkins/lines.cpp @@ -58,7 +58,12 @@ LinesManager::LinesManager() { essai2 = NULL; BufLig = (int16 *)g_PTRNUL; _route = (int16 *)g_PTRNUL; - SegmentEnCours = 0; + _currentSegmentId = 0; + BUFFERTAPE = NULL; +} + +LinesManager::~LinesManager() { + _vm->_globals.freeMemory(BUFFERTAPE); } void LinesManager::setParent(HopkinsEngine *vm) { @@ -87,14 +92,6 @@ void LinesManager::loadLines(const Common::String &file) { _vm->_globals.freeMemory(ptr); } -/** - * Clear all zones and reset nextLine - */ -void LinesManager::clearAllZones() { - for (int idx = 0; idx < MAX_LINES; ++idx) - removeZoneLine(idx); -} - /** * Check Hotspots in Inventory screen * Returns the ID of the hotspot under mouse @@ -159,14 +156,6 @@ int LinesManager::checkInventoryHotspotsRow(int posX, int minZoneNum, bool lastR } /** - * Remove Zone Line - */ -void LinesManager::removeZoneLine(int idx) { - assert (idx <= MAX_LINES); - _zoneLine[idx]._zoneData = (int16 *)_vm->_globals.freeMemory((byte *)_zoneLine[idx]._zoneData); -} - -/** * Add Zone Line */ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZoneIdx) { @@ -217,21 +206,6 @@ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZ } } -void LinesManager::resetLines() { - for (int idx = 0; idx < MAX_LINES; ++idx) { - removeLine(idx); - Ligne[idx]._lineDataEndIdx = 0; - Ligne[idx]._lineData = (int16 *)g_PTRNUL; - } -} - -// Remove Line -void LinesManager::removeLine(int idx) { - if (idx > MAX_LINES) - error("Attempting to add a line obstacle > MAX_LIGNE."); - Ligne[idx]._lineData = (int16 *)_vm->_globals.freeMemory((byte *)Ligne[idx]._lineData); -} - /** * Add Line */ @@ -274,8 +248,7 @@ void LinesManager::addLine(int idx, int a2, int a3, int a4, int a5, int a6, int v34 = v8; v10 = _vm->_globals.allocMemory(4 * v34 + 8); - if (v10 == g_PTRNUL) - error("AJOUTE LIGNE OBSTACLE"); + assert (v10 != g_PTRNUL); Common::fill(v10, v10 + 4 * v34 + 8, 0); Ligne[idx]._lineData = (int16 *)v10; @@ -2865,7 +2838,6 @@ bool LinesManager::PLAN_TEST(int paramX, int paramY, int a3, int a4, int a5) { int superRouteIdx = a3; if (v33 == 1) { - essai0 = essai0; for (int i = 0; i < Ligne[idxTest]._lineDataEndIdx; i++) { super_parcours[superRouteIdx] = Ligne[idxTest]._lineData[2 * i]; super_parcours[superRouteIdx + 1] = Ligne[idxTest]._lineData[2 * i + 1]; @@ -3028,7 +3000,7 @@ int LinesManager::MZONE() { } } } - SegmentEnCours = 0; + _currentSegmentId = 0; for (int squareZoneId = 0; squareZoneId <= 99; squareZoneId++) { if (_vm->_globals.ZONEP[squareZoneId]._enabledFl && CarreZone[squareZoneId]._enabledFl == 1 && CarreZone[squareZoneId]._left <= xp && CarreZone[squareZoneId]._right >= xp @@ -3037,12 +3009,12 @@ int LinesManager::MZONE() { _vm->_globals.oldzone_46 = _zoneLine[CarreZone[squareZoneId]._minZoneLineIdx].field2; return _vm->_globals.oldzone_46; } - Segment[SegmentEnCours].field2 = CarreZone[squareZoneId]._minZoneLineIdx; - Segment[SegmentEnCours].field4 = CarreZone[squareZoneId]._maxZoneLineIdx; - ++SegmentEnCours; + Segment[_currentSegmentId].field2 = CarreZone[squareZoneId]._minZoneLineIdx; + Segment[_currentSegmentId].field4 = CarreZone[squareZoneId]._maxZoneLineIdx; + ++_currentSegmentId; } } - if (!SegmentEnCours) { + if (!_currentSegmentId) { _vm->_globals.oldzone_46 = -1; return -1; } @@ -3102,13 +3074,13 @@ int LinesManager::MZONE() { } int LinesManager::colision(int xp, int yp) { - if (SegmentEnCours <= 0) + if (_currentSegmentId <= 0) return -1; int xMax = xp + 4; int xMin = xp - 4; - for (int idx = 0; idx <= SegmentEnCours; ++idx) { + for (int idx = 0; idx <= _currentSegmentId; ++idx) { int field2 = Segment[idx].field2; if (Segment[idx].field4 < field2) continue; @@ -3199,4 +3171,67 @@ void LinesManager::CARRE_ZONE() { } } +void LinesManager::clearAll() { + _vm->_linesManager.essai0 = (int16 *)g_PTRNUL; + _vm->_linesManager.essai1 = (int16 *)g_PTRNUL; + _vm->_linesManager.essai2 = (int16 *)g_PTRNUL; + _vm->_linesManager.BufLig = (int16 *)g_PTRNUL; + _vm->_linesManager._route = (int16 *)g_PTRNUL; + + for (int idx = 0; idx < MAX_LINES; ++idx) { + _vm->_linesManager.Ligne[idx]._lineDataEndIdx = 0; + _vm->_linesManager.Ligne[idx].field2 = 0; + _vm->_linesManager.Ligne[idx]._direction = 0; + _vm->_linesManager.Ligne[idx].field6 = 0; + _vm->_linesManager.Ligne[idx].field8 = 0; + _vm->_linesManager.Ligne[idx]._lineData = (int16 *)g_PTRNUL; + + _vm->_linesManager._zoneLine[idx]._count = 0; + _vm->_linesManager._zoneLine[idx].field2 = 0; + _vm->_linesManager._zoneLine[idx]._zoneData = (int16 *)g_PTRNUL; + } + + for (int idx = 0; idx < 100; ++idx) { + _vm->_linesManager.CarreZone[idx]._enabledFl = 0; + } + + BUFFERTAPE = _vm->_globals.allocMemory(85000); + + _vm->_linesManager.essai0 = (int16 *)BUFFERTAPE; + _vm->_linesManager.essai1 = (int16 *)(BUFFERTAPE + 25000); + _vm->_linesManager.essai2 = (int16 *)(BUFFERTAPE + 50000); + _vm->_linesManager.BufLig = (int16 *)(BUFFERTAPE + 75000); +} + +/** + * Clear all zones and reset nextLine + */ +void LinesManager::clearAllZones() { + for (int idx = 0; idx < MAX_LINES; ++idx) + removeZoneLine(idx); +} + +/** + * Remove Zone Line + */ +void LinesManager::removeZoneLine(int idx) { + assert (idx <= MAX_LINES); + _zoneLine[idx]._zoneData = (int16 *)_vm->_globals.freeMemory((byte *)_zoneLine[idx]._zoneData); +} + +void LinesManager::resetLines() { + for (int idx = 0; idx < MAX_LINES; ++idx) { + removeLine(idx); + Ligne[idx]._lineDataEndIdx = 0; + Ligne[idx]._lineData = (int16 *)g_PTRNUL; + } +} + +// Remove Line +void LinesManager::removeLine(int idx) { + if (idx > MAX_LINES) + error("Attempting to add a line obstacle > MAX_LIGNE."); + Ligne[idx]._lineData = (int16 *)_vm->_globals.freeMemory((byte *)Ligne[idx]._lineData); +} + } // End of namespace Hopkins diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h index fa4e2efe7c..6098ca5034 100644 --- a/engines/hopkins/lines.h +++ b/engines/hopkins/lines.h @@ -80,6 +80,15 @@ private: int NVPY; int _smoothMoveDirection; int16 super_parcours[32002]; + byte *BUFFERTAPE; + int16 *essai0; + int16 *essai1; + int16 *BufLig; + LigneZoneItem _zoneLine[401]; + LigneItem Ligne[400]; + SegmentItem Segment[101]; + CarreZoneItem CarreZone[101]; + int _currentSegmentId; int CALC_PROPRE(int idx); int checkInventoryHotspotsRow(int posX, int minZoneNum, bool lastRow); @@ -99,21 +108,14 @@ private: public: int _lastLine; int _linesNumb; - LigneZoneItem _zoneLine[401]; - LigneItem Ligne[400]; int _maxLineIdx; - SegmentItem Segment[101]; - CarreZoneItem CarreZone[101]; - int SegmentEnCours; + int16 *essai2; public: - int16 *essai0; - int16 *essai1; - int16 *essai2; - int16 *BufLig; int16 *_route; LinesManager(); + ~LinesManager(); void setParent(HopkinsEngine *vm); int checkInventoryHotspots(int posX, int posY); @@ -129,6 +131,7 @@ public: int colision(int xp, int yp); int MZONE(); void CARRE_ZONE(); + void clearAll(); }; } // End of namespace Hopkins diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index d468884859..48fcfb8f10 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -3335,21 +3335,19 @@ void ObjectsManager::SPECIAL_INI() { } } -void ObjectsManager::OPTI_BOBON(int idx1, int idx2, int idx3, int a4, int a5, int a6, int a7) { +void ObjectsManager::OPTI_BOBON(int idx1, int idx2, int idx3, int a4, int a5, int a6) { if (idx1 != -1) setBobAnimation(idx1); if (idx2 != -1) setBobAnimation(idx2); if (idx3 != -1) setBobAnimation(idx3); - if (!a7) { - if (idx1 != -1) - SET_BOBPOSI(idx1, a4); - if (idx2 != -1) - SET_BOBPOSI(idx2, a5); - if (idx3 != -1) - SET_BOBPOSI(idx3, a6); - } + if (idx1 != -1) + SET_BOBPOSI(idx1, a4); + if (idx2 != -1) + SET_BOBPOSI(idx2, a5); + if (idx3 != -1) + SET_BOBPOSI(idx3, a6); } void ObjectsManager::SCI_OPTI_ONE(int idx, int a2, int a3, int a4) { diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h index ef7b069152..d0d61c954c 100644 --- a/engines/hopkins/objects.h +++ b/engines/hopkins/objects.h @@ -189,7 +189,7 @@ public: void INILINK(const Common::String &file); void SPECIAL_INI(); - void OPTI_BOBON(int idx1, int idx2, int idx3, int a4, int a5, int a6, int a7); + void OPTI_BOBON(int idx1, int idx2, int idx3, int a4, int a5, int a6); void SCI_OPTI_ONE(int idx, int a2, int a3, int a4); void disableVerb(int idx, int a2); void enableVerb(int idx, int a2); diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index b4caa74b2c..a9bcae6be6 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -736,7 +736,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_globals.NOT_VERIF = true; _vm->_soundManager.loadSample(1, "SOUND44.WAV"); _vm->_soundManager.loadSample(2, "SOUND45.WAV"); - _vm->_objectsManager.OPTI_BOBON(9, 10, -1, 0, 0, 0, 0); + _vm->_objectsManager.OPTI_BOBON(9, 10, -1, 0, 0, 0); bool v15 = false; do { if (_vm->shouldQuit()) @@ -805,7 +805,7 @@ int ScriptManager::handleOpcode(byte *dataP) { case 49: { _vm->_globals.CACHE_OFF(); _vm->_objectsManager.removeSprite(0); - _vm->_objectsManager.OPTI_BOBON(9, 10, -1, 0, 0, 0, 0); + _vm->_objectsManager.OPTI_BOBON(9, 10, -1, 0, 0, 0); int v19 = 12; if (_vm->_globals._saveData->_data[svField133] == 1) v19 = 41; |