From c36104ac0ca2f350decd4622a70690f651ce7446 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 22 Dec 2005 18:14:52 +0000 Subject: Completed implementation of processItemDrop also changed implementation of itemDropDown a bit. Implemented new opcodes: - cmd_fadeSpecialPalette - cmd_setCustomPaletteRange svn-id: r19828 --- kyra/kyra.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++--- kyra/kyra.h | 8 +++++ kyra/screen.cpp | 13 +++++++++ kyra/screen.h | 1 + kyra/script_v1.cpp | 10 +++++-- kyra/staticres.cpp | 23 ++++++++++++++- 6 files changed, 132 insertions(+), 8 deletions(-) (limited to 'kyra') diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index 828e31cbab..2de295f445 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -371,6 +371,8 @@ int KyraEngine::init(GameDetector &detector) { _unkScreenVar1 = 1; _unkScreenVar2 = 0; _unkScreenVar3 = 0; + + memset(_specialPalettes, 0, sizeof(_specialPalettes)); return 0; } @@ -2987,8 +2989,7 @@ int KyraEngine::processItemDrop(uint16 sceneId, uint8 item, int x, int y, int un } if (unk1 == 2) { - warning("processItemDrop unk1 == 2 is NOT implemented"); - // XXX + itemSpecialFX(x, y, item); } if (unk1 == 0) { @@ -3115,9 +3116,13 @@ void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, ++addY; drawY = tempY - 16; backUpRect0(drawX, drawY); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; _screen->drawShape(0, _shapes[220+item], drawX, drawY, 0, 0); - delay(1); _screen->updateScreen(); + while (_system->getMillis() < nextTime) { + if ((nextTime - _system->getMillis()) >= 10) + delay(10); + } } bool skip = false; @@ -3154,9 +3159,13 @@ void KyraEngine::itemDropDown(int x, int y, int destX, int destY, byte freeItem, drawX = (unkX >> 4) - 8; drawY = tempY - 16; backUpRect0(drawX, drawY); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; _screen->drawShape(0, _shapes[220+item], drawX, drawY, 0, 0); - delay(1); _screen->updateScreen(); + while (_system->getMillis() < nextTime) { + if ((nextTime - _system->getMillis()) >= 10) + delay(10); + } } restoreRect0(drawX, drawY); } else { @@ -3185,6 +3194,74 @@ void KyraEngine::dropItem(int unk1, int item, int x, int y, int unk2) { } } +void KyraEngine::itemSpecialFX(int x, int y, int item) { + debug(9, "itemSpecialFX(%d, %d, %d)", x, y, item); + if (item == 41) { + itemSpecialFX1(x, y, item); + } else { + itemSpecialFX2(x, y, item); + } +} + +void KyraEngine::itemSpecialFX1(int x, int y, int item) { + debug(9, "itemSpecialFX1(%d, %d, %d)", x, y, item); + uint8 *shape = _shapes[220+item]; + x -= 8; + int startY = y; + y -= 15; + _screen->hideMouse(); + backUpRect0(x, y); + for (int i = 1; i <= 16; ++i) { + _screen->setNewShapeHeight(shape, i); + --startY; + restoreRect0(x, y); + uint32 nextTime = _system->getMillis() + 1 * _tickLength; + _screen->drawShape(0, shape, x, startY, 0, 0); + _screen->updateScreen(); + while (_system->getMillis() < nextTime) { + if ((nextTime - _system->getMillis()) >= 10) + delay(10); + } + } + restoreRect0(x, y); + _screen->showMouse(); +} + +void KyraEngine::itemSpecialFX2(int x, int y, int item) { + debug(9, "itemSpecialFX2(%d, %d, %d)", x, y, item); + x -= 8; + y -= 15; + int yAdd = (int8)(((16 - _itemTable[item].height) >> 1) & 0xFF); + backUpRect0(x, y); + if (item >= 80 && item <= 89) { + // snd_kyraPlaySound(55); + } + + for (int i = 201; i <= 205; ++i) { + restoreRect0(x, y); + uint32 nextTime = _system->getMillis() + 3 * _tickLength; + _screen->drawShape(0, _shapes[4+i], x, y + yAdd, 0, 0); + _screen->updateScreen(); + while (_system->getMillis() < nextTime) { + if ((nextTime - _system->getMillis()) >= 10) + delay(10); + } + } + + for (int i = 204; i >= 201; --i) { + restoreRect0(x, y); + uint32 nextTime = _system->getMillis() + 3 * _tickLength; + _screen->drawShape(0, _shapes[220+item], x, y, 0, 0); + _screen->drawShape(0, _shapes[4+i], x, y + yAdd, 0, 0); + _screen->updateScreen(); + while (_system->getMillis() < nextTime) { + if ((nextTime - _system->getMillis()) >= 10) + delay(10); + } + } + restoreRect0(x, y); +} + #pragma mark - #pragma mark - Animation specific code #pragma mark - diff --git a/kyra/kyra.h b/kyra/kyra.h index 5b6896f742..464e5c7c42 100644 --- a/kyra/kyra.h +++ b/kyra/kyra.h @@ -191,6 +191,9 @@ public: const char **seqCPSTable() { return (const char **)_seq_CPSTable; } const char **seqCOLTable() { return (const char **)_seq_COLTable; } const char **seqTextsTable() { return (const char **)_seq_textsTable; } + + const uint8 **palTable1() { return (const uint8 **)&_specialPalettes[0]; } + const uint8 **palTable2() { return (const uint8 **)&_specialPalettes[29]; } bool seq_skipSequence() const; void quitGame(); @@ -491,6 +494,9 @@ protected: int isDropable(int x, int y); void itemDropDown(int x, int y, int destX, int destY, byte freeItem, int item); void dropItem(int unk1, int item, int x, int y, int unk2); + void itemSpecialFX(int x, int y, int item); + void itemSpecialFX1(int x, int y, int item); + void itemSpecialFX2(int x, int y, int item); void animRemoveGameItem(int index); void animAddGameItem(int index, uint16 sceneId); @@ -713,6 +719,8 @@ protected: int _roomFilenameTableSize; uint8 *_amuleteAnim; + + uint8 *_specialPalettes[33]; Timer _timers[34]; uint32 _timerNextRun; diff --git a/kyra/screen.cpp b/kyra/screen.cpp index 3c42de0461..de1325452d 100644 --- a/kyra/screen.cpp +++ b/kyra/screen.cpp @@ -140,6 +140,19 @@ void Screen::fadeToBlack() { fadePalette(blackPal, 0x54); } +void Screen::fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime) { + debug(9, "fadeSpecialPalette(%d, %d, %d, %d)", palIndex, startIndex, size, fadeTime); + assert(_vm->palTable1()[palIndex]); + assert(_currentPalette); + uint8 tempPal[768]; + memcpy(tempPal, _currentPalette, 768); + memcpy(&tempPal[startIndex*3], _vm->palTable1()[palIndex], size*3); + fadePalette(tempPal, fadeTime*9); + memcpy(&_currentPalette[startIndex*3], &tempPal[startIndex*3], size*3); + setScreenPalette(_currentPalette); + _system->updateScreen(); +} + void Screen::fadePalette(const uint8 *palData, int delay) { debug(9, "Screen::fadePalette(0x%X, %d)", palData, delay); uint8 fadePal[768]; diff --git a/kyra/screen.h b/kyra/screen.h index 1266719c1c..f64a0fb07d 100644 --- a/kyra/screen.h +++ b/kyra/screen.h @@ -92,6 +92,7 @@ public: void setPagePixel(int pageNum, int x, int y, uint8 color); void fadeFromBlack(); void fadeToBlack(); + void fadeSpecialPalette(int palIndex, int startIndex, int size, int fadeTime); void fadePalette(const uint8 *palData, int delay); void setScreenPalette(const uint8 *palData); void copyToPage0(int y, int h, uint8 page, uint8 *seqBuf); diff --git a/kyra/script_v1.cpp b/kyra/script_v1.cpp index 0a8b897ea9..7dbc143b08 100644 --- a/kyra/script_v1.cpp +++ b/kyra/script_v1.cpp @@ -509,7 +509,8 @@ int KyraEngine::cmd_runSceneAnimUntilDone(ScriptState *script) { } int KyraEngine::cmd_fadeSpecialPalette(ScriptState *script) { - warning("STUB: cmd_fadeSpecialPalette"); + debug(3, "cmd_fadeSpecialPalette(0x%X) (%d, %d, %d, %d)", script, stackPos(0), stackPos(1), stackPos(2), stackPos(3)); + _screen->fadeSpecialPalette(stackPos(0), stackPos(1), stackPos(2), stackPos(3)); return 0; } @@ -791,7 +792,10 @@ int KyraEngine::cmd_restoreAllObjectBackgrounds(ScriptState *script) { } int KyraEngine::cmd_setCustomPaletteRange(ScriptState *script) { - warning("STUB: cmd_setCustomPaletteRange"); + debug(3, "cmd_setCustomPaletteRange(0x%X) (%d, %d, %d)", script, stackPos(0), stackPos(1), stackPos(2)); + uint8 *screenPal = _screen->_currentPalette; + memcpy(&screenPal[stackPos(1)*3], _specialPalettes[stackPos(0)], stackPos(2)*3); + _screen->setScreenPalette(screenPal); return 0; } @@ -802,7 +806,7 @@ int KyraEngine::cmd_loadPageFromDisk(ScriptState *script) { int KyraEngine::cmd_customPrintTalkString(ScriptState *script) { if (_features & GF_TALKIE) { - debug(3, "cmd_customPrintTalkString(0x%X) ('%s', %d, %d, %d)", script, stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF); + debug(3, "cmd_customPrintTalkString(0x%X) (%d, '%s', %d, %d, %d)", script, stackPos(0), stackPosString(1), stackPos(2), stackPos(3), stackPos(4) & 0xFF); while (snd_voicePlaying() && !_fastMode) { delay(10); } diff --git a/kyra/staticres.cpp b/kyra/staticres.cpp index 1f5afdff97..6e22845a8a 100644 --- a/kyra/staticres.cpp +++ b/kyra/staticres.cpp @@ -26,7 +26,7 @@ namespace Kyra { -#define RESFILE_VERSION 5 +#define RESFILE_VERSION 6 #define GAME_FLAGS (GF_FLOPPY | GF_TALKIE | GF_DEMO | GF_AUDIOCD) #define LANGUAGE_FLAGS (GF_ENGLISH | GF_FRENCH | GF_GERMAN | GF_SPANISH | GF_LNGUNK) @@ -162,6 +162,7 @@ void KyraEngine::res_loadResources(int type) { temp = 0; \ } + if ((type & RES_INTRO) || type == RES_ALL) { loadRawFile(resFile, "FOREST.SEQ", _seq_Forest); loadRawFile(resFile, "KALLAK-WRITING.SEQ", _seq_KallakWriting); @@ -196,6 +197,21 @@ void KyraEngine::res_loadResources(int type) { res_loadLangTable("NODROP.", &resFile, (byte***)&_noDropList, &_noDropList_Size, loadNativeLanguage); loadRawFile(resFile, "AMULETEANIM.SEQ", _amuleteAnim); + + for (int i = 1; i <= 33; ++i) { + char buffer[32]; + sprintf(buffer, "PALTABLE%d.PAL", i); + if (_features & GF_TALKIE) { + strcat(buffer, ".CD"); + } else if (_features & GF_DEMO) { + strcat(buffer, ".DEM"); + } + temp = getFile(resFile, buffer); + if (temp) { + _specialPalettes[i-1] = temp; + temp = 0; + } + } } #undef loadRooms @@ -304,6 +320,11 @@ void KyraEngine::res_unloadResources(int type) { delete [] _amuleteAnim; _amuleteAnim = 0; + + for (int i = 0; i < 33; ++i) { + delete [] _specialPalettes[i]; + _specialPalettes[i] = 0; + } } } -- cgit v1.2.3