From 687b7f97df666c392af6f0f4ff3eca7832b1b313 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 20 Dec 2012 00:30:01 +0100 Subject: HOPKINS: Remane functions and variables from Globals --- engines/hopkins/anim.cpp | 18 ++-- engines/hopkins/computer.cpp | 4 +- engines/hopkins/detection.cpp | 16 ++-- engines/hopkins/dialogs.cpp | 10 +-- engines/hopkins/globals.cpp | 40 ++++----- engines/hopkins/globals.h | 38 ++++---- engines/hopkins/hopkins.cpp | 4 +- engines/hopkins/objects.cpp | 165 ++++++++++++++++------------------ engines/hopkins/saveload.cpp | 52 +++++------ engines/hopkins/saveload.h | 22 ++--- engines/hopkins/talk.cpp | 201 ++++++++++++++++++++---------------------- 11 files changed, 266 insertions(+), 304 deletions(-) (limited to 'engines/hopkins') diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index d26b1b8b17..a45c49e45e 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -237,9 +237,9 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 a2, uint _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager.ofscroll = 0; @@ -311,7 +311,7 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 a2, uint _vm->_globals.freeMemory(v13); f.close(); - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); @@ -385,7 +385,7 @@ LABEL_88: _vm->_globals.freeMemory(v13); f.close(); - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); @@ -427,7 +427,7 @@ LABEL_88: _vm->_globals.freeMemory(v13); f.close(); - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); @@ -506,7 +506,7 @@ LABEL_114: _vm->_graphicsManager.FADE_LINUX = 0; _vm->_globals.freeMemory(v13); - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); @@ -828,9 +828,9 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager.ofscroll = 0; } @@ -962,7 +962,7 @@ LABEL_59: f.close(); if (!NO_COUL) { - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); _vm->_eventsManager._mouseFl = true; diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index 9509a849bd..610629e439 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -644,7 +644,7 @@ void ComputerManager::loadHiscore() { _vm->_fileManager.constructLinuxFilename("HISCORE.DAT"); ptr = _vm->_globals.allocMemory(100); - _vm->_saveLoadManager.bload(_vm->_globals.NFICHIER, ptr); + _vm->_saveLoadManager.load(_vm->_globals.NFICHIER, ptr); for (int scoreIndex = 0; scoreIndex < 6; ++scoreIndex) { for (int i = 0; i < 5; ++i) { @@ -1102,7 +1102,7 @@ void ComputerManager::saveScore() { } _vm->_fileManager.constructLinuxFilename("HISCORE.DAT"); - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, ptr, 0x64u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, ptr, 0x64u); _vm->_globals.freeMemory(ptr); } diff --git a/engines/hopkins/detection.cpp b/engines/hopkins/detection.cpp index 684854bb45..9ebf6837ea 100644 --- a/engines/hopkins/detection.cpp +++ b/engines/hopkins/detection.cpp @@ -140,10 +140,10 @@ SaveStateList HopkinsMetaEngine::listSaves(const char *target) const { if (in) { if (Hopkins::SaveLoadManager::readSavegameHeader(in, header)) { - saveList.push_back(SaveStateDescriptor(slot, header.saveName)); + saveList.push_back(SaveStateDescriptor(slot, header._saveName)); - header.thumbnail->free(); - delete header.thumbnail; + header._thumbnail->free(); + delete header._thumbnail; } delete in; @@ -173,11 +173,11 @@ SaveStateDescriptor HopkinsMetaEngine::querySaveMetaInfos(const char *target, in 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); + SaveStateDescriptor desc(slot, header._saveName); + desc.setThumbnail(header._thumbnail); + desc.setSaveDate(header._year, header._month, header._day); + desc.setSaveTime(header._hour, header._minute); + desc.setPlayTime(header._totalFrames * GAME_FRAME_TIME); return desc; } diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index a228b030ba..6efd7b7191 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -580,7 +580,7 @@ void DialogsManager::showLoadGame() { _vm->_objectsManager.SL_Y = 0; if (slotNumber != 7) { - _vm->_saveLoadManager.restore(slotNumber); + _vm->_saveLoadManager.loadGame(slotNumber); } _vm->_objectsManager.changeObject(14); @@ -617,7 +617,7 @@ void DialogsManager::showSaveGame() { saveName = Common::String::format("Save #%d", slotNumber); // Save the game - _vm->_saveLoadManager.save(slotNumber, saveName); + _vm->_saveLoadManager.saveGame(slotNumber, saveName); } } @@ -661,7 +661,7 @@ void DialogsManager::showSaveLoad(int a1) { for (slotNumber = 1; slotNumber <= 6; ++slotNumber) { if (_vm->_saveLoadManager.readSavegameHeader(slotNumber, header)) { Graphics::Surface thumb8; - _vm->_saveLoadManager.convertThumb16To8(header.thumbnail, &thumb8); + _vm->_saveLoadManager.convertThumb16To8(header._thumbnail, &thumb8); thumb = (byte *)thumb8.pixels; @@ -687,8 +687,8 @@ void DialogsManager::showSaveLoad(int a1) { } thumb8.free(); - header.thumbnail->free(); - delete header.thumbnail; + header._thumbnail->free(); + delete header._thumbnail; } } diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 5739cc1d74..6af81b819a 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -461,9 +461,8 @@ void Globals::INIT_VBOB() { 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]._spriteData = g_PTRNUL; VBob[idx]._oldSpriteData = g_PTRNUL; } } @@ -474,9 +473,8 @@ void Globals::CLEAR_VBOB() { VBob[idx]._xp = 0; VBob[idx]._yp = 0; VBob[idx]._frameIndex = 0; - VBob[idx].fieldC = 0; VBob[idx]._surface = freeMemory(VBob[idx]._surface); - VBob[idx].spriteData = g_PTRNUL; + VBob[idx]._spriteData = g_PTRNUL; VBob[idx]._oldSpriteData = g_PTRNUL; } } @@ -489,7 +487,7 @@ void Globals::CHARGE_OBJET() { for (int idx = 0; idx < 300; ++idx) { ObjetW[idx].field0 = *srcP++; - ObjetW[idx].field1 = *srcP++; + ObjetW[idx]._idx = *srcP++; ObjetW[idx].field2 = *srcP++; ObjetW[idx].field3 = *srcP++; ObjetW[idx].field4 = *srcP++; @@ -522,15 +520,14 @@ void Globals::RESET_CACHE() { } 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]._spriteData = g_PTRNUL; + Cache[idx]._x = 0; + Cache[idx]._y = 0; + Cache[idx]._spriteIndex = 0; Cache[idx].fieldA = 0; - Cache[idx].field6 = 0; - Cache[idx].field8 = 0; - Cache[idx].field10 = 0; - Cache[idx].field12 = 0; + Cache[idx]._width = 0; + Cache[idx]._height = 0; + Cache[idx].field10 = false; Cache[idx].field14 = 0; } @@ -579,22 +576,21 @@ void Globals::loadCache(const Common::String &file) { int v5 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 2); int v6 = i; 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; + Cache[v6]._spriteIndex = v11; + Cache[v6]._x = v4; + Cache[v6]._y = v5; if (spriteData == g_PTRNUL) { Cache[i].fieldA = 0; } else { int v8 = _vm->_objectsManager.getWidth(spriteData, v11); int v9 = _vm->_objectsManager.getHeight(spriteData, v11); - Cache[i].fieldC = spriteData; - Cache[i].field6 = v8; - Cache[i].field8 = v9; + Cache[i]._spriteData = spriteData; + Cache[i]._width = v8; + Cache[i]._height = v9; Cache[i].fieldA = 1; } - if ( !Cache[i].field0 && !Cache[i].field4 && !Cache[i].field2) + if ( !Cache[i]._x && !Cache[i]._y && !Cache[i]._spriteIndex) Cache[i].fieldA = 0; v15 += 5; } @@ -605,7 +601,7 @@ void Globals::loadCache(const Common::String &file) { } void Globals::B_CACHE_OFF(int idx) { - Bob[idx].field34 = 1; + Bob[idx].field34 = true; } diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index d1fdae57a8..db26cd8f4e 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -96,25 +96,20 @@ struct BobItem { int _xp; int _yp; int _frameIndex; - int fieldE; - int field10; + int field10; // BOBPOSI ? int field12; int field14; - int field16; + bool field16; // set to true in BOBANIM_OFF() byte *_animData; - int field1C; + bool field1C; int field1E; int field20; int field22; - int offsetY; - int field26; - int field28; - int field2A; - int field2C; + int _offsetY; // Unused variable? byte *field30; - int field34; + bool field34; // Set to true in B_CACHE_OFF() int field36; - int field38; + int _modeFlag; bool _isSpriteFl; bool _activeFl; int _oldX; @@ -132,13 +127,11 @@ struct BlAnimItem { }; struct VBobItem { - byte *spriteData; + byte *_spriteData; int field4; int _xp; int _yp; int _frameIndex; - int fieldC; - int fieldE; byte *_surface; int _oldX; int _oldY; @@ -148,7 +141,7 @@ struct VBobItem { struct ObjetWItem { byte field0; - byte field1; + byte _idx; byte field2; byte field3; byte field4; @@ -180,15 +173,14 @@ struct TriItem { }; struct CacheItem { - int field0; - int field2; - int field4; - int field6; - int field8; + int _x; + int _spriteIndex; + int _y; + int _width; + int _height; int fieldA; - byte *fieldC; - int field10; - int field12; + byte *_spriteData; + bool field10; int field14; }; diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 27504dce08..1792cf472a 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -82,14 +82,14 @@ bool HopkinsEngine::canSaveGameStateCurrently() { * Load the savegame at the specified slot index */ Common::Error HopkinsEngine::loadGameState(int slot) { - return _saveLoadManager.restore(slot); + return _saveLoadManager.loadGame(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); + return _saveLoadManager.saveGame(slot, desc); } Common::Error HopkinsEngine::run() { diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 0c632b02ce..5afd9fe922 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -111,9 +111,9 @@ void ObjectsManager::changeObject(int objIndex) { byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { byte *dataP; - dataP = 0; + dataP = NULL; int val1 = _vm->_globals.ObjetW[objIndex].field0; - int val2 = _vm->_globals.ObjetW[objIndex].field1; + int val2 = _vm->_globals.ObjetW[objIndex]._idx; if (mode == 1) ++val2; @@ -566,25 +566,20 @@ void ObjectsManager::BOB_ZERO(int idx) { 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.field16 = false; bob._animData = g_PTRNUL; - bob.field1C = 0; + bob.field1C = false; 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._offsetY = 0; bob.field30 = g_PTRNUL; - bob.field34 = 0; + bob.field34 = false; bob.field36 = 0; - bob.field38 = 0; + bob._modeFlag = 0; bob._oldX2 = 0; item._visibleFl = false; @@ -606,7 +601,7 @@ void ObjectsManager::DEF_BOB(int idx) { _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _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.Bob[idx]._modeFlag); _vm->_globals.Liste2[idx]._visibleFl = true; _vm->_globals.Liste2[idx]._xp = xp; @@ -672,7 +667,7 @@ void ObjectsManager::BOB_VISU(int idx) { if (_vm->_globals.Bank[v1]._fileHeader == 1) { _vm->_globals.Bob[idx]._isSpriteFl = true; _vm->_globals.Bob[idx].field36 = 0; - _vm->_globals.Bob[idx].field38 = 0; + _vm->_globals.Bob[idx]._modeFlag = 0; } _vm->_globals.Bob[idx]._animData = _vm->_globals.Bqe_Anim[idx]._data; @@ -682,7 +677,7 @@ void ObjectsManager::BOB_VISU(int idx) { _vm->_globals.Bob[idx].field1E = v9; _vm->_globals.Bob[idx].field20 = v6; _vm->_globals.Bob[idx].field22 = v8; - _vm->_globals.Bob[idx].offsetY = offsetY; + _vm->_globals.Bob[idx]._offsetY = offsetY; } } } @@ -705,7 +700,7 @@ void ObjectsManager::BOB_ADJUST(int idx, int v) { } void ObjectsManager::BOB_OFFSETY(int idx, int v) { - _vm->_globals.Bob[idx].offsetY = v; + _vm->_globals.Bob[idx]._offsetY = v; } void ObjectsManager::SCBOB(int idx) { @@ -717,14 +712,14 @@ void ObjectsManager::SCBOB(int idx) { int v2 = _vm->_globals.Bob[v8]._oldWidth; int v9 = _vm->_globals.Bob[v8]._oldX + _vm->_globals.Bob[v8]._oldWidth; int v6 = _vm->_globals.Bob[v8]._oldY + _vm->_globals.Bob[v8]._oldHeight; - int v3 =_vm->_globals.Cache[idx].field0; - int v4 =_vm->_globals.Cache[idx].field4; - int v7 =_vm->_globals.Cache[idx].field6 + v3; - int v1 =_vm->_globals.Cache[idx].field14 +_vm->_globals.Cache[idx].field8 + v4; + int v3 =_vm->_globals.Cache[idx]._x; + int v4 =_vm->_globals.Cache[idx]._y; + int v7 =_vm->_globals.Cache[idx]._width + v3; + int v1 =_vm->_globals.Cache[idx].field14 +_vm->_globals.Cache[idx]._height + v4; if ((v6 > v4) && (v6 < v1)) { v1 = 0; - if (v9 >= v3 && v9 <= (_vm->_globals.Cache[idx].field6 + v3)) { + if (v9 >= v3 && v9 <= (_vm->_globals.Cache[idx]._width + v3)) { ++_vm->_globals.Cache[idx].fieldA; v1 = 1; } @@ -756,14 +751,14 @@ void ObjectsManager::SCBOB(int idx) { void ObjectsManager::CALCUL_BOB(int idx) { _vm->_globals.Bob[idx]._activeFl = false; if (_vm->_globals.Bob[idx]._isSpriteFl) { - _vm->_globals.Bob[idx].field38 = 0; + _vm->_globals.Bob[idx]._modeFlag = 0; _vm->_globals.Bob[idx].field36 = 0; } int result = _vm->_globals.Bob[idx]._frameIndex; if (result != 250) { int v5, v15, v22; - if (_vm->_globals.Bob[idx].field38) { + if (_vm->_globals.Bob[idx]._modeFlag) { v22 = v15 = get_offsetx(_vm->_globals.Bob[idx]._spriteData, result, 1); v5 = get_offsety(_vm->_globals.Bob[idx]._spriteData, _vm->_globals.Bob[idx]._frameIndex, 1); } else { @@ -872,12 +867,12 @@ void ObjectsManager::VERIFCACHE() { 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; + v6 = _vm->_globals.Cache[v8]._x; + v3 = _vm->_globals.Cache[v8]._y; + v9 = _vm->_globals.Cache[v8]._width + v6; if (v2 > v3) { - if (v2 < (_vm->_globals.Cache[v8].field14 + _vm->_globals.Cache[v8].field8 + v3)) { + if (v2 < (_vm->_globals.Cache[v8].field14 + _vm->_globals.Cache[v8]._height + v3)) { v4 = 0; if (v11 >= v6 && v11 <= v9) { ++_vm->_globals.Cache[v8].fieldA; @@ -911,19 +906,19 @@ void ObjectsManager::VERIFCACHE() { SCBOB(v8); if (_vm->_globals.Cache[v8].fieldA == v7) { - if (_vm->_globals.Cache[v8].field10 == 1) { - _vm->_globals.Cache[v8].field10 = 0; + if (_vm->_globals.Cache[v8].field10) { + _vm->_globals.Cache[v8].field10 = false; _vm->_globals.Cache[v8].fieldA = 1; } } else { - v5 = _vm->_globals.Cache[v8].field14 + _vm->_globals.Cache[v8].field8 + - _vm->_globals.Cache[v8].field4; + v5 = _vm->_globals.Cache[v8].field14 + _vm->_globals.Cache[v8]._height + + _vm->_globals.Cache[v8]._y; if (v5 > 440) v5 = 500; AvantTri(TRI_CACHE, v8, v5); _vm->_globals.Cache[v8].fieldA = 1; - _vm->_globals.Cache[v8].field10 = 1; + _vm->_globals.Cache[v8].field10 = true; } } } @@ -993,13 +988,13 @@ void ObjectsManager::DEF_SPRITE(int idx) { void ObjectsManager::DEF_CACHE(int idx) { _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _vm->_globals.CACHE_BANQUE[1], - _vm->_globals.Cache[idx].field0 + 300, _vm->_globals.Cache[idx].field4 + 300, - _vm->_globals.Cache[idx].field2); + _vm->_globals.Cache[idx]._x + 300, _vm->_globals.Cache[idx]._y + 300, + _vm->_globals.Cache[idx]._spriteIndex); - _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); + _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_globals.Cache[idx]._x, + _vm->_globals.Cache[idx]._y, + _vm->_globals.Cache[idx]._x + _vm->_globals.Cache[idx]._width, + _vm->_globals.Cache[idx]._y + _vm->_globals.Cache[idx]._height); } // Compute Sprite @@ -1143,11 +1138,8 @@ int ObjectsManager::AvantTri(TriMode triMode, int index, int priority) { // Display BOB Anim void ObjectsManager::AFF_BOB_ANIM() { int v1; - int v2; int v5; uint v6; - int v7; - int v8; int v10; int v11; int v12; @@ -1161,27 +1153,26 @@ void ObjectsManager::AFF_BOB_ANIM() { do { ++idx; if (idx <= 20 && PERSO_ON == true) { - _vm->_globals.Bob[idx].field1C = 0; + _vm->_globals.Bob[idx].field1C = false; continue; } if (_vm->_globals.Bob[idx].field0 == 10) { - _vm->_globals.Bob[idx].field1C = 0; + _vm->_globals.Bob[idx].field1C = false; 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; + if (_vm->_globals.Bob[idx].field12 == _vm->_globals.Bob[idx].field14) { + _vm->_globals.Bob[idx].field1C = true; } else { - _vm->_globals.Bob[idx].field14 = v2 + 1; - _vm->_globals.Bob[idx].field1C = 0; + _vm->_globals.Bob[idx].field14++; + _vm->_globals.Bob[idx].field1C = false; } - if (_vm->_globals.Bob[idx].field1C != 1) + if (!_vm->_globals.Bob[idx].field1C) goto LABEL_38; v20 = _vm->_globals.Bob[idx]._animData + 20; @@ -1196,7 +1187,7 @@ void ObjectsManager::AFF_BOB_ANIM() { _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]._modeFlag = *(v20 + 2 * v24 + 9); _vm->_globals.Bob[idx].field10 += 5; v5 = _vm->_globals.Bob[idx].field12; @@ -1210,18 +1201,16 @@ LABEL_38: v12 = idx; if ((unsigned int)(_vm->_globals.Bob[v12].field1E - 1) <= 1u) - _vm->_globals.Bob[v12].field1C = 1; + _vm->_globals.Bob[v12].field1C = true; 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) { + if (_vm->_globals.Bob[idx].field20 > 0) + _vm->_globals.Bob[idx].field20--; + if (_vm->_globals.Bob[idx].field20 != -1 && _vm->_globals.Bob[idx].field20 <= 0) { _vm->_globals.Bob[idx].field0 = 11; } else { _vm->_globals.Bob[idx].field10 = 0; @@ -1236,8 +1225,8 @@ LABEL_38: _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]._frameIndex = v21[8]; + _vm->_globals.Bob[idx]._modeFlag = v21[9]; _vm->_globals.Bob[idx].field10 += 5; v10 = _vm->_globals.Bob[idx].field12; @@ -1258,7 +1247,7 @@ LABEL_38: if (!PERSO_ON && BOBTOUS == true) { for (int v26 = 0; v26 != 35; v26++) { if (_vm->_globals.Bob[v26].field0 == 10 && !_vm->_globals.Bob[v26].field16) - _vm->_globals.Bob[v26].field1C = 1; + _vm->_globals.Bob[v26].field1C = true; } } @@ -1266,7 +1255,7 @@ LABEL_38: for (int v27 = 1; v27 < 35; v27++) { if (v27 > 20 || PERSO_ON != true) { - if ((_vm->_globals.Bob[v27].field0 == 10) && (_vm->_globals.Bob[v27].field1C == 1)) { + if ((_vm->_globals.Bob[v27].field0 == 10) && (_vm->_globals.Bob[v27].field1C)) { v14 = _vm->_globals.Bob[v27].field1E; if ((v14 != 2) && (v14 != 4)) { @@ -1298,7 +1287,7 @@ LABEL_38: for (int v28 = 1; v28 < 25; v28++) { _vm->_globals.Bob[v28]._oldY = 0; - if (_vm->_globals.Bob[v28].field0 == 10 && !_vm->_globals.Bob[v28].field16 && _vm->_globals.Bob[v28].field1C == 1) { + if (_vm->_globals.Bob[v28].field0 == 10 && !_vm->_globals.Bob[v28].field16 && _vm->_globals.Bob[v28].field1C) { CALCUL_BOB(v28); int v = _vm->_globals.Bob[v28]._oldHeight + _vm->_globals.Bob[v28]._oldY; v19 = _vm->_globals.Bob[v28]._oldX2 + v; @@ -1318,8 +1307,8 @@ void ObjectsManager::AFF_VBOB() { for (int idx = 0; idx <= 29; idx++) { if (_vm->_globals.VBob[idx].field4 == 4) { - width = getWidth(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx]._frameIndex); - height = getHeight(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx]._frameIndex); + width = getWidth(_vm->_globals.VBob[idx]._spriteData, _vm->_globals.VBob[idx]._frameIndex); + height = getHeight(_vm->_globals.VBob[idx]._spriteData, _vm->_globals.VBob[idx]._frameIndex); _vm->_graphicsManager.Restore_Mem(_vm->_graphicsManager._vesaScreen, _vm->_globals.VBob[idx]._surface, _vm->_globals.VBob[idx]._xp, @@ -1337,7 +1326,7 @@ void ObjectsManager::AFF_VBOB() { _vm->_globals.VBob[idx]._surface = _vm->_globals.freeMemory(_vm->_globals.VBob[idx]._surface); _vm->_globals.VBob[idx].field4 = 0; - _vm->_globals.VBob[idx].spriteData = 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; @@ -1365,7 +1354,7 @@ void ObjectsManager::AFF_VBOB() { _vm->_globals.VBob[idx]._oldY + height); _vm->_globals.VBob[idx].field4 = 1; - _vm->_globals.VBob[idx]._oldSpriteData = _vm->_globals.VBob[idx].spriteData; + _vm->_globals.VBob[idx]._oldSpriteData = _vm->_globals.VBob[idx]._spriteData; _vm->_globals.VBob[idx]._surface = _vm->_globals.freeMemory(_vm->_globals.VBob[idx]._surface); @@ -1375,8 +1364,8 @@ void ObjectsManager::AFF_VBOB() { } if (_vm->_globals.VBob[idx].field4 == 1) { - width = getWidth(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx]._frameIndex); - height = getHeight(_vm->_globals.VBob[idx].spriteData, _vm->_globals.VBob[idx]._frameIndex); + width = getWidth(_vm->_globals.VBob[idx]._spriteData, _vm->_globals.VBob[idx]._frameIndex); + height = getHeight(_vm->_globals.VBob[idx]._spriteData, _vm->_globals.VBob[idx]._frameIndex); _vm->_globals.VBob[idx]._surface = _vm->_globals.freeMemory(_vm->_globals.VBob[idx]._surface); @@ -1386,7 +1375,7 @@ void ObjectsManager::AFF_VBOB() { _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager._vesaScreen, surface, _vm->_globals.VBob[idx]._xp, _vm->_globals.VBob[idx]._yp, width, height); - byte *v10 = _vm->_globals.VBob[idx].spriteData; + byte *v10 = _vm->_globals.VBob[idx]._spriteData; if (*v10 == 78) { _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaScreen, v10, _vm->_globals.VBob[idx]._xp + 300, _vm->_globals.VBob[idx]._yp + 300, @@ -1394,7 +1383,7 @@ void ObjectsManager::AFF_VBOB() { 0, 0, 0); _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, - _vm->_globals.VBob[idx].spriteData, + _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); @@ -1403,7 +1392,7 @@ void ObjectsManager::AFF_VBOB() { v10, _vm->_globals.VBob[idx]._xp + 300, _vm->_globals.VBob[idx]._yp + 300, _vm->_globals.VBob[idx]._frameIndex); - _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaScreen, _vm->_globals.VBob[idx].spriteData, + _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaScreen, _vm->_globals.VBob[idx]._spriteData, _vm->_globals.VBob[idx]._xp + 300, _vm->_globals.VBob[idx]._yp + 300, _vm->_globals.VBob[idx]._frameIndex); } @@ -4056,7 +4045,7 @@ void ObjectsManager::SPECIAL_JEU() { v1 = _vm->_globals.allocMemory(0x3E8u); memcpy(v1, _vm->_graphicsManager.Palette, 0x301u); - _vm->_saveLoadManager.SAUVE_FICHIER("TEMP1.SCR", _vm->_graphicsManager._vesaScreen, 0x4B000u); + _vm->_saveLoadManager.saveFile("TEMP1.SCR", _vm->_graphicsManager._vesaScreen, 0x4B000u); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager.ofscroll = 0; @@ -4072,7 +4061,7 @@ void ObjectsManager::SPECIAL_JEU() { _vm->_graphicsManager.NB_SCREEN(); _vm->_globals.NECESSAIRE = false; - _vm->_saveLoadManager.bload("TEMP1.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP1.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP1.SCR"); PERSO_ON = false; @@ -4166,22 +4155,19 @@ void ObjectsManager::VBOB(byte *src, int idx, int xp, int yp, int 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]._spriteData = src; _vm->_globals.VBob[idx]._oldSpriteData = src; _vm->_globals.VBob[idx]._surface = _vm->_globals.freeMemory(_vm->_globals.VBob[idx]._surface); - } - - int f4 = _vm->_globals.VBob[idx].field4; - if (f4 == 2 || f4 == 4) { + } else if (_vm->_globals.VBob[idx].field4 == 2 || _vm->_globals.VBob[idx].field4 == 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]._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; + _vm->_globals.VBob[idx]._spriteData = src; } } @@ -4415,7 +4401,7 @@ int ObjectsManager::BOBPOSI(int idx) { void ObjectsManager::BOBANIM_ON(int idx) { if (_vm->_globals.Bob[idx].field16) { - _vm->_globals.Bob[idx].field16 = 0; + _vm->_globals.Bob[idx].field16 = false; _vm->_globals.Bob[idx].field10 = 5; _vm->_globals.Bob[idx]._frameIndex = 250; _vm->_globals.Bob[idx].field12 = 0; @@ -4424,7 +4410,7 @@ void ObjectsManager::BOBANIM_ON(int idx) { } void ObjectsManager::BOBANIM_OFF(int idx) { - _vm->_globals.Bob[idx].field16 = 1; + _vm->_globals.Bob[idx].field16 = true; } @@ -4521,10 +4507,9 @@ void ObjectsManager::INILINK(const Common::String &file) { 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; + _vm->_globals.Cache[v11]._spriteIndex = v8; + _vm->_globals.Cache[v11]._x = v9; + _vm->_globals.Cache[v11]._y = v10; if (!_vm->_globals.CACHE_BANQUE[1]) { _vm->_globals.Cache[v40].fieldA = 0; @@ -4533,13 +4518,13 @@ void ObjectsManager::INILINK(const Common::String &file) { v13 = _vm->_globals.CACHE_BANQUE[1]; v14 = getWidth(v13, v8); v15 = getHeight(v13, v12); - _vm->_globals.Cache[v40].fieldC = v13; - _vm->_globals.Cache[v40].field6 = v14; - _vm->_globals.Cache[v40].field8 = v15; + _vm->_globals.Cache[v40]._spriteData = v13; + _vm->_globals.Cache[v40]._width = v14; + _vm->_globals.Cache[v40]._height = v15; _vm->_globals.Cache[v40].fieldA = 1; } - if (!_vm->_globals.Cache[v40].field0 && !_vm->_globals.Cache[v40].field4 - && !_vm->_globals.Cache[v40].field2) + if (!_vm->_globals.Cache[v40]._x && !_vm->_globals.Cache[v40]._y + && !_vm->_globals.Cache[v40]._spriteIndex) _vm->_globals.Cache[v40].fieldA = 0; v36 += 5; diff --git a/engines/hopkins/saveload.cpp b/engines/hopkins/saveload.cpp index 66afa9fcdf..1510e8e248 100644 --- a/engines/hopkins/saveload.cpp +++ b/engines/hopkins/saveload.cpp @@ -40,7 +40,7 @@ void SaveLoadManager::setParent(HopkinsEngine *vm) { _vm = vm; } -bool SaveLoadManager::bsave(const Common::String &file, const void *buf, size_t n) { +bool SaveLoadManager::save(const Common::String &file, const void *buf, size_t n) { Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(file); if (f) { @@ -54,8 +54,8 @@ bool SaveLoadManager::bsave(const Common::String &file, const void *buf, size_t } // Save File -bool SaveLoadManager::SAUVE_FICHIER(const Common::String &file, const void *buf, size_t n) { - return bsave(file, buf, n); +bool SaveLoadManager::saveFile(const Common::String &file, const void *buf, size_t n) { + return save(file, buf, n); } void SaveLoadManager::initSaves() { @@ -63,10 +63,10 @@ void SaveLoadManager::initSaves() { byte data[100]; Common::fill(&data[0], &data[100], 0); - SAUVE_FICHIER(dataFilename, data, 100); + saveFile(dataFilename, data, 100); } -void SaveLoadManager::bload(const Common::String &file, byte *buf) { +void SaveLoadManager::load(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()); @@ -78,34 +78,34 @@ void SaveLoadManager::bload(const Common::String &file, byte *buf) { bool SaveLoadManager::readSavegameHeader(Common::InSaveFile *in, hopkinsSavegameHeader &header) { char saveIdentBuffer[SAVEGAME_STR_SIZE + 1]; - header.thumbnail = NULL; + 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) + header._version = in->readByte(); + if (header._version > HOPKINS_SAVEGAME_VERSION) return false; // Read in the string - header.saveName.clear(); + header._saveName.clear(); char ch; - while ((ch = (char)in->readByte()) != '\0') header.saveName += ch; + while ((ch = (char)in->readByte()) != '\0') header._saveName += ch; // Get the thumbnail - header.thumbnail = Graphics::loadThumbnail(*in); - if (!header.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(); + header._year = in->readSint16LE(); + header._month = in->readSint16LE(); + header._day = in->readSint16LE(); + header._hour = in->readSint16LE(); + header._minute = in->readSint16LE(); + header._totalFrames = in->readUint32LE(); return true; } @@ -117,7 +117,7 @@ void SaveLoadManager::writeSavegameHeader(Common::OutSaveFile *out, hopkinsSaveg out->writeByte(HOPKINS_SAVEGAME_VERSION); // Write savegame name - out->write(header.saveName.c_str(), header.saveName.size() + 1); + out->write(header._saveName.c_str(), header._saveName.size() + 1); // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); @@ -137,7 +137,7 @@ void SaveLoadManager::writeSavegameHeader(Common::OutSaveFile *out, hopkinsSaveg out->writeUint32LE(_vm->_eventsManager._gameCounter); } -Common::Error SaveLoadManager::save(int slot, const Common::String &saveName) { +Common::Error SaveLoadManager::saveGame(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; @@ -157,8 +157,8 @@ Common::Error SaveLoadManager::save(int slot, const Common::String &saveName) { // Write out the savegame header hopkinsSavegameHeader header; - header.saveName = saveName; - header.version = HOPKINS_SAVEGAME_VERSION; + header._saveName = saveName; + header._version = HOPKINS_SAVEGAME_VERSION; writeSavegameHeader(saveFile, header); // Write out the savegame data @@ -171,7 +171,7 @@ Common::Error SaveLoadManager::save(int slot, const Common::String &saveName) { return Common::kNoError; } -Common::Error SaveLoadManager::restore(int slot) { +Common::Error SaveLoadManager::loadGame(int slot) { // Try and open the save file for reading Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading( _vm->generateSaveName(slot)); @@ -184,9 +184,9 @@ Common::Error SaveLoadManager::restore(int slot) { // Read in the savegame header hopkinsSavegameHeader header; readSavegameHeader(saveFile, header); - if (header.thumbnail) - header.thumbnail->free(); - delete header.thumbnail; + if (header._thumbnail) + header._thumbnail->free(); + delete header._thumbnail; // Read in the savegame data syncSavegameData(serializer); diff --git a/engines/hopkins/saveload.h b/engines/hopkins/saveload.h index aa59fe7ba4..c2e9488223 100644 --- a/engines/hopkins/saveload.h +++ b/engines/hopkins/saveload.h @@ -36,12 +36,12 @@ 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; + uint8 _version; + Common::String _saveName; + Graphics::Surface *_thumbnail; + int _year, _month, _day; + int _hour, _minute; + int _totalFrames; }; class SaveLoadManager { @@ -55,15 +55,15 @@ 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); + bool save(const Common::String &file, const void *buf, size_t n); + bool saveFile(const Common::String &file, const void *buf, size_t n); + void load(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); + Common::Error saveGame(int slot, const Common::String &saveName); + Common::Error loadGame(int slot); /** * Converts a 16-bit thumbnail to 8 bit paletted using the currently active palette. diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index ef2ff53e19..c339b0e1ad 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -100,9 +100,9 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager.ofscroll = 0; @@ -143,7 +143,7 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { _vm->_graphicsManager.NB_SCREEN(); _vm->_globals.NECESSAIRE = false; - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); _vm->_objectsManager.PERSO_ON = false; @@ -733,7 +733,7 @@ void TalkManager::BOB_VISU_PARLE(int idx) { if ((int16)READ_LE_UINT16(v5 + 24)) { _vm->_globals.Bob[idx]._isSpriteFl = true; _vm->_globals.Bob[idx].field36 = 0; - _vm->_globals.Bob[idx].field38 = 0; + _vm->_globals.Bob[idx]._modeFlag = 0; _vm->_globals.Bob[idx]._animData = _vm->_globals.Bqe_Anim[idx]._data; _vm->_globals.Bob[idx].field0 = 10; v5 = _characterSprite; @@ -741,7 +741,7 @@ void TalkManager::BOB_VISU_PARLE(int idx) { _vm->_globals.Bob[idx].field1E = v4; _vm->_globals.Bob[idx].field20 = -1; _vm->_globals.Bob[idx].field22 = 0; - _vm->_globals.Bob[idx].offsetY = 0; + _vm->_globals.Bob[idx]._offsetY = 0; } } } @@ -946,15 +946,13 @@ void TalkManager::REPONSE(int a1, int a2) { byte *v6; uint16 v7; byte *v8; - int v9; int v10; uint16 v11; int v12; int v13; - int v14; int v15; int v16; - int v17; + bool loopCond; byte *ptr; v2 = a1; @@ -964,11 +962,11 @@ LABEL_2: if (_vm->_globals.COUCOU != g_PTRNUL) { v5 = _vm->_globals.COUCOU; for (;;) { - if ((*v5 == 'C') && (*(v5 + 1) == 'O') && (*(v5 + 2) == 'D')) { - if ((*(v5 + 3) == v2) && (*(v5 + 4) == v3)) + if (v5[0] == 'C' && v5[1] == 'O' && v5[2] == 'D') { + if (v5[3] == v2 && v5[4] == v3) v15 = 1; } - if (*v5 == 'F' && *(v5 + 1) == 'I' && *(v5 + 2) == 'N') + if (v5[0] == 'F' && v5[1] == 'I' && v5[2] == 'N') break; if (!v15) v5 = v5 + 1; @@ -980,10 +978,10 @@ LABEL_2: memset(ptr, 0, 620); v7 = 0; v12 = 0; - v14 = 0; + loopCond = false; do { v16 = 0; - if (*(v7 + v6) == 'F' && *(v6 + v7 + 1) == 'C') { + if (v6[v7] == 'F' && v6[v7 + 1] == 'C') { ++v12; assert(v12 < (620 / 20)); @@ -991,26 +989,25 @@ LABEL_2: v11 = 0; do { assert(v11 < 20); - *(v11++ + v8) = *(v7++ + v6); - if (*(v7 + v6) == 'F' && *(v6 + v7 + 1) == 'F') { + *(v11++ + v8) = v6[v7++]; + if (v6[v7] == 'F' && v6[v7] == 'F') { v16 = 1; - v9 = v11; - *(v9 + v8) = 'F'; - *(v8 + v9 + 1) = 'F'; + v8[v11] = 'F'; + v8[v11 + 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; + if (v6[v7] == 'C' && v6[v7 + 1] == 'O' && v6[v7 + 2] == 'D') + loopCond = true; + if (v16 != 1 && v6[v7] == 'F' && v6[v7 + 1] == 'I' && v6[v7 + 2] == 'N') + loopCond = true; } v6 += v7 + 1; v7 = 0; - } while (v14 != 1); - v17 = 0; + } while (!loopCond); + loopCond = false; v13 = 1; do { v10 = _vm->_scriptManager.Traduction(ptr + 20 * v13); @@ -1019,21 +1016,23 @@ LABEL_2: if (v10 == 2) v13 = _vm->_scriptManager.Control_Goto(ptr + 20 * v13); - if (v10 == 3) + else 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) { + else if (!v10 || v10 == 5) + loopCond = true; + else if (v10 == 6) { _vm->_globals.freeMemory(ptr); v2 = _vm->_objectsManager.NVZONE; v3 = _vm->_objectsManager.NVVERBE; goto LABEL_2; } - } while (v17 != 1); + } while (!loopCond); _vm->_globals.freeMemory(ptr); _vm->_globals.SAUVEGARDE->data[svField2] = 0; return; @@ -1043,37 +1042,18 @@ LABEL_2: } 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; + int indx = 0; if (a2 == 5 && _vm->_globals.SAUVEGARDE->data[svField3] == 4) { - if ((uint16)(a1 - 22) <= 1u) { + if (a1 == 22 || a1 == 23) { _vm->_objectsManager.setFlipSprite(0, false); _vm->_objectsManager.setSpriteIndex(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.BLOQUE_ANIMX(6, _vm->_objectsManager.BOBX(3)); + _vm->_objectsManager.BLOQUE_ANIMX(8, _vm->_objectsManager.BOBX(3)); + } else { // a1 == 23 + _vm->_objectsManager.BLOQUE_ANIMX(6, _vm->_objectsManager.BOBX(4)); + _vm->_objectsManager.BLOQUE_ANIMX(8, _vm->_objectsManager.BOBX(4)); } _vm->_objectsManager.BOBANIM_OFF(3); _vm->_objectsManager.BOBANIM_OFF(4); @@ -1082,46 +1062,46 @@ void TalkManager::REPONSE2(int a1, int a2) { _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); + while (_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; + + switch (_vm->_globals.ECRAN) { + case 35: + indx = 201; + break; + case 36: + indx = 203; + break; + case 37: + indx = 205; + break; + case 38: + indx = 207; + break; + case 39: + indx = 209; + break; + case 40: + indx = 211; + break; + case 41: + indx = 213; + break; + } + _vm->_globals.SAUVEGARDE->data[indx] = 2; _vm->_objectsManager.ZONE_OFF(22); _vm->_objectsManager.ZONE_OFF(23); - } - if ((uint16)(a1 - 20) <= 1u) { + } else if (a1 == 20 || a1 == 21) { _vm->_objectsManager.setFlipSprite(0, true); _vm->_objectsManager.setSpriteIndex(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.BLOQUE_ANIMX(5, _vm->_objectsManager.BOBX(1)); + _vm->_objectsManager.BLOQUE_ANIMX(7, _vm->_objectsManager.BOBX(1)); + } else { // a1 == 21 + _vm->_objectsManager.BLOQUE_ANIMX(5, _vm->_objectsManager.BOBX(2)); + _vm->_objectsManager.BLOQUE_ANIMX(7, _vm->_objectsManager.BOBX(2)); } _vm->_objectsManager.BOBANIM_OFF(1); _vm->_objectsManager.BOBANIM_OFF(2); @@ -1130,24 +1110,33 @@ void TalkManager::REPONSE2(int a1, int a2) { _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); + while (_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; + switch (_vm->_globals.ECRAN) { + case 35: + indx = 200; + break; + case 36: + indx = 202; + break; + case 37: + indx = 204; + break; + case 38: + indx = 206; + break; + case 39: + indx = 208; + break; + case 40: + indx = 210; + break; + case 41: + indx = 212; + break; + } + _vm->_globals.SAUVEGARDE->data[indx] = 2; _vm->_objectsManager.ZONE_OFF(21); _vm->_objectsManager.ZONE_OFF(20); } @@ -1206,9 +1195,9 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager._lineNbr == SCREEN_WIDTH) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x4B000u); else if (_vm->_graphicsManager._lineNbr == (SCREEN_WIDTH * 2)) - _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); + _vm->_saveLoadManager.saveFile(_vm->_globals.NFICHIER, _vm->_graphicsManager._vesaScreen, 0x96000u); if (!_vm->_graphicsManager._lineNbr) _vm->_graphicsManager.ofscroll = 0; @@ -1272,7 +1261,7 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { if (_vm->_globals.SORTIE == 101) _vm->_globals.SORTIE = 0; - _vm->_saveLoadManager.bload("TEMP.SCR", _vm->_graphicsManager._vesaScreen); + _vm->_saveLoadManager.load("TEMP.SCR", _vm->_graphicsManager._vesaScreen); g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); _vm->_objectsManager.PERSO_ON = false; -- cgit v1.2.3