diff options
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/anim.cpp | 129 | ||||
-rw-r--r-- | engines/hopkins/computer.cpp | 76 | ||||
-rw-r--r-- | engines/hopkins/dialogs.cpp | 74 | ||||
-rw-r--r-- | engines/hopkins/events.cpp | 35 | ||||
-rw-r--r-- | engines/hopkins/files.cpp | 4 | ||||
-rw-r--r-- | engines/hopkins/font.cpp | 178 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 42 |
7 files changed, 203 insertions, 335 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 43b7229f19..ee959d169d 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -41,7 +41,6 @@ AnimationManager::AnimationManager() { // Play Anim void AnimationManager::PLAY_ANM(const Common::String &filename, uint32 rate1, uint32 rate2, uint32 rate3) { int v4; - int v5; bool hasScreenCopy; byte *screenCopy = NULL; byte *v10 = NULL; @@ -214,7 +213,7 @@ LABEL_58: memcpy(screenCopy, v10, 0x4B000u); - v5 = 0; + int v5 = 0; do { memset(ptr, 0, 0x13u); if (f.read(ptr, 16) != 16) @@ -245,25 +244,15 @@ LABEL_58: // Play Anim 2 void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint32 a3, uint32 a4) { - byte *v4; int v5; - int v6; int v8; byte *ptr; - byte *ptra; int v11; byte *v12; byte *v13; int v15; - int v16; - int v17; - int v18; - int v19; - int v20; - char v21; size_t nbytes; byte buf[6]; - char v25; Common::File f; if (_vm->shouldQuit()) @@ -271,11 +260,6 @@ void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint v8 = 0; while (!_vm->shouldQuit()) { - v17 = 0; - v16 = 0; - v19 = 0; - v18 = 0; - v20 = 1; memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u); _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR"); @@ -298,12 +282,12 @@ void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint f.read(_vm->_graphicsManager.Palette, 0x320u); f.read(&buf, 4); nbytes = f.readUint32LE(); - v21 = f.readUint32LE(); - v20 = f.readUint16LE(); - v19 = f.readUint16LE(); - v18 = f.readUint16LE(); - v17 = f.readUint16LE(); - v16 = f.readUint16LE(); + f.readUint32LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); f.read(v12, nbytes); @@ -367,7 +351,6 @@ void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); - v4 = &_vm->_graphicsManager.Palette[769]; _vm->_graphicsManager.Cls_Pal(); _vm->_graphicsManager.DD_Lock(); _vm->_graphicsManager.Cls_Video(); @@ -428,7 +411,6 @@ LABEL_48: if (f.read(v13, 0x10) != 0x10) v5 = -1; - v25 = 0; if (strncmp((const char *)v13, "IMAGE=", 6)) v5 = -1; @@ -473,7 +455,6 @@ LABEL_88: g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); - v4 = &_vm->_graphicsManager.Palette[769]; _vm->_graphicsManager.Cls_Pal(); _vm->_graphicsManager.DD_Lock(); _vm->_graphicsManager.Cls_Video(); @@ -538,7 +519,6 @@ LABEL_88: g_system->getSavefileManager()->removeSavefile("TEMP.SCR"); memcpy(_vm->_graphicsManager.Palette, _vm->_graphicsManager.OLD_PAL, 0x301u); - v4 = &_vm->_graphicsManager.Palette[769]; _vm->_graphicsManager.Cls_Pal(); _vm->_graphicsManager.DD_Lock(); _vm->_graphicsManager.Cls_Video(); @@ -591,6 +571,7 @@ LABEL_114: f.close(); if (_vm->_graphicsManager.FADE_LINUX == 2 && !v8) { + byte *ptra; ptra = _vm->_globals.dos_malloc2(0x4B000u); f.seek(0); @@ -598,16 +579,18 @@ LABEL_114: f.read(_vm->_graphicsManager.Palette, 0x320u); f.read(&buf, 4u); nbytes = f.readUint32LE(); - v21 = f.readUint32LE(); - v20 = f.readUint16LE(); - v19 = f.readUint16LE(); - v18 = f.readUint16LE(); - v17 = f.readUint16LE(); - v16 = f.readUint16LE(); + + f.readUint32LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.read(v12, nbytes); memcpy(ptra, v12, 0x4B000u); - v6 = 0; + int v6 = 0; do { memset(&buf, 0, 6u); memset(v13, 0, 0x13u); @@ -767,17 +750,9 @@ void AnimationManager::CLEAR_ANIM() { int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filename) { byte *v3; byte *v4; - int v7; - int v8; - int width; - int height; byte *v13; - int v16; - int v17; byte *ptr; byte *v19; - int v20; - int v21; int result = 0; _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename); _vm->_globals.Bank[idx].field1C = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER); @@ -797,20 +772,22 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam if (_vm->_globals.Bank[idx].fileHeader) { _vm->_globals.Bank[idx].data = v3; - v7 = 0; - v8 = 0; + bool loopCond = false; + int v8 = 0; + int width; + int height; do { ptr = v4; width = _vm->_objectsManager.Get_Largeur(v4, v8); height = _vm->_objectsManager.Get_Hauteur(ptr, v8); v4 = ptr; if (!width && !height) - v7 = 1; - if (!v7) + loopCond = true; + if (!loopCond) ++v8; if (v8 > 249) - v7 = 1; - } while (v7 != 1); + loopCond = true; + } while (!loopCond); if (v8 <= 249) { _vm->_globals.Bank[idx].field1A = v8; @@ -830,16 +807,16 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam v13 = v19; if (_vm->_globals.Bank[idx].field1A > 0) { - for (int v14 = 0; v14 < _vm->_globals.Bank[idx].field1A; ++v14) { - v16 = (int16)READ_LE_UINT16(v13); - v17 = (int16)READ_LE_UINT16(v13 + 2); - v21 = (int16)READ_LE_UINT16(v13 + 4); - v20 = (int16)READ_LE_UINT16(v13 + 6); + for (int objIdx = 0; objIdx < _vm->_globals.Bank[idx].field1A; ++objIdx) { + int x1 = (int16)READ_LE_UINT16(v13); + int y1 = (int16)READ_LE_UINT16(v13 + 2); + int x2 = (int16)READ_LE_UINT16(v13 + 4); + int y2 = (int16)READ_LE_UINT16(v13 + 6); v13 += 8; - _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, v14, v16, v17, 0); + _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, objIdx, x1, y1, 0); if (_vm->_globals.Bank[idx].fileHeader == 2) - _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, v14, v21, v20, 1); + _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx].data, objIdx, x2, y2, 1); } } @@ -1135,19 +1112,11 @@ LABEL_59: void AnimationManager::PLAY_SEQ2(const Common::String &file, uint32 rate1, uint32 rate2, uint32 rate3) { bool v4; - bool v5; int v7; byte *ptr = NULL; - byte *ptra; byte *v10; byte *v11 = NULL; int v13; - int v14; - int v15; - int v16; - int v17; - int v18; - char v19; size_t nbytes; Common::File f; @@ -1156,11 +1125,6 @@ void AnimationManager::PLAY_SEQ2(const Common::String &file, uint32 rate1, uint3 if (_vm->shouldQuit()) return; - v15 = 0; - v14 = 0; - v17 = 0; - v16 = 0; - v18 = 1; _vm->_eventsManager.souris_flag = false; v10 = _vm->_graphicsManager.VESA_SCREEN; v11 = _vm->_globals.dos_malloc2(0x16u); @@ -1173,12 +1137,12 @@ void AnimationManager::PLAY_SEQ2(const Common::String &file, uint32 rate1, uint3 f.read(_vm->_graphicsManager.Palette, 0x320u); f.skip(4); nbytes = f.readUint32LE(); - v19 = f.readUint32LE(); - v18 = f.readUint16LE(); - v17 = f.readUint16LE(); - v16 = f.readUint16LE(); - v15 = f.readUint16LE(); - v14 = f.readUint16LE(); + f.readUint32LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); f.read(v10, nbytes); if (_vm->_graphicsManager.WinScan / _vm->_graphicsManager.Winbpp > SCREEN_WIDTH) { @@ -1298,6 +1262,7 @@ LABEL_53: } LABEL_54: if (_vm->_graphicsManager.FADE_LINUX == 2 && !v7) { + byte *ptra; ptra = _vm->_globals.dos_malloc2(0x4B000u); f.seek(0); @@ -1305,16 +1270,18 @@ LABEL_54: f.read(_vm->_graphicsManager.Palette, 0x320u); f.skip(4); nbytes = f.readUint32LE(); - v19 = f.readUint32LE(); - v18 = f.readUint16LE(); - v17 = f.readUint16LE(); - v16 = f.readUint16LE(); - v15 = f.readUint16LE(); - v14 = f.readUint16LE(); + + f.readUint32LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.readUint16LE(); + f.read(v10, nbytes); memcpy(ptra, v10, 0x4B000u); - v5 = false; + bool v5 = false; do { memset(v11, 0, 0x13u); if (f.read(v11, 16) != 16) diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index ee322cdda2..d2e1209516 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -100,17 +100,7 @@ void ComputerManager::settextposition(int yp, int xp) { void ComputerManager::COMPUT_HOPKINS(ComputerEnum mode) { bool passwordMatch; - bool numericFlag; char *v3; - int v4; - char v5; - char *v6; - int v7; - char v8; - char *v9; - int v10; - char v11; - char v12; char s[12]; const char *s2; @@ -138,16 +128,15 @@ void ComputerManager::COMPUT_HOPKINS(ComputerEnum mode) { outtext(Common::String(MenuText[4]._line)); settextposition(14, 35); - v3 = &s[0]; - memset(s, 0, 8u); + memset(s, 0, 12); TXT4(280, 224, 8); - strcpy(s, Sup_string); + v3 = &s[0]; if (mode == COMPUTER_HOPKINS) { s2 = "HOPKINS"; - v4 = 8; - v5 = 1; + int v4 = 8; + char v5 = 1; do { if (!v4) break; @@ -158,28 +147,28 @@ void ComputerManager::COMPUT_HOPKINS(ComputerEnum mode) { passwordMatch = true; } if (mode == COMPUTER_SAMANTHAS) { - v6 = &s[0]; + char *v6 = &s[0]; s2 = "328MHZA"; - v7 = 8; - v8 = 1; + int v7 = 8; + bool v8 = true; do { if (!v7) break; - v8 = *v6++ == *s2++; + v8 = (*v6++ == *s2++); --v7; } while (v8); if (v8) passwordMatch = true; } if (mode == COMPUTER_PUBLIC) { - v9 = &s[0]; + char *v9 = &s[0]; s2 = "ALLFREE"; - v10 = 8; - v11 = 1; + int v10 = 8; + bool v11 = true; do { if (!v10) break; - v11 = *v9++ == *s2++; + v11 = (*v9++ == *s2++); --v10; } while (v11); if (v11) @@ -229,18 +218,21 @@ void ComputerManager::COMPUT_HOPKINS(ComputerEnum mode) { outtext2(Common::String(MenuText[16]._line)); } + bool numericFlag = false; + char v12; do { v12 = _vm->_eventsManager.keywin(); if (_vm->shouldQuit()) return; - numericFlag = false; if ((uint16)(v12 - 48) <= 8u) numericFlag = true; } while (!numericFlag); - if (v12 == 48) + // 0 - Quit + if (v12 == '0') break; + // 1 - Games if (v12 == '1') { GAMES(); } else if (mode == COMPUTER_HOPKINS) { @@ -1090,15 +1082,11 @@ void ComputerManager::PRINT_HSCORE(byte *objectData, int a2, int a3, int a4) { } int ComputerManager::DEP_BALLE() { - int v0; int16 v1; - int v2; - int16 v4; - - v4 = 0; + int16 v4 = 0; //(signed int)(6.0 * (long double)_vm->getRandomNumber( rand() / 2147483648.0) + 1; // TODO: Figure out random number - v0 = _vm->getRandomNumber(6); + int v0 = _vm->getRandomNumber(6); if (CASSESPEED == 1) { CASSEP1 = 1; CASSEP2 = 1; @@ -1145,7 +1133,7 @@ int ComputerManager::DEP_BALLE() { if ((uint16)(BALLE.y - 186) <= 8u) { _vm->_soundManager.PLAY_SAMPLE(2, 6); if (BALLE.x > RAQX - 2) { - v2 = BALLE.x + 6; + int v2 = BALLE.x + 6; if (v2 < RAQX + 36) { BALLEVERTI = 0; if (v2 <= RAQX + 15) { @@ -1178,31 +1166,23 @@ int ComputerManager::DEP_BALLE() { void ComputerManager::VERIFBRIQUES() { - int v0; int v1; int v2; int v3; int v4; - int v5; - int v6; - int v7; - uint16 v8; - int16 *v9; int v10; int v11; - int v12; - int v13; - v7 = 0; + int v7 = 0; //v6 = (signed int)(6.0 * (long double)rand() / 2147483648.0) + 1; // TODO: Check if correct - v6 = _vm->getRandomNumber(6) + 1; - v0 = BALLE.x; - v13 = BALLE.y; - v5 = BALLE.x + 6; - v12 = BALLE.y + 6; - v9 = CASSETAB; - v8 = 0; + int v6 = _vm->getRandomNumber(6) + 1; + int v0 = BALLE.x; + int v13 = BALLE.y; + int v5 = BALLE.x + 6; + int v12 = BALLE.y + 6; + int16 *v9 = CASSETAB; + uint16 v8 = 0; do { v1 = v9[v8]; v11 = v9[v8 + 1]; diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index e20409a3b4..000afed3c8 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -303,25 +303,6 @@ void DialogsManager::showOptionsDialog() { } void DialogsManager::showInventory() { - size_t filesize; - int v4; - int v6; - byte *v7; - int v8; - int v9; - int v10; - int v11; - int v12; - int v13; - int v15; - int v16; - int v17; - int v18; - int v19; - int v20; - Common::File f; - - v13 = 0; if (!VIRE_INVENT && !AFFINVEN && !_vm->_globals.DESACTIVE_INVENT) { _vm->_graphicsManager.no_scroll = 1; _vm->_objectsManager.FLAG_VISIBLE_EFFACE = 4; @@ -352,34 +333,35 @@ LABEL_7: break; } + Common::File f; if (!f.open(_vm->_globals.NFICHIER)) error("Error opening file - %s", _vm->_globals.NFICHIER.c_str()); - filesize = f.size(); + size_t filesize = f.size(); _vm->_dialogsManager.Winventaire = _vm->_globals.dos_malloc2(filesize); _vm->_fileManager.bload_it(f, _vm->_dialogsManager.Winventaire, filesize); f.close(); _vm->_fileManager.CONSTRUIT_SYSTEM("INVENT2.SPR"); inventaire2 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); - v19 = _vm->_graphicsManager.ofscroll + 152; - v18 = _vm->_objectsManager.Get_Largeur(_vm->_dialogsManager.Winventaire, 0); - v17 = _vm->_objectsManager.Get_Hauteur(_vm->_dialogsManager.Winventaire, 0); + int v19 = _vm->_graphicsManager.ofscroll + 152; + int v18 = _vm->_objectsManager.Get_Largeur(_vm->_dialogsManager.Winventaire, 0); + int v17 = _vm->_objectsManager.Get_Hauteur(_vm->_dialogsManager.Winventaire, 0); inventairex = v19; inventairey = 114; inventairel = v18; inventaireh = v17; _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire, v19 + 300, 414, 0, 0, 0, 0); - v15 = 0; - v4 = 0; + int v15 = 0; + int v4 = 0; for (int v14 = 1; v14 <= 5; v14++) { - v16 = 0; + int v16 = 0; for (int v5 = 1; v5 <= 6; v5++) { ++v4; - v6 = _vm->_globals.INVENTAIRE[v4]; + int v6 = _vm->_globals.INVENTAIRE[v4]; if (v6 && v4 <= 29) { - v7 = _vm->_objectsManager.CAPTURE_OBJET(v6, 0); + byte *v7 = _vm->_objectsManager.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->_globals.dos_free2(v7); @@ -390,18 +372,19 @@ LABEL_7: } _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager.VESA_BUFFER, _vm->_dialogsManager.Winventaire, inventairex, inventairey, inventairel, inventaireh); _vm->_eventsManager.souris_bb = 0; - v20 = 0; + bool v20 = false; + int v13 = 0; // 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(); - v10 = v13; - v11 = _vm->_linesManager.ZONE_OBJET(v8, v9); + int v8 = _vm->_eventsManager.XMOUSE(); + int v9 = _vm->_eventsManager.YMOUSE(); + int v12 = _vm->_eventsManager.BMOUSE(); + int v10 = v13; + int v11 = _vm->_linesManager.ZONE_OBJET(v8, v9); v13 = v11; if (v11 != v10) _vm->_objectsManager.PARAMCADRE(v11); @@ -422,8 +405,8 @@ LABEL_7: v9 = v13; _vm->_objectsManager.VALID_OBJET(_vm->_globals.INVENTAIRE[v13]); if (_vm->_eventsManager.btsouris == 8) - v20 = 1; - if (v20 != 1) { + v20 = true; + if (!v20) { _vm->_scriptManager.TRAVAILOBJET = 1; _vm->_globals.SAUVEGARDE->data[svField3] = _vm->_globals.OBJET_EN_COURS; _vm->_globals.SAUVEGARDE->data[svField8] = _vm->_globals.INVENTAIRE[v13]; @@ -439,22 +422,22 @@ LABEL_7: } if (_vm->_globals.SORTIE) { if (_vm->_globals.SORTIE == 2) - v20 = 1; + v20 = true; _vm->_globals.SORTIE = 0; - if (v20 != 1) { + if (!v20) { inventaire2 = _vm->_globals.dos_free2(inventaire2); if (g_PTRNUL != _vm->_dialogsManager.Winventaire) _vm->_dialogsManager.Winventaire = _vm->_globals.dos_free2(_vm->_dialogsManager.Winventaire); goto LABEL_7; } - } else if (v20 != 1) { + } else if (!v20) { AFFINVEN = true; } } } if (VIRE_INVENT == true) - v20 = 1; - if (v20 == 1) + v20 = true; + if (v20) break; _vm->_eventsManager.VBL(); if ((uint16)(_vm->_globals.ECRAN - 35) <= 5u) @@ -463,7 +446,7 @@ LABEL_7: _vm->_fontManager.TEXTE_OFF(9); if (AFFINVEN) { AFFINVEN = false; - v9 = 114; +// 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); _vm->_objectsManager.BOBTOUS = true; @@ -491,9 +474,6 @@ LABEL_7: } void DialogsManager::INVENT_ANIM() { - int v0; - int v1; - if (!DESACTIVE_INVENT) { if (_vm->_objectsManager.FLAG_VISIBLE_EFFACE && !_vm->_objectsManager.FLAG_VISIBLE) { _vm->_graphicsManager.SCOPY(_vm->_graphicsManager.VESA_SCREEN, _vm->_objectsManager.I_old_x, 27, 48, 38, @@ -509,8 +489,8 @@ void DialogsManager::INVENT_ANIM() { _vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.I_old_x, 27); _vm->_graphicsManager.Ajoute_Segment_Vesa(_vm->_objectsManager.I_old_x, 27, _vm->_objectsManager.I_old_x + 48, 65); - v0 = _vm->_graphicsManager.ofscroll + 2; - v1 = _vm->_graphicsManager.ofscroll + 2; + int v0 = _vm->_graphicsManager.ofscroll + 2; + int v1 = _vm->_graphicsManager.ofscroll + 2; _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_globals.ICONE, v1 + 300, 327, 0); _vm->_graphicsManager.Ajoute_Segment_Vesa(v1, 27, v1 + 45, 62); _vm->_objectsManager.I_old_x = v0; diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index 746fc5666d..5dc68064f2 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -301,11 +301,6 @@ void EventsManager::VBL() { int v1; int v2; int v3; - int v4; - int v5; - int v6; - int v7; - int v10; signed int v11 = 0; signed int v12 = 0; int v13 = 0; @@ -437,6 +432,7 @@ LABEL_65: if (_vm->_graphicsManager.DOUBLE_ECRAN != true || _vm->_graphicsManager.no_scroll == 1) { _vm->_graphicsManager.Affiche_Segment_Vesa(); } else { + int v4; if (_vm->_graphicsManager.no_scroll != 2) { if (XMOUSE() > _vm->_graphicsManager.SCROLL + 620) _vm->_graphicsManager.SCROLL += _vm->_graphicsManager.SPEED_SCROLL; @@ -458,10 +454,10 @@ LABEL_65: _vm->_graphicsManager.DD_Lock(); if (_vm->_graphicsManager.SDL_ECHELLE) { if (_vm->_graphicsManager.Winbpp == 2) { - v5 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE); + int v5 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE); _vm->_graphicsManager.m_scroll16A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, v5); } else { - v6 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE); + int v6 = _vm->_graphicsManager.Reel_Zoom(0x14u, _vm->_graphicsManager.SDL_ECHELLE); _vm->_graphicsManager.m_scroll2A(_vm->_graphicsManager.VESA_BUFFER, v4, 20, 640, 440, 0, v6); } _vm->_graphicsManager.DD_Unlock(); @@ -477,17 +473,18 @@ LABEL_65: _vm->_graphicsManager.DD_Unlock(); _vm->_graphicsManager.dstrect[0] = Common::Rect(0, 20, 640, 460); } - if (!_vm->_globals.BPP_NOAFF) { -// SDL_UpdateRects(LinuxScr, 1, dstrect); - } + + // CHECKME: Useless? + // if (!_vm->_globals.BPP_NOAFF) { + // // SDL_UpdateRects(LinuxScr, 1, dstrect); + // } + if (_vm->_globals.NBBLOC) { - v7 = 1; - v10 = _vm->_globals.NBBLOC + 1; - do { - if (_vm->_globals.BLOC[v7].field0 == 1) - _vm->_globals.BLOC[v7].field0 = 0; - ++v7; - } while (v10 != v7); + int v10 = _vm->_globals.NBBLOC + 1; + for (int i = 1; i != v10; i++) { + if (_vm->_globals.BLOC[i].field0 == 1) + _vm->_globals.BLOC[i].field0 = 0; + } } _vm->_globals.NBBLOC = 0; start_x = v4; @@ -500,6 +497,9 @@ LABEL_65: } souris_bb = souris_b; souris_b = 0; +#if 0 + // Commented by Strangerke. Looks completely useless. + if (souris_flag == true) { if (btsouris != 23) { if (yp < _vm->_graphicsManager.max_y && v15 < _vm->_graphicsManager.max_x && v14 > 1 && v13 > 1) { @@ -520,6 +520,7 @@ LABEL_65: } } LABEL_113: +#endif _vm->_soundManager.VERIF_SOUND(); CONTROLE_MES(); } diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index 13e54bb288..a5d193fda7 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -285,7 +285,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) { bool matchFlag = false; int offsetVal = 0; - do { + while (!matchFlag) { Common::String name = (const char *)ptr + offsetVal; if (name == filename) { @@ -302,7 +302,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) { } offsetVal += 23; - } while (!matchFlag); + } _vm->_globals.dos_free2(ptr); diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index 8fd69fa766..64f39f9c9e 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -114,74 +114,23 @@ void FontManager::DOS_TEXT(int idx, int messageId, const Common::String &filenam // Box void FontManager::BOITE(int idx, int messageId, const Common::String &filename, int xp, int yp) { - int filesize; byte *v9; - const byte *v10; - int v11; - byte v13; - byte v14; - int v15; - byte v16; - int v17; - int v18; - int v19; - int v20; - int v21; - int v22; - int v23; - byte v24; - int v25; - int v27; - int v28; - int v29; - int v32; - int v34; - int v36; - int v37; - int ptrb; - int ptrc; - byte *ptrd; byte *ptre; Common::String s; - int v49; - int blockSize; - int v51; - int blockHeight; - int v53; - int blockWidth; - int v55; - int v56; - int lineSize; - int lineCount; byte *v59; - byte *v60; - byte *v61; - int v62; - int v63; - int v64; - int v65; - int v66; - int v67; - int v68; - int v69; - int v70; - int v71; - int v73; - int i; - int v75; Common::String file; Common::File f; - v73 = xp; - v70 = yp; - lineCount = 0; + int v73 = xp; + int v70 = yp; if (idx < 0) error("Bad number for text"); _vm->_globals.police_l = 11; _vm->_globals.largeur_boite = 11 * Txt[idx].field3FE; + int lineCount = 0; if (Txt[idx].textLoaded) { - v34 = Txt[idx].field3FC; + int v34 = Txt[idx].field3FC; if (v34 != 6 && v34 != 1 && v34 != 3 && v34 != 5) { int yCurrent = yp + 5; if (Txt[idx].lineCount > 0) { @@ -191,8 +140,8 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, } } } else { - v36 = Txt[idx].height; - v37 = Txt[idx].width; + int v36 = Txt[idx].height; + int v37 = Txt[idx].width; _vm->_graphicsManager.Restore_Mem( _vm->_graphicsManager.VESA_BUFFER, Txt[idx].textBlock, @@ -203,7 +152,7 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, _vm->_graphicsManager.Ajoute_Segment_Vesa(xp, yp, xp + v37, yp + v36); } } else { - v62 = 0; + int v62 = 0; do { TRIER_TEXT[v62++] = 0; } while (v62 <= 19); @@ -219,11 +168,12 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, if (!f.open(nom_index)) error("Error opening file - %s", nom_index.c_str()); - filesize = f.size(); - for (i = 0; i < (filesize / 4); ++i) + int filesize = f.size(); + for (int i = 0; i < (filesize / 4); ++i) Index[i] = f.readUint32LE(); f.close(); } + int v11, v69; if (filename[0] != 'Z' || filename[1] != 'O') { if (!f.open(file)) error("Error opening file - %s", nom_index.c_str()); @@ -246,17 +196,19 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, Common::fill(&v9[0], &v9[0x6e], 0); texte_tmp = v9; - v10 = _vm->_globals.BUF_ZONE + Index[messageId]; + const byte *v10 = _vm->_globals.BUF_ZONE + Index[messageId]; memcpy(v9, v10, 0x60u); v11 = 0; WRITE_LE_UINT16((uint16 *)v9 + 48, (int16)READ_LE_UINT16(v10 + 96)); } v59 = texte_tmp; - v63 = 0; + int v63 = 0; + int v64 = 0; + byte *v60; if (!v69) goto LABEL_43; do { - v13 = *v59; + byte v13 = *v59; if ((byte)(*v59 + 46) > 0x1Bu) { if ((byte)(v13 + 80) > 0x1Bu) { if ((byte)(v13 - 65) <= 0x19u || (byte)(v13 - 97) <= 0x19u) @@ -273,10 +225,9 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, } while (v63 < v69); v60 = texte_tmp; - v64 = 0; if (v69) { while (1) { - v14 = *(v60 + v64); + byte v14 = *(v60 + v64); if (v14 == '\r' || v14 == '\n') { *(v60 + v64) = 0; if (!Txt[idx].field3FE) @@ -289,7 +240,8 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, Txt[idx].field3FE = v64; _vm->_globals.largeur_boite = 0; - v15 = 0; + int v15 = 0; + byte v16; if (v64 + 1 > 0) { do { v16 = *(v60 + v15); @@ -300,13 +252,12 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, } while (v15 < v64 + 1); } _vm->_globals.largeur_boite += 2; - v17 = _vm->_globals.largeur_boite / 2; + int v17 = _vm->_globals.largeur_boite / 2; if (v17 < 0) v17 = -v17; Txt[idx].xp = 320 - v17; v73 = _vm->_eventsManager.start_x + 320 - v17; lineCount = 1; - v18 = 0; if (v64 + 1 > 0) { Txt[idx].lines[0] = Common::String((const char *)v60, v64); } @@ -314,11 +265,13 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, LABEL_43: if (!_vm->_globals.largeur_boite) _vm->_globals.largeur_boite = 240; - v65 = 0; - v61 = texte_tmp; + int v65 = 0; + byte *v61 = texte_tmp; + int v21; + int lineSize; do { - v19 = 0; - ptrb = _vm->_globals.largeur_boite - 4; + int v19 = 0; + int ptrb = _vm->_globals.largeur_boite - 4; while (1) { lineSize = v19; do @@ -339,7 +292,7 @@ LABEL_55: if (v11 == '%') lineSize = v19; LABEL_57: - v20 = lineCount; + int v20 = lineCount; v21 = v11; // WORKAROUND: Perhaps due to the usage of ScummVM strings here, recalculate what the @@ -355,48 +308,45 @@ LABEL_57: v65 += lineSize; v11 = v21; } while (v21 != 37); - v66 = 0; - do { - v22 = TRIER_TEXT[v66]; + + for (int i = 0; i <= 19; i++) { + int v22 = TRIER_TEXT[i]; if (v22 <= 0) { - TRIER_TEXT[v66] = 0; + TRIER_TEXT[i] = 0; } else { - ptrc = 0; - v23 = 0; + int ptrc = 0; + int v23 = 0; if (v22 - 1 > 0) { do { - Common::String &line = Txt[idx].lines[v66]; - v24 = (v23 >= (int)line.size()) ? '\0' : line[v23]; + Common::String &line = Txt[idx].lines[i]; + byte v24 = (v23 >= (int)line.size()) ? '\0' : line.c_str()[v23]; if ((byte)v24 <= 0x1Fu) v24 = 32; ptrc += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, (byte)v24 - 32); ++v23; - } while (v23 < TRIER_TEXT[v66] - 1); + } while (v23 < TRIER_TEXT[i] - 1); } - TRIER_TEXT[v66] = ptrc; + TRIER_TEXT[i] = ptrc; } - ++v66; - } while (v66 <= 19); - v67 = 0; - do { - v25 = v67; + } + for (int i = 0; i <= 19; i++) { + int v25 = i; do { ++v25; if (v25 == 20) v25 = 0; - if (TRIER_TEXT[v67] < TRIER_TEXT[v25]) - TRIER_TEXT[v67] = 0; - } while (v25 != (int16)v67); - ++v67; - } while (v67 <= 19); - v68 = 0; - do { - if (TRIER_TEXT[v68]) - _vm->_globals.largeur_boite = TRIER_TEXT[v68]; - ++v68; - } while (v68 <= 19); + if (TRIER_TEXT[i] < TRIER_TEXT[v25]) + TRIER_TEXT[i] = 0; + } while (v25 != i); + }; + + for (int i = 0; i <= 19; i++) { + if (TRIER_TEXT[i]) + _vm->_globals.largeur_boite = TRIER_TEXT[i]; + } if ((uint16)(Txt[idx].field3FC - 2) > 1u) { + int i; for (i = xp - _vm->_eventsManager.start_x; _vm->_globals.largeur_boite + i > 638 && i > -2 && Txt[idx].field3FC; i -= 2) ; Txt[idx].xp = i; @@ -414,26 +364,26 @@ LABEL_57: } } _vm->_globals.hauteur_boite = (_vm->_globals.police_h + 1) * lineCount + 2; - v56 = v73; - v55 = yp; - v53 = _vm->_globals.largeur_boite + 10; - v51 = (_vm->_globals.police_h + 1) * lineCount + 12; + int v56 = v73; + int v55 = yp; + int v53 = _vm->_globals.largeur_boite + 10; + int v51 = (_vm->_globals.police_h + 1) * lineCount + 12; if (Txt[idx].field3FC == 6) { - v27 = v53 / 2; + int v27 = v53 / 2; if (v27 < 0) v27 = -v27; Txt[idx].xp = 315 - v27; - v28 = _vm->_eventsManager.start_x + 315 - v27; + int v28 = _vm->_eventsManager.start_x + 315 - v27; v73 = _vm->_eventsManager.start_x + 315 - v27; Txt[idx].yp = 50; v70 = 50; v55 = 50; v56 = v28; } - v29 = Txt[idx].field3FC; + int v29 = Txt[idx].field3FC; if (v29 == 1 || v29 == 3 || (uint16)(v29 - 5) <= 1u) { - v49 = v51 * v53; - ptrd = _vm->_globals.dos_malloc2(v51 * v53); + int v49 = v51 * v53; + byte *ptrd = _vm->_globals.dos_malloc2(v49); if (ptrd == g_PTRNUL) { error("Cutting a block for text box (%d)", v49); } @@ -448,8 +398,8 @@ LABEL_57: _vm->_graphicsManager.Plot_Vline(_vm->_graphicsManager.VESA_BUFFER, v53 + v56, v70, v51, (byte)-2); } Txt[idx].lineCount = lineCount; - v75 = v73 + 5; - v71 = v70 + 5; + int v75 = v73 + 5; + int v71 = v70 + 5; if (lineCount > 0) { for (int lineNum = 0; lineNum < lineCount; ++lineNum) { @@ -458,16 +408,16 @@ LABEL_57: } } - blockWidth = v53 + 1; - blockHeight = v51 + 1; + int blockWidth = v53 + 1; + int blockHeight = v51 + 1; Txt[idx].width = blockWidth; Txt[idx].height = blockHeight; - v32 = Txt[idx].field3FC; + int v32 = Txt[idx].field3FC; if (v32 == 6 || v32 == 1 || v32 == 3 || v32 == 5) { if (Txt[idx].textBlock != g_PTRNUL) Txt[idx].textBlock = _vm->_globals.dos_free2(Txt[idx].textBlock); - blockSize = blockHeight * blockWidth; + int blockSize = blockHeight * blockWidth; ptre = _vm->_globals.dos_malloc2(blockSize + 20); if (ptre == g_PTRNUL) error("Cutting a block for text box (%d)", blockSize); diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 5a24a5f207..882d869d33 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -569,16 +569,8 @@ void Globals::CACHE_ADD(int idx) { // Load Cache void Globals::CHARGE_CACHE(const Common::String &file) { byte *v2 = g_PTRNUL; - int v4; - int v5; - int v6; - int v8; - int v9; - int v11; byte *spriteData; byte *ptr; - int v14; - int v15; Common::String v16; Common::File f; @@ -592,34 +584,32 @@ void Globals::CHARGE_CACHE(const Common::String &file) { if (f.exists(NFICHIER)) { spriteData = _vm->_fileManager.CHARGE_FICHIER(NFICHIER); CACHE_BANQUE[1] = spriteData; - v15 = 60; - v14 = 0; - do { - v11 = (int16)READ_LE_UINT16((uint16 *)ptr + v15); - v4 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 1); - v5 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 2); - v6 = v14; + int v15 = 60; + for (int i = 0; i <= 21; i++) { + int v11 = (int16)READ_LE_UINT16((uint16 *)ptr + v15); + int v4 = (int16)READ_LE_UINT16((uint16 *)ptr + v15 + 1); + 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; if (spriteData == g_PTRNUL) { - Cache[v14].fieldA = 0; + Cache[i].fieldA = 0; } else { - v8 = _vm->_objectsManager.Get_Largeur(spriteData, v11); - v9 = _vm->_objectsManager.Get_Hauteur(spriteData, v11); - Cache[v14].fieldC = spriteData; - Cache[v14].field6 = v8; - Cache[v14].field8 = v9; - Cache[v14].fieldA = 1; + int v8 = _vm->_objectsManager.Get_Largeur(spriteData, v11); + int v9 = _vm->_objectsManager.Get_Hauteur(spriteData, v11); + Cache[i].fieldC = spriteData; + Cache[i].field6 = v8; + Cache[i].field8 = v9; + Cache[i].fieldA = 1; } - if ( !Cache[v14].field0 && !Cache[v14].field4 && !Cache[v14].field2) - Cache[v14].fieldA = 0; + if ( !Cache[i].field0 && !Cache[i].field4 && !Cache[i].field2) + Cache[i].fieldA = 0; v15 += 5; - ++v14; - } while (v14 <= 21); + } CACHE_ON(); v2 = ptr; } |