aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2016-05-18 09:53:32 +0200
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit1a3d44edc9b97c97b4ff9dc80747703a952f2409 (patch)
tree3e1e189c9e5a09be4379e6cce6b89731891a2974 /engines/director
parentc2414ae3815e92b768f194c8e353405e6b532919 (diff)
downloadscummvm-rg350-1a3d44edc9b97c97b4ff9dc80747703a952f2409.tar.gz
scummvm-rg350-1a3d44edc9b97c97b4ff9dc80747703a952f2409.tar.bz2
scummvm-rg350-1a3d44edc9b97c97b4ff9dc80747703a952f2409.zip
DIRECTOR: Fix image loading, moved displaying to the engine
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/dib.cpp45
-rw-r--r--engines/director/dib.h2
-rw-r--r--engines/director/director.cpp33
3 files changed, 50 insertions, 30 deletions
diff --git a/engines/director/dib.cpp b/engines/director/dib.cpp
index 30c32349a6..a8fc7548a2 100644
--- a/engines/director/dib.cpp
+++ b/engines/director/dib.cpp
@@ -27,13 +27,13 @@
#include "common/textconsole.h"
#include "graphics/pixelformat.h"
#include "graphics/surface.h"
- #include "graphics/palette.h"
+#include "graphics/palette.h"
#include "image/codecs/codec.h"
#include "common/util.h"
#include "common/debug.h"
#include "image/codecs/bmp_raw.h"
#include "common/system.h"
-#include "common/events.h"
+
namespace Director {
DIBDecoder::DIBDecoder() {
@@ -78,7 +78,7 @@ void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) {
while (index < 768) {
_palette[index++] = 0;
}
-}
+}
bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) {
@@ -87,36 +87,37 @@ bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) {
Common::hexdump(buf, stream.size());
stream.seek(0);
- if (stream.readByte() != 40)
- return false;
- if (stream.readByte() != 0)
+ uint32 headerSize = stream.readUint32LE();
+ if (headerSize != 40)
return false;
- stream.seek(4);
- uint16 width = stream.readUint32LE();
- uint16 height = stream.readUint32LE();
- stream.seek(32);
- _paletteColorCount = stream.readByte() + (stream.readByte() << 8);
+ uint32 width = stream.readUint32LE();
+ uint32 height = stream.readUint32LE();
+ stream.readUint16LE(); // planes
+ uint16 bitsPerPixel = stream.readUint16LE();
+ uint32 compression = stream.readUint32LE();
+ uint32 imageSize = stream.readUint32LE();
+ /* uint32 pixelsPerMeterX = */ stream.readUint32LE();
+ /* uint32 pixelsPerMeterY = */ stream.readUint32LE();
+ _paletteColorCount = stream.readUint32LE();
+ /* uint32 colorsImportant = */ stream.readUint32LE();
+
_paletteColorCount = (_paletteColorCount == 0) ? 255: _paletteColorCount;
- uint16 totalsize = 14 + stream.size() + 1024;
+
uint16 imageRawSize = stream.size() - 40;
Common::SeekableSubReadStream subStream(&stream, 40, imageRawSize);
- _codec = new Image::BitmapRawDecoder(width, height, 4);
+ warning("w: %d h: %d bpp: %d pal: %d size: %d (size rep: %d) comp: %x", width, height, bitsPerPixel, _paletteColorCount, imageRawSize, imageSize, compression);
+
+ _codec = Image::createBitmapCodec(compression, width, height, bitsPerPixel);
+ if (!_codec)
+ return false;
_surface = _codec->decodeFrame(subStream);
//FIXME
g_system->getPaletteManager()->setPalette(_palette, 0, _paletteColorCount - 1);
- g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 100, 100, 24, 24);
- g_system->updateScreen();
+ g_system->copyRectToScreen(_surface->getPixels(), _surface->pitch, 0, 0, width, height);
- int stop = 0;
-
- while (stop < 100) {
- g_system->delayMillis(50);
- g_system->updateScreen();
- stop++;
- }
return true;
}
diff --git a/engines/director/dib.h b/engines/director/dib.h
index c3243dfd26..e81b32be8e 100644
--- a/engines/director/dib.h
+++ b/engines/director/dib.h
@@ -63,7 +63,7 @@ public:
uint16 getPaletteColorCount() const { return _paletteColorCount; }
private:
- Image::BitmapRawDecoder *_codec;
+ Image::Codec *_codec;
const Graphics::Surface *_surface;
byte *_palette;
uint8 _paletteColorCount;
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index f64af75cea..bf4d4c5f75 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -26,12 +26,15 @@
#include "common/debug.h"
#include "common/scummsys.h"
#include "common/error.h"
+#include "common/events.h"
#include "common/macresman.h"
#include "common/stream.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "director/dib.h"
+#include "engines/util.h"
+
#include "director/director.h"
#include "director/resource.h"
#include "graphics/surface.h"
@@ -51,6 +54,17 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
SearchMan.addSubDirectoryMatching(gameDataDir, "install");
+}
+
+DirectorEngine::~DirectorEngine() {
+ delete _mainArchive;
+ delete _macBinary;
+}
+
+Common::Error DirectorEngine::run() {
+ debug("Starting v%d Director game", getVersion());
+
+ initGraphics(640, 480, true);
//FIXME
RIFFArchive riff;
@@ -63,16 +77,21 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
Common::SeekableReadStream *dib = riff.getResource(MKTAG('D', 'I', 'B', ' '), 1103);
img.loadStream(*dib);
+ bool stop = false;
-}
+ while (!stop) {
+ Common::Event event;
-DirectorEngine::~DirectorEngine() {
- delete _mainArchive;
- delete _macBinary;
-}
+ while (_eventMan->pollEvent(event)) {
+ if (event.type == Common::EVENT_QUIT)
+ stop = true;
+ }
-Common::Error DirectorEngine::run() {
- debug("Starting v%d Director game", getVersion());
+ g_system->updateScreen();
+ g_system->delayMillis(50);
+ }
+
+ return Common::kNoError;
if (getPlatform() == Common::kPlatformWindows)
loadEXE();