aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukaslw2014-08-16 22:54:38 +0200
committerlukaslw2014-08-16 22:54:38 +0200
commit9bda7c37c376a7c925a4b44184dddc952813c2d5 (patch)
treeb2443f11f25b817ee2dc9dbd3b7fb0194390fb82
parent422054f81cdcdd3f962afd8f777e83458b3f4588 (diff)
downloadscummvm-rg350-9bda7c37c376a7c925a4b44184dddc952813c2d5.tar.gz
scummvm-rg350-9bda7c37c376a7c925a4b44184dddc952813c2d5.tar.bz2
scummvm-rg350-9bda7c37c376a7c925a4b44184dddc952813c2d5.zip
PRINCE: Shadows drawing - update
-rw-r--r--engines/prince/hero.cpp131
-rw-r--r--engines/prince/hero.h13
-rw-r--r--engines/prince/prince.cpp95
-rw-r--r--engines/prince/prince.h16
4 files changed, 128 insertions, 127 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
index e2d63c5e5d..ff4be1aefc 100644
--- a/engines/prince/hero.cpp
+++ b/engines/prince/hero.cpp
@@ -38,20 +38,14 @@ Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph),
_number(0), _visible(false), _state(kHeroStateStay), _middleX(0), _middleY(0),
_boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0), _zoomedHeroSurface(nullptr),
_lastDirection(kHeroDirDown), _destDirection(kHeroDirDown), _talkTime(0), _boredomTime(0), _phase(0),
- _specAnim(nullptr), _drawX(0), _drawY(0), _drawZ(0), _zoomFactor(0), _scaleValue(0),
- _shadZoomFactor(0), _shadScaleValue(0), _shadLineLen(0), _shadDrawX(0), _shadDrawY(0),
+ _specAnim(nullptr), _drawX(0), _drawY(0), _drawZ(0),
_frameXSize(0), _frameYSize(0), _scaledFrameXSize(0), _scaledFrameYSize(0), _color(0),
_coords(nullptr), _dirTab(nullptr), _currCoords(nullptr), _currDirTab(nullptr), _step(0),
_maxBoredom(200), _leftRightMainDir(0), _upDownMainDir(0), _animSetNr(0)
{
- _shadowLine = (byte *)malloc(kShadowLineArraySize);
}
Hero::~Hero() {
- if (_shadowLine != nullptr) {
- free(_shadowLine);
- _shadowLine = nullptr;
- }
freeHeroAnim();
freeOldMove();
freeZoomedSurface();
@@ -116,14 +110,14 @@ uint16 Hero::getData(AttrId dataId) {
int Hero::getScaledValue(int size) {
int newSize = 0;
- int16 initScaleValue = _scaleValue;
- if (_scaleValue != 10000) {
- for(int i = 0; i < size; i++) {
+ int16 initScaleValue = _vm->_scaleValue;
+ if (_vm->_scaleValue != 10000) {
+ for (int i = 0; i < size; i++) {
initScaleValue -= 100;
- if(initScaleValue >= 0) {
+ if (initScaleValue >= 0) {
newSize++;
} else {
- initScaleValue += _scaleValue;
+ initScaleValue += _vm->_scaleValue;
}
}
return newSize;
@@ -137,7 +131,7 @@ Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
zoomedFrame->create(_scaledFrameXSize, _scaledFrameYSize, Graphics::PixelFormat::createFormatCLUT8());
int sprZoomX;
- int sprZoomY = _scaleValue;
+ int sprZoomY = _vm->_scaleValue;
uint xSource = 0;
uint ySource = 0;
uint xDest = 0;
@@ -147,12 +141,12 @@ Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
// linear_loop:
while (1) {
sprZoomY -= 100;
- if (sprZoomY >= 0 || _scaleValue == 10000) {
+ if (sprZoomY >= 0 || _vm->_scaleValue == 10000) {
// all_r_y
- sprZoomX = _scaleValue;
+ sprZoomX = _vm->_scaleValue;
break; // to loop_lin
} else {
- sprZoomY += _scaleValue;
+ sprZoomY += _vm->_scaleValue;
xSource = 0;
ySource++;
}
@@ -165,7 +159,7 @@ Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
memcpy(zoomedFrame->getBasePtr(xDest, yDest), heroFrame->getBasePtr(xSource, ySource), 1);
xDest++;
} else {
- sprZoomX += _scaleValue;
+ sprZoomX += _vm->_scaleValue;
j--;
}
xSource++;
@@ -213,7 +207,7 @@ void Hero::countDrawPosition() {
//int diffY = heroAnim->getIdYDiff();
}
- if (_zoomFactor != 0) {
+ if (_vm->_scaleValue != 10000) {
//notfullSize
_drawX = _middleX - _scaledFrameXSize / 2;
_drawY = tempMiddleY + 1 - _scaledFrameYSize;
@@ -229,19 +223,8 @@ void Hero::countDrawPosition() {
}
}
-void Hero::plotPoint(int x, int y) {
- WRITE_UINT16(&_shadowLine[_shadLineLen * 4], x);
- WRITE_UINT16(&_shadowLine[_shadLineLen * 4 + 2], y);
-}
-
-static void plot(int x, int y, int color, void *data) {
- Hero *shadowLine = (Hero *)data;
- shadowLine->plotPoint(x, y);
- shadowLine->_shadLineLen++;
-}
-
void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
- Hero *heroData = (Hero *)drawNode->data;
+ PrinceEngine *vm = (PrinceEngine *)drawNode->data;
int16 heroSurfaceWidth = drawNode->s->w;
int16 heroSurfaceHeight = drawNode->s->h;
@@ -262,27 +245,27 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
if (drawNode->posY > 1 && drawNode->posY < PrinceEngine::kMaxPicHeight) {
int shadDirection;
- if (heroData->_vm->_lightY > drawNode->posY) {
+ if (vm->_lightY > drawNode->posY) {
shadDirection = 1;
} else {
shadDirection = 0;
}
- heroData->_shadLineLen = 0;
- Graphics::drawLine(heroData->_vm->_lightX, heroData->_vm->_lightY, drawNode->posX, drawNode->posY, 0, &plot, heroData);
+ vm->_shadLineLen = 0;
+ Graphics::drawLine(vm->_lightX, vm->_lightY, drawNode->posX, drawNode->posY, 0, &vm->plotShadowLinePoint, vm);
- byte *sprShadow = (byte *)heroData->_graph->_shadowTable70;
+ byte *sprShadow = vm->_graph->_shadowTable70;
- heroData->_shadDrawX = drawNode->posX - heroData->_vm->_picWindowX;
- heroData->_shadDrawY = drawNode->posY - heroData->_vm->_picWindowY;
+ int shadDrawX = drawNode->posX - vm->_picWindowX;
+ int shadDrawY = drawNode->posY - vm->_picWindowY;
- int shadPosX = heroData->_shadDrawX;
- int shadPosY = heroData->_shadDrawY;
+ int shadPosX = shadDrawX;
+ int shadPosY = shadDrawY;
int shadBitAddr = drawNode->posY * PrinceEngine::kMaxPicWidth / 8 + drawNode->posX / 8;
int shadBitMask = 128 >> (drawNode->posX % 8);
- int shadZoomY2 = heroData->_shadScaleValue;
- int shadZoomY = heroData->_scaleValue;
+ int shadZoomY2 = vm->_shadScaleValue;
+ int shadZoomY = drawNode->scaleValue;
int diffX = 0;
int diffY = 0;
@@ -293,10 +276,10 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
int shadLastY = 0;
byte *shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY); // first pixel from last row of shadow hero
- byte *background = (byte *)screen->getBasePtr(heroData->_shadDrawX, heroData->_shadDrawY); // pixel of background where shadow sprite starts
+ byte *background = (byte *)screen->getBasePtr(shadDrawX, shadDrawY); // pixel of background where shadow sprite starts
// banked2
- byte *shadowLineStart = heroData->_shadowLine + 8;
+ byte *shadowLineStart = vm->_shadowLine + 8;
int shadWallDown = 0;
int shadWallBitAddr = 0;
@@ -316,8 +299,8 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
//retry_line:
for (j = heroSurfaceHeight - i; j > 0; j--) {
shadZoomY -= 100;
- if (shadZoomY < 0 && heroData->_scaleValue != 10000) {
- shadZoomY += heroData->_scaleValue;
+ if (shadZoomY < 0 && drawNode->scaleValue != 10000) {
+ shadZoomY += drawNode->scaleValue;
shadowHeroY--;
if (shadowHeroY < 0) {
break;
@@ -326,7 +309,7 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
break;
}
}
- if (j == 0) {
+ if (!j) {
break;
}
if (shadowHeroY < 0) {
@@ -363,8 +346,8 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
int k;
for (k = j; k > 0; k--) {
shadZoomY2 -= 100;
- if (shadZoomY2 < 0 && heroData->_shadScaleValue != 10000) {
- shadZoomY2 += heroData->_shadScaleValue;
+ if (shadZoomY2 < 0 && vm->_shadScaleValue != 10000) {
+ shadZoomY2 += vm->_shadScaleValue;
shadowHeroY--;
if (shadowHeroY < 0) {
break;
@@ -376,18 +359,18 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
if (shadowHeroY < 0) {
break;
}
- if (k == 0) {
+ if (!k) {
break;
}
//line_y_ok_2:
//copy_trans
bool shadWDFlag = false;
- int shadZoomX = heroData->_scaleValue;
+ int shadZoomX = drawNode->scaleValue;
int backgroundDiff = shadSkipX;
int shadBitMaskCopyTrans = shadBitMask;
int shadBitAddrCopyTrans = shadBitAddr;
shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
- background = (byte *)screen->getBasePtr(heroData->_shadDrawX + diffX + backgroundDiff, heroData->_shadDrawY + diffY);
+ background = (byte *)screen->getBasePtr(shadDrawX + diffX + backgroundDiff, shadDrawY + diffY);
if (shadPosX < 0) {
if (heroSurfaceWidth > shadSkipX) {
@@ -409,13 +392,13 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
//ct_loop:
for (int l = 0; l < ct_loop; l++) {
shadZoomX -= 100;
- if (shadZoomX < 0 && heroData->_scaleValue != 10000) {
- shadZoomX += heroData->_scaleValue;
+ if (shadZoomX < 0 && drawNode->scaleValue != 10000) {
+ shadZoomX += drawNode->scaleValue;
} else {
if (*shadowHero == GraphicsMan::kShadowColor) {
- if ((shadBitMaskCopyTrans & heroData->_vm->_shadowBitmap[shadBitAddrCopyTrans]) != 0) {
+ if ((shadBitMaskCopyTrans & vm->_shadowBitmap[shadBitAddrCopyTrans])) {
if (shadWallDown == 0) {
- if ((shadBitMaskCopyTrans & heroData->_vm->_shadowBitmap[shadBitAddrCopyTrans + heroData->_vm->kShadowBitmapSize]) != 0) {
+ if ((shadBitMaskCopyTrans & vm->_shadowBitmap[shadBitAddrCopyTrans + PrinceEngine::kShadowBitmapSize])) {
shadWDFlag = true;
//shadow
*background = *(sprShadow + *background);
@@ -435,7 +418,7 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
}
//okok
backgroundDiff++;
- background = (byte *)screen->getBasePtr(heroData->_shadDrawX + diffX + backgroundDiff, heroData->_shadDrawY + diffY);
+ background = (byte *)screen->getBasePtr(shadDrawX + diffX + backgroundDiff, shadDrawY + diffY);
}
shadowHeroX++;
shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
@@ -444,14 +427,14 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
if (!shadWallDown && shadWDFlag) {
shadWallDown = shadPosX;
shadWallBitAddr = shadBitAddr;
- shadWallDestAddr = (byte *)screen->getBasePtr(heroData->_shadDrawX + diffX, heroData->_shadDrawY + diffY);
+ shadWallDestAddr = (byte *)screen->getBasePtr(shadDrawX + diffX, shadDrawY + diffY);
shadWallBitMask = shadBitMask;
shadWallPosY = shadPosY;
shadWallSkipX = shadSkipX;
shadWallModulo = sprModulo;
}
//byebye
- if (shadDirection != 0 && shadWallDown != 0) {
+ if (shadDirection && shadWallDown) {
int shadBitMaskWallCopyTrans = shadWallBitMask;
int shadBitAddrWallCopyTrans = shadWallBitAddr;
background = shadWallDestAddr;
@@ -460,18 +443,18 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
if (ct_loop > shadWallSkipX && ct_loop - shadWallSkipX > shadWallModulo) {
//WALL_copy_trans
shadWDFlag = false;
- int shadZoomXWall = heroData->_scaleValue;
+ int shadZoomXWall = drawNode->scaleValue;
int backgroundDiffWall = 0;
int shadowHeroXWall = 0;
//ct_loop:
for (int m = 0; m < ct_loop; m++) {
shadZoomXWall -= 100;
- if (shadZoomXWall < 0 && heroData->_scaleValue != 10000) {
- shadZoomXWall += heroData->_scaleValue;
+ if (shadZoomXWall < 0 && drawNode->scaleValue != 10000) {
+ shadZoomXWall += drawNode->scaleValue;
} else {
//point_ok:
if (*shadowHero == GraphicsMan::kShadowColor) {
- if ((shadBitMaskWallCopyTrans & heroData->_vm->_shadowBitmap[shadBitAddrWallCopyTrans + heroData->_vm->kShadowBitmapSize]) != 0) {
+ if ((shadBitMaskWallCopyTrans & vm->_shadowBitmap[shadBitAddrWallCopyTrans + PrinceEngine::kShadowBitmapSize])) {
*background = *(sprShadow + *background);
}
}
@@ -539,7 +522,7 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
break;
}
shadowHeroX = 0;
- background = (byte *)screen->getBasePtr(heroData->_shadDrawX + diffX, heroData->_shadDrawY + diffY);
+ background = (byte *)screen->getBasePtr(shadDrawX + diffX, shadDrawY + diffY);
shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
}
//koniec_bajki - end_of_a_story
@@ -549,12 +532,10 @@ void Hero::showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode) {
}
void Hero::setScale(int8 zoomBitmapValue) {
- if (zoomBitmapValue == 0) {
- _zoomFactor = 0;
- _scaleValue = 10000;
+ if (!zoomBitmapValue) {
+ _vm->_scaleValue = 10000;
} else {
- _zoomFactor = zoomBitmapValue;
- _scaleValue = 10000 / _zoomFactor;
+ _vm->_scaleValue = 10000 / zoomBitmapValue;
}
}
@@ -563,17 +544,6 @@ void Hero::selectZoom() {
setScale(zoomBitmapValue);
}
-void Hero::setShadowScale(int32 shadowScale) {
- shadowScale = 100 - shadowScale;
- if (shadowScale == 0) {
- _shadZoomFactor = 0;
- _shadScaleValue = 10000;
- } else {
- _shadZoomFactor = shadowScale;
- _shadScaleValue = 10000 / _shadZoomFactor;
- }
-}
-
int Hero::rotateHero(int oldDirection, int newDirection) {
switch (oldDirection) {
case kHeroDirLeft:
@@ -904,7 +874,7 @@ void Hero::drawHero() {
newDrawNode.data = _vm->_transTable;
newDrawNode.drawFunction = &_graph->drawTransparentWithTransDrawNode;
- if (_zoomFactor) {
+ if (_vm->_scaleValue != 10000) {
_zoomedHeroSurface = zoomSprite(mainHeroSurface);
newDrawNode.s = _zoomedHeroSurface;
} else {
@@ -925,8 +895,9 @@ void Hero::drawHeroShadow(Graphics::Surface *heroFrame) {
newDrawNode.posZ = kHeroShadowZ;
newDrawNode.width = 0;
newDrawNode.height = 0;
+ newDrawNode.scaleValue = _vm->_scaleValue;
newDrawNode.originalRoomSurface = nullptr;
- newDrawNode.data = this;
+ newDrawNode.data = _vm;
newDrawNode.drawFunction = &showHeroShadow;
newDrawNode.s = heroFrame;
_vm->_drawNodeList.push_back(newDrawNode);
diff --git a/engines/prince/hero.h b/engines/prince/hero.h
index 743e09ac8d..d5f7d8cc7a 100644
--- a/engines/prince/hero.h
+++ b/engines/prince/hero.h
@@ -41,7 +41,6 @@ struct DrawNode;
class Hero {
public:
static const uint32 kMoveSetSize = 26;
- static const int16 kShadowLineArraySize = 2 * 1280 * 4;
static const int16 kStepLeftRight = 8;
static const int16 kStepUpDown = 4;
static const int16 kHeroShadowZ = 2;
@@ -128,7 +127,6 @@ public:
void plotPoint(int x, int y);
static void showHeroShadow(Graphics::Surface *screen, DrawNode *drawNode);
void drawHeroShadow(Graphics::Surface *heroFrame);
- void setShadowScale(int32 shadowScale);
void freeOldMove();
void freeHeroAnim();
@@ -138,9 +136,7 @@ public:
int16 _middleX; // middle of X
int16 _middleY; // lower part of hero
int16 _moveSetType;
-
- int8 _zoomFactor;
- int16 _scaleValue;
+
int16 _frameXSize;
int16 _frameYSize;
int16 _scaledFrameXSize;
@@ -149,12 +145,6 @@ public:
int16 _drawY;
int16 _drawZ;
- int32 _shadZoomFactor;
- int32 _shadScaleValue;
- int32 _shadLineLen;
- int16 _shadDrawX;
- int16 _shadDrawY;
-
byte *_coords; // array of coordinates
byte *_dirTab; // array of directions
byte *_currCoords; // current coordinations
@@ -180,7 +170,6 @@ public:
int _color; // subtitles color
uint32 _animSetNr; // number of animation set
Common::Array<Animation *> _moveSet; // MoveAnims MoveSet
- byte *_shadowLine;
uint32 _moveDelay;
uint32 _shadMinus;
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 080085b323..4b1147626a 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -95,7 +95,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
_tracePointFirstPointFlag(false), _coordsBuf2(nullptr), _coords2(nullptr), _coordsBuf3(nullptr), _coords3(nullptr),
_shanLen(0), _directionTable(nullptr), _currentMidi(0), _lightX(0), _lightY(0), _curveData(nullptr), _curvPos(0),
_creditsData(nullptr), _creditsDataSize(0), _currentTime(0), _zoomBitmap(nullptr), _shadowBitmap(nullptr), _transTable(nullptr),
- _flcFrameSurface(nullptr) {
+ _flcFrameSurface(nullptr), _shadScaleValue(0), _shadLineLen(0), _scaleValue(0) {
// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
@@ -196,6 +196,8 @@ PrinceEngine::~PrinceEngine() {
free(_curveData);
+ free(_shadowLine);
+
free(_creditsData);
}
@@ -345,6 +347,8 @@ void PrinceEngine::init() {
_curveData = (int16 *)malloc(2 * kCurveLen * sizeof(int16));
+ _shadowLine = (byte *)malloc(kShadowLineArraySize);
+
Common::SeekableReadStream *creditsDataStream = SearchMan.createReadStreamForMember("credits.dat");
if (!creditsDataStream) {
error("Can't load creditsDataStream");
@@ -489,8 +493,7 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_lightX = _script->getLightX(_locationNr);
_lightY = _script->getLightY(_locationNr);
- _mainHero->setShadowScale(_script->getShadowScale(_locationNr));
- _secondHero->setShadowScale(_script->getShadowScale(_locationNr));
+ setShadowScale(_script->getShadowScale(_locationNr));
for (uint i = 0; i < _mobList.size(); i++) {
_mobList[i]._visible = _script->getMobVisible(_room->_mobs, i);
@@ -514,6 +517,22 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
return true;
}
+void PrinceEngine::setShadowScale(int32 shadowScale) {
+ shadowScale = 100 - shadowScale;
+ if (!shadowScale) {
+ _shadScaleValue = 10000;
+ } else {
+ _shadScaleValue = 10000 / shadowScale;
+ }
+}
+
+void PrinceEngine::plotShadowLinePoint(int x, int y, int color, void *data) {
+ PrinceEngine *vm = (PrinceEngine *)data;
+ WRITE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4], x);
+ WRITE_UINT16(&vm->_shadowLine[vm->_shadLineLen * 4 + 2], y);
+ vm->_shadLineLen++;
+}
+
void PrinceEngine::changeCursor(uint16 curId) {
_debugger->_cursorNr = curId;
_mouseFlag = curId;
@@ -1360,8 +1379,6 @@ void PrinceEngine::showSpriteShadow(Graphics::Surface *shadowSurface, int destX,
void PrinceEngine::showAnim(Anim &anim) {
//ShowFrameCode
//ShowAnimFrame
- int phaseCount = anim._animData->getPhaseCount();
- int frameCount = anim._animData->getFrameCount();
int phase = anim._showFrame;
int phaseFrameIndex = anim._animData->getPhaseFrameIndex(phase);
int x = anim._x + anim._animData->getPhaseOffsetX(phase);
@@ -1371,34 +1388,49 @@ void PrinceEngine::showAnim(Anim &anim) {
int maxFrontFlag = (animFlag & 2);
int specialZFlag = anim._nextAnim;
int z = anim._nextAnim;
- Graphics::Surface *backAnimSurface = anim._animData->getFrame(phaseFrameIndex);
- int frameWidth = backAnimSurface->w;
- int frameHeight = backAnimSurface->h;
+ Graphics::Surface *animSurface = anim._animData->getFrame(phaseFrameIndex);
+ int frameWidth = animSurface->w;
+ int frameHeight = animSurface->h;
int shadowZ = 0;
- if (x != 0 || y != 0 || phaseCount != 1 || frameCount != 1) { // TODO - check if this needed
-
- if (checkMaskFlag) {
- if (!anim._nextAnim) {
- z = y + frameHeight - 1;
- }
- checkMasks(x, y, frameWidth, frameHeight, z);
- }
-
- if (specialZFlag) {
- z = specialZFlag;
- } else if (maxFrontFlag) {
- z = kMaxPicHeight + 1;
- } else {
+ if (checkMaskFlag) {
+ if (!anim._nextAnim) {
z = y + frameHeight - 1;
}
- shadowZ = z;
+ checkMasks(x, y, frameWidth, frameHeight, z);
+ }
- anim._currX = x;
- anim._currY = y;
- anim._currW = frameWidth;
- anim._currH = frameHeight;
- showSprite(backAnimSurface, x, y, z);
+ if (specialZFlag) {
+ z = specialZFlag;
+ } else if (maxFrontFlag) {
+ z = kMaxPicHeight + 1;
+ } else {
+ z = y + frameHeight - 1;
+ }
+ shadowZ = z;
+
+ anim._currX = x;
+ anim._currY = y;
+ anim._currW = frameWidth;
+ anim._currH = frameHeight;
+ showSprite(animSurface, x, y, z);
+
+ // make_special_shadow
+ if ((anim._flags & 0x80)) {
+ if (animSurface) {
+ DrawNode newDrawNode;
+ newDrawNode.posX = x;
+ newDrawNode.posY = y + animSurface->h - anim._shadowBack;
+ newDrawNode.posZ = Hero::kHeroShadowZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.scaleValue = _scaleValue;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = this;
+ newDrawNode.drawFunction = &Hero::showHeroShadow;
+ newDrawNode.s = animSurface;
+ _drawNodeList.push_back(newDrawNode);
+ }
}
//ShowFrameCodeShadow
@@ -1778,12 +1810,11 @@ void PrinceEngine::drawScreen() {
clsMasks();
_mainHero->showHero();
- _secondHero->showHero();
-
_mainHero->scrollHero();
- _secondHero->_drawX -= _picWindowX;
-
_mainHero->drawHero();
+
+ _secondHero->showHero();
+ _secondHero->_drawX -= _picWindowX;
_secondHero->drawHero();
const Graphics::Surface *roomSurface;
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 7e4592ad54..3c7b381caf 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -227,6 +227,7 @@ struct DrawNode {
int posZ;
int32 width;
int32 height;
+ int32 scaleValue;
Graphics::Surface *s;
Graphics::Surface *originalRoomSurface;
void *data;
@@ -325,19 +326,28 @@ public:
uint16 _sceneWidth;
int32 _picWindowX;
int32 _picWindowY;
- int16 _lightX; // for hero shadow
- int16 _lightY;
+
Image::BitmapDecoder *_roomBmp;
MhwanhDecoder *_suitcaseBmp;
Room *_room;
Script *_script;
InterpreterFlags *_flags;
Interpreter *_interpreter;
+ GraphicsMan *_graph;
uint8 _currentMidi;
byte *_zoomBitmap;
byte *_shadowBitmap;
byte *_transTable;
+ int16 _scaleValue; // scale for hero or special shadow animation
+ int16 _lightX; // for hero shadow
+ int16 _lightY;
+ int32 _shadScaleValue;
+ int32 _shadLineLen;
+ byte *_shadowLine;
+ void setShadowScale(int32 shadowScale);
+ static void plotShadowLinePoint(int x, int y, int color, void *data);
+
static const int16 kFPS = 15;
static const int16 kMaxPicWidth = 1280;
@@ -345,6 +355,7 @@ public:
static const int16 kZoomStep = 4;
static const int32 kZoomBitmapLen = kMaxPicHeight / kZoomStep * kMaxPicWidth / kZoomStep;
static const int32 kShadowBitmapSize = kMaxPicWidth * kMaxPicHeight / 8;
+ static const int16 kShadowLineArraySize = 2 * 1280 * 4;
static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep;
static const int16 kNormalWidth = 640;
@@ -630,7 +641,6 @@ private:
Graphics::Surface *_cursor2;
Cursor *_cursor3;
Debugger *_debugger;
- GraphicsMan *_graph;
Font *_font;
MusicPlayer *_midiPlayer;