aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukaslw2014-05-27 16:29:08 +0200
committerlukaslw2014-06-22 20:08:15 +0200
commitbc1553def6d7cc8a2cae014b35e0e963acc825b4 (patch)
tree7df7d43e8ca92196f9cf5a77406b20540265201d
parentc9ed2074b5e7964e52b494f135767d7b8bc96c8b (diff)
downloadscummvm-rg350-bc1553def6d7cc8a2cae014b35e0e963acc825b4.tar.gz
scummvm-rg350-bc1553def6d7cc8a2cae014b35e0e963acc825b4.tar.bz2
scummvm-rg350-bc1553def6d7cc8a2cae014b35e0e963acc825b4.zip
PRINCE: showSprite first implementation, showBackAnims small update
-rw-r--r--engines/prince/hero.cpp8
-rw-r--r--engines/prince/hero.h1
-rw-r--r--engines/prince/prince.cpp88
-rw-r--r--engines/prince/prince.h5
4 files changed, 77 insertions, 25 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
index a91ef94602..d5123cc337 100644
--- a/engines/prince/hero.cpp
+++ b/engines/prince/hero.cpp
@@ -754,14 +754,14 @@ void Hero::scrollHero() {
*/
int locationWidth = _vm->_sceneWidth;
- int difference = locationWidth - kNormalWidth / 2;
+ int difference = locationWidth - _vm->kNormalWidth / 2;
int destValue = 0;
- if (position > kNormalWidth / 2) {
- destValue = difference - kNormalWidth / 2;
+ if (position > _vm->kNormalWidth / 2) {
+ destValue = difference - _vm->kNormalWidth / 2;
}
if (position < difference) {
- destValue = position - kNormalWidth / 2;
+ destValue = position - _vm->kNormalWidth / 2;
}
if(destValue < 0) {
destValue = 0;
diff --git a/engines/prince/hero.h b/engines/prince/hero.h
index 0b3935637d..c430cc3861 100644
--- a/engines/prince/hero.h
+++ b/engines/prince/hero.h
@@ -43,7 +43,6 @@ public:
static const int16 kMaxPicWidth = 1280;
static const int16 kMaxPicHeight = 480;
static const int16 kZoomBitmapWidth = kMaxPicWidth / kZoomStep;
- static const int16 kNormalWidth = 640;
static const int16 kShadowLineArraySize = 2 * 1280 * 4;
static const int32 kShadowBitmapSize = kMaxPicWidth * kMaxPicHeight / 8;
static const int16 kScreenWidth = 640;
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 4d221fdfeb..be4fb1544e 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -115,13 +115,15 @@ PrinceEngine::~PrinceEngine() {
}
_objList.clear();
- /*
- for (uint i = 0; i < _backAnimList.size(); i++) {
- delete _backAnimList[i]._animData;
- delete _backAnimList[i]._shadowData;
+ for (uint32 i = 0; i < _backAnimList.size(); i++) {
+ int anims = _backAnimList[i]._seq._anims != 0 ? _backAnimList[i]._seq._anims : 1;
+ for (uint32 j = 0; j < anims; j++) {
+ delete _backAnimList[i].backAnims[j]._animData;
+ delete _backAnimList[i].backAnims[j]._shadowData;
+ }
+ _backAnimList[i].backAnims.clear();
}
_backAnimList.clear();
- */
for (uint i = 0; i < _mainHero->_moveSet.size(); i++) {
delete _mainHero->_moveSet[i];
@@ -244,8 +246,7 @@ bool AnimListItem::loadFromStream(Common::SeekableReadStream &stream) {
_type = type;
_fileNumber = stream.readUint16LE();
_startPhase = stream.readUint16LE();
- //_endPhase = stream.readUint16LE();
- _endPhase = stream.readSint16LE();
+ _endPhase = stream.readUint16LE();
_loopPhase = stream.readUint16LE();
_x = stream.readSint16LE();
_y = stream.readSint16LE();
@@ -327,14 +328,15 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
_room->loadRoom(_script->getRoomOffset(_locationNr));
- /*
for (uint32 i = 0; i < _backAnimList.size(); i++) {
- delete _backAnimList[i]._animData;
- delete _backAnimList[i]._shadowData;
+ int anims = _backAnimList[i]._seq._anims != 0 ? _backAnimList[i]._seq._anims : 1;
+ for (uint32 j = 0; j < anims; j++) {
+ delete _backAnimList[i].backAnims[j]._animData;
+ delete _backAnimList[i].backAnims[j]._shadowData;
+ }
+ _backAnimList[i].backAnims.clear();
}
_backAnimList.clear();
- */
- _backAnimList.clear();
_script->installBackAnims(_backAnimList, _room->_backAnim);
@@ -704,15 +706,59 @@ void PrinceEngine::showTexts() {
}
}
-void PrinceEngine::setBackAnim() {
+void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) {
+ int sprWidth = backAnimSurface->w;
+ int sprHeight = backAnimSurface->h;
+ int sprModulo = 0;
+
+ if (destX - _picWindowX < 0) { // x1 on visible part of screen?
+ // X1 signed, we add spriteWidth for x2
+ if (sprWidth + destX - _picWindowX - 1 < 0) {
+ //exit - x2 is negative - out of window
+ return; // don't draw
+ } else {
+ //esi += _picWindowX - destX;
+ sprWidth -= _picWindowX - destX;
+ sprModulo += _picWindowX - destX;
+ destX = 0; // x1 = 0;
+ }
+ }
+ //left_x_check_ok
+ if (destX >= kNormalWidth) { // x1 outside of screen on right side
+ return; // don't draw
+ }
+ if (destX + sprWidth > kNormalWidth) { // x2 too far?
+ sprWidth -= destX - kNormalWidth;
+ sprModulo += destX - kNormalWidth;
+ }
+ //right_x_check_ok
+ if (destY - _picWindowY < 0) {
+ if (sprHeight + destY - _picWindowY - 1 < 0) {
+ //exit - y2 is negative - out of window
+ return; // don't draw
+ } else {
+ sprHeight -= _picWindowY - destY;
+ //esi += (sprWidth + sprModulo) * (_picWindowY - destY);
+ destY = 0;
+ }
+ }
+ //upper_y_check_ok
+ if (destY >= kNormalHeight) {
+ return; // don't draw
+ }
+ if (destY + sprHeight > kNormalHeight) {
+ sprHeight -= destY + sprHeight - kNormalHeight;
+ }
+ //lower_y_check_ok
+ _graph->drawTransparent(destX - _picWindowX, destY - _picWindowY, backAnimSurface); // TODO
}
void PrinceEngine::showBackAnims() {
for (uint i = 0; i < _backAnimList.size(); i++) {
int activeSubAnim = _backAnimList[i]._seq._currRelative;
- if (_backAnimList[i].backAnims[activeSubAnim]._state == 0) {
+ if (_backAnimList[i].backAnims[activeSubAnim]._state == 0 && _backAnimList[i]._seq._type != 2 && _backAnimList[i]._seq._type != 3 && _backAnimList[i]._seq._type != 4) { //TEMP
_backAnimList[i]._seq._counter++;
if (_backAnimList[i]._seq._type == 2) {
@@ -749,10 +795,9 @@ void PrinceEngine::showBackAnims() {
}
//not_type_3_1:
//show_bugger
- if (_backAnimList[i].backAnims[activeSubAnim]._frame == _backAnimList[i].backAnims[activeSubAnim]._lastFrame) {
+ if (_backAnimList[i].backAnims[activeSubAnim]._frame == _backAnimList[i].backAnims[activeSubAnim]._lastFrame - 1) { // TEST
//loop_back_anim
_backAnimList[i].backAnims[activeSubAnim]._frame = _backAnimList[i].backAnims[activeSubAnim]._loopFrame;
- //debug("loopFrame: %d", _backAnimList[i].backAnims[tempAnimNr]._loopFrame);
//change_back_anim
if (_backAnimList[i]._seq._type == 0) {
//show_bugger
@@ -854,17 +899,22 @@ void PrinceEngine::showBackAnims() {
//not_end:
_backAnimList[i].backAnims[activeSubAnim]._showFrame = _backAnimList[i].backAnims[activeSubAnim]._frame;
- //ShowFrameCode
- //ShowFrameCodeShadow
+ //ShowFrameCode
int frame = _backAnimList[i].backAnims[activeSubAnim]._showFrame;
int phaseFrameIndex = _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseFrameIndex(frame);
Graphics::Surface *backAnimSurface = _backAnimList[i].backAnims[activeSubAnim]._animData->getFrame(phaseFrameIndex);
int x = _backAnimList[i].backAnims[activeSubAnim]._x + _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseOffsetX(frame);
int y = _backAnimList[i].backAnims[activeSubAnim]._y + _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseOffsetY(frame);
- _graph->drawTransparent(x, y, backAnimSurface); // out of range now - crash .exe
+ //debug("x: %d", x);
+ //debug("picWindowX: %d", _picWindowX);
+ if (x - _picWindowX >= 0) { // || x - _picWindowX + _backAnimList[i].backAnims[activeSubAnim]._animData->getPhaseOffsetX(frame) >= 0 ??
+ showSprite(backAnimSurface, x, y);
+ }
backAnimSurface->free();
delete backAnimSurface;
+
+ //ShowFrameCodeShadow
}
}
}
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 356c4dd960..34e6c753eb 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -208,6 +208,9 @@ public:
Common::RandomSource _randomSource;
+ static const int16 kNormalWidth = 640;
+ static const int16 kNormalHeight = 480;
+
int testAnimNr;
int testAnimFrame;
@@ -222,7 +225,7 @@ private:
void init();
void showLogo();
void showBackAnims();
- void setBackAnim();
+ void showSprite(Graphics::Surface *backAnimSurface, int destX, int destY);
void makeShadowTable(int brightness);
uint32 getTextWidth(const char *s);