aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authormd52011-03-03 19:34:11 +0200
committermd52011-03-03 19:34:11 +0200
commit51437ba5e6e418d7e79cf341606bc6c1c50fd50b (patch)
tree8375cf8727b5af39dc844f3d176afa575b0576b1 /engines/sci
parent1aed9a1f3401477d4d56e278fec63cd90fafd81d (diff)
downloadscummvm-rg350-51437ba5e6e418d7e79cf341606bc6c1c50fd50b.tar.gz
scummvm-rg350-51437ba5e6e418d7e79cf341606bc6c1c50fd50b.tar.bz2
scummvm-rg350-51437ba5e6e418d7e79cf341606bc6c1c50fd50b.zip
SCI: Fixed path finding in Amiga SCI1 games
Added wrapper functions to read/write from dynmem segments, as these are treated as BE in Amiga versions (as we treat them like raw data instead of reg_t's), whereas the rest are LE. Thanks to waltervn and wjp for their help on this
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kpathing.cpp12
-rw-r--r--engines/sci/util.cpp14
-rw-r--r--engines/sci/util.h6
3 files changed, 26 insertions, 6 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index cb70cf91e0..c98d93c2d9 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -264,9 +264,9 @@ struct PathfindingState {
static Common::Point readPoint(SegmentRef list_r, int offset) {
Common::Point point;
- if (list_r.isRaw) {
- point.x = (int16)READ_LE_UINT16(list_r.raw + offset * POLY_POINT_SIZE);
- point.y = (int16)READ_LE_UINT16(list_r.raw + offset * POLY_POINT_SIZE + 2);
+ if (list_r.isRaw) { // dynmem blocks are raw
+ point.x = (int16)READ_SCI1ENDIAN_UINT16(list_r.raw + offset * POLY_POINT_SIZE);
+ point.y = (int16)READ_SCI1ENDIAN_UINT16(list_r.raw + offset * POLY_POINT_SIZE + 2);
} else {
point.x = list_r.reg[offset * 2].toUint16();
point.y = list_r.reg[offset * 2 + 1].toUint16();
@@ -275,9 +275,9 @@ static Common::Point readPoint(SegmentRef list_r, int offset) {
}
static void writePoint(SegmentRef ref, int offset, const Common::Point &point) {
- if (ref.isRaw) {
- WRITE_LE_UINT16(ref.raw + offset * POLY_POINT_SIZE, point.x);
- WRITE_LE_UINT16(ref.raw + offset * POLY_POINT_SIZE + 2, point.y);
+ if (ref.isRaw) { // dynmem blocks are raw
+ WRITE_SCI1ENDIAN_UINT16(ref.raw + offset * POLY_POINT_SIZE, point.x);
+ WRITE_SCI1ENDIAN_UINT16(ref.raw + offset * POLY_POINT_SIZE + 2, point.y);
} else {
ref.reg[offset * 2] = make_reg(0, point.x);
ref.reg[offset * 2 + 1] = make_reg(0, point.y);
diff --git a/engines/sci/util.cpp b/engines/sci/util.cpp
index f6a2465682..6bc08e6b63 100644
--- a/engines/sci/util.cpp
+++ b/engines/sci/util.cpp
@@ -30,6 +30,20 @@
namespace Sci {
+uint16 READ_SCI1ENDIAN_UINT16(const void *ptr) {
+ if (g_sci->getPlatform() == Common::kPlatformAmiga && getSciVersion() >= SCI_VERSION_1_EGA_ONLY && getSciVersion() <= SCI_VERSION_1_LATE)
+ return READ_BE_UINT16(ptr);
+
+ return READ_LE_UINT16(ptr);
+}
+
+void WRITE_SCI1ENDIAN_UINT16(void *ptr, uint16 val) {
+ if (g_sci->getPlatform() == Common::kPlatformAmiga && getSciVersion() >= SCI_VERSION_1_EGA_ONLY && getSciVersion() <= SCI_VERSION_1_LATE)
+ WRITE_BE_UINT16(ptr, val);
+
+ WRITE_LE_UINT16(ptr, val);
+}
+
uint16 READ_SCI11ENDIAN_UINT16(const void *ptr) {
if (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() >= SCI_VERSION_1_1)
return READ_BE_UINT16(ptr);
diff --git a/engines/sci/util.h b/engines/sci/util.h
index d9ced5c9f6..d1f1c2ffa9 100644
--- a/engines/sci/util.h
+++ b/engines/sci/util.h
@@ -30,6 +30,12 @@
namespace Sci {
+// Wrappers for reading/writing integer values for SCI1 Amiga.
+// Amiga versions store big endian data in dynmem blocks, as
+// the game resources are in LE, but the actual system is BE.
+uint16 READ_SCI1ENDIAN_UINT16(const void *ptr);
+void WRITE_SCI1ENDIAN_UINT16(void *ptr, uint16 val);
+
// Wrappers for reading integer values for SCI1.1+.
// Mac versions have big endian data for some fields.
uint16 READ_SCI11ENDIAN_UINT16(const void *ptr);