aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2010-01-09 19:12:53 +0000
committerMartin Kiewitz2010-01-09 19:12:53 +0000
commit7f78815e0e46c5549f1eb7b32455f053e11ada44 (patch)
treeb415f58b6417274cbd5cd4183128c5e1a4772457
parent9c2fa534d115c2c38cc8249d738c747d22bb48eb (diff)
downloadscummvm-rg350-7f78815e0e46c5549f1eb7b32455f053e11ada44.tar.gz
scummvm-rg350-7f78815e0e46c5549f1eb7b32455f053e11ada44.tar.bz2
scummvm-rg350-7f78815e0e46c5549f1eb7b32455f053e11ada44.zip
SCI: kPortrait almost fully implemented (animation bitmaps still missing)
svn-id: r47204
-rw-r--r--engines/sci/graphics/gui.cpp5
-rw-r--r--engines/sci/graphics/portrait.cpp54
-rw-r--r--engines/sci/graphics/portrait.h6
3 files changed, 55 insertions, 10 deletions
diff --git a/engines/sci/graphics/gui.cpp b/engines/sci/graphics/gui.cpp
index a5e9442478..7b11684960 100644
--- a/engines/sci/graphics/gui.cpp
+++ b/engines/sci/graphics/gui.cpp
@@ -850,15 +850,14 @@ reg_t SciGui::portraitLoad(Common::String resourceName) {
return NULL_REG;
}
-void SciGui::portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
+void SciGui::portraitShow(Common::String resourceName, Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
Portrait *myPortrait = new Portrait(_s->resMan, _screen, _palette, _audio, resourceName);
// TODO: cache portraits
// adjust given coordinates to curPort (but dont adjust coordinates on upscaledHires_Save_Box and give us hires coordinates
// on kDrawCel, yeah this whole stuff makes sense)
position.x += _gfx->GetPort()->left; position.y += _gfx->GetPort()->top;
position.x *= 2; position.y *= 2;
- myPortrait->setupAudio(resourceNum, noun, verb, cond, seq);
- myPortrait->draw(position);
+ myPortrait->doit(position, resourceId, noun, verb, cond, seq);
delete myPortrait;
}
diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp
index 6cea167e4c..67abacfb75 100644
--- a/engines/sci/graphics/portrait.cpp
+++ b/engines/sci/graphics/portrait.cpp
@@ -108,25 +108,67 @@ void Portrait::init() {
// TODO: Read animation bitmaps
}
-void Portrait::setupAudio(uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
- uint32 number = ((noun & 0xff) << 24) | ((verb & 0xff) << 16) | ((cond & 0xff) << 8) | (seq & 0xff);
+void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
+ _position = position;
+ // Now init audio and sync resource
+ uint32 audioNumber = ((noun & 0xff) << 24) | ((verb & 0xff) << 16) | ((cond & 0xff) << 8) | (seq & 0xff);
+ ResourceId syncResourceId = ResourceId(kResourceTypeSync36, resourceId, noun, verb, cond, seq);
+ Resource *syncResource = _resMan->findResource(syncResourceId, true);
+ uint syncOffset = 0;
+
+ // Draw base bitmap
+ drawMainBitmap();
+
+ // Start playing audio...
_audio->stopAudio();
- _audio->startAudio(resourceId, number);
+ _audio->startAudio(resourceId, audioNumber);
+
+ // Do animation depending on sync resource till audio is done playing
+ int16 syncCue;
+ int timerPosition, curPosition;
+
+ timerPosition = 0;
+ while (syncOffset < syncResource->size - 2) {
+ timerPosition += (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+ syncOffset += 2;
+ if (syncOffset < syncResource->size - 2) {
+ syncCue = (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+ syncOffset += 2;
+ } else {
+ syncCue = -1;
+ }
+ // Wait till syncTime passed, then show specific animation bitmap
+ do {
+ g_system->delayMillis(10);
+ curPosition = _audio->getAudioPosition();
+ } while ((curPosition != -1) && (curPosition < timerPosition));
+
+ if (syncCue >= 0) {
+ // Display animation bitmap
+ drawBitmap(syncCue);
+ warning("display animation %d", syncCue);
+ }
+ }
}
-void Portrait::draw(Common::Point position) {
+void Portrait::drawMainBitmap() {
byte *data = _mainBitmapData;
_palette->set(&_portraitPalette, 1);
for (int y = 0; y < _height; y++) {
for (int x = 0; x < _width; x++) {
- _screen->putPixelOnDisplay(position.x + x, position.y + y, _portraitPalette.mapping[*data++]);
+ _screen->putPixelOnDisplay(_position.x + x, _position.y + y, _portraitPalette.mapping[*data++]);
}
}
Common::Rect mainBitmap = Common::Rect(_width, _height);
- mainBitmap.moveTo(position.x, position.y);
+ mainBitmap.moveTo(_position.x, _position.y);
_screen->copyDisplayRectToScreen(mainBitmap);
+ g_system->updateScreen();
+}
+
+void Portrait::drawBitmap(int16 bitmapNr) {
+ // 0 seems to be main bitmap
}
} // End of namespace Sci
diff --git a/engines/sci/graphics/portrait.h b/engines/sci/graphics/portrait.h
index 847ed9f2dc..30984e091b 100644
--- a/engines/sci/graphics/portrait.h
+++ b/engines/sci/graphics/portrait.h
@@ -34,10 +34,12 @@ public:
~Portrait();
void setupAudio(uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
- void draw(Common::Point position);
+ void doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
private:
void init();
+ void drawMainBitmap();
+ void drawBitmap(int16 bitmapNr);
ResourceManager *_resMan;
Screen *_screen;
@@ -56,6 +58,8 @@ private:
Palette _portraitPalette;
byte *_mainBitmapData;
+
+ Common::Point _position;
};
} // End of namespace Sci