2008-07-23 09:02:47 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* A (some would say very) small collection of utility functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "tinsel/dw.h"
|
|
|
|
#include "tinsel/film.h"
|
|
|
|
#include "tinsel/handle.h"
|
|
|
|
#include "tinsel/multiobj.h"
|
|
|
|
#include "tinsel/scn.h"
|
|
|
|
#include "tinsel/tinsel.h" // for _vm
|
|
|
|
|
|
|
|
namespace Tinsel {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a scene handle and a chunk id, gets the scene in RAM and
|
|
|
|
* locates the requested chunk.
|
|
|
|
* @param handle Scene handle
|
|
|
|
* @param chunk Chunk Id
|
|
|
|
*/
|
|
|
|
byte *FindChunk(SCNHANDLE handle, uint32 chunk) {
|
|
|
|
byte *bptr = LockMem(handle);
|
|
|
|
uint32 *lptr = (uint32 *)bptr;
|
|
|
|
uint32 add;
|
|
|
|
|
2008-12-01 20:35:36 +00:00
|
|
|
// Initial adjustmnet for Tinsel 1 chunk types
|
|
|
|
if ((TinselVersion != TINSEL_V2) && (chunk >= CHUNK_SCENE) &&
|
|
|
|
(chunk != CHUNK_MBSTRING))
|
|
|
|
--chunk;
|
|
|
|
|
|
|
|
// V0 chunk types can be found by substracting 2 from the
|
2008-07-23 09:02:47 +00:00
|
|
|
// chunk type. Note that CHUNK_STRING and CHUNK_BITMAP are
|
2008-12-01 20:35:36 +00:00
|
|
|
// the same in V0 and V1
|
2009-01-01 15:06:43 +00:00
|
|
|
if (TinselVersion == TINSEL_V0 &&
|
2008-07-23 09:02:47 +00:00
|
|
|
chunk != CHUNK_STRING && chunk != CHUNK_BITMAP)
|
|
|
|
chunk -= 0x2L;
|
|
|
|
|
|
|
|
while (1) {
|
2012-12-11 00:56:48 +00:00
|
|
|
if (READ_32(lptr) == chunk)
|
2008-07-23 09:02:47 +00:00
|
|
|
return (byte *)(lptr + 2);
|
|
|
|
|
|
|
|
++lptr;
|
2012-12-11 00:56:48 +00:00
|
|
|
add = READ_32(lptr);
|
2010-11-20 03:14:03 +00:00
|
|
|
|
2008-07-23 09:02:47 +00:00
|
|
|
if (!add)
|
2010-11-20 03:14:03 +00:00
|
|
|
// End of file reached
|
2008-07-23 09:02:47 +00:00
|
|
|
return NULL;
|
|
|
|
|
2010-11-20 03:14:03 +00:00
|
|
|
// Move to next chunk
|
2008-07-23 09:02:47 +00:00
|
|
|
lptr = (uint32 *)(bptr + add);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Tinsel
|