aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukaslw2014-07-31 20:59:41 +0200
committerlukaslw2014-07-31 20:59:41 +0200
commit34f496c38a84347d54c47812a1e7c59001c444ec (patch)
tree088203d95fb2c15538074ed5ba80d3ab88225e8d
parent60881987d058ad92366aa7fc0767f9f55d33fca4 (diff)
downloadscummvm-rg350-34f496c38a84347d54c47812a1e7c59001c444ec.tar.gz
scummvm-rg350-34f496c38a84347d54c47812a1e7c59001c444ec.tar.bz2
scummvm-rg350-34f496c38a84347d54c47812a1e7c59001c444ec.zip
PRINCE: Second hero implementation
-rw-r--r--engines/prince/hero.cpp66
-rw-r--r--engines/prince/hero.h16
-rw-r--r--engines/prince/prince.cpp172
-rw-r--r--engines/prince/prince.h30
-rw-r--r--engines/prince/script.cpp4
5 files changed, 187 insertions, 101 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
index bb6d07e524..c139148c82 100644
--- a/engines/prince/hero.cpp
+++ b/engines/prince/hero.cpp
@@ -35,7 +35,7 @@ namespace Prince {
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)
+ , _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)
@@ -43,17 +43,14 @@ Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph)
, _coords(nullptr), _dirTab(nullptr), _currCoords(nullptr), _currDirTab(nullptr), _step(0)
, _maxBoredom(200), _turnAnim(0), _leftRightMainDir(0), _upDownMainDir(0), _animSetNr(0)
{
- _zoomBitmap = (byte *)malloc(kZoomBitmapLen);
- _shadowBitmap = (byte *)malloc(2 * kShadowBitmapSize);
_shadowLine = new byte[kShadowLineArraySize];
}
Hero::~Hero() {
- free(_zoomBitmap);
- free(_shadowBitmap);
delete[] _shadowLine;
freeHeroAnim();
freeOldMove();
+ freeZoomedSurface();
}
bool Hero::loadAnimSet(uint32 animSetNr) {
@@ -238,6 +235,7 @@ static void plot(int x, int y, int color, void *data) {
shadowLine->_shadLineLen++;
}
+// TODO - fix me
void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
Graphics::Surface *makeShadow = new Graphics::Surface();
makeShadow->create(_frameXSize, _frameYSize, Graphics::PixelFormat::createFormatCLUT8());
@@ -258,16 +256,16 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
int destX = _middleX - _scaledFrameXSize / 2;
int destY = _middleY - _shadMinus - 1;
- if (destY > 1 && destY < kMaxPicHeight) {
+ if (destY > 1 && destY < _vm->kMaxPicHeight) {
int shadDirection;
- if (_lightY > destY) {
+ if (_vm->_lightY > destY) {
shadDirection = 1;
} else {
shadDirection = 0;
}
_shadLineLen = 0;
- Graphics::drawLine(_lightX, _lightY, destX, destY, 0, &plot, this);
+ Graphics::drawLine(_vm->_lightX, _vm->_lightY, destX, destY, 0, &plot, this);
byte *sprShadow = (byte *)_graph->_shadowTable70;
@@ -276,7 +274,7 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
int shadPosX = _shadDrawX;
int shadPosY = _shadDrawY;
- int shadBitAddr = destY * kMaxPicWidth / 8 + destX / 8;
+ int shadBitAddr = destY * _vm->kMaxPicWidth / 8 + destX / 8;
int shadBitMask = 128 >> (destX % 8);
int shadZoomY2 = _shadScaleValue;
@@ -401,9 +399,9 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
shadZoomX += _scaleValue;
} else {
if (*shadowHero == _graph->kShadowColor) {
- if ((shadBitMaskCopyTrans & _shadowBitmap[shadBitAddrCopyTrans]) != 0) {
+ if ((shadBitMaskCopyTrans & _vm->_shadowBitmap[shadBitAddrCopyTrans]) != 0) {
if (shadWallDown == 0) {
- if ((shadBitMaskCopyTrans & _shadowBitmap[shadBitAddrCopyTrans + kShadowBitmapSize]) != 0) {
+ if ((shadBitMaskCopyTrans & _vm->_shadowBitmap[shadBitAddrCopyTrans + _vm->kShadowBitmapSize]) != 0) {
shadWDFlag = true;
//shadow
*background = *(sprShadow + *background);
@@ -459,7 +457,7 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
} else {
//point_ok:
if (*shadowHero == _graph->kShadowColor) {
- if ((shadBitMaskWallCopyTrans & _shadowBitmap[shadBitAddrWallCopyTrans + kShadowBitmapSize]) != 0) {
+ if ((shadBitMaskWallCopyTrans & _vm->_shadowBitmap[shadBitAddrWallCopyTrans + _vm->kShadowBitmapSize]) != 0) {
*background = *(sprShadow + *background);
}
}
@@ -480,7 +478,7 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
}
//krap2
shadWallDestAddr -= kScreenWidth;
- shadWallBitAddr -= kMaxPicWidth / 8;
+ shadWallBitAddr -= _vm->kMaxPicWidth / 8;
shadWallPosY--;
}
}
@@ -488,11 +486,11 @@ void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
//next_line
if (*(shadowLineStart + 2) < *(shadowLineStart - 2)) {
//minus_y
- shadBitAddr -= kMaxPicWidth / 8;
+ shadBitAddr -= _vm->kMaxPicWidth / 8;
shadPosY--;
diffY--;
} else if (*(shadowLineStart + 2) > *(shadowLineStart - 2)) {
- shadBitAddr += kMaxPicWidth / 8;
+ shadBitAddr += _vm->kMaxPicWidth / 8;
shadPosY++;
diffY++;
}
@@ -546,7 +544,7 @@ void Hero::setScale(int8 zoomBitmapValue) {
}
void Hero::selectZoom() {
- int8 zoomBitmapValue = *(_zoomBitmap + _middleY / 4 * kZoomBitmapWidth + _middleX / 4);
+ int8 zoomBitmapValue = *(_vm->_zoomBitmap + _middleY / 4 * _vm->kZoomBitmapWidth + _middleX / 4);
setScale(zoomBitmapValue);
}
@@ -879,9 +877,34 @@ void Hero::showHero() {
}
}
}
-
countDrawPosition();
+ }
+}
+void Hero::drawHero() {
+ if (_visible && !_vm->_flags->getFlagValue(Flags::NOHEROATALL)) {
+ freeZoomedSurface();
+ Graphics::Surface *mainHeroSurface = getSurface();
+ if (mainHeroSurface) {
+ //showHeroShadow(mainHeroSurface);
+ DrawNode newDrawNode;
+ newDrawNode.posX = _drawX;
+ newDrawNode.posY = _drawY;
+ newDrawNode.posZ = _drawZ;
+ newDrawNode.width = 0;
+ newDrawNode.height = 0;
+ newDrawNode.originalRoomSurface = nullptr;
+ newDrawNode.data = nullptr;
+ newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
+
+ if (_zoomFactor) {
+ _zoomedHeroSurface = zoomSprite(mainHeroSurface);
+ newDrawNode.s = _zoomedHeroSurface;
+ } else {
+ newDrawNode.s = mainHeroSurface;
+ }
+ _vm->_drawNodeList.push_back(newDrawNode);
+ }
}
}
@@ -966,6 +989,7 @@ void Hero::scrollHero() {
if (position < difference) {
destValue = position - _vm->kNormalWidth / 2;
}
+
if(destValue < 0) {
destValue = 0;
}
@@ -995,6 +1019,14 @@ void Hero::freeHeroAnim() {
}
}
+void Hero::freeZoomedSurface() {
+ if (_zoomedHeroSurface != nullptr) {
+ _zoomedHeroSurface->free();
+ delete _zoomedHeroSurface;
+ _zoomedHeroSurface = nullptr;
+ }
+}
+
}
/* vim: set tabstop=4 noexpandtab: */
diff --git a/engines/prince/hero.h b/engines/prince/hero.h
index 236818c3a1..7c30fda559 100644
--- a/engines/prince/hero.h
+++ b/engines/prince/hero.h
@@ -39,15 +39,8 @@ struct InventoryItem;
class Hero {
public:
- static const int16 kMaxPicWidth = 1280;
- static const int16 kMaxPicHeight = 480;
static const uint32 kMoveSetSize = 26;
- static const int16 kZoomStep = 4;
- static const int32 kZoomBitmapLen = kMaxPicHeight / kZoomStep * kMaxPicWidth / kZoomStep;
- static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
- static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep;
static const int16 kShadowLineArraySize = 2 * 1280 * 4;
- static const int32 kShadowBitmapSize = kMaxPicWidth * kMaxPicHeight / 8;
static const int16 kScreenWidth = 640;
static const int16 kStepLeftRight = 8;
static const int16 kStepUpDown = 4;
@@ -119,6 +112,8 @@ public:
void setVisible(bool flag) { _visible = flag; }
void showHero();
+ void drawHero();
+ void freeZoomedSurface();
void heroStanding();
void heroMoveGotIt(int x, int y, int dir);
int rotateHero(int oldDirection, int newDirection);
@@ -155,9 +150,7 @@ public:
int16 _drawX;
int16 _drawY;
int16 _drawZ;
-
- int16 _lightX; // for hero's shadow
- int16 _lightY;
+
int32 _shadZoomFactor;
int32 _shadScaleValue;
int32 _shadLineLen;
@@ -179,6 +172,7 @@ public:
uint16 _boreNum; // Bore anim frame
int16 _talkTime; // TalkTime time of talk anim
Animation *_specAnim; // additional anim
+ Graphics::Surface *_zoomedHeroSurface;
uint16 _currHeight; // height of current anim phase
@@ -189,8 +183,6 @@ public:
uint32 _animSetNr; // number of animation set
Common::Array<Animation *> _moveSet; // MoveAnims MoveSet
int16 _turnAnim;
- byte *_zoomBitmap;
- byte *_shadowBitmap;
byte *_shadowLine;
uint32 _moveDelay;
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 34af04b7d2..54579820ec 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -93,7 +93,7 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc)
_traceLineLen(0), _rembBitmapTemp(nullptr), _rembBitmap(nullptr), _rembMask(0), _rembX(0), _rembY(0), _fpX(0), _fpY(0),
_checkBitmapTemp(nullptr), _checkBitmap(nullptr), _checkMask(0), _checkX(0), _checkY(0), _traceLineFirstPointFlag(false),
_tracePointFirstPointFlag(false), _coordsBuf2(nullptr), _coords2(nullptr), _coordsBuf3(nullptr), _coords3(nullptr),
- _shanLen1(0), _directionTable(nullptr), _currentMidi(0) {
+ _shanLen(0), _directionTable(nullptr), _currentMidi(0), _lightX(0), _lightY(0) {
// Debug/console setup
DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel");
@@ -185,6 +185,9 @@ PrinceEngine::~PrinceEngine() {
_mobPriorityList.clear();
freeAllSamples();
+
+ free(_zoomBitmap);
+ free(_shadowBitmap);
}
GUI::Debugger *PrinceEngine::getDebugger() {
@@ -301,6 +304,7 @@ void PrinceEngine::init() {
_mainHero = new Hero(this, _graph);
_secondHero = new Hero(this, _graph);
_secondHero->_maxBoredom = 140;
+ _secondHero->loadAnimSet(3);
_roomPathBitmap = (byte *)malloc(kPathBitmapLen);
_roomPathBitmapTemp = (byte *)malloc(kPathBitmapLen);
@@ -325,6 +329,9 @@ void PrinceEngine::init() {
for (int i = 0; i < kMaxObjects; i++) {
_objSlot[i] = 0xFF;
}
+
+ _zoomBitmap = (byte *)malloc(kZoomBitmapLen);
+ _shadowBitmap = (byte *)malloc(2 * kShadowBitmapSize);
}
void PrinceEngine::showLogo() {
@@ -413,8 +420,8 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_sceneWidth = _roomBmp->getSurface()->w;
}
- loadZoom(_mainHero->_zoomBitmap, _mainHero->kZoomBitmapLen, "zoom"); // TODO - second hero
- loadShadow(_mainHero->_shadowBitmap, _mainHero->kShadowBitmapSize, "shadow", "shadow2"); // TODO - second hero
+ loadZoom(_zoomBitmap, kZoomBitmapLen, "zoom");
+ loadShadow(_shadowBitmap, kShadowBitmapSize, "shadow", "shadow2");
loadPath("path");
for (uint32 i = 0; i < _pscrList.size(); i++) {
@@ -453,9 +460,10 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_picWindowX = 0;
- _mainHero->_lightX = _script->getLightX(_locationNr);
- _mainHero->_lightY = _script->getLightY(_locationNr);
+ _lightX = _script->getLightX(_locationNr);
+ _lightY = _script->getLightY(_locationNr);
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
+ _secondHero->setShadowScale(_script->getShadowScale(_locationNr));
for (uint i = 0; i < _mobList.size(); i++) {
_mobList[i]._visible = _script->getMobVisible(_room->_mobs, i);
@@ -1758,15 +1766,17 @@ void PrinceEngine::runDrawNodes() {
}
void PrinceEngine::drawScreen() {
+ if (!_showInventoryFlag || _inventoryBackgroundRemember) {
+ clsMasks();
- clsMasks();
+ _mainHero->showHero();
+ _secondHero->showHero();
- _mainHero->showHero();
- _secondHero->showHero();
+ _mainHero->scrollHero();
- _mainHero->scrollHero();
+ _mainHero->drawHero();
+ _secondHero->drawHero();
- if (!_showInventoryFlag || _inventoryBackgroundRemember) {
const Graphics::Surface *roomSurface;
if (_locationNr != 50) {
roomSurface = _roomBmp->getSurface();
@@ -1779,33 +1789,6 @@ void PrinceEngine::drawScreen() {
_graph->draw(_graph->_frontScreen, &visiblePart);
}
- Graphics::Surface *mainHeroSurface = nullptr;
- Graphics::Surface *zoomedHeroSurface = nullptr;
- if (_mainHero->_visible) {
- mainHeroSurface = _mainHero->getSurface();
- if (mainHeroSurface) {
- _mainHero->showHeroShadow(mainHeroSurface);
-
- DrawNode newDrawNode;
- newDrawNode.posX = _mainHero->_drawX;
- newDrawNode.posY = _mainHero->_drawY;
- newDrawNode.posZ = _mainHero->_drawZ;
- newDrawNode.width = 0;
- newDrawNode.height = 0;
- newDrawNode.originalRoomSurface = nullptr;
- newDrawNode.data = nullptr;
- newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
-
- if (_mainHero->_zoomFactor) {
- zoomedHeroSurface = _mainHero->zoomSprite(mainHeroSurface);
- newDrawNode.s = zoomedHeroSurface;
- } else {
- newDrawNode.s = mainHeroSurface;
- }
- _drawNodeList.push_back(newDrawNode);
- }
- }
-
showBackAnims();
showNormAnims();
@@ -1824,12 +1807,6 @@ void PrinceEngine::drawScreen() {
_drawNodeList.clear();
- if (zoomedHeroSurface != nullptr) {
- zoomedHeroSurface->free();
- delete zoomedHeroSurface;
- zoomedHeroSurface = nullptr;
- }
-
if (!_inventoryBackgroundRemember && !_dialogFlag) {
if (!_optionsFlag) {
_selectedMob = checkMob(_graph->_frontScreen, _mobList, true);
@@ -1909,7 +1886,7 @@ void PrinceEngine::setPalette() {
void PrinceEngine::pause() {
uint32 currentTime = _system->getMillis();
- int delay = 1000/15 - int32(_system->getMillis() - currentTime);
+ int delay = 1000 / 15 - int32(_system->getMillis() - currentTime);
delay = delay < 0 ? 0 : delay;
_system->delayMillis(delay);
}
@@ -2225,13 +2202,13 @@ void PrinceEngine::walkTo() {
destY = mousePos.y + _picWindowY;
_mainHero->_destDirection = 0;
}
- _mainHero->_coords = makePath(destX, destY);
+ _mainHero->_coords = makePath(kMainHero, _mainHero->_middleX, _mainHero->_middleY, destX, destY);
if (_mainHero->_coords != nullptr) {
_mainHero->_currCoords = _mainHero->_coords;
_mainHero->_dirTab = _directionTable;
_mainHero->_currDirTab = _directionTable;
_directionTable = nullptr;
- _mainHero->_state = _mainHero->kHeroStateMove;
+ _mainHero->_state = Hero::kHeroStateMove;
moveShandria();
}
}
@@ -2251,16 +2228,16 @@ void PrinceEngine::moveRunHero(int heroId, int x, int y, int dir, bool runHeroFl
}
if (x || y) {
hero->freeOldMove();
- hero->_coords = makePath(x, y);
+ hero->_coords = makePath(heroId, hero->_middleX, hero->_middleY, x, y);
if (hero->_coords != nullptr) {
- hero->_currCoords = _mainHero->_coords;
+ hero->_currCoords = hero->_coords;
hero->_dirTab = _directionTable;
hero->_currDirTab = _directionTable;
_directionTable = nullptr;
if (runHeroFlag) {
- hero->_state = _mainHero->kHeroStateRun;
+ hero->_state = Hero::kHeroStateRun;
} else {
- hero->_state = _mainHero->kHeroStateMove;
+ hero->_state = Hero::kHeroStateMove;
}
}
} else {
@@ -4240,20 +4217,81 @@ void PrinceEngine::scanDirections() {
}
}
-// TODO
void PrinceEngine::moveShandria() {
+ int shanLen1 = _shanLen;
+ static const int kMinDistance = 2500;
+ if (_flags->getFlagValue(Flags::SHANDOG)) {
+ _secondHero->freeHeroAnim();
+ _secondHero->freeOldMove();
+ byte *shanCoords = _mainHero->_currCoords + shanLen1 * 4 - 4;
+ int shanX = READ_UINT16(shanCoords - 4);
+ int shanY = READ_UINT16(shanCoords - 2);
+ int xDiff = shanX - _secondHero->_middleX;
+ if (xDiff < 0) {
+ xDiff *= -1;
+ }
+ int yDiff = shanY - _secondHero->_middleY;
+ if (yDiff < 0) {
+ yDiff *= -1;
+ }
+ shanCoords -= 4;
+ if (shanCoords != _mainHero->_currCoords) {
+ yDiff *= 1.5;
+ int shanDis = xDiff * xDiff + yDiff * yDiff;
+ if (shanDis >= kMinDistance) {
+ //scangoodpoint:
+ while (1) {
+ shanCoords -= 4;
+ if (shanCoords == _mainHero->_currCoords) {
+ break;
+ }
+ int x = READ_UINT16(shanCoords);
+ int y = READ_UINT16(shanCoords + 2);
+ int pointDiffX = x - shanX;
+ if (pointDiffX < 0) {
+ pointDiffX *= -1;
+ }
+ int pointDiffY = y - shanY;
+ if (pointDiffY < 0) {
+ pointDiffY *= -1;
+ }
+ pointDiffY *= 1.5;
+ int distance = pointDiffX * pointDiffX + pointDiffY * pointDiffY;
+ if (distance >= kMinDistance) {
+ break;
+ }
+ }
+ //bye2
+ int pathSizeDiff = (shanCoords - _mainHero->_currCoords) / 4;
+ int destDir = *_mainHero->_currDirTab + pathSizeDiff;
+ _secondHero->_destDirection = destDir;
+ int destX = READ_UINT16(shanCoords);
+ int destY = READ_UINT16(shanCoords + 2);
+ _secondHero->_coords = makePath(kSecondHero, _secondHero->_middleX, _secondHero->_middleY, destX, destY);
+ if (_secondHero->_coords != nullptr) {
+ _secondHero->_currCoords = _mainHero->_coords;
+ int delay = shanLen1 - _shanLen;
+ if (delay < 6) {
+ delay = 6;
+ }
+ _secondHero->_moveDelay = delay / 2;
+ _secondHero->_state = Hero::kHeroStateDelayMove;
+ _secondHero->_dirTab = _directionTable;
+ _secondHero->_currDirTab = _directionTable;
+ _directionTable = nullptr;
+ }
+ }
+ }
+ }
}
-byte *PrinceEngine::makePath(int destX, int destY) {
+byte *PrinceEngine::makePath(int heroId, int currX, int currY, int destX, int destY) {
int realDestX = destX;
int realDestY = destY;
_flags->setFlagValue(Flags::MOVEDESTX, destX);
_flags->setFlagValue(Flags::MOVEDESTY, destY);
- int currX = _mainHero->_middleX; // TODO - check for second hero
- int currY = _mainHero->_middleY;
-
int x1 = currX / 2;
int y1 = currY / 2;
int x2 = destX / 2;
@@ -4280,8 +4318,13 @@ byte *PrinceEngine::makePath(int destX, int destY) {
}
if ((x1 == x2) && (y1 == y2)) {
- _mainHero->freeOldMove();
- _mainHero->_state = _mainHero->kHeroStateTurn;
+ if (!heroId) {
+ _mainHero->freeOldMove();
+ _mainHero->_state = Hero::kHeroStateTurn;
+ } else if (heroId == 1) {
+ _secondHero->freeOldMove();
+ _secondHero->_state = Hero::kHeroStateTurn;
+ }
return nullptr;
}
@@ -4381,8 +4424,8 @@ byte *PrinceEngine::makePath(int destX, int destY) {
WRITE_UINT16(newCoords - 2, realDestY);
WRITE_UINT32(newCoords, 0xFFFFFFFF);
newCoords += 4;
- _shanLen1 = (newCoords - newCoordsBegin);
- //_shanLen1 /= 4 ?
+ _shanLen = (newCoords - newCoordsBegin);
+ //_shanLen /= 4 ?
return newCoordsBegin;
}
}
@@ -4392,8 +4435,13 @@ byte *PrinceEngine::makePath(int destX, int destY) {
freeCoords3();
return nullptr;
} else {
- _mainHero->freeOldMove();
- _mainHero->_state = _mainHero->kHeroStateTurn;
+ if (!heroId) {
+ _mainHero->freeOldMove();
+ _mainHero->_state = Hero::kHeroStateTurn;
+ } else if (heroId == 1) {
+ _secondHero->freeOldMove();
+ _secondHero->_state = Hero::kHeroStateTurn;
+ }
return nullptr;
}
}
@@ -4465,7 +4513,7 @@ void PrinceEngine::mainLoop() {
_graph->update(_graph->_frontScreen);
// Calculate the frame delay based off a desired frame time
- int delay = 1000/15 - int32(_system->getMillis() - currentTime);
+ int delay = 1000 / 15 - int32(_system->getMillis() - currentTime);
// Ensure non-negative
delay = delay < 0 ? 0 : delay;
_system->delayMillis(delay);
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index ac898aaf57..4b8d78ad94 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -310,11 +310,18 @@ public:
Hero *_mainHero;
Hero *_secondHero;
+ enum HeroId {
+ kMainHero,
+ kSecondHero
+ };
+
int _mouseFlag;
uint16 _locationNr;
uint16 _sceneWidth;
int32 _picWindowX;
int32 _picWindowY;
+ int16 _lightX; // for hero shadow
+ int16 _lightY;
Image::BitmapDecoder *_roomBmp;
MhwanhDecoder *_suitcaseBmp;
Room *_room;
@@ -322,12 +329,25 @@ public:
InterpreterFlags *_flags;
Interpreter *_interpreter;
uint8 _currentMidi;
+ byte *_zoomBitmap;
+ byte *_shadowBitmap;
+
+ static const int16 kMaxPicWidth = 1280;
+ static const int16 kMaxPicHeight = 480;
+ static const int16 kZoomStep = 4;
+ static const int32 kZoomBitmapLen = kMaxPicHeight / kZoomStep * kMaxPicWidth / kZoomStep;
+ static const int32 kShadowBitmapSize = kMaxPicWidth * kMaxPicHeight / 8;
+ static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
+ static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep;
+ static const int16 kNormalWidth = 640;
+ static const int16 kNormalHeight = 480;
static const int kMaxNormAnims = 64;
static const int kMaxBackAnims = 64;
static const int kMaxObjects = 64;
static const int kMaxMobs = 64;
+ Common::Array<DrawNode> _drawNodeList;
Common::Array<AnimListItem> _animList;
Common::Array<BackgroundAnim> _backAnimList;
Common::Array<Anim> _normAnimList;
@@ -343,11 +363,6 @@ public:
Common::RandomSource _randomSource;
- static const int16 kNormalWidth = 640;
- static const int16 kNormalHeight = 480;
- static const int16 kMaxPicWidth = 1280;
- static const int16 kMaxPicHeight = 480;
-
void checkMasks(int x1, int y1, int sprWidth, int sprHeight, int z);
void insertMasks(Graphics::Surface *originalRoomSurface);
void showMask(int maskNr, Graphics::Surface *originalRoomSurface);
@@ -484,7 +499,7 @@ public:
bool _traceLineFirstPointFlag; // if plotTraceLine after first point
bool _tracePointFirstPointFlag; // if plotTracePoint after first point
byte *_directionTable;
- int _shanLen1;
+ int _shanLen;
byte *_checkBitmapTemp;
byte *_checkBitmap;
@@ -503,7 +518,7 @@ public:
int drawLine(int x0, int y0, int x1, int y1, int (*plotProc)(int, int, void *), void *data);
bool loadPath(const char *resourceName);
- byte *makePath(int destX, int destY);
+ byte *makePath(int heroId, int currX, int currY, int destX, int destY);
void findPoint(int x, int y);
int getPixelAddr(byte *pathBitmap, int x, int y);
static int plotTraceLine(int x, int y, void *data);
@@ -593,7 +608,6 @@ private:
Audio::SoundHandle _soundHandle[kMaxSamples];
Common::Array<PScr *> _pscrList;
- Common::Array<DrawNode> _drawNodeList;
Common::Array<InvItem> _allInvList;
Common::Array<Mob> _invMobList;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index cf45d50fdb..a621c864cb 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -1725,9 +1725,9 @@ void Interpreter::O_FREEFLC() {
void Interpreter::O_TALKHEROSTOP() {
uint16 heroId = readScriptFlagValue();
if (!heroId) {
- _vm->_mainHero->_state = _vm->_mainHero->kHeroStateStay;
+ _vm->_mainHero->_state = Hero::kHeroStateStay;
} else if (heroId == 1) {
- _vm->_secondHero->_state = _vm->_secondHero->kHeroStateStay;
+ _vm->_secondHero->_state = Hero::kHeroStateStay;
}
debugInterpreter("O_TALKHEROSTOP %d", heroId);
}