aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-01-09 20:38:22 +0000
committerMartin Kiewitz2010-01-09 20:38:22 +0000
commit273da184ee4f63904e72e5aa9ae85daa93f5f95e (patch)
tree442435b9e6268f84f369e45a2bfa0956c15884c7 /engines/sci
parentac66783b5f5243163bcd06da43007e938e3b8f60 (diff)
downloadscummvm-rg350-273da184ee4f63904e72e5aa9ae85daa93f5f95e.tar.gz
scummvm-rg350-273da184ee4f63904e72e5aa9ae85daa93f5f95e.tar.bz2
scummvm-rg350-273da184ee4f63904e72e5aa9ae85daa93f5f95e.zip
SCI: kPortrait - animation included, doesnt seem right currently coordinate offset is missing (cause i cant find it) and mouth movement doesnt seem right...at least the basics work and graphic data is fine
svn-id: r47206
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/portrait.cpp76
-rw-r--r--engines/sci/graphics/portrait.h12
2 files changed, 50 insertions, 38 deletions
diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp
index 67abacfb75..65f82022ef 100644
--- a/engines/sci/graphics/portrait.cpp
+++ b/engines/sci/graphics/portrait.cpp
@@ -82,7 +82,8 @@ void Portrait::init() {
}
_width = READ_LE_UINT16(_fileData + 3);
_height = READ_LE_UINT16(_fileData + 5);
- _animationCount = READ_LE_UINT16(_fileData + 7);
+ _bitmapCount = READ_LE_UINT16(_fileData + 7);
+ _bitmaps = new PortraitBitmap[_bitmapCount];
_portraitPaletteSize = READ_LE_UINT16(_fileData + 13);
byte *data = _fileData + 17;
@@ -98,14 +99,17 @@ void Portrait::init() {
palNr++; palSize += 3;
}
- // Read main bitmap
- assert(READ_LE_UINT16(data + 4) == _height);
- assert(READ_LE_UINT16(data + 6) == _width);
- data += 14; // Skip over bitmap header
- _mainBitmapData = data;
- data += _height * _width;
-
- // TODO: Read animation bitmaps
+ // Read all bitmaps
+ PortraitBitmap *curBitmap = _bitmaps;
+ uint16 bitmapNr;
+
+ for (bitmapNr = 0; bitmapNr < _bitmapCount; bitmapNr++) {
+ curBitmap->height = READ_LE_UINT16(data + 4);
+ curBitmap->width = READ_LE_UINT16(data + 6);
+ curBitmap->rawBitmap = data + 14;
+ data += 14 + (curBitmap->height * curBitmap->width);
+ curBitmap++;
+ }
}
void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
@@ -118,57 +122,61 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint
uint syncOffset = 0;
// Draw base bitmap
- drawMainBitmap();
+ _palette->set(&_portraitPalette, 1);
+ drawBitmap(0);
// Start playing audio...
_audio->stopAudio();
_audio->startAudio(resourceId, audioNumber);
// Do animation depending on sync resource till audio is done playing
- int16 syncCue;
+ // TODO: This whole mess doesnt seem to be correct currently
+ uint16 syncCue;
int timerPosition, curPosition;
-
- timerPosition = 0;
while (syncOffset < syncResource->size - 2) {
- timerPosition += (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+ timerPosition = (int16)READ_LE_UINT16(syncResource->data + syncOffset);
syncOffset += 2;
if (syncOffset < syncResource->size - 2) {
- syncCue = (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+ syncCue = READ_LE_UINT16(syncResource->data + syncOffset);
syncOffset += 2;
} else {
- syncCue = -1;
+ syncCue = 0xFFFF;
}
+
+ if (syncCue != 0xFFFF) {
+ // Display animation bitmap
+ syncCue++; // TODO: Not sure if 0 means main bitmap or animation-frame 0
+ if (syncCue < _bitmapCount) {
+ drawBitmap(syncCue);
+ } else {
+ warning("kPortrait: sync information tried to draw non-existant %d", syncCue);
+ }
+ }
+
// 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::drawMainBitmap() {
- byte *data = _mainBitmapData;
- _palette->set(&_portraitPalette, 1);
- for (int y = 0; y < _height; y++) {
- for (int x = 0; x < _width; x++) {
+// TODO: coordinate offset is missing...can't find it in the bitmap header nor in the main header
+void Portrait::drawBitmap(uint16 bitmapNr) {
+ byte *data = _bitmaps[bitmapNr].rawBitmap;
+ uint16 bitmapHeight = _bitmaps[bitmapNr].height;
+ uint16 bitmapWidth = _bitmaps[bitmapNr].width;
+
+ for (int y = 0; y < bitmapHeight; y++) {
+ for (int x = 0; x < bitmapWidth; x++) {
_screen->putPixelOnDisplay(_position.x + x, _position.y + y, _portraitPalette.mapping[*data++]);
}
}
- Common::Rect mainBitmap = Common::Rect(_width, _height);
- mainBitmap.moveTo(_position.x, _position.y);
- _screen->copyDisplayRectToScreen(mainBitmap);
+ Common::Rect bitmapRect = Common::Rect(bitmapWidth, bitmapHeight);
+ bitmapRect.moveTo(_position.x, _position.y);
+ _screen->copyDisplayRectToScreen(bitmapRect);
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 30984e091b..71218bdd90 100644
--- a/engines/sci/graphics/portrait.h
+++ b/engines/sci/graphics/portrait.h
@@ -28,6 +28,11 @@
namespace Sci {
+struct PortraitBitmap {
+ int16 width, height;
+ byte *rawBitmap;
+};
+
class Portrait {
public:
Portrait(ResourceManager *resMan, Screen *screen, SciPalette *palette, AudioPlayer *audio, Common::String resourceName);
@@ -38,8 +43,7 @@ public:
private:
void init();
- void drawMainBitmap();
- void drawBitmap(int16 bitmapNr);
+ void drawBitmap(uint16 bitmapNr);
ResourceManager *_resMan;
Screen *_screen;
@@ -53,11 +57,11 @@ private:
uint16 _height;
uint16 _width;
- uint16 _animationCount;
uint16 _portraitPaletteSize;
Palette _portraitPalette;
- byte *_mainBitmapData;
+ uint16 _bitmapCount;
+ PortraitBitmap *_bitmaps;
Common::Point _position;
};