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 {
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
extern byte _braAmigaFramesDefaultPalette[];
|
2007-07-27 19:02:19 +00:00
|
|
|
|
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;
|
|
|
|
|
2008-12-12 04:52:37 +00:00
|
|
|
Sprites(uint num) : _num(0), _sprites(0) {
|
2007-08-25 20:34:10 +00:00
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
2009-01-23 04:45:44 +00:00
|
|
|
Common::SeekableReadStream *stream = _sset.createReadStreamForMember(lookup);
|
2009-01-08 07:31:32 +00:00
|
|
|
if (stream) {
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
// as a very last resort, try trimming the file name to 8 chars
|
|
|
|
if (!ext.empty() && lookup.hasSuffix(ext.c_str())) {
|
|
|
|
Common::String filename = Common::lastPathComponent(lookup, '/');
|
|
|
|
int len = filename.size();
|
|
|
|
if (len > 8) {
|
|
|
|
debugC(9, kDebugDisk, "Disk_br::openFile: trimming filename (%s) to 8 characters", name.c_str());
|
|
|
|
while (len-- > 8) {
|
|
|
|
lookup.deleteLastChar();
|
|
|
|
}
|
|
|
|
lookup += ext;
|
2009-01-23 04:45:44 +00:00
|
|
|
stream = _sset.createReadStreamForMember(lookup);
|
2009-01-08 07:31:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
if (!stream && errorOnNotFound) {
|
2009-01-08 07:31:32 +00:00
|
|
|
errorFileNotFound(name);
|
2008-10-12 07:01:09 +00:00
|
|
|
}
|
|
|
|
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"));
|
2008-12-07 12:41:50 +00:00
|
|
|
_sset.add("base", _baseDir, 5, true);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-15 09:29:25 +00:00
|
|
|
GfxObj* DosDisk_br::loadObjects(const char *name, uint8 part) {
|
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
|
|
|
}
|
|
|
|
|
2009-01-07 08:16:18 +00:00
|
|
|
void DosDisk_br::loadPath(const char *name, PathBuffer &buffer) {
|
|
|
|
if (!name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *stream = openFile("pth/" + Common::String(name), ".pth");
|
|
|
|
|
|
|
|
// NOTE: info.width and info.height are only valid if the background graphics
|
|
|
|
// have already been loaded
|
|
|
|
buffer.bigEndian = false;
|
|
|
|
stream->read(buffer.data, buffer.size);
|
|
|
|
delete stream;
|
|
|
|
}
|
|
|
|
|
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) {
|
2009-01-07 07:35:11 +00:00
|
|
|
info._mask = new MaskBuffer;
|
|
|
|
info._mask->create(info.width, info.height);
|
|
|
|
loadMask(mask, *info._mask);
|
2007-08-12 19:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (path) {
|
2009-01-07 08:16:18 +00:00
|
|
|
info._path = new PathBuffer;
|
|
|
|
info._path->create(info.width, info.height);
|
|
|
|
loadPath(path, *info._path);
|
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");
|
2009-03-14 17:02:28 +00:00
|
|
|
return openFile("msc/" + Common::String(name), ".msc");
|
2007-07-27 19:02:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
void AmigaDisk_br::adjustForPalette(Graphics::Surface &surf, int move) {
|
|
|
|
uint size = surf.w * surf.h;
|
|
|
|
byte *data = (byte*)surf.pixels;
|
|
|
|
for (uint i = 0; i < size; i++, data++) {
|
|
|
|
*data += move;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
int i;
|
2008-04-06 07:05:56 +00:00
|
|
|
|
|
|
|
info.width = info.bg.w;
|
|
|
|
info.height = info.bg.h;
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
/* TODO: support loading of additional palette (*.ap files), for locations which
|
|
|
|
have them. If an additional palette is present then it is used in place of
|
|
|
|
_braAmigaFramesDefaultPalette.
|
|
|
|
*/
|
|
|
|
byte r,g,b;
|
|
|
|
byte *p = _braAmigaFramesDefaultPalette;
|
2008-04-17 09:30:04 +00:00
|
|
|
for (i = 0; i < 16; i++) {
|
2009-03-16 09:11:51 +00:00
|
|
|
r = *p >> 2;
|
|
|
|
p++;
|
|
|
|
g = *p >> 2;
|
|
|
|
p++;
|
|
|
|
b = *p >> 2;
|
|
|
|
p++;
|
|
|
|
info.palette.setEntry(i, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
p = pal;
|
|
|
|
for (i = 16; i < 32; i++) {
|
|
|
|
r = *p >> 2;
|
2008-04-06 07:05:56 +00:00
|
|
|
p++;
|
2009-03-16 09:11:51 +00:00
|
|
|
g = *p >> 2;
|
2008-04-06 07:05:56 +00:00
|
|
|
p++;
|
2009-03-16 09:11:51 +00:00
|
|
|
b = *p >> 2;
|
2008-04-06 07:05:56 +00:00
|
|
|
p++;
|
|
|
|
info.palette.setEntry(i, r, g, b);
|
|
|
|
}
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
#if 0
|
|
|
|
// The first entry in the palette is overwritten in the original, but I could not
|
|
|
|
// find any difference so far.
|
|
|
|
info.palette.setEntry(0, pal[0] >> 2, pal[1] >> 2, pal[2] >> 0);
|
|
|
|
#endif
|
2008-04-06 07:05:56 +00:00
|
|
|
free(pal);
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
// background data is drawn used the upper portion of the palette
|
|
|
|
adjustForPalette(info.bg, 16);
|
2008-04-06 07:05:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-16 23:58:19 +00:00
|
|
|
void AmigaDisk_br::loadMask(const char *name, MaskBuffer &buffer) {
|
|
|
|
if (!name) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *stream = openFile("msk/" + Common::String(name), ".msk");
|
|
|
|
|
|
|
|
byte *pal = 0;
|
|
|
|
Graphics::Surface* surf = new Graphics::Surface;
|
|
|
|
Graphics::ILBMDecoder decoder(*stream, *surf, pal);
|
|
|
|
decoder.decode();
|
|
|
|
free(pal);
|
|
|
|
|
|
|
|
buffer.create(surf->w, surf->h);
|
|
|
|
memcpy(buffer.data, surf->pixels, buffer.size);
|
|
|
|
buffer.bigEndian = false;
|
|
|
|
delete stream;
|
|
|
|
}
|
|
|
|
|
2008-04-06 07:05:56 +00:00
|
|
|
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
|
|
|
}
|
2009-03-15 06:07:57 +00:00
|
|
|
if (mask) {
|
2009-03-16 23:58:19 +00:00
|
|
|
#if 0
|
|
|
|
info._mask = new MaskBuffer;
|
|
|
|
loadMask(mask, *info._mask);
|
2008-07-31 14:20:51 +00:00
|
|
|
#endif
|
2009-03-16 23:58:19 +00:00
|
|
|
}
|
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
if (path) {
|
2009-03-16 23:58:19 +00:00
|
|
|
info._path = new PathBuffer;
|
|
|
|
info._path->create(info.width, info.height);
|
|
|
|
loadPath(path, *info._path);
|
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();
|
|
|
|
|
2009-03-16 09:11:51 +00:00
|
|
|
// static pictures are drawn used the upper half of the palette
|
|
|
|
adjustForPalette(*surf, 16);
|
|
|
|
|
2008-05-04 15:06:47 +00:00
|
|
|
free(pal);
|
2008-10-12 07:01:09 +00:00
|
|
|
delete stream;
|
2008-05-04 15:06:47 +00:00
|
|
|
|
2009-03-16 23:58:19 +00:00
|
|
|
return new GfxObj(0, new SurfaceToFrames(surf), name);
|
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);
|
2009-03-16 14:35:18 +00:00
|
|
|
|
2008-10-12 07:01:09 +00:00
|
|
|
Common::SeekableReadStream *stream = openFile("talks/" + Common::String(name), ".tal");
|
2009-03-16 14:35:18 +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!
|
|
|
|
Sprites *spr = createSprites(*stream);
|
|
|
|
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;
|
2009-03-16 14:35:18 +00:00
|
|
|
return new GfxObj(0, spr, name);
|
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");
|
2009-03-15 06:07:57 +00:00
|
|
|
return tryOpenFile("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
|
|
|
}
|
|
|
|
|
2009-03-15 09:29:25 +00:00
|
|
|
static const uint16 objectsMax[5] = {
|
|
|
|
5, 73, 71, 19, 48
|
|
|
|
};
|
|
|
|
|
|
|
|
GfxObj* AmigaDisk_br::loadObjects(const char *name, uint8 part) {
|
2008-07-28 05:18:23 +00:00
|
|
|
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);
|
|
|
|
|
2009-03-15 09:29:25 +00:00
|
|
|
uint16 max = objectsMax[part];
|
2009-03-15 09:51:02 +00:00
|
|
|
if (_vm->getFeatures() & GF_DEMO)
|
|
|
|
max = 72;
|
|
|
|
|
2009-03-15 09:29:25 +00:00
|
|
|
byte *data = new byte[max * 2601];
|
|
|
|
|
|
|
|
// Convert to the expected display format
|
|
|
|
for (int i = 0; i < max; i++) {
|
|
|
|
uint16 x = (i % 8) * 51;
|
|
|
|
uint16 y = (i / 8) * 51;
|
|
|
|
|
|
|
|
byte *src = (byte *)surf->getBasePtr(x, y);
|
|
|
|
byte *dst = data + i * 2601;
|
|
|
|
for (int h = 0; h < 51; h++) {
|
|
|
|
memcpy(dst, src, 51);
|
|
|
|
src += surf->w;
|
|
|
|
dst += 51;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new GfxObj(0, new Cnv(max, 51, 51, data, true));
|
2008-07-28 05:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|