diff options
author | Max Horn | 2009-01-16 21:08:55 +0000 |
---|---|---|
committer | Max Horn | 2009-01-16 21:08:55 +0000 |
commit | c0e1dbf1ac1542bcd2c6789a6d74221ec40b3f1a (patch) | |
tree | f84a3e4a30cba69a5749f1af0ecd301a65d8cc10 | |
parent | 1082d82ba8d4ab966cba862b57f66ac9e059f656 (diff) | |
download | scummvm-rg350-c0e1dbf1ac1542bcd2c6789a6d74221ec40b3f1a.tar.gz scummvm-rg350-c0e1dbf1ac1542bcd2c6789a6d74221ec40b3f1a.tar.bz2 scummvm-rg350-c0e1dbf1ac1542bcd2c6789a6d74221ec40b3f1a.zip |
TUCKER: Changed loadFile and loadImage to take filename as parameter (trying to get rid of _fileToLoad)
svn-id: r35874
-rw-r--r-- | engines/tucker/resource.cpp | 109 | ||||
-rw-r--r-- | engines/tucker/sequences.cpp | 77 | ||||
-rw-r--r-- | engines/tucker/tucker.cpp | 19 | ||||
-rw-r--r-- | engines/tucker/tucker.h | 4 |
4 files changed, 96 insertions, 113 deletions
diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 100913952b..d3387bf9af 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -161,38 +161,40 @@ public: int _pos; }; -uint8 *TuckerEngine::loadFile(uint8 *p) { +uint8 *TuckerEngine::loadFile(const char *fname, uint8 *p) { + char filename[80]; + strcpy(filename, fname); if (_gameLang == Common::DE_DEU) { - if (strcmp(_fileToLoad, "bgtext.c") == 0) { - strcpy(_fileToLoad, "bgtextgr.c"); - } else if (strcmp(_fileToLoad, "charname.c") == 0) { - strcpy(_fileToLoad, "charnmgr.c"); - } else if (strcmp(_fileToLoad, "data5.c") == 0) { - strcpy(_fileToLoad, "data5gr.c"); - } else if (strcmp(_fileToLoad, "infobar.txt") == 0) { - strcpy(_fileToLoad, "infobrgr.txt"); - } else if (strcmp(_fileToLoad, "charsize.dta") == 0) { - strcpy(_fileToLoad, "charszgr.dta"); - } else if (strncmp(_fileToLoad, "objtxt", 6) == 0) { - const char num = _fileToLoad[6]; - snprintf(_fileToLoad, sizeof(_fileToLoad), "objtx%cgr.c", num); - } else if (strncmp(_fileToLoad, "pt", 2) == 0) { - const char num = _fileToLoad[2]; - snprintf(_fileToLoad, sizeof(_fileToLoad), "pt%ctxtgr.c", num); + if (strcmp(filename, "bgtext.c") == 0) { + strcpy(filename, "bgtextgr.c"); + } else if (strcmp(filename, "charname.c") == 0) { + strcpy(filename, "charnmgr.c"); + } else if (strcmp(filename, "data5.c") == 0) { + strcpy(filename, "data5gr.c"); + } else if (strcmp(filename, "infobar.txt") == 0) { + strcpy(filename, "infobrgr.txt"); + } else if (strcmp(filename, "charsize.dta") == 0) { + strcpy(filename, "charszgr.dta"); + } else if (strncmp(filename, "objtxt", 6) == 0) { + const char num = filename[6]; + snprintf(filename, sizeof(filename), "objtx%cgr.c", num); + } else if (strncmp(filename, "pt", 2) == 0) { + const char num = filename[2]; + snprintf(filename, sizeof(filename), "pt%ctxtgr.c", num); } } _fileLoadSize = 0; bool decode = false; if (_gameFlags & kGameFlagEncodedData) { - char *ext = strrchr(_fileToLoad, '.'); + char *ext = strrchr(filename, '.'); if (ext && strcmp(ext + 1, "c") == 0) { strcpy(ext + 1, "enc"); decode = true; } } Common::File f; - if (!f.open(_fileToLoad)) { - warning("Unable to open '%s'", _fileToLoad); + if (!f.open(filename)) { + warning("Unable to open '%s'", filename); return 0; } const int sz = f.size(); @@ -227,12 +229,15 @@ void TuckerEngine::closeCompressedSoundFile() { _fCompressedSound.close(); } -void TuckerEngine::loadImage(uint8 *dst, int type) { +void TuckerEngine::loadImage(const char *fname, uint8 *dst, int type) { + char filename[80]; + strcpy(filename, fname); + Common::File f; - if (!f.open(_fileToLoad)) { + if (!f.open(filename)) { // workaround for "paper-3.pcx" / "paper_3.pcx" bool tryOpen = false; - for (char *p = _fileToLoad; *p; ++p) { + for (char *p = filename; *p; ++p) { switch (*p) { case '-': *p = '_'; @@ -244,8 +249,8 @@ void TuckerEngine::loadImage(uint8 *dst, int type) { break; } } - if (!tryOpen || !f.open(_fileToLoad)) { - warning("Unable to open '%s'", _fileToLoad); + if (!tryOpen || !f.open(filename)) { + warning("Unable to open '%s'", filename); return; } } @@ -277,16 +282,14 @@ void TuckerEngine::loadImage(uint8 *dst, int type) { } void TuckerEngine::loadCursor() { - strcpy(_fileToLoad, "pointer.pcx"); - loadImage(_loadTempBuf, 0); + loadImage("pointer.pcx", _loadTempBuf, 0); for (int cursor = 0; cursor < 7; ++cursor) { Graphics::encodeRAW(_loadTempBuf + cursor * 320 * 16, _cursorGfxBuf + cursor * 256, 16, 16); } } void TuckerEngine::loadCharset() { - strcpy(_fileToLoad, "charset.pcx"); - loadImage(_loadTempBuf, 0); + loadImage("charset.pcx", _loadTempBuf, 0); switch (_gameLang) { case Common::EN_ANY: Graphics::setCharset(kCharsetTypeEng); @@ -302,8 +305,7 @@ void TuckerEngine::loadCharset2() { _charWidthTable[58] = 7; _charWidthTable[32] = 15; memcpy(_charWidthTable + 65, _charWidthCharset2, 58); - strcpy(_fileToLoad, "char2.pcx"); - loadImage(_loadTempBuf, 0); + loadImage("char2.pcx", _loadTempBuf, 0); Graphics::setCharset(kCharsetTypeCredits); loadCharsetHelper(); } @@ -320,8 +322,7 @@ void TuckerEngine::loadCharsetHelper() { } void TuckerEngine::loadCharSizeDta() { - strcpy(_fileToLoad, "charsize.dta"); - loadFile(_loadTempBuf); + loadFile("charsize.dta", _loadTempBuf); if (_fileLoadSize != 0) { DataTokenizer t(_loadTempBuf, _fileLoadSize, true); for (int i = 0; i < 256; ++i) { @@ -335,7 +336,7 @@ void TuckerEngine::loadCharSizeDta() { void TuckerEngine::loadPanel() { strcpy(_fileToLoad, (_panelNum == 0) ? "panel1.pcx" : "panel2.pcx"); - loadImage(_panelGfxBuf, 0); + loadImage(_fileToLoad, _panelGfxBuf, 0); } void TuckerEngine::loadBudSpr(int startOffset) { @@ -357,7 +358,7 @@ void TuckerEngine::loadBudSpr(int startOffset) { sprintf(_fileToLoad, "mac_%d.pcx", frame + 1); break; } - loadImage(_loadTempBuf, 0); + loadImage(_fileToLoad, _loadTempBuf, 0); ++frame; } int sz = Graphics::encodeRLE(_loadTempBuf + _spriteFramesTable[i].sourceOffset, _spritesGfxBuf + spriteOffset, _spriteFramesTable[i].xSize, _spriteFramesTable[i].ySize); @@ -367,8 +368,7 @@ void TuckerEngine::loadBudSpr(int startOffset) { } void TuckerEngine::loadCTable01(int locationNum, int firstSpriteNum, int &lastSpriteNum) { - strcpy(_fileToLoad, "ctable01.c"); - loadFile(_loadTempBuf); + loadFile("ctable01.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); lastSpriteNum = firstSpriteNum; int count = 0; @@ -404,8 +404,7 @@ void TuckerEngine::loadCTable02(int fl) { assert(fl == 0); int entry = 0; int i = 0; - strcpy(_fileToLoad, "ctable02.c"); - loadFile(_loadTempBuf); + loadFile("ctable02.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); while (t.findNextToken(kDataTokenDw)) { _spriteAnimationsTable[entry].numParts = t.getNextInteger(); @@ -454,9 +453,8 @@ void TuckerEngine::loadLoc() { Graphics::copyFrom640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf + 89600, 320, 140); } if (_locationNum == 1) { - strcpy(_fileToLoad, "rochpath.pcx"); _loadLocBufPtr = _quadBackgroundGfxBuf + 89600; - loadImage(_loadLocBufPtr, 0); + loadImage("rochpath.pcx", _loadLocBufPtr, 0); } if (i > 3) { sprintf(_fileToLoad, "loc%02dd.pcx", _locationNum); @@ -488,10 +486,10 @@ void TuckerEngine::loadObj() { _currentPartNum = _partNum; sprintf(_fileToLoad, "objtxt%d.c", _partNum); free(_objTxtBuf); - _objTxtBuf = loadFile(); + _objTxtBuf = loadFile(_fileToLoad, 0); sprintf(_fileToLoad, "pt%dtext.c", _partNum); free(_ptTextBuf); - _ptTextBuf = loadFile(); + _ptTextBuf = loadFile(_fileToLoad, 0); loadData(); loadPanObj(); } @@ -499,8 +497,7 @@ void TuckerEngine::loadObj() { void TuckerEngine::loadData() { int flag = 0; int objNum = _partNum * 10; - strcpy(_fileToLoad, "data.c"); - loadFile(_loadTempBuf); + loadFile("data.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); _dataCount = 0; int count = 0; @@ -542,7 +539,7 @@ void TuckerEngine::loadData() { int offset = 0; for (int i = 0; i < count; ++i) { sprintf(_fileToLoad, "scrobj%d%d.pcx", _partNum, i); - loadImage(_loadTempBuf, 0); + loadImage(_fileToLoad, _loadTempBuf, 0); offset = loadDataHelper(offset, i); } } @@ -560,7 +557,7 @@ int TuckerEngine::loadDataHelper(int offset, int index) { void TuckerEngine::loadPanObj() { sprintf(_fileToLoad, "panobjs%d.pcx", _partNum); - loadImage(_loadTempBuf, 0); + loadImage(_fileToLoad, _loadTempBuf, 0); int offset = 0; for (int y = 0; y < 5; ++y) { for (int x = 0; x < 10; ++x) { @@ -572,8 +569,7 @@ void TuckerEngine::loadPanObj() { } void TuckerEngine::loadData3() { - strcpy(_fileToLoad, "data3.c"); - loadFile(_loadTempBuf); + loadFile("data3.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); _locationAnimationsCount = 0; if (t.findIndex(_locationNum)) { @@ -617,8 +613,7 @@ void TuckerEngine::loadData3() { } void TuckerEngine::loadData4() { - strcpy(_fileToLoad,"data4.c"); - loadFile(_loadTempBuf); + loadFile("data4.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); t.findNextToken(kDataTokenDw); _gameDebug = t.getNextInteger() != 0; @@ -667,7 +662,7 @@ void TuckerEngine::loadActionFile() { strcpy(_fileToLoad, "action3.c"); break; } - loadFile(_loadTempBuf); + loadFile(_fileToLoad, _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); _actionsCount = 0; if (t.findIndex(_locationNum)) { @@ -699,8 +694,7 @@ void TuckerEngine::loadActionFile() { } void TuckerEngine::loadCharPos() { - strcpy(_fileToLoad, "charpos.c"); - loadFile(_loadTempBuf); + loadFile("charpos.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); _charPosCount = 0; if (t.findIndex(_locationNum)) { @@ -766,7 +760,7 @@ void TuckerEngine::loadSprA02_01() { const int count = _sprA02LookupTable[_locationNum]; for (int i = 1; i < count + 1; ++i) { sprintf(_fileToLoad, "sprites/a%02d_%02d.spr", _locationNum, i); - _sprA02Table[i] = loadFile(); + _sprA02Table[i] = loadFile(_fileToLoad, 0); } _sprA02Table[0] = _sprA02Table[1]; } @@ -784,7 +778,7 @@ void TuckerEngine::loadSprC02_01() { const int count = _sprC02LookupTable[_locationNum]; for (int i = 1; i < count + 1; ++i) { sprintf(_fileToLoad, "sprites/c%02d_%02d.spr", _locationNum, i); - _sprC02Table[i] = loadFile(); + _sprC02Table[i] = loadFile(_fileToLoad, 0); } _sprC02Table[0] = _sprC02Table[1]; _spritesCount = _sprC02LookupTable2[_locationNum]; @@ -804,8 +798,7 @@ void TuckerEngine::unloadSprC02_01() { } void TuckerEngine::loadFx() { - strcpy(_fileToLoad, "fx.c"); - loadFile(_loadTempBuf); + loadFile("fx.c", _loadTempBuf); DataTokenizer t(_loadTempBuf, _fileLoadSize); t.findIndex(_locationNum); t.findNextToken(kDataTokenDw); diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 8fb06403c4..bda1dd7bc0 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -63,10 +63,8 @@ void TuckerEngine::handleCreditsSequence() { _spritesTable[i].state = -1; _spritesTable[i].stateIndex = -1; } - strcpy(_fileToLoad, "credits.txt"); - loadFile(_ptTextBuf); - strcpy(_fileToLoad, "loc74.pcx"); - loadImage(_quadBackgroundGfxBuf, 1); + loadFile("credits.txt", _ptTextBuf); + loadImage("loc74.pcx", _quadBackgroundGfxBuf, 1); startSpeechSound(9001, 120); _timerCounter2 = 0; _fadePaletteCounter = 0; @@ -128,30 +126,30 @@ void TuckerEngine::handleCreditsSequence() { _spritesTable[i].stateIndex = -1; } ++num; - switch (num) { - case 1: - strcpy(_fileToLoad, "loc75.pcx"); - break; - case 2: - strcpy(_fileToLoad, "loc76.pcx"); - break; - case 3: - strcpy(_fileToLoad, "paper-3.pcx"); - break; - case 4: - strcpy(_fileToLoad, "loc77.pcx"); - break; - case 5: - strcpy(_fileToLoad, "loc78.pcx"); - break; - } if (num == 6) { for (int i = 0; i < 16; ++i) { sprintf(_fileToLoad, "cogs%04d.pcx", i); - loadImage(imgBuf + i * 64000, 2); + loadImage(_fileToLoad, imgBuf + i * 64000, 2); } } else { - loadImage(_quadBackgroundGfxBuf, 2); + switch (num) { + case 1: + strcpy(_fileToLoad, "loc75.pcx"); + break; + case 2: + strcpy(_fileToLoad, "loc76.pcx"); + break; + case 3: + strcpy(_fileToLoad, "paper-3.pcx"); + break; + case 4: + strcpy(_fileToLoad, "loc77.pcx"); + break; + case 5: + strcpy(_fileToLoad, "loc78.pcx"); + break; + } + loadImage(_fileToLoad, _quadBackgroundGfxBuf, 2); } _spritesCount = _creditsSequenceData2[num]; ++_flagsTable[236]; @@ -173,8 +171,7 @@ void TuckerEngine::handleCongratulationsSequence() { _timerCounter2 = 0; _fadePaletteCounter = 0; stopSounds(); - strcpy(_fileToLoad, "congrat.pcx"); - loadImage(_loadTempBuf, 1); + loadImage("congrat.pcx", _loadTempBuf, 1); Graphics::copyTo640(_locationBackgroundGfxBuf, _loadTempBuf, 320, 320, 200); _fullRedrawCounter = 2; redrawScreen(0); @@ -215,7 +212,15 @@ void TuckerEngine::handleNewPartSequence() { strcpy(_fileToLoad, "pt3bak.pcx"); break; } - loadImage(_quadBackgroundGfxBuf, 1); + loadImage(_fileToLoad, _quadBackgroundGfxBuf, 1); + _spritesCount = 1; + memset(&_spritesTable[0], 0, sizeof(Sprite)); + _spritesTable[0].state = -1; + _spritesTable[0].stateIndex = -1; + int currentLocation = _locationNum; + _locationNum = 98; + unloadSprA02_01(); + unloadSprC02_01(); switch (_partNum) { case 1: strcpy(_fileToLoad, "sprites/partone.spr"); @@ -227,15 +232,7 @@ void TuckerEngine::handleNewPartSequence() { strcpy(_fileToLoad, "sprites/partthr.spr"); break; } - _spritesCount = 1; - memset(&_spritesTable[0], 0, sizeof(Sprite)); - _spritesTable[0].state = -1; - _spritesTable[0].stateIndex = -1; - int currentLocation = _locationNum; - _locationNum = 98; - unloadSprA02_01(); - unloadSprC02_01(); - _sprC02Table[1] = loadFile(); + _sprC02Table[1] = loadFile(_fileToLoad, 0); startSpeechSound(9000, 60); _fadePaletteCounter = 0; do { @@ -287,7 +284,7 @@ void TuckerEngine::handleMeanwhileSequence() { if (_flagsTable[215] == 0 && _flagsTable[231] == 1) { strcpy(_fileToLoad, "loc80.pcx"); } - loadImage(_quadBackgroundGfxBuf + 89600, 1); + loadImage(_fileToLoad, _quadBackgroundGfxBuf + 89600, 1); _fadePaletteCounter = 0; for (int i = 0; i < 60; ++i) { if (_fadePaletteCounter < 16) { @@ -314,10 +311,8 @@ void TuckerEngine::handleMeanwhileSequence() { } void TuckerEngine::handleMapSequence() { - strcpy(_fileToLoad, "map2.pcx"); - loadImage(_quadBackgroundGfxBuf + 89600, 0); - strcpy(_fileToLoad, "map1.pcx"); - loadImage(_loadTempBuf, 1); + loadImage("map2.pcx", _quadBackgroundGfxBuf + 89600, 0); + loadImage("map1.pcx", _loadTempBuf, 1); _selectedObject.locationObject_locationNum = 0; if (_flagsTable[7] > 0) { copyMapRect(0, 0, 140, 86); @@ -455,7 +450,7 @@ int TuckerEngine::handleSpecialObjectSelectionSequence() { --_fadePaletteCounter; } _mouseClick = 1; - loadImage(_quadBackgroundGfxBuf, 1); + loadImage(_fileToLoad, _quadBackgroundGfxBuf, 1); _fadePaletteCounter = 0; while (!_quitGame) { waitForTimer(2); diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index 165ecf4576..12f966ba9d 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -331,16 +331,11 @@ void TuckerEngine::mainLoop() { loadCharSizeDta(); loadCharset(); loadPanel(); - strcpy(_fileToLoad, "infobar.txt"); - loadFile(_infoBarBuf); - strcpy(_fileToLoad, "data5.c"); - _data5Buf = loadFile(); - strcpy(_fileToLoad, "bgtext.c"); - _bgTextBuf = loadFile(); - strcpy(_fileToLoad, "charname.c"); - _charNameBuf = loadFile(); - strcpy(_fileToLoad, "csdata.c"); - _csDataBuf = loadFile(); + loadFile("infobar.txt", _infoBarBuf); + _data5Buf = loadFile("data5.c", 0); + _bgTextBuf = loadFile("bgtext.c", 0); + _charNameBuf = loadFile("charname.c", 0); + _csDataBuf = loadFile("csdata.c", 0); _csDataSize = _fileLoadSize; _currentSaveLoadGameState = 1; @@ -720,12 +715,12 @@ void TuckerEngine::setupNewLocation() { } } -void TuckerEngine::copyLocBitmap(int offset, bool isMask) { +void TuckerEngine::copyLocBitmap(const char *filename, int offset, bool isMask) { int type = !isMask ? 1 : 0; if (offset > 0 && _locationNum == 16) { type = 0; } - loadImage(_loadTempBuf, type); + loadImage(filename, _loadTempBuf, type); uint8 *dst = isMask ? _locationBackgroundMaskBuf : _locationBackgroundGfxBuf; dst += offset; const uint8 *src = _loadTempBuf; diff --git a/engines/tucker/tucker.h b/engines/tucker/tucker.h index e67fd61310..9d5110cbb7 100644 --- a/engines/tucker/tucker.h +++ b/engines/tucker/tucker.h @@ -541,8 +541,8 @@ protected: void openCompressedSoundFile(); void closeCompressedSoundFile(); - uint8 *loadFile(uint8 *p = 0); - void loadImage(uint8 *dst, int a); + uint8 *loadFile(const char *filename, uint8 *p); + void loadImage(const char *filename, uint8 *dst, int a); void loadCursor(); void loadCharset(); void loadCharset2(); |