aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/neverhood/graphics.h15
-rw-r--r--engines/neverhood/module1000.cpp119
-rw-r--r--engines/neverhood/module1000.h8
-rw-r--r--engines/neverhood/module1200.cpp44
-rw-r--r--engines/neverhood/module1300.cpp72
-rw-r--r--engines/neverhood/module1400.cpp60
-rw-r--r--engines/neverhood/module1700.cpp25
-rw-r--r--engines/neverhood/module2000.cpp5
-rw-r--r--engines/neverhood/module2200.cpp89
-rw-r--r--engines/neverhood/scene.h5
-rw-r--r--engines/neverhood/sprite.cpp16
-rw-r--r--engines/neverhood/sprite.h6
12 files changed, 148 insertions, 316 deletions
diff --git a/engines/neverhood/graphics.h b/engines/neverhood/graphics.h
index 36bd95e3ab..08fa1f5df0 100644
--- a/engines/neverhood/graphics.h
+++ b/engines/neverhood/graphics.h
@@ -44,14 +44,29 @@ struct NRect {
int16 x1, y1, x2, y2;
NRect() : x1(0), y1(0), x2(0), y2(0) {}
NRect(int16 x01, int16 y01, int16 x02, int16 y02) : x1(x01), y1(y01), x2(x02), y2(y02) {}
+ void set(int16 x01, int16 y01, int16 x02, int16 y02) {
+ x1 = x01;
+ y1 = y01;
+ x2 = x02;
+ y2 = y02;
+ }
};
typedef Common::Array<NRect> NRectArray;
+// TODO: Use Common::Rect
struct NDrawRect {
int16 x, y, width, height;
NDrawRect() : x(0), y(0), width(0), height(0) {}
NDrawRect(int16 x0, int16 y0, int16 width0, int16 height0) : x(x0), y(y0), width(width0), height(height0) {}
+ int16 x2() { return x + width; }
+ int16 y2() { return y + height; }
+ void set(int16 x0, int16 y0, int16 width0, int16 height0) {
+ x = x0;
+ y = y0;
+ width = width0;
+ height = height0;
+ }
};
class AnimResource;
diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp
index 8dda9ed039..ddd3e0aef9 100644
--- a/engines/neverhood/module1000.cpp
+++ b/engines/neverhood/module1000.cpp
@@ -369,18 +369,11 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which)
tempSprite = insertStaticSprite(0x2080A3A8, 1300);
- // TODO: This sucks somehow, find a better way
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = tempSprite->getSurface()->getDrawRect().x + tempSprite->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, tempSprite->getDrawRect().x2(), 480);
if (getGlobalVar(0xD217189D) == 0) {
_asDoor = addSprite(new AsScene1001Door(_vm));
- _asDoor->getSurface()->getClipRect().x1 = 0;
- _asDoor->getSurface()->getClipRect().y1 = 0;
- _asDoor->getSurface()->getClipRect().x2 = tempSprite->getSurface()->getDrawRect().x + tempSprite->getSurface()->getDrawRect().width;
- _asDoor->getSurface()->getClipRect().y2 = 480;
+ _asDoor->setClipRect(0, 0, tempSprite->getDrawRect().x2(), 480);
} else {
_asDoor = NULL;
}
@@ -395,10 +388,7 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x03C698DA) == 0) {
tempSprite = insertStaticSprite(0x8C066150, 200);
_asWindow = addSprite(new AsScene1001Window(_vm));
- _asWindow->getSurface()->getClipRect().x1 = tempSprite->getSurface()->getDrawRect().x;
- _asWindow->getSurface()->getClipRect().y1 = tempSprite->getSurface()->getDrawRect().y;
- _asWindow->getSurface()->getClipRect().x2 = tempSprite->getSurface()->getDrawRect().x + tempSprite->getSurface()->getDrawRect().width;
- _asWindow->getSurface()->getClipRect().y2 = tempSprite->getSurface()->getDrawRect().y + tempSprite->getSurface()->getDrawRect().height;
+ _asWindow->setClipRect(tempSprite->getDrawRect());
} else {
_asWindow = NULL;
}
@@ -526,12 +516,7 @@ AsScene1002Ring::AsScene1002Ring(NeverhoodEngine *vm, Scene *parentScene, bool f
SetMessageHandler(&AsScene1002Ring::handleMessage4475E0);
}
- debug("clipY1 = %d", clipY1);
-
- _surface->getClipRect().x1 = 0;
- _surface->getClipRect().y1 = clipY1;
- _surface->getClipRect().x2 = 640;
- _surface->getClipRect().y2 = 480;
+ setClipRect(0, clipY1, 640, 480);
_x = x;
_y = y;
@@ -664,7 +649,7 @@ AsScene1002Door::AsScene1002Door(NeverhoodEngine *vm, NRect &clipRect)
_spriteResource.load2(0x1052370F);
createSurface(800, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height);
- _surface->getClipRect() = clipRect;
+ setClipRect(clipRect);
_x = 526;
@@ -764,7 +749,7 @@ AsScene1002DoorSpy::AsScene1002DoorSpy(NeverhoodEngine *vm, NRect &clipRect, Sce
SetMessageHandler(&AsScene1002DoorSpy::handleMessage4489D0);
SetSpriteCallback(&AsScene1002DoorSpy::spriteUpdate448AA0);
createSurface(800, 136, 147);
- _surface->getClipRect() = clipRect;
+ setClipRect(clipRect);
spriteUpdate448AA0();
_soundResource.load(0xC0C40298);
setFileHash(0x586C1D48, 0, 0);
@@ -803,17 +788,14 @@ void AsScene1002DoorSpy::spriteUpdate448AA0() {
}
void AsScene1002DoorSpy::sub448AC0() {
- _surface->getClipRect() = _rect;
+ setClipRect(_rect);
_parentScene->setSurfacePriority(getSurface(), 800);
setFileHash(0x586C1D48, 0, 0);
SetMessageHandler(&AsScene1002DoorSpy::handleMessage4489D0);
}
void AsScene1002DoorSpy::sub448B10() {
- _surface->getClipRect().x1 = 0;
- _surface->getClipRect().y1 = 0;
- _surface->getClipRect().x2 = 640;
- _surface->getClipRect().y2 = 480;
+ setClipRect(0, 0, 640, 480);
_parentScene->setSurfacePriority(getSurface(), 1200);
setFileHash(0x586C1D48, 1, -1);
SetMessageHandler(&AsScene1002DoorSpy::handleMessage448A60);
@@ -1313,14 +1295,11 @@ uint32 Class479::handleMessage(int messageNum, const MessageParam &param, Entity
sendMessage(_parentScene, 0x1022, 1200);
_flag1 = true;
_savedClipRect = _surface->getClipRect();
- _surface->getClipRect().x1 = 0;
- _surface->getClipRect().y1 = 0;
- _surface->getClipRect().x2 = 640;
- _surface->getClipRect().y2 = 480;
+ setClipRect(0, 0, 640, 480);
} else if (param.asInteger() == 0x88001184) {
sendMessage(_parentScene, 0x1022, 1000);
if (_flag1) {
- _surface->getClipRect() = _savedClipRect;
+ setClipRect(_savedClipRect);
}
}
break;
@@ -1362,54 +1341,39 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which)
InsertKlaymanInitArgs(KmScene1002, 90, 226, (_class599, _ssLadderArch));
_class478 = addSprite(new Class478(_vm, _klayman));
setMessageList(0x004B4270);
- _klayman->getSurface()->getClipRect().x1 = 31;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _ssLadderArchPart3->getSurface()->getDrawRect().y + _ssLadderArchPart3->getSurface()->getDrawRect().height;
+ _klayman->setClipRect(31, 0, _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart3->getDrawRect().y2());
_class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
_klayman->setRepl(64, 0);
} else {
InsertKlaymanInitArgs(KmScene1002, 379, 435, (_class599, _ssLadderArch));
_class478 = addSprite(new Class478(_vm, _klayman));
setMessageList(0x004B4270);
- _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _ssLadderArchPart1->getSurface()->getDrawRect().y + _ssLadderArchPart1->getSurface()->getDrawRect().height;
- _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _klayman->setClipRect(_ssLadderArch->getDrawRect().x, 0, _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart1->getDrawRect().y2());
+ _class478->setClipRect(_klayman->getClipRect());
}
} else if (which == 1) {
InsertKlaymanInitArgs(KmScene1002, 650, 435, (_class599, _ssLadderArch));
_class478 = addSprite(new Class478(_vm, _klayman));
setMessageList(0x004B4478);
- _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _ssLadderArchPart1->getSurface()->getDrawRect().y + _ssLadderArchPart1->getSurface()->getDrawRect().height;
- _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _klayman->setClipRect(_ssLadderArch->getDrawRect().x, 0, _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart1->getDrawRect().y2());
+ _class478->setClipRect(_klayman->getClipRect());
_vm->_gameState.field2 = 1;
} else if (which == 2) {
InsertKlaymanInitArgs(KmScene1002, 68, 645, (_class599, _ssLadderArch));
_class478 = addSprite(new Class478(_vm, _klayman));
setMessageList(0x004B4298);
- _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _ssLadderArchPart1->getSurface()->getDrawRect().y + _ssLadderArchPart1->getSurface()->getDrawRect().height;
- _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _klayman->setClipRect(_ssLadderArch->getDrawRect().x, 0, _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart1->getDrawRect().y2());
+ _class478->setClipRect(_klayman->getClipRect());
_vm->_gameState.field2 = 1;
sendMessage(_klayman, 0x4820, 0);
} else {
InsertKlaymanInitArgs(KmScene1002, 90, 226, (_class599, _ssLadderArch));
_class478 = addSprite(new Class478(_vm, _klayman));
setMessageList(0x004B4470);
- _klayman->getSurface()->getClipRect().x1 = 31;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _ssLadderArchPart3->getSurface()->getDrawRect().y + _ssLadderArchPart3->getSurface()->getDrawRect().height;
- _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _klayman->setClipRect(31, 0, _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart3->getDrawRect().y2());
+ _class478->setClipRect(_klayman->getClipRect());
_class479 = addSprite(new Class479(_vm, this, _klayman));
- _class479->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _class479->setClipRect(_klayman->getClipRect());
_klayman->setRepl(64, 0);
_vm->_gameState.field2 = 0;
}
@@ -1417,16 +1381,14 @@ Scene1002::Scene1002(NeverhoodEngine *vm, Module *parentModule, int which)
insertMouse433(0x23303124);
tempSprite = insertStaticSprite(0xB3242310, 825);
- tempClipRect.x1 = tempSprite->getSurface()->getDrawRect().x;
- tempClipRect.y1 = tempSprite->getSurface()->getDrawRect().y;
- tempClipRect.x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- tempClipRect.y2 = _ssLadderArchPart2->getSurface()->getDrawRect().y + _ssLadderArchPart2->getSurface()->getDrawRect().height;
+ tempClipRect.set(tempSprite->getDrawRect().x, tempSprite->getDrawRect().y,
+ _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart2->getDrawRect().y2());
- _asRing1 = addSprite(new AsScene1002Ring(_vm, this, false, 258, 191, _class599->getSurface()->getDrawRect().y, false));
- _asRing2 = addSprite(new AsScene1002Ring(_vm, this, false, 297, 189, _class599->getSurface()->getDrawRect().y, false));
- _asRing3 = addSprite(new AsScene1002Ring(_vm, this, true, 370, 201, _class599->getSurface()->getDrawRect().y, getGlobalVar(0x8306F218) != 0));
- _asRing4 = addSprite(new AsScene1002Ring(_vm, this, false, 334, 191, _class599->getSurface()->getDrawRect().y, false));
- _asRing5 = addSprite(new AsScene1002Ring(_vm, this, false, 425, 184, _class599->getSurface()->getDrawRect().y, false));
+ _asRing1 = addSprite(new AsScene1002Ring(_vm, this, false, 258, 191, _class599->getDrawRect().y, false));
+ _asRing2 = addSprite(new AsScene1002Ring(_vm, this, false, 297, 189, _class599->getDrawRect().y, false));
+ _asRing3 = addSprite(new AsScene1002Ring(_vm, this, true, 370, 201, _class599->getDrawRect().y, getGlobalVar(0x8306F218) != 0));
+ _asRing4 = addSprite(new AsScene1002Ring(_vm, this, false, 334, 191, _class599->getDrawRect().y, false));
+ _asRing5 = addSprite(new AsScene1002Ring(_vm, this, false, 425, 184, _class599->getDrawRect().y, false));
_asDoor = addSprite(new AsScene1002Door(_vm, tempClipRect));
@@ -1456,11 +1418,8 @@ Scene1002::~Scene1002() {
void Scene1002::update() {
Scene::update();
if (!_flag1B4 && _klayman->getY() > 230) {
- _klayman->getSurface()->getClipRect().x1 = _ssLadderArch->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _ssLadderArchPart2->getSurface()->getDrawRect().x + _ssLadderArchPart2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _ssLadderArchPart1->getSurface()->getDrawRect().y + _ssLadderArchPart1->getSurface()->getDrawRect().height;
- _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _klayman->setClipRect(_ssLadderArch->getDrawRect().x, 0, _ssLadderArchPart2->getDrawRect().x2(), _ssLadderArchPart1->getDrawRect().y2());
+ _class478->setClipRect(_klayman->getClipRect());
deleteSprite(&_ssLadderArchPart3);
_klayman->clearRepl();
_flag1B4 = true;
@@ -1480,6 +1439,7 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam &param, Entit
Scene::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x0001:
+ // Debug stuff (original)
if (param.asPoint().x == 0 && getGlobalVar(0xA4014072)) {
setGlobalVar(0x8306F218, 1);
setGlobalVar(0x1B144052, 3);
@@ -1487,6 +1447,7 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam &param, Entit
}
break;
case 0x000D:
+ // Debug stuff (original)
if (param.asInteger() == 0x48848178) {
setGlobalVar(0x8306F218, 1);
setGlobalVar(0x1B144052, 3);
@@ -1499,15 +1460,12 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam &param, Entit
if (getGlobalVar(0x8306F218)) {
setMessageList(0x004B4428);
} else {
- // TODO _resourceTable3.load();
setMessageList(0x004B4448);
}
messageResult = 1;
} else if (param.asInteger() == 0x4A845A00) {
- // TODO _resourceTable4.load();
sendEntityMessage(_klayman, 0x1014, _asRing1);
} else if (param.asInteger() == 0x43807801) {
- // TODO _resourceTable4.load();
sendEntityMessage(_klayman, 0x1014, _asRing2);
} else if (param.asInteger() == 0x46C26A01) {
if (getGlobalVar(0x8306F218)) {
@@ -1518,27 +1476,19 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam &param, Entit
setGlobalVar(0x2B514304, 1);
setMessageList(0x004B44A8);
} else {
- // TODO _resourceTable5.load();
setMessageList(0x004B44A0);
}
}
messageResult = 1;
} else if (param.asInteger() == 0x468C7B11) {
- // TODO _resourceTable4.load();
sendEntityMessage(_klayman, 0x1014, _asRing4);
} else if (param.asInteger() == 0x42845B19) {
- // TODO _resourceTable4.load();
sendEntityMessage(_klayman, 0x1014, _asRing5);
} else if (param.asInteger() == 0xC0A07458) {
sendEntityMessage(_klayman, 0x1014, _class426);
}
break;
case 0x1024:
- if (param.asInteger() == 1) {
- // TODO _resourceTable3.load();
- } else if (param.asInteger() == 3) {
- // TODO _resourceTable2.load();
- }
sendMessage(_parentModule, 0x1024, param.asInteger());
break;
case 0x2000:
@@ -1717,11 +1667,8 @@ Scene1004::Scene1004(NeverhoodEngine *vm, Module *parentModule, int which)
insertStaticSprite(0x3060222E, 1300);
tempSprite = insertStaticSprite(0x0E002004, 1300);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = tempSprite->getSurface()->getDrawRect().y;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
- _class478->getSurface()->getClipRect() = _klayman->getSurface()->getClipRect();
+ _klayman->setClipRect(0, tempSprite->getDrawRect().y, 640, 480);
+ _class478->setClipRect(_klayman->getClipRect());
_asTrashCan = addSprite(new AsScene1004TrashCan(_vm));
diff --git a/engines/neverhood/module1000.h b/engines/neverhood/module1000.h
index a7046ce1a4..47b1a91229 100644
--- a/engines/neverhood/module1000.h
+++ b/engines/neverhood/module1000.h
@@ -267,14 +267,6 @@ public:
Scene1002(NeverhoodEngine *vm, Module *parentModule, int which);
virtual ~Scene1002();
protected:
- // TODO ResourceTable _resourceTable1;
- // TODO ResourceTable _resourceTable2;
- // TODO ResourceTable _resourceTable3;
- // TODO ResourceTable _resourceTable4;
- // TODO ResourceTable _resourceTable5;
- // TODO ResourceTable _resourceTable6;
- // TODO ResourceTable _resourceTable7;
- // TODO ResourceTable _resourceTable8;
Sprite *_asRing1;
Sprite *_asRing2;
Sprite *_asRing3;
diff --git a/engines/neverhood/module1200.cpp b/engines/neverhood/module1200.cpp
index 81e61c7fc2..62462fc649 100644
--- a/engines/neverhood/module1200.cpp
+++ b/engines/neverhood/module1200.cpp
@@ -27,7 +27,6 @@ namespace Neverhood {
Module1200::Module1200(NeverhoodEngine *vm, Module *parentModule, int which)
: Module(vm, parentModule) {
- // TODO _resourceTable.setResourceList(0x004B3E68);
SetMessageHandler(&Module1200::handleMessage);
debug("Module1200: which = %d", which);
@@ -188,10 +187,7 @@ SsScene1201Tnt::SsScene1201Tnt(NeverhoodEngine *vm, uint32 elemIndex, uint32 poi
}
createSurface(50, _spriteResource.getDimensions().width, _spriteResource.getDimensions().height);
- _surface->getClipRect().x1 = 0;
- _surface->getClipRect().y1 = 0;
- _surface->getClipRect().x2 = 640;
- _surface->getClipRect().y2 = clipY2;
+ setClipRect(0, 0, 640, clipY2);
_needRefresh = true;
StaticSprite::update();
}
@@ -774,22 +770,19 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
_vm->_collisionMan->addSprite(_asTape);
tempSprite = insertStaticSprite(0x03C82530, 100);
- topY1 = tempSprite->getY() + tempSprite->getSurface()->getDrawRect().height;
+ topY1 = tempSprite->getY() + tempSprite->getDrawRect().height;
tempSprite = insertStaticSprite(0x88182069, 200);
- topY2 = tempSprite->getY() + tempSprite->getSurface()->getDrawRect().height;
+ topY2 = tempSprite->getY() + tempSprite->getDrawRect().height;
tempSprite = insertStaticSprite(0x476014E0, 300);
- topY3 = tempSprite->getY() + tempSprite->getSurface()->getDrawRect().height;
+ topY3 = tempSprite->getY() + tempSprite->getDrawRect().height;
tempSprite = insertStaticSprite(0x04063110, 500);
topY4 = tempSprite->getY() + 1;
_class466 = addSprite(new Class466(_vm, getGlobalVar(0x000CF819) && which != 1));
- _class466->getSurface()->getClipRect().x1 = 0;
- _class466->getSurface()->getClipRect().y1 = topY4;
- _class466->getSurface()->getClipRect().x2 = 640;
- _class466->getSurface()->getClipRect().y2 = 480;
+ _class466->setClipRect(0, topY4, 640, 480);
insertStaticSprite(0x400B04B0, 1200);
@@ -797,7 +790,7 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
x1 = tempSprite->getX();
tempSprite = insertStaticSprite(0xA29223FA, 1200);
- x2 = tempSprite->getX() + tempSprite->getSurface()->getDrawRect().width;
+ x2 = tempSprite->getX() + tempSprite->getDrawRect().width;
class464 = addSprite(new Class464(_vm));
@@ -830,10 +823,7 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
setMessageList(0x004AEC10);
}
- _klayman->getSurface()->getClipRect().x1 = x1;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = x2;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(x1, 0, x2, 480);
_klayman->setRepl(64, 0);
if (getGlobalVar(0x0A310817) && !getGlobalVar(0x0A18CA33)) {
@@ -851,17 +841,11 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
if (!getGlobalVar(0x0A18CA33)) {
AsScene1201TntMan *asTntMan;
asTntMan = new AsScene1201TntMan(_vm, this, _class466, which == 1);
- asTntMan->getSurface()->getClipRect().x1 = x1;
- asTntMan->getSurface()->getClipRect().y1 = 0;
- asTntMan->getSurface()->getClipRect().x2 = x2;
- asTntMan->getSurface()->getClipRect().y2 = 480;
+ asTntMan->setClipRect(x1, 0, x2, 480);
_vm->_collisionMan->addSprite(asTntMan);
_asTntMan = addSprite(asTntMan);
tempSprite = addSprite(new Class465(_vm, _asTntMan));
- tempSprite->getSurface()->getClipRect().x1 = x1;
- tempSprite->getSurface()->getClipRect().y1 = 0;
- tempSprite->getSurface()->getClipRect().x2 = x2;
- tempSprite->getSurface()->getClipRect().y2 = 480;
+ tempSprite->setClipRect(x1, 0, x2, 480);
asTntMan->setRepl(64, 0);
}
@@ -926,10 +910,7 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
tempSprite = insertStaticSprite(0x63D400BC, 900);
_asLeftDoor = addSprite(new AsScene1201LeftDoor(_vm, _klayman));
- _asLeftDoor->getSurface()->getClipRect().x1 = x1;
- _asLeftDoor->getSurface()->getClipRect().y1 = tempSprite->getSurface()->getDrawRect().y;
- _asLeftDoor->getSurface()->getClipRect().x2 = tempSprite->getSurface()->getDrawRect().x + tempSprite->getSurface()->getDrawRect().width;
- _asLeftDoor->getSurface()->getClipRect().y2 = 480;
+ _asLeftDoor->setClipRect(x1, tempSprite->getDrawRect().y, tempSprite->getDrawRect().x2(), 480);
if (getGlobalVar(0x0A310817) && ! getGlobalVar(0x0112090A)) {
setGlobalVar(0x0112090A, 1);
@@ -944,10 +925,7 @@ Scene1201::Scene1201(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x0A310817) && !getGlobalVar(0x0A18CA33)) {
_asCreature = addSprite(new AsScene1201Creature(_vm, this, _klayman));
- _asCreature->getSurface()->getClipRect().x1 = x1;
- _asCreature->getSurface()->getClipRect().y1 = 0;
- _asCreature->getSurface()->getClipRect().x2 = x2;
- _asCreature->getSurface()->getClipRect().y2 = 480;
+ _asCreature->setClipRect(x1, 0, x2, 480);
}
}
diff --git a/engines/neverhood/module1300.cpp b/engines/neverhood/module1300.cpp
index 8f3483ad20..48a8b54e66 100644
--- a/engines/neverhood/module1300.cpp
+++ b/engines/neverhood/module1300.cpp
@@ -430,18 +430,15 @@ Scene1302::Scene1302(NeverhoodEngine *vm, Module *parentModule, int which)
_sprite2->setVisible(false);
_sprite3 = insertStaticSprite(0x16E01E20, 1100);
- _asRing1 = addSprite(new AsScene1002Ring(_vm, this, false, 218, 122, _class595->getSurface()->getDrawRect().y, false));
- _asRing2 = addSprite(new AsScene1002Ring(_vm, this, true, 218 + 32, 132, _class595->getSurface()->getDrawRect().y, getGlobalVar(0x13206309)));
- _asRing3 = addSprite(new AsScene1002Ring(_vm, this, false, 218 + 32 + 32, 122, _class595->getSurface()->getDrawRect().y, false));
- _asRing4 = addSprite(new AsScene1002Ring(_vm, this, true, 218 + 32 + 32 + 32, 132, _class595->getSurface()->getDrawRect().y, getGlobalVar(0x80101B1E)));
- _asRing5 = addSprite(new AsScene1002Ring(_vm, this, false, 218 + 32 + 32 + 32 + 32, 115, _class595->getSurface()->getDrawRect().y, false));
+ _asRing1 = addSprite(new AsScene1002Ring(_vm, this, false, 218, 122, _class595->getDrawRect().y, false));
+ _asRing2 = addSprite(new AsScene1002Ring(_vm, this, true, 218 + 32, 132, _class595->getDrawRect().y, getGlobalVar(0x13206309)));
+ _asRing3 = addSprite(new AsScene1002Ring(_vm, this, false, 218 + 32 + 32, 122, _class595->getDrawRect().y, false));
+ _asRing4 = addSprite(new AsScene1002Ring(_vm, this, true, 218 + 32 + 32 + 32, 132, _class595->getDrawRect().y, getGlobalVar(0x80101B1E)));
+ _asRing5 = addSprite(new AsScene1002Ring(_vm, this, false, 218 + 32 + 32 + 32 + 32, 115, _class595->getDrawRect().y, false));
_asBridge = addSprite(new AsScene1302Bridge(_vm, this));
_ssFence = addSprite(new SsScene1302Fence(_vm));
- _ssFence->getSurface()->getClipRect().x1 = 0;
- _ssFence->getSurface()->getClipRect().y1 = 0;
- _ssFence->getSurface()->getClipRect().x2 = 640;
- _ssFence->getSurface()->getClipRect().y2 = _sprite1->getSurface()->getDrawRect().y + _sprite1->getSurface()->getDrawRect().height;
+ _ssFence->setClipRect(0, 0, 640, _sprite1->getDrawRect().y2());
if (which < 0) {
InsertKlaymanInitArgs(KmScene1002, 380, 364, (_class595, NULL));
@@ -451,10 +448,7 @@ Scene1302::Scene1302(NeverhoodEngine *vm, Module *parentModule, int which)
setMessageList(0x004B0870);
}
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite3->getSurface()->getDrawRect().x + _sprite3->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, _sprite3->getDrawRect().x2(), 480);
_asVenusFlyTrap = addSprite(new AsScene1002VenusFlyTrap(_vm, this, _klayman, true));
_vm->_collisionMan->addSprite(_asVenusFlyTrap);
@@ -658,10 +652,7 @@ Scene1303::Scene1303(NeverhoodEngine *vm, Module *parentModule, int which)
InsertKlayman(KmScene1303, 207, 332);
setMessageList(0x004AF9A0);
- _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480);
}
@@ -746,10 +737,7 @@ Scene1304::Scene1304(NeverhoodEngine *vm, Module *parentModule, int which)
setMessageList(0x004B90F0);
}
- _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480);
}
@@ -1236,7 +1224,7 @@ void AsScene1307Key::stRemoveKey() {
void AsScene1307Key::stInsertKey() {
_pointIndex = 0;
sendMessage(_parentScene, 0x1022, kAsScene1307KeySurfacePriorities[getSubVar(0xA010B810, _index) % 4]);
- _surface->getClipRect() = _clipRects[getSubVar(0xA010B810, _index) % 4];
+ setClipRect(_clipRects[getSubVar(0xA010B810, _index) % 4]);
SetSpriteCallback(&AsScene1307Key::suInsertKey);
_newHashListIndex = -2;
}
@@ -1246,10 +1234,7 @@ void AsScene1307Key::stMoveKey() {
int16 newX = pt.x + kAsScene1307KeyXDelta;
int16 newY = pt.y + kAsScene1307KeyYDelta;
sendMessage(_parentScene, 0x1022, 1000);
- _surface->getClipRect().x1 = 0;
- _surface->getClipRect().y1 = 0;
- _surface->getClipRect().x2 = 640;
- _surface->getClipRect().y2 = 480;
+ setClipRect(0, 0, 640, 480);
_prevX = _x;
_prevY = _y;
if (newX == _x && newY == _y) {
@@ -1311,28 +1296,16 @@ Scene1307::Scene1307(NeverhoodEngine *vm, Module *parentModule, int which)
insertMouse435(0x06204A88, 20, 620);
tempSprite = insertStaticSprite(0x00A3621C, 800);
- _clipRects[0].x1 = tempSprite->getSurface()->getDrawRect().x;
- _clipRects[0].y1 = 0;
- _clipRects[0].x2 = 640;
- _clipRects[0].y2 = 480;
+ _clipRects[0].set(tempSprite->getDrawRect().x, 0, 640, 480);
tempSprite = insertStaticSprite(0x00A3641C, 600);
- _clipRects[1].x1 = tempSprite->getSurface()->getDrawRect().x;
- _clipRects[1].y1 = 0;
- _clipRects[1].x2 = 640;
- _clipRects[1].y2 = 480;
+ _clipRects[1].set(tempSprite->getDrawRect().x, 0, 640, 480);
tempSprite = insertStaticSprite(0x00A3681C, 400);
- _clipRects[2].x1 = tempSprite->getSurface()->getDrawRect().x;
- _clipRects[2].y1 = 0;
- _clipRects[2].x2 = 640;
- _clipRects[2].y2 = 480;
+ _clipRects[2].set(tempSprite->getDrawRect().x, 0, 640, 480);
tempSprite = insertStaticSprite(0x00A3701C, 200);
- _clipRects[3].x1 = tempSprite->getSurface()->getDrawRect().x;
- _clipRects[3].y1 = 0;
- _clipRects[3].x2 = 640;
- _clipRects[3].y2 = 480;
+ _clipRects[3].set(tempSprite->getDrawRect().x, 0, 640, 480);
for (uint keyIndex = 0; keyIndex < 3; keyIndex++) {
if (getSubVar(0x08D0AB11, keyIndex)) {
@@ -1693,25 +1666,16 @@ Scene1308::Scene1308(NeverhoodEngine *vm, Module *parentModule, int which)
}
if (_sprite4) {
- _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite4->getSurface()->getDrawRect().x + _sprite4->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_sprite1->getDrawRect().x, 0, _sprite4->getDrawRect().x2(), 480);
} else {
- _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480);
}
if (getGlobalVar(0x04A105B3) == 4) {
_class489 = new Class489(_vm, this, _klayman, 0);
addSprite(_class489);
_vm->_collisionMan->addSprite(_class489);
- _class489->getSurface()->getClipRect().x1 = 0;
- _class489->getSurface()->getClipRect().y1 = 0;
- _class489->getSurface()->getClipRect().x2 = 0;
- _class489->getSurface()->getClipRect().y2 = _sprite2->getSurface()->getDrawRect().y + _sprite2->getSurface()->getDrawRect().height;
+ _class489->setClipRect(0, 0, 640, _sprite2->getDrawRect().y2());
_class489->setRepl(64, 0);
} else {
_class489 = NULL;
diff --git a/engines/neverhood/module1400.cpp b/engines/neverhood/module1400.cpp
index 3f61ceb52d..7bff2940c8 100644
--- a/engines/neverhood/module1400.cpp
+++ b/engines/neverhood/module1400.cpp
@@ -714,16 +714,10 @@ Scene1401::Scene1401(NeverhoodEngine *vm, Module *parentModule, int which)
_klayman->processDelta();
setMessageList(0x004B6670);
}
- _class489->getSurface()->getClipRect().x1 = _sprite3->getSurface()->getDrawRect().x;
- _class489->getSurface()->getClipRect().y1 = _sprite2->getSurface()->getDrawRect().y;
- _class489->getSurface()->getClipRect().x2 = 640;
- _class489->getSurface()->getClipRect().y2 = 480;
+ _class489->setClipRect(_sprite3->getDrawRect().x, _sprite2->getDrawRect().y, 640, 480);
}
- _klayman->getSurface()->getClipRect().x1 = _sprite3->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_sprite3->getDrawRect().x, 0, 640, 480);
if (which == 0 && _class489 && _class489->hasMessageHandler()) {
sendMessage(_class489, 0x482B, 0);
@@ -881,8 +875,8 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which)
SetMessageHandler(&Scene1402::handleMessage);
- _background = addBackground(new Background(_vm, 0x231482F0, 0, 0));
- _background->getSurface()->getDrawRect().y = -10;
+ setBackground(0x231482F0);
+ setBackgroundY(-10);
// TODO g_screen->field_26 = 0;
setPalette(0x231482F0);
_palette->addPalette(0x91D3A391, 0, 64, 0);
@@ -928,10 +922,7 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which)
}
if (_class482) {
- _class482->getSurface()->getClipRect().x1 = 0;
- _class482->getSurface()->getClipRect().y1 = 0;
- _class482->getSurface()->getClipRect().x2 = 640;
- _class482->getSurface()->getClipRect().y2 = _class454_3->getSurface()->getDrawRect().y + _class454_3->getSurface()->getDrawRect().height;
+ _class482->setClipRect(0, 0, 640, _class454_3->getDrawRect().y2());
}
if (getGlobalVar(0x4A105B3) == 1) {
@@ -948,39 +939,27 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which)
_klayman->processDelta();
setMessageList(0x004B0BD0);
}
- _class489->getSurface()->getClipRect().x1 = _class454_1->getSurface()->getDrawRect().x;
- _class489->getSurface()->getClipRect().y1 = 0;
- _class489->getSurface()->getClipRect().x2 = _class454_2->getSurface()->getDrawRect().x;
- _class489->getSurface()->getClipRect().y2 = _class454_3->getSurface()->getDrawRect().y + _class454_3->getSurface()->getDrawRect().height;
+ _class489->setClipRect(_class454_1->getDrawRect().x, 0, _class454_2->getDrawRect().x, _class454_3->getDrawRect().y2());
}
- _klayman->getSurface()->getClipRect().x1 = _class454_1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _class454_2->getSurface()->getDrawRect().x + _class454_2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _class454_3->getSurface()->getDrawRect().y + _class454_3->getSurface()->getDrawRect().height;
+ _klayman->setClipRect(_class454_1->getDrawRect().x, 0, _class454_2->getDrawRect().x2(), _class454_3->getDrawRect().y2());
}
void Scene1402::update() {
if (_flag) {
- _background->getSurface()->getDrawRect().y = _vm->_rnd->getRandomNumber(10 - 1) - 10;
- // TODO g_screen->field_26 = -10 - _background->getSurface()->getDrawRect().y;
+ setBackgroundY(_vm->_rnd->getRandomNumber(10 - 1) - 10);
+ // TODO g_screen->field_26 = -10 - _background->getDrawRect().y;
} else {
- _background->getSurface()->getDrawRect().y = -10;
+ setBackgroundY(-10);
// TODO g_screen->field_26 = 0;
SetUpdateHandler(&Scene::update);
}
Scene::update();
if (_class482) {
- _class482->getSurface()->getClipRect().x1 = 0;
- _class482->getSurface()->getClipRect().y1 = 0;
- _class482->getSurface()->getClipRect().x2 = 640;
- _class482->getSurface()->getClipRect().y2 = _class454_3->getSurface()->getDrawRect().y + _class454_3->getSurface()->getDrawRect().height;
+ _class482->setClipRect(0, 0, 640, _class454_3->getDrawRect().y2());
}
- _klayman->getSurface()->getClipRect().x1 = _class454_1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _class454_2->getSurface()->getDrawRect().x + _class454_2->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _class454_3->getSurface()->getDrawRect().y + _class454_3->getSurface()->getDrawRect().height;
+ _klayman->setClipRect(_class454_1->getDrawRect().x, 0, _class454_2->getDrawRect().x2(), _class454_3->getDrawRect().y2());
}
uint32 Scene1402::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
@@ -1392,10 +1371,7 @@ Scene1403::Scene1403(NeverhoodEngine *vm, Module *parentModule, int which)
_klayman->processDelta();
setMessageList(0x004B1F70);
}
- _class489->getSurface()->getClipRect().x1 = 0;
- _class489->getSurface()->getClipRect().y1 = 0;
- _class489->getSurface()->getClipRect().x2 = 640;
- _class489->getSurface()->getClipRect().y2 = _class401_2->getSurface()->getDrawRect().y + _class401_2->getSurface()->getDrawRect().height;
+ _class489->setClipRect(0, 0, 640, _class401_2->getDrawRect().y2());
class489->setRepl(64, 0);
}
@@ -1515,16 +1491,10 @@ Scene1404::Scene1404(NeverhoodEngine *vm, Module *parentModule, int which)
_klayman->processDelta();
setMessageList(0x004B8CB8);
}
- _class489->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
- _class489->getSurface()->getClipRect().y1 = 0;
- _class489->getSurface()->getClipRect().x2 = 640;
- _class489->getSurface()->getClipRect().y2 = 480;
+ _class489->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480);
}
- _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480);
}
diff --git a/engines/neverhood/module1700.cpp b/engines/neverhood/module1700.cpp
index f551911b3a..30e4631f23 100644
--- a/engines/neverhood/module1700.cpp
+++ b/engines/neverhood/module1700.cpp
@@ -210,47 +210,32 @@ Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which)
InsertKlayman(KmScene1705, 231, 434);
setMessageList(0x004B69E8);
sendMessage(this, 0x2000, 0);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, _sprite->getDrawRect().x2(), 480);
} else if (which == 1) {
InsertKlayman(KmScene1705, 431, 434);
sendMessage(_klayman, 0x2000, 1);
setMessageList(0x004B6A08);
sendMessage(this, 0x2000, 1);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, _sprite->getDrawRect().x2(), 480);
} else if (which == 2) {
InsertKlayman(KmScene1705, 431, 434);
sendMessage(_klayman, 0x2000, 1);
setMessageList(0x004B6AA0);
sendMessage(this, 0x2000, 1);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, _sprite->getDrawRect().x2(), 480);
} else if (which == 3) {
InsertKlayman(KmScene1705, 431, 434);
sendMessage(_klayman, 0x2000, 1);
setMessageList(0x004B6A18);
sendMessage(this, 0x2000, 1);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, _sprite->getDrawRect().x2(), 480);
} else {
InsertKlayman(KmScene1705, 231, 74);
sendMessage(_klayman, 0x2000, 0);
setMessageList(0x004B69F0);
sendMessage(this, 0x2000, 0);
tempSprite = insertStaticSprite(0x30303822, 1100);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = tempSprite->getSurface()->getDrawRect().y;
- _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, tempSprite->getDrawRect().y, _sprite->getDrawRect().x2(), 480);
}
}
diff --git a/engines/neverhood/module2000.cpp b/engines/neverhood/module2000.cpp
index b2e9a0ef5a..3977598726 100644
--- a/engines/neverhood/module2000.cpp
+++ b/engines/neverhood/module2000.cpp
@@ -133,10 +133,7 @@ Scene2001::Scene2001(NeverhoodEngine *vm, Module *parentModule, int which)
_klayman->setDoDeltaX(1);
}
- _klayman->getSurface()->getClipRect().x1 = _class401->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_class401->getDrawRect().x, 0, 640, 480);
}
diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp
index a0db78829e..124ace634c 100644
--- a/engines/neverhood/module2200.cpp
+++ b/engines/neverhood/module2200.cpp
@@ -760,16 +760,16 @@ Scene2201::Scene2201(NeverhoodEngine *vm, Module *parentModule, int which)
}
tempSprite = insertStaticSprite(0x030326A0, 1100);
- _rect1.x1 = tempSprite->getSurface()->getDrawRect().x;
+ _rect1.x1 = tempSprite->getDrawRect().x;
insertStaticSprite(0x811DA061, 1100);
tempSprite = insertStaticSprite(0x11180022, 1100);
- _rect2.x1 = tempSprite->getSurface()->getDrawRect().x;
+ _rect2.x1 = tempSprite->getDrawRect().x;
tempSprite = insertStaticSprite(0x0D411130, 1100);
- _rect1.y2 = tempSprite->getSurface()->getDrawRect().y + tempSprite->getSurface()->getDrawRect().height;
- _rect2.y1 = tempSprite->getSurface()->getDrawRect().y + tempSprite->getSurface()->getDrawRect().height;
+ _rect1.y2 = tempSprite->getDrawRect().y2();
+ _rect2.y1 = tempSprite->getDrawRect().y2();
_doorLightSprite = insertStaticSprite(0xA4062212, 900);
@@ -1366,15 +1366,8 @@ Scene2203::Scene2203(NeverhoodEngine *vm, Module *parentModule, int which)
_ssSmallLeftDoor = insertStaticSprite(0x542CC072, 1100);
_ssSmallRightDoor = insertStaticSprite(0x0A2C0432, 1100);
- _leftDoorClipRect.x1 = _ssSmallLeftDoor->getSurface()->getDrawRect().x;
- _leftDoorClipRect.y1 = 0;
- _leftDoorClipRect.x2 = 640;
- _leftDoorClipRect.y2 = 480;
-
- _rightDoorClipRect.x1 = 0;
- _rightDoorClipRect.y1 = 0;
- _rightDoorClipRect.x2 = _ssSmallRightDoor->getSurface()->getDrawRect().x + _ssSmallRightDoor->getSurface()->getDrawRect().width;
- _rightDoorClipRect.y2 = 480;
+ _leftDoorClipRect.set(_ssSmallLeftDoor->getDrawRect().x, 0, 640, 480);
+ _rightDoorClipRect.set(0, 0, _ssSmallRightDoor->getDrawRect().x2(), 480);
sendEntityMessage(_asLeftDoor, 0x2000, _asRightDoor);
sendEntityMessage(_asRightDoor, 0x2000, _asLeftDoor);
@@ -1403,10 +1396,10 @@ Scene2203::Scene2203(NeverhoodEngine *vm, Module *parentModule, int which)
if (getGlobalVar(0x9A500914)) {
_ssSmallLeftDoor->setVisible(false);
- _klayman->getSurface()->getClipRect() = _rightDoorClipRect;
+ _klayman->setClipRect(_rightDoorClipRect);
} else {
_ssSmallRightDoor->setVisible(false);
- _klayman->getSurface()->getClipRect() = _leftDoorClipRect;
+ _klayman->setClipRect(_leftDoorClipRect);
}
setRectList(0x004B8420);
@@ -1445,10 +1438,10 @@ uint32 Scene2203::handleMessage(int messageNum, const MessageParam &param, Entit
case 0x4808:
if (sender == _asLeftDoor) {
_ssSmallLeftDoor->setVisible(true);
- _klayman->getSurface()->getClipRect() = _leftDoorClipRect;
+ _klayman->setClipRect(_leftDoorClipRect);
} else {
_ssSmallRightDoor->setVisible(true);
- _klayman->getSurface()->getClipRect() = _rightDoorClipRect;
+ _klayman->setClipRect(_rightDoorClipRect);
}
break;
case 0x4826:
@@ -1548,10 +1541,7 @@ Scene2205::Scene2205(NeverhoodEngine *vm, Module *parentModule, int which)
_isKlaymanInLight = true;
}
- _klayman->getSurface()->getClipRect().x1 = _ssDoorFrame->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(_ssDoorFrame->getDrawRect().x, 0, 640, 480);
loadDataResource(0x00144822);
_klayman->setSoundFlag(true);
@@ -1563,14 +1553,14 @@ void Scene2205::update() {
if (!_isLightOn && getGlobalVar(0x4D080E54)) {
_palette->addPalette(0x0008028D, 0, 256, 0);
- _background->load(0x0008028D);
+ changeBackground(0x0008028D);
_ssLightSwitch->setFileHashes(0x2D339030, 0x2D309030);
sendMessage(_ssDoorFrame, 0x2000, 0);
changeMouseCursor(0x80289008);
_isLightOn = true;
} else if (_isLightOn && !getGlobalVar(0x4D080E54)) {
_palette->addPalette(0xD00A028D, 0, 256, 0);
- _background->load(0xD00A028D);
+ changeBackground(0xD00A028D);
_ssLightSwitch->setFileHashes(0x2D339030, 0xDAC86E84);
sendMessage(_ssDoorFrame, 0x2000, 0);
changeMouseCursor(0xA0289D08);
@@ -1769,10 +1759,7 @@ Scene2206::Scene2206(NeverhoodEngine *vm, Module *parentModule, int which)
_sprite2 = insertStaticSprite(0x3406A333, 300);
_sprite3 = insertStaticSprite(0x24A223A2, 100);
_sprite4 = addSprite(new Class603(_vm, 0x26133023));
- _sprite4->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
- _sprite4->getSurface()->getClipRect().y1 = 0;
- _sprite4->getSurface()->getClipRect().x2 = 640;
- _sprite4->getSurface()->getClipRect().y2 = 480;
+ _sprite4->setClipRect(_sprite2->getDrawRect().x, 0, 640, 480);
setRectList(0x004B8AF8);
_sprite5 = addSprite(new SsCommonButtonSprite(_vm, this, 0x0E038022, 100, 0));
insertMouse433(0x83212411);
@@ -1784,10 +1771,7 @@ Scene2206::Scene2206(NeverhoodEngine *vm, Module *parentModule, int which)
_sprite2 = insertStaticSprite(0x020462E0, 300);
_sprite3 = insertStaticSprite(0x900626A2, 100);
_sprite4 = addSprite(new Class603(_vm, 0x544822A8));
- _sprite4->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
- _sprite4->getSurface()->getClipRect().y1 = 0;
- _sprite4->getSurface()->getClipRect().x2 = 640;
- _sprite4->getSurface()->getClipRect().y2 = 480;
+ _sprite4->setClipRect(_sprite2->getDrawRect().x, 0, 640, 480);
setRectList(0x004B8B58);
_sprite5 = addSprite(new SsCommonButtonSprite(_vm, this, 0x16882608, 100, 0));
insertMouse433(0x02A41E09);
@@ -1795,10 +1779,7 @@ Scene2206::Scene2206(NeverhoodEngine *vm, Module *parentModule, int which)
_class604 = addSprite(new Class604(_vm, 0x317831A0));
}
- _class604->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
- _class604->getSurface()->getClipRect().y1 = 0;
- _class604->getSurface()->getClipRect().x2 = _sprite3->getSurface()->getDrawRect().x + _sprite3->getSurface()->getDrawRect().width;
- _class604->getSurface()->getClipRect().y2 = _sprite1->getSurface()->getDrawRect().y + _sprite1->getSurface()->getDrawRect().height;
+ _class604->setClipRect(_sprite2->getDrawRect().x, 0, _sprite3->getDrawRect().x2(), _sprite1->getDrawRect().y2());
setBackground(fileHash);
@@ -1894,10 +1875,7 @@ void Scene2206::sub481950() {
setSurfacePriority(_sprite2->getSurface(), 300);
setSurfacePriority(_sprite3->getSurface(), 100);
setSurfacePriority(_sprite4->getSurface(), 200);
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, 0, 640, 480);
}
void Scene2206::sub4819D0() {
@@ -1909,10 +1887,7 @@ void Scene2206::sub4819D0() {
setSurfacePriority(_sprite2->getSurface(), 1300);
setSurfacePriority(_sprite3->getSurface(), 1100);
setSurfacePriority(_sprite4->getSurface(), 1200);
- _klayman->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
- _klayman->getSurface()->getClipRect().y1 = 0;
- _klayman->getSurface()->getClipRect().x2 = _sprite3->getSurface()->getDrawRect().x + _sprite3->getSurface()->getDrawRect().width;
- _klayman->getSurface()->getClipRect().y2 = _sprite1->getSurface()->getDrawRect().y + _sprite1->getSurface()->getDrawRect().height;
+ _klayman->setClipRect(_sprite2->getDrawRect().x, 0, _sprite3->getDrawRect().x2(), _sprite1->getDrawRect().y2());
}
void Scene2206::sub481B00() {
@@ -2307,20 +2282,9 @@ Scene2207::Scene2207(NeverhoodEngine *vm, Module *parentModule, int which)
_ssButton = addSprite(new SsCommonButtonSprite(_vm, this, 0x2C4061C4, 100, 0));
- _asLever->getSurface()->getClipRect().x1 = 0;
- _asLever->getSurface()->getClipRect().y1 = 0;
- _asLever->getSurface()->getClipRect().x2 = _ssMaskPart3->getSurface()->getDrawRect().x + _ssMaskPart3->getSurface()->getDrawRect().width;
- _asLever->getSurface()->getClipRect().y2 = 480;
-
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = _ssMaskPart1->getSurface()->getDrawRect().y;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = _ssMaskPart2->getSurface()->getDrawRect().y + _ssMaskPart2->getSurface()->getDrawRect().height;
-
- _asElevator->getSurface()->getClipRect().x1 = 0;
- _asElevator->getSurface()->getClipRect().y1 = _ssMaskPart1->getSurface()->getDrawRect().y;
- _asElevator->getSurface()->getClipRect().x2 = 640;
- _asElevator->getSurface()->getClipRect().y2 = _ssMaskPart2->getSurface()->getDrawRect().y + _ssMaskPart2->getSurface()->getDrawRect().height;
+ _asLever->setClipRect(0, 0, _ssMaskPart3->getDrawRect().x2(), 480);
+ _klayman->setClipRect(0, _ssMaskPart1->getDrawRect().y, 640, _ssMaskPart2->getDrawRect().y2());
+ _asElevator->setClipRect(0, _ssMaskPart1->getDrawRect().y, 640, _ssMaskPart2->getDrawRect().y2());
} else {
@@ -2342,15 +2306,8 @@ Scene2207::Scene2207(NeverhoodEngine *vm, Module *parentModule, int which)
_asWallCannonAnimation = NULL;
_ssButton = NULL;
- _klayman->getSurface()->getClipRect().x1 = 0;
- _klayman->getSurface()->getClipRect().y1 = _ssMaskPart1->getSurface()->getDrawRect().y;
- _klayman->getSurface()->getClipRect().x2 = 640;
- _klayman->getSurface()->getClipRect().y2 = 480;
-
- _asElevator->getSurface()->getClipRect().x1 = 0;
- _asElevator->getSurface()->getClipRect().y1 = _ssMaskPart1->getSurface()->getDrawRect().y;
- _asElevator->getSurface()->getClipRect().x2 = 640;
- _asElevator->getSurface()->getClipRect().y2 = 480;
+ _klayman->setClipRect(0, _ssMaskPart1->getDrawRect().y, 640, 480);
+ _asElevator->setClipRect(0, _ssMaskPart1->getDrawRect().y, 640, 480);
}
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index bcae32457e..fd11509cad 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -40,6 +40,9 @@ namespace Neverhood {
#define InsertKlayman(KlaymanClass, X, Y) _klayman = new KlaymanClass(_vm, this, X, Y); addSprite(_klayman)
#define InsertKlaymanInitArgs(KlaymanClass, X, Y, InitArgs) _klayman = new KlaymanClass(_vm, this, X, Y); ((KlaymanClass*)_klayman)->init InitArgs; addSprite(_klayman)
+#define InsertSprite(SpriteClass) (SpriteClass*)addSprite(new SpriteClass(_vm));
+#define InsertSpriteInitArgs(SpriteClass, InitArgs) (SpriteClass*)addSprite((new SpriteClass(_vm))-> init InitArgs);
+
class Scene : public Entity {
public:
Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects);
@@ -55,6 +58,8 @@ public:
Background *addBackground(Background *background);
void setBackground(uint32 fileHash, bool dirtyBackground = true);
void changeBackground(uint32 fileHash);
+ void setBackgroundY(int16 y) { _background->getSurface()->getDrawRect().y = y; }
+ int16 getBackgroundY() { return _background->getSurface()->getDrawRect().y; }
void setPalette(uint32 fileHash = 0);
Sprite *insertStaticSprite(uint32 fileHash, int surfacePriority);
void insertMouse433(uint32 fileHash, NRect *mouseRect = NULL);
diff --git a/engines/neverhood/sprite.cpp b/engines/neverhood/sprite.cpp
index 9dc1d8bc7e..480e9e9299 100644
--- a/engines/neverhood/sprite.cpp
+++ b/engines/neverhood/sprite.cpp
@@ -98,6 +98,22 @@ int16 Sprite::defFilterY(int16 y) {
return y;
}
+void Sprite::setClipRect(int16 x1, int16 y1, int16 x2, int16 y2) {
+ NRect &clipRect = _surface->getClipRect();
+ clipRect.x1 = x1;
+ clipRect.y1 = y1;
+ clipRect.x2 = x2;
+ clipRect.y2 = y2;
+}
+
+void Sprite::setClipRect(NRect& clipRect) {
+ _surface->getClipRect() = clipRect;
+}
+
+void Sprite::setClipRect(NDrawRect& drawRect) {
+ setClipRect(drawRect.x, drawRect.y, drawRect.x2(), drawRect.y2());
+}
+
// StaticSprite
StaticSprite::StaticSprite(NeverhoodEngine *vm, int objectPriority)
diff --git a/engines/neverhood/sprite.h b/engines/neverhood/sprite.h
index 1c4008e911..59109d6900 100644
--- a/engines/neverhood/sprite.h
+++ b/engines/neverhood/sprite.h
@@ -58,6 +58,12 @@ public:
void loadDataResource(uint32 fileHash);
int16 defFilterY(int16 y);
void setVisible(bool value) { _surface->setVisible(value); }
+ NDrawRect& getDrawRect() { return _surface->getDrawRect(); }
+ // Some shortcuts to set the clipRect
+ NRect& getClipRect() { return _surface->getClipRect(); }
+ void setClipRect(int16 x1, int16 y1, int16 x2, int16 y2);
+ void setClipRect(NRect& clipRect);
+ void setClipRect(NDrawRect& drawRect);
protected:
void (Sprite::*_spriteUpdateCb)();
Common::String _spriteUpdateCbName; // For debugging purposes