aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorlukaslw2014-05-30 22:05:40 +0200
committerlukaslw2014-06-22 20:08:25 +0200
commit16a6d99a861c75ff2a142cc604b5ea9d87063072 (patch)
tree9524c6a22c024978a2e1a7d76fc9aefdafb93507 /engines
parent4f291feadd7ee75b91213df677bf71f5f85e6700 (diff)
downloadscummvm-rg350-16a6d99a861c75ff2a142cc604b5ea9d87063072.tar.gz
scummvm-rg350-16a6d99a861c75ff2a142cc604b5ea9d87063072.tar.bz2
scummvm-rg350-16a6d99a861c75ff2a142cc604b5ea9d87063072.zip
PRINCE: loadOverlays(), checkNak()
Diffstat (limited to 'engines')
-rw-r--r--engines/prince/hero.cpp17
-rw-r--r--engines/prince/hero.h1
-rw-r--r--engines/prince/prince.cpp23
-rw-r--r--engines/prince/prince.h15
-rw-r--r--engines/prince/script.cpp33
-rw-r--r--engines/prince/script.h2
6 files changed, 78 insertions, 13 deletions
diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp
index b8e5780a4c..2f984c1814 100644
--- a/engines/prince/hero.cpp
+++ b/engines/prince/hero.cpp
@@ -140,10 +140,6 @@ int Hero::getScaledValue(int size) {
}
}
-void Hero::checkNak() {
-
-}
-
Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
Graphics::Surface *zoomedFrame = new Graphics::Surface();
zoomedFrame->create(_scaledFrameXSize, _scaledFrameYSize, Graphics::PixelFormat::createFormatCLUT8());
@@ -191,6 +187,7 @@ Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
}
void Hero::countDrawPosition() {
+ int16 tempMiddleX;
int16 tempMiddleY;
int16 baseX = _moveSet[_moveSetType]->getBaseX();
int16 baseY = _moveSet[_moveSetType]->getBaseY();
@@ -206,12 +203,12 @@ void Hero::countDrawPosition() {
_scaledFrameYSize = getScaledValue(_frameYSize);
//TODO
- //int tempHeroHeight = scaledY; // not used? global?
- //int width = scaledX / 2;
- //tempMiddleX = _middleX - width; //eax
- //int z = _middleY; //ebp
- //int y = _middleY - scaledY; //ecx
- //checkNak();
+ int tempHeroHeight = _scaledFrameYSize; // not used? global?
+ int width = _frameXSize / 2;
+ tempMiddleX = _middleX - width; //eax
+ int z = _middleY; //ebp
+ int y = _middleY - _scaledFrameYSize; //ecx
+ _vm->checkNak(tempMiddleX, y, _scaledFrameXSize, _scaledFrameYSize, z);
if (_zoomFactor != 0) {
//notfullSize
diff --git a/engines/prince/hero.h b/engines/prince/hero.h
index 839907a574..565212447b 100644
--- a/engines/prince/hero.h
+++ b/engines/prince/hero.h
@@ -115,7 +115,6 @@ public:
int getScaledValue(int size);
void selectZoom();
void countDrawPosition();
- void checkNak();
Graphics::Surface *zoomSprite(Graphics::Surface *heroFrame);
void showHeroAnimFrame();
void line(int x1, int y1, int x2, int y2);
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 5e1b49e48e..beaa997184 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -318,6 +318,10 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_mainHero->setShadowScale(_script->getShadowScale(_locationNr));
_room->loadRoom(_script->getRoomOffset(_locationNr));
+
+ _overlayList.clear();
+ _script->loadOverlays(_overlayList, _room->_nak);
+
clearBackAnimList();
_script->installBackAnims(_backAnimList, _room->_backAnim);
@@ -742,6 +746,25 @@ bool PrinceEngine::spriteCheck(Graphics::Surface *backAnimSurface, int destX, in
return true;
}
+void PrinceEngine::checkNak(int x1, int y1, int sprWidth, int sprHeight, int z) {
+ int x2 = x1 + sprWidth - 1;
+ int y2 = y1 + sprHeight - 1;
+ if (x1 < 0) {
+ x1 = 0;
+ }
+ for (uint i = 0; i < _overlayList.size() ; i++) {
+ if (_overlayList[i]._state != 1 && _overlayList[i]._flags != 1) {
+ if (_overlayList[i]._z > z) {
+ if (_overlayList[i]._x1 <= x2 && _overlayList[i]._x2 >= x1) {
+ if (_overlayList[i]._y1 <= y2 && _overlayList[i]._y2 >= y1) {
+ _overlayList[i]._state = 1;
+ }
+ }
+ }
+ }
+ }
+}
+
void PrinceEngine::showSprite(Graphics::Surface *backAnimSurface, int destX, int destY) {
if (spriteCheck(backAnimSurface, destX, destY)) {
destX -= _picWindowX;
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 8b840d3cab..988f468a72 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -141,6 +141,18 @@ struct BackgroundAnim {
Common::Array<Anim> backAnims;
};
+// Nak (PL - Nakladka)
+struct Overlay {
+ int16 _state; // visible / invisible
+ int16 _flags; // turning on / turning off of an overlay
+ int16 _x1;
+ int16 _y1;
+ int16 _x2;
+ int16 _y2;
+ int16 _z;
+ int16 _number; // number of mask for background recreating
+};
+
struct DebugChannel {
enum Type {
@@ -209,6 +221,8 @@ public:
static const int16 kNormalWidth = 640;
static const int16 kNormalHeight = 480;
+ void checkNak(int x1, int y1, int sprWidth, int sprHeight, int z);
+
int testAnimNr;
int testAnimFrame;
@@ -255,6 +269,7 @@ private:
Animation *_zoom;
Common::Array<Mob> _mobList;
Common::Array<Object *> _objList;
+ Common::Array<Overlay> _overlayList;
bool _flicLooped;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 48617f16f5..9798882bbc 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -284,13 +284,42 @@ void Script::installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList,
}
}
-void Script::installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset) {
+void Script::installBackAnims(Common::Array<BackgroundAnim> &backanimList, int offset) {
for (uint i = 0; i < 64; i++) {
- installSingleBackAnim(_backanimList, offset);
+ installSingleBackAnim(backanimList, offset);
offset += 4;
}
}
+void Script::loadOverlays(Common::Array<Overlay> &overlayList, int offset) {
+ Overlay tempOverlay;
+ while (1) {
+ tempOverlay._state = READ_UINT32(&_data[offset]);
+ if (tempOverlay._state == -1) {
+ break;
+ }
+ debug("tempOverlay._state: %d", tempOverlay._state);
+ tempOverlay._flags = READ_UINT32(&_data[offset + 2]);
+ debug("tempOverlay._flags: %d", tempOverlay._flags);
+ tempOverlay._x1 = READ_UINT32(&_data[offset + 4]);
+ debug("tempOverlay._x1: %d", tempOverlay._x1);
+ tempOverlay._y1 = READ_UINT32(&_data[offset + 6]);
+ debug("tempOverlay._y1: %d", tempOverlay._y1);
+ tempOverlay._x2 = READ_UINT32(&_data[offset + 8]);
+ debug("tempOverlay._x2: %d", tempOverlay._x2);
+ tempOverlay._y2 = READ_UINT32(&_data[offset + 10]);
+ debug("tempOverlay._y2: %d", tempOverlay._y2);
+ tempOverlay._z = READ_UINT32(&_data[offset + 12]);
+ debug("tempOverlay._z: %d", tempOverlay._z);
+ tempOverlay._number = READ_UINT32(&_data[offset + 14]);
+ debug("tempOverlay._number: %d\n", tempOverlay._number);
+ overlayList.push_back(tempOverlay);
+ offset += 16; // size of Overlay (Nak) struct
+ }
+ debug("NAK size: %d", sizeof(Overlay));
+ debug("overlayList size: %d", overlayList.size());
+}
+
InterpreterFlags::InterpreterFlags() {
resetAllFlags();
}
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 5f0f1e139e..d0693ca11f 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -39,6 +39,7 @@ class PrinceEngine;
class Animation;
struct Anim;
struct BackgroundAnim;
+struct Overlay;
namespace Detail {
template <typename T> T LittleEndianReader(void *data);
@@ -134,6 +135,7 @@ public:
uint8 *getRoomOffset(int locationNr);
void installBackAnims(Common::Array<BackgroundAnim> &_backanimList, int offset);
void installSingleBackAnim(Common::Array<BackgroundAnim> &_backanimList, int offset);
+ void loadOverlays(Common::Array<Overlay> &overlayList, int offset);
const char *getString(uint32 offset) {
return (const char *)(&_data[offset]);