mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 20:21:06 +00:00
added Patch.re_ support
svn-id: r18603
This commit is contained in:
parent
372a483ceb
commit
86ab70b149
@ -601,7 +601,7 @@ static GameFileDescription IHNMCD_GameFiles[] = {
|
||||
{"musicfm.res", GAME_MUSICFILE_FM},
|
||||
{"musicgm.res", GAME_MUSICFILE_GM},
|
||||
{"scream.res", GAME_RESOURCEFILE},
|
||||
{"patch.re_", GAME_PATCHFILE},
|
||||
{"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE},
|
||||
{"scripts.res", GAME_SCRIPTFILE},
|
||||
{"sfx.res", GAME_SOUNDFILE},
|
||||
{"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important
|
||||
@ -619,7 +619,7 @@ static GameFileDescription IHNMCDDE_GameFiles[] = {
|
||||
{"musicgm.res", GAME_MUSICFILE_GM},
|
||||
{"scream.res", GAME_RESOURCEFILE},
|
||||
{"scripts.res", GAME_SCRIPTFILE},
|
||||
{"patch.re_", GAME_PATCHFILE},
|
||||
{"patch.re_", GAME_PATCHFILE | GAME_RESOURCEFILE},
|
||||
{"sfx.res", GAME_SOUNDFILE},
|
||||
{"voicess.res", GAME_VOICEFILE}, //order of voice bank file is important
|
||||
{"voices1.res", GAME_VOICEFILE},
|
||||
|
@ -48,6 +48,11 @@ bool Resource::loadContext(ResourceContext *context) {
|
||||
ResourceData *resourceData;
|
||||
byte *tableBuffer;
|
||||
size_t tableSize;
|
||||
uint16 subjectResourceType;
|
||||
ResourceContext *subjectContext;
|
||||
uint32 subjectResourceId;
|
||||
uint32 patchResourceId;
|
||||
ResourceData *subjectResourceData;
|
||||
|
||||
if (!context->file->open(context->fileName)) {
|
||||
return false;
|
||||
@ -103,7 +108,29 @@ bool Resource::loadContext(ResourceContext *context) {
|
||||
|
||||
free(tableBuffer);
|
||||
|
||||
//process patch files
|
||||
//process internal patch files
|
||||
if (GAME_PATCHFILE & context->fileType) {
|
||||
subjectResourceType = ~GAME_PATCHFILE & context->fileType;
|
||||
subjectContext = getContext(subjectResourceType);
|
||||
if (subjectContext == NULL) {
|
||||
error("Resource::loadContext() Subject context not found");
|
||||
}
|
||||
loadResource(context, context->count - 1, tableBuffer, tableSize);
|
||||
|
||||
MemoryReadStreamEndian readS2(tableBuffer, tableSize, context->isBigEndian);
|
||||
for (i = 0; i < tableSize / 8; i++) {
|
||||
subjectResourceId = readS2.readUint32();
|
||||
patchResourceId = readS2.readUint32();
|
||||
subjectResourceData = getResourceData(subjectContext, subjectResourceId);
|
||||
resourceData = getResourceData(context, patchResourceId);
|
||||
subjectResourceData->patchData = new PatchData(context->file);
|
||||
subjectResourceData->offset = resourceData->offset;
|
||||
subjectResourceData->size = resourceData->size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//process external patch files
|
||||
if (result) {
|
||||
for (j = 0; j < _vm->getGameDescription()->patchsCount; j++) {
|
||||
patchDescription = &_vm->getGameDescription()->patchDescriptions[j];
|
||||
|
@ -36,18 +36,21 @@ namespace Saga {
|
||||
|
||||
#define RSC_MIN_FILESIZE (RSC_TABLEINFO_SIZE + RSC_TABLEENTRY_SIZE + 1)
|
||||
|
||||
//TODO: good PATCH.RE_ support
|
||||
|
||||
struct PatchData {
|
||||
bool _deletePatchFile;
|
||||
Common::File *_patchFile;
|
||||
GamePatchDescription *_patchDescription;
|
||||
|
||||
PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription) {
|
||||
PatchData(GamePatchDescription *patchDescription): _patchDescription(patchDescription), _deletePatchFile(true) {
|
||||
_patchFile = new Common::File();
|
||||
}
|
||||
PatchData(Common::File *patchFile): _patchDescription(NULL), _patchFile(patchFile), _deletePatchFile(false) {
|
||||
}
|
||||
|
||||
~PatchData() {
|
||||
delete _patchFile;
|
||||
if (_deletePatchFile) {
|
||||
delete _patchFile;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -55,6 +58,15 @@ struct ResourceData {
|
||||
size_t offset;
|
||||
size_t size;
|
||||
PatchData *patchData;
|
||||
void fillSoundPatch(const GameSoundInfo *&soundInfo) {
|
||||
if (patchData != NULL) {
|
||||
if (patchData->_patchDescription != NULL) {
|
||||
if (patchData->_patchDescription->soundInfo != NULL) {
|
||||
soundInfo = patchData->_patchDescription->soundInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct ResourceContext {
|
||||
|
@ -116,11 +116,8 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
|
||||
} else {
|
||||
soundInfo = _vm->getSfxInfo();
|
||||
}
|
||||
if (context->table[resourceId].patchData != NULL) {
|
||||
if (context->table[resourceId].patchData->_patchDescription->soundInfo != NULL) {
|
||||
soundInfo = context->table[resourceId].patchData->_patchDescription->soundInfo;
|
||||
}
|
||||
}
|
||||
|
||||
context->table[resourceId].fillSoundPatch(soundInfo);
|
||||
|
||||
MemoryReadStream readS(soundResource, soundResourceLength);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user