2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2004-2006 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
// RSC Resource file management header file
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2006-07-23 15:16:50 +00:00
|
|
|
#ifndef SAGA_RSCFILE_H
|
|
|
|
#define SAGA_RSCFILE_H
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-04-23 11:40:51 +00:00
|
|
|
#include "common/file.h"
|
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
|
|
|
|
2005-08-04 10:23:49 +00:00
|
|
|
#define MAC_BINARY_HEADER_SIZE 128
|
2004-04-12 21:40:49 +00:00
|
|
|
#define RSC_TABLEINFO_SIZE 8
|
|
|
|
#define RSC_TABLEENTRY_SIZE 8
|
|
|
|
|
|
|
|
#define RSC_MIN_FILESIZE (RSC_TABLEINFO_SIZE + RSC_TABLEENTRY_SIZE + 1)
|
|
|
|
|
2005-07-26 19:40:58 +00:00
|
|
|
struct PatchData {
|
2005-07-30 17:28:58 +00:00
|
|
|
bool _deletePatchFile;
|
2005-07-26 19:40:58 +00:00
|
|
|
Common::File *_patchFile;
|
2006-10-08 07:48:19 +00:00
|
|
|
const GamePatchDescription *_patchDescription;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2006-10-08 07:48:19 +00:00
|
|
|
PatchData(const GamePatchDescription *patchDescription): _patchDescription(patchDescription), _deletePatchFile(true) {
|
2005-07-26 19:40:58 +00:00
|
|
|
_patchFile = new Common::File();
|
|
|
|
}
|
2005-07-30 17:28:58 +00:00
|
|
|
PatchData(Common::File *patchFile): _patchDescription(NULL), _patchFile(patchFile), _deletePatchFile(false) {
|
|
|
|
}
|
2005-07-26 19:40:58 +00:00
|
|
|
|
|
|
|
~PatchData() {
|
2005-07-30 17:28:58 +00:00
|
|
|
if (_deletePatchFile) {
|
|
|
|
delete _patchFile;
|
|
|
|
}
|
2005-07-26 19:40:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
struct ResourceData {
|
|
|
|
size_t offset;
|
|
|
|
size_t size;
|
2005-07-26 19:40:58 +00:00
|
|
|
PatchData *patchData;
|
2005-07-30 17:28:58 +00:00
|
|
|
void fillSoundPatch(const GameSoundInfo *&soundInfo) {
|
|
|
|
if (patchData != NULL) {
|
|
|
|
if (patchData->_patchDescription != NULL) {
|
|
|
|
if (patchData->_patchDescription->soundInfo != NULL) {
|
|
|
|
soundInfo = patchData->_patchDescription->soundInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-25 14:42:14 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
struct ResourceContext {
|
|
|
|
const char *fileName;
|
|
|
|
uint16 fileType;
|
|
|
|
Common::File *file;
|
2005-07-23 15:23:01 +00:00
|
|
|
int serial;
|
2005-07-19 19:05:52 +00:00
|
|
|
|
|
|
|
bool isBigEndian;
|
|
|
|
ResourceData *table;
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
Common::File *getFile(ResourceData *resourceData) const {
|
2005-07-26 19:40:58 +00:00
|
|
|
if (resourceData->patchData != NULL) {
|
|
|
|
return resourceData->patchData->_patchFile;
|
2005-07-19 19:05:52 +00:00
|
|
|
} else {
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
};
|
|
|
|
|
2005-08-05 23:14:11 +00:00
|
|
|
struct MetaResource {
|
|
|
|
int16 sceneIndex;
|
2005-08-07 00:00:43 +00:00
|
|
|
int16 objectCount;
|
2005-10-08 22:09:21 +00:00
|
|
|
int32 objectsStringsResourceID;
|
2005-10-11 02:22:53 +00:00
|
|
|
int32 inventorySpritesID;
|
2005-08-05 23:14:11 +00:00
|
|
|
int32 mainSpritesID;
|
2005-08-07 00:00:43 +00:00
|
|
|
int32 objectsResourceID;
|
2005-08-05 23:14:11 +00:00
|
|
|
int16 actorCount;
|
2005-10-08 22:09:21 +00:00
|
|
|
int32 actorsStringsResourceID;
|
2005-08-05 23:14:11 +00:00
|
|
|
int32 actorsResourceID;
|
|
|
|
int32 protagFaceSpritesID;
|
|
|
|
int32 field_22;
|
|
|
|
int16 field_26;
|
2005-08-06 14:26:59 +00:00
|
|
|
int16 protagStatesCount;
|
|
|
|
int32 protagStatesResourceID;
|
2005-08-05 23:14:11 +00:00
|
|
|
int32 cutawayListResourceID;
|
|
|
|
int32 songTableID;
|
|
|
|
|
|
|
|
MetaResource() {
|
|
|
|
memset(this, 0, sizeof(*this));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
class Resource {
|
|
|
|
public:
|
|
|
|
Resource(SagaEngine *vm);
|
|
|
|
~Resource();
|
|
|
|
bool createContexts();
|
|
|
|
void clearContexts();
|
|
|
|
void loadResource(ResourceContext *context, uint32 resourceId, byte*&resourceBuffer, size_t &resourceSize);
|
|
|
|
size_t getResourceSize(ResourceContext *context, uint32 resourceId);
|
|
|
|
uint32 convertResourceId(uint32 resourceId);
|
|
|
|
|
2005-08-05 23:14:11 +00:00
|
|
|
void loadGlobalResources(int chapter, int actorsEntrance);
|
|
|
|
|
2005-07-23 15:23:01 +00:00
|
|
|
ResourceContext *getContext(uint16 fileType, int serial = 0) {
|
2005-07-19 19:05:52 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < _contextsCount; i++) {
|
2005-07-23 15:23:01 +00:00
|
|
|
if ((_contexts[i].fileType & fileType) && _contexts[i].serial == serial) {
|
2005-07-19 19:05:52 +00:00
|
|
|
return &_contexts[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool validResourceId(ResourceContext *context, uint32 resourceId) const {
|
|
|
|
return (resourceId < context->count);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getResourceSize(ResourceContext *context, uint32 resourceId) const {
|
|
|
|
return getResourceData(context, resourceId)->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t getResourceOffset(ResourceContext *context, uint32 resourceId) const {
|
|
|
|
return getResourceData(context, resourceId)->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
ResourceData *getResourceData(ResourceContext *context, uint32 resourceId) const {
|
|
|
|
if (!validResourceId(context, resourceId)) {
|
2005-08-07 00:00:43 +00:00
|
|
|
warning("Resource::getResourceData() wrong resourceId %d", resourceId);
|
|
|
|
assert(0);
|
2005-07-19 19:05:52 +00:00
|
|
|
}
|
|
|
|
return &context->table[resourceId];
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SagaEngine *_vm;
|
|
|
|
ResourceContext *_contexts;
|
|
|
|
int _contextsCount;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
bool loadContext(ResourceContext *context);
|
2005-08-04 10:23:49 +00:00
|
|
|
bool loadMacContext(ResourceContext *context);
|
|
|
|
bool loadSagaContext(ResourceContext *context, uint32 contextOffset, uint32 contextSize);
|
2005-07-19 19:05:52 +00:00
|
|
|
|
2005-08-07 00:00:43 +00:00
|
|
|
|
|
|
|
public:
|
2005-08-05 23:14:11 +00:00
|
|
|
MetaResource _metaResource;
|
2005-07-19 19:05:52 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
} // End of namespace Saga
|
|
|
|
|
2004-05-01 13:19:15 +00:00
|
|
|
#endif
|