diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/disk.h | 9 | ||||
-rw-r--r-- | engines/parallaction/disk_br.cpp | 75 | ||||
-rw-r--r-- | engines/parallaction/disk_ns.cpp | 78 |
3 files changed, 79 insertions, 83 deletions
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index c251882b08..4faa9e666c 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -109,8 +109,7 @@ class DosDisk_ns : public Disk_ns { private: void unpackBackground(Common::ReadStream *stream, byte *screen, byte *mask, byte *path); - Cnv* loadExternalCnv(const char *filename); - Frames* loadCnv(const char *filename); + Cnv* loadCnv(const char *filename); void loadBackground(BackgroundInfo& info, const char *filename); void loadMaskAndPath(BackgroundInfo& info, const char *name); void parseDepths(BackgroundInfo &info, Common::SeekableReadStream &stream); @@ -146,7 +145,7 @@ public: class AmigaDisk_ns : public Disk_ns { protected: - Cnv* makeCnv(Common::SeekableReadStream *stream, bool disposeStream); + Cnv* makeCnv(Common::SeekableReadStream *stream); void patchFrame(byte *dst, byte *dlta, uint16 bytesPerPlane, uint16 height); void unpackFrame(byte *dst, byte *src, uint16 planeSize); void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 bytesPerPlane, uint16 height); @@ -208,7 +207,7 @@ class DosDisk_br : public Disk_br { protected: Font *createFont(const char *name, Common::ReadStream &stream); - Sprites* createSprites(Common::ReadStream &stream); + Sprites* createSprites(Common::ReadStream *stream); void loadBitmap(Common::SeekableReadStream &stream, Graphics::Surface &surf, byte *palette); GfxObj* createInventoryObjects(Common::SeekableReadStream &stream); @@ -250,7 +249,7 @@ public: class AmigaDisk_br : public DosDisk_br { protected: - Sprites* createSprites(Common::ReadStream &stream); + Sprites* createSprites(Common::ReadStream *stream); Font *createFont(const char *name, Common::SeekableReadStream &stream); void loadBackground(BackgroundInfo& info, const char *filename); void adjustForPalette(Graphics::Surface &surf, int transparentColor = -1); diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index 30ef73b27b..e0d498d3df 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -180,13 +180,11 @@ GfxObj* DosDisk_br::loadTalk(const char *name) { // talk position is set to (0,0), because talks are always displayed at // absolute coordinates, set in the dialogue manager. The original used // to null out coordinates every time they were needed. We do it better! - Sprites *spr = createSprites(*stream); + Sprites *spr = createSprites(stream); for (int i = 0; i < spr->getNum(); i++) { spr->_sprites[i].x = 0; spr->_sprites[i].y = 0; } - - delete stream; return new GfxObj(0, spr, name); } @@ -273,33 +271,41 @@ GfxObj* DosDisk_br::loadStatic(const char* name) { return new GfxObj(0, new SurfaceToFrames(surf), name); } -Sprites* DosDisk_br::createSprites(Common::ReadStream &stream) { +Sprites* DosDisk_br::createSprites(Common::ReadStream *stream) { - uint16 num = stream.readUint16LE(); + uint16 num = stream->readUint16LE(); Sprites *sprites = new Sprites(num); for (uint i = 0; i < num; i++) { Sprite *spr = &sprites->_sprites[i]; - spr->size = stream.readUint16LE(); - spr->x = stream.readUint16LE(); - spr->y = stream.readUint16LE(); - spr->w = stream.readUint16LE(); - spr->h = stream.readUint16LE(); + spr->size = stream->readUint16LE(); + spr->x = stream->readUint16LE(); + spr->y = stream->readUint16LE(); + spr->w = stream->readUint16LE(); + spr->h = stream->readUint16LE(); spr->packedData = (byte*)malloc(spr->size); - stream.read(spr->packedData, spr->size); + stream->read(spr->packedData, spr->size); } + delete stream; return sprites; } Frames* DosDisk_br::loadFrames(const char* name) { + Common::SeekableReadStream *stream = 0; + debugC(5, kDebugDisk, "DosDisk_br::loadFrames"); - Common::SeekableReadStream *stream = openFile("ani/" + Common::String(name), ".ani"); - Frames *frames = createSprites(*stream); - delete stream; - return frames; + + Common::String path(name); + if (path.hasSuffix(".win")) { + stream = openFile(path); + } else { + stream = openFile("ani/" + Common::String(name), ".ani"); + } + + return createSprites(stream); } // Slides in Nippon Safes are basically screen-sized pictures with valid @@ -645,32 +651,41 @@ GfxObj* AmigaDisk_br::loadStatic(const char* name) { return new GfxObj(0, new SurfaceToFrames(surf), name); } -Sprites* AmigaDisk_br::createSprites(Common::ReadStream &stream) { - uint16 num = stream.readUint16BE(); +Sprites* AmigaDisk_br::createSprites(Common::ReadStream *stream) { + uint16 num = stream->readUint16BE(); Sprites *sprites = new Sprites(num); for (uint i = 0; i < num; i++) { Sprite *spr = &sprites->_sprites[i]; - spr->size = stream.readUint16BE(); - spr->x = stream.readUint16BE(); - spr->y = stream.readUint16BE(); - spr->w = stream.readUint16BE(); - spr->h = stream.readUint16BE() - 1; + spr->size = stream->readUint16BE(); + spr->x = stream->readUint16BE(); + spr->y = stream->readUint16BE(); + spr->w = stream->readUint16BE(); + spr->h = stream->readUint16BE() - 1; spr->packedData = (byte*)malloc(spr->size); - stream.read(spr->packedData, spr->size); + stream->read(spr->packedData, spr->size); } + delete stream; + return sprites; } Frames* AmigaDisk_br::loadFrames(const char* name) { - debugC(1, kDebugDisk, "AmigaDisk_br::loadFrames '%s'", name); - Common::SeekableReadStream *stream = openFile("anims/" + Common::String(name), ".ani"); - Frames *frames = createSprites(*stream); - delete stream; - return frames; + Common::SeekableReadStream *stream = 0; + + debugC(5, kDebugDisk, "AmigaDisk_br::loadFrames"); + + Common::String path(name); + if (path.hasSuffix(".win")) { + stream = openFile(path); + } else { + stream = openFile("anims/" + Common::String(name), ".ani"); + } + + return createSprites(stream); } GfxObj* AmigaDisk_br::loadTalk(const char *name) { @@ -681,13 +696,11 @@ GfxObj* AmigaDisk_br::loadTalk(const char *name) { // talk position is set to (0,0), because talks are always displayed at // absolute coordinates, set in the dialogue manager. The original used // to null out coordinates every time they were needed. We do it better! - Sprites *spr = createSprites(*stream); + Sprites *spr = createSprites(stream); for (int i = 0; i < spr->getNum(); i++) { spr->_sprites[i].x = 0; spr->_sprites[i].y = 0; } - - delete stream; return new GfxObj(0, spr, name); } diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp index cf3fa681cc..a43b82b5c0 100644 --- a/engines/parallaction/disk_ns.cpp +++ b/engines/parallaction/disk_ns.cpp @@ -267,47 +267,29 @@ Common::SeekableReadStream *DosDisk_ns::tryOpenFile(const char* name) { } -// -// loads a cnv from an external file -// -Cnv* DosDisk_ns::loadExternalCnv(const char *filename) { - - char path[PATH_LEN]; - - sprintf(path, "%s.cnv", filename); - - Common::SeekableReadStream *stream = openFile(path); - - uint16 numFrames = stream->readByte(); - uint16 width = stream->readByte(); - uint16 height = stream->readByte(); - uint32 decsize = numFrames * width * height; - - byte *data = new byte[decsize]; - stream->read(data, decsize); - delete stream; - - return new Cnv(numFrames, width, height, data, true); -} - - -Frames* DosDisk_ns::loadCnv(const char *filename) { - +Cnv* DosDisk_ns::loadCnv(const char *filename) { Common::SeekableReadStream *stream = openFile(filename); uint16 numFrames = stream->readByte(); uint16 width = stream->readByte(); uint16 height = stream->readByte(); - uint32 decsize = numFrames * width * height; + int32 decsize = numFrames * width * height; byte *data = new byte[decsize]; - Graphics::PackBitsReadStream decoder(*stream); - decoder.read(data, decsize); + bool packed = (stream->size() - stream->pos()) != decsize; + if (packed) { + Graphics::PackBitsReadStream decoder(*stream); + decoder.read(data, decsize); + } else { + stream->read(data, decsize); + } + delete stream; return new Cnv(numFrames, width, height, data, true); } + GfxObj* DosDisk_ns::loadTalk(const char *name) { const char *ext = strstr(name, ".talk"); @@ -319,12 +301,12 @@ GfxObj* DosDisk_ns::loadTalk(const char *name) { char v20[30]; if (_engineFlags & kEngineTransformedDonna) { - sprintf(v20, "%stta", name); + sprintf(v20, "%stta.cnv", name); } else { - sprintf(v20, "%stal", name); + sprintf(v20, "%stal.cnv", name); } - return new GfxObj(0, loadExternalCnv(v20), name); + return new GfxObj(0, loadCnv(v20), name); } Script* DosDisk_ns::loadLocation(const char *name) { @@ -355,26 +337,29 @@ GfxObj* DosDisk_ns::loadHead(const char* name) { char path[PATH_LEN]; sprintf(path, "%shead", name); path[8] = '\0'; - return new GfxObj(0, loadExternalCnv(path)); + strcat(path, ".cnv"); + return new GfxObj(0, loadCnv(path)); } Frames* DosDisk_ns::loadPointer(const char *name) { - return loadExternalCnv(name); + char path[PATH_LEN]; + sprintf(path, "%s.cnv", name); + return loadCnv(path); } Font* DosDisk_ns::loadFont(const char* name) { char path[PATH_LEN]; - sprintf(path, "%scnv", name); - return createFont(name, loadExternalCnv(path)); + sprintf(path, "%scnv.cnv", name); + return createFont(name, loadCnv(path)); } GfxObj* DosDisk_ns::loadObjects(const char *name, uint8 part) { char path[PATH_LEN]; - sprintf(path, "%sobj", name); - return new GfxObj(0, loadExternalCnv(path), name); + sprintf(path, "%sobj.cnv", name); + return new GfxObj(0, loadCnv(path), name); } @@ -844,7 +829,7 @@ void AmigaDisk_ns::unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 b } -Cnv* AmigaDisk_ns::makeCnv(Common::SeekableReadStream *stream, bool disposeStream) { +Cnv* AmigaDisk_ns::makeCnv(Common::SeekableReadStream *stream) { assert(stream); uint16 numFrames = stream->readByte(); @@ -867,8 +852,7 @@ Cnv* AmigaDisk_ns::makeCnv(Common::SeekableReadStream *stream, bool disposeStrea free(buf); - if (disposeStream) - delete stream; + delete stream; return new Cnv(numFrames, width, height, data, true); } @@ -901,13 +885,13 @@ Script* AmigaDisk_ns::loadScript(const char* name) { Frames* AmigaDisk_ns::loadPointer(const char* name) { debugC(1, kDebugDisk, "AmigaDisk_ns::loadPointer"); Common::SeekableReadStream *stream = openFile(name); - return makeCnv(stream, true); + return makeCnv(stream); } GfxObj* AmigaDisk_ns::loadStatic(const char* name) { debugC(1, kDebugDisk, "AmigaDisk_ns::loadStatic '%s'", name); Common::SeekableReadStream *s = openFile(name); - return new GfxObj(0, makeCnv(s, true), name); + return new GfxObj(0, makeCnv(s), name); } Common::SeekableReadStream *AmigaDisk_ns::tryOpenFile(const char* name) { @@ -1115,7 +1099,7 @@ Frames* AmigaDisk_ns::loadFrames(const char* name) { if (!s) s = openFile(name); - return makeCnv(s, true); + return makeCnv(s); } GfxObj* AmigaDisk_ns::loadHead(const char* name) { @@ -1123,7 +1107,7 @@ GfxObj* AmigaDisk_ns::loadHead(const char* name) { char path[PATH_LEN]; sprintf(path, "%s.head", name); Common::SeekableReadStream *s = openFile(path); - return new GfxObj(0, makeCnv(s, true), name); + return new GfxObj(0, makeCnv(s), name); } @@ -1137,7 +1121,7 @@ GfxObj* AmigaDisk_ns::loadObjects(const char *name, uint8 part) { sprintf(path, "objs/%s.objs", name); Common::SeekableReadStream *s = openFile(path); - return new GfxObj(0, makeCnv(s, true), name); + return new GfxObj(0, makeCnv(s), name); } @@ -1154,7 +1138,7 @@ GfxObj* AmigaDisk_ns::loadTalk(const char *name) { if (!s) { s = openFile(name); } - return new GfxObj(0, makeCnv(s, true), name); + return new GfxObj(0, makeCnv(s), name); } Table* AmigaDisk_ns::loadTable(const char* name) { |