aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Menshakov2009-12-27 18:21:49 +0000
committerVladimir Menshakov2009-12-27 18:21:49 +0000
commit3e915d9ec5b7b57d1d1914f18946a60bd4c93529 (patch)
tree5545e069cd3f45d10136dd36d14fbfa2b2d0b80b
parent95f90be7efde138d2792798cb013c3685be7cf25 (diff)
downloadscummvm-rg350-3e915d9ec5b7b57d1d1914f18946a60bd4c93529.tar.gz
scummvm-rg350-3e915d9ec5b7b57d1d1914f18946a60bd4c93529.tar.bz2
scummvm-rg350-3e915d9ec5b7b57d1d1914f18946a60bd4c93529.zip
implemented fade in/out effects
svn-id: r46653
-rw-r--r--engines/teenagent/scene.cpp44
-rw-r--r--engines/teenagent/scene.h4
-rw-r--r--engines/teenagent/surface_list.cpp2
-rw-r--r--engines/teenagent/teenagent.cpp18
-rw-r--r--engines/teenagent/teenagent.h2
5 files changed, 57 insertions, 13 deletions
diff --git a/engines/teenagent/scene.cpp b/engines/teenagent/scene.cpp
index 16634c2144..6f1f4d1418 100644
--- a/engines/teenagent/scene.cpp
+++ b/engines/teenagent/scene.cpp
@@ -194,6 +194,8 @@ void Scene::init(TeenAgentEngine *engine, OSystem *system) {
_engine = engine;
_system = system;
+ memset(palette, 0, sizeof(palette));
+
Resources *res = Resources::instance();
Common::SeekableReadStream *s = res->varia.getStream(1);
if (s == NULL)
@@ -363,7 +365,6 @@ void Scene::init(int id, const Common::Point &pos) {
}
}
}
- setPalette(_system, palette, 4);
Common::SeekableReadStream *stream = res->on.getStream(id);
int sub_hack = 0;
@@ -389,6 +390,9 @@ void Scene::init(int id, const Common::Point &pos) {
if (now_playing != res->dseg.get_byte(0xDB90))
_engine->music->load(res->dseg.get_byte(0xDB90));
+
+ _system->copyRectToScreen((const byte *)background.pixels, background.pitch, 0, 0, background.w, background.h);
+ setPalette(0);
}
void Scene::playAnimation(byte idx, uint id, bool loop, bool paused, bool ignore) {
@@ -450,7 +454,7 @@ bool Scene::processEvent(const Common::Event &event) {
for (int i = 0; i < 4; ++i)
custom_animation[i].free();
_engine->playMusic(4);
- init(10, Common::Point(136, 153));
+ _engine->loadScene(10, Common::Point(136, 153));
return true;
}
@@ -504,7 +508,8 @@ bool Scene::render(OSystem *system) {
restart = false;
busy = processEventQueue();
- if (current_event.type == SceneEvent::kCredits) {
+ switch(current_event.type) {
+ case SceneEvent::kCredits: {
system->fillScreen(0);
///\todo: optimize me
Graphics::Surface *surface = system->lockScreen();
@@ -513,8 +518,19 @@ bool Scene::render(OSystem *system) {
if (current_event.dst.y < -(int)current_event.timer)
current_event.clear();
-
+ }
return true;
+ case SceneEvent::kFade:
+ //debug(0, "fade timer = %d", current_event.timer);
+ setPalette(current_event.orientation? 4 - current_event.timer: current_event.timer);
+ ++current_event.timer;
+ if (current_event.timer > 4) {
+ nextEvent();
+ continue;
+ } else
+ busy |= true;
+ default:
+ ;
}
if (!message.empty() && message_timer != 0) {
@@ -962,7 +978,10 @@ bool Scene::processEventQueue() {
debug(0, "*stub* shaking the screen");
current_event.clear();
break;
-
+
+ case SceneEvent::kFade:
+ break;
+
case SceneEvent::kCredits:
debug(0, "showing credits");
break;
@@ -983,16 +1002,16 @@ bool Scene::processEventQueue() {
return !current_event.empty();
}
-void Scene::setPalette(OSystem *system, const byte *buf, unsigned mul) {
+void Scene::setPalette(unsigned mul) {
byte p[1024];
memset(p, 0, 1024);
for (int i = 0; i < 256; ++i) {
for (int c = 0; c < 3; ++c)
- p[i * 4 + c] = buf[i * 3 + c] * mul;
+ p[i * 4 + c] = (unsigned)palette[i * 3 + c] * mul;
}
- system->setPalette(p, 0, 256);
+ _system->setPalette(p, 0, 256);
}
Object *Scene::getObject(int id, int scene_id) {
@@ -1003,8 +1022,13 @@ Object *Scene::getObject(int id, int scene_id) {
if (scene_id == 0)
return NULL;
-
- return &objects[scene_id - 1][id - 1];
+
+ Common::Array<Object> &scene_objects = objects[scene_id - 1];
+ --id;
+ if (id >= (int)scene_objects.size())
+ return NULL;
+
+ return &scene_objects[id];
}
Common::Point Scene::messagePosition(const Common::String &str, Common::Point position) {
diff --git a/engines/teenagent/scene.h b/engines/teenagent/scene.h
index d9c89e689b..bdd38c6efb 100644
--- a/engines/teenagent/scene.h
+++ b/engines/teenagent/scene.h
@@ -60,6 +60,7 @@ struct SceneEvent {
kCredits,
kTimer,
kEffect,
+ kFade,
kQuit
} type;
@@ -137,6 +138,7 @@ public:
void displayMessage(const Common::String &str, byte color = 0xd1, const Common::Point &pos = Common::Point());
void setOrientation(uint8 o) { orientation = o; }
void push(const SceneEvent &event);
+ SceneEvent::Type last_event_type() const { return !events.empty()? events.back().type: SceneEvent::kNone; }
bool processEvent(const Common::Event &event);
@@ -155,6 +157,7 @@ public:
Animation * getAnimation(byte slot);
inline Animation * getActorAnimation() { return &actor_animation; }
inline const Common::String& getMessage() const { return message; }
+ void setPalette(unsigned mul);
private:
void loadOns();
@@ -164,7 +167,6 @@ private:
void playActorAnimation(uint id, bool loop, bool ignore);
byte palette[768];
- void setPalette(OSystem *system, const byte *palette, unsigned mul = 1);
static Common::Point messagePosition(const Common::String &str, Common::Point position);
static uint messageDuration(const Common::String &str);
diff --git a/engines/teenagent/surface_list.cpp b/engines/teenagent/surface_list.cpp
index cd0b559793..5485b42fa4 100644
--- a/engines/teenagent/surface_list.cpp
+++ b/engines/teenagent/surface_list.cpp
@@ -28,7 +28,7 @@
namespace TeenAgent {
-SurfaceList::SurfaceList() : surfaces(NULL) {}
+SurfaceList::SurfaceList() : surfaces(NULL), surfaces_n(0) {}
void SurfaceList::load(Common::SeekableReadStream *stream, Type type, int sub_hack) {
free();
diff --git a/engines/teenagent/teenagent.cpp b/engines/teenagent/teenagent.cpp
index f33bf9b97e..9bc6bc5c54 100644
--- a/engines/teenagent/teenagent.cpp
+++ b/engines/teenagent/teenagent.cpp
@@ -218,6 +218,7 @@ Common::Error TeenAgentEngine::loadGameState(int slot) {
uint16 x = res->dseg.get_word(0x64AF), y = res->dseg.get_word(0x64B1);
scene->loadObjectData();
scene->init(id, Common::Point(x, y));
+ scene->setPalette(4);
return Common::kNoError;
}
@@ -518,7 +519,6 @@ void TeenAgentEngine::displayCutsceneMessage(uint16 addr, uint16 position) {
scene->push(event);
}
-
void TeenAgentEngine::moveTo(const Common::Point &dst, byte o, bool warp) {
moveTo(dst.x, dst.y, o, warp);
}
@@ -573,12 +573,16 @@ void TeenAgentEngine::loadScene(byte id, const Common::Point &pos, byte o) {
}
void TeenAgentEngine::loadScene(byte id, uint16 x, uint16 y, byte o) {
+ if (scene->last_event_type() != SceneEvent::kCreditsMessage)
+ fadeOut();
+
SceneEvent event(SceneEvent::kLoadScene);
event.scene = id;
event.dst.x = x;
event.dst.y = y;
event.orientation = o;
scene->push(event);
+ fadeIn();
}
void TeenAgentEngine::setOns(byte id, byte value, byte scene_id) {
@@ -676,6 +680,18 @@ void TeenAgentEngine::shakeScreen() {
scene->push(event);
}
+void TeenAgentEngine::fadeIn() {
+ SceneEvent event(SceneEvent::kFade);
+ event.orientation = 0;
+ scene->push(event);
+}
+
+void TeenAgentEngine::fadeOut() {
+ SceneEvent event(SceneEvent::kFade);
+ event.orientation = 1;
+ scene->push(event);
+}
+
void TeenAgentEngine::playSoundNow(byte id) {
Resources *res = Resources::instance();
Common::SeekableReadStream *in = res->sam_sam.getStream(id);
diff --git a/engines/teenagent/teenagent.h b/engines/teenagent/teenagent.h
index 19dc771dcf..a02197aa33 100644
--- a/engines/teenagent/teenagent.h
+++ b/engines/teenagent/teenagent.h
@@ -106,6 +106,8 @@ public:
void setTimerCallback(uint16 addr, uint16 frames);
void shakeScreen();
void displayCredits();
+ void fadeIn();
+ void fadeOut();
Common::RandomSource random;