[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.214,1.215 gfx.cpp,2.425,2.426 object.cpp,1.213,1.214 resource.cpp,1.296,1.297 saveload.cpp,1.200,1.201 script.cpp,1.210,1.211 script_v100he.cpp,2.103,2.104 script_v2.cpp,2.268,2.269 script_v5.cpp,1.274,1.275 script_v6.cpp,1.426,1.427 script_v7he.cpp,2.137,2.138 script_v8.cpp,2.285,2.286 scumm.cpp,1.392,1.393 scumm.h,1.554,1.555 sound.cpp,1.432,1.433 string.cpp,1.272,1.273 verbs.cpp,1.123,1.124 wiz_he.cpp,2.30,2.31
Max Horn
fingolfin at users.sourceforge.net
Thu Mar 31 13:54:06 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse_sndmgr.cpp,1.67,1.68
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.407,2.408 script_v100he.cpp,2.104,2.105 script_v90he.cpp,2.202,2.203 sprite_he.cpp,1.111,1.112 sprite_he.h,1.27,1.28 wiz_he.cpp,2.31,2.32 wiz_he.h,2.12,2.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2195
Modified Files:
akos.cpp gfx.cpp object.cpp resource.cpp saveload.cpp
script.cpp script_v100he.cpp script_v2.cpp script_v5.cpp
script_v6.cpp script_v7he.cpp script_v8.cpp scumm.cpp scumm.h
sound.cpp string.cpp verbs.cpp wiz_he.cpp
Log Message:
Started to move some resource related code into a new class ResourceManager (hypothetic goal for the future: use ResourceManager in ScummEx)
Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.214
retrieving revision 1.215
diff -u -d -r1.214 -r1.215
--- akos.cpp 30 Mar 2005 14:54:22 -0000 1.214
+++ akos.cpp 31 Mar 2005 21:38:29 -0000 1.215
@@ -739,7 +739,7 @@
/* implement custom scale table */
v1.scaletable = (_vm->_features & GF_HUMONGOUS) ? oldScaleTable : defaultScaleTable;
- if (_vm->VAR_CUSTOMSCALETABLE != 0xFF && _vm->isResourceLoaded(rtString, _vm->VAR(_vm->VAR_CUSTOMSCALETABLE))) {
+ if (_vm->VAR_CUSTOMSCALETABLE != 0xFF && _vm->res.isResourceLoaded(rtString, _vm->VAR(_vm->VAR_CUSTOMSCALETABLE))) {
v1.scaletable = _vm->getStringAddressVar(_vm->VAR_CUSTOMSCALETABLE);
}
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.425
retrieving revision 2.426
diff -u -d -r2.425 -r2.426
--- gfx.cpp 28 Mar 2005 20:27:09 -0000 2.425
+++ gfx.cpp 31 Mar 2005 21:38:30 -0000 2.426
@@ -254,8 +254,8 @@
int adj = 0;
for (i = 0; i < 3; i++) {
- nukeResource(rtBuffer, i + 1);
- nukeResource(rtBuffer, i + 5);
+ res.nukeResource(rtBuffer, i + 1);
+ res.nukeResource(rtBuffer, i + 5);
}
if (!getResourceAddress(rtBuffer, 4)) {
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -d -r1.213 -r1.214
--- object.cpp 28 Mar 2005 20:18:35 -0000 1.213
+++ object.cpp 31 Mar 2005 21:38:33 -0000 1.214
@@ -521,7 +521,7 @@
} else {
// Nuke all unlocked flObjects
if (!(res.flags[rtFlObject][_objs[i].fl_object_index] & RF_LOCK)) {
- nukeResource(rtFlObject, _objs[i].fl_object_index);
+ res.nukeResource(rtFlObject, _objs[i].fl_object_index);
_objs[i].obj_nr = 0;
_objs[i].fl_object_index = 0;
}
@@ -896,7 +896,7 @@
if (_objs[i].obj_nr == obj) {
if (!_objs[i].fl_object_index)
return;
- nukeResource(rtFlObject, _objs[i].fl_object_index);
+ res.nukeResource(rtFlObject, _objs[i].fl_object_index);
_objs[i].obj_nr = 0;
_objs[i].fl_object_index = 0;
}
@@ -908,7 +908,7 @@
if (_inventory[i] == obj) {
j = whereIsObject(obj);
if (j == WIO_INVENTORY) {
- nukeResource(rtInventory, i);
+ res.nukeResource(rtInventory, i);
_inventory[i] = 0;
}
a = _inventory;
@@ -990,7 +990,7 @@
for (i = 0; i < _numNewNames; i++) {
if (_newNames[i] == obj) {
- nukeResource(rtObjectName, i);
+ res.nukeResource(rtObjectName, i);
_newNames[i] = 0;
break;
}
@@ -1420,7 +1420,7 @@
for (i = (_numLocalObjects-1), od = _objs; --i >= 0; od++)
if (od->fl_object_index && od->obj_nr >= min && od->obj_nr <= max) {
- nukeResource(rtFlObject, od->fl_object_index);
+ res.nukeResource(rtFlObject, od->fl_object_index);
od->obj_nr = 0;
od->fl_object_index = 0;
}
@@ -1638,9 +1638,9 @@
isRoomLocked = ((res.flags[rtRoom][room] & RF_LOCK) != 0);
isRoomScriptsLocked = ((res.flags[rtRoomScripts][room] & RF_LOCK) != 0);
if (!isRoomLocked)
- lock(rtRoom, room);
+ res.lock(rtRoom, room);
if (_version == 8 && !isRoomScriptsLocked)
- lock(rtRoomScripts, room);
+ res.lock(rtRoomScripts, room);
// Allocate slot & memory for floating object
slot = findFlObjectSlot();
@@ -1656,9 +1656,9 @@
// Unlock room/roomScripts
if (!isRoomLocked)
- unlock(rtRoom, room);
+ res.unlock(rtRoom, room);
if (_version == 8 && !isRoomScriptsLocked)
- unlock(rtRoomScripts, room);
+ res.unlock(rtRoomScripts, room);
// Setup local object flags
setupRoomObject(od, flob, flob);
Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.296
retrieving revision 1.297
diff -u -d -r1.296 -r1.297
--- resource.cpp 30 Mar 2005 21:57:48 -0000 1.296
+++ resource.cpp 31 Mar 2005 21:38:34 -0000 1.297
@@ -631,7 +631,7 @@
void ScummEngine::nukeCharset(int i) {
checkRange(_numCharsets - 1, 1, i, "Nuking illegal charset %d");
- nukeResource(rtCharset, i);
+ res.nukeResource(rtCharset, i);
}
void ScummEngine::ensureResourceLoaded(int type, int i) {
@@ -749,7 +749,7 @@
return 1;
}
- nukeResource(type, idx);
+ res.nukeResource(type, idx);
error("Cannot read resource");
}
@@ -771,7 +771,7 @@
byte *ptr;
CHECK_HEAP
- if (!validateResource("getResourceAddress", type, idx))
+ if (!res.validateResource("getResourceAddress", type, idx))
return NULL;
if (!res.address[type]) {
@@ -788,7 +788,7 @@
return NULL;
}
- setResourceCounter(type, idx, 1);
+ res.setResourceCounter(type, idx, 1);
debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d) == %p", resTypeFromId(type), idx, ptr + sizeof(MemBlkHeader));
return ptr + sizeof(MemBlkHeader);
@@ -811,9 +811,23 @@
return getStringAddress(_scummVars[i]);
}
-void ScummEngine::setResourceCounter(int type, int idx, byte flag) {
- res.flags[type][idx] &= ~RF_USAGE;
- res.flags[type][idx] |= flag;
+void ResourceManager::increaseResourceCounter() {
+ int i, j;
+ byte counter;
+
+ for (i = rtFirst; i <= rtLast; i++) {
+ for (j = num[i]; --j >= 0;) {
+ counter = flags[i][j] & RF_USAGE;
+ if (counter && counter < RF_USAGE_MAX) {
+ setResourceCounter(i, j, counter + 1);
+ }
+ }
+ }
+}
+
+void ResourceManager::setResourceCounter(int type, int idx, byte flag) {
+ flags[type][idx] &= ~RF_USAGE;
+ flags[type][idx] |= flag;
}
/* 2 bytes safety area to make "precaching" of bytes in the gdi drawer easier */
@@ -825,9 +839,9 @@
CHECK_HEAP
debugC(DEBUG_RESOURCE, "createResource(%s,%d,%d)", resTypeFromId(type), idx, size);
- if (!validateResource("allocating", type, idx))
+ if (!res.validateResource("allocating", type, idx))
return NULL;
- nukeResource(type, idx);
+ res.nukeResource(type, idx);
expireResources(size);
@@ -837,35 +851,41 @@
error("Out of memory while allocating %d", size);
}
- _allocatedSize += size;
+ res._allocatedSize += size;
res.address[type][idx] = ptr;
((MemBlkHeader *)ptr)->size = size;
- setResourceCounter(type, idx, 1);
+ res.setResourceCounter(type, idx, 1);
return ptr + sizeof(MemBlkHeader); /* skip header */
}
-bool ScummEngine::validateResource(const char *str, int type, int idx) const {
- if (type < rtFirst || type > rtLast || (uint) idx >= (uint) res.num[type]) {
+ResourceManager::ResourceManager(ScummEngine *vm) {
+ memset(this, 0, sizeof(ResourceManager));
+ _vm = vm;
+// _allocatedSize = 0;
+}
+
+bool ResourceManager::validateResource(const char *str, int type, int idx) const {
+ if (type < rtFirst || type > rtLast || (uint) idx >= (uint)num[type]) {
warning("%s Illegal Glob type %s (%d) num %d", str, resTypeFromId(type), type, idx);
return false;
}
return true;
}
-void ScummEngine::nukeResource(int type, int idx) {
+void ResourceManager::nukeResource(int type, int idx) {
byte *ptr;
CHECK_HEAP
- if (!res.address[type])
+ if (!address[type])
return;
- assert(idx >= 0 && idx < res.num[type]);
+ assert(idx >= 0 && idx < num[type]);
- if ((ptr = res.address[type][idx]) != NULL) {
+ if ((ptr = address[type][idx]) != NULL) {
debugC(DEBUG_RESOURCE, "nukeResource(%s,%d)", resTypeFromId(type), idx);
- res.address[type][idx] = 0;
- res.flags[type][idx] = 0;
+ address[type][idx] = 0;
+ flags[type][idx] = 0;
_allocatedSize -= ((MemBlkHeader *)ptr)->size;
free(ptr);
}
@@ -896,20 +916,20 @@
return READ_BE_UINT32(ptr - 4) - 8;
}
-void ScummEngine::lock(int type, int i) {
+void ResourceManager::lock(int type, int i) {
if (!validateResource("Locking", type, i))
return;
- res.flags[type][i] |= RF_LOCK;
+ flags[type][i] |= RF_LOCK;
}
-void ScummEngine::unlock(int type, int i) {
+void ResourceManager::unlock(int type, int i) {
if (!validateResource("Unlocking", type, i))
return;
- res.flags[type][i] &= ~RF_LOCK;
+ flags[type][i] &= ~RF_LOCK;
}
bool ScummEngine::isResourceInUse(int type, int i) const {
- if (!validateResource("isResourceInUse", type, i))
+ if (!res.validateResource("isResourceInUse", type, i))
return false;
switch (type) {
case rtRoom:
@@ -927,20 +947,6 @@
}
}
-void ScummEngine::increaseResourceCounter() {
- int i, j;
- byte counter;
-
- for (i = rtFirst; i <= rtLast; i++) {
- for (j = res.num[i]; --j >= 0;) {
- counter = res.flags[i][j] & RF_USAGE;
- if (counter && counter < RF_USAGE_MAX) {
- setResourceCounter(i, j, counter + 1);
- }
- }
- }
-}
-
void ScummEngine::expireResources(uint32 size) {
int i, j;
byte flag;
@@ -948,15 +954,15 @@
int best_type, best_res = 0;
uint32 oldAllocatedSize;
- if (_expire_counter != 0xFF) {
- _expire_counter = 0xFF;
- increaseResourceCounter();
+ if (res._expireCounter != 0xFF) {
+ res._expireCounter = 0xFF;
+ res.increaseResourceCounter();
}
- if (size + _allocatedSize < _maxHeapThreshold)
+ if (size + res._allocatedSize < res._maxHeapThreshold)
return;
- oldAllocatedSize = _allocatedSize;
+ oldAllocatedSize = res._allocatedSize;
do {
best_type = 0;
@@ -976,32 +982,27 @@
if (!best_type)
break;
- nukeResource(best_type, best_res);
- } while (size + _allocatedSize > _minHeapThreshold);
+ res.nukeResource(best_type, best_res);
+ } while (size + res._allocatedSize > res._minHeapThreshold);
- increaseResourceCounter();
+ res.increaseResourceCounter();
- debugC(DEBUG_RESOURCE, "Expired resources, mem %d -> %d", oldAllocatedSize, _allocatedSize);
+ debugC(DEBUG_RESOURCE, "Expired resources, mem %d -> %d", oldAllocatedSize, res._allocatedSize);
}
-void ScummEngine::freeResources() {
+void ResourceManager::freeResources() {
int i, j;
for (i = rtFirst; i <= rtLast; i++) {
- for (j = res.num[i]; --j >= 0;) {
+ for (j = num[i]; --j >= 0;) {
if (isResourceLoaded(i, j))
nukeResource(i, j);
}
- free(res.address[i]);
- free(res.flags[i]);
- free(res.roomno[i]);
- free(res.roomoffs[i]);
+ free(address[i]);
+ free(flags[i]);
+ free(roomno[i]);
+ free(roomoffs[i]);
- if (_heversion >= 70)
- free(res.globsize[i]);
- }
- if (_heversion >= 70) {
- free(_heV7RoomIntOffsets);
- free(_heV7RoomOffsets);
+ free(globsize[i]);
}
}
@@ -1009,7 +1010,7 @@
byte *alloced;
int i, len;
- nukeResource(type, resindex);
+ res.nukeResource(type, resindex);
len = resStrLen(source) + 1;
@@ -1028,10 +1029,10 @@
}
}
-bool ScummEngine::isResourceLoaded(int type, int idx) const {
+bool ResourceManager::isResourceLoaded(int type, int idx) const {
if (!validateResource("isResourceLoaded", type, idx))
return false;
- return res.address[type][idx] != NULL;
+ return address[type][idx] != NULL;
}
void ScummEngine::resourceStats() {
@@ -1048,7 +1049,7 @@
}
}
- debug(1, "Total allocated size=%d, locked=%d(%d)", _allocatedSize, lockedSize, lockedNum);
+ debug(1, "Total allocated size=%d, locked=%d(%d)", res._allocatedSize, lockedSize, lockedNum);
}
void ScummEngine::readMAXS(int blockSize) {
Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- saveload.cpp 28 Mar 2005 20:17:21 -0000 1.200
+++ saveload.cpp 31 Mar 2005 21:38:35 -0000 1.201
@@ -167,7 +167,7 @@
for (i = rtFirst; i <= rtLast; i++)
if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat))
for (j = 0; j < res.num[i]; j++) {
- nukeResource(i, j);
+ res.nukeResource(i, j);
res.flags[i][j] = 0;
}
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- script.cpp 25 Mar 2005 00:40:58 -0000 1.210
+++ script.cpp 31 Mar 2005 21:38:49 -0000 1.211
@@ -364,7 +364,7 @@
for (i = 1; i < _numArray; i++) {
if (_arraySlot[i] == script) {
- nukeResource(rtString, i);
+ res.nukeResource(rtString, i);
_arraySlot[i] = 0;
}
}
@@ -897,7 +897,7 @@
continue;
_newNames[i] = 0;
- nukeResource(rtObjectName, i);
+ res.nukeResource(rtObjectName, i);
}
}
}
Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.103
retrieving revision 2.104
diff -u -d -r2.103 -r2.104
--- script_v100he.cpp 30 Mar 2005 11:49:52 -0000 2.103
+++ script_v100he.cpp 31 Mar 2005 21:38:49 -0000 2.104
@@ -1128,16 +1128,16 @@
if (_heResType == rtFlObject) {
objidx = getObjectIndex(_heResId);
//assert(objidx != -1);
- //lock(_heResType, objidx);
+ //res.lock(_heResType, objidx);
} else {
- lock(_heResType, _heResId);
+ res.lock(_heResType, _heResId);
}
break;
case 133:
if (_heResType == rtCharset)
nukeCharset(_heResId);
else
- nukeResource(_heResType, _heResId);
+ res.nukeResource(_heResType, _heResId);
break;
case 134:
case 135:
@@ -1153,9 +1153,9 @@
if (_heResType == rtFlObject) {
objidx = getObjectIndex(_heResId);
//assert(objidx != -1);
- //unlock(_heResType, objidx);
+ //res.unlock(_heResType, objidx);
} else {
- unlock(_heResType, _heResId);
+ res.unlock(_heResType, _heResId);
}
break;
default:
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.268
retrieving revision 2.269
diff -u -d -r2.268 -r2.269
--- script_v2.cpp 27 Mar 2005 21:21:04 -0000 2.268
+++ script_v2.cpp 31 Mar 2005 21:38:51 -0000 2.269
@@ -782,9 +782,9 @@
ensureResourceLoaded(type, resid);
} else {
if (opcode & 1)
- lock(type, resid);
+ res.lock(type, resid);
else
- unlock(type, resid);
+ res.unlock(type, resid);
}
}
Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.274
retrieving revision 1.275
diff -u -d -r1.274 -r1.275
--- script_v5.cpp 19 Mar 2005 00:15:55 -0000 1.274
+++ script_v5.cpp 31 Mar 2005 21:38:53 -0000 1.275
@@ -1732,40 +1732,40 @@
if (_gameId == GID_ZAK256)
warning("o5_resourceRoutines %d should not occur in Zak256", op);
else
- setResourceCounter(resType[op-5], resid, 0x7F);
+ res.setResourceCounter(resType[op-5], resid, 0x7F);
break;
case 9: // SO_LOCK_SCRIPT
if (resid >= _numGlobalScripts)
break;
- lock(rtScript, resid);
+ res.lock(rtScript, resid);
break;
case 10: // SO_LOCK_SOUND
- lock(rtSound, resid);
+ res.lock(rtSound, resid);
break;
case 11: // SO_LOCK_COSTUME
- lock(rtCostume, resid);
+ res.lock(rtCostume, resid);
break;
case 12: // SO_LOCK_ROOM
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- lock(rtRoom, resid);
+ res.lock(rtRoom, resid);
break;
case 13: // SO_UNLOCK_SCRIPT
if (resid >= _numGlobalScripts)
break;
- unlock(rtScript, resid);
+ res.unlock(rtScript, resid);
break;
case 14: // SO_UNLOCK_SOUND
- unlock(rtSound, resid);
+ res.unlock(rtSound, resid);
break;
case 15: // SO_UNLOCK_COSTUME
- unlock(rtCostume, resid);
+ res.unlock(rtCostume, resid);
break;
case 16: // SO_UNLOCK_ROOM
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- unlock(rtRoom, resid);
+ res.unlock(rtRoom, resid);
break;
case 17: // SO_CLEAR_HEAP
@@ -2256,7 +2256,7 @@
case 2: /* copystring */
a = getVarOrDirectByte(PARAM_1);
b = getVarOrDirectByte(PARAM_2);
- nukeResource(rtString, a);
+ res.nukeResource(rtString, a);
ptr = getResourceAddress(rtString, b);
if (ptr)
loadPtrToResource(rtString, a, ptr);
@@ -2287,7 +2287,7 @@
case 5: /* create empty string */
a = getVarOrDirectByte(PARAM_1);
b = getVarOrDirectByte(PARAM_2);
- nukeResource(rtString, a);
+ res.nukeResource(rtString, a);
if (b) {
ptr = createResource(rtString, a, b);
if (ptr) {
@@ -2332,7 +2332,7 @@
case 2: // SO_VERB_NAME
loadPtrToResource(rtVerb, slot, NULL);
if (slot == 0)
- nukeResource(rtVerb, slot);
+ res.nukeResource(rtVerb, slot);
vs->type = kTextVerbType;
vs->imgindex = 0;
break;
@@ -2446,12 +2446,12 @@
case 20: // SO_VERB_NAME_STR
ptr = getResourceAddress(rtString, getVarOrDirectWord(PARAM_1));
if (!ptr)
- nukeResource(rtVerb, slot);
+ res.nukeResource(rtVerb, slot);
else {
loadPtrToResource(rtVerb, slot, ptr);
}
if (slot == 0)
- nukeResource(rtVerb, slot);
+ res.nukeResource(rtVerb, slot);
vs->type = kTextVerbType;
vs->imgindex = 0;
break;
Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.426
retrieving revision 1.427
diff -u -d -r1.426 -r1.427
--- script_v6.cpp 30 Mar 2005 21:58:07 -0000 1.426
+++ script_v6.cpp 31 Mar 2005 21:38:55 -0000 1.427
@@ -466,7 +466,7 @@
data = readVar(a);
if (data)
- nukeResource(rtString, data);
+ res.nukeResource(rtString, data);
if (_features & GF_HUMONGOUS)
_arraySlot[data] = 0;
@@ -1559,59 +1559,59 @@
if (_version >= 7)
if (resid >= _numGlobalScripts)
break;
- setResourceCounter(rtScript, resid, 0x7F);
+ res.setResourceCounter(rtScript, resid, 0x7F);
break;
case 105: // SO_NUKE_SOUND
resid = pop();
- setResourceCounter(rtSound, resid, 0x7F);
+ res.setResourceCounter(rtSound, resid, 0x7F);
break;
case 106: // SO_NUKE_COSTUME
resid = pop();
- setResourceCounter(rtCostume, resid, 0x7F);
+ res.setResourceCounter(rtCostume, resid, 0x7F);
break;
case 107: // SO_NUKE_ROOM
resid = pop();
- setResourceCounter(rtRoom, resid, 0x7F);
+ res.setResourceCounter(rtRoom, resid, 0x7F);
break;
case 108: // SO_LOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- lock(rtScript, resid);
+ res.lock(rtScript, resid);
break;
case 109: // SO_LOCK_SOUND
resid = pop();
- lock(rtSound, resid);
+ res.lock(rtSound, resid);
break;
case 110: // SO_LOCK_COSTUME
resid = pop();
- lock(rtCostume, resid);
+ res.lock(rtCostume, resid);
break;
case 111: // SO_LOCK_ROOM
resid = pop();
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- lock(rtRoom, resid);
+ res.lock(rtRoom, resid);
break;
case 112: // SO_UNLOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- unlock(rtScript, resid);
+ res.unlock(rtScript, resid);
break;
case 113: // SO_UNLOCK_SOUND
resid = pop();
- unlock(rtSound, resid);
+ res.unlock(rtSound, resid);
break;
case 114: // SO_UNLOCK_COSTUME
resid = pop();
- unlock(rtCostume, resid);
+ res.unlock(rtCostume, resid);
break;
case 115: // SO_UNLOCK_ROOM
resid = pop();
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- unlock(rtRoom, resid);
+ res.unlock(rtRoom, resid);
break;
case 116: // SO_CLEAR_HEAP
/* this is actually a scumm message */
Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.137
retrieving revision 2.138
diff -u -d -r2.137 -r2.138
--- script_v7he.cpp 30 Mar 2005 11:49:53 -0000 2.137
+++ script_v7he.cpp 31 Mar 2005 21:38:58 -0000 2.138
@@ -532,59 +532,59 @@
break;
case 104: // SO_NUKE_SCRIPT
resid = pop();
- setResourceCounter(rtScript, resid, 0x7F);
+ res.setResourceCounter(rtScript, resid, 0x7F);
break;
case 105: // SO_NUKE_SOUND
resid = pop();
- setResourceCounter(rtSound, resid, 0x7F);
+ res.setResourceCounter(rtSound, resid, 0x7F);
break;
case 106: // SO_NUKE_COSTUME
resid = pop();
- setResourceCounter(rtCostume, resid, 0x7F);
+ res.setResourceCounter(rtCostume, resid, 0x7F);
break;
case 107: // SO_NUKE_ROOM
resid = pop();
- setResourceCounter(rtRoom, resid, 0x7F);
+ res.setResourceCounter(rtRoom, resid, 0x7F);
break;
case 108: // SO_LOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- lock(rtScript, resid);
+ res.lock(rtScript, resid);
break;
case 109: // SO_LOCK_SOUND
resid = pop();
- lock(rtSound, resid);
+ res.lock(rtSound, resid);
break;
case 110: // SO_LOCK_COSTUME
resid = pop();
- lock(rtCostume, resid);
+ res.lock(rtCostume, resid);
break;
case 111: // SO_LOCK_ROOM
resid = pop();
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- lock(rtRoom, resid);
+ res.lock(rtRoom, resid);
break;
case 112: // SO_UNLOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- unlock(rtScript, resid);
+ res.unlock(rtScript, resid);
break;
case 113: // SO_UNLOCK_SOUND
resid = pop();
- unlock(rtSound, resid);
+ res.unlock(rtSound, resid);
break;
case 114: // SO_UNLOCK_COSTUME
resid = pop();
- unlock(rtCostume, resid);
+ res.unlock(rtCostume, resid);
break;
case 115: // SO_UNLOCK_ROOM
resid = pop();
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- unlock(rtRoom, resid);
+ res.unlock(rtRoom, resid);
break;
case 116:
break;
@@ -611,11 +611,11 @@
break;
case 159:
resid = pop();
- unlock(rtImage, resid);
+ res.unlock(rtImage, resid);
break;
case 192:
resid = pop();
- nukeResource(rtImage, resid);
+ res.nukeResource(rtImage, resid);
break;
case 201:
resid = pop();
@@ -623,7 +623,7 @@
break;
case 202:
resid = pop();
- lock(rtImage, resid);
+ res.lock(rtImage, resid);
break;
case 233:
resid = pop();
Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.285
retrieving revision 2.286
diff -u -d -r2.285 -r2.286
--- script_v8.cpp 30 Mar 2005 21:58:31 -0000 2.285
+++ script_v8.cpp 31 Mar 2005 21:38:59 -0000 2.286
@@ -779,40 +779,40 @@
break;
case 0x42: // SO_HEAP_LOCK_COSTUME Lock costume in heap
- lock(rtCostume, resid);
+ res.lock(rtCostume, resid);
break;
case 0x43: // SO_HEAP_LOCK_ROOM Lock room in heap
- lock(rtRoom, resid);
+ res.lock(rtRoom, resid);
break;
case 0x44: // SO_HEAP_LOCK_SCRIPT Lock script in heap
- lock(rtScript, resid);
+ res.lock(rtScript, resid);
break;
case 0x45: // SO_HEAP_LOCK_SOUND Lock sound in heap
- lock(rtSound, resid);
+ res.lock(rtSound, resid);
break;
case 0x46: // SO_HEAP_UNLOCK_COSTUME Unlock costume
- unlock(rtCostume, resid);
+ res.unlock(rtCostume, resid);
break;
case 0x47: // SO_HEAP_UNLOCK_ROOM Unlock room
- unlock(rtRoom, resid);
+ res.unlock(rtRoom, resid);
break;
case 0x48: // SO_HEAP_UNLOCK_SCRIPT Unlock script
- unlock(rtScript, resid);
+ res.unlock(rtScript, resid);
break;
case 0x49: // SO_HEAP_UNLOCK_SOUND Unlock sound
- unlock(rtSound, resid);
+ res.unlock(rtSound, resid);
break;
case 0x4A: // SO_HEAP_NUKE_COSTUME Remove costume from heap
- setResourceCounter(rtCostume, resid, 0x7F);
+ res.setResourceCounter(rtCostume, resid, 0x7F);
break;
case 0x4B: // SO_HEAP_NUKE_ROOM Remove room from heap
- setResourceCounter(rtRoom, resid, 0x7F);
+ res.setResourceCounter(rtRoom, resid, 0x7F);
break;
case 0x4C: // SO_HEAP_NUKE_SCRIPT Remove script from heap
- setResourceCounter(rtScript, resid, 0x7F);
+ res.setResourceCounter(rtScript, resid, 0x7F);
break;
case 0x4D: // SO_HEAP_NUKE_SOUND Remove sound from heap
- setResourceCounter(rtSound, resid, 0x7F);
+ res.setResourceCounter(rtSound, resid, 0x7F);
break;
default:
error("o8_resourceRoutines: default case 0x%x", subOp);
@@ -1214,13 +1214,13 @@
case 11: { // lockObject
int objidx = getObjectIndex(args[1]);
assert(objidx != -1);
- lock(rtFlObject, objidx);
+ res.lock(rtFlObject, objidx);
break;
}
case 12: { // unlockObject
int objidx = getObjectIndex(args[1]);
assert(objidx != -1);
- unlock(rtFlObject, objidx);
+ res.unlock(rtFlObject, objidx);
break;
}
case 13: // remapCostume
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.392
retrieving revision 1.393
diff -u -d -r1.392 -r1.393
--- scumm.cpp 30 Mar 2005 23:25:47 -0000 1.392
+++ scumm.cpp 31 Mar 2005 21:39:01 -0000 1.393
@@ -594,7 +594,9 @@
_heversion(gs.heversion),
_numActors(gs.numActors),
_features(gs.features),
- gdi(this), _pauseDialog(0), _mainMenuDialog(0), _versionDialog(0),
+ gdi(this),
+ res(this),
+ _pauseDialog(0), _mainMenuDialog(0), _versionDialog(0),
_targetName(detector->_targetName) {
// Copy MD5 checksum
@@ -758,8 +760,6 @@
_lastSaveTime = 0;
_saveTemporaryState = false;
memset(_saveLoadName, 0, sizeof(_saveLoadName));
- _maxHeapThreshold = 0;
- _minHeapThreshold = 0;
memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
_scriptPointer = NULL;
_scriptOrgPointer = NULL;
@@ -776,8 +776,6 @@
_fileOffset = 0;
_dynamicRoomOffsets = false;
memset(_resourceMapper, 0, sizeof(_resourceMapper));
- _allocatedSize = 0;
- _expire_counter = 0;
_lastLoadedRoom = 0;
_roomResource = 0;
_substResFileNameIndex = 0;
@@ -1173,7 +1171,11 @@
free(_shadowPalette);
- freeResources();
+ res.freeResources();
+ if (_heversion >= 70) {
+ free(_heV7RoomIntOffsets);
+ free(_heV7RoomOffsets);
+ }
free(_objectStateTable);
free(_objectRoomTable);
@@ -1309,18 +1311,18 @@
#ifdef __PALM_OS__
if (_features & GF_NEW_COSTUMES)
- _maxHeapThreshold = gVars->memory[kMemScummNewCostGames];
+ res._maxHeapThreshold = gVars->memory[kMemScummNewCostGames];
else
- _maxHeapThreshold = gVars->memory[kMemScummOldCostGames];
+ res._maxHeapThreshold = gVars->memory[kMemScummOldCostGames];
#else
// Since the new costumes are very big, we increase the heap limit, to avoid having
// to constantly reload stuff from the data files.
if (_features & GF_NEW_COSTUMES)
- _maxHeapThreshold = 2500000;
+ res._maxHeapThreshold = 2500000;
else
- _maxHeapThreshold = 550000;
+ res._maxHeapThreshold = 550000;
#endif
- _minHeapThreshold = 400000;
+ res._minHeapThreshold = 400000;
allocResTypeData(rtBuffer, MKID('NONE'), 10, "buffer", 0);
@@ -2074,8 +2076,8 @@
camera._last = camera._cur;
- if (!(++_expire_counter)) {
- increaseResourceCounter();
+ if (!(++res._expireCounter)) {
+ res.increaseResourceCounter();
}
animateCursor();
@@ -2174,7 +2176,7 @@
VAR(VAR_ROOM) = room;
_fullRedraw = true;
- increaseResourceCounter();
+ res.increaseResourceCounter();
_currentRoom = room;
VAR(VAR_ROOM) = room;
@@ -2391,8 +2393,8 @@
//
// Load box data
//
- nukeResource(rtMatrix, 1);
- nukeResource(rtMatrix, 2);
+ res.nukeResource(rtMatrix, 1);
+ res.nukeResource(rtMatrix, 2);
if (_features & GF_SMALL_HEADER) {
if (_version <= 2)
ptr = roomptr + *(roomptr + 0x15);
@@ -2451,7 +2453,7 @@
// Load scale data
//
for (i = 1; i < res.num[rtScaleTable]; i++)
- nukeResource(rtScaleTable, i);
+ res.nukeResource(rtScaleTable, i);
if (_features & GF_OLD_BUNDLE)
ptr = 0;
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.554
retrieving revision 1.555
diff -u -d -r1.554 -r1.555
--- scumm.h 30 Mar 2005 21:58:41 -0000 1.554
+++ scumm.h 31 Mar 2005 21:39:05 -0000 1.555
@@ -291,6 +291,44 @@
int subIndex;
};
+class ResourceManager {
+ friend class ScummDebugger;
+ friend class ScummEngine;
+protected:
+ ScummEngine *_vm;
+
+public:
+ byte mode[rtNumTypes];
+ uint16 num[rtNumTypes];
+ uint32 tags[rtNumTypes];
+ const char *name[rtNumTypes];
+ byte **address[rtNumTypes];
+ byte *flags[rtNumTypes];
+ byte *roomno[rtNumTypes];
+ uint32 *roomoffs[rtNumTypes];
+ uint32 *globsize[rtNumTypes];
+
+ uint32 _allocatedSize;
+ uint32 _maxHeapThreshold, _minHeapThreshold;
+ byte _expireCounter;
+
+public:
+ ResourceManager(ScummEngine *vm);
+
+ void nukeResource(int type, int i);
+
+ void freeResources();
+
+ bool validateResource(const char *str, int type, int index) const;
+ bool isResourceLoaded(int type, int index) const;
+
+ void lock(int type, int i);
+ void unlock(int type, int i);
+
+ void setResourceCounter(int type, int index, byte flag);
+ void increaseResourceCounter();
+};
+
class ScummEngine : public Engine {
friend class ScummDebugger;
friend class SmushPlayer;
@@ -325,20 +363,10 @@
/** Graphics manager */
Gdi gdi;
-protected:
/** Central resource data. */
- struct {
- byte mode[rtNumTypes];
- uint16 num[rtNumTypes];
- uint32 tags[rtNumTypes];
- const char *name[rtNumTypes];
- byte **address[rtNumTypes];
- byte *flags[rtNumTypes];
- byte *roomno[rtNumTypes];
- uint32 *roomoffs[rtNumTypes];
- uint32 *globsize[rtNumTypes];
- } res;
+ ResourceManager res;
+protected:
VirtualMachineState vm;
public:
@@ -534,13 +562,7 @@
void requestSave(int slot, const char *name, bool temporary = false);
void requestLoad(int slot);
- void lock(int type, int i);
- void unlock(int type, int i);
-
protected:
- /* Heap and memory management */
- uint32 _maxHeapThreshold, _minHeapThreshold;
-
/* Script VM - should be in Script class */
uint32 _localScriptOffsets[256];
const byte *_scriptPointer, *_scriptOrgPointer;
@@ -631,8 +653,6 @@
Common::String _targetName; // This is the game the user calls it, so use for saving
bool _dynamicRoomOffsets;
byte _resourceMapper[128];
- uint32 _allocatedSize;
- byte _expire_counter;
byte *_heV7DiskOffsets;
byte *_heV7RoomOffsets;
uint32 *_heV7RoomIntOffsets;
@@ -652,11 +672,10 @@
void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode);
byte *createResource(int type, int index, uint32 size);
int loadResource(int type, int i);
- void nukeResource(int type, int i);
+// void nukeResource(int type, int i);
int getResourceSize(int type, int idx);
public:
- bool isResourceLoaded(int type, int index) const;
byte *getResourceAddress(int type, int i);
byte *getStringAddress(int i);
byte *getStringAddressVar(int i);
@@ -669,9 +688,6 @@
void convertMac0Resource(int type, int index, byte *ptr, int size);
void convertADResource(int type, int index, byte *ptr, int size);
int readSoundResourceSmallHeader(int type, int index);
- void setResourceCounter(int type, int index, byte flag);
- bool validateResource(const char *str, int type, int index) const;
- void increaseResourceCounter();
bool isResourceInUse(int type, int i) const;
void initRoomSubBlocks();
void clearRoomObjects();
@@ -695,7 +711,6 @@
protected:
void resourceStats();
void expireResources(uint32 size);
- void freeResources();
public:
/* Should be in Object class */
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.432
retrieving revision 1.433
diff -u -d -r1.432 -r1.433
--- sound.cpp 30 Mar 2005 21:58:58 -0000 1.432
+++ sound.cpp 31 Mar 2005 21:39:06 -0000 1.433
@@ -841,7 +841,7 @@
if (isSoundInQueue(sound))
return 1;
- if (sound > _vm->_numSounds || !_vm->isResourceLoaded(rtSound, sound))
+ if (sound > _vm->_numSounds || !_vm->res.isResourceLoaded(rtSound, sound))
return 0;
if (_vm->_musicEngine)
@@ -872,7 +872,7 @@
if (isSoundInQueue(sound))
return true;
- if (!_vm->isResourceLoaded(rtSound, sound))
+ if (!_vm->res.isResourceLoaded(rtSound, sound))
return false;
if (_vm->_imuse)
Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -d -r1.272 -r1.273
--- string.cpp 30 Mar 2005 17:30:47 -0000 1.272
+++ string.cpp 31 Mar 2005 21:39:10 -0000 1.273
@@ -720,7 +720,7 @@
int i;
if (_gameId == GID_FT) {
- if (!isResourceLoaded(rtCharset, charsetno))
+ if (!res.isResourceLoaded(rtCharset, charsetno))
loadCharset(charsetno);
} else {
if (!getResourceAddress(rtCharset, charsetno))
Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- verbs.cpp 28 Mar 2005 20:18:36 -0000 1.123
+++ verbs.cpp 31 Mar 2005 21:39:11 -0000 1.124
@@ -613,7 +613,7 @@
vs->verbid = 0;
vs->curmode = 0;
- nukeResource(rtVerb, slot);
+ res.nukeResource(rtVerb, slot);
if (_version <= 6 && vs->saveid == 0) {
drawVerb(slot, 0);
Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.30
retrieving revision 2.31
diff -u -d -r2.30 -r2.31
--- wiz_he.cpp 30 Mar 2005 14:54:23 -0000 2.30
+++ wiz_he.cpp 31 Mar 2005 21:39:30 -0000 2.31
@@ -1424,7 +1424,7 @@
f.seek(0, SEEK_SET);
byte *p = createResource(rtImage, params->img.resNum, size);
if (f.read(p, size) != size) {
- nukeResource(rtImage, params->img.resNum);
+ res.nukeResource(rtImage, params->img.resNum);
warning("i/o error when reading '%s'", params->filename);
VAR(VAR_GAME_LOADED) = -2;
VAR(119) = -2;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse_sndmgr.cpp,1.67,1.68
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.407,2.408 script_v100he.cpp,2.104,2.105 script_v90he.cpp,2.202,2.203 sprite_he.cpp,1.111,1.112 sprite_he.h,1.27,1.28 wiz_he.cpp,2.31,2.32 wiz_he.h,2.12,2.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list