aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage/core.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2011-04-26 09:25:25 +1000
committerPaul Gilbert2011-04-26 09:25:25 +1000
commit8fddf47e8ca5991b105d748304b64bf32c81c6de (patch)
tree52f9327d92d7043f91ee9b006ebcf64d88925293 /engines/tsage/core.cpp
parent09bf964807d35328a073fad3942a3e89f84c1ea6 (diff)
downloadscummvm-rg350-8fddf47e8ca5991b105d748304b64bf32c81c6de.tar.gz
scummvm-rg350-8fddf47e8ca5991b105d748304b64bf32c81c6de.tar.bz2
scummvm-rg350-8fddf47e8ca5991b105d748304b64bf32c81c6de.zip
TSAGE: Implemented scene priority changes introduced in Ringworld CD & Floppy Demo #2
Diffstat (limited to 'engines/tsage/core.cpp')
-rw-r--r--engines/tsage/core.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp
index 776e449c87..9118df2b15 100644
--- a/engines/tsage/core.cpp
+++ b/engines/tsage/core.cpp
@@ -2667,6 +2667,17 @@ Region::Region(int resNum, int rlbNum, ResourceType ctlType) {
byte *regionData = _resourceManager->getResource(ctlType, resNum, rlbNum);
assert(regionData);
+ load(regionData);
+
+ DEALLOCATE(regionData);
+}
+
+Region::Region(int regionId, const byte *regionData) {
+ _regionId = regionId;
+ load(regionData);
+}
+
+void Region::load(const byte *regionData) {
// Set the region bounds
_bounds.top = READ_LE_UINT16(regionData + 6);
_bounds.left = READ_LE_UINT16(regionData + 8);
@@ -2689,8 +2700,6 @@ Region::Region(int resNum, int rlbNum, ResourceType ctlType) {
_ySlices.push_back(sliceSet);
}
-
- DEALLOCATE(regionData);
}
/**
@@ -3233,18 +3242,27 @@ void ScenePriorities::load(int resNum) {
_resNum = resNum;
clear();
- byte *regionData = _resourceManager->getResource(RES_PRIORITY, resNum, 9999, true);
+ bool altMode = (_vm->getFeatures() & GF_ALT_REGIONS) != 0;
+ byte *regionData = _resourceManager->getResource(RES_PRIORITY, resNum, altMode ? 1 : 9999, true);
+ if (!regionData)
+ return;
- if (regionData) {
- int regionCount = READ_LE_UINT16(regionData);
- for (int regionCtr = 0; regionCtr < regionCount; ++regionCtr) {
+ int regionCount = READ_LE_UINT16(regionData);
+ for (int regionCtr = 0; regionCtr < regionCount; ++regionCtr) {
+ if (altMode) {
+ // Region data is embedded within the resource
+ uint16 regionId = READ_LE_UINT16(regionData + regionCtr * 6 + 2);
+ uint32 dataOffset = READ_LE_UINT32(regionData + regionCtr * 6 + 4);
+ push_back(Region(regionId, regionData + dataOffset));
+ } else {
+ // The data contains the index of another resource containing the region data
int rlbNum = READ_LE_UINT16(regionData + regionCtr * 6 + 2);
push_back(Region(resNum, rlbNum, RES_PRIORITY));
}
-
- DEALLOCATE(regionData);
}
+
+ DEALLOCATE(regionData);
}
Region *ScenePriorities::find(int priority) {
@@ -3255,7 +3273,7 @@ Region *ScenePriorities::find(int priority) {
if (priority > 255)
priority = 255;
- // Loop through the regions to find the closest for the givne priority level
+ // Loop through the regions to find the closest for the given priority level
int minRegionId = 9998;
Region *region = NULL;
for (ScenePriorities::iterator i = begin(); i != end(); ++i) {