Skip to content

Commit

Permalink
DIRECTOR: Fix image loading, moved displaying to the engine
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Aug 3, 2016
1 parent c2414ae commit 1a3d44e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
45 changes: 23 additions & 22 deletions engines/director/dib.cpp
Expand Up @@ -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() {
Expand Down Expand Up @@ -78,7 +78,7 @@ void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) {
while (index < 768) {
_palette[index++] = 0;
}
}
}

bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) {

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/director/dib.h
Expand Up @@ -63,7 +63,7 @@ class DIBDecoder : public Image::ImageDecoder {
uint16 getPaletteColorCount() const { return _paletteColorCount; }

private:
Image::BitmapRawDecoder *_codec;
Image::Codec *_codec;
const Graphics::Surface *_surface;
byte *_palette;
uint8 _paletteColorCount;
Expand Down
33 changes: 26 additions & 7 deletions engines/director/director.cpp
Expand Up @@ -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"
Expand All @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit 1a3d44e

Please sign in to comment.