aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-09-24 10:13:17 +0000
committerTorbjörn Andersson2005-09-24 10:13:17 +0000
commitee4b2ccb02bc53f3c861ac899985796ebd0ce2a0 (patch)
tree4db0792e283c8ad4c8d2552b8764bad079f6e228 /saga
parente077fdd9eda8a4eb455810b994deef8cc1805311 (diff)
downloadscummvm-rg350-ee4b2ccb02bc53f3c861ac899985796ebd0ce2a0.tar.gz
scummvm-rg350-ee4b2ccb02bc53f3c861ac899985796ebd0ce2a0.tar.bz2
scummvm-rg350-ee4b2ccb02bc53f3c861ac899985796ebd0ce2a0.zip
Some more preliminary cutaway work. The backgrounds are displayed now, but
not the animations themselves. Still, it's enough to make the IHNM intro look fairly interesting. svn-id: r18874
Diffstat (limited to 'saga')
-rw-r--r--saga/animation.cpp53
-rw-r--r--saga/animation.h5
-rw-r--r--saga/sfuncs.cpp9
3 files changed, 61 insertions, 6 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp
index 799fd3f974..33082058af 100644
--- a/saga/animation.cpp
+++ b/saga/animation.cpp
@@ -27,7 +27,10 @@
#include "saga/console.h"
#include "saga/events.h"
+#include "saga/interface.h"
#include "saga/render.h"
+#include "saga/rscfile.h"
+#include "saga/scene.h"
#include "saga/animation.h"
@@ -55,8 +58,8 @@ void Anim::loadCutawayList(const byte *resourcePointer, size_t resourceLength) {
MemoryReadStream cutawayS(resourcePointer, resourceLength);
for (int i = 0; i < _cutawayListLength; i++) {
- _cutawayList[i].backgroundID = cutawayS.readUint16LE();
- _cutawayList[i].frameID = cutawayS.readUint16LE();
+ _cutawayList[i].backgroundResourceId = cutawayS.readUint16LE();
+ _cutawayList[i].animResourceId = cutawayS.readUint16LE();
_cutawayList[i].maxFrame = (int16)cutawayS.readUint16LE();
_cutawayList[i].frameRate = (int16)cutawayS.readUint16LE();
}
@@ -68,6 +71,51 @@ void Anim::freeCutawayList(void) {
_cutawayListLength = 0;
}
+void Anim::playCutaway(int cut, bool fade) {
+ debug(0, "playCutaway(%d, %d)", cut, fade);
+
+ if (fade) {
+ // TODO: Fade down. Is this blocking or non-blocking?
+ }
+
+ // TODO: Stop all other animations
+
+ _vm->_gfx->showCursor(false);
+ _vm->_interface->setStatusText("");
+ _vm->_interface->setSaveReminderState(0);
+
+ // TODO: Hide the inventory. Perhaps by adding a new panel mode?
+
+ // Set the initial background and palette for the cutaway
+
+ ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE);
+
+ byte *resourceData;
+ size_t resourceDataLength;
+
+ _vm->_resource->loadResource(context, _cutawayList[cut].backgroundResourceId, resourceData, resourceDataLength);
+
+ byte *buf;
+ size_t buflen;
+ int width;
+ int height;
+
+ _vm->decodeBGImage(resourceData, resourceDataLength, &buf, &buflen, &width, &height);
+
+ PalEntry *palette = (PalEntry *)_vm->getImagePal(resourceData, resourceDataLength);
+
+ Surface *bgSurface = _vm->_render->getBackGroundSurface();
+ const Rect rect(width, height);
+
+ bgSurface->blit(rect, buf);
+ _vm->_gfx->setPalette(palette);
+
+ free(buf);
+ free(resourceData);
+
+ // TODO: Start the animation
+}
+
void Anim::load(uint16 animId, const byte *animResourceData, size_t animResourceLength) {
AnimationData *anim;
uint16 temp;
@@ -230,7 +278,6 @@ void Anim::play(uint16 animId, int vectorTime, bool playing) {
event.time = frameTime;
_vm->_events->queue(&event);
-
}
void Anim::stop(uint16 animId) {
diff --git a/saga/animation.h b/saga/animation.h
index e594a0ba80..a8529ca9ab 100644
--- a/saga/animation.h
+++ b/saga/animation.h
@@ -54,8 +54,8 @@ enum AnimationState {
// Cutaway info array member. Cutaways are basically animations with a really
// bad attitude.
struct Cutaway {
- uint16 backgroundID;
- uint16 frameID;
+ uint16 backgroundResourceId;
+ uint16 animResourceId;
int16 maxFrame;
int16 frameRate;
};
@@ -109,6 +109,7 @@ public:
void loadCutawayList(const byte *resourcePointer, size_t resourceLength);
void freeCutawayList(void);
+ void playCutaway(int cut, bool fade);
void load(uint16 animId, const byte *animResourceData, size_t animResourceLength);
void freeId(uint16 animId);
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 16f108ce01..293753d770 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -1840,7 +1840,14 @@ void Script::sf75(SCRIPTFUNC_PARAMS) {
}
void Script::sfScriptStartCutAway(SCRIPTFUNC_PARAMS) {
- SF_stub("sfScriptStartCutAway", thread, nArgs);
+ int16 cut;
+ int16 fade;
+
+ cut = thread->pop();
+ thread->pop(); // Not used
+ fade = thread->pop();
+
+ _vm->_anim->playCutaway(cut, fade != 0);
}
void Script::sfReturnFromCutAway(SCRIPTFUNC_PARAMS) {