aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra/resource.h')
-rw-r--r--engines/kyra/resource.h173
1 files changed, 168 insertions, 5 deletions
diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h
index 6319e31477..6520fe609f 100644
--- a/engines/kyra/resource.h
+++ b/engines/kyra/resource.h
@@ -61,13 +61,8 @@ private:
Common::List<PakChunk*> _files; // the entries
};
-// some resource types
-class Movie;
-class VMContext;
-
class Resource {
public:
-
Resource(KyraEngine *engine);
~Resource();
@@ -91,6 +86,174 @@ protected:
Common::List<PakFileEntry> _pakfiles;
};
+// TODO?: maybe prefix all things here with 'kKyra1' instead of 'k'
+enum kKyraResources {
+ kLoadAll = -1,
+
+ kForestSeq,
+ kKallakWritingSeq,
+ kKyrandiaLogoSeq,
+ kKallakMalcolmSeq,
+ kMalcolmTreeSeq,
+ kWestwoodLogoSeq,
+
+ kDemo1Seq,
+ kDemo2Seq,
+ kDemo3Seq,
+ kDemo4Seq,
+
+ kAmuleteAnimSeq,
+
+ kOutroReunionSeq,
+
+ kIntroCPSStrings,
+ kIntroCOLStrings,
+ kIntroWSAStrings,
+ kIntroStrings,
+
+ kOutroHomeString,
+
+ kRoomFilenames,
+ kRoomList,
+
+ kCharacterImageFilenames,
+
+ kItemNames,
+ kTakenStrings,
+ kPlacedStrings,
+ kDroppedStrings,
+ kNoDropStrings,
+
+ kPutDownString,
+ kWaitAmuletString,
+ kBlackJewelString,
+ kPoisonGoneString,
+ kHealingTipString,
+ kWispJewelStrings,
+ kMagicJewelStrings,
+
+ kThePoisonStrings,
+ kFluteStrings,
+
+ kFlaskFullString,
+ kFullFlaskString,
+
+ kVeryCleverString,
+
+ kDefaultShapes,
+ kHealing1Shapes,
+ kHealing2Shapes,
+ kPoisonDeathShapes,
+ kFluteShapes,
+ kWinter1Shapes,
+ kWinter2Shapes,
+ kWinter3Shapes,
+ kDrinkShapes,
+ kWispShapes,
+ kMagicAnimShapes,
+ kBranStoneShapes,
+
+ kPaletteList,
+
+ kMaxResIDs
+};
+
+struct Shape;
+struct Room;
+
+class StaticResource {
+public:
+ StaticResource(KyraEngine *engine) : _engine(engine), _resList(), _fileLoader(0), _builtIn(0), _filenameTable(0) {}
+ ~StaticResource() { deinit(); }
+
+ bool init();
+ void deinit();
+
+ const char **loadStrings(int id, int &strings);
+ const uint8 *loadRawData(int id, int &size);
+ const Shape *loadShapeTable(int id, int &entries);
+ const Room *loadRoomTable(int id, int &entries);
+ const uint8 **loadPaletteTable(int id, int &entries);
+
+ // use '-1' to prefetch/unload all ids
+ // prefetchId retruns false if only on of the resources
+ // can't be loaded and it breaks then the first res
+ // can't be loaded
+ bool prefetchId(int id);
+ void unloadId(int id);
+private:
+ KyraEngine *_engine;
+
+ struct FilenameTable;
+ struct ResData;
+ struct FileType;
+
+ bool checkResList(int id, int &type, const void *&ptr, int &size);
+ const void *checkForBuiltin(int id, int &type, int &size);
+ const FilenameTable *searchFile(int id);
+ const FileType *getFiletype(int type);
+ const void *getData(int id, int requesttype, int &size);
+
+ bool loadLanguageTable(const char *filename, void *&ptr, int &size);
+ bool loadStringTable(const char *filename, void *&ptr, int &size);
+ bool loadRawData(const char *filename, void *&ptr, int &size);
+ bool loadShapeTable(const char *filename, void *&ptr, int &size);
+ bool loadRoomTable(const char *filename, void *&ptr, int &size);
+ bool loadPaletteTable(const char *filename, void *&ptr, int &size);
+
+ void freeRawData(void *&ptr, int &size);
+ void freeStringTable(void *&ptr, int &size);
+ void freeShapeTable(void *&ptr, int &size);
+ void freeRoomTable(void *&ptr, int &size);
+ void freePaletteTable(void *&ptr, int &size);
+
+ uint8 *getFile(const char *name, int &size);
+
+ enum kResTypes {
+ kLanguageList,
+ kStringList,
+ kRoomList,
+ kShapeList,
+ kRawData,
+ kPaletteTable
+ };
+
+ struct BuiltinRes {
+ int id;
+ int type;
+ int size;
+ const void *data;
+ };
+
+ struct FilenameTable {
+ int id;
+ int type;
+ const char *filename;
+ };
+
+ struct FileType {
+ int type;
+ typedef bool (StaticResource::*LoadFunc)(const char *filename, void *&ptr, int &size);
+ typedef void (StaticResource::*FreeFunc)(void *&ptr, int &size);
+
+ LoadFunc load;
+ FreeFunc free;
+ };
+
+ struct ResData {
+ int id;
+ int type;
+ int size;
+ void *data;
+ };
+
+ Common::List<ResData> _resList;
+
+ const FileType *_fileLoader;
+ const BuiltinRes *_builtIn;
+ const FilenameTable *_filenameTable;
+};
+
} // end of namespace Kyra
#endif