diff options
author | Strangerke | 2012-12-09 20:22:12 +0100 |
---|---|---|
committer | Strangerke | 2012-12-09 20:22:12 +0100 |
commit | 867cbbf4ff6ddfca826724a7ff74f44a06e8d044 (patch) | |
tree | 597fe707ae53fbd0b3a73e9d3215b51aac261228 /engines/hopkins | |
parent | fedf2ca70f7d38e0b49adec8b61b0a6b464b9929 (diff) | |
download | scummvm-rg350-867cbbf4ff6ddfca826724a7ff74f44a06e8d044.tar.gz scummvm-rg350-867cbbf4ff6ddfca826724a7ff74f44a06e8d044.tar.bz2 scummvm-rg350-867cbbf4ff6ddfca826724a7ff74f44a06e8d044.zip |
HOPKINS: Refactor fileManager
Diffstat (limited to 'engines/hopkins')
-rw-r--r-- | engines/hopkins/anim.cpp | 30 | ||||
-rw-r--r-- | engines/hopkins/computer.cpp | 49 | ||||
-rw-r--r-- | engines/hopkins/dialogs.cpp | 32 | ||||
-rw-r--r-- | engines/hopkins/events.cpp | 1 | ||||
-rw-r--r-- | engines/hopkins/files.cpp | 172 | ||||
-rw-r--r-- | engines/hopkins/files.h | 33 | ||||
-rw-r--r-- | engines/hopkins/font.cpp | 2 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 13 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 1 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 37 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 90 | ||||
-rw-r--r-- | engines/hopkins/menu.cpp | 10 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 87 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 20 | ||||
-rw-r--r-- | engines/hopkins/sound.cpp | 34 | ||||
-rw-r--r-- | engines/hopkins/talk.cpp | 44 |
16 files changed, 306 insertions, 349 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 97ec536b0b..dbd4289f36 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -59,7 +59,7 @@ LABEL_2: v10 = _vm->_graphicsManager.VESA_SCREEN; ptr = _vm->_globals.dos_malloc2(0x14u); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANM, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANM, filename); if (!f.open(_vm->_globals.NFICHIER)) error("File not found - %s", _vm->_globals.NFICHIER.c_str()); @@ -263,18 +263,18 @@ void AnimationManager::PLAY_ANM2(const Common::String &filename, uint32 a2, uint while (!_vm->shouldQuit()) { memcpy(_vm->_graphicsManager.OLD_PAL, _vm->_graphicsManager.Palette, 0x301u); - _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR"); + _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u); - if (_vm->_graphicsManager.nbrligne == 1280) + else if (_vm->_graphicsManager.nbrligne == 1280) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u); if (!_vm->_graphicsManager.nbrligne) _vm->_graphicsManager.ofscroll = 0; v12 = _vm->_graphicsManager.VESA_SCREEN; v13 = _vm->_globals.dos_malloc2(0x14u); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANM, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANM, filename); if (!f.open(_vm->_globals.NFICHIER)) error("Error opening file - %s", _vm->_globals.NFICHIER.c_str()); @@ -685,7 +685,7 @@ void AnimationManager::CHARGE_ANIM(const Common::String &animName) { CLEAR_ANIM(); Common::String filename = animName + ".ANI"; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, filename); Common::File f; if (!f.open(_vm->_globals.NFICHIER)) @@ -710,7 +710,7 @@ void AnimationManager::CHARGE_ANIM(const Common::String &animName) { for (int idx = 1; idx <= 6; ++idx) { if (files[idx - 1][0]) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, files[idx - 1]); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, files[idx - 1]); if (!f.exists(_vm->_globals.NFICHIER)) error("File not found"); @@ -755,13 +755,13 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam byte *ptr; byte *v19; int result = 0; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename); - _vm->_globals.Bank[idx].field1C = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, filename); + _vm->_globals.Bank[idx].field1C = _vm->_fileManager.fileSize(_vm->_globals.NFICHIER); _vm->_globals.Bank[idx].field4 = 1; _vm->_globals.Bank[idx].filename1 = filename; _vm->_globals.Bank[idx].filename2 = _vm->_globals.REP_SPR; - v3 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + v3 = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); v4 = v3; _vm->_globals.Bank[idx].fileHeader = 0; @@ -801,10 +801,10 @@ int AnimationManager::CHARGE_BANK_SPRITE1(int idx, const Common::String &filenam } while (ch != '.'); ofsFilename += ".OFS"; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, ofsFilename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, ofsFilename); Common::File f; if (f.exists(_vm->_globals.NFICHIER)) { - v19 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + v19 = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); v13 = v19; if (_vm->_globals.Bank[idx].field1A > 0) { @@ -951,17 +951,17 @@ void AnimationManager::PLAY_SEQ(const Common::String &file, uint32 rate1, uint32 if (!NO_COUL) { _vm->_eventsManager.VBL(); - _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR"); + _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u); - if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2)) + else if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2)) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u); if (!_vm->_graphicsManager.nbrligne) _vm->_graphicsManager.ofscroll = 0; } v9 = _vm->_graphicsManager.VESA_SCREEN; v10 = _vm->_globals.dos_malloc2(0x16u); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSEQ, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSEQ, file); if (!f.open(_vm->_globals.NFICHIER)) error("Error opening file - %s", _vm->_globals.NFICHIER.c_str()); @@ -1129,7 +1129,7 @@ void AnimationManager::PLAY_SEQ2(const Common::String &file, uint32 rate1, uint3 _vm->_eventsManager.souris_flag = false; v10 = _vm->_graphicsManager.VESA_SCREEN; v11 = _vm->_globals.dos_malloc2(0x16u); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSEQ, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSEQ, file); if (!f.open(_vm->_globals.NFICHIER)) error("File not found - %s", _vm->_globals.NFICHIER.c_str()); diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index cddc1f18c1..bc90074d18 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -73,9 +73,9 @@ void ComputerManager::TEXT_MODE() { //SET_MODE(SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.nbrligne = SCREEN_WIDTH; - _vm->_fileManager.CONSTRUIT_SYSTEM("STFONT.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "STFONT.SPR"); _vm->_globals.police = _vm->_globals.dos_free2(_vm->_globals.police); - _vm->_globals.police = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.police = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.police_l = 8; _vm->_globals.police_h = 8; _vm->_graphicsManager.LOAD_IMAGE("WINTEXT"); @@ -300,8 +300,8 @@ void ComputerManager::COMPUT_HOPKINS(ComputerEnum mode) { } void ComputerManager::Charge_Menu() { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "COMPUTAN.TXT"); - byte *ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "COMPUTAN.TXT"); + byte *ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); byte *tmpPtr = ptr; int lineNum = 0; int strPos; @@ -473,8 +473,8 @@ void ComputerManager::outtext2(const Common::String &msg) { void ComputerManager::RESTORE_POLICE() { _vm->_globals.police = _vm->_globals.dos_free2(_vm->_globals.police); - _vm->_fileManager.CONSTRUIT_SYSTEM("FONTE3.SPR"); - _vm->_globals.police = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "FONTE3.SPR"); + _vm->_globals.police = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.police_l = 12; _vm->_globals.police_h = 21; @@ -499,14 +499,14 @@ void ComputerManager::LIT_TEXTE(int a1) { _vm->_eventsManager.ESC_KEY = false; if (_vm->_globals.FR == 0) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "THOPKAN.TXT"); - if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "THOPK.TXT"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "THOPKES.TXT"); - - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); - v1 = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "THOPKAN.TXT"); + else if (_vm->_globals.FR == 1) + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "THOPK.TXT"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "THOPKES.TXT"); + + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + v1 = _vm->_fileManager.fileSize(_vm->_globals.NFICHIER); v2 = 0; v3 = 0; if (v1 > 0u) { @@ -581,8 +581,8 @@ void ComputerManager::GAMES() { _vm->_soundManager.CHARGE_SAMPLE(1, "SOUND37.WAV"); _vm->_soundManager.CHARGE_SAMPLE(2, "SOUND38.WAV"); _vm->_soundManager.CHARGE_SAMPLE(3, "SOUND39.WAV"); - _vm->_fileManager.CONSTRUIT_SYSTEM("CASSE.SPR"); - CASSESPR = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "CASSE.SPR"); + CASSESPR = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); CHARGE_SCORE(); MODE_VGA256(); NEWTAB(); @@ -612,7 +612,7 @@ void ComputerManager::CHARGE_SCORE() { char nextChar; byte *ptr; - _vm->_fileManager.CONSTRUIT_LINUX("HISCORE.DAT"); + _vm->_fileManager.constructLinuxFilename("HISCORE.DAT"); ptr = _vm->_globals.dos_malloc2(100); _vm->_saveLoadManager.bload(_vm->_globals.NFICHIER, ptr); @@ -642,7 +642,6 @@ void ComputerManager::MODE_VGA256() { _vm->_graphicsManager.DD_Unlock(); _vm->_graphicsManager.Cls_Pal(); _vm->_graphicsManager.SCANLINE(0x140u); - _vm->_fileManager.DMESS(); } void ComputerManager::NEWTAB() { @@ -665,7 +664,7 @@ void ComputerManager::NEWTAB() { while (!_vm->shouldQuit()) { file = Common::String::format("TAB%d.TAB", NB_TABLE); - _vm->_fileManager.CONSTRUIT_SYSTEM(file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, file); if (f.open(_vm->_globals.NFICHIER)) break; @@ -673,7 +672,7 @@ void ComputerManager::NEWTAB() { } f.close(); - CASSETAB = (int16 *)_vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + CASSETAB = (int16 *)_vm->_fileManager.loadFile(_vm->_globals.NFICHIER); AFF_BRIQUES(); _vm->_objectsManager.SPRITE(CASSESPR, 150, 192, 0, 13, 0, 0, 0, 0); _vm->_objectsManager.SPRITE(CASSESPR, 164, 187, 1, 14, 0, 0, 0, 0); @@ -842,8 +841,8 @@ int ComputerManager::HIGHT_SCORE() { _vm->_graphicsManager.RESET_SEGMENT_VESA(); CHARGE_SCORE(); _vm->_graphicsManager.LOAD_IMAGEVGA("HISCORE.PCX"); - _vm->_fileManager.CONSTRUIT_SYSTEM("ALPHA.SPR"); - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "ALPHA.SPR"); + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_graphicsManager.SETCOLOR3(252, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100); @@ -894,8 +893,8 @@ void ComputerManager::NAME_SCORE() { _vm->_graphicsManager.SETCOLOR3(253, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(251, 100, 100, 100); _vm->_graphicsManager.SETCOLOR3(254, 0, 0, 0); - _vm->_fileManager.CONSTRUIT_SYSTEM("ALPHA.SPR"); - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "ALPHA.SPR"); + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_graphicsManager.FADE_IN_CASSE(); for (int strPos = 0; strPos <= 4; strPos++) { PRINT_HSCORE(ptr, 9 * strPos + 140, 78, 1); @@ -1050,7 +1049,7 @@ void ComputerManager::SAUVE_SCORE() { *(ptr + v9 + 9) = 0; } - _vm->_fileManager.CONSTRUIT_LINUX("HISCORE.DAT"); + _vm->_fileManager.constructLinuxFilename("HISCORE.DAT"); _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, ptr, 0x64u); _vm->_globals.dos_free2(ptr); } diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 436e4f694a..774767311e 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -60,13 +60,13 @@ void DialogsManager::showOptionsDialog() { _vm->_eventsManager.CHANGE_MOUSE(0); _vm->_eventsManager.VBL(); if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_SYSTEM("OPTIFR.SPR"); - if (!_vm->_globals.FR) - _vm->_fileManager.CONSTRUIT_SYSTEM("OPTIAN.SPR"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_SYSTEM("OPTIES.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OPTIFR.SPR"); + else if (!_vm->_globals.FR) + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OPTIAN.SPR"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OPTIES.SPR"); - _vm->_globals.OPTION_SPR = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.OPTION_SPR = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.OPTION_FLAG = true; do { @@ -322,13 +322,13 @@ LABEL_7: switch (_vm->_globals.FR) { case 0: - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTAN.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENTAN.SPR"); break; case 1: - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTFR.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENTFR.SPR"); break; case 2: - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENTES.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENTES.SPR"); break; } @@ -338,11 +338,11 @@ LABEL_7: size_t filesize = f.size(); _vm->_dialogsManager.Winventaire = _vm->_globals.dos_malloc2(filesize); - _vm->_fileManager.bload_it(f, _vm->_dialogsManager.Winventaire, filesize); + _vm->_fileManager.readStream(f, _vm->_dialogsManager.Winventaire, filesize); f.close(); - _vm->_fileManager.CONSTRUIT_SYSTEM("INVENT2.SPR"); - inventaire2 = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "INVENT2.SPR"); + inventaire2 = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); 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); @@ -624,18 +624,18 @@ void DialogsManager::LOAD_SAUVE(int a1) { switch (_vm->_globals.FR) { case 0: - _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEAN.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVEAN.SPR"); break; case 1: - _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEFR.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVEFR.SPR"); break; case 2: - _vm->_fileManager.CONSTRUIT_SYSTEM("SAVEES.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVEES.SPR"); break; } _vm->_objectsManager.SL_SPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER); - _vm->_fileManager.CONSTRUIT_SYSTEM("SAVE2.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "SAVE2.SPR"); _vm->_objectsManager.SL_SPR2 = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER); _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager.VESA_BUFFER, _vm->_objectsManager.SL_SPR, _vm->_eventsManager.start_x + 483, 360, 0); diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index f92e225939..d876481393 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -319,7 +319,6 @@ void EventsManager::VBL() { _vm->_graphicsManager.m_scroll(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll, 50, 0x280u, 340, 0, 50); else _vm->_graphicsManager.m_scroll(_vm->_graphicsManager.VESA_BUFFER, _vm->_graphicsManager.ofscroll, 20, 0x280u, 440, 0, 20); - _vm->_fileManager.DMESS(); --_vm->_graphicsManager.REDRAW; } _vm->_graphicsManager.DD_Unlock(); diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index fbbac191c2..f251d51388 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -38,8 +38,10 @@ void FileManager::setParent(HopkinsEngine *vm) { _vm = vm; } -// Load INI File -void FileManager::Chage_Inifile(Common::StringMap &iniParams) { +/** + * Load INI File + */ +void FileManager::loadIniFile(Common::StringMap &iniParams) { // TODO: Review whether we can do something cleaner with ScummVM initialisation than // just initialising the INI array as if it had read in the INI file @@ -52,10 +54,10 @@ void FileManager::Chage_Inifile(Common::StringMap &iniParams) { iniParams["SOUND"] = "YES"; } -// Load File -byte *FileManager::CHARGE_FICHIER(const Common::String &file) { - DMESS1(); - +/** + * Load a file + */ +byte *FileManager::loadFile(const Common::String &file) { Common::File f; if (!f.open(file)) error("Error opening %s", file.c_str()); @@ -66,55 +68,27 @@ byte *FileManager::CHARGE_FICHIER(const Common::String &file) { if (!data) error("Error allocating space for file being loaded - %s", file.c_str()); - bload_it(f, data, filesize); + readStream(f, data, filesize); f.close(); return data; } -// Load File 2 -void FileManager::CHARGE_FICHIER2(const Common::String &file, byte *buf) { - Common::File f; - size_t filesize; - - DMESS1(); - if (!f.open(file)) - error("Error opening file - %s", file.c_str()); - - filesize = f.size(); - _vm->_fileManager.bload_it(f, buf, filesize); - f.close(); -} - -// Guess: Debug Message -void FileManager::DMESS() { - // No implementation in original -} - -// Guess: Debug Message 1 -void FileManager::DMESS1() { - // No implementation in original -} - -void FileManager::bload(const Common::String &file, byte *buf) { - Common::File f; - if (!f.open(file)) - error("Error opening file - %s", file.c_str()); - int32 filesize = f.size(); - _vm->_fileManager.bload_it(f, buf, filesize); - f.close(); -} - -int FileManager::bload_it(Common::ReadStream &stream, void *buf, size_t nbytes) { +/** + * Read a given number of bytes from a Stream into a pre-allocated buffer + */ +int FileManager::readStream(Common::ReadStream &stream, void *buf, size_t nbytes) { return stream.read(buf, nbytes); } -// Censorship -void FileManager::F_Censure() { +/** + * Initialize censorship based on blood.dat file + */ +void FileManager::initCensorship() { _vm->_globals.CENSURE = false; - CONSTRUIT_SYSTEM("BLOOD.DAT"); - char *data = (char *)CHARGE_FICHIER(_vm->_globals.NFICHIER); + constructFilename(_vm->_globals.HOPSYSTEM, "BLOOD.DAT"); + char *data = (char *)loadFile(_vm->_globals.NFICHIER); if (*(data + 6) == 'u' && *(data + 7) == 'k') _vm->_globals.CENSURE = true; @@ -124,13 +98,12 @@ void FileManager::F_Censure() { free(data); } -// Build System -int FileManager::CONSTRUIT_SYSTEM(const Common::String &file) { - _vm->_globals.NFICHIER = Common::String::format("system/%s", file.c_str()); - return _vm->_globals.NFICHIER.size(); -} - -void FileManager::CONSTRUIT_FICHIER(const Common::String &folder, const Common::String &file) { +/** + * Construct a filename based on a suggested folder and filename. + * @param folder Folder to use. May be overriden for animations. + * @param file Filename + */ +void FileManager::constructFilename(const Common::String &folder, const Common::String &file) { Common::String folderToUse = folder; // A lot of the code in the original engine based on COPIE_SEQ was used to determine @@ -142,15 +115,15 @@ void FileManager::CONSTRUIT_FICHIER(const Common::String &folder, const Common:: if (folder == _vm->_globals.HOPANM) { switch (_vm->_globals.SVGA) { case 1: - if (TEST_REP(folderToUse, file)) + if (fileExists(folderToUse, file)) folderToUse = _vm->_globals.HOPTSVGA; break; case 2: - if (TEST_REP(folderToUse, file)) + if (fileExists(folderToUse, file)) folderToUse = _vm->_globals.HOPSVGA; break; case 3: - if (TEST_REP(folderToUse, file)) + if (fileExists(folderToUse, file)) folderToUse = _vm->_globals.HOPVGA; break; default: @@ -161,7 +134,18 @@ void FileManager::CONSTRUIT_FICHIER(const Common::String &folder, const Common:: _vm->_globals.NFICHIER = Common::String::format("%s/%s", folderToUse.c_str(), file.c_str()); } -bool FileManager::TEST_REP(const Common::String &folder, const Common::String &file) { +/** + * Construct Linux filename + */ +Common::String FileManager::constructLinuxFilename(const Common::String &file) { + _vm->_globals.NFICHIER = file; + return file; +} + +/** + * Check if a file is present in a given (optional) folder + */ +bool FileManager::fileExists(const Common::String &folder, const Common::String &file) { Common::String filename = folder.empty() ? file : Common::String::format("%s/%s", folder.c_str(), file.c_str()); @@ -169,14 +153,10 @@ bool FileManager::TEST_REP(const Common::String &folder, const Common::String &f return !f.exists(filename); } -// Free File -byte *FileManager::LIBERE_FICHIER(byte *ptr) { - free(ptr); - return g_PTRNUL; -} - -// Search Cat -byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) { +/** + * Search file in Cat file + */ +byte *FileManager::searchCat(const Common::String &file, int a2) { byte *ptr = NULL; Common::File f; @@ -185,91 +165,91 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) { switch (a2) { case 1: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_INI.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_INI.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_INI.RES"); + ptr = loadFile(_vm->_globals.NFICHIER); + constructFilename(_vm->_globals.HOPLINK, "RES_INI.RES"); break; case 2: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_REP.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_REP.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_REP.RES"); + ptr = loadFile(_vm->_globals.NFICHIER); + constructFilename(_vm->_globals.HOPLINK, "RES_REP.RES"); break; case 3: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_LIN.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_LIN.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_LIN.RES"); + ptr = loadFile(_vm->_globals.NFICHIER); + constructFilename(_vm->_globals.HOPLINK, "RES_LIN.RES"); break; case 4: - CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_ANI.CAT"); + constructFilename(_vm->_globals.HOPANIM, "RES_ANI.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); - CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_ANI.RES"); + ptr = loadFile(_vm->_globals.NFICHIER); + constructFilename(_vm->_globals.HOPANIM, "RES_ANI.RES"); break; case 5: - CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_PER.CAT"); + constructFilename(_vm->_globals.HOPANIM, "RES_PER.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); - CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_PER.RES"); + ptr = loadFile(_vm->_globals.NFICHIER); + constructFilename(_vm->_globals.HOPANIM, "RES_PER.RES"); break; case 6: - CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.CAT"); + constructFilename(_vm->_globals.HOPIMAGE, "PIC.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); + ptr = loadFile(_vm->_globals.NFICHIER); break; case 7: - CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.CAT"); + constructFilename(_vm->_globals.HOPANIM, "RES_SAN.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); + ptr = loadFile(_vm->_globals.NFICHIER); break; case 8: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_SLI.CAT"); if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); + ptr = loadFile(_vm->_globals.NFICHIER); break; case 9: switch (_vm->_globals.FR) { case 0: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_VAN.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_VAN.CAT"); break; case 1: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_VFR.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_VFR.CAT"); break; case 2: - CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_VES.CAT"); + constructFilename(_vm->_globals.HOPLINK, "RES_VES.CAT"); break; } if (!f.exists(_vm->_globals.NFICHIER)) return g_PTRNUL; - ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER); + ptr = loadFile(_vm->_globals.NFICHIER); break; // Deliberate fall-through to default: @@ -313,7 +293,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) { if (catData == g_PTRNUL) error("CHARGE_FICHIER"); - bload_it(f, catData, _vm->_globals.CAT_TAILLE); + readStream(f, catData, _vm->_globals.CAT_TAILLE); f.close(); result = catData; } else { @@ -323,8 +303,10 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) { return result; } -// File Size -uint32 FileManager::FLONG(const Common::String &filename) { +/** + * Returns the size of a file. Throws an error if the file can't be found + */ +uint32 FileManager::fileSize(const Common::String &filename) { Common::File f; uint32 size; @@ -337,10 +319,4 @@ uint32 FileManager::FLONG(const Common::String &filename) { return size; } -// Build Linux -Common::String FileManager::CONSTRUIT_LINUX(const Common::String &file) { - _vm->_globals.NFICHIER = file; - return file; -} - } // End of namespace Hopkins diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h index e63e5370c8..fe63fd0848 100644 --- a/engines/hopkins/files.h +++ b/engines/hopkins/files.h @@ -34,38 +34,23 @@ class HopkinsEngine; class FileManager { private: - bool TEST_REP(const Common::String &folder, const Common::String &file); + bool fileExists(const Common::String &folder, const Common::String &file); public: HopkinsEngine *_vm; public: FileManager(); void setParent(HopkinsEngine *vm); - void Chage_Inifile(Common::StringMap &iniParams); - byte *CHARGE_FICHIER(const Common::String &file); - void CHARGE_FICHIER2(const Common::String &file, byte *a2); - void DMESS(); - void DMESS1(); - void bload(const Common::String &file, byte *buf); - int bload_it(Common::ReadStream &stream, void *buf, size_t nbytes); - void F_Censure(); - int CONSTRUIT_SYSTEM(const Common::String &file); - - /** - * Construct a filename based on a suggested folder and filename. - * @param folder Folder to use. May be overriden for animations. - * @param file Filename - */ - void CONSTRUIT_FICHIER(const Common::String &folder, const Common::String &file); + void loadIniFile(Common::StringMap &iniParams); + byte *loadFile(const Common::String &file); + int readStream(Common::ReadStream &stream, void *buf, size_t nbytes); + void initCensorship(); + void constructFilename(const Common::String &folder, const Common::String &file); - byte *LIBERE_FICHIER(byte *ptr); - byte *RECHERCHE_CAT(const Common::String &file, int a2); - Common::String CONSTRUIT_LINUX(const Common::String &file); + byte *searchCat(const Common::String &file, int a2); + Common::String constructLinuxFilename(const Common::String &file); - /** - * Returns the size of a file. Throws an error if the file can't be found - */ - uint32 FLONG(const Common::String &filename); + uint32 fileSize(const Common::String &filename); }; } // End of namespace Hopkins diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index cb7580cc33..c7fae50218 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -168,7 +168,7 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, TRIER_TEXT[v62++] = 0; } while (v62 <= 19); Txt[idx].textLoaded = true; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); file = _vm->_globals.NFICHIER; if (strncmp(file.c_str(), oldname.c_str(), strlen(file.c_str())) != 0) { diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index e4a405ef0c..a311c91253 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -301,6 +301,7 @@ void Globals::setConfig() { HOPSVGA = "SVGA"; HOPVGA = "VGA"; HOPSEQ = "SEQ"; + HOPSYSTEM = "SYSTEM"; // CHECKME: Should be in Globals() but it doesn't work // The Polish version is a translation of the English version. The filenames are the same. @@ -490,8 +491,8 @@ void Globals::CLEAR_VBOB() { // Load Object void Globals::CHARGE_OBJET() { - _vm->_fileManager.CONSTRUIT_SYSTEM("OBJET.DAT"); - byte *data = _vm->_fileManager.CHARGE_FICHIER(NFICHIER); + _vm->_fileManager.constructFilename(HOPSYSTEM, "OBJET.DAT"); + byte *data = _vm->_fileManager.loadFile(NFICHIER); byte *srcP = data; for (int idx = 0; idx < 300; ++idx) { @@ -580,14 +581,14 @@ void Globals::CHARGE_CACHE(const Common::String &file) { Common::File f; RESET_CACHE(); - _vm->_fileManager.CONSTRUIT_FICHIER(HOPLINK, file); - ptr = _vm->_fileManager.CHARGE_FICHIER(NFICHIER); + _vm->_fileManager.constructFilename(HOPLINK, file); + ptr = _vm->_fileManager.loadFile(NFICHIER); v16 = Common::String((const char *)ptr); - _vm->_fileManager.CONSTRUIT_FICHIER(HOPLINK, v16); + _vm->_fileManager.constructFilename(HOPLINK, v16); if (f.exists(NFICHIER)) { - spriteData = _vm->_fileManager.CHARGE_FICHIER(NFICHIER); + spriteData = _vm->_fileManager.loadFile(NFICHIER); CACHE_BANQUE[1] = spriteData; int v15 = 60; for (int i = 0; i <= 21; i++) { diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 2e3097eafb..c44316611c 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -360,6 +360,7 @@ public: Common::String HOPSVGA; Common::String HOPVGA; Common::String HOPSEQ; + Common::String HOPSYSTEM; Common::String FICH_ZONE; Common::String FICH_TEXTE; Common::String NFICHIER; diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0075fb0830..1f734e284c 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -190,7 +190,7 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { DD_Lock(); Cls_Video(); DD_Unlock(); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); A_PCX320(VESA_SCREEN, _vm->_globals.NFICHIER, Palette); memcpy(VESA_BUFFER, VESA_SCREEN, 0xFA00u); _vm->_eventsManager.souris_max(); @@ -209,14 +209,11 @@ void GraphicsManager::LOAD_IMAGEVGA(const Common::String &file) { // Load Screen void GraphicsManager::CHARGE_ECRAN(const Common::String &file) { - bool flag; Common::File f; - _vm->_fileManager.DMESS1(); - - flag = true; - if (_vm->_fileManager.RECHERCHE_CAT(file, 6) == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + bool flag = true; + if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) error("CHARGE_ECRAN - %s", file.c_str()); @@ -360,14 +357,14 @@ void GraphicsManager::A_PCX640_480(byte *surface, const Common::String &file, by if (typeFlag) { // Load PCX from within the PIC resource - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, "PIC.RES"); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); f.seek(_vm->_globals.CAT_POSI); } else { // Load stand alone PCX file - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPIMAGE, file); if (!f.open(_vm->_globals.NFICHIER)) error("(nom)Erreur en cours de lecture."); } @@ -2299,26 +2296,26 @@ void GraphicsManager::INI_ECRAN2(const Common::String &file) { void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { Common::String filename = file + ".ini"; - byte *ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 1); + byte *ptr = _vm->_fileManager.searchCat(filename, 1); if (ptr == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (!mode) { filename = file + ".spr"; if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); + _vm->_globals.SPRITE_ECRAN = _vm->_globals.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); if (!_vm->_globals.NOSPRECRAN) { - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.RECHERCHE_CAT(filename, 8); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.searchCat(filename, 8); if (_vm->_globals.SPRITE_ECRAN) { _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); } else { _vm->_globals.CAT_FLAG = true; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES"); } - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.CAT_FLAG = false; } } @@ -2351,11 +2348,11 @@ void GraphicsManager::OPTI_INI(const Common::String &file, int mode) { _vm->_globals.COUCOU = _vm->_globals.dos_free2(_vm->_globals.COUCOU); filename = file + ".rep"; - byte *dataP = _vm->_fileManager.RECHERCHE_CAT(filename, 2); + byte *dataP = _vm->_fileManager.searchCat(filename, 2); _vm->_globals.COUCOU = dataP; if (g_PTRNUL == dataP) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); - dataP = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); + dataP = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.COUCOU = dataP; } } diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index edcfb5afb5..b040cd712c 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -96,11 +96,11 @@ Common::Error HopkinsEngine::run() { _saveLoadManager.initSaves(); Common::StringMap iniParams; - _fileManager.Chage_Inifile(iniParams); + _fileManager.loadIniFile(iniParams); processIniParams(iniParams); _globals.setConfig(); - _fileManager.F_Censure(); + _fileManager.initCensorship(); INIT_SYSTEM(); _soundManager.WSOUND_INIT(); @@ -174,8 +174,8 @@ bool HopkinsEngine::runWin95Demo() { warning("TODO Init_Interrupt_();"); _graphicsManager.FADE_OUTW(); _globals.iRegul = 1; - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals.SAUVEGARDE, 0, 2000); @@ -482,8 +482,8 @@ bool HopkinsEngine::runLinuxDemo() { INTRORUN(); _globals.iRegul = 0; - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals.SAUVEGARDE, 0, 2000); @@ -849,9 +849,9 @@ bool HopkinsEngine::runWin95full() { _eventsManager.delay(500); _graphicsManager.FADE_OUTW(); _globals.iRegul = 0; - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals.SAUVEGARDE, 0, 2000); @@ -1236,7 +1236,7 @@ bool HopkinsEngine::runWin95full() { Common::String im = Common::String::format("IM%d", _globals.SORTIE); _soundManager.WSOUND(13); if (_globals.FORETSPR == g_PTRNUL) { - _fileManager.CONSTRUIT_SYSTEM("HOPDEG.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "HOPDEG.SPR"); _globals.FORETSPR = _objectsManager.CHARGE_SPRITE(_globals.NFICHIER); _soundManager.CHARGE_SAMPLE(1, "SOUND41.WAV"); } @@ -1686,8 +1686,8 @@ bool HopkinsEngine::runWin95full() { _globals.SORTIE = WBASE(); _soundManager.WSOUND_OFF(); warning("TODO: heapshrink();"); - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.iRegul = 0; _graphicsManager.nbrligne = SCREEN_WIDTH; @@ -1727,8 +1727,8 @@ bool HopkinsEngine::runLinuxFull() { INTRORUN(); _globals.iRegul = 0; - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.PLANX = _globals.PLANY = 0; memset(_globals.SAUVEGARDE, 0, 2000); @@ -2114,7 +2114,7 @@ bool HopkinsEngine::runLinuxFull() { Common::String im = Common::String::format("IM%d", _globals.SORTIE); _soundManager.WSOUND(13); if (_globals.FORETSPR == g_PTRNUL) { - _fileManager.CONSTRUIT_SYSTEM("HOPDEG.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "HOPDEG.SPR"); _globals.FORETSPR = _objectsManager.CHARGE_SPRITE(_globals.NFICHIER); _soundManager.CHARGE_SAMPLE(1, "SOUND41.WAV"); } @@ -2576,8 +2576,8 @@ bool HopkinsEngine::runLinuxFull() { _soundManager.WSOUND(23); _globals.SORTIE = PWBASE(); _soundManager.WSOUND_OFF(); - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.iRegul = 0; _graphicsManager.nbrligne = SCREEN_WIDTH; @@ -2629,18 +2629,18 @@ void HopkinsEngine::INIT_SYSTEM() { switch (_globals.FR) { case 0: if (!_eventsManager.mouse_linux) - _fileManager.CONSTRUIT_SYSTEM("SOUAN.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "SOUAN.SPR"); else - _fileManager.CONSTRUIT_SYSTEM("LSOUAN.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "LSOUAN.SPR"); break; case 1: if (!_eventsManager.mouse_linux) - _fileManager.CONSTRUIT_SYSTEM("SOUFR.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "SOUFR.SPR"); else - _fileManager.CONSTRUIT_SYSTEM("LSOUFR.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "LSOUFR.SPR"); break; case 2: - _fileManager.CONSTRUIT_SYSTEM("SOUES.SPR"); + _fileManager.constructFilename(_globals.HOPSYSTEM, "SOUES.SPR"); break; } @@ -2651,31 +2651,31 @@ void HopkinsEngine::INIT_SYSTEM() { _eventsManager.souris_sizex = 34; _eventsManager.souris_sizey = 20; } - _eventsManager.pointeur_souris = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _eventsManager.pointeur_souris = _fileManager.loadFile(_globals.NFICHIER); _globals.clearAll(); - _fileManager.CONSTRUIT_SYSTEM("FONTE3.SPR"); - _globals.police = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "FONTE3.SPR"); + _globals.police = _fileManager.loadFile(_globals.NFICHIER); _globals.police_l = 12; _globals.police_h = 21; - _fileManager.CONSTRUIT_SYSTEM("ICONE.SPR"); - _globals.ICONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); - _fileManager.CONSTRUIT_SYSTEM("TETE.SPR"); - _globals.TETE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "ICONE.SPR"); + _globals.ICONE = _fileManager.loadFile(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "TETE.SPR"); + _globals.TETE = _fileManager.loadFile(_globals.NFICHIER); switch (_globals.FR) { case 0: - _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "ZONEAN.TXT"); - _globals.BUF_ZONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPLINK, "ZONEAN.TXT"); + _globals.BUF_ZONE = _fileManager.loadFile(_globals.NFICHIER); break; case 1: - _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "ZONE01.TXT"); - _globals.BUF_ZONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPLINK, "ZONE01.TXT"); + _globals.BUF_ZONE = _fileManager.loadFile(_globals.NFICHIER); break; case 2: - _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "ZONEES.TXT"); - _globals.BUF_ZONE = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPLINK, "ZONEES.TXT"); + _globals.BUF_ZONE = _fileManager.loadFile(_globals.NFICHIER); break; } @@ -2988,7 +2988,7 @@ void HopkinsEngine::BOOM() { _graphicsManager.FADE_LINUX = 2; if (_globals.SVGA == 1) _animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500); - if (_globals.SVGA == 2) + else if (_globals.SVGA == 2) _animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500); _soundManager.SPECIAL_SOUND = 0; @@ -3357,8 +3357,8 @@ void HopkinsEngine::JOUE_FIN() { _globals.iRegul = 0; _globals.SORTIE = 300; } - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _globals.PERSO = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; _globals.iRegul = 0; } @@ -3537,20 +3537,20 @@ void HopkinsEngine::Charge_Credits() { _globals.Credit_step = 45; switch (_globals.FR) { case 0: - _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "CREAN.TXT"); + _fileManager.constructFilename(_globals.HOPLINK, "CREAN.TXT"); break; case 1: - _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "CREFR.TXT"); + _fileManager.constructFilename(_globals.HOPLINK, "CREFR.TXT"); break; case 2: - _fileManager.CONSTRUIT_FICHIER(_globals.HOPLINK, "CREES.TXT"); + _fileManager.constructFilename(_globals.HOPLINK, "CREES.TXT"); break; default: error("Charge_Credits(): Unhandled language"); break; } - byte *bufPtr = _fileManager.CHARGE_FICHIER(_globals.NFICHIER); + byte *bufPtr = _fileManager.loadFile(_globals.NFICHIER); byte *curPtr = bufPtr; int idxLines = 0; bool loopCond = false; @@ -3905,8 +3905,8 @@ void HopkinsEngine::OCEAN(int16 a1, Common::String a2, Common::String a3, int16 _globals.AFFIVBL = true; _globals.DESACTIVE_INVENT = true; _soundManager.WSOUND(a9); - _fileManager.CONSTRUIT_SYSTEM("VAISSEAU.SPR"); - _fileManager.CHARGE_FICHIER2(_globals.NFICHIER, _globals.PERSO); + _fileManager.constructFilename(_globals.HOPSYSTEM, "VAISSEAU.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); if (a2.size()) _graphicsManager.LOAD_IMAGE(a2); @@ -3987,8 +3987,8 @@ void HopkinsEngine::OCEAN(int16 a1, Common::String a2, Common::String a3, int16 _objectsManager.SPRITE_OFF(0); _globals.AFFLI = false; _objectsManager.CLEAR_ECRAN(); - _fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _fileManager.CHARGE_FICHIER2(_globals.NFICHIER, _globals.PERSO); + _fileManager.constructFilename(_globals.HOPSYSTEM, "PERSO.SPR"); + _globals.PERSO = _fileManager.loadFile(_globals.NFICHIER); _globals.PERSO_TYPE = 0; } diff --git a/engines/hopkins/menu.cpp b/engines/hopkins/menu.cpp index 18484580e7..bcb2e3d737 100644 --- a/engines/hopkins/menu.cpp +++ b/engines/hopkins/menu.cpp @@ -84,11 +84,11 @@ int MenuManager::MENU() { _vm->_graphicsManager.FADE_INW(); if (_vm->_globals.FR == 0) - _vm->_fileManager.CONSTRUIT_SYSTEM("MENUAN.SPR"); - if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_SYSTEM("MENUFR.SPR"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_SYSTEM("MENUES.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "MENUAN.SPR"); + else if (_vm->_globals.FR == 1) + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "MENUFR.SPR"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "MENUES.SPR"); spriteData = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER); _vm->_eventsManager.MOUSE_ON(); diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index ebc1e03f1a..e0fc5fd3ec 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -120,7 +120,7 @@ byte *ObjectsManager::CAPTURE_OBJET(int objIndex, int mode) { if (_vm->_globals.ADR_FICHIER_OBJ != g_PTRNUL) ObjectsManager::DEL_FICHIER_OBJ(); if (val1 == 1) { - _vm->_fileManager.CONSTRUIT_SYSTEM("OBJET1.SPR"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "OBJET1.SPR"); _vm->_globals.ADR_FICHIER_OBJ = ObjectsManager::CHARGE_SPRITE(_vm->_globals.NFICHIER); } _vm->_globals.NUM_FICHIER_OBJ = val1; @@ -258,7 +258,7 @@ int ObjectsManager::sprite_alone(const byte *objectData, byte *sprite, int objIn byte *ObjectsManager::DEL_FICHIER_OBJ() { _vm->_globals.NUM_FICHIER_OBJ = 0; if (_vm->_globals.ADR_FICHIER_OBJ != g_PTRNUL) - _vm->_globals.ADR_FICHIER_OBJ = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.ADR_FICHIER_OBJ); + _vm->_globals.ADR_FICHIER_OBJ = _vm->_globals.LIBERE_FICHIER(_vm->_globals.ADR_FICHIER_OBJ); byte *result = g_PTRNUL; _vm->_globals.ADR_FICHIER_OBJ = g_PTRNUL; @@ -267,8 +267,7 @@ byte *ObjectsManager::DEL_FICHIER_OBJ() { // Load Sprite byte *ObjectsManager::CHARGE_SPRITE(const Common::String &file) { - _vm->_fileManager.DMESS1(); - return _vm->_fileManager.CHARGE_FICHIER(file); + return _vm->_fileManager.loadFile(file); } int ObjectsManager::capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex) { @@ -2336,8 +2335,8 @@ void ObjectsManager::CHARGE_OBSTACLE(const Common::String &file) { _vm->_linesManager.RESET_OBSTACLE(); _vm->_linesManager.TOTAL_LIGNES = 0; DERLIGNE = 0; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file); - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, file); + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); v4 = 0; v5 = 0; do { @@ -2402,13 +2401,13 @@ void ObjectsManager::CHARGE_ZONE(const Common::String &file) { ++v1; } while (v1 <= 100); - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, file); Common::File f; if (!f.exists(_vm->_globals.NFICHIER)) error("File not found : %s", _vm->_globals.NFICHIER.c_str()); - ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); v4 = 0; v18 = 0; v17 = 0; @@ -2571,8 +2570,8 @@ void ObjectsManager::PLAN_BETA() { CHARGE_OBSTACLE("PLAN.OB2"); _vm->_globals.CHARGE_CACHE("PLAN.CA2"); CHARGE_ZONE("PLAN.ZO2"); - _vm->_fileManager.CONSTRUIT_SYSTEM("VOITURE.SPR"); - sprite_ptr = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "VOITURE.SPR"); + sprite_ptr = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_animationManager.CHARGE_ANIM("PLAN"); _vm->_graphicsManager.VISU_ALL(); _vm->_graphicsManager.INI_ECRAN2("PLAN"); @@ -3005,9 +3004,9 @@ void ObjectsManager::CLEAR_ECRAN() { DERLIGNE = 0; _vm->_globals.chemin = (int16 *)g_PTRNUL; if (_vm->_globals.COUCOU != g_PTRNUL) - _vm->_globals.COUCOU = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.COUCOU); + _vm->_globals.COUCOU = _vm->_globals.LIBERE_FICHIER(_vm->_globals.COUCOU); if (g_PTRNUL != _vm->_globals.SPRITE_ECRAN) - _vm->_globals.SPRITE_ECRAN = _vm->_fileManager.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); + _vm->_globals.SPRITE_ECRAN = _vm->_globals.LIBERE_FICHIER(_vm->_globals.SPRITE_ECRAN); _vm->_eventsManager.start_x = 0; _vm->_eventsManager.souris_n = 0; Vold_taille = 200; @@ -3060,8 +3059,8 @@ void ObjectsManager::CHANGE_TETE(PlayerCharacter oldCharacter, PlayerCharacter n T_RECTIF = 0; loc = &_vm->_globals.SAUVEGARDE->realHopkins; - _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PERSO.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 0; SPRITE(_vm->_globals.PERSO, loc->xp, loc->yp, 0, 64, loc->field4, 0, 34, 190); SPRITE_ON(0); @@ -3086,8 +3085,8 @@ void ObjectsManager::CHANGE_TETE(PlayerCharacter oldCharacter, PlayerCharacter n _vm->_globals.SAUVEGARDE->data[svField357] = 0; loc = &_vm->_globals.SAUVEGARDE->samantha; - _vm->_fileManager.CONSTRUIT_SYSTEM("PSAMAN.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PSAMAN.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 2; SPRITE(_vm->_globals.PERSO, loc->xp, loc->yp, 0, 64, loc->field4, 0, 20, 127); SPRITE_ON(0); @@ -4122,10 +4121,10 @@ void ObjectsManager::OPTI_OBJET() { int v7; file = "OBJET1.ini"; - data = _vm->_fileManager.RECHERCHE_CAT(file, 1); + data = _vm->_fileManager.searchCat(file, 1); if (data == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file); - data = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, file); + data = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if ((data == g_PTRNUL) || *data != 'I' || *(data + 1) != 'N' || *(data + 2) != 'I') { @@ -4355,8 +4354,8 @@ void ObjectsManager::ACTION_DOS(int idx) { _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 1; - _vm->_fileManager.CONSTRUIT_SYSTEM("DOS.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "DOS.SPR"); + _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0); @@ -4391,8 +4390,8 @@ void ObjectsManager::ACTION_DROITE(int idx) { if (_vm->_globals.GESTE != g_PTRNUL) _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 3; - _vm->_fileManager.CONSTRUIT_SYSTEM("PROFIL.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PROFIL.SPR"); + _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (idx == 1) ACTION(_vm->_globals.GESTE, "20,19,18,17,16,15,14,13,13,13,13,13,14,15,16,17,18,19,20,-1,", 0, 0, 8, 0); @@ -4421,8 +4420,8 @@ void ObjectsManager::Q_DROITE(int idx) { if (_vm->_globals.GESTE != g_PTRNUL) _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 4; - _vm->_fileManager.CONSTRUIT_SYSTEM("3Q.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "3Q.SPR"); + _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0); @@ -4451,8 +4450,8 @@ void ObjectsManager::ACTION_FACE(int idx) { if (_vm->_globals.GESTE != g_PTRNUL) _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 2; - _vm->_fileManager.CONSTRUIT_SYSTEM("FACE.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "FACE.SPR"); + _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,9,9,9,9,9,9,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 0); @@ -4469,8 +4468,8 @@ void ObjectsManager::Q_GAUCHE(int idx) { if (_vm->_globals.GESTE != g_PTRNUL) _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 4; - _vm->_fileManager.CONSTRUIT_SYSTEM("3Q.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "3Q.SPR"); + _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (idx == 1) ACTION(_vm->_globals.GESTE, "0,1,2,3,4,5,6,7,8,8,8,8,8,7,6,5,4,3,2,1,0,-1,", 0, 0, 8, 1); @@ -4499,8 +4498,8 @@ void ObjectsManager::ACTION_GAUCHE(int idx) { if (_vm->_globals.GESTE != g_PTRNUL) _vm->_globals.GESTE = _vm->_globals.dos_free2(_vm->_globals.GESTE); _vm->_globals.GESTE_FLAG = 3; - _vm->_fileManager.CONSTRUIT_SYSTEM("PROFIL.SPR"); - _vm->_globals.GESTE = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PROFIL.SPR"); + _vm->_globals.GESTE = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); } if (idx == 1) ACTION(_vm->_globals.GESTE, "20,19,18,17,16,15,14,13,13,13,13,13,14,15,16,17,18,19,20,-1,", 0, 0, 8, 1); @@ -4651,10 +4650,10 @@ void ObjectsManager::INILINK(const Common::String &file) { v2 = 0; filename = file + ".LNK"; - ptr = _vm->_fileManager.RECHERCHE_CAT(filename, 3); + ptr = _vm->_fileManager.searchCat(filename, 3); nbytes = _vm->_globals.CAT_TAILLE; if (ptr == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename); if (!f.open(_vm->_globals.NFICHIER)) error("Error opening file - %s", _vm->_globals.NFICHIER.c_str()); @@ -4663,7 +4662,7 @@ void ObjectsManager::INILINK(const Common::String &file) { ptr = _vm->_globals.dos_malloc2(nbytes); if (g_PTRNUL == ptr) error("INILINK"); - _vm->_fileManager.bload_it(f, ptr, nbytes); + _vm->_fileManager.readStream(f, ptr, nbytes); f.close(); } if (!OBSSEUL) { @@ -4674,17 +4673,17 @@ void ObjectsManager::INILINK(const Common::String &file) { filename2 = Common::String((const char *)ptr + 1000); if (!filename2.empty()) { - _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.RECHERCHE_CAT(filename2, 8); + _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.searchCat(filename2, 8); if (_vm->_globals.CACHE_BANQUE[1] || _vm->_globals.CACHE_BANQUE[1] == g_PTRNUL) { _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, filename2); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, filename2); } else { _vm->_globals.CAT_FLAG = true; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, "RES_SLI.RES"); } - _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); + _vm->_globals.CACHE_BANQUE[1] = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.CAT_FLAG = false; v36 = 60; v37 = ptr + 1000; @@ -5639,21 +5638,21 @@ void ObjectsManager::PERSONAGE2(const Common::String &backgroundFile, const Comm if (!_vm->_globals.PERSO_TYPE) goto LABEL_70; if (!_vm->_globals.SAUVEGARDE->data[svField122] && !_vm->_globals.SAUVEGARDE->data[svField356]) { - _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PERSO.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 0; } if (!_vm->_globals.PERSO_TYPE) { LABEL_70: if (_vm->_globals.SAUVEGARDE->data[svField122] == 1) { - _vm->_fileManager.CONSTRUIT_SYSTEM("HOPFEM.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "HOPFEM.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 1; } } if (_vm->_globals.PERSO_TYPE != 2 && _vm->_globals.SAUVEGARDE->data[svField356] == 1) { - _vm->_fileManager.CONSTRUIT_SYSTEM("PSAMAN.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PSAMAN.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 2; } _vm->_globals.HOPKINS_DATA(); diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 1abe125e08..e9eca6cb5d 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -554,7 +554,7 @@ LABEL_1141: _vm->_graphicsManager.FADESPD = 1; if (_vm->_globals.SVGA == 2) _vm->_animationManager.PLAY_ANM("BOMBE1A.ANM", 100, 18, 100); - if (_vm->_globals.SVGA == 1) + else if (_vm->_globals.SVGA == 1) _vm->_animationManager.PLAY_ANM("BOMBE1.ANM", 100, 18, 100); } _vm->_graphicsManager.LOAD_IMAGE("BOMBEB"); @@ -586,7 +586,7 @@ LABEL_1141: _vm->_graphicsManager.FADE_LINUX = 2; if (_vm->_globals.SVGA == 1) _vm->_animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500); - if (_vm->_globals.SVGA == 2) + else if (_vm->_globals.SVGA == 2) _vm->_animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500); _vm->_soundManager.SPECIAL_SOUND = 0; memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x96000u); @@ -601,7 +601,7 @@ LABEL_1141: _vm->_soundManager.SPECIAL_SOUND = 199; if (_vm->_globals.SVGA == 1) _vm->_animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500); - if (_vm->_globals.SVGA == 2) + else if (_vm->_globals.SVGA == 2) _vm->_animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500); _vm->_soundManager.SPECIAL_SOUND = 0; _vm->_graphicsManager.NOFADE = true; @@ -618,7 +618,7 @@ LABEL_1141: _vm->_graphicsManager.FADE_LINUX = 2; if (_vm->_globals.SVGA == 1) _vm->_animationManager.PLAY_ANM("BOMBE2.ANM", 50, 14, 500); - if (_vm->_globals.SVGA == 2) + else if (_vm->_globals.SVGA == 2) _vm->_animationManager.PLAY_ANM("BOMBE2A.ANM", 50, 14, 500); _vm->_soundManager.SPECIAL_SOUND = 0; _vm->_graphicsManager.NOFADE = true; @@ -633,7 +633,7 @@ LABEL_1141: if ((_vm->getPlatform() != Common::kPlatformWindows) || !_vm->getIsDemo()) { if (_vm->_globals.SVGA == 1) _vm->_animationManager.PLAY_ANM("BOMBE3.ANM", 50, 14, 500); - if (_vm->_globals.SVGA == 2) + else if (_vm->_globals.SVGA == 2) _vm->_animationManager.PLAY_ANM("BOMBE3A.ANM", 50, 14, 500); memset(_vm->_graphicsManager.VESA_BUFFER, 0, 0x96000u); } @@ -1951,8 +1951,8 @@ LABEL_1141: _vm->_globals.SAUVEGARDE->data[svField354] = 1; } if (v76 == 56) { - _vm->_fileManager.CONSTRUIT_SYSTEM("HOPFEM.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "HOPFEM.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 1; _vm->_globals.SAUVEGARDE->data[svField122] = 1; _vm->_globals.HOPKINS_DATA(); @@ -1961,8 +1961,8 @@ LABEL_1141: _vm->_objectsManager.VERIFTAILLE(); } if (v76 == 57) { - _vm->_fileManager.CONSTRUIT_SYSTEM("PERSO.SPR"); - _vm->_fileManager.CHARGE_FICHIER2(_vm->_globals.NFICHIER, _vm->_globals.PERSO); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSYSTEM, "PERSO.SPR"); + _vm->_globals.PERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); _vm->_globals.PERSO_TYPE = 0; _vm->_globals.SAUVEGARDE->data[svField122] = 0; _vm->_globals.HOPKINS_DATA(); @@ -2094,7 +2094,7 @@ LABEL_1141: _vm->_globals.NOPARLE = false; if (_vm->_globals.SVGA == 1) _vm->_animationManager.PLAY_ANM2("T421.ANM", 100, 14, 500); - if (_vm->_globals.SVGA == 2) + else if (_vm->_globals.SVGA == 2) _vm->_animationManager.PLAY_ANM2("T421a.ANM", 100, 14, 500); _vm->_eventsManager.VBL(); _vm->_eventsManager.VBL(); diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 1f7e6a9ee0..6c01051d60 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -344,7 +344,7 @@ void SoundManager::WSOUND_OFF() { void SoundManager::PLAY_MOD(const Common::String &file) { if (!MUSICOFF) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPMUSIC, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPMUSIC, file); if (MOD_FLAG) { STOP_MUSIC(); DEL_MUSIC(); @@ -569,30 +569,30 @@ bool SoundManager::VOICE_MIX(int voiceId, int voiceMode) { filename = Common::String::format("%s%d", prefix.c_str(), fileNumber); - if (!_vm->_fileManager.RECHERCHE_CAT(filename + ".WAV", 9)) { + if (!_vm->_fileManager.searchCat(filename + ".WAV", 9)) { if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); - if (!_vm->_globals.FR) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VAN.RES"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + else if (!_vm->_globals.FR) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals.CAT_POSI; catLen = _vm->_globals.CAT_TAILLE; - } else if (!_vm->_fileManager.RECHERCHE_CAT(filename + ".APC", 9)) { + } else if (!_vm->_fileManager.searchCat(filename + ".APC", 9)) { if (_vm->_globals.FR == 1) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VFR.RES"); - if (!_vm->_globals.FR) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VAN.RES"); - if (_vm->_globals.FR == 2) - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, "RES_VES.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VFR.RES"); + else if (!_vm->_globals.FR) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VAN.RES"); + else if (_vm->_globals.FR == 2) + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, "RES_VES.RES"); catPos = _vm->_globals.CAT_POSI; catLen = _vm->_globals.CAT_TAILLE; } else { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename + ".WAV"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".WAV"); if (!f.exists(_vm->_globals.NFICHIER)) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPVOICE, filename + ".APC"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPVOICE, filename + ".APC"); if (!f.exists(_vm->_globals.NFICHIER)) return false; } @@ -671,7 +671,7 @@ void SoundManager::MODSetMusicVolume(int volume) { } void SoundManager::CHARGE_SAMPLE(int wavIndex, const Common::String &file) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 0); SOUND[wavIndex]._active = true; } @@ -803,7 +803,7 @@ void SoundManager::LOAD_SAMPLE2_SDL(int wavIndex, const Common::String &filename } void SoundManager::LOAD_NWAV(const Common::String &file, int wavIndex) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPSOUND, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPSOUND, file); LOAD_SAMPLE2_SDL(wavIndex, _vm->_globals.NFICHIER, 1); } diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index 9bdaae155f..5cb1147169 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -71,12 +71,12 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { _vm->_graphicsManager.no_scroll = 1; bool old_DESACTIVE_INVENT = _vm->_globals.DESACTIVE_INVENT; _vm->_globals.DESACTIVE_INVENT = true; - BUFFERPERSO = _vm->_fileManager.RECHERCHE_CAT(filename, 5); + BUFFERPERSO = _vm->_fileManager.searchCat(filename, 5); TAILLEPERSO = _vm->_globals.CAT_TAILLE; if (BUFFERPERSO == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename); - BUFFERPERSO = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); - TAILLEPERSO = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, filename); + BUFFERPERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + TAILLEPERSO = _vm->_fileManager.fileSize(_vm->_globals.NFICHIER); } _vm->_globals.SAUVEGARDE->data[svField4] = 0; RENVOIE_FICHIER(40, v16, (const char *)BUFFERPERSO); @@ -92,21 +92,21 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { v2 = (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 40); v3 = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110; PCHERCHE = 20 * (int16)READ_LE_UINT16((uint16 *)BUFFERPERSO + 42) + 110; - PERSOSPR = _vm->_fileManager.RECHERCHE_CAT(v16, 7); + PERSOSPR = _vm->_fileManager.searchCat(v16, 7); if (PERSOSPR) { _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, v16); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, v16); } else { _vm->_globals.CAT_FLAG = true; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, "RES_SAN.RES"); } PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER); _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR"); + _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u); - if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2)) + else if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2)) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x96000u); if (!_vm->_graphicsManager.nbrligne) @@ -200,12 +200,12 @@ void TalkManager::PARLER_PERSO2(const Common::String &filename) { STATI = 1; bool v7 = _vm->_globals.DESACTIVE_INVENT; _vm->_globals.DESACTIVE_INVENT = 1; - BUFFERPERSO = _vm->_fileManager.RECHERCHE_CAT(filename, 5); + BUFFERPERSO = _vm->_fileManager.searchCat(filename, 5); TAILLEPERSO = _vm->_globals.CAT_TAILLE; if (BUFFERPERSO == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, filename); - BUFFERPERSO = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); - TAILLEPERSO = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, filename); + BUFFERPERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + TAILLEPERSO = _vm->_fileManager.fileSize(_vm->_globals.NFICHIER); } _vm->_globals.SAUVEGARDE->data[svField4] = 0; @@ -649,7 +649,7 @@ int TalkManager::VERIF_BOITE(int idx, const Common::String &file, int a3) { v18 = 0; _vm->_globals.police_l = 11; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, file); + _vm->_fileManager.constructFilename(_vm->_globals.HOPLINK, file); // Build up the filename filename = dest = _vm->_globals.NFICHIER; @@ -1219,12 +1219,12 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { _vm->_objectsManager.NUMZONE = -1; _vm->_eventsManager.btsouris = 4; _vm->_eventsManager.CHANGE_MOUSE(0); - BUFFERPERSO = _vm->_fileManager.RECHERCHE_CAT(a2, 5); + BUFFERPERSO = _vm->_fileManager.searchCat(a2, 5); TAILLEPERSO = _vm->_globals.CAT_TAILLE; if (BUFFERPERSO == g_PTRNUL) { - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, a2); - BUFFERPERSO = _vm->_fileManager.CHARGE_FICHIER(_vm->_globals.NFICHIER); - TAILLEPERSO = _vm->_fileManager.FLONG(_vm->_globals.NFICHIER); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, a2); + BUFFERPERSO = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); + TAILLEPERSO = _vm->_fileManager.fileSize(_vm->_globals.NFICHIER); } RENVOIE_FICHIER(40, v23, (const char *)BUFFERPERSO); RENVOIE_FICHIER(0, v22, (const char *)BUFFERPERSO); @@ -1236,18 +1236,18 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) { if (!v6) { v20 = Common::String::format("IM%d", _vm->_globals.ECRAN); } - PERSOSPR = _vm->_fileManager.RECHERCHE_CAT(v23, 7); + PERSOSPR = _vm->_fileManager.searchCat(v23, 7); if (PERSOSPR) { _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, v23); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, v23); } else { _vm->_globals.CAT_FLAG = true; - _vm->_fileManager.CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.RES"); + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, "RES_SAN.RES"); } PERSOSPR = _vm->_objectsManager.CHARGE_SPRITE(_vm->_globals.NFICHIER); _vm->_globals.CAT_FLAG = false; - _vm->_fileManager.CONSTRUIT_LINUX("TEMP.SCR"); + _vm->_fileManager.constructLinuxFilename("TEMP.SCR"); if (_vm->_graphicsManager.nbrligne == SCREEN_WIDTH) _vm->_saveLoadManager.SAUVE_FICHIER(_vm->_globals.NFICHIER, _vm->_graphicsManager.VESA_SCREEN, 0x4B000u); if (_vm->_graphicsManager.nbrligne == (SCREEN_WIDTH * 2)) |