2004-01-06 17:28:29 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2001-2005 The ScummVM project
|
2004-01-06 17:28:29 +00:00
|
|
|
*
|
|
|
|
* 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-01-06 17:28:29 +00:00
|
|
|
*
|
2004-05-23 19:44:10 +00:00
|
|
|
* $Header$
|
2004-01-06 17:28:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BUNDLE_MGR_H
|
|
|
|
#define BUNDLE_MGR_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/file.h"
|
2005-05-23 23:59:20 +00:00
|
|
|
#include "scumm/util.h"
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
namespace Scumm {
|
|
|
|
|
2004-01-07 04:50:38 +00:00
|
|
|
class BundleDirCache {
|
2004-01-07 03:34:41 +00:00
|
|
|
public:
|
|
|
|
struct AudioTable {
|
2005-01-25 22:21:26 +00:00
|
|
|
char filename[24];
|
2004-01-07 03:34:41 +00:00
|
|
|
int32 offset;
|
2005-01-25 22:21:26 +00:00
|
|
|
int32 size;
|
2004-01-07 03:34:41 +00:00
|
|
|
};
|
2004-01-07 04:50:38 +00:00
|
|
|
private:
|
2004-01-06 17:28:29 +00:00
|
|
|
|
2004-01-07 04:50:38 +00:00
|
|
|
struct FileDirCache {
|
|
|
|
char fileName[20];
|
|
|
|
AudioTable *bundleTable;
|
|
|
|
int32 numFiles;
|
2005-01-25 22:21:26 +00:00
|
|
|
bool compressedBun;
|
2004-01-07 04:50:38 +00:00
|
|
|
} _budleDirCache[4];
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-07 04:50:38 +00:00
|
|
|
public:
|
|
|
|
BundleDirCache();
|
|
|
|
~BundleDirCache();
|
|
|
|
|
2005-01-25 22:21:26 +00:00
|
|
|
int matchFile(const char *filename);
|
|
|
|
AudioTable *getTable(const char *filename, int slot);
|
|
|
|
int32 getNumFiles(const char *filename, int slot);
|
|
|
|
bool isCompressed(int slot);
|
2004-01-07 04:50:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BundleMgr {
|
2004-01-06 17:28:29 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
struct CompTable {
|
|
|
|
int32 offset;
|
|
|
|
int32 size;
|
|
|
|
int32 codec;
|
|
|
|
};
|
|
|
|
|
2004-01-07 04:50:38 +00:00
|
|
|
BundleDirCache *_cache;
|
|
|
|
BundleDirCache::AudioTable *_bundleTable;
|
2004-01-07 03:34:41 +00:00
|
|
|
CompTable *_compTable;
|
2004-05-23 19:32:11 +00:00
|
|
|
int _numFiles;
|
|
|
|
int _numCompItems;
|
|
|
|
int _curSample;
|
2005-05-23 23:59:20 +00:00
|
|
|
ScummFile _file;
|
2004-01-07 03:34:41 +00:00
|
|
|
bool _compTableLoaded;
|
|
|
|
int _fileBundleId;
|
2004-05-23 19:32:11 +00:00
|
|
|
byte _compOutput[0x2000];
|
|
|
|
byte *_compInput;
|
|
|
|
int _outputSize;
|
|
|
|
int _lastBlock;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-08-28 14:06:36 +00:00
|
|
|
bool loadCompTable(int32 index);
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
public:
|
2004-01-07 03:34:41 +00:00
|
|
|
|
2004-01-07 04:50:38 +00:00
|
|
|
BundleMgr(BundleDirCache *_cache);
|
2004-01-06 17:28:29 +00:00
|
|
|
~BundleMgr();
|
|
|
|
|
2005-09-02 01:41:53 +00:00
|
|
|
bool open(const char *filename, bool &compressed, bool errorFlag=false);
|
2005-01-25 22:21:26 +00:00
|
|
|
void close();
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File *getFile(const char *filename, int32 &offset, int32 &size);
|
2004-01-09 13:16:06 +00:00
|
|
|
int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final, bool header_outside);
|
|
|
|
int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
|
|
|
|
int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size, bool header_outside);
|
2004-01-06 17:28:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace BundleCodecs {
|
|
|
|
|
2004-10-17 19:40:34 +00:00
|
|
|
uint32 decode12BitsSample(const byte *src, byte **dst, uint32 size);
|
2004-01-06 17:28:29 +00:00
|
|
|
void initializeImcTables();
|
2005-10-08 21:25:09 +00:00
|
|
|
#ifdef PALMOS_68K
|
2004-01-08 12:14:48 +00:00
|
|
|
void releaseImcTables();
|
|
|
|
#endif
|
2004-01-06 17:28:29 +00:00
|
|
|
int32 decompressCodec(int32 codec, byte *comp_input, byte *comp_output, int32 input_size);
|
|
|
|
|
|
|
|
} // End of namespace BundleCodecs
|
|
|
|
|
|
|
|
} // End of namespace Scumm
|
|
|
|
|
|
|
|
#endif
|