aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorTravis Howell2006-01-27 00:27:57 +0000
committerTravis Howell2006-01-27 00:27:57 +0000
commite370d8525419c8b9e47b423384b1169602cc6bb4 (patch)
tree4eb33a39a72bab1ac5ba299838fc83bc03a5a29c /scumm
parente9903522196176c24a6adb973355631b7d3938e3 (diff)
downloadscummvm-rg350-e370d8525419c8b9e47b423384b1169602cc6bb4.tar.gz
scummvm-rg350-e370d8525419c8b9e47b423384b1169602cc6bb4.tar.bz2
scummvm-rg350-e370d8525419c8b9e47b423384b1169602cc6bb4.zip
Make resource management of modified wizImages closer to original games.
Fixes many errors in Backyard Sports titles. svn-id: r20201
Diffstat (limited to 'scumm')
-rw-r--r--scumm/floodfill_he.cpp4
-rw-r--r--scumm/resource.cpp26
-rw-r--r--scumm/script_v100he.cpp6
-rw-r--r--scumm/script_v7he.cpp1
-rw-r--r--scumm/scumm.h5
-rw-r--r--scumm/wiz_he.cpp51
-rw-r--r--scumm/wiz_he.h1
7 files changed, 65 insertions, 29 deletions
diff --git a/scumm/floodfill_he.cpp b/scumm/floodfill_he.cpp
index 6bed8f8785..54ad927cdd 100644
--- a/scumm/floodfill_he.cpp
+++ b/scumm/floodfill_he.cpp
@@ -22,9 +22,10 @@
#include "common/stdafx.h"
+#include "scumm/floodfill_he.h"
#include "scumm/intern.h"
+#include "scumm/resource.h"
#include "scumm/scumm.h"
-#include "scumm/floodfill_he.h"
namespace Scumm {
@@ -285,6 +286,7 @@ void Wiz::fillWizFlood(const WizParameters *params) {
}
}
}
+ _vm->res.setModified(rtImage, params->img.resNum);
}
} // End of namespace Scumm
diff --git a/scumm/resource.cpp b/scumm/resource.cpp
index b5c505ec5a..5f232a8969 100644
--- a/scumm/resource.cpp
+++ b/scumm/resource.cpp
@@ -40,7 +40,9 @@ namespace Scumm {
enum {
RF_LOCK = 0x80,
RF_USAGE = 0x7F,
- RF_USAGE_MAX = RF_USAGE
+ RF_USAGE_MAX = RF_USAGE,
+
+ RS_MODIFIED = 0x10
};
@@ -623,6 +625,7 @@ void ScummEngine::allocResTypeData(int id, uint32 tag, int num, const char *name
res.name[id] = name;
res.address[id] = (byte **)calloc(num, sizeof(void *));
res.flags[id] = (byte *)calloc(num, sizeof(byte));
+ res.status[id] = (byte *)calloc(num, sizeof(byte));
if (mode) {
res.roomno[id] = (byte *)calloc(num, sizeof(byte));
@@ -1000,6 +1003,8 @@ bool ScummEngine::isResourceInUse(int type, int i) const {
return _sound->isSoundInUse(i);
case rtCharset:
return _charset->getCurID() == i;
+ case rtImage:
+ return res.isModified(type, i) != 0;
case rtSpoolBuffer:
return _sound->isSoundRunning(10000 + i) != 0;
default:
@@ -1007,6 +1012,24 @@ bool ScummEngine::isResourceInUse(int type, int i) const {
}
}
+void ResourceManager::setModified(int type, int i) {
+ if (!validateResource("Modified", type, i))
+ return;
+ status[type][i] |= RS_MODIFIED;
+}
+
+void ResourceManager::setUnModified(int type, int i) {
+ if (!validateResource("Modified", type, i))
+ return;
+ status[type][i] &= ~RS_MODIFIED;
+}
+
+bool ResourceManager::isModified(int type, int i) const {
+ if (!validateResource("isModified", type, i))
+ return false;
+ return (status[type][i] & RS_MODIFIED) != 0;
+}
+
void ResourceManager::expireResources(uint32 size) {
int i, j;
byte flag;
@@ -1059,6 +1082,7 @@ void ResourceManager::freeResources() {
}
free(address[i]);
free(flags[i]);
+ free(status[i]);
free(roomno[i]);
free(roomoffs[i]);
diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp
index bfd24c9790..f1ede6f4b7 100644
--- a/scumm/script_v100he.cpp
+++ b/scumm/script_v100he.cpp
@@ -1119,10 +1119,12 @@ void ScummEngine_v100he::o100_resourceRoutines() {
}
break;
case 133:
- if (_heResType == rtCharset)
+ if (_heResType == rtCharset) {
nukeCharset(_heResId);
- else
+ } else {
+ res.setUnModified(_heResType, _heResId);
res.nukeResource(_heResType, _heResId);
+ }
break;
case 134:
case 135:
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index 5fa56605d1..a99ee1c95f 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -631,6 +631,7 @@ void ScummEngine_v70he::o70_resourceRoutines() {
break;
case 192:
resid = pop();
+ res.setUnModified(rtImage, resid);
res.nukeResource(rtImage, resid);
break;
case 201:
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 157068628a..82278dc595 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -327,6 +327,7 @@ public:
byte **address[rtNumTypes];
protected:
byte *flags[rtNumTypes];
+ byte *status[rtNumTypes];
public:
byte *roomno[rtNumTypes];
uint32 *roomoffs[rtNumTypes];
@@ -350,6 +351,10 @@ public:
void unlock(int type, int i);
bool isLocked(int type, int i) const;
+ void setModified(int type, int i);
+ void setUnModified(int type, int i);
+ bool isModified(int type, int i) const;
+
void setResourceCounter(int type, int index, byte flag);
void increaseResourceCounter();
diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp
index 33c41eea0a..af8db52081 100644
--- a/scumm/wiz_he.cpp
+++ b/scumm/wiz_he.cpp
@@ -918,6 +918,7 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in
break;
}
}
+ _vm->res.setModified(rtImage, resNum);
}
void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) {
@@ -1441,18 +1442,7 @@ void Wiz::displayWizComplexImage(const WizParameters *params) {
dstResNum = params->dstResNum;
}
if (params->processFlags & kWPFRemapPalette) {
- int st = (params->processFlags & kWPFNewState) ? params->img.state : 0;
- int num = params->remapNum;
- const uint8 *index = params->remapIndex;
- uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
- assert(iwiz);
- uint8 *rmap = _vm->findWrappedBlock(MKID('RMAP'), iwiz, st, 0) ;
- assert(rmap);
- WRITE_BE_UINT32(rmap, 0x01234567);
- while (num--) {
- uint8 idx = *index++;
- rmap[4 + idx] = params->remapColor[idx];
- }
+ remapWizImagePal(params);
flags |= kWIFRemapPalette;
}
@@ -1556,6 +1546,7 @@ void Wiz::createWizEmptyImage(const WizParameters *params) {
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, params->img.resNum);
}
void Wiz::fillWizRect(const WizParameters *params) {
@@ -1600,6 +1591,7 @@ void Wiz::fillWizRect(const WizParameters *params) {
}
}
}
+ _vm->res.setModified(rtImage, params->img.resNum);
}
void Wiz::fillWizLine(const WizParameters *params) {
@@ -1691,6 +1683,7 @@ void Wiz::fillWizLine(const WizParameters *params) {
}
}
}
+ _vm->res.setModified(rtImage, params->img.resNum);
}
void Wiz::fillWizPixel(const WizParameters *params) {
@@ -1727,6 +1720,23 @@ void Wiz::fillWizPixel(const WizParameters *params) {
}
}
}
+ _vm->res.setModified(rtImage, params->img.resNum);
+}
+
+void Wiz::remapWizImagePal(const WizParameters *params) {
+ int st = (params->processFlags & kWPFNewState) ? params->img.state : 0;
+ int num = params->remapNum;
+ const uint8 *index = params->remapIndex;
+ uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
+ assert(iwiz);
+ uint8 *rmap = _vm->findWrappedBlock(MKID('RMAP'), iwiz, st, 0) ;
+ assert(rmap);
+ WRITE_BE_UINT32(rmap, 0x01234567);
+ while (num--) {
+ uint8 idx = *index++;
+ rmap[4 + idx] = params->remapColor[idx];
+ }
+ _vm->res.setModified(rtImage, params->img.resNum);
}
void Wiz::processWizImage(const WizParameters *params) {
@@ -1767,7 +1777,7 @@ void Wiz::processWizImage(const WizParameters *params) {
_vm->VAR(_vm->VAR_GAME_LOADED) = -2;
_vm->VAR(119) = -2;
} else {
- _vm->res.lock(rtImage, params->img.resNum);
+ _vm->res.setModified(rtImage, params->img.resNum);
_vm->VAR(_vm->VAR_GAME_LOADED) = 0;
_vm->VAR(119) = 0;
}
@@ -1824,24 +1834,14 @@ void Wiz::processWizImage(const WizParameters *params) {
break;
case 6:
if (params->processFlags & kWPFRemapPalette) {
- int state = (params->processFlags & kWPFNewState) ? params->img.state : 0;
- int num = params->remapNum;
- const uint8 *index = params->remapIndex;
- uint8 *iwiz = _vm->getResourceAddress(rtImage, params->img.resNum);
- assert(iwiz);
- uint8 *rmap = _vm->findWrappedBlock(MKID('RMAP'), iwiz, state, 0) ;
- assert(rmap);
- WRITE_BE_UINT32(rmap, 0x01234567);
- while (num--) {
- uint8 idx = *index++;
- rmap[4 + idx] = params->remapColor[idx];
- }
+ remapWizImagePal(params);
}
break;
// HE 99+
case 7:
// Used in PuttsFunShop/SamsFunShop/soccer2004
// TODO: Capture polygon
+ _vm->res.setModified(rtImage, params->img.resNum);
break;
case 8:
createWizEmptyImage(params);
@@ -1877,6 +1877,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);
break;
default:
error("Unhandled processWizImage mode %d", params->processMode);
diff --git a/scumm/wiz_he.h b/scumm/wiz_he.h
index 2a62b7ee48..88de19bc5b 100644
--- a/scumm/wiz_he.h
+++ b/scumm/wiz_he.h
@@ -166,6 +166,7 @@ public:
void fillWizLine(const WizParameters *params);
void fillWizPixel(const WizParameters *params);
void fillWizFlood(const WizParameters *params);
+ void remapWizImagePal(const WizParameters *params);
void getWizImageDim(int resNum, int state, int32 &w, int32 &h);
int getWizImageStates(int resnum);