aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2013-11-05 08:19:02 -0500
committerPaul Gilbert2013-11-05 08:19:02 -0500
commit974348c77130867151a7443aad53ec18ba82fd00 (patch)
tree99422c49c1930887ed2b155caab3abda65f00fa5
parentc0f9455b281d62e8089c47ddbed04135c6ed5f20 (diff)
downloadscummvm-rg350-974348c77130867151a7443aad53ec18ba82fd00.tar.gz
scummvm-rg350-974348c77130867151a7443aad53ec18ba82fd00.tar.bz2
scummvm-rg350-974348c77130867151a7443aad53ec18ba82fd00.zip
TSAGE: Implemented R2R shadowing effect
-rw-r--r--engines/tsage/core.cpp19
-rw-r--r--engines/tsage/core.h2
-rw-r--r--engines/tsage/graphics.cpp17
-rw-r--r--engines/tsage/graphics.h3
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp20
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.cpp36
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.h2
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes3.cpp34
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes3.h4
9 files changed, 72 insertions, 65 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp
index 553c3216e6..fd36d4fb01 100644
--- a/engines/tsage/core.cpp
+++ b/engines/tsage/core.cpp
@@ -2735,9 +2735,24 @@ void SceneObject::draw() {
Rect destRect = _bounds;
destRect.translate(-g_globals->_sceneManager._scene->_sceneBounds.left,
-g_globals->_sceneManager._scene->_sceneBounds.top);
- Region *priorityRegion = g_globals->_sceneManager._scene->_priorities.find(_priority);
GfxSurface frame = getFrame();
- g_globals->gfxManager().copyFrom(frame, destRect, priorityRegion);
+ Region *priorityRegion = g_globals->_sceneManager._scene->_priorities.find(_priority);
+
+ if (g_vm->getGameID() == GType_Ringworld2) {
+ switch (_effect) {
+ case EFFECT_SHADOW_MAP: {
+ assert(_shadowMap);
+
+ GLOBALS.gfxManager().getSurface().copyFrom(frame, frame.getBounds(),
+ destRect, priorityRegion, _shadowMap);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+
+ GLOBALS.gfxManager().copyFrom(frame, destRect, priorityRegion);
}
/**
diff --git a/engines/tsage/core.h b/engines/tsage/core.h
index 59711513d6..79ce1e8a90 100644
--- a/engines/tsage/core.h
+++ b/engines/tsage/core.h
@@ -467,7 +467,7 @@ enum AnimateMode {ANIM_MODE_NONE = 0, ANIM_MODE_1 = 1, ANIM_MODE_2 = 2, ANIM_MOD
};
enum Effect { EFFECT_NONE = 0, EFFECT_SHADED = 1, EFFECT_2 = 2, EFFECT_3 = 3,
- EFFECT_4 = 4, EFFECT_SHADOW = 5, EFFECT_6 = 6 };
+ EFFECT_4 = 4, EFFECT_SHADOW_MAP = 5, EFFECT_6 = 6 };
class SceneObject;
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index 32810626e7..f00dcf0378 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -559,9 +559,11 @@ static GfxSurface ResizeSurface(GfxSurface &src, int xSize, int ySize, int trans
}
/**
- * Copys an area from one GfxSurface to another
+ * Copys an area from one GfxSurface to another.
+ *
*/
-void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Region *priorityRegion) {
+void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds,
+ Region *priorityRegion, const byte *shadowMap) {
GfxSurface srcImage;
if (srcBounds.isEmpty())
return;
@@ -631,8 +633,15 @@ void GfxSurface::copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Regi
if (!priorityRegion || !priorityRegion->contains(Common::Point(
xp + g_globals->_sceneManager._scene->_sceneBounds.left,
destBounds.top + y + g_globals->_sceneManager._scene->_sceneBounds.top))) {
- if (*tempSrc != src._transColor)
- *tempDest = *tempSrc;
+ if (*tempSrc != src._transColor) {
+ if (shadowMap) {
+ // Using a shadow map, so translate the dest pixel using the mapping array
+ *tempDest = shadowMap[*tempDest];
+ } else {
+ // Otherwise, it's a standard pixel copy
+ *tempDest = *tempSrc;
+ }
+ }
}
++tempSrc;
++tempDest;
diff --git a/engines/tsage/graphics.h b/engines/tsage/graphics.h
index 497cd76ad6..d31bac0738 100644
--- a/engines/tsage/graphics.h
+++ b/engines/tsage/graphics.h
@@ -105,7 +105,8 @@ public:
void setBounds(const Rect &bounds) { _bounds = bounds; }
const Rect &getBounds() const { return _bounds; }
- void copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, Region *priorityRegion = NULL);
+ void copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds,
+ Region *priorityRegion = NULL, const byte *shadowMap = NULL);
void copyFrom(GfxSurface &src, Rect destBounds, Region *priorityRegion = NULL) {
copyFrom(src, src.getBounds(), destBounds, priorityRegion);
}
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 5cda153e59..b495a7e052 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -1326,26 +1326,6 @@ bool SceneActor::startAction(CursorType action, Event &event) {
GfxSurface SceneActor::getFrame() {
GfxSurface frame = SceneObject::getFrame();
- // TODO: Proper effects handling
- switch (_effect) {
- case EFFECT_NONE:
- case EFFECT_SHADOW:
- // TODO: Figure out purpose of setting image flags to 64, and getting
- // scene priorities -1 or _shade
- break;
- case EFFECT_SHADED:
- // TODO: Transposing using R2_GLOBALS._pixelArrayMap
- break;
- case EFFECT_2:
- // No effect
- break;
- case EFFECT_4:
- break;
- default:
- // TODO: Default effect
- break;
- }
-
return frame;
}
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index 1247000cd2..1b75ed4fdd 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -868,7 +868,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {
_palette1.loadPalette(1101);
R2_GLOBALS._player.postInit();
R2_GLOBALS._player.disableControl();
- R2_GLOBALS._player._effect = EFFECT_SHADOW;
+ R2_GLOBALS._player._effect = EFFECT_SHADOW_MAP;
R2_GLOBALS._player._shadowMap = _shadowPaletteMap;
R2_GLOBALS._player.setup(1102, 3, 2);
R2_GLOBALS._player.setObjectWrapper(NULL);
@@ -894,7 +894,7 @@ void Scene1100::postInit(SceneObjectList *OwnerList) {
_shipFormationShadow.setup(1102, 6, 2);
_shipFormationShadow._moveRate = 30;
_shipFormationShadow._moveDiff.x = 2;
- _shipFormationShadow._effect = EFFECT_SHADOW;
+ _shipFormationShadow._effect = EFFECT_SHADOW_MAP;
_shipFormationShadow._shadowMap = _shadowPaletteMap;
R2_GLOBALS._sound1.play(86);
@@ -1084,8 +1084,7 @@ void Scene1100::signal() {
case 11: {
setAction(&_sequenceManager1, this, 1106, &_animation, &_laserShot, &_leftImpacts, NULL);
- // CHECKME: Shadow effect should be set next to shadowmap
- R2_GLOBALS._player._effect = EFFECT_SHADOW;
+ R2_GLOBALS._player._effect = EFFECT_SHADOW_MAP;
R2_GLOBALS._player.setup(1102, 3, 2);
R2_GLOBALS._player.setPosition(Common::Point(-50, 131));
R2_GLOBALS._sound2.play(84);
@@ -6909,7 +6908,7 @@ void Scene1500::postInit(SceneObjectList *OwnerList) {
_starshipShadow.postInit();
_starshipShadow.setup(1401, 1, 1);
- _starshipShadow._effect = EFFECT_SHADOW;
+ _starshipShadow._effect = EFFECT_SHADOW_MAP;
_starshipShadow.fixPriority(10);
_starshipShadow._shadowMap = _shadowPaletteMap;
@@ -6921,7 +6920,7 @@ void Scene1500::postInit(SceneObjectList *OwnerList) {
if (R2_GLOBALS._sceneManager._previousScene != 1010) {
_smallShipShadow.postInit();
_smallShipShadow.setup(1401, 2, 1);
- _smallShipShadow._effect = EFFECT_SHADOW;
+ _smallShipShadow._effect = EFFECT_SHADOW_MAP;
_smallShipShadow.fixPriority(10);
_smallShipShadow._shadowMap = _shadowPaletteMap;
@@ -10570,17 +10569,17 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {
R2_GLOBALS._sound1.play(134);
- _actor1.postInit();
- _actor1.fixPriority(10);
+ _playerShadow.postInit();
+ _playerShadow.fixPriority(10);
if (R2_GLOBALS._player._characterIndex == R2_QUINN)
- _actor1.setVisage(1112);
+ _playerShadow.setVisage(1112);
else
- _actor1.setVisage(1111);
+ _playerShadow.setVisage(1111);
- _actor1._effect = EFFECT_SHADOW;
- _actor1._shadowMap = _shadowPaletteMap;
- R2_GLOBALS._player._linkedActor = &_actor1;
+ _playerShadow._effect = EFFECT_SHADOW_MAP;
+ _playerShadow._shadowMap = _shadowPaletteMap;
+ R2_GLOBALS._player._linkedActor = &_playerShadow;
_actor2.postInit();
_actor2.fixPriority(10);
@@ -10589,7 +10588,7 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {
else
_actor2.setVisage(1112);
- _actor2._effect = EFFECT_SHADOW;
+ _actor2._effect = EFFECT_SHADOW_MAP;
_actor2._shadowMap = _shadowPaletteMap;
_actor12._linkedActor = &_actor2;
@@ -10611,7 +10610,7 @@ void Scene1700::postInit(SceneObjectList *OwnerList) {
_ledgeHopper.setPosition(Common::Point(220, 137));
_ledgeHopper.setDetails(1700, 6, -1, -1, 1, (SceneItem *) NULL);
- _actor1.hide();
+ _playerShadow.hide();
_actor2.hide();
R2_GLOBALS._events.setCursor(CURSOR_WALK);
_stripManager.start(539, this);
@@ -10788,7 +10787,8 @@ void Scene1700::signal() {
case 40:
R2_GLOBALS._player.disableControl();
_sceneMode = 1704;
- setAction(&_sequenceManager, this, 1704, &R2_GLOBALS._player, &_actor12, &_actor10, &_ledgeHopper, &_actor1, &_actor2, NULL);
+ setAction(&_sequenceManager, this, 1704, &R2_GLOBALS._player, &_actor12,
+ &_actor10, &_ledgeHopper, &_playerShadow, &_actor2, NULL);
break;
case 50:
if (R2_GLOBALS._player._characterIndex == R2_QUINN)
@@ -11527,7 +11527,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {
else
_playerShadow.setVisage(1110);
- _playerShadow._effect = EFFECT_SHADOW;
+ _playerShadow._effect = EFFECT_SHADOW_MAP;
_playerShadow._shadowMap = _shadowPaletteMap;
R2_GLOBALS._player._linkedActor = &_playerShadow;
@@ -11539,7 +11539,7 @@ void Scene1800::postInit(SceneObjectList *OwnerList) {
else
_companionShadow.setVisage(1111);
- _companionShadow._effect = EFFECT_SHADOW;
+ _companionShadow._effect = EFFECT_SHADOW_MAP;
_companionShadow._shadowMap = _shadowPaletteMap;
_companion._linkedActor = &_companionShadow;
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h
index c9b6244cb4..48088981f2 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.h
@@ -749,7 +749,7 @@ public:
SpeakerSeeker _seekerSpeaker;
NamedHotspot _item1;
Item2 _item2;
- SceneActor _actor1;
+ SceneActor _playerShadow;
SceneActor _actor2;
SceneActor _slabWest;
SceneActor _slabEast;
diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
index dd01c3d8d9..6eda26db2f 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
@@ -5204,18 +5204,20 @@ void Scene3800::enterArea() {
R2_GLOBALS._player.setStrip(3);
R2_GLOBALS._player.changeZoom(-1);
R2_GLOBALS._player._moveDiff = Common::Point(3, 2);
- _balloonQuinn.postInit();
- _balloonQuinn.fixPriority(10);
- _balloonQuinn.changeZoom(-1);
- _balloonQuinn.setVisage(1110);
- _balloonQuinn._effect = EFFECT_SHADOW;
- _balloonQuinn._shadowMap = this->_shadowPaletteMap;
- R2_GLOBALS._player._linkedActor = &_balloonQuinn;
+
+ _quinnShadow.postInit();
+ _quinnShadow.fixPriority(10);
+ _quinnShadow.changeZoom(-1);
+ _quinnShadow.setVisage(1110);
+ _quinnShadow._effect = EFFECT_SHADOW_MAP;
+ _quinnShadow._shadowMap = this->_shadowPaletteMap;
+ R2_GLOBALS._player._linkedActor = &_quinnShadow;
+
switch (R2_GLOBALS._sceneManager._previousScene) {
case 2600:
_balloon.postInit();
_harness.postInit();
- _balloonQuinn.hide();
+ _quinnShadow.hide();
_sceneMode = 3800;
setAction(&_sequenceManager1, this, 3800, &R2_GLOBALS._player,
&_balloon, &_harness, NULL);
@@ -5361,7 +5363,7 @@ void Scene3800::signal() {
g_globals->_sceneManager.changeScene(3900);
break;
case 3800:
- _balloonQuinn.show();
+ _quinnShadow.show();
_balloon.remove();
_harness.remove();
R2_GLOBALS._player.enableControl();
@@ -5514,13 +5516,13 @@ void Scene3900::postInit(SceneObjectList *OwnerList) {
R2_GLOBALS._player.changeZoom(-1);
R2_GLOBALS._player._moveDiff = Common::Point(3, 2);
- _linkedQuinn.postInit();
- _linkedQuinn.fixPriority(10);
- _linkedQuinn.changeZoom(-1);
- _linkedQuinn.setVisage(1110);
- _linkedQuinn._effect = EFFECT_SHADOW;
- _linkedQuinn._shadowMap = _shadowPaletteMap;
- R2_GLOBALS._player._linkedActor = &_linkedQuinn;
+ _quinnShadow.postInit();
+ _quinnShadow.fixPriority(10);
+ _quinnShadow.changeZoom(-1);
+ _quinnShadow.setVisage(1110);
+ _quinnShadow._effect = EFFECT_SHADOW_MAP;
+ _quinnShadow._shadowMap = _shadowPaletteMap;
+ R2_GLOBALS._player._linkedActor = &_quinnShadow;
if ((R2_GLOBALS._desertPreviousDirection == 2) && (R2_GLOBALS._sceneManager._previousScene != 2700)) {
// loadScene(3825);
diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.h b/engines/tsage/ringworld2/ringworld2_scenes3.h
index 48236ee300..6191b750be 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes3.h
+++ b/engines/tsage/ringworld2/ringworld2_scenes3.h
@@ -786,7 +786,7 @@ class Scene3800 : public SceneExt {
public:
SceneObject _balloon;
SceneObject _harness;
- SceneActor _balloonQuinn;
+ SceneActor _quinnShadow;
NamedHotspot _background;
NorthExit _northExit;
EastExit _eastExit;
@@ -833,7 +833,7 @@ class Scene3900 : public SceneExt {
virtual void changeScene();
};
public:
- SceneActor _linkedQuinn;
+ SceneActor _quinnShadow;
NamedHotspot _background;
NorthExit _northExit;
EastExit _eastExit;