aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTravis Howell2011-08-28 10:40:23 +1000
committerTravis Howell2011-08-28 10:40:23 +1000
commitb3457144ed6a4002ea8b51ac93ba14047950c262 (patch)
tree377c407a860c73cf578ac705c37ef741980e0be0 /engines
parent4e83a49b0fe42de37827ecffe5a65e492e76ea06 (diff)
downloadscummvm-rg350-b3457144ed6a4002ea8b51ac93ba14047950c262.tar.gz
scummvm-rg350-b3457144ed6a4002ea8b51ac93ba14047950c262.tar.bz2
scummvm-rg350-b3457144ed6a4002ea8b51ac93ba14047950c262.zip
SCUMM: Add basic support for setOffHeap resource flag in HE90+ games.
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/he/intern_he.h1
-rw-r--r--engines/scumm/he/resource_he.cpp34
-rw-r--r--engines/scumm/he/script_v90he.cpp2
-rw-r--r--engines/scumm/resource.cpp29
-rw-r--r--engines/scumm/resource.h9
5 files changed, 70 insertions, 5 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index f4df6571fa..cdc5faa084 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -458,6 +458,7 @@ protected:
virtual void saveOrLoad(Serializer *s);
virtual void readMAXS(int blockSize);
+ void setResourceOffHeap(int typeId, int resId, int val);
virtual void processActors();
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index 39240e347f..42748d08ed 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -386,6 +386,40 @@ int ScummEngine_v72he::getSoundResourceSize(ResId id) {
return size;
}
+void ScummEngine_v90he::setResourceOffHeap(int typeId, int resId, int val) {
+ debug(0, "setResourceOffHeap: type %d resId %d toggle %d", typeId, resId, val);
+ ResType type;
+
+ switch (typeId) {
+ case 1:
+ type = rtRoom;
+ break;
+ case 2:
+ type = rtScript;
+ break;
+ case 3:
+ type = rtCostume;
+ break;
+ case 4:
+ type = rtSound;
+ break;
+ case 6:
+ type = rtCharset;
+ break;
+ case 19:
+ type = rtImage;
+ break;
+ default:
+ error("setResourceOffHeap: default case %d", typeId);
+ }
+
+ if (val == 1) {
+ _res->setOffHeap(type, resId);
+ } else {
+ _res->setOnHeap(type, resId);
+ }
+}
+
#endif
} // End of namespace Scumm
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 66a0a34d16..877f8b239d 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -2358,7 +2358,7 @@ void ScummEngine_v90he::o90_kernelSetFunctions() {
_wiz->_rectOverrideEnabled = false;
break;
case 714:
- debug(5, "o90_kernelSetFunctions: case 714: type %d resId %d unk1 %d", args[1], args[2], args[3]);
+ setResourceOffHeap(args[1], args[2], args[3]);
break;
case 1492:
// Remote start script function
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 10301da3e3..8c34ed3626 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -47,7 +47,8 @@ enum {
RF_USAGE = 0x7F,
RF_USAGE_MAX = RF_USAGE,
- RS_MODIFIED = 0x10
+ RS_MODIFIED = 0x10,
+ RF_OFFHEAP = 0x40
};
@@ -938,6 +939,18 @@ void ResourceManager::unlock(ResType type, ResId idx) {
_types[type][idx].unlock();
}
+void ResourceManager::setOffHeap(ResType type, ResId idx) {
+ if (!validateResource("setOffHeap", type, idx))
+ return;
+ _types[type][idx].setOffHeap();
+}
+
+void ResourceManager::setOnHeap(ResType type, ResId idx) {
+ if (!validateResource("setOnHeap", type, idx))
+ return;
+ _types[type][idx].setOnHeap();
+}
+
bool ResourceManager::isLocked(ResType type, ResId idx) const {
if (!validateResource("isLocked", type, idx))
return false;
@@ -956,6 +969,18 @@ bool ResourceManager::Resource::isLocked() const {
return (_flags & RF_LOCK) != 0;
}
+void ResourceManager::Resource::setOffHeap() {
+ _flags |= RF_OFFHEAP;
+}
+
+void ResourceManager::Resource::setOnHeap() {
+ _flags &= ~RF_OFFHEAP;
+}
+
+bool ResourceManager::Resource::isOffHeap() const {
+ return (_flags & RF_OFFHEAP) != 0;
+}
+
bool ScummEngine::isResourceInUse(ResType type, ResId idx) const {
if (!_res->validateResource("isResourceInUse", type, idx))
return false;
@@ -1035,7 +1060,7 @@ void ResourceManager::expireResources(uint32 size) {
while (idx-- > 0) {
Resource &tmp = _types[type][idx];
byte counter = tmp.getResourceCounter();
- if (!tmp.isLocked() && counter >= best_counter && tmp._address && !_vm->isResourceInUse(type, idx)) {
+ if (!tmp.isLocked() && counter >= best_counter && tmp._address && !_vm->isResourceInUse(type, idx) && !tmp.isOffHeap()) {
best_counter = counter;
best_type = type;
best_res = idx;
diff --git a/engines/scumm/resource.h b/engines/scumm/resource.h
index 2e8960717f..ddecca43a2 100644
--- a/engines/scumm/resource.h
+++ b/engines/scumm/resource.h
@@ -134,12 +134,15 @@ public:
inline void setResourceCounter(byte counter);
inline byte getResourceCounter() const;
+ // HE specific
void lock();
void unlock();
bool isLocked() const;
-
void setModified();
bool isModified() const;
+ void setOffHeap();
+ void setOnHeap();
+ bool isOffHeap() const;
};
/**
@@ -188,12 +191,14 @@ public:
bool isResourceLoaded(ResType type, ResId idx) const;
+ // HE Specific
void lock(ResType type, ResId idx);
void unlock(ResType type, ResId idx);
bool isLocked(ResType type, ResId idx) const;
-
void setModified(ResType type, ResId idx);
bool isModified(ResType type, ResId idx) const;
+ void setOffHeap(ResType type, ResId idx);
+ void setOnHeap(ResType type, ResId idx);
/**
* This method increments the _expireCounter, and if it overflows (which happens