diff options
author | Max Horn | 2003-06-26 13:54:29 +0000 |
---|---|---|
committer | Max Horn | 2003-06-26 13:54:29 +0000 |
commit | 8e0c6dfede866ef42a1d95666518c6051c72fa8e (patch) | |
tree | b2a0badbb1cf67c362ec3a55d85ea0dadbfe92f8 /scumm | |
parent | 7a79ef8f5f94d9523d9aa8fb1999cbc58512b389 (diff) | |
download | scummvm-rg350-8e0c6dfede866ef42a1d95666518c6051c72fa8e.tar.gz scummvm-rg350-8e0c6dfede866ef42a1d95666518c6051c72fa8e.tar.bz2 scummvm-rg350-8e0c6dfede866ef42a1d95666518c6051c72fa8e.zip |
rearragned stuff
svn-id: r8652
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/resource.cpp | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 3e3ed7b522..421f773f22 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -1370,116 +1370,6 @@ int Scumm::getResourceDataSize(const byte *ptr) const { return READ_BE_UINT32(ptr - 4) - 8; } -ResourceIterator::ResourceIterator(const byte *searchin, bool smallHeader) - : _ptr(searchin), _smallHeader(smallHeader) { - assert(searchin); - if (_smallHeader) { - _size = READ_LE_UINT32(searchin); - _pos = 6; - _ptr = searchin + 6; - } else { - _size = READ_BE_UINT32(searchin + 4); - _pos = 8; - _ptr = searchin + 8; - } - -} - -const byte *ResourceIterator::findNext(uint32 tag) { - uint32 size = 0; - const byte *result = 0; - - if (_smallHeader) { - uint16 smallTag = newTag2Old(tag); - do { - if (_pos >= _size) - return 0; - - result = _ptr; - size = READ_LE_UINT32(result); - if ((int32)size <= 0) - return 0; // Avoid endless loop - - _pos += size; - _ptr += size; - } while (READ_LE_UINT16(result + 4) != smallTag); - } else { - do { - if (_pos >= _size) - return 0; - - result = _ptr; - size = READ_BE_UINT32(result + 4); - if ((int32)size <= 0) - return 0; // Avoid endless loop - - _pos += size; - _ptr += size; - } while (READ_UINT32(result) != tag); - } - - return result; -} - -const byte *findResource(uint32 tag, const byte *searchin) { - uint32 curpos, totalsize, size; - - assert(searchin); - - searchin += 4; - totalsize = READ_BE_UINT32(searchin); - curpos = 8; - searchin += 4; - - while (curpos < totalsize) { - if (READ_UINT32(searchin) == tag) - return searchin; - - size = READ_BE_UINT32(searchin + 4); - if ((int32)size <= 0) { - error("(%c%c%c%c) Not found in %d... illegal block len %d", - tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size); - return NULL; - } - - curpos += size; - searchin += size; - } - - return NULL; -} - -const byte *findResourceSmall(uint32 tag, const byte *searchin) { - uint32 curpos, totalsize, size; - uint16 smallTag; - - smallTag = newTag2Old(tag); - - assert(searchin); - - totalsize = READ_LE_UINT32(searchin); - searchin += 6; - curpos = 6; - - while (curpos < totalsize) { - size = READ_LE_UINT32(searchin); - - if (READ_LE_UINT16(searchin + 4) == smallTag) - return searchin; - - if ((int32)size <= 0) { - error("(%c%c%c%c) Not found in %d... illegal block len %d", - tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size); - return NULL; - } - - curpos += size; - searchin += size; - } - - return NULL; -} - void Scumm::lock(int type, int i) { if (!validateResource("Locking", type, i)) return; @@ -1774,6 +1664,116 @@ bool Scumm::isGlobInMemory(int type, int idx) const{ return res.address[type][idx] != NULL; } +ResourceIterator::ResourceIterator(const byte *searchin, bool smallHeader) + : _ptr(searchin), _smallHeader(smallHeader) { + assert(searchin); + if (_smallHeader) { + _size = READ_LE_UINT32(searchin); + _pos = 6; + _ptr = searchin + 6; + } else { + _size = READ_BE_UINT32(searchin + 4); + _pos = 8; + _ptr = searchin + 8; + } + +} + +const byte *ResourceIterator::findNext(uint32 tag) { + uint32 size = 0; + const byte *result = 0; + + if (_smallHeader) { + uint16 smallTag = newTag2Old(tag); + do { + if (_pos >= _size) + return 0; + + result = _ptr; + size = READ_LE_UINT32(result); + if ((int32)size <= 0) + return 0; // Avoid endless loop + + _pos += size; + _ptr += size; + } while (READ_LE_UINT16(result + 4) != smallTag); + } else { + do { + if (_pos >= _size) + return 0; + + result = _ptr; + size = READ_BE_UINT32(result + 4); + if ((int32)size <= 0) + return 0; // Avoid endless loop + + _pos += size; + _ptr += size; + } while (READ_UINT32(result) != tag); + } + + return result; +} + +const byte *findResource(uint32 tag, const byte *searchin) { + uint32 curpos, totalsize, size; + + assert(searchin); + + searchin += 4; + totalsize = READ_BE_UINT32(searchin); + curpos = 8; + searchin += 4; + + while (curpos < totalsize) { + if (READ_UINT32(searchin) == tag) + return searchin; + + size = READ_BE_UINT32(searchin + 4); + if ((int32)size <= 0) { + error("(%c%c%c%c) Not found in %d... illegal block len %d", + tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size); + return NULL; + } + + curpos += size; + searchin += size; + } + + return NULL; +} + +const byte *findResourceSmall(uint32 tag, const byte *searchin) { + uint32 curpos, totalsize, size; + uint16 smallTag; + + smallTag = newTag2Old(tag); + + assert(searchin); + + totalsize = READ_LE_UINT32(searchin); + searchin += 6; + curpos = 6; + + while (curpos < totalsize) { + size = READ_LE_UINT32(searchin); + + if (READ_LE_UINT16(searchin + 4) == smallTag) + return searchin; + + if ((int32)size <= 0) { + error("(%c%c%c%c) Not found in %d... illegal block len %d", + tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size); + return NULL; + } + + curpos += size; + searchin += size; + } + + return NULL; +} + uint16 newTag2Old(uint32 oldTag) { switch (oldTag) { case (MKID('RMHD')): |