From e27c46359526bdc2cdc1dddfbf5888cffac6f70a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2008 16:29:26 +0000 Subject: Some initial code for HRS resource loading svn-id: r35497 --- engines/saga/resource.h | 14 ++++++++++---- engines/saga/resource_hrs.cpp | 29 +++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) (limited to 'engines') 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; } -- cgit v1.2.3