2007-07-27 19:02:19 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-04-06 07:05:56 +00:00
|
|
|
#include "graphics/iff.h"
|
|
|
|
|
2008-07-28 05:18:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2007-07-27 19:02:19 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
struct Sprite {
|
|
|
|
uint16 size;
|
|
|
|
uint16 x;
|
|
|
|
uint16 y;
|
|
|
|
uint16 w;
|
|
|
|
uint16 h;
|
|
|
|
|
|
|
|
byte *packedData;
|
|
|
|
|
|
|
|
Sprite() : size(0), x(0), y(0), w(0), h(0), packedData(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
~Sprite() {
|
2007-11-18 13:22:38 +00:00
|
|
|
free(packedData);
|
2007-08-25 20:34:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sprites : public Frames {
|
|
|
|
uint16 _num;
|
|
|
|
Sprite* _sprites;
|
|
|
|
|
|
|
|
Sprites(uint num) {
|
|
|
|
_num = num;
|
|
|
|
_sprites = new Sprite[_num];
|
|
|
|
}
|
|
|
|
|
|
|
|
~Sprites() {
|
2008-07-10 02:00:54 +00:00
|
|
|
delete[] _sprites;
|
2007-08-25 20:34:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16 getNum() {
|
|
|
|
return _num;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte* getData(uint16 index) {
|
|
|
|
assert(index < _num);
|
|
|
|
return _sprites[index].packedData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void getRect(uint16 index, Common::Rect &r) {
|
|
|
|
assert(index < _num);
|
|
|
|
r.setWidth(_sprites[index].w);
|
|
|
|
r.setHeight(_sprites[index].h);
|
|
|
|
r.moveTo(_sprites[index].x, _sprites[index].y);
|
2008-02-03 10:48:07 +00:00
|
|
|
}
|
|
|
|
uint getRawSize(uint16 index) {
|
|
|
|
assert(index < _num);
|
|
|
|
return _sprites[index].size;
|
|
|
|
}
|
|
|
|
uint getSize(uint16 index) {
|
|
|
|
assert(index < _num);
|
|
|
|
return _sprites[index].w * _sprites[index].h;
|
|
|
|
}
|
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *Disk_br::openFile_internal(bool errorOnNotFound, const Common::String &name, const Common::String &ext) {
|
|
|
|
assert(!name.empty());
|
|
|
|
debugC(5, kDebugDisk, "Disk_br::openFile(%s, %s)", name.c_str(), ext.c_str());
|
2007-08-25 20:34:10 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::String lookup(name);
|
2007-08-25 20:34:10 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
if (!ext.empty() && !name.hasSuffix(ext.c_str())) {
|
|
|
|
// make sure we are using the specified extension
|
|
|
|
debugC(9, kDebugDisk, "Disk_br::openFile: appending explicit extension (%s) to (%s)", ext.c_str(), name.c_str());
|
|
|
|
lookup = name + ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *stream = _sset.openFile(lookup);
|
|
|
|
if (!stream && errorOnNotFound) {
|
|
|
|
errorFileNotFound(lookup);
|
|
|
|
}
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *Disk_br::openFile(const Common::String &name, const Common::String &ext) {
|
|
|
|
return openFile_internal(true, name, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *Disk_br::tryOpenFile(const Common::String &name, const Common::String &ext) {
|
|
|
|
return openFile_internal(false, name, ext);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Disk_br::errorFileNotFound(const Common::String &filename) {
|
|
|
|
error("File '%s' not found", filename.c_str());
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::String DosDisk_br::selectArchive(const Common::String& name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::selectArchive");
|
2007-08-12 13:21:45 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::String oldPath = _currentPart;
|
|
|
|
_currentPart = name;
|
2008-07-28 05:18:23 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::selectArchive: adding part directory to search set");
|
|
|
|
_sset.remove("part");
|
2008-10-22 17:44:12 +00:00
|
|
|
_sset.add("part", _baseDir->getSubDirectory(name, 3), 10);
|
2007-08-12 13:21:45 +00:00
|
|
|
|
|
|
|
return oldPath;
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DosDisk_br::setLanguage(uint16 language) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::setLanguage");
|
2008-07-28 05:18:23 +00:00
|
|
|
assert(language < 4);
|
|
|
|
_language = language;
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
2008-10-26 09:15:57 +00:00
|
|
|
DosDisk_br::DosDisk_br(Parallaction* vm) : Disk_br(vm) {
|
2008-10-12 07:01:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DosDisk_br::init() {
|
|
|
|
// TODO: clarify whether the engine or OSystem should add the base game directory to the search manager.
|
|
|
|
// Right now, I am keeping an internal search set to do the job.
|
2008-10-26 09:15:57 +00:00
|
|
|
_baseDir = new Common::FSDirectory(ConfMan.get("path"));
|
|
|
|
_sset.add("base", _baseDir, 5, false);
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
|
2008-06-29 09:30:32 +00:00
|
|
|
GfxObj* DosDisk_br::loadTalk(const char *name) {
|
2008-06-04 09:07:55 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadTalk(%s)", name);
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("tal/" + Common::String(name), ".tal");
|
2008-07-29 03:14:35 +00:00
|
|
|
|
|
|
|
// 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!
|
2008-10-12 07:01:09 +00:00
|
|
|
Sprites *spr = createSprites(*stream);
|
2008-07-29 03:14:35 +00:00
|
|
|
for (int i = 0; i < spr->getNum(); i++) {
|
|
|
|
spr->_sprites[i].x = 0;
|
|
|
|
spr->_sprites[i].y = 0;
|
|
|
|
}
|
2008-10-12 07:01:09 +00:00
|
|
|
|
|
|
|
delete stream;
|
2008-07-29 03:14:35 +00:00
|
|
|
return new GfxObj(0, spr, name);
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Script* DosDisk_br::loadLocation(const char *name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadLocation");
|
2007-08-12 13:47:19 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
static const Common::String langs[4] = { "it/", "fr/", "en/", "ge/" };
|
2008-07-28 05:18:23 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::String fullName(name);
|
|
|
|
if (!fullName.hasSuffix(".slf")) {
|
|
|
|
fullName += ".loc";
|
2007-08-12 13:54:31 +00:00
|
|
|
}
|
2007-08-12 13:47:19 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(langs[_language] + fullName);
|
2007-08-12 19:11:37 +00:00
|
|
|
return new Script(stream, true);
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Script* DosDisk_br::loadScript(const char* name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadScript");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("scripts/" + Common::String(name), ".scr");
|
2007-08-24 20:14:51 +00:00
|
|
|
return new Script(stream, true);
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// there are no Head resources in Big Red Adventure
|
2008-06-29 09:30:32 +00:00
|
|
|
GfxObj* DosDisk_br::loadHead(const char* name) {
|
2007-07-27 19:02:19 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadHead");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-03 16:51:38 +00:00
|
|
|
void DosDisk_br::loadBitmap(Common::SeekableReadStream &stream, Graphics::Surface &surf, byte *palette) {
|
|
|
|
stream.skip(4);
|
|
|
|
uint width = stream.readUint32BE();
|
2008-07-28 14:02:46 +00:00
|
|
|
if (width & 1) width++;
|
2008-02-03 16:51:38 +00:00
|
|
|
uint height = stream.readUint32BE();
|
|
|
|
stream.skip(20);
|
|
|
|
|
|
|
|
if (palette) {
|
|
|
|
stream.read(palette, 768);
|
|
|
|
} else {
|
|
|
|
stream.skip(768);
|
|
|
|
}
|
|
|
|
|
|
|
|
surf.create(width, height, 1);
|
|
|
|
stream.read(surf.pixels, width * height);
|
|
|
|
}
|
2007-07-27 19:02:19 +00:00
|
|
|
|
2007-11-22 21:51:33 +00:00
|
|
|
Frames* DosDisk_br::loadPointer(const char *name) {
|
2007-07-27 19:02:19 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadPointer");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(Common::String(name), ".ras");
|
2007-08-11 21:08:08 +00:00
|
|
|
Graphics::Surface *surf = new Graphics::Surface;
|
2008-10-12 07:01:09 +00:00
|
|
|
loadBitmap(*stream, *surf, 0);
|
|
|
|
delete stream;
|
2007-11-22 21:51:33 +00:00
|
|
|
return new SurfaceToFrames(surf);
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Font* DosDisk_br::loadFont(const char* name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadFont");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(name, ".fnt");
|
|
|
|
Font *font = createFont(name, *stream);
|
|
|
|
delete stream;
|
|
|
|
return font;
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-29 09:30:32 +00:00
|
|
|
GfxObj* DosDisk_br::loadObjects(const char *name) {
|
2007-07-27 19:02:19 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadObjects");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(name);
|
|
|
|
GfxObj *obj = createInventoryObjects(*stream);
|
|
|
|
delete stream;
|
|
|
|
return obj;
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
void genSlidePath(char *path, const char* name) {
|
|
|
|
sprintf(path, "%s.bmp", name);
|
|
|
|
}
|
2007-07-27 19:02:19 +00:00
|
|
|
|
2008-06-29 09:30:32 +00:00
|
|
|
GfxObj* DosDisk_br::loadStatic(const char* name) {
|
2007-07-27 19:02:19 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadStatic");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("ras/" + Common::String(name), ".ras");
|
2008-02-03 16:51:38 +00:00
|
|
|
Graphics::Surface *surf = new Graphics::Surface;
|
2008-10-12 07:01:09 +00:00
|
|
|
loadBitmap(*stream, *surf, 0);
|
|
|
|
delete stream;
|
2008-06-29 09:30:32 +00:00
|
|
|
return new GfxObj(0, new SurfaceToFrames(surf), name);
|
2007-08-11 14:18:00 +00:00
|
|
|
}
|
|
|
|
|
2008-06-04 09:07:55 +00:00
|
|
|
Sprites* DosDisk_br::createSprites(Common::ReadStream &stream) {
|
2007-08-25 20:34:10 +00:00
|
|
|
|
|
|
|
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->packedData = (byte*)malloc(spr->size);
|
|
|
|
stream.read(spr->packedData, spr->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sprites;
|
|
|
|
}
|
|
|
|
|
2008-07-03 10:31:25 +00:00
|
|
|
Frames* DosDisk_br::loadFrames(const char* name) {
|
2007-08-11 14:18:00 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadFrames");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("ani/" + Common::String(name), ".ani");
|
|
|
|
Frames *frames = createSprites(*stream);
|
|
|
|
delete stream;
|
|
|
|
return frames;
|
2007-08-11 14:18:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Slides in Nippon Safes are basically screen-sized pictures with valid
|
|
|
|
// palette data used for menu and for location switches. Big Red Adventure
|
|
|
|
// doesn't need slides in that sense, but it still has some special
|
|
|
|
// graphics resources with palette data, so those will be named slides.
|
|
|
|
//
|
2007-08-12 17:13:21 +00:00
|
|
|
void DosDisk_br::loadSlide(BackgroundInfo& info, const char *name) {
|
2007-08-11 14:18:00 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadSlide");
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(name, ".bmp");
|
2007-08-09 19:26:20 +00:00
|
|
|
|
|
|
|
byte rgb[768];
|
2008-02-03 16:51:38 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
loadBitmap(*stream, info.bg, rgb);
|
2008-02-03 16:51:38 +00:00
|
|
|
info.width = info.bg.w;
|
|
|
|
info.height = info.bg.h;
|
2007-08-09 19:26:20 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
delete stream;
|
|
|
|
|
2007-08-09 19:26:20 +00:00
|
|
|
for (uint i = 0; i < 256; i++) {
|
2007-08-12 17:13:21 +00:00
|
|
|
info.palette.setEntry(i, rgb[i] >> 2, rgb[i+256] >> 2, rgb[i+512] >> 2);
|
2007-08-09 19:26:20 +00:00
|
|
|
}
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
2008-08-15 14:25:43 +00:00
|
|
|
void DosDisk_br::loadMask(const char *name, MaskBuffer &buffer) {
|
|
|
|
if (!name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("msk/" + Common::String(name), ".msk");
|
2008-08-15 14:25:43 +00:00
|
|
|
|
|
|
|
// NOTE: info.width and info.height are only valid if the background graphics
|
|
|
|
// have already been loaded
|
|
|
|
buffer.bigEndian = false;
|
2008-10-12 07:01:09 +00:00
|
|
|
stream->read(buffer.data, buffer.size);
|
|
|
|
delete stream;
|
2008-08-15 14:25:43 +00:00
|
|
|
}
|
|
|
|
|
2007-08-12 17:13:21 +00:00
|
|
|
void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char *mask, const char* path) {
|
2007-07-27 19:02:19 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadScenery");
|
2007-08-12 19:11:37 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream;
|
2007-08-12 19:11:37 +00:00
|
|
|
|
|
|
|
if (name) {
|
2008-10-12 07:01:09 +00:00
|
|
|
stream = openFile("bkg/" + Common::String(name), ".bkg");
|
2007-08-12 19:11:37 +00:00
|
|
|
byte rgb[768];
|
2008-02-03 16:51:38 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
loadBitmap(*stream, info.bg, rgb);
|
2008-02-03 16:51:38 +00:00
|
|
|
info.width = info.bg.w;
|
|
|
|
info.height = info.bg.h;
|
2007-08-12 19:11:37 +00:00
|
|
|
|
|
|
|
for (uint i = 0; i < 256; i++) {
|
|
|
|
info.palette.setEntry(i, rgb[i] >> 2, rgb[i+256] >> 2, rgb[i+512] >> 2);
|
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
delete stream;
|
2007-08-12 19:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mask) {
|
|
|
|
info.mask.create(info.width, info.height);
|
2008-10-12 07:01:09 +00:00
|
|
|
loadMask(mask, info.mask);
|
2007-08-12 19:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (path) {
|
2008-10-12 07:01:09 +00:00
|
|
|
stream = openFile("pth/" + Common::String(path), ".pth");
|
2007-08-12 19:11:37 +00:00
|
|
|
|
|
|
|
// NOTE: info.width and info.height are only valid if the background graphics
|
|
|
|
// have already been loaded
|
|
|
|
info.path.create(info.width, info.height);
|
2008-10-12 07:01:09 +00:00
|
|
|
stream->read(info.path.data, info.path.size);
|
|
|
|
delete stream;
|
2007-08-12 19:11:37 +00:00
|
|
|
}
|
|
|
|
|
2007-08-12 17:13:21 +00:00
|
|
|
return;
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Table* DosDisk_br::loadTable(const char* name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadTable");
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(name, ".tab");
|
|
|
|
Table *t = createTableFromStream(100, *stream);
|
|
|
|
delete stream;
|
2007-08-24 20:14:51 +00:00
|
|
|
return t;
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
2007-07-28 07:52:24 +00:00
|
|
|
Common::SeekableReadStream* DosDisk_br::loadMusic(const char* name) {
|
2007-07-27 19:02:19 +00:00
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadMusic");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Common::ReadStream* DosDisk_br::loadSound(const char* name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDisk_br::loadSound");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-06 07:05:56 +00:00
|
|
|
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
DosDemoDisk_br::DosDemoDisk_br(Parallaction *vm) : DosDisk_br(vm) {
|
2008-07-28 07:20:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
void DosDemoDisk_br::init() {
|
|
|
|
// TODO: clarify whether the engine or OSystem should add the base game directory to the search manager.
|
|
|
|
// Right now, I am keeping an internal search set to do the job.
|
2008-10-26 09:15:57 +00:00
|
|
|
_baseDir = new Common::FSDirectory(ConfMan.get("path"), 2);
|
|
|
|
_sset.add("base", _baseDir, 5, false);
|
2008-07-28 07:20:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::String DosDemoDisk_br::selectArchive(const Common::String& name) {
|
|
|
|
debugC(5, kDebugDisk, "DosDemoDisk_br::selectArchive");
|
|
|
|
Common::String oldPath = _currentPart;
|
|
|
|
_currentPart = name;
|
2008-07-28 07:20:55 +00:00
|
|
|
return oldPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-06 07:05:56 +00:00
|
|
|
AmigaDisk_br::AmigaDisk_br(Parallaction *vm) : DosDisk_br(vm) {
|
2008-10-12 07:01:09 +00:00
|
|
|
}
|
2008-04-06 07:05:56 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
void AmigaDisk_br::init() {
|
2008-10-26 09:15:57 +00:00
|
|
|
_baseDir = new Common::FSDirectory(ConfMan.get("path"));
|
|
|
|
_sset.add("base", _baseDir, 5, false);
|
2008-07-28 05:18:23 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
const Common::String subDirNames[3] = { "fonts", "backs", "common" };
|
|
|
|
const Common::String subDirPrefixes[3] = { "fonts", "backs", Common::String::emptyString };
|
2008-10-22 17:44:12 +00:00
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
_sset.add(subDirNames[i], _baseDir->getSubDirectory(subDirPrefixes[i], subDirNames[i], 2), 6);
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
2008-07-28 05:18:23 +00:00
|
|
|
void AmigaDisk_br::loadBackground(BackgroundInfo& info, Common::SeekableReadStream &stream) {
|
2008-04-06 07:05:56 +00:00
|
|
|
|
|
|
|
byte *pal;
|
|
|
|
|
2008-07-28 05:18:23 +00:00
|
|
|
Graphics::ILBMDecoder decoder(stream, info.bg, pal);
|
2008-04-06 07:05:56 +00:00
|
|
|
decoder.decode();
|
|
|
|
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
info.width = info.bg.w;
|
|
|
|
info.height = info.bg.h;
|
|
|
|
|
|
|
|
byte *p = pal;
|
2008-04-17 09:30:04 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2008-04-06 07:05:56 +00:00
|
|
|
byte r = *p >> 2;
|
|
|
|
p++;
|
|
|
|
byte g = *p >> 2;
|
|
|
|
p++;
|
|
|
|
byte b = *p >> 2;
|
|
|
|
p++;
|
|
|
|
info.palette.setEntry(i, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pal);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AmigaDisk_br::loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path) {
|
|
|
|
debugC(1, kDebugDisk, "AmigaDisk_br::loadScenery '%s', '%s' '%s'", name, mask, path);
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream;
|
2008-04-06 07:05:56 +00:00
|
|
|
|
|
|
|
if (name) {
|
2008-10-12 07:01:09 +00:00
|
|
|
stream = openFile("backs/" + Common::String(name), ".bkg");
|
|
|
|
loadBackground(info, *stream);
|
|
|
|
delete stream;
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
2008-07-31 14:20:51 +00:00
|
|
|
#if 0
|
2008-07-28 06:18:39 +00:00
|
|
|
if (mask && _mskDir.exists()) {
|
|
|
|
filepath = Common::String(mask) + ".msk";
|
2008-07-28 05:18:23 +00:00
|
|
|
node = _mskDir.getChild(filepath);
|
|
|
|
if (!node.exists()) {
|
2008-07-29 04:00:07 +00:00
|
|
|
filepath = Common::String(mask) + ".msk";
|
|
|
|
node = _commonMskDir.getChild(filepath);
|
2008-07-28 05:18:23 +00:00
|
|
|
}
|
2008-07-29 04:06:10 +00:00
|
|
|
|
|
|
|
if (node.exists()) {
|
|
|
|
stream.open(node);
|
2008-07-31 14:20:51 +00:00
|
|
|
stream.seek(0x30, SEEK_SET);
|
|
|
|
Graphics::PackBitsReadStream unpackedStream(stream);
|
|
|
|
info.mask.create(info.width, info.height);
|
|
|
|
unpackedStream.read(info.mask.data, info.mask.size);
|
|
|
|
// TODO: there is another step to do after decompression...
|
2008-07-29 04:06:10 +00:00
|
|
|
loadMask(info, stream);
|
|
|
|
stream.close();
|
|
|
|
}
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
2008-07-31 14:20:51 +00:00
|
|
|
#endif
|
2008-10-12 07:01:09 +00:00
|
|
|
if (path) {
|
|
|
|
stream = tryOpenFile("pth/" + Common::String(path), ".pth");
|
|
|
|
if (stream) {
|
|
|
|
// NOTE: info.width and info.height are only valid if the background graphics
|
|
|
|
// have already been loaded
|
|
|
|
info.path.create(info.width, info.height);
|
|
|
|
stream->read(info.path.data, info.path.size);
|
|
|
|
delete stream;
|
|
|
|
} else {
|
|
|
|
debugC(1, kDebugDisk, "AmigaDisk_br::loadScenery: (%s) not found", path);
|
2008-07-28 05:18:23 +00:00
|
|
|
}
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AmigaDisk_br::loadSlide(BackgroundInfo& info, const char *name) {
|
|
|
|
debugC(1, kDebugDisk, "AmigaDisk_br::loadSlide '%s'", name);
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("backs/" + Common::String(name), ".bkg");
|
|
|
|
loadBackground(info, *stream);
|
|
|
|
delete stream;
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
2008-06-29 09:30:32 +00:00
|
|
|
GfxObj* AmigaDisk_br::loadStatic(const char* name) {
|
2008-04-06 07:05:56 +00:00
|
|
|
debugC(1, kDebugDisk, "AmigaDisk_br::loadStatic '%s'", name);
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("ras/" + Common::String(name), ".ras");
|
2008-04-06 07:05:56 +00:00
|
|
|
|
2008-05-04 15:06:47 +00:00
|
|
|
byte *pal = 0;
|
|
|
|
Graphics::Surface* surf = new Graphics::Surface;
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Graphics::ILBMDecoder decoder(*stream, *surf, pal);
|
2008-05-04 15:06:47 +00:00
|
|
|
decoder.decode();
|
|
|
|
|
|
|
|
free(pal);
|
2008-10-12 07:01:09 +00:00
|
|
|
delete stream;
|
2008-05-04 15:06:47 +00:00
|
|
|
|
2008-06-29 09:30:32 +00:00
|
|
|
return new GfxObj(0, new SurfaceToFrames(surf));
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 10:36:26 +00:00
|
|
|
Sprites* AmigaDisk_br::createSprites(Common::ReadStream &stream) {
|
2008-04-06 07:05:56 +00:00
|
|
|
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();
|
|
|
|
|
|
|
|
// TODO: Convert image format
|
|
|
|
spr->packedData = (byte*)malloc(spr->size);
|
|
|
|
stream.read(spr->packedData, spr->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sprites;
|
|
|
|
}
|
|
|
|
|
2008-07-03 10:31:25 +00:00
|
|
|
Frames* AmigaDisk_br::loadFrames(const char* name) {
|
2008-04-06 07:05:56 +00:00
|
|
|
debugC(1, kDebugDisk, "AmigaDisk_br::loadFrames '%s'", name);
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("anims/" + Common::String(name), ".ani");
|
|
|
|
Frames *frames = createSprites(*stream);
|
|
|
|
delete stream;
|
|
|
|
return frames;
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
2008-06-29 09:30:32 +00:00
|
|
|
GfxObj* AmigaDisk_br::loadTalk(const char *name) {
|
2008-04-06 07:05:56 +00:00
|
|
|
debugC(1, kDebugDisk, "AmigaDisk_br::loadTalk '%s'", name);
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("talks/" + Common::String(name), ".tal");
|
|
|
|
GfxObj* obj = new GfxObj(0, createSprites(*stream));
|
|
|
|
delete stream;
|
|
|
|
return obj;
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Font* AmigaDisk_br::loadFont(const char* name) {
|
|
|
|
debugC(1, kDebugDisk, "AmigaFullDisk::loadFont '%s'", name);
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("fonts/" + Common::String(name), ".font");
|
2008-07-28 05:18:23 +00:00
|
|
|
|
|
|
|
Common::String fontDir;
|
|
|
|
Common::String fontFile;
|
|
|
|
byte ch;
|
2008-04-06 07:05:56 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
stream->seek(4, SEEK_SET);
|
|
|
|
while ((ch = stream->readByte()) != 0x2F) fontDir += ch;
|
|
|
|
while ((ch = stream->readByte()) != 0) fontFile += ch;
|
|
|
|
delete stream;
|
2008-07-28 05:18:23 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
stream = openFile("fonts/" + fontDir + "/" + fontFile);
|
|
|
|
Font *font = createFont(name, *stream);
|
2008-07-28 05:18:23 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
delete stream;
|
|
|
|
return font;
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
2008-07-27 10:43:15 +00:00
|
|
|
Common::SeekableReadStream* AmigaDisk_br::loadMusic(const char* name) {
|
|
|
|
debugC(5, kDebugDisk, "AmigaDisk_br::loadMusic");
|
2008-10-12 07:01:09 +00:00
|
|
|
return openFile("msc/" + Common::String(name), ".msc");
|
2008-07-27 10:43:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Common::ReadStream* AmigaDisk_br::loadSound(const char* name) {
|
|
|
|
debugC(5, kDebugDisk, "AmigaDisk_br::loadSound");
|
2008-10-12 07:01:09 +00:00
|
|
|
return openFile("sfx/" + Common::String(name), ".sfx");
|
2008-07-27 10:43:15 +00:00
|
|
|
}
|
|
|
|
|
2008-07-28 05:18:23 +00:00
|
|
|
GfxObj* AmigaDisk_br::loadObjects(const char *name) {
|
|
|
|
debugC(5, kDebugDisk, "AmigaDisk_br::loadObjects");
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile(name);
|
2008-07-28 05:18:23 +00:00
|
|
|
|
|
|
|
byte *pal = 0;
|
|
|
|
Graphics::Surface* surf = new Graphics::Surface;
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Graphics::ILBMDecoder decoder(*stream, *surf, pal);
|
2008-07-28 05:18:23 +00:00
|
|
|
decoder.decode();
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
delete stream;
|
2008-07-28 05:18:23 +00:00
|
|
|
free(pal);
|
|
|
|
|
|
|
|
return new GfxObj(0, new SurfaceToFrames(surf));
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String AmigaDisk_br::selectArchive(const Common::String& name) {
|
|
|
|
debugC(5, kDebugDisk, "AmigaDisk_br::selectArchive");
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::String oldPath = _currentPart;
|
|
|
|
_currentPart = name;
|
2008-07-28 05:18:23 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
debugC(5, kDebugDisk, "AmigaDisk_br::selectArchive: adding part directory to search set");
|
|
|
|
_sset.remove("part");
|
2008-10-22 17:44:12 +00:00
|
|
|
_sset.add("part", _baseDir->getSubDirectory(name, 3), 10);
|
2008-07-28 05:18:23 +00:00
|
|
|
|
|
|
|
return oldPath;
|
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
|
2008-10-26 09:15:57 +00:00
|
|
|
Disk_br::Disk_br(Parallaction *vm) : _vm(vm), _baseDir(0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Disk_br::~Disk_br() {
|
|
|
|
_sset.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-27 19:02:19 +00:00
|
|
|
} // namespace Parallaction
|