[Scummvm-cvs-logs] SF.net SVN: scummvm:[46653] scummvm/trunk/engines/teenagent
megath at users.sourceforge.net
megath at users.sourceforge.net
Sun Dec 27 19:21:49 CET 2009
Revision: 46653
http://scummvm.svn.sourceforge.net/scummvm/?rev=46653&view=rev
Author: megath
Date: 2009-12-27 18:21:49 +0000 (Sun, 27 Dec 2009)
Log Message:
-----------
implemented fade in/out effects
Modified Paths:
--------------
scummvm/trunk/engines/teenagent/scene.cpp
scummvm/trunk/engines/teenagent/scene.h
scummvm/trunk/engines/teenagent/surface_list.cpp
scummvm/trunk/engines/teenagent/teenagent.cpp
scummvm/trunk/engines/teenagent/teenagent.h
Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp 2009-12-27 16:44:38 UTC (rev 46652)
+++ scummvm/trunk/engines/teenagent/scene.cpp 2009-12-27 18:21:49 UTC (rev 46653)
@@ -194,6 +194,8 @@
_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 @@
}
}
}
- setPalette(_system, palette, 4);
Common::SeekableReadStream *stream = res->on.getStream(id);
int sub_hack = 0;
@@ -389,6 +390,9 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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) {
Modified: scummvm/trunk/engines/teenagent/scene.h
===================================================================
--- scummvm/trunk/engines/teenagent/scene.h 2009-12-27 16:44:38 UTC (rev 46652)
+++ scummvm/trunk/engines/teenagent/scene.h 2009-12-27 18:21:49 UTC (rev 46653)
@@ -60,6 +60,7 @@
kCredits,
kTimer,
kEffect,
+ kFade,
kQuit
} type;
@@ -137,6 +138,7 @@
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 @@
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 @@
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);
Modified: scummvm/trunk/engines/teenagent/surface_list.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/surface_list.cpp 2009-12-27 16:44:38 UTC (rev 46652)
+++ scummvm/trunk/engines/teenagent/surface_list.cpp 2009-12-27 18:21:49 UTC (rev 46653)
@@ -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();
Modified: scummvm/trunk/engines/teenagent/teenagent.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.cpp 2009-12-27 16:44:38 UTC (rev 46652)
+++ scummvm/trunk/engines/teenagent/teenagent.cpp 2009-12-27 18:21:49 UTC (rev 46653)
@@ -218,6 +218,7 @@
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 @@
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, 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 @@
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);
Modified: scummvm/trunk/engines/teenagent/teenagent.h
===================================================================
--- scummvm/trunk/engines/teenagent/teenagent.h 2009-12-27 16:44:38 UTC (rev 46652)
+++ scummvm/trunk/engines/teenagent/teenagent.h 2009-12-27 18:21:49 UTC (rev 46653)
@@ -106,6 +106,8 @@
void setTimerCallback(uint16 addr, uint16 frames);
void shakeScreen();
void displayCredits();
+ void fadeIn();
+ void fadeOut();
Common::RandomSource random;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list