diff options
author | Filippos Karapetis | 2008-12-23 16:29:26 +0000 |
---|---|---|
committer | Filippos Karapetis | 2008-12-23 16:29:26 +0000 |
commit | e27c46359526bdc2cdc1dddfbf5888cffac6f70a (patch) | |
tree | 8652acd4d205c09e07d0b256183894223059bf4a /engines | |
parent | 350943f291f6e6b9506bb790b7e0496504c2e6fd (diff) | |
download | scummvm-rg350-e27c46359526bdc2cdc1dddfbf5888cffac6f70a.tar.gz scummvm-rg350-e27c46359526bdc2cdc1dddfbf5888cffac6f70a.tar.bz2 scummvm-rg350-e27c46359526bdc2cdc1dddfbf5888cffac6f70a.zip |
Some initial code for HRS resource loading
svn-id: r35497
Diffstat (limited to 'engines')
-rw-r--r-- | engines/saga/resource.h | 14 | ||||
-rw-r--r-- | engines/saga/resource_hrs.cpp | 29 |
2 files changed, 37 insertions, 6 deletions
diff --git a/engines/saga/resource.h b/engines/saga/resource.h index f5fece0150..943bbd95ef 100644 --- a/engines/saga/resource.h +++ b/engines/saga/resource.h @@ -57,8 +57,12 @@ struct PatchData { }; struct ResourceData { + uint32 id; // SAGA2 size_t offset; size_t size; + + bool isExternal() { return ((offset & (1L<<31)) != 0L); } // SAGA2 + PatchData *patchData; void fillSoundPatch(const GameSoundInfo *&soundInfo) { if (patchData != NULL) { @@ -75,11 +79,13 @@ struct ResourceContext { const char *fileName; uint16 fileType; Common::File *file; - int serial; + int serial; // IHNM speech files bool isBigEndian; ResourceData *table; size_t count; + uint32 firstGroupOffset; // SAGA2 + ResourceData *groups; // SAGA2 Common::File *getFile(ResourceData *resourceData) const { if (resourceData->patchData != NULL) { @@ -189,7 +195,7 @@ public: private: virtual bool loadMacContext(ResourceContext *context) { return false; } virtual bool loadResContext(ResourceContext *context, uint32 contextOffset, uint32 contextSize) { - return loadResContext_v1(context, contextOffset, contextSize); + return loadResContext_v1(context, 0, contextSize); } MetaResource _metaResource; }; @@ -207,9 +213,9 @@ public: private: virtual bool loadMacContext(ResourceContext *context) { return false; } virtual bool loadResContext(ResourceContext *context, uint32 contextOffset, uint32 contextSize) { - return loadResContext_v2(context, contextOffset, contextSize); + return loadResContext_v2(context, contextSize); } - bool loadResContext_v2(ResourceContext *context, uint32 contextOffset, uint32 contextSize); + bool loadResContext_v2(ResourceContext *context, uint32 contextSize); }; } // End of namespace Saga diff --git a/engines/saga/resource_hrs.cpp b/engines/saga/resource_hrs.cpp index 500b3d04d5..09b71a929b 100644 --- a/engines/saga/resource_hrs.cpp +++ b/engines/saga/resource_hrs.cpp @@ -36,11 +36,36 @@ #include "saga/sndres.h" #include "common/advancedDetector.h" +#include "common/endian.h" namespace Saga { -bool Resource_HRS::loadResContext_v2(ResourceContext *context, uint32 contextOffset, uint32 contextSize) { - // STUB +bool Resource_HRS::loadResContext_v2(ResourceContext *context, uint32 contextSize) { + ResourceData *resourceData = new ResourceData(); + uint32 firstGroupOffset; + const int resDataSize = 4 + 4 + 4; + + context->file->seek(0, SEEK_SET); + + // Read head element (origin) + resourceData->id = context->file->readUint32BE(); + resourceData->offset = context->file->readUint32LE(); + resourceData->size = context->file->readUint32LE(); + + // Check if the file is valid + if (resourceData->id != MKID_BE('HRES')) { // header + free(resourceData); + return false; + } + + // Read first group offset + context->file->seek(resourceData->offset - 4, SEEK_SET); + firstGroupOffset = context->file->readUint32LE(); + + // Allocate buffers for root/base node, groups and data + // TODO + + free(resourceData); return true; } |