2003-12-16 02:10:15 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2003-2006 The ScummVM project
|
2003-12-16 02:10:15 +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.
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RESMAN_H
|
|
|
|
#define RESMAN_H
|
|
|
|
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/memman.h"
|
2004-11-05 22:12:07 +00:00
|
|
|
#include "common/file.h"
|
2004-10-21 12:43:49 +00:00
|
|
|
#include "sword1/sworddefs.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
namespace Sword1 {
|
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#define MAX_LABEL_SIZE (31+1)
|
2005-12-27 19:17:53 +00:00
|
|
|
|
|
|
|
#if defined(__PSP__)
|
|
|
|
#define MAX_OPEN_CLUS 4 // the PSP can't have more than 8 files open simultaneously
|
|
|
|
// since we also need filehandles for music and sometimes savegames
|
|
|
|
// set the maximum number of open clusters to 4.
|
|
|
|
#else
|
2005-02-20 18:53:30 +00:00
|
|
|
#define MAX_OPEN_CLUS 8 // don't open more than 8 files at once
|
2005-12-27 19:17:53 +00:00
|
|
|
#endif
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
struct Grp {
|
2003-12-16 02:10:15 +00:00
|
|
|
uint32 noRes;
|
2004-01-11 15:47:41 +00:00
|
|
|
MemHandle *resHandle;
|
2003-12-16 02:10:15 +00:00
|
|
|
uint32 *offset;
|
|
|
|
uint32 *length;
|
|
|
|
};
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
struct Clu {
|
2005-02-20 18:53:30 +00:00
|
|
|
uint32 refCount;
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File *file;
|
2003-12-16 02:10:15 +00:00
|
|
|
char label[MAX_LABEL_SIZE];
|
|
|
|
uint32 noGrp;
|
2005-02-20 18:53:30 +00:00
|
|
|
Grp *grp;
|
|
|
|
Clu *nextOpen;
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
struct Prj {
|
2003-12-16 02:10:15 +00:00
|
|
|
uint32 noClu;
|
2005-02-20 18:53:30 +00:00
|
|
|
Clu *clu;
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ResMan {
|
|
|
|
public:
|
2005-02-21 08:15:15 +00:00
|
|
|
ResMan(const char *fileName);
|
2003-12-16 02:10:15 +00:00
|
|
|
~ResMan(void);
|
2003-12-20 09:12:54 +00:00
|
|
|
void flush(void);
|
2003-12-16 02:10:15 +00:00
|
|
|
void resClose(uint32 id);
|
|
|
|
void resOpen(uint32 id);
|
|
|
|
void *fetchRes(uint32 id);
|
|
|
|
void dumpRes(uint32 id);
|
|
|
|
void *openFetchRes(uint32 id);
|
|
|
|
void *cptResOpen(uint32 id);
|
|
|
|
Header *lockScript(uint32 scrID);
|
|
|
|
void unlockScript(uint32 scrID);
|
|
|
|
FrameHeader *fetchFrame(void *resourceData, uint32 frameNo);
|
|
|
|
private:
|
2005-02-20 18:53:30 +00:00
|
|
|
uint32 resLength(uint32 id);
|
2004-01-11 15:47:41 +00:00
|
|
|
MemHandle *resHandle(uint32 id);
|
2005-02-20 18:53:30 +00:00
|
|
|
uint32 resOffset(uint32 id);
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File *resFile(uint32 id);
|
2005-02-20 18:53:30 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
void openCptResourceBigEndian(uint32 id);
|
|
|
|
void openScriptResourceBigEndian(uint32 id);
|
|
|
|
|
|
|
|
void loadCluDescript(const char *fileName);
|
|
|
|
void freeCluDescript(void);
|
2004-01-11 15:47:41 +00:00
|
|
|
Prj _prj;
|
2003-12-16 02:10:15 +00:00
|
|
|
MemMan *_memMan;
|
|
|
|
static const uint32 _scriptList[TOTAL_SECTIONS]; //a table of resource tags
|
2003-12-20 16:30:58 +00:00
|
|
|
static uint32 _srIdList[29];
|
2005-02-20 18:53:30 +00:00
|
|
|
Clu *_openCluStart, *_openCluEnd;
|
|
|
|
int _openClus;
|
2003-12-16 02:10:15 +00:00
|
|
|
};
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
} // End of namespace Sword1
|
2004-01-11 15:47:41 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#endif //RESMAN_H
|