diff options
-rw-r--r-- | engines/kyra/eobcommon.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/eobcommon.h | 6 | ||||
-rw-r--r-- | engines/kyra/gui_eob.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/items_eob.cpp | 8 | ||||
-rw-r--r-- | engines/kyra/scene_eob.cpp | 16 | ||||
-rw-r--r-- | engines/kyra/screen_eob.cpp | 82 | ||||
-rw-r--r-- | engines/kyra/screen_eob.h | 17 | ||||
-rw-r--r-- | engines/kyra/sequences_darkmoon.cpp | 35 | ||||
-rw-r--r-- | engines/kyra/sprites_eob.cpp | 20 |
9 files changed, 124 insertions, 92 deletions
diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index d5327c859d..4f5dfcdd47 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -114,6 +114,8 @@ EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags) _dscDoorY1 = 0; _dscDoorXE = 0; + _greenFadingTable = _blueFadingTable = _lightBlueFadingTable = _blackFadingTable = _greyFadingTable = 0; + _menuDefs = 0; _exchangeCharacterId = -1; @@ -297,6 +299,12 @@ EoBCoreEngine::~EoBCoreEngine() { delete[] _levelDecorationRects; _dscWallMapping.clear(); + delete[] _greenFadingTable; + delete[] _blueFadingTable; + delete[] _lightBlueFadingTable; + delete[] _blackFadingTable; + delete[] _greyFadingTable; + delete[] _spells; delete[] _spellAnimBuffer; delete[] _wallsOfForce; @@ -447,6 +455,12 @@ Common::Error EoBCoreEngine::init() { _wllVcnOffset = 16; + _greenFadingTable = new uint8[256]; + _blueFadingTable = new uint8[256]; + _lightBlueFadingTable = new uint8[256]; + _blackFadingTable = new uint8[256]; + _greyFadingTable = new uint8[256]; + _monsters = new EoBMonsterInPlay[30]; memset(_monsters, 0, 30 * sizeof(EoBMonsterInPlay)); @@ -842,7 +856,7 @@ void EoBCoreEngine::setHandItem(Item itemIndex) { const uint8 *ovl = 0; if (icon && (_items[_itemInHand].flags & 0x80) && (_partyEffectFlags & 2)) - ovl = _flags.gameID == GI_EOB1 ? ((_configRenderMode == Common::kRenderCGA) ? _itemsOverlayCGA : &_itemsOverlay[icon << 4]) : _screen->generateShapeOverlay(shp, 3); + ovl = _flags.gameID == GI_EOB1 ? ((_configRenderMode == Common::kRenderCGA) ? _itemsOverlayCGA : &_itemsOverlay[icon << 4]) : _screen->generateShapeOverlay(shp, _lightBlueFadingTable); int mouseOffs = itemIndex ? 8 : 0; _screen->setMouseCursor(mouseOffs, mouseOffs, shp, ovl); diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index 157c820c5d..810b792eb2 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -639,6 +639,12 @@ protected: const uint8 *_dscDoorY1; const uint8 *_dscDoorXE; + uint8 *_greenFadingTable; + uint8 *_blueFadingTable; + uint8 *_lightBlueFadingTable; + uint8 *_blackFadingTable; + uint8 *_greyFadingTable; + const uint8 *_wllFlagPreset; int _wllFlagPresetSize; const uint8 *_teleporterShapeCoords; diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 968bca2be2..cdc5fba5c1 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -236,18 +236,18 @@ void EoBCoreEngine::gui_drawFaceShape(int index) { } } else { if (c->effectFlags & 0x140) { - _screen->setFadeTableIndex(1); - _screen->setShapeFadeMode(1, true); + _screen->setFadeTable(_blackFadingTable); + _screen->setShapeFadingLevel(1); } if (c->flags & 2) { - _screen->setFadeTableIndex(0); - _screen->setShapeFadeMode(1, true); + _screen->setFadeTable(_greenFadingTable); + _screen->setShapeFadingLevel(1); } if (c->flags & 8) { - _screen->setFadeTableIndex(2); - _screen->setShapeFadeMode(1, true); + _screen->setFadeTable(_blueFadingTable); + _screen->setShapeFadingLevel(1); } } @@ -256,8 +256,8 @@ void EoBCoreEngine::gui_drawFaceShape(int index) { if (c->hitPointsCur < 1) _screen->drawShape(_screen->_curPage, _disabledCharGrid, x, y, 0); - _screen->setFadeTableIndex(4); - _screen->setShapeFadeMode(1, false); + _screen->setFadeTable(_greyFadingTable); + _screen->setShapeFadingLevel(0); } void EoBCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) { diff --git a/engines/kyra/items_eob.cpp b/engines/kyra/items_eob.cpp index e2d4b1be56..6ec9b331a3 100644 --- a/engines/kyra/items_eob.cpp +++ b/engines/kyra/items_eob.cpp @@ -468,16 +468,16 @@ void EoBCoreEngine::drawItemIconShape(int pageNum, Item itemId, int x, int y) { if (_flags.gameID == GI_EOB1) { ovl = (_configRenderMode == Common::kRenderCGA) ? _itemsOverlayCGA : &_itemsOverlay[icn << 4]; } else { - _screen->setFadeTableIndex(3); - _screen->setShapeFadeMode(1, true); + _screen->setFadeTable(_lightBlueFadingTable); + _screen->setShapeFadingLevel(1); } } _screen->drawShape(pageNum, _itemIconShapes[icn], x, y, 0, ovl ? 2 : 0, ovl); if (applyBluePal) { - _screen->setFadeTableIndex(4); - _screen->setShapeFadeMode(1, false); + _screen->setFadeTable(_greyFadingTable); + _screen->setShapeFadingLevel(0); } } diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp index 84822c3fd2..6fac56f12c 100644 --- a/engines/kyra/scene_eob.cpp +++ b/engines/kyra/scene_eob.cpp @@ -168,8 +168,8 @@ Common::String EoBCoreEngine::initLevelData(int sub) { if (_flags.gameID == GI_EOB1) { pos += 11; - _screen->setShapeFadeMode(0, false); - _screen->setShapeFadeMode(1, false); + _screen->setShapeFadingLevel(0); + _screen->enableShapeBackgroundFading(false); } if (_flags.gameID == GI_EOB2 || _configRenderMode != Common::kRenderEGA) @@ -181,14 +181,14 @@ Common::String EoBCoreEngine::initLevelData(int sub) { _screen->getPalette(0).fill(224, 32, 0x3F); uint8 *src = _screen->getPalette(0).getData(); - _screen->createFadeTable(src, _screen->getFadeTable(0), 4, 75); // green - _screen->createFadeTable(src, _screen->getFadeTable(1), 12, 200); // black - _screen->createFadeTable(src, _screen->getFadeTable(2), 10, 85); // blue - _screen->createFadeTable(src, _screen->getFadeTable(3), 11, 125); // light blue + _screen->createFadeTable(src, _greenFadingTable, 4, 75); + _screen->createFadeTable(src, _blackFadingTable, 12, 200); + _screen->createFadeTable(src, _blueFadingTable, 10, 85); + _screen->createFadeTable(src, _lightBlueFadingTable, 11, 125); _screen->getPalette(0).copy(backupPal, 224, 32, 224); - _screen->createFadeTable(src, _screen->getFadeTable(4), 12, 85); // grey (shadow) - _screen->setFadeTableIndex(4); + _screen->createFadeTable(src, _greyFadingTable, 12, 85); + _screen->setFadeTable(_greyFadingTable); if (_flags.gameID == GI_EOB2 && _configRenderMode == Common::kRenderEGA) _screen->setScreenPalette(_screen->getPalette(0)); } diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp index 3a9a647fa5..6553ffa76c 100644 --- a/engines/kyra/screen_eob.cpp +++ b/engines/kyra/screen_eob.cpp @@ -38,10 +38,10 @@ namespace Kyra { Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system, _screenDimTable, _screenDimTableCount) { - _shapeFadeMode[0] = _shapeFadeMode[1] = 0; - _shapeFadeInternal = 0; - _fadeData = 0; - _fadeDataIndex = 0; + _dsBackgroundFading = false; + _dsShapeFadingLevel = 0; + _dsBackgroundFadingXOffs = 0; + _dsShapeFadingTable = 0; _dsX1 = _dsX2 = _dsY1 = _dsY2 = 0; _gfxX = _gfxY = 0; _gfxCol = 0; @@ -59,7 +59,6 @@ Screen_EoB::Screen_EoB(EoBCoreEngine *vm, OSystem *system) : Screen(vm, system, } Screen_EoB::~Screen_EoB() { - delete[] _fadeData; delete[] _dsTempPage; delete[] _cgaScaleTable; delete[] _egaDitheringTable; @@ -73,20 +72,6 @@ bool Screen_EoB::init() { int temp; _gfxMaxY = _vm->staticres()->loadRawData(kEoBBaseExpObjectY, temp); - if (_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) - _fadeData = _vm->resource()->fileData("FADING.DAT", 0); - - if (!_fadeData) { - _fadeData = new uint8[0x700]; - memset(_fadeData, 0, 0x700); - if (_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) { - uint8 *pal = _vm->resource()->fileData("PALETTE1.PAL", 0); - for (int i = 0; i < 7; i++) - createFadeTable(pal, &_fadeData[i << 8], 18, (i + 1) * 36); - delete[] pal; - } - } - _dsTempPage = new uint8[12000]; if (_vm->gameFlags().useHiRes && _renderMode == Common::kRenderEGA) { @@ -379,7 +364,7 @@ uint8 *Screen_EoB::encodeShape(uint16 x, uint16 y, uint16 w, uint16 h, bool enco memset(shp, 0, shapesize); uint8 *dst = shp; - *dst++ = 8; + *dst++ = 1; *dst++ = (h & 0xFF); *dst++ = (w & 0xFF); *dst++ = (h & 0xFF); @@ -483,11 +468,6 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, if (!src) return; - va_list args; - va_start(args, flags); - uint8 *ovl = (flags & 2) ? va_arg(args, uint8 *) : 0; - va_end(args); - if (sd != -1) { const ScreenDim *dm = getScreenDim(sd); setShapeFrame(dm->sx, dm->sy, dm->sx + dm->w, dm->sy + dm->h); @@ -495,12 +475,22 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, y += _dsY1; } + uint8 *ovl = 0; + + va_list args; + va_start(args, flags); + if (flags & 2) { + ovl = va_arg(args, uint8 *); + _dsBackgroundFadingXOffs = x; + } + va_end(args); + dst += (_dsX1 << 3); int16 dX = x - (_dsX1 << 3); int16 dY = y; int16 dW = _dsX2 - _dsX1; + uint8 pixelsPerByte = *src++; - uint16 dH = *src++; uint16 width = (*src++) << 3; uint16 transOffset = (pixelsPerByte == 4) ? (dH * width) >> 2 : 0; @@ -516,7 +506,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int pixelStep = (flags & 1) ? -1 : 1; - if (pixelsPerByte == 8) { + if (pixelsPerByte == 1) { uint16 marginLeft = 0; uint16 marginRight = 0; @@ -773,7 +763,7 @@ void Screen_EoB::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, } const uint8 *Screen_EoB::scaleShape(const uint8 *shapeData, int steps) { - setShapeFadeMode(1, steps ? true : false); + setShapeFadingLevel(steps); while (shapeData && steps--) shapeData = scaleShapeStep(shapeData); @@ -842,14 +832,13 @@ const uint8 *Screen_EoB::scaleShapeStep(const uint8 *shp) { return (const uint8 *)dst; } -const uint8 *Screen_EoB::generateShapeOverlay(const uint8 *shp, int paletteOverlayIndex) { +const uint8 *Screen_EoB::generateShapeOverlay(const uint8 *shp, const uint8 *fadingTable) { if (*shp != 2) return 0; shp += 4; - uint8 *ovl = getFadeTable(paletteOverlayIndex); for (int i = 0; i < 16; i++) - _shapeOverlay[i] = ovl[shp[i]]; + _shapeOverlay[i] = fadingTable[shp[i]]; return _shapeOverlay; } @@ -860,9 +849,12 @@ void Screen_EoB::setShapeFrame(int x1, int y1, int x2, int y2) { _dsY2 = y2; } -void Screen_EoB::setShapeFadeMode(uint8 i, bool b) { - if (!i || i == 1) - _shapeFadeMode[i] = b; +void Screen_EoB::enableShapeBackgroundFading(bool enable) { + _dsBackgroundFading = enable; +} + +void Screen_EoB::setShapeFadingLevel(int level) { + _dsShapeFadingLevel = level; } void Screen_EoB::setGfxParameters(int x, int y, int col) { @@ -1171,8 +1163,8 @@ int Screen_EoB::getRectSize(int w, int h) { return w * h; } -void Screen_EoB::setFadeTableIndex(int index) { - _fadeDataIndex = (CLIP(index, 0, 7) << 8); +void Screen_EoB::setFadeTable(const uint8 *table) { + _dsShapeFadingTable = table; } void Screen_EoB::createFadeTable(uint8 *palData, uint8 *dst, uint8 rootColor, uint8 weight) { @@ -1218,10 +1210,6 @@ void Screen_EoB::createFadeTable(uint8 *palData, uint8 *dst, uint8 rootColor, ui } } -uint8 *Screen_EoB::getFadeTable(int index) { - return (index >= 0 && index < 5) ? &_fadeData[index << 8] : 0; -} - const uint16 *Screen_EoB::getCGADitheringTable(int index) { return !(index & ~1) ? _cgaDitheringTables[index] : 0; } @@ -1273,19 +1261,19 @@ void Screen_EoB::ditherRect(const uint8 *src, uint8 *dst, int dstPitch, int srcW void Screen_EoB::drawShapeSetPixel(uint8 *dst, uint8 col) { if ((_renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA) || _useHiResEGADithering) { - if (_shapeFadeMode[0]) { - if (_shapeFadeMode[1]) { + if (_dsBackgroundFading) { + if (_dsShapeFadingLevel) { col = *dst; } else { - _shapeFadeInternal &= 7; - col = *(dst + _shapeFadeInternal++); + _dsBackgroundFadingXOffs &= 7; + col = *(dst + _dsBackgroundFadingXOffs++); } } - if (_shapeFadeMode[1]) { - uint8 cnt = _shapeFadeMode[1]; + if (_dsShapeFadingLevel) { + uint8 cnt = _dsShapeFadingLevel; while (cnt--) - col = _fadeData[_fadeDataIndex + col]; + col = _dsShapeFadingTable[col]; } } diff --git a/engines/kyra/screen_eob.h b/engines/kyra/screen_eob.h index 3634ae1a39..42c7e59e28 100644 --- a/engines/kyra/screen_eob.h +++ b/engines/kyra/screen_eob.h @@ -59,10 +59,11 @@ public: void drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int sd = -1, int flags = 0, ...); const uint8 *scaleShape(const uint8 *shapeData, int blockDistance); const uint8 *scaleShapeStep(const uint8 *shp); - const uint8 *generateShapeOverlay(const uint8 *shp, int paletteOverlayIndex); + const uint8 *generateShapeOverlay(const uint8 *shp, const uint8 *fadingTable); void setShapeFrame(int x1, int y1, int x2, int y2); - void setShapeFadeMode(uint8 i, bool b); + void enableShapeBackgroundFading(bool enable); + void setShapeFadingLevel(int val); void setGfxParameters(int x, int y, int col); void drawExplosion(int scale, int radius, int numElements, int stepSize, int aspectRatio, const uint8 *colorTable, int colorTableSize); @@ -74,10 +75,9 @@ public: void setTextColorMap(const uint8 *cmap) {} int getRectSize(int w, int h); - void setFadeTableIndex(int index); + void setFadeTable(const uint8 *table); void createFadeTable(uint8 *palData, uint8 *dst, uint8 rootColor, uint8 weight); - uint8 *getFadeTable(int index); - + const uint16 *getCGADitheringTable(int index); const uint8 *getEGADitheringTable(); @@ -100,10 +100,9 @@ private: const uint8 *_gfxMaxY; int16 _dsX1, _dsX2, _dsY1, _dsY2; - bool _shapeFadeMode[2]; - uint16 _shapeFadeInternal; - uint8 *_fadeData; - int _fadeDataIndex; + + bool _dsBackgroundFading; + int16 _dsBackgroundFadingXOffs; uint8 _shapeOverlay[16]; uint8 *_dsTempPage; diff --git a/engines/kyra/sequences_darkmoon.cpp b/engines/kyra/sequences_darkmoon.cpp index 68d6f752e0..befa8aa6a6 100644 --- a/engines/kyra/sequences_darkmoon.cpp +++ b/engines/kyra/sequences_darkmoon.cpp @@ -82,6 +82,7 @@ private: const Config *_config; Palette *_palettes[12]; + uint8 *_fadingTables[7]; const uint8 **_shapes; @@ -972,6 +973,27 @@ DarkmoonSequenceHelper::DarkmoonSequenceHelper(OSystem *system, DarkMoonEngine * _palettes[11] = new Palette(256); _palettes[11]->fill(0, 256, 0); + for (int i = 0; i < 7; i++) + _fadingTables[i] = 0; + + uint8 *fadeData = (_vm->_configRenderMode != Common::kRenderCGA && _vm->_configRenderMode != Common::kRenderEGA) ? _vm->resource()->fileData("FADING.DAT", 0) : 0; + + if (fadeData) { + for (int i = 0; i < 7; i++) { + _fadingTables[i] = new uint8[256]; + memcpy(_fadingTables[i], fadeData + (i << 8), 256); + } + } else { + if (_vm->_configRenderMode != Common::kRenderCGA && _vm->_configRenderMode != Common::kRenderEGA) { + uint8 *pal = _vm->resource()->fileData("PALETTE1.PAL", 0); + for (int i = 0; i < 7; i++) + _screen->createFadeTable(pal, _fadingTables[i], 18, (i + 1) * 36); + delete[] pal; + } + } + + delete[] fadeData; + _shapes = new const uint8*[30]; memset(_shapes, 0, 30 * sizeof(uint8 *)); @@ -994,6 +1016,9 @@ DarkmoonSequenceHelper::~DarkmoonSequenceHelper() { delete _palettes[10]; delete _palettes[11]; + for (int i = 0; i < 7; i++) + delete[] _fadingTables[i]; + for (int i = 0; i < 30; i++) delete[] _shapes[i]; delete[] _shapes; @@ -1152,13 +1177,13 @@ void DarkmoonSequenceHelper::animCommand(int index, int del) { _screen->updateScreen(); delay(s->delay /** 7*/); } else { - _screen->setShapeFadeMode(0, true); - _screen->setShapeFadeMode(1, true); + _screen->enableShapeBackgroundFading(true); + _screen->setShapeFadingLevel(1); end = _system->getMillis() + s->delay * _vm->tickLength(); if (palIndex) { - _screen->setFadeTableIndex(palIndex - 1); + _screen->setFadeTable(_fadingTables[palIndex - 1]); _screen->copyRegion(s->x1 - 8, s->y1 - 8, 0, 0, (_shapes[s->obj][2] + 1) << 3, _shapes[s->obj][3], 2, 4, Screen::CR_NO_P_CHECK); _screen->drawShape(4, _shapes[s->obj], s->x1 & 7, 0, 0); @@ -1169,8 +1194,8 @@ void DarkmoonSequenceHelper::animCommand(int index, int del) { _screen->updateScreen(); _vm->delayUntil(end); - _screen->setShapeFadeMode(0, false); - _screen->setShapeFadeMode(1, false); + _screen->enableShapeBackgroundFading(false); + _screen->setShapeFadingLevel(0); } break; diff --git a/engines/kyra/sprites_eob.cpp b/engines/kyra/sprites_eob.cpp index 5a82cf604c..c93bf0edb7 100644 --- a/engines/kyra/sprites_eob.cpp +++ b/engines/kyra/sprites_eob.cpp @@ -429,7 +429,7 @@ void EoBCoreEngine::drawBlockItems(int index) { y += itemPosFin[(o >> 1) & 7]; drawBlockObject(0, 2, shp, x, y, 5); - _screen->setShapeFadeMode(1, false); + _screen->setShapeFadingLevel(0); } } @@ -535,7 +535,7 @@ void EoBCoreEngine::drawMonsters(int index) { drawMonsterShape(shp, x, y, f >= 0 ? 0 : 1, d->flags, palIndex); if (_flags.gameID == GI_EOB1) { - _screen->setShapeFadeMode(1, false); + _screen->setShapeFadingLevel(0); continue; } @@ -559,7 +559,7 @@ void EoBCoreEngine::drawMonsters(int index) { drawMonsterShape(shp, x + ((f < 0) ? (w - dx - (shp[2] << 3)) : dx), y + dy, f >= 0 ? 0 : 1, d->flags, -1); } - _screen->setShapeFadeMode(1, false); + _screen->setShapeFadingLevel(0); } } @@ -614,12 +614,12 @@ void EoBCoreEngine::drawFlyingObjects(int index) { int flipped = 0; if (sclValue < 0) { - _screen->setShapeFadeMode(1, false); + _screen->setShapeFadingLevel(0); continue; } const uint8 *shp = 0; - bool rstFade = false; + bool noFade = false; if (fo->enable == 1) { int shpIx = _dscItemShapeMap[_items[fo->item].icon]; @@ -634,7 +634,7 @@ void EoBCoreEngine::drawFlyingObjects(int index) { } } else { - rstFade = true; + noFade = true; shp = (fo->objectType < _numThrownItemShapes) ? _thrownItemShapes[fo->objectType] : _spellShapes[fo->objectType - _numThrownItemShapes]; flipped = _flightObjFlipIndex[(fo->direction << 2) + (fo->curPos & 3)]; @@ -648,16 +648,16 @@ void EoBCoreEngine::drawFlyingObjects(int index) { shp = _screen->scaleShape(shp, sclValue); - if (rstFade) { - _screen->setShapeFadeMode(1, false); - rstFade = false; + if (noFade) { + _screen->setShapeFadingLevel(0); + noFade = false; } x -= (shp[2] << 2); y -= (y == 44 ? (shp[1] >> 1) : shp[1]); drawBlockObject(flipped, 2, shp, x, y, 5); - _screen->setShapeFadeMode(1, false); + _screen->setShapeFadingLevel(0); } } |