aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2006-09-17 20:36:48 +0000
committerMax Horn2006-09-17 20:36:48 +0000
commit51017cf1b21f450acad9c735e9364f5bb5d35f17 (patch)
treec61007341218b4522350f23cf646a2376b0bf3be
parent8c0b0c012007d938ab500c5ccc64f6e0cbcf13e0 (diff)
downloadscummvm-rg350-51017cf1b21f450acad9c735e9364f5bb5d35f17.tar.gz
scummvm-rg350-51017cf1b21f450acad9c735e9364f5bb5d35f17.tar.bz2
scummvm-rg350-51017cf1b21f450acad9c735e9364f5bb5d35f17.zip
Renamed ScummEngine::res to _res and allocate the ResourceManager on the heap (i.e. _res is a pointer now)
svn-id: r23922
-rw-r--r--engines/scumm/akos.cpp2
-rw-r--r--engines/scumm/boxes.cpp2
-rw-r--r--engines/scumm/debugger.cpp6
-rw-r--r--engines/scumm/gfx.cpp10
-rw-r--r--engines/scumm/he/floodfill_he.cpp2
-rw-r--r--engines/scumm/he/resource_he.cpp4
-rw-r--r--engines/scumm/he/script_v100he.cpp10
-rw-r--r--engines/scumm/he/script_v70he.cpp40
-rw-r--r--engines/scumm/he/script_v72he.cpp4
-rw-r--r--engines/scumm/he/sound_he.cpp6
-rw-r--r--engines/scumm/he/wiz_he.cpp26
-rw-r--r--engines/scumm/imuse_digi/dimuse_sndmgr.cpp4
-rw-r--r--engines/scumm/input.cpp2
-rw-r--r--engines/scumm/insane/insane.cpp4
-rw-r--r--engines/scumm/object.cpp34
-rw-r--r--engines/scumm/plugin.cpp2
-rw-r--r--engines/scumm/resource.cpp112
-rw-r--r--engines/scumm/resource_v2.cpp32
-rw-r--r--engines/scumm/resource_v3.cpp12
-rw-r--r--engines/scumm/resource_v4.cpp2
-rw-r--r--engines/scumm/room.cpp36
-rw-r--r--engines/scumm/saveload.cpp48
-rw-r--r--engines/scumm/script.cpp18
-rw-r--r--engines/scumm/script_c64.cpp16
-rw-r--r--engines/scumm/script_v2.cpp4
-rw-r--r--engines/scumm/script_v5.cpp32
-rw-r--r--engines/scumm/script_v6.cpp34
-rw-r--r--engines/scumm/script_v8.cpp28
-rw-r--r--engines/scumm/scumm.cpp16
-rw-r--r--engines/scumm/scumm.h2
-rw-r--r--engines/scumm/sound.cpp46
-rw-r--r--engines/scumm/string.cpp2
-rw-r--r--engines/scumm/verbs.cpp8
33 files changed, 303 insertions, 303 deletions
diff --git a/engines/scumm/akos.cpp b/engines/scumm/akos.cpp
index eb0de5b6e2..2dfe3f03f1 100644
--- a/engines/scumm/akos.cpp
+++ b/engines/scumm/akos.cpp
@@ -777,7 +777,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) {
// So I had to put copy of it back here as it was before 1.227 revision
// of this file.
v1.scaletable = (_vm->_game.heversion >= 61) ? smallCostumeScaleTableAKOS : bigCostumeScaleTable;
- if (_vm->VAR_CUSTOMSCALETABLE != 0xFF && _vm->res.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);
}
diff --git a/engines/scumm/boxes.cpp b/engines/scumm/boxes.cpp
index 359d04f65e..0fcbfd8f0e 100644
--- a/engines/scumm/boxes.cpp
+++ b/engines/scumm/boxes.cpp
@@ -1039,7 +1039,7 @@ void ScummEngine::createBoxMatrix() {
// the boxes 7,8,9,10,11 the shortest way is to go via box 15.
// See also getPathToDestBox.
- byte *matrixStart = res.createResource(rtMatrix, 1, BOX_MATRIX_SIZE);
+ byte *matrixStart = _res->createResource(rtMatrix, 1, BOX_MATRIX_SIZE);
const byte *matrixEnd = matrixStart + BOX_MATRIX_SIZE;
#define addToMatrix(b) do { *matrixStart++ = (b); assert(matrixStart < matrixEnd); } while (0)
diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp
index 89d80c81da..b15f74d2e4 100644
--- a/engines/scumm/debugger.cpp
+++ b/engines/scumm/debugger.cpp
@@ -325,7 +325,7 @@ bool ScummDebugger::Cmd_ImportRes(int argc, const char** argv) {
file.seek(-8, SEEK_CUR);
}
- file.read(_vm->res.createResource(rtScript, resnum, size), size);
+ file.read(_vm->_res->createResource(rtScript, resnum, size), size);
} else
DebugPrintf("Unknown importres type '%s'\n", argv[1]);
@@ -395,8 +395,8 @@ bool ScummDebugger::Cmd_Actor(int argc, const char **argv) {
DebugPrintf("Actor[%d]._elevation = %d\n", actnum, a->getElevation());
_vm->_fullRedraw = true;
} else if (!strcmp(argv[2], "costume")) {
- if (value >= _vm->res.num[rtCostume])
- DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->res.num[rtCostume]);
+ if (value >= _vm->_res->num[rtCostume])
+ DebugPrintf("Costume not changed as %d exceeds max of %d\n", value, _vm->_res->num[rtCostume]);
else {
a->setActorCostume(value);
_vm->_fullRedraw = true;
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp
index 2c615ba3e7..bfe90a32df 100644
--- a/engines/scumm/gfx.cpp
+++ b/engines/scumm/gfx.cpp
@@ -258,8 +258,8 @@ void ScummEngine::initScreens(int b, int h) {
int adj = 0;
for (i = 0; i < 3; i++) {
- res.nukeResource(rtBuffer, i + 1);
- res.nukeResource(rtBuffer, i + 5);
+ _res->nukeResource(rtBuffer, i + 1);
+ _res->nukeResource(rtBuffer, i + 5);
}
if (!getResourceAddress(rtBuffer, 4)) {
@@ -338,12 +338,12 @@ void ScummEngine::initVirtScreen(VirtScreenNumber slot, int top, int width, int
}
}
- res.createResource(rtBuffer, slot + 1, size);
+ _res->createResource(rtBuffer, slot + 1, size);
vs->pixels = getResourceAddress(rtBuffer, slot + 1);
memset(vs->pixels, 0, size); // reset background
if (twobufs) {
- vs->backBuf = res.createResource(rtBuffer, slot + 5, size);
+ vs->backBuf = _res->createResource(rtBuffer, slot + 5, size);
}
if (slot != 3) {
@@ -744,7 +744,7 @@ void ScummEngine::initBGBuffers(int height) {
size = itemsize * _gdi->_numZBuffer;
- memset(res.createResource(rtBuffer, 9, size), 0, size);
+ memset(_res->createResource(rtBuffer, 9, size), 0, size);
for (i = 0; i < (int)ARRAYSIZE(_gdi->_imgBufOffs); i++) {
if (i < _gdi->_numZBuffer)
diff --git a/engines/scumm/he/floodfill_he.cpp b/engines/scumm/he/floodfill_he.cpp
index f4a3cc7998..fb9fa73513 100644
--- a/engines/scumm/he/floodfill_he.cpp
+++ b/engines/scumm/he/floodfill_he.cpp
@@ -287,7 +287,7 @@ void Wiz::fillWizFlood(const WizParameters *params) {
}
}
}
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
}
} // End of namespace Scumm
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index e0958554c9..1ac91c9516 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -733,7 +733,7 @@ Win32ResExtractor::WinResource *Win32ResExtractor::list_ne_type_resources(WinLib
/* list_resources:
* Return an array of WinResource's in the current
- * resource level specified by res.
+ * resource level specified by _res->
*/
Win32ResExtractor::WinResource *Win32ResExtractor::list_resources(WinLibrary *fi, WinResource *res, int *count) {
if (res != NULL && !res->is_directory)
@@ -1630,7 +1630,7 @@ void ScummEngine_v70he::readRoomsOffsets() {
num = READ_LE_UINT16(_heV7RoomOffsets);
ptr = _heV7RoomOffsets + 2;
for (i = 0; i < num; i++) {
- res.roomoffs[rtRoom][i] = READ_LE_UINT32(ptr);
+ _res->roomoffs[rtRoom][i] = READ_LE_UINT32(ptr);
ptr += 4;
}
}
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 6efa7d612a..f576c294cf 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -1122,16 +1122,16 @@ void ScummEngine_v100he::o100_resourceRoutines() {
objidx = getObjectIndex(_heResId);
if (objidx == -1)
break;
- res.lock(rtFlObject, _objs[objidx].fl_object_index);
+ _res->lock(rtFlObject, _objs[objidx].fl_object_index);
} else {
- res.lock(_heResType, _heResId);
+ _res->lock(_heResType, _heResId);
}
break;
case 133:
if (_heResType == rtCharset)
nukeCharset(_heResId);
else
- res.nukeResource(_heResType, _heResId);
+ _res->nukeResource(_heResType, _heResId);
break;
case 134:
case 135:
@@ -1151,9 +1151,9 @@ void ScummEngine_v100he::o100_resourceRoutines() {
objidx = getObjectIndex(_heResId);
if (objidx == -1)
break;
- res.unlock(rtFlObject, _objs[objidx].fl_object_index);
+ _res->unlock(rtFlObject, _objs[objidx].fl_object_index);
} else {
- res.unlock(_heResType, _heResId);
+ _res->unlock(_heResType, _heResId);
}
break;
default:
diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp
index 16c3d7e4d1..133d802311 100644
--- a/engines/scumm/he/script_v70he.cpp
+++ b/engines/scumm/he/script_v70he.cpp
@@ -541,62 +541,62 @@ void ScummEngine_v70he::o70_resourceRoutines() {
break;
case 104: // SO_NUKE_SCRIPT
resid = pop();
- res.nukeResource(rtScript, resid);
+ _res->nukeResource(rtScript, resid);
break;
case 105: // SO_NUKE_SOUND
resid = pop();
- res.nukeResource(rtSound, resid);
+ _res->nukeResource(rtSound, resid);
break;
case 106: // SO_NUKE_COSTUME
resid = pop();
- res.nukeResource(rtCostume, resid);
+ _res->nukeResource(rtCostume, resid);
break;
case 107: // SO_NUKE_ROOM
resid = pop();
- res.nukeResource(rtRoom, resid);
- res.nukeResource(rtRoomImage, resid);
+ _res->nukeResource(rtRoom, resid);
+ _res->nukeResource(rtRoomImage, resid);
break;
case 108: // SO_LOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- res.lock(rtScript, resid);
+ _res->lock(rtScript, resid);
break;
case 109: // SO_LOCK_SOUND
resid = pop();
- res.lock(rtSound, resid);
+ _res->lock(rtSound, resid);
break;
case 110: // SO_LOCK_COSTUME
resid = pop();
- res.lock(rtCostume, resid);
+ _res->lock(rtCostume, resid);
break;
case 111: // SO_LOCK_ROOM
resid = pop();
if (_game.heversion <= 71 && resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- res.lock(rtRoom, resid);
- res.lock(rtRoomImage, resid);
+ _res->lock(rtRoom, resid);
+ _res->lock(rtRoomImage, resid);
break;
case 112: // SO_UNLOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- res.unlock(rtScript, resid);
+ _res->unlock(rtScript, resid);
break;
case 113: // SO_UNLOCK_SOUND
resid = pop();
- res.unlock(rtSound, resid);
+ _res->unlock(rtSound, resid);
break;
case 114: // SO_UNLOCK_COSTUME
resid = pop();
- res.unlock(rtCostume, resid);
+ _res->unlock(rtCostume, resid);
break;
case 115: // SO_UNLOCK_ROOM
resid = pop();
if (_game.heversion <= 71 && resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- res.unlock(rtRoom, resid);
- res.unlock(rtRoomImage, resid);
+ _res->unlock(rtRoom, resid);
+ _res->unlock(rtRoomImage, resid);
break;
case 116:
break;
@@ -635,11 +635,11 @@ void ScummEngine_v70he::o70_resourceRoutines() {
break;
case 159:
resid = pop();
- res.unlock(rtImage, resid);
+ _res->unlock(rtImage, resid);
break;
case 192:
resid = pop();
- res.nukeResource(rtImage, resid);
+ _res->nukeResource(rtImage, resid);
break;
case 201:
resid = pop();
@@ -647,7 +647,7 @@ void ScummEngine_v70he::o70_resourceRoutines() {
break;
case 202:
resid = pop();
- res.lock(rtImage, resid);
+ _res->lock(rtImage, resid);
break;
case 203:
resid = pop();
@@ -658,14 +658,14 @@ void ScummEngine_v70he::o70_resourceRoutines() {
objidx = getObjectIndex(resid);
if (objidx == -1)
break;
- res.lock(rtFlObject, _objs[objidx].fl_object_index);
+ _res->lock(rtFlObject, _objs[objidx].fl_object_index);
break;
case 235:
resid = pop();
objidx = getObjectIndex(resid);
if (objidx == -1)
break;
- res.unlock(rtFlObject, _objs[objidx].fl_object_index);
+ _res->unlock(rtFlObject, _objs[objidx].fl_object_index);
break;
case 239:
// Used in airport
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index dfc8b89151..a708b3baad 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -419,7 +419,7 @@ ScummEngine_v72he::ArrayHeader *ScummEngine_v72he::defineArray(int array, int ty
size *= dim1end - dim1start + 1;
size >>= 3;
- ah = (ArrayHeader *)res.createResource(rtString, id, size + sizeof(ArrayHeader));
+ ah = (ArrayHeader *)_res->createResource(rtString, id, size + sizeof(ArrayHeader));
ah->type = TO_LE_32(type);
ah->dim1start = TO_LE_32(dim1start);
@@ -962,7 +962,7 @@ void ScummEngine_v72he::o72_getArrayDimSize() {
}
void ScummEngine_v72he::o72_getNumFreeArrays() {
- byte **addr = res.address[rtString];
+ byte **addr = _res->address[rtString];
int i, num = 0;
for (i = 1; i < _numArray; i++) {
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index d0af600899..8b12dd191e 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -528,7 +528,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
musicFile.seek(music_offs, SEEK_SET);
_vm->_mixer->stopHandle(_heSoundChannels[heChannel]);
- spoolPtr = _vm->res.createResource(rtSpoolBuffer, heChannel, size);
+ spoolPtr = _vm->_res->createResource(rtSpoolBuffer, heChannel, size);
assert(spoolPtr);
musicFile.read(spoolPtr, size);
musicFile.close();
@@ -686,13 +686,13 @@ void SoundHE::startHETalkSound(uint32 offset) {
}
_sfxMode |= 2;
- _vm->res.nukeResource(rtSound, 1);
+ _vm->_res->nukeResource(rtSound, 1);
_sfxFile->seek(offset + 4, SEEK_SET);
size = _sfxFile->readUint32BE();
_sfxFile->seek(offset, SEEK_SET);
- _vm->res.createResource(rtSound, 1, size);
+ _vm->_res->createResource(rtSound, 1, size);
ptr = _vm->getResourceAddress(rtSound, 1);
_sfxFile->read(ptr, size);
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index f2c60223d8..252423a2ef 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -1025,7 +1025,7 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in
dataSize = (dataSize + 1) & ~1;
int wizSize = headerSize + dataSize;
// write header
- uint8 *wizImg = _vm->res.createResource(rtImage, resNum, dataSize + headerSize);
+ uint8 *wizImg = _vm->_res->createResource(rtImage, resNum, dataSize + headerSize);
WRITE_BE_UINT32(wizImg + 0x00, 'AWIZ');
WRITE_BE_UINT32(wizImg + 0x04, wizSize);
WRITE_BE_UINT32(wizImg + 0x08, 'WIZH');
@@ -1063,7 +1063,7 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in
break;
}
}
- _vm->res.setModified(rtImage, resNum);
+ _vm->_res->setModified(rtImage, resNum);
}
void Wiz::displayWizImage(WizImage *pwi) {
@@ -1637,7 +1637,7 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i
} else {
palPtr = _vm->_currentPalette;
}
- uint8 *res_data = _vm->res.createResource(rtImage, resNum, res_size);
+ uint8 *res_data = _vm->_res->createResource(rtImage, resNum, res_size);
if (!res_data) {
_vm->VAR(119) = -1;
} else {
@@ -1671,7 +1671,7 @@ void Wiz::createWizEmptyImage(int resNum, int img_x, int img_y, int img_w, int i
WRITE_BE_UINT32(res_data, 'WIZD'); res_data += 4;
WRITE_BE_UINT32(res_data, 8 + img_w * img_h); res_data += 4;
}
- _vm->res.setModified(rtImage, resNum);
+ _vm->_res->setModified(rtImage, resNum);
}
void Wiz::fillWizRect(const WizParameters *params) {
@@ -1716,7 +1716,7 @@ void Wiz::fillWizRect(const WizParameters *params) {
}
}
}
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
}
void Wiz::fillWizLine(const WizParameters *params) {
@@ -1808,7 +1808,7 @@ void Wiz::fillWizLine(const WizParameters *params) {
}
}
}
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
}
void Wiz::fillWizPixel(const WizParameters *params) {
@@ -1845,7 +1845,7 @@ void Wiz::fillWizPixel(const WizParameters *params) {
}
}
}
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
}
void Wiz::remapWizImagePal(const WizParameters *params) {
@@ -1861,7 +1861,7 @@ void Wiz::remapWizImagePal(const WizParameters *params) {
uint8 idx = *index++;
rmap[4 + idx] = params->remapColor[idx];
}
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
}
void Wiz::processWizImage(const WizParameters *params) {
@@ -1890,14 +1890,14 @@ void Wiz::processWizImage(const WizParameters *params) {
if (id == MKID_BE('AWIZ') || id == MKID_BE('MULT')) {
uint32 size = f.readUint32BE();
f.seek(0, SEEK_SET);
- byte *p = _vm->res.createResource(rtImage, params->img.resNum, size);
+ byte *p = _vm->_res->createResource(rtImage, params->img.resNum, size);
if (f.read(p, size) != size) {
- _vm->res.nukeResource(rtImage, params->img.resNum);
+ _vm->_res->nukeResource(rtImage, params->img.resNum);
error("i/o error when reading '%s'", filename);
_vm->VAR(_vm->VAR_GAME_LOADED) = -2;
_vm->VAR(119) = -2;
} else {
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
_vm->VAR(_vm->VAR_GAME_LOADED) = 0;
_vm->VAR(119) = 0;
}
@@ -1955,7 +1955,7 @@ void Wiz::processWizImage(const WizParameters *params) {
case 7:
// Used in PuttsFunShop/SamsFunShop/soccer2004
// TODO: Capture polygon
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
break;
case 8: {
int img_w = 640;
@@ -2006,7 +2006,7 @@ void Wiz::processWizImage(const WizParameters *params) {
case 17:
// Used in to draw circles in FreddisFunShop/PuttsFunShop/SamsFunShop
// TODO: Ellipse
- _vm->res.setModified(rtImage, params->img.resNum);
+ _vm->_res->setModified(rtImage, params->img.resNum);
break;
default:
error("Unhandled processWizImage mode %d", params->processMode);
diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
index 65e003d0ec..733b0d576c 100644
--- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
+++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
@@ -356,7 +356,7 @@ ImuseDigiSndMgr::soundStruct *ImuseDigiSndMgr::openSound(int32 soundId, const ch
assert(soundName[0] == 0); // Paranoia check
_vm->ensureResourceLoaded(rtSound, soundId);
- _vm->res.lock(rtSound, soundId);
+ _vm->_res->lock(rtSound, soundId);
ptr = _vm->getResourceAddress(rtSound, soundId);
if (ptr == NULL) {
closeSound(sound);
@@ -430,7 +430,7 @@ void ImuseDigiSndMgr::closeSound(soundStruct *soundHandle) {
found = true;
}
if (!found)
- _vm->res.unlock(rtSound, soundHandle->soundId);
+ _vm->_res->unlock(rtSound, soundHandle->soundId);
}
if (soundHandle->compressedStream)
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 2abf471408..eb814b2819 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -79,7 +79,7 @@ void ScummEngine::parseEvents() {
else if (event.kbd.keycode == 'd')
_debugger->attach();
else if (event.kbd.keycode == 's')
- res.resourceStats();
+ _res->resourceStats();
else
_keyPressed = event.kbd.ascii; // Normal key press, pass on to the game.
} else if (event.kbd.flags & OSystem::KBD_ALT) {
diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp
index 3f979ce2a3..59fc99a857 100644
--- a/engines/scumm/insane/insane.cpp
+++ b/engines/scumm/insane/insane.cpp
@@ -1148,7 +1148,7 @@ int Insane::smlayer_loadSound(int id, int flag, int phase) {
if (phase == 2)
_vm->ensureResourceLoaded(rtSound, resid);
- _vm->res.setResourceCounter(rtSound, resid, 1);
+ _vm->_res->setResourceCounter(rtSound, resid, 1);
if (phase == 1) {
_objArray2Idx2++;
@@ -1170,7 +1170,7 @@ int Insane::smlayer_loadCostume(int id, int phase) {
return 0;
_vm->ensureResourceLoaded(rtCostume, resid);
- _vm->res.setResourceCounter(rtCostume, resid, 1);
+ _vm->_res->setResourceCounter(rtCostume, resid, 1);
// smlayer_lock(rtCostume, resid); // FIXME
diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp
index 39dd978fa0..c0eb9c8ef3 100644
--- a/engines/scumm/object.cpp
+++ b/engines/scumm/object.cpp
@@ -500,8 +500,8 @@ void ScummEngine::clearRoomObjects() {
_objs[i].obj_nr = 0;
} else {
// Nuke all unlocked flObjects
- if (!res.isLocked(rtFlObject, _objs[i].fl_object_index)) {
- res.nukeResource(rtFlObject, _objs[i].fl_object_index);
+ if (!_res->isLocked(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;
} else if (_game.heversion >= 70) {
@@ -933,7 +933,7 @@ void ScummEngine::clearOwnerOf(int obj) {
if (_objs[i].obj_nr == obj) {
if (!_objs[i].fl_object_index)
return;
- res.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;
}
@@ -945,7 +945,7 @@ void ScummEngine::clearOwnerOf(int obj) {
if (_inventory[i] == obj) {
j = whereIsObject(obj);
if (j == WIO_INVENTORY) {
- res.nukeResource(rtInventory, i);
+ _res->nukeResource(rtInventory, i);
_inventory[i] = 0;
}
a = _inventory;
@@ -953,8 +953,8 @@ void ScummEngine::clearOwnerOf(int obj) {
if (!a[0] && a[1]) {
a[0] = a[1];
a[1] = 0;
- res.address[rtInventory][i] = res.address[rtInventory][i + 1];
- res.address[rtInventory][i + 1] = NULL;
+ _res->address[rtInventory][i] = _res->address[rtInventory][i + 1];
+ _res->address[rtInventory][i + 1] = NULL;
}
}
return;
@@ -1029,7 +1029,7 @@ void ScummEngine::setObjectName(int obj) {
for (i = 0; i < _numNewNames; i++) {
if (_newNames[i] == obj) {
- res.nukeResource(rtObjectName, i);
+ _res->nukeResource(rtObjectName, i);
_newNames[i] = 0;
break;
}
@@ -1234,7 +1234,7 @@ void ScummEngine::addObjectToInventory(uint obj, uint room) {
slot = getInventorySlot();
_inventory[slot] = obj;
- dst = res.createResource(rtInventory, slot, size);
+ dst = _res->createResource(rtInventory, slot, size);
assert(dst);
memcpy(dst, ptr, size);
@@ -1562,7 +1562,7 @@ void ScummEngine::nukeFlObjects(int min, int max) {
for (i = (_numLocalObjects-1), od = _objs; --i >= 0; od++)
if (od->fl_object_index && od->obj_nr >= min && od->obj_nr <= max) {
- res.nukeResource(rtFlObject, od->fl_object_index);
+ _res->nukeResource(rtFlObject, od->fl_object_index);
od->obj_nr = 0;
od->fl_object_index = 0;
}
@@ -1729,7 +1729,7 @@ int ScummEngine::findLocalObjectSlot() {
int ScummEngine::findFlObjectSlot() {
int i;
for (i = 1; i < _numFlObject; i++) {
- if (res.address[rtFlObject][i] == NULL)
+ if (_res->address[rtFlObject][i] == NULL)
return i;
}
error("findFlObjectSlot: Out of FLObject slots");
@@ -1782,16 +1782,16 @@ void ScummEngine::loadFlObject(uint object, uint room) {
// Lock room/roomScripts for the given room. They contains the OBCD/OBIM
// data, and a call to createResource might expire them, hence we lock them.
- isRoomLocked = res.isLocked(rtRoom, room);
- isRoomScriptsLocked = res.isLocked(rtRoomScripts, room);
+ isRoomLocked = _res->isLocked(rtRoom, room);
+ isRoomScriptsLocked = _res->isLocked(rtRoomScripts, room);
if (!isRoomLocked)
- res.lock(rtRoom, room);
+ _res->lock(rtRoom, room);
if (_game.version == 8 && !isRoomScriptsLocked)
- res.lock(rtRoomScripts, room);
+ _res->lock(rtRoomScripts, room);
// Allocate slot & memory for floating object
slot = findFlObjectSlot();
- flob = res.createResource(rtFlObject, slot, flob_size);
+ flob = _res->createResource(rtFlObject, slot, flob_size);
assert(flob);
// Copy object code + object image to floating object
@@ -1803,9 +1803,9 @@ void ScummEngine::loadFlObject(uint object, uint room) {
// Unlock room/roomScripts
if (!isRoomLocked)
- res.unlock(rtRoom, room);
+ _res->unlock(rtRoom, room);
if (_game.version == 8 && !isRoomScriptsLocked)
- res.unlock(rtRoomScripts, room);
+ _res->unlock(rtRoomScripts, room);
// Setup local object flags
resetRoomObject(od, flob, flob);
diff --git a/engines/scumm/plugin.cpp b/engines/scumm/plugin.cpp
index fe592bdbe8..3289eda8aa 100644
--- a/engines/scumm/plugin.cpp
+++ b/engines/scumm/plugin.cpp
@@ -821,7 +821,7 @@ static const MD5Table *findInMD5Table(const char *md5) {
}
Common::String ScummEngine::generateFilename(const int room) const {
- const int diskNumber = (room > 0) ? res.roomno[rtRoom][room] : 0;
+ const int diskNumber = (room > 0) ? _res->roomno[rtRoom][room] : 0;
char buf[128];
if (_game.version == 4) {
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 47e411dd06..c6053f8453 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -85,8 +85,8 @@ void ScummEngine::openRoom(const int room) {
// Load the disk numer / room offs (special case for room 0 exists because
// room 0 contains the data which is used to create the roomno / roomoffs
// tables -- hence obviously we mustn't use those when loading room 0.
- const uint32 diskNumber = room ? res.roomno[rtRoom][room] : 0;
- const uint32 room_offs = room ? res.roomoffs[rtRoom][room] : 0;
+ const uint32 diskNumber = room ? _res->roomno[rtRoom][room] : 0;
+ const uint32 room_offs = room ? _res->roomoffs[rtRoom][room] : 0;
// FIXME: Since room_offs is const, clearly the following loop either
// is never entered, or loops forever (if it wasn't for the return/error
@@ -96,7 +96,7 @@ void ScummEngine::openRoom(const int room) {
while (room_offs != 0xFFFFFFFF) {
if (room_offs != 0 && room != 0 && _game.heversion < 98) {
- _fileOffset = res.roomoffs[rtRoom][room];
+ _fileOffset = _res->roomoffs[rtRoom][room];
return;
}
@@ -124,7 +124,7 @@ void ScummEngine::openRoom(const int room) {
return;
deleteRoomOffsets();
readRoomsOffsets();
- _fileOffset = res.roomoffs[rtRoom][room];
+ _fileOffset = _res->roomoffs[rtRoom][room];
if (_fileOffset != 8)
return;
@@ -159,8 +159,8 @@ void ScummEngine::closeRoom() {
/** Delete the currently loaded room offsets. */
void ScummEngine::deleteRoomOffsets() {
for (int i = 0; i < _numRooms; i++) {
- if (res.roomoffs[rtRoom][i] != 0xFFFFFFFF)
- res.roomoffs[rtRoom][i] = 0;
+ if (_res->roomoffs[rtRoom][i] != 0xFFFFFFFF)
+ _res->roomoffs[rtRoom][i] = 0;
}
}
@@ -179,8 +179,8 @@ void ScummEngine::readRoomsOffsets() {
num = _fileHandle->readByte();
while (num--) {
room = _fileHandle->readByte();
- if (res.roomoffs[rtRoom][room] != 0xFFFFFFFF) {
- res.roomoffs[rtRoom][room] = _fileHandle->readUint32LE();
+ if (_res->roomoffs[rtRoom][room] != 0xFFFFFFFF) {
+ _res->roomoffs[rtRoom][room] = _fileHandle->readUint32LE();
} else {
_fileHandle->readUint32LE();
}
@@ -508,29 +508,29 @@ void ScummEngine::readResTypeList(int id, const char *name) {
else
num = _fileHandle->readUint16LE();
- if (num != res.num[id]) {
+ if (num != _res->num[id]) {
error("Invalid number of %ss (%d) in directory", name, num);
}
if (_game.features & GF_SMALL_HEADER) {
for (i = 0; i < num; i++) {
- res.roomno[id][i] = _fileHandle->readByte();
- res.roomoffs[id][i] = _fileHandle->readUint32LE();
+ _res->roomno[id][i] = _fileHandle->readByte();
+ _res->roomoffs[id][i] = _fileHandle->readUint32LE();
}
} else {
for (i = 0; i < num; i++) {
- res.roomno[id][i] = _fileHandle->readByte();
+ _res->roomno[id][i] = _fileHandle->readByte();
}
for (i = 0; i < num; i++) {
- res.roomoffs[id][i] = _fileHandle->readUint32LE();
+ _res->roomoffs[id][i] = _fileHandle->readUint32LE();
if (id == rtRoom && _game.heversion >= 70)
- _heV7RoomIntOffsets[i] = res.roomoffs[id][i];
+ _heV7RoomIntOffsets[i] = _res->roomoffs[id][i];
}
if (_game.heversion >= 70) {
for (i = 0; i < num; i++) {
- res.globsize[id][i] = _fileHandle->readUint32LE();
+ _res->globsize[id][i] = _fileHandle->readUint32LE();
}
}
}
@@ -590,7 +590,7 @@ void ScummEngine::loadCharset(int no) {
void ScummEngine::nukeCharset(int i) {
assertRange(1, i, _numCharsets - 1, "charset");
- res.nukeResource(rtCharset, i);
+ _res->nukeResource(rtCharset, i);
}
void ScummEngine::ensureResourceLoaded(int type, int i) {
@@ -616,8 +616,8 @@ void ScummEngine::ensureResourceLoaded(int type, int i) {
if (type != rtCharset && i == 0)
return;
- if (i <= res.num[type])
- addr = res.address[type][i];
+ if (i <= _res->num[type])
+ addr = _res->address[type][i];
if (addr)
return;
@@ -642,8 +642,8 @@ int ScummEngine::loadResource(int type, int idx) {
roomNr = getResourceRoomNr(type, idx);
- if (idx >= res.num[type])
- error("%s %d undefined %d %d", res.name[type], idx, res.num[type], roomNr);
+ if (idx >= _res->num[type])
+ error("%s %d undefined %d %d", _res->name[type], idx, _res->num[type], roomNr);
if (roomNr == 0)
roomNr = _roomResource;
@@ -656,7 +656,7 @@ int ScummEngine::loadResource(int type, int idx) {
else
fileOffs = 0;
} else {
- fileOffs = res.roomoffs[type][idx];
+ fileOffs = _res->roomoffs[type][idx];
if (fileOffs == 0xFFFFFFFF)
return 0;
}
@@ -688,16 +688,16 @@ int ScummEngine::loadResource(int type, int idx) {
tag = _fileHandle->readUint32BE();
- if (tag != res.tags[type] && _game.heversion < 70) {
+ if (tag != _res->tags[type] && _game.heversion < 70) {
error("%s %d not in room %d at %d+%d in file %s",
- res.name[type], idx, roomNr,
+ _res->name[type], idx, roomNr,
_fileOffset, fileOffs, _fileHandle->name());
}
size = _fileHandle->readUint32BE();
_fileHandle->seek(-8, SEEK_CUR);
}
- _fileHandle->read(res.createResource(type, idx, size), size);
+ _fileHandle->read(_res->createResource(type, idx, size), size);
// dump the resource if requested
if (_dumpScripts && type == rtScript) {
@@ -708,7 +708,7 @@ int ScummEngine::loadResource(int type, int idx) {
return 1;
}
- res.nukeResource(type, idx);
+ _res->nukeResource(type, idx);
error("Cannot read resource");
}
@@ -716,7 +716,7 @@ int ScummEngine::loadResource(int type, int idx) {
int ScummEngine::getResourceRoomNr(int type, int idx) {
if (type == rtRoom && _game.heversion < 70)
return idx;
- return res.roomno[type][idx];
+ return _res->roomno[type][idx];
}
int ScummEngine::getResourceSize(int type, int idx) {
@@ -734,24 +734,24 @@ byte *ScummEngine::getResourceAddress(int type, int idx) {
if (_game.heversion >= 80 && type == rtString)
idx &= ~0x33539000;
- if (!res.validateResource("getResourceAddress", type, idx))
+ if (!_res->validateResource("getResourceAddress", type, idx))
return NULL;
- if (!res.address[type]) {
- debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d), res.address[type] == NULL", resTypeFromId(type), idx);
+ if (!_res->address[type]) {
+ debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d), _res->address[type] == NULL", resTypeFromId(type), idx);
return NULL;
}
- if (res.mode[type] && !res.address[type][idx]) {
+ if (_res->mode[type] && !_res->address[type][idx]) {
ensureResourceLoaded(type, idx);
}
- if (!(ptr = (byte *)res.address[type][idx])) {
+ if (!(ptr = (byte *)_res->address[type][idx])) {
debugC(DEBUG_RESOURCE, "getResourceAddress(%s,%d) == NULL", resTypeFromId(type), idx);
return NULL;
}
- res.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);
@@ -805,7 +805,7 @@ byte *ResourceManager::createResource(int type, int idx, uint32 size) {
byte *ptr;
CHECK_HEAP
- debugC(DEBUG_RESOURCE, "res.createResource(%s,%d,%d)", resTypeFromId(type), idx, size);
+ debugC(DEBUG_RESOURCE, "_res->createResource(%s,%d,%d)", resTypeFromId(type), idx, size);
if (!validateResource("allocating", type, idx))
return NULL;
@@ -926,7 +926,7 @@ bool ResourceManager::isLocked(int type, int i) const {
}
bool ScummEngine::isResourceInUse(int type, int i) const {
- if (!res.validateResource("isResourceInUse", type, i))
+ if (!_res->validateResource("isResourceInUse", type, i))
return false;
switch (type) {
case rtRoom:
@@ -944,7 +944,7 @@ bool ScummEngine::isResourceInUse(int type, int i) const {
case rtCharset:
return _charset->getCurID() == i;
case rtImage:
- return res.isModified(type, i) != 0;
+ return _res->isModified(type, i) != 0;
case rtSpoolBuffer:
return _sound->isSoundRunning(10000 + i) != 0;
default:
@@ -1028,14 +1028,14 @@ void ScummEngine::loadPtrToResource(int type, int resindex, const byte *source)
byte *alloced;
int i, len;
- res.nukeResource(type, resindex);
+ _res->nukeResource(type, resindex);
len = resStrLen(source) + 1;
if (len <= 0)
return;
- alloced = res.createResource(type, resindex, len);
+ alloced = _res->createResource(type, resindex, len);
if (!source) {
alloced[0] = fetchScriptByte();
@@ -1292,28 +1292,28 @@ void ScummEngine::allocateArrays() {
_storedFlObjects = (ObjectData *)calloc(100, sizeof(ObjectData));
}
- res.allocResTypeData(rtCostume, (_game.features & GF_NEW_COSTUMES) ? MKID_BE('AKOS') : MKID_BE('COST'),
+ _res->allocResTypeData(rtCostume, (_game.features & GF_NEW_COSTUMES) ? MKID_BE('AKOS') : MKID_BE('COST'),
_numCostumes, "costume", 1);
- res.allocResTypeData(rtRoom, MKID_BE('ROOM'), _numRooms, "room", 1);
- res.allocResTypeData(rtRoomImage, MKID_BE('RMIM'), _numRooms, "room image", 1);
- res.allocResTypeData(rtRoomScripts, MKID_BE('RMSC'), _numRooms, "room script", 1);
- res.allocResTypeData(rtSound, MKID_BE('SOUN'), _numSounds, "sound", 2);
- res.allocResTypeData(rtScript, MKID_BE('SCRP'), _numScripts, "script", 1);
- res.allocResTypeData(rtCharset, MKID_BE('CHAR'), _numCharsets, "charset", 1);
- res.allocResTypeData(rtObjectName, 0, _numNewNames, "new name", 0);
- res.allocResTypeData(rtInventory, 0, _numInventory, "inventory", 0);
- res.allocResTypeData(rtTemp, 0, 10, "temp", 0);
- res.allocResTypeData(rtScaleTable, 0, 5, "scale table", 0);
- res.allocResTypeData(rtActorName, 0, _numActors, "actor name", 0);
- res.allocResTypeData(rtVerb, 0, _numVerbs, "verb", 0);
- res.allocResTypeData(rtString, 0, _numArray, "array", 0);
- res.allocResTypeData(rtFlObject, 0, _numFlObject, "flobject", 0);
- res.allocResTypeData(rtMatrix, 0, 10, "boxes", 0);
- res.allocResTypeData(rtImage, MKID_BE('AWIZ'), _numImages, "images", 1);
- res.allocResTypeData(rtTalkie, MKID_BE('TLKE'), _numTalkies, "talkie", 1);
+ _res->allocResTypeData(rtRoom, MKID_BE('ROOM'), _numRooms, "room", 1);
+ _res->allocResTypeData(rtRoomImage, MKID_BE('RMIM'), _numRooms, "room image", 1);
+ _res->allocResTypeData(rtRoomScripts, MKID_BE('RMSC'), _numRooms, "room script", 1);
+ _res->allocResTypeData(rtSound, MKID_BE('SOUN'), _numSounds, "sound", 2);
+ _res->allocResTypeData(rtScript, MKID_BE('SCRP'), _numScripts, "script", 1);
+ _res->allocResTypeData(rtCharset, MKID_BE('CHAR'), _numCharsets, "charset", 1);
+ _res->allocResTypeData(rtObjectName, 0, _numNewNames, "new name", 0);
+ _res->allocResTypeData(rtInventory, 0, _numInventory, "inventory", 0);
+ _res->allocResTypeData(rtTemp, 0, 10, "temp", 0);
+ _res->allocResTypeData(rtScaleTable, 0, 5, "scale table", 0);
+ _res->allocResTypeData(rtActorName, 0, _numActors, "actor name", 0);
+ _res->allocResTypeData(rtVerb, 0, _numVerbs, "verb", 0);
+ _res->allocResTypeData(rtString, 0, _numArray, "array", 0);
+ _res->allocResTypeData(rtFlObject, 0, _numFlObject, "flobject", 0);
+ _res->allocResTypeData(rtMatrix, 0, 10, "boxes", 0);
+ _res->allocResTypeData(rtImage, MKID_BE('AWIZ'), _numImages, "images", 1);
+ _res->allocResTypeData(rtTalkie, MKID_BE('TLKE'), _numTalkies, "talkie", 1);
if (_game.heversion >= 70) {
- res.allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
+ _res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
_heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
}
}
diff --git a/engines/scumm/resource_v2.cpp b/engines/scumm/resource_v2.cpp
index e1a12aac86..a503e1291d 100644
--- a/engines/scumm/resource_v2.cpp
+++ b/engines/scumm/resource_v2.cpp
@@ -87,40 +87,40 @@ void ScummEngine_v2::readClassicIndexFile() {
}
for (i = 0; i < _numRooms; i++) {
- res.roomno[rtRoom][i] = i;
+ _res->roomno[rtRoom][i] = i;
}
_fileHandle->seek(_numRooms, SEEK_CUR);
for (i = 0; i < _numRooms; i++) {
- res.roomoffs[rtRoom][i] = _fileHandle->readUint16LE();
- if (res.roomoffs[rtRoom][i] == 0xFFFF)
- res.roomoffs[rtRoom][i] = 0xFFFFFFFF;
+ _res->roomoffs[rtRoom][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtRoom][i] == 0xFFFF)
+ _res->roomoffs[rtRoom][i] = 0xFFFFFFFF;
}
for (i = 0; i < _numCostumes; i++) {
- res.roomno[rtCostume][i] = _fileHandle->readByte();
+ _res->roomno[rtCostume][i] = _fileHandle->readByte();
}
for (i = 0; i < _numCostumes; i++) {
- res.roomoffs[rtCostume][i] = _fileHandle->readUint16LE();
- if (res.roomoffs[rtCostume][i] == 0xFFFF)
- res.roomoffs[rtCostume][i] = 0xFFFFFFFF;
+ _res->roomoffs[rtCostume][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtCostume][i] == 0xFFFF)
+ _res->roomoffs[rtCostume][i] = 0xFFFFFFFF;
}
for (i = 0; i < _numScripts; i++) {
- res.roomno[rtScript][i] = _fileHandle->readByte();
+ _res->roomno[rtScript][i] = _fileHandle->readByte();
}
for (i = 0; i < _numScripts; i++) {
- res.roomoffs[rtScript][i] = _fileHandle->readUint16LE();
- if (res.roomoffs[rtScript][i] == 0xFFFF)
- res.roomoffs[rtScript][i] = 0xFFFFFFFF;
+ _res->roomoffs[rtScript][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtScript][i] == 0xFFFF)
+ _res->roomoffs[rtScript][i] = 0xFFFFFFFF;
}
for (i = 0; i < _numSounds; i++) {
- res.roomno[rtSound][i] = _fileHandle->readByte();
+ _res->roomno[rtSound][i] = _fileHandle->readByte();
}
for (i = 0; i < _numSounds; i++) {
- res.roomoffs[rtSound][i] = _fileHandle->readUint16LE();
- if (res.roomoffs[rtSound][i] == 0xFFFF)
- res.roomoffs[rtSound][i] = 0xFFFFFFFF;
+ _res->roomoffs[rtSound][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[rtSound][i] == 0xFFFF)
+ _res->roomoffs[rtSound][i] = 0xFFFFFFFF;
}
}
diff --git a/engines/scumm/resource_v3.cpp b/engines/scumm/resource_v3.cpp
index 5f9f088bfd..3f1c1ead24 100644
--- a/engines/scumm/resource_v3.cpp
+++ b/engines/scumm/resource_v3.cpp
@@ -45,16 +45,16 @@ void ScummEngine_v3old::readResTypeList(int id, const char *name) {
if (id == rtRoom) {
for (i = 0; i < num; i++)
- res.roomno[id][i] = i;
+ _res->roomno[id][i] = i;
_fileHandle->seek(num, SEEK_CUR);
} else {
for (i = 0; i < num; i++)
- res.roomno[id][i] = _fileHandle->readByte();
+ _res->roomno[id][i] = _fileHandle->readByte();
}
for (i = 0; i < num; i++) {
- res.roomoffs[id][i] = _fileHandle->readUint16LE();
- if (res.roomoffs[id][i] == 0xFFFF)
- res.roomoffs[id][i] = 0xFFFFFFFF;
+ _res->roomoffs[id][i] = _fileHandle->readUint16LE();
+ if (_res->roomoffs[id][i] == 0xFFFF)
+ _res->roomoffs[id][i] = 0xFFFFFFFF;
}
}
@@ -116,7 +116,7 @@ void ScummEngine_v3::loadCharset(int no) {
}
size = file.readUint16LE();
- file.read(res.createResource(rtCharset, no, size), size);
+ file.read(_res->createResource(rtCharset, no, size), size);
}
} // End of namespace Scumm
diff --git a/engines/scumm/resource_v4.cpp b/engines/scumm/resource_v4.cpp
index f6d51373fc..c8c2eb562d 100644
--- a/engines/scumm/resource_v4.cpp
+++ b/engines/scumm/resource_v4.cpp
@@ -149,7 +149,7 @@ void ScummEngine_v4::loadCharset(int no) {
}
size = file.readUint32LE() + 11;
- file.read(res.createResource(rtCharset, no, size), size);
+ file.read(_res->createResource(rtCharset, no, size), size);
}
void ScummEngine_v4::readMAXS(int blockSize) {
diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp
index 0fa4ebea51..82257976d2 100644
--- a/engines/scumm/room.cpp
+++ b/engines/scumm/room.cpp
@@ -118,7 +118,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {
VAR(VAR_ROOM) = room;
_fullRedraw = true;
- res.increaseResourceCounter();
+ _res->increaseResourceCounter();
_currentRoom = room;
VAR(VAR_ROOM) = room;
@@ -464,8 +464,8 @@ void ScummEngine::resetRoomSubBlocks() {
//
memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags));
- res.nukeResource(rtMatrix, 1);
- res.nukeResource(rtMatrix, 2);
+ _res->nukeResource(rtMatrix, 1);
+ _res->nukeResource(rtMatrix, 2);
if (_game.features & GF_SMALL_HEADER) {
ptr = findResourceData(MKID_BE('BOXD'), roomptr);
if (ptr) {
@@ -476,13 +476,13 @@ void ScummEngine::resetRoomSubBlocks() {
else
size = numOfBoxes * SIZEOF_BOX + 1;
- res.createResource(rtMatrix, 2, size);
+ _res->createResource(rtMatrix, 2, size);
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
ptr += size;
size = getResourceDataSize(ptr - size - _resourceHeaderSize) - size;
if (size > 0) { // do this :)
- res.createResource(rtMatrix, 1, size);
+ _res->createResource(rtMatrix, 1, size);
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
}
@@ -491,7 +491,7 @@ void ScummEngine::resetRoomSubBlocks() {
ptr = findResourceData(MKID_BE('BOXD'), roomptr);
if (ptr) {
int size = getResourceDataSize(ptr);
- res.createResource(rtMatrix, 2, size);
+ _res->createResource(rtMatrix, 2, size);
roomptr = getResourceAddress(rtRoom, _roomResource);
ptr = findResourceData(MKID_BE('BOXD'), roomptr);
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
@@ -500,7 +500,7 @@ void ScummEngine::resetRoomSubBlocks() {
ptr = findResourceData(MKID_BE('BOXM'), roomptr);
if (ptr) {
int size = getResourceDataSize(ptr);
- res.createResource(rtMatrix, 1, size);
+ _res->createResource(rtMatrix, 1, size);
roomptr = getResourceAddress(rtRoom, _roomResource);
ptr = findResourceData(MKID_BE('BOXM'), roomptr);
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
@@ -510,14 +510,14 @@ void ScummEngine::resetRoomSubBlocks() {
//
// Load scale data
//
- for (i = 1; i < res.num[rtScaleTable]; i++)
- res.nukeResource(rtScaleTable, i);
+ for (i = 1; i < _res->num[rtScaleTable]; i++)
+ _res->nukeResource(rtScaleTable, i);
ptr = findResourceData(MKID_BE('SCAL'), roomptr);
if (ptr) {
int s1, s2, y1, y2;
if (_game.version == 8) {
- for (i = 1; i < res.num[rtScaleTable]; i++, ptr += 16) {
+ for (i = 1; i < _res->num[rtScaleTable]; i++, ptr += 16) {
s1 = READ_LE_UINT32(ptr);
y1 = READ_LE_UINT32(ptr + 4);
s2 = READ_LE_UINT32(ptr + 8);
@@ -525,7 +525,7 @@ void ScummEngine::resetRoomSubBlocks() {
setScaleSlot(i, 0, y1, s1, 0, y2, s2);
}
} else {
- for (i = 1; i < res.num[rtScaleTable]; i++, ptr += 8) {
+ for (i = 1; i < _res->num[rtScaleTable]; i++, ptr += 8) {
s1 = READ_LE_UINT16(ptr);
y1 = READ_LE_UINT16(ptr + 2);
s2 = READ_LE_UINT16(ptr + 4);
@@ -714,8 +714,8 @@ void ScummEngine_v3old::resetRoomSubBlocks() {
//
// Load box data
//
- res.nukeResource(rtMatrix, 1);
- res.nukeResource(rtMatrix, 2);
+ _res->nukeResource(rtMatrix, 1);
+ _res->nukeResource(rtMatrix, 2);
if (_game.version <= 2)
ptr = roomptr + *(roomptr + 0x15);
@@ -735,7 +735,7 @@ void ScummEngine_v3old::resetRoomSubBlocks() {
ptr = roomptr + *(roomptr + 0x15);
size = numOfBoxes * SIZEOF_BOX_C64 + 1;
- res.createResource(rtMatrix, 2, size + 1);
+ _res->createResource(rtMatrix, 2, size + 1);
getResourceAddress(rtMatrix, 2)[0] = numOfBoxes;
memcpy(getResourceAddress(rtMatrix, 2) + 1, ptr, size);
} else {
@@ -745,7 +745,7 @@ void ScummEngine_v3old::resetRoomSubBlocks() {
else
size = numOfBoxes * SIZEOF_BOX_V3 + 1;
- res.createResource(rtMatrix, 2, size);
+ _res->createResource(rtMatrix, 2, size);
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
}
@@ -771,7 +771,7 @@ void ScummEngine_v3old::resetRoomSubBlocks() {
}
if (size > 0) { // do this :)
- res.createResource(rtMatrix, 1, size);
+ _res->createResource(rtMatrix, 1, size);
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
}
@@ -780,8 +780,8 @@ void ScummEngine_v3old::resetRoomSubBlocks() {
//
// No scale data in old bundle games
//
- for (i = 1; i < res.num[rtScaleTable]; i++)
- res.nukeResource(rtScaleTable, i);
+ for (i = 1; i < _res->num[rtScaleTable]; i++)
+ _res->nukeResource(rtScaleTable, i);
}
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 459823a8ff..c3444b5117 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -247,8 +247,8 @@ bool ScummEngine::loadState(int slot, bool compat) {
// Nuke all resources
for (i = rtFirst; i <= rtLast; i++)
if (i != rtTemp && i != rtBuffer && (i != rtSound || _saveSound || !compat))
- for (j = 0; j < res.num[i]; j++) {
- res.nukeResource(i, j);
+ for (j = 0; j < _res->num[i]; j++) {
+ _res->nukeResource(i, j);
}
resetScummVars();
@@ -320,7 +320,7 @@ bool ScummEngine::loadState(int slot, bool compat) {
// loading such an old save game, try to upgrade the old to new format.
if (hdr.ver < VER(22)) {
// Convert all rtScaleTable resources to matching scale items
- for (i = 1; i < res.num[rtScaleTable]; i++) {
+ for (i = 1; i < _res->num[rtScaleTable]; i++) {
convertScaleTableToScaleSlot(i);
}
}
@@ -1002,11 +1002,11 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// number of script resources, savegames won't break.
if (s->isSaving()) {
for (type = rtFirst; type <= rtLast; type++) {
- if (res.mode[type] != 1 && type != rtTemp && type != rtBuffer) {
+ if (_res->mode[type] != 1 && type != rtTemp && type != rtBuffer) {
s->saveUint16(type); // Save the res type...
- for (idx = 0; idx < res.num[type]; idx++) {
+ for (idx = 0; idx < _res->num[type]; idx++) {
// Only save resources which actually exist...
- if (res.address[type][idx]) {
+ if (_res->address[type][idx]) {
s->saveUint16(idx); // Save the index of the resource
saveResource(s, type, idx);
}
@@ -1018,7 +1018,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
} else {
while ((type = s->loadUint16()) != 0xFFFF) {
while ((idx = s->loadUint16()) != 0xFFFF) {
- assert(0 <= idx && idx < res.num[type]);
+ assert(0 <= idx && idx < _res->num[type]);
loadResource(s, type, idx);
}
}
@@ -1028,13 +1028,13 @@ void ScummEngine::saveOrLoad(Serializer *s) {
// with index 0, and breaks whenever we change the limit on a given
// resource type.
for (type = rtFirst; type <= rtLast; type++)
- if (res.mode[type] != 1 && type != rtTemp && type != rtBuffer) {
+ if (_res->mode[type] != 1 && type != rtTemp && type != rtBuffer) {
// For V1-V5 games, there used to be no object name resources.
// At some point this changed. But since old savegames rely on
// unchanged resource counts, we have to hard code the following check
if (_game.version < 6 && type == rtObjectName)
continue;
- for (idx = 1; idx < res.num[type]; idx++)
+ for (idx = 1; idx < _res->num[type]; idx++)
saveLoadResource(s, type, idx);
}
}
@@ -1115,8 +1115,8 @@ void ScummEngine::saveOrLoad(Serializer *s) {
//
if (s->isSaving()) {
for (i = rtFirst; i <= rtLast; i++)
- for (j = 1; j < res.num[i]; j++) {
- if (res.isLocked(i, j)) {
+ for (j = 1; j < _res->num[i]; j++) {
+ if (_res->isLocked(i, j)) {
s->saveByte(i);
s->saveUint16(j);
}
@@ -1125,7 +1125,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
} else {
while ((i = s->loadByte()) != 0xFF) {
j = s->loadUint16();
- res.lock(i, j);
+ _res->lock(i, j);
}
}
@@ -1307,9 +1307,9 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) {
byte *ptr;
uint32 size;
- if (!res.mode[type]) {
+ if (!_res->mode[type]) {
if (ser->isSaving()) {
- ptr = res.address[type][idx];
+ ptr = _res->address[type][idx];
if (ptr == NULL) {
ser->saveUint32(0);
return;
@@ -1329,7 +1329,7 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) {
} else {
size = ser->loadUint32();
if (size) {
- res.createResource(type, idx, size);
+ _res->createResource(type, idx, size);
ser->loadBytes(getResourceAddress(type, idx), size);
if (type == rtInventory) {
_inventory[idx] = ser->loadUint16();
@@ -1346,10 +1346,10 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) {
}
}
}
- } else if (res.mode[type] == 2 && ser->getVersion() >= VER(23)) {
+ } else if (_res->mode[type] == 2 && ser->getVersion() >= VER(23)) {
// Save/load only a list of resource numbers that need reloaded.
if (ser->isSaving()) {
- ser->saveUint16(res.address[type][idx] ? 1 : 0);
+ ser->saveUint16(_res->address[type][idx] ? 1 : 0);
} else {
if (ser->loadUint16())
ensureResourceLoaded(type, idx);
@@ -1358,10 +1358,10 @@ void ScummEngine::saveLoadResource(Serializer *ser, int type, int idx) {
}
void ScummEngine::saveResource(Serializer *ser, int type, int idx) {
- assert(res.address[type][idx]);
+ assert(_res->address[type][idx]);
- if (res.mode[type] == 0) {
- byte *ptr = res.address[type][idx];
+ if (_res->mode[type] == 0) {
+ byte *ptr = _res->address[type][idx];
uint32 size = ((MemBlkHeader *)ptr)->size;
ser->saveUint32(size);
@@ -1381,12 +1381,12 @@ void ScummEngine::loadResource(Serializer *ser, int type, int idx) {
((type == rtSound && idx == 1) || (type == rtSpoolBuffer))) {
uint32 size = ser->loadUint32();
assert(size);
- res.createResource(type, idx, size);
+ _res->createResource(type, idx, size);
ser->loadBytes(getResourceAddress(type, idx), size);
- } else if (res.mode[type] == 0) {
+ } else if (_res->mode[type] == 0) {
uint32 size = ser->loadUint32();
assert(size);
- res.createResource(type, idx, size);
+ _res->createResource(type, idx, size);
ser->loadBytes(getResourceAddress(type, idx), size);
if (type == rtInventory) {
@@ -1395,7 +1395,7 @@ void ScummEngine::loadResource(Serializer *ser, int type, int idx) {
if (type == rtObjectName) {
_newNames[idx] = ser->loadUint16();
}
- } else if (res.mode[type] == 2) {
+ } else if (_res->mode[type] == 2) {
// HE Games use sound resource 1 for speech
if (_game.heversion >= 60 && idx == 1)
return;
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index c956121db1..691342464e 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -371,7 +371,7 @@ void ScummEngine::nukeArrays(byte scriptSlot) {
for (i = 1; i < _numArray; i++) {
if (_arraySlot[i] == scriptSlot) {
- res.nukeResource(rtString, i);
+ _res->nukeResource(rtString, i);
_arraySlot[i] = 0;
}
}
@@ -393,26 +393,26 @@ void ScummEngine::getScriptBaseAddress() {
break;
_scriptOrgPointer = getResourceAddress(rtInventory, idx);
assert(idx < _numInventory);
- _lastCodePtr = &res.address[rtInventory][idx];
+ _lastCodePtr = &_res->address[rtInventory][idx];
break;
case WIO_LOCAL:
case WIO_ROOM: /* room script */
if (_game.version == 8) {
_scriptOrgPointer = getResourceAddress(rtRoomScripts, _roomResource);
- assert(_roomResource < res.num[rtRoomScripts]);
- _lastCodePtr = &res.address[rtRoomScripts][_roomResource];
+ assert(_roomResource < _res->num[rtRoomScripts]);
+ _lastCodePtr = &_res->address[rtRoomScripts][_roomResource];
} else {
_scriptOrgPointer = getResourceAddress(rtRoom, _roomResource);
assert(_roomResource < _numRooms);
- _lastCodePtr = &res.address[rtRoom][_roomResource];
+ _lastCodePtr = &_res->address[rtRoom][_roomResource];
}
break;
case WIO_GLOBAL: /* global script */
_scriptOrgPointer = getResourceAddress(rtScript, ss->number);
assert(ss->number < _numScripts);
- _lastCodePtr = &res.address[rtScript][ss->number];
+ _lastCodePtr = &_res->address[rtScript][ss->number];
break;
case WIO_FLOBJECT: /* flobject script */
@@ -421,7 +421,7 @@ void ScummEngine::getScriptBaseAddress() {
idx = _objs[idx].fl_object_index;
_scriptOrgPointer = getResourceAddress(rtFlObject, idx);
assert(idx < _numFlObject);
- _lastCodePtr = &res.address[rtFlObject][idx];
+ _lastCodePtr = &_res->address[rtFlObject][idx];
break;
default:
error("Bad type while getting base address");
@@ -1024,7 +1024,7 @@ void ScummEngine::killScriptsAndResources() {
continue;
_newNames[i] = 0;
- res.nukeResource(rtObjectName, i);
+ _res->nukeResource(rtObjectName, i);
}
}
}
@@ -1128,7 +1128,7 @@ void ScummEngine::checkAndRunSentenceScript() {
// For now we assume that if there are more than 460 scripts, then
// the pair 29/104 is used, else the pair 28/103.
- if (res.num[rtScript] > 460) {
+ if (_res->num[rtScript] > 460) {
if (sentenceScript == 104)
sentenceScript = 29;
} else {
diff --git a/engines/scumm/script_c64.cpp b/engines/scumm/script_c64.cpp
index 7882f44f05..1185ce40c3 100644
--- a/engines/scumm/script_c64.cpp
+++ b/engines/scumm/script_c64.cpp
@@ -594,12 +594,12 @@ void ScummEngine_c64::o_loadSound() {
void ScummEngine_c64::o_lockSound() {
int resid = fetchScriptByte();
- res.lock(rtSound, resid);
+ _res->lock(rtSound, resid);
}
void ScummEngine_c64::o_unlockSound() {
int resid = fetchScriptByte();
- res.unlock(rtSound, resid);
+ _res->unlock(rtSound, resid);
}
void ScummEngine_c64::o_loadCostume() {
@@ -609,12 +609,12 @@ void ScummEngine_c64::o_loadCostume() {
void ScummEngine_c64::o_lockCostume() {
int resid = fetchScriptByte();
- res.lock(rtCostume, resid);
+ _res->lock(rtCostume, resid);
}
void ScummEngine_c64::o_unlockCostume() {
int resid = fetchScriptByte();
- res.unlock(rtCostume, resid);
+ _res->unlock(rtCostume, resid);
}
void ScummEngine_c64::o_loadScript() {
@@ -624,12 +624,12 @@ void ScummEngine_c64::o_loadScript() {
void ScummEngine_c64::o_lockScript() {
int resid = fetchScriptByte();
- res.lock(rtScript, resid);
+ _res->lock(rtScript, resid);
}
void ScummEngine_c64::o_unlockScript() {
int resid = fetchScriptByte();
- res.unlock(rtScript, resid);
+ _res->unlock(rtScript, resid);
}
void ScummEngine_c64::o_loadRoom() {
@@ -670,12 +670,12 @@ void ScummEngine_c64::o_loadRoomWithEgo() {
void ScummEngine_c64::o_lockRoom() {
int resid = fetchScriptByte();
- res.lock(rtRoom, resid);
+ _res->lock(rtRoom, resid);
}
void ScummEngine_c64::o_unlockRoom() {
int resid = fetchScriptByte();
- res.unlock(rtRoom, resid);
+ _res->unlock(rtRoom, resid);
}
void ScummEngine_c64::o_cursorCommand() {
diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp
index ace9a2fe8e..66b1ea8bb3 100644
--- a/engines/scumm/script_v2.cpp
+++ b/engines/scumm/script_v2.cpp
@@ -787,9 +787,9 @@ void ScummEngine_v2::o2_resourceRoutines() {
ensureResourceLoaded(type, resid);
} else {
if (opcode & 1)
- res.lock(type, resid);
+ _res->lock(type, resid);
else
- res.unlock(type, resid);
+ _res->unlock(type, resid);
}
}
diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp
index dbd5e2a77c..887137fe47 100644
--- a/engines/scumm/script_v5.cpp
+++ b/engines/scumm/script_v5.cpp
@@ -1690,7 +1690,7 @@ void ScummEngine_v5::o5_resourceRoutines() {
resid = _resourceMapper[resid & 0x7F];
if (_currentRoom != resid) {
- res.setResourceCounter(rtRoom, resid, 1);
+ _res->setResourceCounter(rtRoom, resid, 1);
}
} else
ensureResourceLoaded(rtRoom, resid);
@@ -1703,40 +1703,40 @@ void ScummEngine_v5::o5_resourceRoutines() {
if (_game.id == GID_ZAK && (_game.platform == Common::kPlatformFMTowns))
error("o5_resourceRoutines %d should not occur in Zak256", op);
else
- res.setResourceCounter(resType[op-5], resid, 0x7F);
+ _res->setResourceCounter(resType[op-5], resid, 0x7F);
break;
case 9: // SO_LOCK_SCRIPT
if (resid >= _numGlobalScripts)
break;
- res.lock(rtScript, resid);
+ _res->lock(rtScript, resid);
break;
case 10: // SO_LOCK_SOUND
- res.lock(rtSound, resid);
+ _res->lock(rtSound, resid);
break;
case 11: // SO_LOCK_COSTUME
- res.lock(rtCostume, resid);
+ _res->lock(rtCostume, resid);
break;
case 12: // SO_LOCK_ROOM
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- res.lock(rtRoom, resid);
+ _res->lock(rtRoom, resid);
break;
case 13: // SO_UNLOCK_SCRIPT
if (resid >= _numGlobalScripts)
break;
- res.unlock(rtScript, resid);
+ _res->unlock(rtScript, resid);
break;
case 14: // SO_UNLOCK_SOUND
- res.unlock(rtSound, resid);
+ _res->unlock(rtSound, resid);
break;
case 15: // SO_UNLOCK_COSTUME
- res.unlock(rtCostume, resid);
+ _res->unlock(rtCostume, resid);
break;
case 16: // SO_UNLOCK_ROOM
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- res.unlock(rtRoom, resid);
+ _res->unlock(rtRoom, resid);
break;
case 17: // SO_CLEAR_HEAP
@@ -2286,7 +2286,7 @@ void ScummEngine_v5::o5_stringOps() {
case 2: /* copystring */
a = getVarOrDirectByte(PARAM_1);
b = getVarOrDirectByte(PARAM_2);
- res.nukeResource(rtString, a);
+ _res->nukeResource(rtString, a);
ptr = getResourceAddress(rtString, b);
if (ptr)
loadPtrToResource(rtString, a, ptr);
@@ -2314,9 +2314,9 @@ void ScummEngine_v5::o5_stringOps() {
case 5: /* create empty string */
a = getVarOrDirectByte(PARAM_1);
b = getVarOrDirectByte(PARAM_2);
- res.nukeResource(rtString, a);
+ _res->nukeResource(rtString, a);
if (b) {
- ptr = res.createResource(rtString, a, b);
+ ptr = _res->createResource(rtString, a, b);
if (ptr) {
for (i = 0; i < b; i++)
ptr[i] = 0;
@@ -2359,7 +2359,7 @@ void ScummEngine_v5::o5_verbOps() {
case 2: // SO_VERB_NAME
loadPtrToResource(rtVerb, slot, NULL);
if (slot == 0)
- res.nukeResource(rtVerb, slot);
+ _res->nukeResource(rtVerb, slot);
vs->type = kTextVerbType;
vs->imgindex = 0;
break;
@@ -2479,12 +2479,12 @@ void ScummEngine_v5::o5_verbOps() {
case 20: // SO_VERB_NAME_STR
ptr = getResourceAddress(rtString, getVarOrDirectWord(PARAM_1));
if (!ptr)
- res.nukeResource(rtVerb, slot);
+ _res->nukeResource(rtVerb, slot);
else {
loadPtrToResource(rtVerb, slot, ptr);
}
if (slot == 0)
- res.nukeResource(rtVerb, slot);
+ _res->nukeResource(rtVerb, slot);
vs->type = kTextVerbType;
vs->imgindex = 0;
break;
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index 500801673f..df3f1fb76b 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -448,7 +448,7 @@ ScummEngine_v6::ArrayHeader *ScummEngine_v6::defineArray(int array, int type, in
size *= dim2 + 1;
size *= dim1 + 1;
- ah = (ArrayHeader *)res.createResource(rtString, id, size + sizeof(ArrayHeader));
+ ah = (ArrayHeader *)_res->createResource(rtString, id, size + sizeof(ArrayHeader));
ah->type = TO_LE_16(type);
ah->dim1 = TO_LE_16(dim1 + 1);
@@ -466,7 +466,7 @@ void ScummEngine_v6::nukeArray(int a) {
data &= ~0x33539000;
if (data)
- res.nukeResource(rtString, data);
+ _res->nukeResource(rtString, data);
if (_game.heversion >= 60)
_arraySlot[data] = 0;
@@ -474,7 +474,7 @@ void ScummEngine_v6::nukeArray(int a) {
}
int ScummEngine_v6::findFreeArrayId() {
- byte **addr = res.address[rtString];
+ byte **addr = _res->address[rtString];
int i;
for (i = 1; i < _numArray; i++) {
@@ -1566,59 +1566,59 @@ void ScummEngine_v6::o6_resourceRoutines() {
if (_game.version >= 7)
if (resid >= _numGlobalScripts)
break;
- res.setResourceCounter(rtScript, resid, 0x7F);
+ _res->setResourceCounter(rtScript, resid, 0x7F);
break;
case 105: // SO_NUKE_SOUND
resid = pop();
- res.setResourceCounter(rtSound, resid, 0x7F);
+ _res->setResourceCounter(rtSound, resid, 0x7F);
break;
case 106: // SO_NUKE_COSTUME
resid = pop();
- res.setResourceCounter(rtCostume, resid, 0x7F);
+ _res->setResourceCounter(rtCostume, resid, 0x7F);
break;
case 107: // SO_NUKE_ROOM
resid = pop();
- res.setResourceCounter(rtRoom, resid, 0x7F);
+ _res->setResourceCounter(rtRoom, resid, 0x7F);
break;
case 108: // SO_LOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- res.lock(rtScript, resid);
+ _res->lock(rtScript, resid);
break;
case 109: // SO_LOCK_SOUND
resid = pop();
- res.lock(rtSound, resid);
+ _res->lock(rtSound, resid);
break;
case 110: // SO_LOCK_COSTUME
resid = pop();
- res.lock(rtCostume, resid);
+ _res->lock(rtCostume, resid);
break;
case 111: // SO_LOCK_ROOM
resid = pop();
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- res.lock(rtRoom, resid);
+ _res->lock(rtRoom, resid);
break;
case 112: // SO_UNLOCK_SCRIPT
resid = pop();
if (resid >= _numGlobalScripts)
break;
- res.unlock(rtScript, resid);
+ _res->unlock(rtScript, resid);
break;
case 113: // SO_UNLOCK_SOUND
resid = pop();
- res.unlock(rtSound, resid);
+ _res->unlock(rtSound, resid);
break;
case 114: // SO_UNLOCK_COSTUME
resid = pop();
- res.unlock(rtCostume, resid);
+ _res->unlock(rtCostume, resid);
break;
case 115: // SO_UNLOCK_ROOM
resid = pop();
if (resid > 0x7F)
resid = _resourceMapper[resid & 0x7F];
- res.unlock(rtRoom, resid);
+ _res->unlock(rtRoom, resid);
break;
case 116: // SO_CLEAR_HEAP
/* this is actually a scumm message */
@@ -3035,7 +3035,7 @@ void ScummEngine_v6::o6_setBoxSet() {
error("ScummEngine_v6::o6_setBoxSet: Can't find dboxes for set %d", arg);
dboxSize = READ_BE_UINT32(boxd + 4) - 8;
- byte *matrix = res.createResource(rtMatrix, 2, dboxSize);
+ byte *matrix = _res->createResource(rtMatrix, 2, dboxSize);
assert(matrix);
memcpy(matrix, boxd + 8, dboxSize);
@@ -3048,7 +3048,7 @@ void ScummEngine_v6::o6_setBoxSet() {
error("ScummEngine_v6::o6_setBoxSet: Can't find mboxes for set %d", arg);
mboxSize = READ_BE_UINT32(boxm + 4) - 8;
- matrix = res.createResource(rtMatrix, 1, mboxSize);
+ matrix = _res->createResource(rtMatrix, 1, mboxSize);
assert(matrix);
memcpy(matrix, boxm + 8, mboxSize);
diff --git a/engines/scumm/script_v8.cpp b/engines/scumm/script_v8.cpp
index 3d6e30f8c7..dc45095570 100644
--- a/engines/scumm/script_v8.cpp
+++ b/engines/scumm/script_v8.cpp
@@ -775,40 +775,40 @@ void ScummEngine_v8::o8_resourceRoutines() {
break;
case 0x42: // SO_HEAP_LOCK_COSTUME Lock costume in heap
- res.lock(rtCostume, resid);
+ _res->lock(rtCostume, resid);
break;
case 0x43: // SO_HEAP_LOCK_ROOM Lock room in heap
- res.lock(rtRoom, resid);
+ _res->lock(rtRoom, resid);
break;
case 0x44: // SO_HEAP_LOCK_SCRIPT Lock script in heap
- res.lock(rtScript, resid);
+ _res->lock(rtScript, resid);
break;
case 0x45: // SO_HEAP_LOCK_SOUND Lock sound in heap
- res.lock(rtSound, resid);
+ _res->lock(rtSound, resid);
break;
case 0x46: // SO_HEAP_UNLOCK_COSTUME Unlock costume
- res.unlock(rtCostume, resid);
+ _res->unlock(rtCostume, resid);
break;
case 0x47: // SO_HEAP_UNLOCK_ROOM Unlock room
- res.unlock(rtRoom, resid);
+ _res->unlock(rtRoom, resid);
break;
case 0x48: // SO_HEAP_UNLOCK_SCRIPT Unlock script
- res.unlock(rtScript, resid);
+ _res->unlock(rtScript, resid);
break;
case 0x49: // SO_HEAP_UNLOCK_SOUND Unlock sound
- res.unlock(rtSound, resid);
+ _res->unlock(rtSound, resid);
break;
case 0x4A: // SO_HEAP_NUKE_COSTUME Remove costume from heap
- res.setResourceCounter(rtCostume, resid, 0x7F);
+ _res->setResourceCounter(rtCostume, resid, 0x7F);
break;
case 0x4B: // SO_HEAP_NUKE_ROOM Remove room from heap
- res.setResourceCounter(rtRoom, resid, 0x7F);
+ _res->setResourceCounter(rtRoom, resid, 0x7F);
break;
case 0x4C: // SO_HEAP_NUKE_SCRIPT Remove script from heap
- res.setResourceCounter(rtScript, resid, 0x7F);
+ _res->setResourceCounter(rtScript, resid, 0x7F);
break;
case 0x4D: // SO_HEAP_NUKE_SOUND Remove sound from heap
- res.setResourceCounter(rtSound, resid, 0x7F);
+ _res->setResourceCounter(rtSound, resid, 0x7F);
break;
default:
error("o8_resourceRoutines: default case 0x%x", subOp);
@@ -1193,13 +1193,13 @@ void ScummEngine_v8::o8_kernelSetFunctions() {
case 11: { // lockObject
int objidx = getObjectIndex(args[1]);
assert(objidx != -1);
- res.lock(rtFlObject, _objs[objidx].fl_object_index);
+ _res->lock(rtFlObject, _objs[objidx].fl_object_index);
break;
}
case 12: { // unlockObject
int objidx = getObjectIndex(args[1]);
assert(objidx != -1);
- res.unlock(rtFlObject, _objs[objidx].fl_object_index);
+ _res->unlock(rtFlObject, _objs[objidx].fl_object_index);
break;
}
case 13: // remapCostume
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 56fecdfe16..fd1c6f74e9 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -84,11 +84,10 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_language(dr.language),
_debugger(0),
_currentScript(0xFF), // Let debug() work on init stage
- res(this),
_pauseDialog(0), _mainMenuDialog(0), _versionDialog(0) {
_gdi = new Gdi(this);
- //_res = new ResourceManager(this);
+ _res = new ResourceManager(this);
// Copy MD5 checksum
memcpy(_gameMD5, dr.md5sum, 16);
@@ -705,6 +704,7 @@ ScummEngine::~ScummEngine() {
delete _debugger;
+ delete _res;
delete _gdi;
}
@@ -971,7 +971,7 @@ int ScummEngine::init() {
resetScummVars();
if (_imuse) {
- _imuse->setBase(res.address[rtSound]);
+ _imuse->setBase(_res->address[rtSound]);
}
if (_game.version >= 5)
@@ -1027,7 +1027,7 @@ void ScummEngine::setupScumm() {
requestLoad(ConfMan.getInt("save_slot"));
}
- res.allocResTypeData(rtBuffer, 0, 10, "buffer", 0);
+ _res->allocResTypeData(rtBuffer, 0, 10, "buffer", 0);
setupScummVars();
@@ -1079,7 +1079,7 @@ void ScummEngine::setupScumm() {
maxHeapThreshold = 550000;
}
#endif
- res.setHeapThreshold(400000, maxHeapThreshold);
+ _res->setHeapThreshold(400000, maxHeapThreshold);
#if (defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
Graphics::initfonts();
@@ -1306,7 +1306,7 @@ void ScummEngine_v4::resetScumm() {
// The boot script sets the characters of string 21,
// before creating the string.resource.
if (_game.id == GID_LOOM) {
- res.createResource(rtString, 21, 12);
+ _res->createResource(rtString, 21, 12);
}
}
@@ -1766,7 +1766,7 @@ load_game:
camera._last = camera._cur;
- res.increaseExpireCounter();
+ _res->increaseExpireCounter();
animateCursor();
@@ -2013,7 +2013,7 @@ void ScummEngine::restart() {
resetScummVars();
if (_imuse) {
- _imuse->setBase(res.address[rtSound]);
+ _imuse->setBase(_res->address[rtSound]);
}
// Reinit sound engine
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 0980b10535..9d51d504b5 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -446,7 +446,7 @@ public:
Gdi *_gdi;
/** Central resource data. */
- ResourceManager res;
+ ResourceManager *_res;
// Misc utility functions
uint32 _debugFlags; // Used by the debugger
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 3d0d4d5844..d57e954bf4 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -689,7 +689,7 @@ int Sound::isSoundRunning(int sound) const {
if (isSoundInQueue(sound))
return 1;
- if (sound > _vm->_numSounds || !_vm->res.isResourceLoaded(rtSound, sound))
+ if (sound > _vm->_numSounds || !_vm->_res->isResourceLoaded(rtSound, sound))
return 0;
if (_vm->_musicEngine)
@@ -722,7 +722,7 @@ bool Sound::isSoundInUse(int sound) const {
if (isSoundInQueue(sound))
return true;
- if (!_vm->res.isResourceLoaded(rtSound, sound))
+ if (!_vm->_res->isResourceLoaded(rtSound, sound))
return false;
if (_vm->_imuse)
@@ -1062,7 +1062,7 @@ void Sound::saveLoadWithSerializer(Serializer *ser) {
#pragma mark --- Sound resource handling ---
#pragma mark -
-static void convertMac0Resource(ResourceManager &res, int type, int idx, byte *src_ptr, int size);
+static void convertMac0Resource(ResourceManager *res, int type, int idx, byte *src_ptr, int size);
/*
@@ -1094,7 +1094,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
case MKID_BE('iMUS'):
if (_musicType != MDT_PCSPK) {
_fileHandle->seek(-8, SEEK_CUR);
- _fileHandle->read(res.createResource(type, idx, total_size + 8), total_size + 8);
+ _fileHandle->read(_res->createResource(type, idx, total_size + 8), total_size + 8);
return 1;
}
break;
@@ -1157,7 +1157,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
if (best_pri != -1) {
_fileHandle->seek(best_offs - 8, SEEK_SET);
- ptr = res.createResource(type, idx, best_size);
+ ptr = _res->createResource(type, idx, best_size);
_fileHandle->read(ptr, best_size);
//dumpResource("sound-", idx, ptr);
return 1;
@@ -1169,7 +1169,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
ptr = (byte *)calloc(total_size, 1);
_fileHandle->read(ptr, total_size);
//dumpResource("sound-", idx, ptr);
- convertMac0Resource(res, type, idx, ptr, total_size);
+ convertMac0Resource(_res, type, idx, ptr, total_size);
free(ptr);
return 1;
@@ -1181,7 +1181,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
case 0x460e200d: // WORKAROUND bug # 1311447
_fileHandle->seek(-12, SEEK_CUR);
total_size = _fileHandle->readUint32BE();
- ptr = res.createResource(type, idx, total_size);
+ ptr = _res->createResource(type, idx, total_size);
_fileHandle->read(ptr, total_size - 8);
//dumpResource("sound-", idx, ptr);
return 1;
@@ -1190,7 +1190,7 @@ int ScummEngine::readSoundResource(int type, int idx) {
// HE sound type without SOUN header
_fileHandle->seek(-16, SEEK_CUR);
total_size = max_total_size + 8;
- ptr = res.createResource(type, idx, total_size);
+ ptr = _res->createResource(type, idx, total_size);
_fileHandle->read(ptr, total_size);
//dumpResource("sound-", idx, ptr);
return 1;
@@ -1220,14 +1220,14 @@ int ScummEngine::readSoundResource(int type, int idx) {
debugC(DEBUG_SOUND, "FMUS file %s", buffer);
if (dmuFile.open(buffer) == false) {
error("Can't open music file %s*", buffer);
- res.roomoffs[type][idx] = 0xFFFFFFFF;
+ _res->roomoffs[type][idx] = 0xFFFFFFFF;
return 0;
}
dmuFile.seek(4, SEEK_SET);
total_size = dmuFile.readUint32BE();
debugC(DEBUG_SOUND, "dmu file size %d", total_size);
dmuFile.seek(-8, SEEK_CUR);
- dmuFile.read(res.createResource(type, idx, total_size), total_size);
+ dmuFile.read(_res->createResource(type, idx, total_size), total_size);
dmuFile.close();
}
return 1;
@@ -1237,14 +1237,14 @@ int ScummEngine::readSoundResource(int type, int idx) {
_fileHandle->seek(-12, SEEK_CUR);
total_size = _fileHandle->readUint32BE();
_fileHandle->seek(-8, SEEK_CUR);
- ptr = res.createResource(type, idx, total_size);
+ ptr = _res->createResource(type, idx, total_size);
_fileHandle->read(ptr, total_size);
//dumpResource("sound-", idx, ptr);
return 1;
}
error("Unrecognized base tag 0x%08x in sound %d", basetag, idx);
}
- res.roomoffs[type][idx] = 0xFFFFFFFF;
+ _res->roomoffs[type][idx] = 0xFFFFFFFF;
return 0;
}
@@ -1423,7 +1423,7 @@ static byte Mac0ToGMInstrument(uint32 type, int &transpose) {
}
}
-static void convertMac0Resource(ResourceManager &res, int type, int idx, byte *src_ptr, int size) {
+static void convertMac0Resource(ResourceManager *res, int type, int idx, byte *src_ptr, int size) {
/*
From Markus Magnuson (superqult) we got this information:
Mac0
@@ -1476,7 +1476,7 @@ static void convertMac0Resource(ResourceManager &res, int type, int idx, byte *s
*/
#if 0
- byte *ptr = res.createResource(type, idx, size);
+ byte *ptr = _res->createResource(type, idx, size);
memcpy(ptr, src_ptr, size);
#else
const int ppqn = 480;
@@ -1518,7 +1518,7 @@ static void convertMac0Resource(ResourceManager &res, int type, int idx, byte *s
assert(*src_ptr == 0x09);
// Create sound resource
- start_ptr = res.createResource(type, idx, total_size);
+ start_ptr = res->createResource(type, idx, total_size);
// Insert MIDI header
ptr = writeMIDIHeader(start_ptr, "GMD ", ppqn, total_size);
@@ -1614,7 +1614,7 @@ static void convertMac0Resource(ResourceManager &res, int type, int idx, byte *s
#endif
}
-static void convertADResource(ResourceManager &res, const GameSettings& game, int type, int idx, byte *src_ptr, int size) {
+static void convertADResource(ResourceManager *res, const GameSettings& game, int type, int idx, byte *src_ptr, int size) {
// We will ignore the PPQN in the original resource, because
// it's invalid anyway. We use a constant PPQN of 480.
@@ -1625,7 +1625,7 @@ static void convertADResource(ResourceManager &res, const GameSettings& game, in
int total_size = kMIDIHeaderSize + 7 + 8 * sizeof(ADLIB_INSTR_MIDI_HACK) + size;
total_size += 24; // Up to 24 additional bytes are needed for the jump sysex
- ptr = res.createResource(type, idx, total_size);
+ ptr = res->createResource(type, idx, total_size);
src_ptr += 2;
size -= 2;
@@ -2019,7 +2019,7 @@ int ScummEngine::readSoundResourceSmallHeader(int type, int idx) {
_fileHandle->seek(ro_offs + 4, SEEK_SET);
_fileHandle->read(src_ptr, ro_size -4);
- ptr = res.createResource(type, idx, ro_size + 2);
+ ptr = _res->createResource(type, idx, ro_size + 2);
memcpy(ptr, "RO", 2); ptr += 2;
memcpy(ptr, src_ptr, ro_size - 4); ptr += ro_size - 4;
return 1;
@@ -2091,24 +2091,24 @@ int ScummEngine::readSoundResourceSmallHeader(int type, int idx) {
}
ptr = (byte *) calloc(ad_size, 1);
_fileHandle->read(ptr, ad_size);
- convertADResource(res, _game, type, idx, ptr, ad_size);
+ convertADResource(_res, _game, type, idx, ptr, ad_size);
free(ptr);
return 1;
} else if ((_musicType == MDT_PCSPK) && wa_offs != 0) {
if (_game.features & GF_OLD_BUNDLE) {
_fileHandle->seek(wa_offs, SEEK_SET);
- _fileHandle->read(res.createResource(type, idx, wa_size), wa_size);
+ _fileHandle->read(_res->createResource(type, idx, wa_size), wa_size);
} else {
_fileHandle->seek(wa_offs - 6, SEEK_SET);
- _fileHandle->read(res.createResource(type, idx, wa_size + 6), wa_size + 6);
+ _fileHandle->read(_res->createResource(type, idx, wa_size + 6), wa_size + 6);
}
return 1;
} else if (ro_offs != 0) {
_fileHandle->seek(ro_offs - 2, SEEK_SET);
- _fileHandle->read(res.createResource(type, idx, ro_size - 4), ro_size - 4);
+ _fileHandle->read(_res->createResource(type, idx, ro_size - 4), ro_size - 4);
return 1;
}
- res.roomoffs[type][idx] = 0xFFFFFFFF;
+ _res->roomoffs[type][idx] = 0xFFFFFFFF;
return 0;
}
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index e3930c49ab..7ef80eb6ad 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -1022,7 +1022,7 @@ void ScummEngine_v80he::initCharset(int charsetno) {
void ScummEngine::initCharset(int charsetno) {
if (_game.id == GID_FT) {
- if (!res.isResourceLoaded(rtCharset, charsetno))
+ if (!_res->isResourceLoaded(rtCharset, charsetno))
loadCharset(charsetno);
} else {
if (!getResourceAddress(rtCharset, charsetno))
diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp
index a93cc83354..55232a9fd8 100644
--- a/engines/scumm/verbs.cpp
+++ b/engines/scumm/verbs.cpp
@@ -882,7 +882,7 @@ void ScummEngine::killVerb(int slot) {
vs->verbid = 0;
vs->curmode = 0;
- res.nukeResource(rtVerb, slot);
+ _res->nukeResource(rtVerb, slot);
if (_game.version <= 6 && vs->saveid == 0) {
drawVerb(slot, 0);
@@ -910,7 +910,7 @@ void ScummEngine::setVerbObject(uint room, uint object, uint verb) {
if (_objs[i].obj_nr == object) {
findObjectInRoom(&foir, foImageHeader, object, room);
size = READ_LE_UINT16(foir.obim);
- byte *ptr = res.createResource(rtVerb, verb, size + 2);
+ byte *ptr = _res->createResource(rtVerb, verb, size + 2);
obcdptr = getResourceAddress(rtRoom, room) + getOBCDOffs(object);
ptr[0] = *(obcdptr + 9); // Width
ptr[1] = *(obcdptr + 15); // Height
@@ -929,7 +929,7 @@ void ScummEngine::setVerbObject(uint room, uint object, uint verb) {
size = READ_LE_UINT32(foir.obim);
obcdptr = getResourceAddress(rtRoom, room) + getOBCDOffs(object);
size2 = READ_LE_UINT32(obcdptr);
- res.createResource(rtVerb, verb, size + size2);
+ _res->createResource(rtVerb, verb, size + size2);
obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim;
obcdptr = getResourceAddress(rtRoom, room) + getOBCDOffs(object);
memcpy(getResourceAddress(rtVerb, verb), obimptr, size);
@@ -940,7 +940,7 @@ void ScummEngine::setVerbObject(uint room, uint object, uint verb) {
} else {
findObjectInRoom(&foir, foImageHeader, object, room);
size = READ_BE_UINT32(foir.obim + 4);
- res.createResource(rtVerb, verb, size);
+ _res->createResource(rtVerb, verb, size);
obimptr = getResourceAddress(rtRoom, room) - foir.roomptr + foir.obim;
memcpy(getResourceAddress(rtVerb, verb), obimptr, size);
}