aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232012-10-06 21:15:18 +0000
committerWillem Jan Palenstijn2013-05-08 20:43:48 +0200
commit15cfb9f787d577c130beb4d0fc486acd5f6af355 (patch)
treec13b72c47abc9ae91dff23bfe970c1e4d7bf9209 /engines
parent8a9ca493b63cbb81b968fc3db57a957e677846ba (diff)
downloadscummvm-rg350-15cfb9f787d577c130beb4d0fc486acd5f6af355.tar.gz
scummvm-rg350-15cfb9f787d577c130beb4d0fc486acd5f6af355.tar.bz2
scummvm-rg350-15cfb9f787d577c130beb4d0fc486acd5f6af355.zip
NEVERHOOD: Implement clipping against multiple clipRects, used only in several scenes for the Klayman sprite.
Currently only implemented in KmScene2201 for testing.
Diffstat (limited to 'engines')
-rw-r--r--engines/neverhood/gamemodule.cpp2
-rw-r--r--engines/neverhood/graphics.cpp7
-rw-r--r--engines/neverhood/graphics.h4
-rw-r--r--engines/neverhood/klayman.cpp5
-rw-r--r--engines/neverhood/module2200.cpp26
-rw-r--r--engines/neverhood/module2200.h3
-rw-r--r--engines/neverhood/screen.cpp6
-rw-r--r--engines/neverhood/screen.h1
8 files changed, 34 insertions, 20 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index d1321056f4..174edd305d 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -310,7 +310,7 @@ void GameModule::startup() {
#if 1
_vm->gameState().sceneNum = 0;
- createModule(2100, -1);
+ createModule(2200, -1);
#endif
#if 0
_vm->gameState().sceneNum = 0;
diff --git a/engines/neverhood/graphics.cpp b/engines/neverhood/graphics.cpp
index b1597f2d5e..84aa3d67da 100644
--- a/engines/neverhood/graphics.cpp
+++ b/engines/neverhood/graphics.cpp
@@ -27,7 +27,8 @@
namespace Neverhood {
BaseSurface::BaseSurface(NeverhoodEngine *vm, int priority, int16 width, int16 height)
- : _vm(vm), _priority(priority), _visible(true), _transparent(true) {
+ : _vm(vm), _priority(priority), _visible(true), _transparent(true),
+ _clipRects(NULL), _clipRectsCount(0) {
_drawRect.x = 0;
_drawRect.y = 0;
@@ -52,7 +53,9 @@ BaseSurface::~BaseSurface() {
void BaseSurface::draw() {
if (_surface && _visible && _drawRect.width > 0 && _drawRect.height > 0) {
- if (_sysRect.x == 0 && _sysRect.y == 0) {
+ if (_clipRects && _clipRectsCount) {
+ _vm->_screen->drawSurfaceClipRects(_surface, _drawRect, _clipRects, _clipRectsCount, _transparent);
+ } else if (_sysRect.x == 0 && _sysRect.y == 0) {
_vm->_screen->drawSurface2(_surface, _drawRect, _clipRect, _transparent);
} else {
_vm->_screen->drawUnk(_surface, _drawRect, _sysRect, _clipRect, _transparent);
diff --git a/engines/neverhood/graphics.h b/engines/neverhood/graphics.h
index 3b30b25338..57c22509f8 100644
--- a/engines/neverhood/graphics.h
+++ b/engines/neverhood/graphics.h
@@ -101,6 +101,8 @@ public:
NDrawRect& getSysRect() { return _sysRect; }
NRect& getClipRect() { return _clipRect; }
void setClipRect(NRect clipRect) { _clipRect = clipRect; }
+ void setClipRects(NRect *clipRects, uint clipRectsCount) { _clipRects = clipRects; _clipRectsCount = clipRectsCount; }
+ void clearClipRects() { _clipRects = NULL; _clipRectsCount = 0; }
bool getVisible() const { return _visible; }
void setVisible(bool value) { _visible = value; }
void setTransparent(bool value) { _transparent = value; }
@@ -113,6 +115,8 @@ protected:
NDrawRect _drawRect;
NDrawRect _sysRect;
NRect _clipRect;
+ NRect *_clipRects;
+ uint _clipRectsCount;
bool _transparent;
};
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp
index 93cc49e305..82c6114d5d 100644
--- a/engines/neverhood/klayman.cpp
+++ b/engines/neverhood/klayman.cpp
@@ -4636,9 +4636,10 @@ uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam &param) {
}
KmScene2201::KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, NRect *clipRects, int clipRectsCount)
- // TODO: NRect *rect1, int16 unk in Klayman ctor
: Klayman(vm, parentScene, x, y, 1000, 1000) {
+ _surface->setClipRects(clipRects, clipRectsCount);
+
_dataResource.load(0x04104242);
_flagF6 = false;
}
@@ -4831,7 +4832,7 @@ uint32 KmScene2205::xHandleMessage(int messageNum, const MessageParam &param) {
KmScene2206::KmScene2206(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y)
: Klayman(vm, parentScene, x, y, 1000, 1000) {
- _walkResumeFrameIncr = 1;
+ _walkResumeFrameIncr = 1;
_vm->_soundMan->addSound(0x80101800, 0xD3B02847);
}
diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp
index 4460314d5e..d7991c2bd7 100644
--- a/engines/neverhood/module2200.cpp
+++ b/engines/neverhood/module2200.cpp
@@ -526,49 +526,49 @@ Scene2201::Scene2201(NeverhoodEngine *vm, Module *parentModule, int which)
}
}
- _rect1.y1 = 0;
- _rect1.x2 = 640;
- _rect2.x2 = 640;
- _rect2.y2 = 480;
+ _clipRects[0].y1 = 0;
+ _clipRects[0].x2 = 640;
+ _clipRects[1].x2 = 640;
+ _clipRects[1].y2 = 480;
if (!getGlobalVar(0x404290D5)) {
insertStaticSprite(0x00026027, 900);
}
tempSprite = insertStaticSprite(0x030326A0, 1100);
- _rect1.x1 = tempSprite->getDrawRect().x;
+ _clipRects[0].x1 = tempSprite->getDrawRect().x;
insertStaticSprite(0x811DA061, 1100);
tempSprite = insertStaticSprite(0x11180022, 1100);
- _rect2.x1 = tempSprite->getDrawRect().x;
+ _clipRects[1].x1 = tempSprite->getDrawRect().x;
tempSprite = insertStaticSprite(0x0D411130, 1100);
- _rect1.y2 = tempSprite->getDrawRect().y2();
- _rect2.y1 = tempSprite->getDrawRect().y2();
+ _clipRects[0].y2 = tempSprite->getDrawRect().y2();
+ _clipRects[1].y1 = tempSprite->getDrawRect().y2();
_doorLightSprite = insertStaticSprite(0xA4062212, 900);
if (which < 0) {
- insertKlayman<KmScene2201>(300, 427, &_rect1, 2);
+ insertKlayman<KmScene2201>(300, 427, _clipRects, 2);
setMessageList(0x004B8118);
_asDoor = insertSprite<AsScene2201Door>(_klayman, _doorLightSprite, false);
} else if (which == 1) {
- insertKlayman<KmScene2201>(412, 393, &_rect1, 2);
+ insertKlayman<KmScene2201>(412, 393, _clipRects, 2);
setMessageList(0x004B8130);
_asDoor = insertSprite<AsScene2201Door>(_klayman, _doorLightSprite, false);
} else if (which == 2) {
if (getGlobalVar(0xC0418A02)) {
- insertKlayman<KmScene2201>(379, 427, &_rect1, 2);
+ insertKlayman<KmScene2201>(379, 427, _clipRects, 2);
_klayman->setDoDeltaX(1);
} else {
- insertKlayman<KmScene2201>(261, 427, &_rect1, 2);
+ insertKlayman<KmScene2201>(261, 427, _clipRects, 2);
}
setMessageList(0x004B8178);
_asDoor = insertSprite<AsScene2201Door>(_klayman, _doorLightSprite, false);
} else {
NPoint pt = _dataResource.getPoint(0x0304D8DC);
- insertKlayman<KmScene2201>(pt.x, pt.y, &_rect1, 2);
+ insertKlayman<KmScene2201>(pt.x, pt.y, _clipRects, 2);
setMessageList(0x004B8120);
_asDoor = insertSprite<AsScene2201Door>(_klayman, _doorLightSprite, true);
}
diff --git a/engines/neverhood/module2200.h b/engines/neverhood/module2200.h
index 53b94695d8..e869e4c89c 100644
--- a/engines/neverhood/module2200.h
+++ b/engines/neverhood/module2200.h
@@ -96,8 +96,7 @@ public:
Scene2201(NeverhoodEngine *vm, Module *parentModule, int which);
~Scene2201();
protected:
- NRect _rect1;
- NRect _rect2;
+ NRect _clipRects[2];
Sprite *_doorLightSprite;
Sprite *_asDoor;
Sprite *_ssDoorButton;
diff --git a/engines/neverhood/screen.cpp b/engines/neverhood/screen.cpp
index dfc5358c5b..372c705b3e 100644
--- a/engines/neverhood/screen.cpp
+++ b/engines/neverhood/screen.cpp
@@ -299,4 +299,10 @@ void Screen::drawUnk(const Graphics::Surface *surface, NDrawRect &drawRect, NDra
}
+void Screen::drawSurfaceClipRects(const Graphics::Surface *surface, NDrawRect &drawRect, NRect *clipRects, uint clipRectsCount, bool transparent) {
+ NDrawRect clipDrawRect(0, 0, drawRect.width, drawRect.height);
+ for (uint i = 0; i < clipRectsCount; i++)
+ drawSurface3(surface, drawRect.x, drawRect.y, clipDrawRect, clipRects[i], transparent);
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/screen.h b/engines/neverhood/screen.h
index 07be04cf32..fe5a2546c0 100644
--- a/engines/neverhood/screen.h
+++ b/engines/neverhood/screen.h
@@ -50,6 +50,7 @@ public:
const Graphics::Surface *shadowSurface = NULL);
void drawDoubleSurface2(const Graphics::Surface *surface, NDrawRect &drawRect);
void drawUnk(const Graphics::Surface *surface, NDrawRect &drawRect, NDrawRect &sysRect, NRect &clipRect, bool transparent);
+ void drawSurfaceClipRects(const Graphics::Surface *surface, NDrawRect &drawRect, NRect *clipRects, uint clipRectsCount, bool transparent);
protected:
NeverhoodEngine *_vm;
Graphics::Surface *_backScreen;