From bed16296425df6def9b59ebe7df6f5ee45dcf035 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 31 Mar 2005 23:11:39 +0000 Subject: [PATCH] Made findResourceSmall local to resource.cpp; simplified _EPAL_offs (since we don't use it nor save it at this time, this is harmless); added a comment about _CLUT_offs ugliness svn-id: r17314 --- scumm/resource.cpp | 7 ++++--- scumm/resource.h | 2 -- scumm/scumm.cpp | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 0899ffcd683..3c54c6b95b2 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -36,6 +36,7 @@ namespace Scumm { static uint16 newTag2Old(uint32 newTag); static const char *resTypeFromId(int id); +static const byte *findResourceSmall(uint32 tag, const byte *searchin); /* Open a room */ @@ -909,11 +910,11 @@ int ScummEngine::getResourceDataSize(const byte *ptr) const { return 0; if (_features & GF_OLD_BUNDLE) - return READ_LE_UINT16(ptr) - 4; + return READ_LE_UINT16(ptr) - _resourceHeaderSize; else if (_features & GF_SMALL_HEADER) - return READ_LE_UINT32(ptr) - 6; + return READ_LE_UINT32(ptr) - _resourceHeaderSize; else - return READ_BE_UINT32(ptr - 4) - 8; + return READ_BE_UINT32(ptr - 4) - _resourceHeaderSize; } void ResourceManager::lock(int type, int i) { diff --git a/scumm/resource.h b/scumm/resource.h index 7e1901f8172..58498ca8169 100644 --- a/scumm/resource.h +++ b/scumm/resource.h @@ -37,8 +37,6 @@ enum { }; -const byte *findResourceSmall(uint32 tag, const byte *searchin); - class ResourceIterator { uint32 _size; uint32 _pos; diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index ec6e621cacf..510f38e7439 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -2421,7 +2421,7 @@ void ScummEngine::initRoomSubBlocks() { // FIXME. This is an evil HACK!!! size = (READ_LE_UINT16(roomptr + 0x0A) - READ_LE_UINT16(roomptr + 0x15)) - size; else - size = getResourceDataSize(ptr - size - 6) - size; + size = getResourceDataSize(ptr - size - _resourceHeaderSize) - size; if (size > 0) { // do this :) createResource(rtMatrix, 1, size); @@ -2611,10 +2611,9 @@ void ScummEngine::initRoomSubBlocks() { } } + // Locate the EGA palette (currently unused). if (_features & GF_OLD_BUNDLE) ptr = 0; - else if (_features & GF_SMALL_HEADER) - ptr = findResourceSmall(MKID('EPAL'), roomptr); else ptr = findResourceData(MKID('EPAL'), roomptr); @@ -2622,17 +2621,26 @@ void ScummEngine::initRoomSubBlocks() { _EPAL_offs = ptr - roomptr; } + // Locate the standard room palette (for V3-V5 games). + // Note: We used to use findResourceSmall instead of findResourceData; + // in the small header case. That means we have to do some ugly trickery + // in order to emulate the old behaviour. It would be very nice to get + // rid of that. That would require some changes to the palette code. + // + // And of course this would break savegame compatibility unless extra code + // were added to the save/load system to cope with this. if (_features & GF_OLD_BUNDLE) ptr = 0; - else if (_features & GF_SMALL_HEADER) - ptr = findResourceSmall(MKID('CLUT'), roomptr); else ptr = findResourceData(MKID('CLUT'), roomptr); if (ptr) { + if ((_features & GF_SMALL_HEADER) && ptr) + ptr -= _resourceHeaderSize; _CLUT_offs = ptr - roomptr; } + // Locate the standard room palettes (for V6+ games). if (_version >= 6) { ptr = findResource(MKID('PALS'), roomptr); if (ptr) {