diff options
author | Johannes Schickel | 2008-03-05 17:38:12 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-03-05 17:38:12 +0000 |
commit | 130cfded751571069d16caff42baa709146ee501 (patch) | |
tree | b42f1348fce940034fd2ce050ee6f0083d25db84 /engines | |
parent | 17642259709a4f0b3d81dc83b7294df15e3920aa (diff) | |
download | scummvm-rg350-130cfded751571069d16caff42baa709146ee501.tar.gz scummvm-rg350-130cfded751571069d16caff42baa709146ee501.tar.bz2 scummvm-rg350-130cfded751571069d16caff42baa709146ee501.zip |
Implement inventory scrolling for HoF.
svn-id: r31043
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/gui_v2.cpp | 97 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 3 | ||||
-rw-r--r-- | engines/kyra/screen_v2.cpp | 77 | ||||
-rw-r--r-- | engines/kyra/screen_v2.h | 4 | ||||
-rw-r--r-- | engines/kyra/sequences_v2.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 2 |
6 files changed, 175 insertions, 16 deletions
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index cfaa9f4d2c..43d480b142 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -26,6 +26,7 @@ #include "kyra/kyra.h" #include "kyra/kyra_v2.h" #include "kyra/screen.h" +#include "kyra/wsamovie.h" namespace Kyra { @@ -370,13 +371,16 @@ int KyraEngine_v2::processButtonList(Button *buttonList, uint16 inputFlag) { uint16 inFlags = inputFlag & 0xFF; uint16 temp = 0; - if (inFlags == 199) - temp = 0x1000; - else if (inFlags == 198) - temp = 0x0100; + // this is NOT like in the original + // the original game somehow just enabled flag 0x1000 here + // but did some other magic, which looks like it depends on how the handle + // key input... so we just enable 0x1000 and 0x4000 here to allow + // all GUI buttons to work (for now at least...) + if (inFlags == 199 || inFlags == 198) + temp = 0x1000 | 0x4000; - if (inputFlag & 0x800) - temp <<= 2; + //if (inputFlag & 0x800) + // temp <<= 2; // the original did some flag hackery here, this works fine too flags |= temp; @@ -616,6 +620,24 @@ int KyraEngine_v2::buttonInventory(Button *button) { return 0; } +int KyraEngine_v2::scrollInventory(Button *button) { + uint16 *src = _mainCharacter.inventory; + uint16 *dst = &_mainCharacter.inventory[10]; + uint16 temp[5]; + + memcpy(temp, src, sizeof(uint16)*5); + memcpy(src, src+5, sizeof(uint16)*5); + memcpy(src+5, dst, sizeof(uint16)*5); + memcpy(dst, dst+5, sizeof(uint16)*5); + memcpy(dst+5, temp, sizeof(uint16)*5); + _screen->hideMouse(); + _screen->copyRegion(0x46, 0x90, 0x46, 0x90, 0x71, 0x2E, 0, 2); + _screen->showMouse(); + redrawInventory(2); + scrollInventoryWheel(); + return 0; +} + bool KyraEngine_v2::checkInventoryItemExchange(uint16 handItem, int slot) { bool removeItem = false; uint16 newItem = 0xFFFF; @@ -662,5 +684,68 @@ void KyraEngine_v2::clearInventorySlot(int slot, int page) { _screen->updateScreen(); } +void KyraEngine_v2::redrawInventory(int page) { + int pageBackUp = _screen->_curPage; + _screen->_curPage = page; + + const uint16 *inventory = _mainCharacter.inventory; + _screen->hideMouse(); + for (int i = 0; i < 10; ++i) { + clearInventorySlot(i, page); + if (inventory[i] != 0xFFFF) { + _screen->drawShape(page, getShapePtr(inventory[i]+64), _inventoryX[i], _inventoryY[i], 0, 0); + drawInventoryShape(page, inventory[i], i); + } + } + _screen->showMouse(); + _screen->updateScreen(); + + _screen->_curPage = pageBackUp; +} + +void KyraEngine_v2::scrollInventoryWheel() { + WSAMovieV2 movie(this); + movie.open("INVWHEEL.WSA", 0, 0); + int frames = movie.opened() ? movie.frames() : 6; + memcpy(_screenBuffer, _screen->getCPagePtr(2), 64000); + uint8 overlay[0x100]; + _screen->generateOverlay(_screen->getPalette(0), overlay, 0, 32); + _screen->hideMouse(); + _screen->copyRegion(0x46, 0x90, 0x46, 0x79, 0x71, 0x17, 0, 2); + _screen->showMouse(); + snd_playSoundEffect(0x25); + + movie.setDrawPage(0); + movie.setX(0); + movie.setY(0); + + bool breakFlag = false; + for (int i = 0; i <= 6 && !breakFlag; ++i) { + if (movie.opened()) { + _screen->hideMouse(); + movie.displayFrame(i % frames, 0, 0); + _screen->showMouse(); + _screen->updateScreen(); + } + + uint32 endTime = _system->getMillis() + _tickLength; + + int y = (i * 981) >> 8; + if (y >= 23 || i == 6) { + y = 23; + breakFlag = true; + } + + _screen->applyOverlay(0x46, 0x79, 0x71, 0x17, 2, overlay); + _screen->copyRegion(0x46, y+0x79, 0x46, 0x90, 0x71, 0x2E, 2, 0); + _screen->updateScreen(); + + delayUntil(endTime); + } + + _screen->copyBlockToPage(2, 0, 0, 320, 200, _screenBuffer); + movie.close(); +} + } // end of namespace Kyra diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index 3fec195d60..c9e54b57e9 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -563,6 +563,8 @@ protected: bool checkInventoryItemExchange(uint16 item, int slot); void drawInventoryShape(int page, uint16 item, int slot); void clearInventorySlot(int slot, int page); + void redrawInventory(int page); + void scrollInventoryWheel(); // gui void loadButtonShapes(); @@ -610,6 +612,7 @@ protected: Button *addButtonToList(Button *list, Button *newButton); int processButtonList(Button *button, uint16 inputFlag); + int scrollInventory(Button *button); int buttonInventory(Button *button); // localization diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 2bec373266..ab46dce6f3 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -84,12 +84,81 @@ void Screen_v2::generateGrayOverlay(const uint8 *srcPal, uint8 *grayOverlay, int grayOverlay[i] = findLeastDifferentColor(tmpPal + 3 * i, srcPal, lastColor); } -void Screen_v2::applyGrayOverlay(int x, int y, int w, int h, int pageNum, const uint8 *grayOverlay) { +uint8 *Screen_v2::generateOverlay(const uint8 *palette, uint8 *buffer, int startColor, int fac) { + if (!palette || !buffer) + return buffer; + + fac = MIN(0xFF, fac); + + byte col1, col2, col3; + col1 = palette[startColor * 3 + 0]; + col2 = palette[startColor * 3 + 1]; + col3 = palette[startColor * 3 + 2]; + *buffer = 0; + + uint8 *dst = buffer + 1; + for (int i = 1; i != 255; ++i) { + byte procCol1, procCol2, procCol3; + const uint8 *src = palette + i*3; + const int factor = (fac >> 1) & 0xFF; + byte col; + + col = *src++; + col -= ((((col - col1) * factor) << 1) >> 8) & 0xFF; + procCol1 = col; + + col = *src++; + col -= ((((col - col2) * factor) << 1) >> 8) & 0xFF; + procCol2 = col; + + col = *src++; + col -= ((((col - col3) * factor) << 1) >> 8) & 0xFF; + procCol3 = col; + + uint16 minValue = 0xFFFF; + uint8 colorNumber = startColor; + const uint8 *pal = palette + 3; + for (int count = 0xFF, cur = 1; count > 0; --count, ++cur) { + pal += 3; + if (cur != i) { + uint16 value = 0; + pal -= 3; + col = *pal++ - procCol1; + col *= col; + value += col; + + col = *pal++ - procCol2; + col *= col; + value += col; + + col = *pal++ - procCol3; + col *= col; + value += col; + + if (value == 0) { + colorNumber = i; + break; + } else if (value < minValue) { + minValue = value; + colorNumber = cur; + } + } + } + + *dst++ = colorNumber; + } + + return buffer; +} + +void Screen_v2::applyOverlay(int x, int y, int w, int h, int pageNum, const uint8 *overlay) { uint8 * dst = getPagePtr(pageNum) + y * 320 + x; while (h--) { - for (int wi = 0; wi < 320; wi++) - dst[wi] = grayOverlay[dst[wi]]; - dst += 320; + for (int wi = 0; wi < w; ++wi) { + uint8 index = *dst; + *dst++ = overlay[index]; + } + dst += 320 - w; } } diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h index b31b1de46a..a00cad6b18 100644 --- a/engines/kyra/screen_v2.h +++ b/engines/kyra/screen_v2.h @@ -43,7 +43,6 @@ public: // sequence player void generateGrayOverlay(const uint8 *srcPal, uint8 *grayOverlay, int factor, int addR, int addG, int addB, int lastColor, bool flag); - void applyGrayOverlay(int x, int y, int w, int h, int pageNum, const uint8 *grayOverlay); int findLeastDifferentColor(const uint8 *paletteEntry, const uint8 *palette, uint16 numColors); bool calcBounds(int w0, int h0, int &x1, int &y1, int &w1, int &h1, int &x2, int &y2, int &w2); void wsaFrameAnimationStep(int x1, int y1, int x2, int y2, int w1, int h1, int w2, int h2, int srcPage, int dstPage, int dim); @@ -55,6 +54,9 @@ public: void copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src, int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2); + uint8 *generateOverlay(const uint8 *palette, uint8 *buffer, int color, int factor); + void applyOverlay(int x, int y, int w, int h, int pageNum, const uint8 *overlay); + // shape handling uint8 *getPtrToShape(uint8 *shpFile, int shape); const uint8 *getPtrToShape(const uint8 *shpFile, int shape); diff --git a/engines/kyra/sequences_v2.cpp b/engines/kyra/sequences_v2.cpp index e14e78bc42..57773bb107 100644 --- a/engines/kyra/sequences_v2.cpp +++ b/engines/kyra/sequences_v2.cpp @@ -405,7 +405,7 @@ int KyraEngine_v2::seq_introOverview(WSAMovieV2 *wsaObj, int x, int y, int frm) case 201: _screen->setScreenPalette(_screen->getPalette(2)); _screen->updateScreen(); - _screen->applyGrayOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); + _screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); _screen->copyPage(2, 12); _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0); _screen->setScreenPalette(_screen->getPalette(0)); @@ -472,7 +472,7 @@ int KyraEngine_v2::seq_introLibrary(WSAMovieV2 *wsaObj, int x, int y, int frm) { seq_waitForTextsTimeout(); _screen->copyPage(12, 2); - _screen->applyGrayOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); + _screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0); _screen->updateScreen(); _screen->copyPage(2, 12); @@ -493,7 +493,7 @@ int KyraEngine_v2::seq_introLibrary(WSAMovieV2 *wsaObj, int x, int y, int frm) { case 340: seq_resetActiveWSA(0); - _screen->applyGrayOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); + _screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); _screen->copyPage(2, 12); _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0); _screen->updateScreen(); @@ -548,7 +548,7 @@ int KyraEngine_v2::seq_introHand(WSAMovieV2 *wsaObj, int x, int y, int frm) { case 201: seq_waitForTextsTimeout(); - _screen->applyGrayOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); + _screen->applyOverlay(0, 0, 320, 200, 2, _screen->getPalette(3)); _screen->copyPage(2, 12); _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0); _screen->updateScreen(); diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index cded12e8a9..8517332906 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -1452,7 +1452,7 @@ void KyraEngine_v2::initMainButtonList() { { 0, 0x2, 0x00, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0x104, 0x90, 0x3C, 0x2C, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, /*&KyraEngine_v2::sub_27037*/0 }, { 0, 0x5, 0x00, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0x0FA, 0x90, 0x0A, 0x2C, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, /*&KyraEngine_v2::sub_27032*/0 }, { 0, 0x3, 0x00, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0x0CE, 0x90, 0x2C, 0x2C, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, /*&KyraEngine_v2::gui_showBook*/0 }, - { 0, 0x4, 0x00, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0x0B6, 0x9D, 0x18, 0x1E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, /*&KyraEngine_v2::sub_2735E*/0 }, + { 0, 0x4, 0x00, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0x0B6, 0x9D, 0x18, 0x1E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, &KyraEngine_v2::scrollInventory }, { 0, 0x6, 0x00, 0, 0, 0, 0, 0x1100, 0, 0, 0, 0, 0x04D, 0x92, 0x13, 0x15, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, &KyraEngine_v2::buttonInventory }, { 0, 0x7, 0x00, 0, 0, 0, 0, 0x1100, 0, 0, 0, 0, 0x061, 0x92, 0x13, 0x15, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, &KyraEngine_v2::buttonInventory }, { 0, 0x8, 0x00, 0, 0, 0, 0, 0x1100, 0, 0, 0, 0, 0x075, 0x92, 0x13, 0x15, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0, &KyraEngine_v2::buttonInventory }, |