diff options
-rw-r--r-- | saga/actor.cpp | 13 | ||||
-rw-r--r-- | saga/events.cpp | 20 | ||||
-rw-r--r-- | saga/gfx.cpp | 38 | ||||
-rw-r--r-- | saga/gfx.h | 1 | ||||
-rw-r--r-- | saga/module.mk | 2 | ||||
-rw-r--r-- | saga/saga.h | 4 |
6 files changed, 59 insertions, 19 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp index 53d6e52f3b..e7ddb291b1 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -1313,9 +1313,10 @@ void Actor::createDrawOrderList() { actor = _actors[i]; if (!actor->inScene) continue; - - _drawOrderList.pushBack(actor, compareFunction); - calcScreenPosition(actor); + + if (calcScreenPosition(actor)) { + _drawOrderList.pushBack(actor, compareFunction); + } } for (i = 0; i < _objsCount; i++) { @@ -1325,9 +1326,9 @@ void Actor::createDrawOrderList() { if (obj->sceneNumber != _vm->_scene->currentSceneNumber()) continue; - _drawOrderList.pushBack(obj, compareFunction); - if (!calcScreenPosition(obj)) { - warning("calcScreenPosition return false actorIdx=%i", i); + + if (calcScreenPosition(obj)) { + _drawOrderList.pushBack(obj, compareFunction); } } } diff --git a/saga/events.cpp b/saga/events.cpp index 739227c220..0ac071bb5d 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -126,6 +126,7 @@ int Events::handleContinuous(EVENT *event) { Surface *backGroundSurface; BGInfo bgInfo; + Rect rect; event_pc = ((double)event->duration - event->time) / event->duration; @@ -163,21 +164,26 @@ int Events::handleContinuous(EVENT *event) { case EVENT_DISSOLVE: backGroundSurface = _vm->_render->getBackGroundSurface(); _vm->_scene->getBGInfo(bgInfo); - _vm->transitionDissolve((byte*)backGroundSurface->pixels, backGroundSurface->w, - backGroundSurface->h, bgInfo.buffer, bgInfo.bounds.width(), bgInfo.bounds.height(), 0, 0, 0, event_pc); + rect.left = rect.top = 0; + rect.right = bgInfo.bounds.width(); + rect.bottom = bgInfo.bounds.height(); + backGroundSurface->transitionDissolve(bgInfo.buffer, rect, 0, event_pc); break; case EVENT_DISSOLVE_BGMASK: // we dissolve it centered. // set flag of Dissolve to 1. It is a hack to simulate zero masking. int w, h; - byte *mask_buf; + byte *maskBuffer; size_t len; backGroundSurface = _vm->_render->getBackGroundSurface(); - _vm->_scene->getBGMaskInfo(w, h, mask_buf, len); - _vm->transitionDissolve((byte*)backGroundSurface->pixels, backGroundSurface->w, - backGroundSurface->h, mask_buf, w, h, 1, - (_vm->getDisplayWidth() - w) / 2, (_vm->getDisplayHeight() - h) / 2, event_pc); + _vm->_scene->getBGMaskInfo(w, h, maskBuffer, len); + rect.left = (_vm->getDisplayWidth() - w) / 2; + rect.top = (_vm->getDisplayHeight() - h) / 2; + rect.setWidth(w); + rect.setHeight(h); + + backGroundSurface->transitionDissolve( maskBuffer, rect, 1, event_pc); break; default: break; diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 0edeefc653..e9c9bb1eec 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -124,6 +124,44 @@ void Surface::drawPolyLine(const Point *points, int count, int color) { } } +/** +* Dissolve one image with another. +* If flags if set to 1, do zero masking. +*/ +void Surface::transitionDissolve(const byte *sourceBuffer, const Common::Rect &sourceRect, int flags, double percent) { +#define XOR_MASK 0xB400; + int pixelcount = w * h; + int seqlimit = (int)(65535 * percent); + int seq = 1; + int i, x1, y1; + byte color; + + for (i = 0; i < seqlimit; i++) { + if (seq & 1) { + seq = (seq >> 1) ^ XOR_MASK; + } else { + seq = seq >> 1; + } + + if (seq == 1) { + return; + } + + if (seq >= pixelcount) { + continue; + } else { + x1 = seq % w; + y1 = seq / w; + + if (sourceRect.contains(x1, y1)) { + color = sourceBuffer[(x1-sourceRect.left) + sourceRect.width()*(y1-sourceRect.top)]; + if (flags == 0 || color) + ((byte*)pixels)[seq] = color; + } + } + } +} + void Gfx::setPalette(PalEntry *pal) { int i; diff --git a/saga/gfx.h b/saga/gfx.h index 73d6b3b4d7..8e6a94c1c1 100644 --- a/saga/gfx.h +++ b/saga/gfx.h @@ -87,6 +87,7 @@ struct Color { struct Surface : Graphics::Surface { + void transitionDissolve(const byte *sourceBuffer, const Common::Rect &sourceRect, int flags, double percent); void drawPalette(); void drawPolyLine(const Point *points, int count, int color); void blit(const Common::Rect &destRect, const byte *sourceBuffer); diff --git a/saga/module.mk b/saga/module.mk index 8a358f7a21..3e28da3163 100644 --- a/saga/module.mk +++ b/saga/module.mk @@ -24,13 +24,11 @@ MODULE_OBJS := \ saga/saveload.o \ saga/scene.o \ saga/script.o \ - saga/sdebug.o \ saga/sfuncs.o \ saga/sndres.o \ saga/sprite.o \ saga/sthread.o \ saga/text.o \ - saga/transitions.o \ saga/input.o \ saga/music.o \ saga/sound.o diff --git a/saga/saga.h b/saga/saga.h index 5744036e5a..c845fe893e 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -585,10 +585,6 @@ public: int effect_color, int flags); int textProcessList(TEXTLIST *textlist, long ms); - int transitionDissolve(byte *dst_img, int dst_w, int dst_h, - const byte *src_img, int src_w, int src_h, int flags, int x, int y, - double percent); - int processInput(void); const Point &mousePos() const { return _mousePos; |