aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2008-07-28 05:18:23 +0000
committerNicola Mettifogo2008-07-28 05:18:23 +0000
commit03ffd60054141dfee971232e935cf6d75c737700 (patch)
treee2689190020a4b33df421de789ffcd9f874dafe6 /engines
parentb0e2cd5967442f1b7cb1cea1df6dcea097bc6f73 (diff)
downloadscummvm-rg350-03ffd60054141dfee971232e935cf6d75c737700.tar.gz
scummvm-rg350-03ffd60054141dfee971232e935cf6d75c737700.tar.bz2
scummvm-rg350-03ffd60054141dfee971232e935cf6d75c737700.zip
* Changed Disk code in BRA to use FilesystemNode (duplication has become truly visible!).
* Fixed Inventory items loading. svn-id: r33352
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/disk.h37
-rw-r--r--engines/parallaction/disk_br.cpp481
-rw-r--r--engines/parallaction/disk_ns.cpp3
-rw-r--r--engines/parallaction/font.cpp6
-rw-r--r--engines/parallaction/parallaction_br.cpp7
5 files changed, 343 insertions, 191 deletions
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index b98e5d0cae..451781d6f1 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -28,6 +28,8 @@
#define PATH_LEN 200
+#include "common/fs.h"
+
#include "common/file.h"
#include "graphics/surface.h"
@@ -202,12 +204,25 @@ public:
class DosDisk_br : public Disk {
protected:
+ uint16 _language;
+
Parallaction *_vm;
- char _partPath[PATH_LEN];
- char _languageDir[2];
+
+ FilesystemNode _baseDir;
+ FilesystemNode _partDir;
+
+ FilesystemNode _aniDir;
+ FilesystemNode _bkgDir;
+ FilesystemNode _mscDir;
+ FilesystemNode _mskDir;
+ FilesystemNode _pthDir;
+ FilesystemNode _rasDir;
+ FilesystemNode _scrDir;
+ FilesystemNode _sfxDir;
+ FilesystemNode _talDir;
protected:
- void errorFileNotFound(const char *s);
+ void errorFileNotFound(const FilesystemNode &dir, const Common::String &filename);
Font *createFont(const char *name, Common::ReadStream &stream);
Sprites* createSprites(Common::ReadStream &stream);
void loadBitmap(Common::SeekableReadStream &stream, Graphics::Surface &surf, byte *palette);
@@ -242,8 +257,17 @@ protected:
Sprites* createSprites(Common::ReadStream &stream);
Font *createFont(const char *name, Common::SeekableReadStream &stream);
- void loadMask(BackgroundInfo& info, const char *name);
- void loadBackground(BackgroundInfo& info, const char *name);
+ void loadMask(BackgroundInfo& info, Common::SeekableReadStream &stream);
+ void loadBackground(BackgroundInfo& info, Common::SeekableReadStream &stream);
+
+ FilesystemNode _baseBkgDir;
+ FilesystemNode _fntDir;
+ FilesystemNode _commonAniDir;
+ FilesystemNode _commonBkgDir;
+ FilesystemNode _commonMscDir;
+ FilesystemNode _commonMskDir;
+ FilesystemNode _commonPthDir;
+ FilesystemNode _commonTalDir;
public:
AmigaDisk_br(Parallaction *vm);
@@ -255,8 +279,11 @@ public:
Frames* loadFrames(const char* name);
void loadSlide(BackgroundInfo& info, const char *filename);
void loadScenery(BackgroundInfo& info, const char* name, const char* mask, const char* path);
+ GfxObj* AmigaDisk_br::loadObjects(const char *name);
Common::SeekableReadStream* loadMusic(const char* name);
Common::ReadStream* loadSound(const char* name);
+ Common::String selectArchive(const Common::String& name);
+
};
} // namespace Parallaction
diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp
index 54a1261936..e354c1cecc 100644
--- a/engines/parallaction/disk_br.cpp
+++ b/engines/parallaction/disk_br.cpp
@@ -25,6 +25,7 @@
#include "graphics/iff.h"
+#include "common/config-manager.h"
#include "parallaction/parallaction.h"
@@ -90,49 +91,40 @@ struct Sprites : public Frames {
-void DosDisk_br::errorFileNotFound(const char *s) {
- error("File '%s' not found", s);
+void DosDisk_br::errorFileNotFound(const FilesystemNode &dir, const Common::String &filename) {
+ error("File '%s' not found in directory '%s'", filename.c_str(), dir.getDisplayName().c_str());
}
Common::String DosDisk_br::selectArchive(const Common::String& name) {
debugC(5, kDebugDisk, "DosDisk_br::selectArchive");
- Common::String oldPath(_partPath);
- strcpy(_partPath, name.c_str());
+ Common::String oldPath;
+ if (_partDir.exists()) {
+ oldPath = _partDir.getDisplayName();
+ }
+
+ _partDir = _baseDir.getChild(name);
+
+ _aniDir = _partDir.getChild("ani");
+ _bkgDir = _partDir.getChild("bkg");
+ _mscDir = _partDir.getChild("msc");
+ _mskDir = _partDir.getChild("msk");
+ _pthDir = _partDir.getChild("pth");
+ _rasDir = _partDir.getChild("ras");
+ _scrDir = _partDir.getChild("scripts");
+ _sfxDir = _partDir.getChild("sfx");
+ _talDir = _partDir.getChild("tal");
return oldPath;
}
void DosDisk_br::setLanguage(uint16 language) {
debugC(5, kDebugDisk, "DosDisk_br::setLanguage");
-
- switch (language) {
- case 0:
- strcpy(_languageDir, "it");
- break;
-
- case 1:
- strcpy(_languageDir, "fr");
- break;
-
- case 2:
- strcpy(_languageDir, "en");
- break;
-
- case 3:
- strcpy(_languageDir, "ge");
- break;
-
- default:
- error("unknown language");
-
- }
-
- return;
+ assert(language < 4);
+ _language = language;
}
-DosDisk_br::DosDisk_br(Parallaction* vm) : _vm(vm) {
-
+DosDisk_br::DosDisk_br(Parallaction* vm) : _vm(vm), _baseDir(ConfMan.get("path")) {
}
DosDisk_br::~DosDisk_br() {
@@ -141,45 +133,54 @@ DosDisk_br::~DosDisk_br() {
GfxObj* DosDisk_br::loadTalk(const char *name) {
debugC(5, kDebugDisk, "DosDisk_br::loadTalk(%s)", name);
- Common::File stream;
-
- char path[PATH_LEN];
- sprintf(path, "%s/tal/%s", _partPath, name);
- if (!stream.open(path)) {
- sprintf(path, "%s/tal/%s.tal", _partPath, name);
- if (!stream.open(path))
- errorFileNotFound(path);
+ Common::String path(name);
+ FilesystemNode node = _talDir.getChild(path);
+ if (!node.exists()) {
+ path += ".tal";
+ node = _talDir.getChild(path);
+ if (!node.exists())
+ errorFileNotFound(_talDir, path);
}
+ Common::File stream;
+ stream.open(node);
return new GfxObj(0, createSprites(stream), name);
}
Script* DosDisk_br::loadLocation(const char *name) {
debugC(5, kDebugDisk, "DosDisk_br::loadLocation");
- Common::File *stream = new Common::File;
-
- char path[PATH_LEN];
- sprintf(path, "%s/%s/%s.slf", _partPath, _languageDir, name);
- if (!stream->open(path)) {
- sprintf(path, "%s/%s/%s.loc", _partPath, _languageDir, name);
- if (!stream->open(path))
- errorFileNotFound(path);
+ Common::String langs[4] = { "it", "fr", "en", "ge" };
+ FilesystemNode locDir = _partDir.getChild(langs[_language]);
+
+ Common::String path(name);
+ path += ".slf";
+ FilesystemNode node = locDir.getChild(path);
+ if (!node.exists()) {
+ path = Common::String(name) + ".loc";
+ node = locDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(locDir, path);
+ }
}
+ Common::File *stream = new Common::File;
+ stream->open(node);
return new Script(stream, true);
}
Script* DosDisk_br::loadScript(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadScript");
- Common::File *stream = new Common::File;
-
- char path[PATH_LEN];
- sprintf(path, "%s/scripts/%s.scr", _partPath, name);
- if (!stream->open(path))
- errorFileNotFound(path);
+ Common::String path(name);
+ path += ".scr";
+ FilesystemNode node = _scrDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_scrDir, path);
+ }
+ Common::File *stream = new Common::File;
+ stream->open(node);
return new Script(stream, true);
}
@@ -208,12 +209,15 @@ void DosDisk_br::loadBitmap(Common::SeekableReadStream &stream, Graphics::Surfac
Frames* DosDisk_br::loadPointer(const char *name) {
debugC(5, kDebugDisk, "DosDisk_br::loadPointer");
- char path[PATH_LEN];
- sprintf(path, "%s.ras", name);
+ Common::String path(name);
+ path += ".ras";
+ FilesystemNode node = _baseDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_baseDir, path);
+ }
Common::File stream;
- if (!stream.open(path))
- errorFileNotFound(path);
+ stream.open(node);
Graphics::Surface *surf = new Graphics::Surface;
loadBitmap(stream, *surf, 0);
@@ -224,13 +228,15 @@ Frames* DosDisk_br::loadPointer(const char *name) {
Font* DosDisk_br::loadFont(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadFont");
- char path[PATH_LEN];
- sprintf(path, "%s.fnt", name);
+ Common::String path(name);
+ path += ".fnt";
+ FilesystemNode node = _baseDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_baseDir, path);
+ }
Common::File stream;
- if (!stream.open(path))
- errorFileNotFound(path);
-
+ stream.open(node);
return createFont(name, stream);
}
@@ -238,12 +244,14 @@ Font* DosDisk_br::loadFont(const char* name) {
GfxObj* DosDisk_br::loadObjects(const char *name) {
debugC(5, kDebugDisk, "DosDisk_br::loadObjects");
- char path[PATH_LEN];
- sprintf(path, "%s/%s", _partPath, name);
+ Common::String path(name);
+ FilesystemNode node = _partDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_partDir, path);
+ }
Common::File stream;
- if (!stream.open(path))
- errorFileNotFound(path);
+ stream.open(node);
return createInventoryObjects(stream);
}
@@ -255,13 +263,15 @@ void genSlidePath(char *path, const char* name) {
GfxObj* DosDisk_br::loadStatic(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadStatic");
- char path[PATH_LEN];
- sprintf(path, "%s/ras/%s", _partPath, name);
- Common::File stream;
- if (!stream.open(path)) {
- errorFileNotFound(path);
+ Common::String path(name);
+ FilesystemNode node = _rasDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_rasDir, path);
}
+ Common::File stream;
+ stream.open(node);
+
Graphics::Surface *surf = new Graphics::Surface;
loadBitmap(stream, *surf, 0);
return new GfxObj(0, new SurfaceToFrames(surf), name);
@@ -291,17 +301,18 @@ Sprites* DosDisk_br::createSprites(Common::ReadStream &stream) {
Frames* DosDisk_br::loadFrames(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadFrames");
- char path[PATH_LEN];
- sprintf(path, "%s/ani/%s", _partPath, name);
-
- Common::File stream;
- if (!stream.open(path)) {
- sprintf(path, "%s/ani/%s.ani", _partPath, name);
- if (!stream.open(path)) {
- errorFileNotFound(path);
+ Common::String path(name);
+ FilesystemNode node = _aniDir.getChild(path);
+ if (!node.exists()) {
+ path += ".ani";
+ node = _aniDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_aniDir, path);
}
}
+ Common::File stream;
+ stream.open(node);
return createSprites(stream);
}
@@ -313,12 +324,15 @@ Frames* DosDisk_br::loadFrames(const char* name) {
void DosDisk_br::loadSlide(BackgroundInfo& info, const char *name) {
debugC(5, kDebugDisk, "DosDisk_br::loadSlide");
- char path[PATH_LEN];
- genSlidePath(path, name);
+ Common::String path(name);
+ path += ".bmp";
+ FilesystemNode node = _baseDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_baseDir, path);
+ }
Common::File stream;
- if (!stream.open(path))
- errorFileNotFound(path);
+ stream.open(node);
byte rgb[768];
@@ -336,13 +350,17 @@ void DosDisk_br::loadSlide(BackgroundInfo& info, const char *name) {
void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char *mask, const char* path) {
debugC(5, kDebugDisk, "DosDisk_br::loadScenery");
- char filename[PATH_LEN];
+ Common::String filepath;
+ FilesystemNode node;
Common::File stream;
if (name) {
- sprintf(filename, "%s/bkg/%s.bkg", _partPath, name);
- if (!stream.open(filename))
- errorFileNotFound(filename);
+ filepath = Common::String(name) + ".bkg";
+ node = _bkgDir.getChild(filepath);
+ if (!node.exists()) {
+ errorFileNotFound(_bkgDir, filepath);
+ }
+ stream.open(node);
byte rgb[768];
@@ -358,9 +376,12 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char
}
if (mask) {
- sprintf(filename, "%s/msk/%s.msk", _partPath, mask);
- if (!stream.open(filename))
- errorFileNotFound(filename);
+ filepath = Common::String(mask) + ".msk";
+ node = _mskDir.getChild(filepath);
+ if (!node.exists()) {
+ errorFileNotFound(_mskDir, filepath);
+ }
+ stream.open(node);
// NOTE: info.width and info.height are only valid if the background graphics
// have already been loaded
@@ -371,9 +392,12 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char
}
if (path) {
- sprintf(filename, "%s/pth/%s.pth", _partPath, path);
- if (!stream.open(filename))
- errorFileNotFound(filename);
+ filepath = Common::String(path) + ".pth";
+ node = _pthDir.getChild(filepath);
+ if (!node.exists()) {
+ errorFileNotFound(_pthDir, filepath);
+ }
+ stream.open(node);
// NOTE: info.width and info.height are only valid if the background graphics
// have already been loaded
@@ -388,15 +412,16 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char
Table* DosDisk_br::loadTable(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadTable");
- char path[PATH_LEN];
- sprintf(path, "%s/%s.tab", _partPath, name);
-
- Common::File stream;
- if (!stream.open(path))
- errorFileNotFound(path);
+ Common::String path(name);
+ path += ".tab";
+ FilesystemNode node = _partDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_partDir, path);
+ }
+ Common::File stream;
+ stream.open(node);
Table *t = createTableFromStream(100, stream);
-
stream.close();
return t;
@@ -419,7 +444,17 @@ Common::ReadStream* DosDisk_br::loadSound(const char* name) {
AmigaDisk_br::AmigaDisk_br(Parallaction *vm) : DosDisk_br(vm) {
+ _fntDir = _baseDir.getChild("fonts");
+ _baseBkgDir = _baseDir.getChild("backs");
+
+ FilesystemNode commonDir = _baseDir.getChild("common");
+ _commonAniDir = commonDir.getChild("anims");
+ _commonBkgDir = commonDir.getChild("backs");
+ _commonMscDir = commonDir.getChild("msc");
+ _commonMskDir = commonDir.getChild("msk");
+ _commonPthDir = commonDir.getChild("pth");
+ _commonTalDir = commonDir.getChild("talks");
}
@@ -455,19 +490,11 @@ void buildMask2(byte* buf) {
}
}
-void AmigaDisk_br::loadBackground(BackgroundInfo& info, const char *name) {
-
- char path[PATH_LEN];
- sprintf(path, "%s", name);
-
- Common::File s;
-
- if (!s.open(path))
- errorFileNotFound(path);
+void AmigaDisk_br::loadBackground(BackgroundInfo& info, Common::SeekableReadStream &stream) {
byte *pal;
- Graphics::ILBMDecoder decoder(s, info.bg, pal);
+ Graphics::ILBMDecoder decoder(stream, info.bg, pal);
decoder.decode();
uint i;
@@ -491,30 +518,23 @@ void AmigaDisk_br::loadBackground(BackgroundInfo& info, const char *name) {
return;
}
-void AmigaDisk_br::loadMask(BackgroundInfo& info, const char *name) {
- debugC(5, kDebugDisk, "AmigaDisk_br::loadMask(%s)", name);
-
- Common::File s;
-
- if (!s.open(name))
- return;
-
- s.seek(0x30, SEEK_SET);
+void AmigaDisk_br::loadMask(BackgroundInfo& info, Common::SeekableReadStream &stream) {
+ stream.seek(0x30, SEEK_SET);
byte r, g, b;
for (uint i = 0; i < 4; i++) {
- r = s.readByte();
- g = s.readByte();
- b = s.readByte();
+ r = stream.readByte();
+ g = stream.readByte();
+ b = stream.readByte();
info.layers[i] = (((r << 4) & 0xF00) | (g & 0xF0) | (b >> 4)) & 0xFF;
}
- s.seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic
- Graphics::PackBitsReadStream stream(s);
+ stream.seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic
+ Graphics::PackBitsReadStream unpackedStream(stream);
info.mask.create(info.width, info.height);
- stream.read(info.mask.data, info.mask.size);
+ unpackedStream.read(info.mask.data, info.mask.size);
buildMask2(info.mask.data);
return;
@@ -523,26 +543,39 @@ void AmigaDisk_br::loadMask(BackgroundInfo& info, const char *name) {
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);
- char filename[PATH_LEN];
+ Common::String filepath;
+ FilesystemNode node;
Common::File stream;
if (name) {
- sprintf(filename, "%s/backs/%s.bkg", _partPath, name);
-
- loadBackground(info, filename);
+ filepath = Common::String(name) + ".bkg";
+ node = _bkgDir.getChild(filepath);
+ if (!node.exists()) {
+ errorFileNotFound(_bkgDir, filepath);
+ }
+ stream.open(node);
+ loadBackground(info, stream);
+ stream.close();
}
if (mask) {
- sprintf(filename, "%s/msk/%s.msk", _partPath, name);
-
- loadMask(info, filename);
+ filepath = Common::String(name) + ".msk";
+ node = _mskDir.getChild(filepath);
+ if (!node.exists()) {
+ errorFileNotFound(_mskDir, filepath);
+ }
+ stream.open(node);
+ loadMask(info, stream);
+ stream.close();
}
if (path) {
- sprintf(filename, "%s/pth/%s.pth", _partPath, path);
- if (!stream.open(filename))
- errorFileNotFound(filename);
-
+ filepath = Common::String(name) + ".pth";
+ node = _pthDir.getChild(filepath);
+ if (!node.exists()) {
+ errorFileNotFound(_pthDir, filepath);
+ }
+ stream.open(node);
// NOTE: info.width and info.height are only valid if the background graphics
// have already been loaded
info.path.create(info.width, info.height);
@@ -556,22 +589,28 @@ void AmigaDisk_br::loadScenery(BackgroundInfo& info, const char* name, const cha
void AmigaDisk_br::loadSlide(BackgroundInfo& info, const char *name) {
debugC(1, kDebugDisk, "AmigaDisk_br::loadSlide '%s'", name);
- char path[PATH_LEN];
- sprintf(path, "backs/%s.bkg", name);
-
- loadBackground(info, path);
+ Common::String path(name);
+ path += ".bkg";
+ FilesystemNode node = _baseBkgDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_baseBkgDir, path);
+ }
+ Common::File stream;
+ stream.open(node);
+ loadBackground(info, stream);
return;
}
GfxObj* AmigaDisk_br::loadStatic(const char* name) {
debugC(1, kDebugDisk, "AmigaDisk_br::loadStatic '%s'", name);
- char path[PATH_LEN];
- sprintf(path, "%s/ras/%s", _partPath, name);
- Common::File stream;
- if (!stream.open(path)) {
- errorFileNotFound(path);
+ Common::String path(name);
+ FilesystemNode node = _rasDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_rasDir, path);
}
+ Common::File stream;
+ stream.open(node);
byte *pal = 0;
Graphics::Surface* surf = new Graphics::Surface;
@@ -608,72 +647,103 @@ Sprites* AmigaDisk_br::createSprites(Common::ReadStream &stream) {
Frames* AmigaDisk_br::loadFrames(const char* name) {
debugC(1, kDebugDisk, "AmigaDisk_br::loadFrames '%s'", name);
- char path[PATH_LEN];
- sprintf(path, "%s/anims/%s", _partPath, name);
-
- Common::File stream;
- if (!stream.open(path)) {
- sprintf(path, "%s/anims/%s.ani", _partPath, name);
- if (!stream.open(path)) {
- sprintf(path, "common/anims/%s", name);
- if (!stream.open(path)) {
- sprintf(path, "common/anims/%s.ani", name);
- if (!stream.open(path)) {
- errorFileNotFound(path);
+ Common::String path(name);
+ FilesystemNode node = _aniDir.getChild(path);
+ if (!node.exists()) {
+ path += ".ani";
+ node = _aniDir.getChild(path);
+ if (!node.exists()) {
+ path = Common::String(name);
+ node = _commonAniDir.getChild(path);
+ if (!node.exists()) {
+ path += ".ani";
+ node = _commonAniDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_aniDir, path);
}
}
}
}
+ Common::File stream;
+ stream.open(node);
return createSprites(stream);
}
GfxObj* AmigaDisk_br::loadTalk(const char *name) {
debugC(1, kDebugDisk, "AmigaDisk_br::loadTalk '%s'", name);
- Common::File stream;
-
- char path[PATH_LEN];
- sprintf(path, "%s/talks/%s", _partPath, name);
- if (!stream.open(path)) {
- sprintf(path, "%s/talks/%s.tal", _partPath, name);
- if (!stream.open(path)) {
- sprintf(path, "common/talks/%s", name);
- if (!stream.open(path)) {
- sprintf(path, "common/talks/%s.tal", name);
- if (!stream.open(path)) {
- errorFileNotFound(path);
+ Common::String path(name);
+ FilesystemNode node = _talDir.getChild(path);
+ if (!node.exists()) {
+ path += ".tal";
+ node = _talDir.getChild(path);
+ if (!node.exists()) {
+ path = Common::String(name);
+ node = _commonTalDir.getChild(path);
+ if (!node.exists()) {
+ path += ".tal";
+ node = _commonTalDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_talDir, path);
}
}
}
}
+ Common::File stream;
+ stream.open(node);
return new GfxObj(0, createSprites(stream));
}
Font* AmigaDisk_br::loadFont(const char* name) {
debugC(1, kDebugDisk, "AmigaFullDisk::loadFont '%s'", name);
- char path[PATH_LEN];
- sprintf(path, "%s", name);
+ Common::String path(name);
+ path += ".font";
+ FilesystemNode node = _fntDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_fntDir, path);
+ }
+
+ Common::String fontDir;
+ Common::String fontFile;
+ byte ch;
Common::File stream;
- if (!stream.open(path))
- errorFileNotFound(path);
+ stream.open(node);
+ stream.seek(4, SEEK_SET);
+ while ((ch = stream.readByte()) != 0x2F) fontDir += ch;
+ while ((ch = stream.readByte()) != 0) fontFile += ch;
+ stream.close();
+
+ printf("fontDir = %s, fontFile = %s\n", fontDir.c_str(), fontFile.c_str());
+ node = _fntDir.getChild(fontDir);
+ if (!node.exists()) {
+ errorFileNotFound(_fntDir, fontDir);
+ }
+ node = node.getChild(fontFile);
+ if (!node.exists()) {
+ errorFileNotFound(node, fontFile);
+ }
+
+ stream.open(node);
return createFont(name, stream);
}
Common::SeekableReadStream* AmigaDisk_br::loadMusic(const char* name) {
debugC(5, kDebugDisk, "AmigaDisk_br::loadMusic");
- char path[PATH_LEN];
- sprintf(path, "%s/msc/%s", _partPath, name);
-
- Common::File *stream = new Common::File;
- if (!stream->open(path))
+ Common::String path(name);
+ FilesystemNode node = _mscDir.getChild(path);
+ if (!node.exists()) {
+ // TODO (Kirben): error out when music file is not found?
return 0;
+ }
+ Common::File *stream = new Common::File;
+ stream->open(node);
return stream;
}
@@ -681,14 +751,61 @@ Common::SeekableReadStream* AmigaDisk_br::loadMusic(const char* name) {
Common::ReadStream* AmigaDisk_br::loadSound(const char* name) {
debugC(5, kDebugDisk, "AmigaDisk_br::loadSound");
- char path[PATH_LEN];
- sprintf(path, "%s/sfx/%s", _partPath, name);
+ Common::String path(name);
+ FilesystemNode node = _sfxDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_sfxDir, path);
+ }
Common::File *stream = new Common::File;
- if (!stream->open(path))
- errorFileNotFound(path);
-
+ stream->open(node);
return stream;
}
+GfxObj* AmigaDisk_br::loadObjects(const char *name) {
+ debugC(5, kDebugDisk, "AmigaDisk_br::loadObjects");
+
+ Common::String path(name);
+ FilesystemNode node = _partDir.getChild(path);
+ if (!node.exists()) {
+ errorFileNotFound(_partDir, path);
+ }
+
+ Common::File stream;
+ stream.open(node);
+
+ byte *pal = 0;
+ Graphics::Surface* surf = new Graphics::Surface;
+
+ Graphics::ILBMDecoder decoder(stream, *surf, pal);
+ decoder.decode();
+
+ free(pal);
+
+ return new GfxObj(0, new SurfaceToFrames(surf));
+}
+
+Common::String AmigaDisk_br::selectArchive(const Common::String& name) {
+ debugC(5, kDebugDisk, "AmigaDisk_br::selectArchive");
+
+ Common::String oldPath;
+ if (_partDir.exists()) {
+ oldPath = _partDir.getDisplayName();
+ }
+
+ _partDir = _baseDir.getChild(name);
+
+ _aniDir = _partDir.getChild("anims");
+ _bkgDir = _partDir.getChild("backs");
+ _mscDir = _partDir.getChild("msc");
+ _mskDir = _partDir.getChild("msk");
+ _pthDir = _partDir.getChild("pth");
+ _rasDir = _partDir.getChild("ras");
+ _scrDir = _partDir.getChild("scripts");
+ _sfxDir = _partDir.getChild("sfx");
+ _talDir = _partDir.getChild("talks");
+
+ return oldPath;
+}
+
} // namespace Parallaction
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp
index 55e6fc5e77..3c13538c32 100644
--- a/engines/parallaction/disk_ns.cpp
+++ b/engines/parallaction/disk_ns.cpp
@@ -25,6 +25,9 @@
#include "graphics/iff.h"
+#include "common/fs.h"
+#include "common/config-manager.h"
+
#include "parallaction/parallaction.h"
diff --git a/engines/parallaction/font.cpp b/engines/parallaction/font.cpp
index 6b65f19298..41fa862400 100644
--- a/engines/parallaction/font.cpp
+++ b/engines/parallaction/font.cpp
@@ -187,7 +187,7 @@ public:
byte* getData(uint16 index) {
assert(index < _numGlyphs);
- return _data + _height * index + _widths[index];
+ return _data + (_height * _widths[index]) * index;;
}
void getRect(uint16 index, Common::Rect &r) {
@@ -616,8 +616,8 @@ void Parallaction_br::initFonts() {
// fonts/sonya/18
// fonts/vanya/16
- _menuFont = _disk->loadFont("fonts/natasha/16");
- _dialogueFont = _disk->loadFont("fonts/sonya/18");
+ _menuFont = _disk->loadFont("natasha");
+ _dialogueFont = _disk->loadFont("sonya");
Common::MemoryReadStream stream(_amigaTopazFont, 2600, false);
_labelFont = new AmigaFont(stream);
}
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 020dfa6df5..18b697fdae 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -174,7 +174,12 @@ void Parallaction_br::initPart() {
_objectsNames = _disk->loadTable("objects");
_countersNames = _disk->loadTable("counters");
- _char._objs = _disk->loadObjects("icone.ico");
+ // TODO: maybe handle this into Disk
+ if (getPlatform() == Common::kPlatformPC) {
+ _char._objs = _disk->loadObjects("icone.ico");
+ } else {
+ _char._objs = _disk->loadObjects("icons.ico");
+ }
}