aboutsummaryrefslogtreecommitdiff
path: root/sword1/resman.h
diff options
context:
space:
mode:
authorRobert Göffringmann2005-02-20 18:53:30 +0000
committerRobert Göffringmann2005-02-20 18:53:30 +0000
commitb455a94e0fb2cb522a75cb1e2a98422f860de9b1 (patch)
tree767f4206869b970d4d4da44df890b62016669b74 /sword1/resman.h
parent7c54b0af7dbe6a6f3710a738dffcdb87c13f032b (diff)
downloadscummvm-rg350-b455a94e0fb2cb522a75cb1e2a98422f860de9b1.tar.gz
scummvm-rg350-b455a94e0fb2cb522a75cb1e2a98422f860de9b1.tar.bz2
scummvm-rg350-b455a94e0fb2cb522a75cb1e2a98422f860de9b1.zip
cache datafile handles instead of opening and closing all files hundreds of times per second. I noticed that behaviour on the PS2. The cd/dvd drive was waaaay too slow for it. ;)
svn-id: r16830
Diffstat (limited to 'sword1/resman.h')
-rw-r--r--sword1/resman.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/sword1/resman.h b/sword1/resman.h
index ca0b32fb0b..d2fcafc36f 100644
--- a/sword1/resman.h
+++ b/sword1/resman.h
@@ -29,6 +29,7 @@
namespace Sword1 {
#define MAX_LABEL_SIZE (31+1)
+#define MAX_OPEN_CLUS 8 // don't open more than 8 files at once
struct Grp {
uint32 noRes;
@@ -38,14 +39,17 @@ struct Grp {
};
struct Clu {
+ uint32 refCount;
+ File *file;
char label[MAX_LABEL_SIZE];
uint32 noGrp;
- Grp **grp;
+ Grp *grp;
+ Clu *nextOpen;
};
struct Prj {
uint32 noClu;
- Clu **clu;
+ Clu *clu;
};
class ResMan {
@@ -63,20 +67,22 @@ public:
void unlockScript(uint32 scrID);
FrameHeader *fetchFrame(void *resourceData, uint32 frameNo);
private:
- uint32 filesInGroup(uint32 id);
- uint32 resLength(uint32 id);
+ uint32 resLength(uint32 id);
MemHandle *resHandle(uint32 id);
- uint32 resOffset(uint32 id);
+ uint32 resOffset(uint32 id);
+ File *resFile(uint32 id);
+
void openCptResourceBigEndian(uint32 id);
void openScriptResourceBigEndian(uint32 id);
- File *openClusterFile(uint32 id);
void loadCluDescript(const char *fileName);
void freeCluDescript(void);
Prj _prj;
MemMan *_memMan;
static const uint32 _scriptList[TOTAL_SECTIONS]; //a table of resource tags
static uint32 _srIdList[29];
+ Clu *_openCluStart, *_openCluEnd;
+ int _openClus;
};
} // End of namespace Sword1