aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/script_v6.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index c7262fa485..610b28fd3f 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -483,6 +483,8 @@ int ScummEngine_v6::findFreeArrayId() {
return -1;
}
+#define SWAP16(x) x = SWAP_BYTES_16(x)
+
ArrayHeader *ScummEngine_v6::getArray(int array) {
ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, readVar(array));
if (!ah)
@@ -492,10 +494,10 @@ ArrayHeader *ScummEngine_v6::getArray(int array) {
// endianness, instead of a fixed endianness. We try to detect savegames
// which were created on a big endian system and convert them to little
// endian.
- if ((ah->dim1 & 0xF000) || (ah->dim2 & 0xF000) || (ah->type & 0xFF00)) {
- SWAP_BYTES_16(ah->dim1);
- SWAP_BYTES_16(ah->dim2);
- SWAP_BYTES_16(ah->type);
+ if ((FROM_LE_16(ah->dim1) & 0xF000) || (FROM_LE_16(ah->dim2) & 0xF000) || (FROM_LE_16(ah->type) & 0xFF00)) {
+ SWAP16(ah->dim1);
+ SWAP16(ah->dim2);
+ SWAP16(ah->type);
}
return ah;
@@ -519,7 +521,6 @@ int ScummEngine_v6::readArray(int array, int idx, int base) {
return 0;
}
-
const int offset = base + idx * FROM_LE_16(ah->dim1);
if (offset < 0 || offset >= FROM_LE_16(ah->dim1) * FROM_LE_16(ah->dim2)) {