diff options
author | Paul Gilbert | 2012-11-24 22:25:19 +1100 |
---|---|---|
committer | Paul Gilbert | 2012-11-24 22:26:06 +1100 |
commit | d52ae2f47be379172ba63810d8c83cd33585ffe6 (patch) | |
tree | ea47c9fb38fe7673e8de37f877cefb0320a80e85 | |
parent | 6db4aca751e3289ea69a4f919d8234e24c6df31d (diff) | |
download | scummvm-rg350-d52ae2f47be379172ba63810d8c83cd33585ffe6.tar.gz scummvm-rg350-d52ae2f47be379172ba63810d8c83cd33585ffe6.tar.bz2 scummvm-rg350-d52ae2f47be379172ba63810d8c83cd33585ffe6.zip |
HOPKINS: Clean-up of CHANGE_TETE to fix switching characters
-rw-r--r-- | engines/hopkins/globals.h | 16 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 206 | ||||
-rw-r--r-- | engines/hopkins/objects.h | 2 | ||||
-rw-r--r-- | engines/hopkins/saveload.cpp | 14 | ||||
-rw-r--r-- | engines/hopkins/saveload.h | 2 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 18 |
6 files changed, 130 insertions, 128 deletions
diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 84eca3b688..980593a235 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -204,11 +204,11 @@ struct HopkinsItem { int field2; }; -struct Sauvegarde1 { - int field0; - int field1; +struct CharacterLocation { + int xp; + int yp; int field2; - int field3; + int location; int field4; }; @@ -274,12 +274,14 @@ enum SauvegardeOffset { , svField401 = 401 }; +enum PlayerCharacter { CHARACTER_HOPKINS = 0, CHARACTER_HOPKINS_CLONE = 1, CHARACTER_2 = 2 }; + // TODO: Sauvegrade1 fields should really be mapped into data array struct Sauvegarde { byte data[0x802]; - Sauvegarde1 field360; - Sauvegarde1 field370; - Sauvegarde1 field380; + CharacterLocation field360; + CharacterLocation field370; + CharacterLocation field380; int16 inventory[35]; // Originally at offset 1300 of data array }; diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index e4c5f0ac05..8b43ef84e1 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -2743,14 +2743,14 @@ void ObjectsManager::BTGAUCHE() { && !_vm->_globals.PLAN_FLAG && (uint16)(destX - 533) <= 0x1Au && (uint16)(destY - 26) <= 0x21u) { - CHANGE_TETE(1, 0); + CHANGE_TETE(CHARACTER_HOPKINS_CLONE, CHARACTER_HOPKINS); return; } if (_vm->_globals.SAUVEGARDE->data[svField356] == 1 && !_vm->_globals.PLAN_FLAG && (uint16)(destX - 533) <= 0x1Au && (uint16)(destY - 26) <= 0x21u) { - CHANGE_TETE(2, 0); + CHANGE_TETE(CHARACTER_2, CHARACTER_HOPKINS); return; } if (_vm->_globals.SAUVEGARDE->data[svField357] == 1) { @@ -2758,14 +2758,14 @@ void ObjectsManager::BTGAUCHE() { && !_vm->_globals.PLAN_FLAG && (uint16)(destX - 533) <= 0x1Au && (uint16)(destY - 26) <= 0x21u) { - CHANGE_TETE(0, 1); + CHANGE_TETE(CHARACTER_HOPKINS, CHARACTER_HOPKINS_CLONE); return; } if (_vm->_globals.SAUVEGARDE->data[svField355] == 1 && !_vm->_globals.PLAN_FLAG && (uint16)(destX - 567) <= 0x1Au && (uint16)(destY - 26) <= 0x21u) { - CHANGE_TETE(0, 2); + CHANGE_TETE(CHARACTER_HOPKINS, CHARACTER_2); return; } } @@ -3068,117 +3068,117 @@ void ObjectsManager::CLEAR_ECRAN() { } // Change Face/Head -void ObjectsManager::CHANGE_TETE(int a1, int a2) { - int v2; - Sauvegarde1 *v3; - Sauvegarde1 *v4; - Sauvegarde1 *v5; - Sauvegarde1 *v6; - Sauvegarde1 *v7; - Sauvegarde1 *v8; - Sauvegarde1 *v9; +void ObjectsManager::CHANGE_TETE(PlayerCharacter a1, PlayerCharacter a2) { + CharacterLocation *loc; CH_TETE = 1; _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, 532, 25, 65, 40, _vm->_graphicsManager.VESA_BUFFER, 532, 25); _vm->_graphicsManager.Ajoute_Segment_Vesa(532, 25, 597, 65); _vm->_globals.NOT_VERIF = 1; _vm->_globals.chemin = (int16 *)g_PTRNUL; - if (a1 == 2) { - if (!a2) { - if (_vm->_globals.SAUVEGARDE->data[svField188] == _vm->_globals.ECRAN) { - CH_TETE = 0; - v3 = &_vm->_globals.SAUVEGARDE->field380; - v3->field0 = XSPR(0); - v3->field1 = YSPR(0); - v3->field2 = 64; - v3->field3 = _vm->_globals.ECRAN; - v3->field4 = Sprite[0].field0; - SPRITE_OFF(1); - SPRITE(_vm->_globals.TETE, v3->field0, v3->field1, 1, 3, v3->field4, 0, 20, 127); - SPRITE_ON(1); - SPRITE_OFF(0); - _vm->_globals.SAUVEGARDE->data[svField354] = 0; - _vm->_globals.SAUVEGARDE->data[svField356] = 0; - _vm->_globals.SAUVEGARDE->data[svField357] = 1; - T_RECTIF = 0; - v4 = &_vm->_globals.SAUVEGARDE->field370; - _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); - _vm->_globals.PERSO_TYPE = 0; - SPRITE(_vm->_globals.PERSO, v4->field0, v4->field1, 0, 64, v4->field4, 0, 34, 190); -LABEL_9: - SPRITE_ON(0); - return; - } - } - } - if (!a1) { - if (a2 == 2 && _vm->_globals.SAUVEGARDE->data[svField193] == _vm->_globals.ECRAN) { - CH_TETE = 0; - v5 = &_vm->_globals.SAUVEGARDE->field370; - v5->field0 = XSPR(0); - v5->field1 = YSPR(0); - v5->field2 = 64; - v5->field3 = _vm->_globals.ECRAN; - v5->field4 = Sprite[0].fieldC; - SPRITE_OFF(1); - SPRITE(_vm->_globals.TETE, v5->field0, v5->field1, 1, 2, v5->field4, 0, 34, 190); - SPRITE_ON(1); - SPRITE_OFF(0); - _vm->_globals.SAUVEGARDE->data[svField354] = 0; - _vm->_globals.SAUVEGARDE->data[svField356] = 1; - _vm->_globals.SAUVEGARDE->data[svField357] = 0; - v6 = &_vm->_globals.SAUVEGARDE->field380; - _vm->_fileManager.CONSTRUIT_SYSTEM("PSAMAN.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); - _vm->_globals.PERSO_TYPE = 2; - SPRITE(_vm->_globals.PERSO, v6->field0, v6->field1, 0, 64, v6->field4, 0, 20, 127); - goto LABEL_9; - } - v7 = &_vm->_globals.SAUVEGARDE->field370; - v7->field0 = XSPR(0); - v7->field1 = YSPR(0); - v7->field2 = 64; - v7->field3 = _vm->_globals.ECRAN; - v7->field4 = Sprite[0].fieldC; - } - if (a1 == 1) { - v8 = &_vm->_globals.SAUVEGARDE->field360; - v8->field0 = XSPR(0); - v8->field1 = YSPR(0); - v8->field2 = 64; - v8->field3 = _vm->_globals.ECRAN; - v8->field4 = Sprite[0].fieldC; - } - if (a1 == 2) { - v9 = &_vm->_globals.SAUVEGARDE->field380; - v9->field0 = XSPR(0); - v9->field1 = YSPR(0); - v9->field2 = 64; - v9->field3 = _vm->_globals.ECRAN; - v9->field4 = Sprite[0].fieldC; - } - if (!a2) { - _vm->_globals.SAUVEGARDE->data[svField121] = 0; + + if (a1 == CHARACTER_2 && !a2 && _vm->_globals.SAUVEGARDE->field370.location) { + CH_TETE = 0; + loc = &_vm->_globals.SAUVEGARDE->field380; + loc->xp = XSPR(0); + loc->yp = YSPR(0); + loc->field2 = 64; + loc->location = _vm->_globals.ECRAN; + loc->field4 = Sprite[0].field0; + + SPRITE_OFF(1); + SPRITE(_vm->_globals.TETE, loc->xp, loc->yp, 1, 3, loc->field4, 0, 20, 127); + SPRITE_ON(1); + SPRITE_OFF(0); + _vm->_globals.SAUVEGARDE->data[svField354] = 0; _vm->_globals.SAUVEGARDE->data[svField356] = 0; _vm->_globals.SAUVEGARDE->data[svField357] = 1; - _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField188]; - } - if (a2 == 1) { - _vm->_globals.SAUVEGARDE->data[svField121] = 1; - _vm->_globals.SAUVEGARDE->data[svField354] = 1; - _vm->_globals.SAUVEGARDE->data[svField356] = 0; - _vm->_globals.SAUVEGARDE->data[svField357] = 0; - _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField183]; - } - if (a2 == 2) { - _vm->_globals.SAUVEGARDE->data[svField121] = 0; + T_RECTIF = 0; + + loc = &_vm->_globals.SAUVEGARDE->field370; + _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); + _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_globals.PERSO_TYPE = 0; + SPRITE(_vm->_globals.PERSO, loc->xp, loc->yp, 0, 64, loc->field4, 0, 34, 190); + SPRITE_ON(0); + _vm->_globals.HOPKINS_DATA(); + } else if (!a1 && a2 == CHARACTER_2 && _vm->_globals.SAUVEGARDE->field380.location == _vm->_globals.ECRAN) { + CH_TETE = 0; + loc = &_vm->_globals.SAUVEGARDE->field370; + loc->xp = XSPR(0); + loc->yp = YSPR(0); + loc->field2 = 64; + loc->location = _vm->_globals.ECRAN; + loc->field4 = Sprite[0].fieldC; + SPRITE_OFF(1); + SPRITE(_vm->_globals.TETE, loc->xp, loc->yp, 1, 2, loc->field4, 0, 34, 190); + SPRITE_ON(1); + SPRITE_OFF(0); _vm->_globals.SAUVEGARDE->data[svField354] = 0; _vm->_globals.SAUVEGARDE->data[svField356] = 1; _vm->_globals.SAUVEGARDE->data[svField357] = 0; - v2 = _vm->_globals.SAUVEGARDE->data[svField193]; - _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->data[svField193]; + + loc = &_vm->_globals.SAUVEGARDE->field380; + _vm->_fileManager.CONSTRUIT_SYSTEM("PSAMAN.SPR"); + _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_globals.PERSO_TYPE = 2; + SPRITE(_vm->_globals.PERSO, loc->xp, loc->yp, 0, 64, loc->field4, 0, 20, 127); + SPRITE_ON(0); + _vm->_globals.HOPKINS_DATA(); + } else { + switch (a1) { + case CHARACTER_HOPKINS: + loc = &_vm->_globals.SAUVEGARDE->field370; + loc->xp = XSPR(0); + loc->yp = YSPR(0); + loc->field2 = 64; + loc->location = _vm->_globals.ECRAN; + loc->field4 = Sprite[0].fieldC; + break; + case CHARACTER_HOPKINS_CLONE: + loc = &_vm->_globals.SAUVEGARDE->field360; + loc->xp = XSPR(0); + loc->yp = YSPR(0); + loc->field2 = 64; + loc->location = _vm->_globals.ECRAN; + loc->field4 = Sprite[0].fieldC; + break; + case CHARACTER_2: + loc = &_vm->_globals.SAUVEGARDE->field380; + loc->xp = XSPR(0); + loc->yp = YSPR(0); + loc->field2 = 64; + loc->location = _vm->_globals.ECRAN; + loc->field4 = Sprite[0].fieldC; + break; + default: + break; + } + + switch (a2) { + case CHARACTER_HOPKINS: + _vm->_globals.SAUVEGARDE->data[svField121] = 0; + _vm->_globals.SAUVEGARDE->data[svField354] = 0; + _vm->_globals.SAUVEGARDE->data[svField356] = 0; + _vm->_globals.SAUVEGARDE->data[svField357] = 1; + _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->field370.location; + break; + case CHARACTER_HOPKINS_CLONE: + _vm->_globals.SAUVEGARDE->data[svField121] = 1; + _vm->_globals.SAUVEGARDE->data[svField354] = 1; + _vm->_globals.SAUVEGARDE->data[svField356] = 0; + _vm->_globals.SAUVEGARDE->data[svField357] = 0; + _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->field360.location; + break; + case CHARACTER_2: + _vm->_globals.SAUVEGARDE->data[svField121] = 0; + _vm->_globals.SAUVEGARDE->data[svField354] = 0; + _vm->_globals.SAUVEGARDE->data[svField356] = 1; + _vm->_globals.SAUVEGARDE->data[svField357] = 0; + _vm->_globals.SORTIE = _vm->_globals.SAUVEGARDE->field380.location; + break; + } } } diff --git a/engines/hopkins/objects.h b/engines/hopkins/objects.h index f8d959c7fa..aec0ef1c4c 100644 --- a/engines/hopkins/objects.h +++ b/engines/hopkins/objects.h @@ -189,7 +189,7 @@ public: void PARADISE(); void CLEAR_ECRAN(); - void CHANGE_TETE(int a1, int a2); + void CHANGE_TETE(PlayerCharacter a1, PlayerCharacter a2); void VERIFTAILLE(); void PACOURS_PROPRE(int16 *a1); int16 *PARC_VOITURE(int a1, int a2, int a3, int a4); diff --git a/engines/hopkins/saveload.cpp b/engines/hopkins/saveload.cpp index cd7c32c345..958737d773 100644 --- a/engines/hopkins/saveload.cpp +++ b/engines/hopkins/saveload.cpp @@ -235,19 +235,19 @@ void SaveLoadManager::createThumbnail(Graphics::Surface *s) { void SaveLoadManager::syncSavegameData(Common::Serializer &s) { s.syncBytes(&_vm->_globals.SAUVEGARDE->data[0], 0x802); - syncSauvegarde1(s, _vm->_globals.SAUVEGARDE->field360); - syncSauvegarde1(s, _vm->_globals.SAUVEGARDE->field370); - syncSauvegarde1(s, _vm->_globals.SAUVEGARDE->field380); + syncCharacterLocation(s, _vm->_globals.SAUVEGARDE->field360); + syncCharacterLocation(s, _vm->_globals.SAUVEGARDE->field370); + syncCharacterLocation(s, _vm->_globals.SAUVEGARDE->field380); for (int i = 0; i < 35; ++i) s.syncAsSint16LE(_vm->_globals.SAUVEGARDE->inventory[i]); } -void SaveLoadManager::syncSauvegarde1(Common::Serializer &s, Sauvegarde1 &item) { - s.syncAsSint16LE(item.field0); - s.syncAsSint16LE(item.field1); +void SaveLoadManager::syncCharacterLocation(Common::Serializer &s, CharacterLocation &item) { + s.syncAsSint16LE(item.xp); + s.syncAsSint16LE(item.yp); s.syncAsSint16LE(item.field2); - s.syncAsSint16LE(item.field3); + s.syncAsSint16LE(item.location); s.syncAsSint16LE(item.field4); } diff --git a/engines/hopkins/saveload.h b/engines/hopkins/saveload.h index 647c64d2e7..f4f94995a9 100644 --- a/engines/hopkins/saveload.h +++ b/engines/hopkins/saveload.h @@ -50,7 +50,7 @@ private: void createThumbnail(Graphics::Surface *s); void syncSavegameData(Common::Serializer &s); - void syncSauvegarde1(Common::Serializer &s, Sauvegarde1 &item); + void syncCharacterLocation(Common::Serializer &s, CharacterLocation &item); public: void setParent(HopkinsEngine *vm); diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index e8f1fff6d5..22c8a65dd9 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -47,9 +47,9 @@ int ScriptManager::Traduction(byte *a1) { char v48; char v49; int v50; - Sauvegarde1 *v51; + CharacterLocation *v51; int v52; - Sauvegarde1 *v53; + CharacterLocation *v53; int v54; int v55; int v56; @@ -1958,10 +1958,10 @@ LABEL_1141: ++v71; } while (v71 <= 29); v51 = &_vm->_globals.SAUVEGARDE->field370; - v51->field0 = _vm->_objectsManager.XSPR(0); - v51->field1 = _vm->_objectsManager.YSPR(0); + v51->xp = _vm->_objectsManager.XSPR(0); + v51->yp = _vm->_objectsManager.YSPR(0); v51->field2 = 57; - v51->field3 = 97; + v51->location = 97; _vm->_globals.SAUVEGARDE->data[svField121] = 1; _vm->_globals.SAUVEGARDE->data[svField352] = 1; _vm->_globals.SAUVEGARDE->data[svField353] = 1; @@ -2186,10 +2186,10 @@ LABEL_1141: _vm->_animationManager.PLAY_SEQ("RESUF.SEQ", 1, 24, 1); _vm->_animationManager.NO_SEQ = false; v53 = &_vm->_globals.SAUVEGARDE->field380; - v53->field0 = 404; - v53->field1 = 395; + v53->xp = 404; + v53->yp = 395; v53->field2 = 64; - v53->field3 = _vm->_globals.ECRAN; + v53->location = _vm->_globals.ECRAN; v54 = _vm->_globals.STAILLE[790 / 2]; if (_vm->_globals.STAILLE[790 / 2] < 0) @@ -2202,7 +2202,7 @@ LABEL_1141: _vm->_globals.SAUVEGARDE->data[svField355] = 1; _vm->_objectsManager.DEUXPERSO = true; _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 373, 191, 3); - _vm->_objectsManager.SPRITE(_vm->_globals.TETE, v53->field0, v53->field1, 1, 3, v53->field4, 0, 20, 127); + _vm->_objectsManager.SPRITE(_vm->_globals.TETE, v53->xp, v53->yp, 1, 3, v53->field4, 0, 20, 127); _vm->_objectsManager.SPRITE_ON(1); } if (v76 == 245) { |