FULLPIPE: Completed Background loading

This commit is contained in:
Eugene Sandulenko 2013-06-21 21:30:38 -04:00
parent 47faa88501
commit 29f323fd27
7 changed files with 129 additions and 44 deletions

View File

@ -48,6 +48,7 @@ class GameProject;
class CGameVar;
class CInventory2;
class Scene;
class NGIArchive;
class FullpipeEngine : public ::Engine {
protected:
@ -96,6 +97,8 @@ public:
Scene *accessScene(int sceneId);
NGIArchive *_currArchive;
public:
bool _isSaveAllowed;

View File

@ -40,13 +40,14 @@ class Picture : public MemoryObject {
int _height;
int _bitmap;
int _field_54;
int _memoryObject2;
MemoryObject2 *_memoryObject2;
int _alpha;
int _paletteData;
byte *_paletteData;
public:
Picture();
virtual bool load(MfcArchive &file);
void setAOIDs();
};
class BigPicture : public Picture {
@ -94,7 +95,7 @@ class Background : public CObject {
int _colorMemoryObj;
int _bigPictureArray1Count;
int _bigPictureArray2Count;
int _bigPictureArray;
BigPicture ***_bigPictureArray;
public:
Background();

View File

@ -33,33 +33,6 @@
namespace Fullpipe {
#define NGI_FILENAME_MAX 13
struct NgiHeader {
int32 pos;
int32 extVal;
int32 flags;
int32 size;
char filename[NGI_FILENAME_MAX];
};
typedef Common::HashMap<Common::String, NgiHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> NgiHeadersMap;
class NGIArchive : public Common::Archive {
NgiHeadersMap _headers;
Common::String _ngiFilename;
public:
NGIArchive(const Common::String &name);
virtual ~NGIArchive();
// Archive implementation
virtual bool hasFile(const Common::String &name) const;
virtual int listMembers(Common::ArchiveMemberList &list) const;
virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
};
NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename) {
Common::File ngiFile;
@ -118,6 +91,8 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename)
free(fat);
g_fullpipe->_currArchive = this;
debug(0, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size());
}
@ -127,6 +102,8 @@ NGIArchive::~NGIArchive() {
for ( ; it != _headers.end(); ++it) {
delete it->_value;
}
g_fullpipe->_currArchive = 0;
}
bool NGIArchive::hasFile(const Common::String &name) const {
@ -163,8 +140,6 @@ Common::SeekableReadStream *NGIArchive::createReadStreamForMember(const Common::
archiveFile.open(_ngiFilename);
archiveFile.seek(hdr->pos, SEEK_SET);
// TODO: It would be good if ArjFile could decompress files in a streaming
// mode, so it would not need to pre-allocate the entire output.
byte *data = (byte *)malloc(hdr->size);
assert(data);

View File

@ -29,6 +29,33 @@ namespace Fullpipe {
class Archive;
#define NGI_FILENAME_MAX 13
struct NgiHeader {
int32 pos;
int32 extVal;
int32 flags;
int32 size;
char filename[NGI_FILENAME_MAX];
};
typedef Common::HashMap<Common::String, NgiHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> NgiHeadersMap;
class NGIArchive : public Common::Archive {
NgiHeadersMap _headers;
Common::String _ngiFilename;
public:
NGIArchive(const Common::String &name);
virtual ~NGIArchive();
// Archive implementation
virtual bool hasFile(const Common::String &name) const;
virtual int listMembers(Common::ArchiveMemberList &list) const;
virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
};
/**
* This factory method creates an Archive instance corresponding to the content
* of the NGI compressed file with the given name.

View File

@ -98,6 +98,8 @@ void SceneTag::loadScene() {
delete file;
g_fullpipe->_currArchive = 0;
free(fname);
free(archname);
}

View File

@ -23,9 +23,11 @@
#include "fullpipe/fullpipe.h"
#include "common/file.h"
#include "common/memstream.h"
#include "fullpipe/objects.h"
#include "fullpipe/motion.h"
#include "fullpipe/ngiarchive.h"
namespace Fullpipe {
@ -102,6 +104,64 @@ char *MfcArchive::readPascalString(bool twoByte) {
return tmp;
}
MemoryObject::MemoryObject() {
_filename = 0;
_field_8 = 0;
_field_C = 0;
_field_10 = -1;
_field_14 = 1;
_dataSize = 0;
_flags = 0;
_libHandle = 0;
_data = 0;
}
bool MemoryObject::load(MfcArchive &file) {
_filename = file.readPascalString();
if (g_fullpipe->_currArchive) {
_field_14 = 0;
_libHandle = g_fullpipe->_currArchive;
}
return true;
}
void MemoryObject::loadFile(char *filename) {
if (!_data) {
if (g_fullpipe->_currArchive != _libHandle) {
assert(0);
}
Common::SeekableReadStream *s = _libHandle->createReadStreamForMember(filename);
if (s) {
debug(0, "Reading %s", filename);
assert(s->size() > 0);
_data = calloc(s->size(), 1);
s->read(_data, s->size());
delete s;
}
}
}
MemoryObject2::MemoryObject2() {
_data2 = 0;
}
bool MemoryObject2::load(MfcArchive &file) {
MemoryObject::load(file);
_flags |= 1;
if (_filename) {
MemoryObject::loadFile(_filename);
}
return true;
}
int MfcArchive::readCount() {
int count = readUint16LE();

View File

@ -30,6 +30,7 @@
namespace Fullpipe {
class CObject;
class NGIArchive;
typedef Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ClassMap;
@ -77,18 +78,34 @@ class CObList : public Common::List<CObject>, public CObject {
};
class MemoryObject : CObject {
int filename;
int field_8;
int field_C;
int field_10;
char field_14;
char field_15;
char field_16;
char field_17;
int data;
int dataSize;
int flags;
int libHandle;
friend class MemoryObject2;
friend class Picture;
char *_filename;
int _field_8;
int _field_C;
int _field_10;
char _field_14;
char _field_15;
char _field_16;
char _field_17;
void *_data;
int _dataSize;
int _flags;
NGIArchive *_libHandle;
public:
MemoryObject();
virtual bool load(MfcArchive &file);
void loadFile(char *filename);
};
class MemoryObject2 : public MemoryObject {
void *_data2;
public:
MemoryObject2();
virtual bool load(MfcArchive &file);
};
class CObArray : public Common::Array<CObject>, public CObject {